summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarol Skocik <karol@lshift.net>2008-08-08 15:40:35 +0100
committerKarol Skocik <karol@lshift.net>2008-08-08 15:40:35 +0100
commit3977f113790eb941acd9ec3ae042bc463c246852 (patch)
treea21e0a6993f4ec3d989687eaa35cf48a44bdc277
parenta67888aae70064de7f3ec8f9ede640f2ffa1f9c8 (diff)
downloadrabbitmq-server-3977f113790eb941acd9ec3ae042bc463c246852.tar.gz
added mapping which decides how to convert Python value to Erlang default value
-rw-r--r--codegen.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/codegen.py b/codegen.py
index 1cad996a..7d830efa 100644
--- a/codegen.py
+++ b/codegen.py
@@ -45,6 +45,13 @@ erlangTypeMap = {
'timestamp': 'timestamp',
}
+erlangDefaultValueTypeConvMap = {
+ bool : lambda x: str(x).lower(),
+ str : lambda x: "<<" + x + ">>",
+ int : lambda x: str(x),
+ float : lambda x: str(x)
+}
+
def erlangize(s):
s = s.replace('-', '_')
s = s.replace(' ', '_')
@@ -276,7 +283,8 @@ def genHrl(spec):
def fillField(field):
result = erlangize(f.name)
if field.defaultvalue != None:
- result += ' = ' + field.defaultvalue
+ conv_fn = erlangDefaultValueTypeConvMap[type(field.defaultvalue)]
+ result += ' = ' + conv_fn(field.defaultvalue)
return result
return ', '.join([fillField(f) for f in fields])