diff options
author | Karol Skocik <karol@lshift.net> | 2008-08-08 15:40:35 +0100 |
---|---|---|
committer | Karol Skocik <karol@lshift.net> | 2008-08-08 15:40:35 +0100 |
commit | 3977f113790eb941acd9ec3ae042bc463c246852 (patch) | |
tree | a21e0a6993f4ec3d989687eaa35cf48a44bdc277 | |
parent | a67888aae70064de7f3ec8f9ede640f2ffa1f9c8 (diff) | |
download | rabbitmq-server-3977f113790eb941acd9ec3ae042bc463c246852.tar.gz |
added mapping which decides how to convert Python value to Erlang default value
-rw-r--r-- | codegen.py | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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]) |