diff options
| author | Vlad Ionescu <vlad@lshift.net> | 2010-05-14 18:28:07 +0100 |
|---|---|---|
| committer | Vlad Ionescu <vlad@lshift.net> | 2010-05-14 18:28:07 +0100 |
| commit | ba24177421fecdfb30defb32b46268b1ba60cfcb (patch) | |
| tree | 79e1f8c435207a01e018021170af9ef970f88b07 /codegen.py | |
| parent | 87556da94328e5dec49f113304189309faa37402 (diff) | |
| parent | 44fe8d966f437ab4778049deaf1bd50a5eddec59 (diff) | |
| download | rabbitmq-server-git-ba24177421fecdfb30defb32b46268b1ba60cfcb.tar.gz | |
merging in from default
Diffstat (limited to 'codegen.py')
| -rw-r--r-- | codegen.py | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/codegen.py b/codegen.py index 60caf060f4..a24a32ff37 100644 --- a/codegen.py +++ b/codegen.py @@ -18,11 +18,11 @@ ## are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial ## Technologies LLC, and Rabbit Technologies Ltd. ## -## Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +## Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift ## Ltd. Portions created by Cohesive Financial Technologies LLC are -## Copyright (C) 2007-2009 Cohesive Financial Technologies +## Copyright (C) 2007-2010 Cohesive Financial Technologies ## LLC. Portions created by Rabbit Technologies Ltd are Copyright -## (C) 2007-2009 Rabbit Technologies Ltd. +## (C) 2007-2010 Rabbit Technologies Ltd. ## ## All Rights Reserved. ## @@ -118,17 +118,17 @@ def printFileHeader(): %% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial %% Technologies LLC, and Rabbit Technologies Ltd. %% -%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift +%% Portions created by LShift Ltd are Copyright (C) 2007-2010 LShift %% Ltd. Portions created by Cohesive Financial Technologies LLC are -%% Copyright (C) 2007-2009 Cohesive Financial Technologies +%% Copyright (C) 2007-2010 Cohesive Financial Technologies %% LLC. Portions created by Rabbit Technologies Ltd are Copyright -%% (C) 2007-2009 Rabbit Technologies Ltd. +%% (C) 2007-2010 Rabbit Technologies Ltd. %% %% All Rights Reserved. %% %% Contributor(s): ______________________________________. %%""" - + def genErl(spec): def erlType(domain): return erlangTypeMap[spec.resolveDomain(domain)] @@ -156,7 +156,7 @@ def genErl(spec): def genMethodHasContent(m): print "method_has_content(%s) -> %s;" % (m.erlangName(), str(m.hasContent).lower()) - + def genMethodIsSynchronous(m): hasNoWait = "nowait" in fieldNameList(m.arguments) if m.isSynchronous and hasNoWait: @@ -219,9 +219,14 @@ def genErl(spec): elif type == 'table': print " F%d = rabbit_binary_parser:parse_table(F%dTab)," % \ (f.index, f.index) + elif type == 'shortstr': + print " if F%dLen > 255 -> exit(method_field_shortstr_overflow); true -> ok end," % (f.index) else: pass + def genMethodRecord(m): + print "method_record(%s) -> #%s{};" % (m.erlangName(), m.erlangName()) + def genDecodeMethodFields(m): packedFields = packMethodFields(m.arguments) binaryPattern = ', '.join([methodFieldFragment(f) for f in packedFields]) @@ -251,7 +256,10 @@ def genErl(spec): elif type == 'table': print " F%dTab = rabbit_binary_generator:generate_table(F%d)," % (f.index, f.index) print " F%dLen = size(F%dTab)," % (f.index, f.index) - elif type in ['shortstr', 'longstr']: + elif type == 'shortstr': + print " F%dLen = size(F%d)," % (f.index, f.index) + print " if F%dLen > 255 -> exit(method_field_shortstr_overflow); true -> ok end," % (f.index) + elif type == 'longstr': print " F%dLen = size(F%d)," % (f.index, f.index) else: pass @@ -300,6 +308,7 @@ def genErl(spec): -export([method_id/1]). -export([method_has_content/1]). -export([is_method_synchronous/1]). +-export([method_record/1]). -export([method_fieldnames/1]). -export([decode_method_fields/2]). -export([decode_properties/2]). @@ -327,6 +336,9 @@ bitvalue(undefined) -> 0. for m in methods: genMethodIsSynchronous(m) print "is_method_synchronous(Name) -> exit({unknown_method_name, Name})." + for m in methods: genMethodRecord(m) + print "method_record(Name) -> exit({unknown_method_name, Name})." + for m in methods: genMethodFieldNames(m) print "method_fieldnames(Name) -> exit({unknown_method_name, Name})." @@ -366,7 +378,7 @@ def genHrl(spec): result += ' = ' + conv_fn(field.defaultvalue) return result return ', '.join([fillField(f) for f in fields]) - + methods = spec.allMethods() printFileHeader() @@ -390,7 +402,7 @@ def generateErl(specPath): def generateHrl(specPath): genHrl(AmqpSpec(specPath)) - + if __name__ == "__main__": do_main(generateHrl, generateErl) |
