diff options
author | Tony Garnock-Jones <tonyg@lshift.net> | 2008-07-03 13:46:09 +0100 |
---|---|---|
committer | Tony Garnock-Jones <tonyg@lshift.net> | 2008-07-03 13:46:09 +0100 |
commit | a67888aae70064de7f3ec8f9ede640f2ffa1f9c8 (patch) | |
tree | bcc3dad259c156d12a8d52d24afb20cd723950e7 | |
parent | 675869a27714307bce377638dfe8f6a5f069e757 (diff) | |
download | rabbitmq-server-a67888aae70064de7f3ec8f9ede640f2ffa1f9c8.tar.gz |
Migrate branch bug17070
-rw-r--r-- | codegen.py | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -271,6 +271,14 @@ def genHrl(spec): def fieldNameList(fields): return ', '.join([erlangize(f.name) for f in fields]) + + def fieldNameListDefaults(fields): + def fillField(field): + result = erlangize(f.name) + if field.defaultvalue != None: + result += ' = ' + field.defaultvalue + return result + return ', '.join([fillField(f) for f in fields]) methods = spec.allMethods() @@ -283,23 +291,18 @@ def genHrl(spec): print "%% Method field records." for m in methods: - print "-record(%s, {%s})." % (m.erlangName(), fieldNameList(m.arguments)) + print "-record(%s, {%s})." % (m.erlangName(), fieldNameListDefaults(m.arguments)) print "%% Class property records." for c in spec.allClasses(): print "-record('P_%s', {%s})." % (erlangize(c.name), fieldNameList(c.fields)) -#--------------------------------------------------------------------------- - def generateErl(specPath): genErl(AmqpSpec(specPath)) def generateHrl(specPath): genHrl(AmqpSpec(specPath)) - + if __name__ == "__main__": do_main(generateHrl, generateErl) - - - |