summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Garnock-Jones <tonyg@lshift.net>2008-07-03 13:46:09 +0100
committerTony Garnock-Jones <tonyg@lshift.net>2008-07-03 13:46:09 +0100
commita67888aae70064de7f3ec8f9ede640f2ffa1f9c8 (patch)
treebcc3dad259c156d12a8d52d24afb20cd723950e7
parent675869a27714307bce377638dfe8f6a5f069e757 (diff)
downloadrabbitmq-server-a67888aae70064de7f3ec8f9ede640f2ffa1f9c8.tar.gz
Migrate branch bug17070
-rw-r--r--codegen.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/codegen.py b/codegen.py
index 242c2418..1cad996a 100644
--- a/codegen.py
+++ b/codegen.py
@@ -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)
-
-
-