From fa23928896317362b07d395c9c8d52e366b04fcb Mon Sep 17 00:00:00 2001 From: Matthew Sackman Date: Wed, 27 Jan 2010 12:42:24 +0000 Subject: Added method_record to codegen.py for the shovel --- codegen.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/codegen.py b/codegen.py index 6f39574f..44559731 100644 --- a/codegen.py +++ b/codegen.py @@ -126,7 +126,7 @@ def printFileHeader(): %% %% Contributor(s): ______________________________________. %%""" - + def genErl(spec): def erlType(domain): return erlangTypeMap[spec.resolveDomain(domain)] @@ -151,7 +151,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: @@ -217,6 +217,9 @@ def genErl(spec): 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]) @@ -294,6 +297,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]). @@ -318,6 +322,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})." @@ -357,7 +364,7 @@ def genHrl(spec): result += ' = ' + conv_fn(field.defaultvalue) return result return ', '.join([fillField(f) for f in fields]) - + methods = spec.allMethods() printFileHeader() @@ -381,7 +388,7 @@ def generateErl(specPath): def generateHrl(specPath): genHrl(AmqpSpec(specPath)) - + if __name__ == "__main__": do_main(generateHrl, generateErl) -- cgit v1.2.1 From 8d31dbdf26909669395c850e4d1b4152ca854b8f Mon Sep 17 00:00:00 2001 From: Matthew Sackman Date: Fri, 29 Jan 2010 13:11:19 +0000 Subject: Need to be able to verify that the response got back from the server is ok, when declaring resources. --- codegen.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/codegen.py b/codegen.py index 44559731..ece768a9 100644 --- a/codegen.py +++ b/codegen.py @@ -166,6 +166,14 @@ def genErl(spec): def genMethodFieldNames(m): print "method_fieldnames(%s) -> %s;" % (m.erlangName(), fieldNameList(m.arguments)) + def genMethodCallResponse(m, methods): + if not m.erlangName().endswith("_ok'"): + responseName = "'" + erlangize(m.klass.name) + '.' + erlangize(m.name) + "_ok'" + filtered = filter(lambda n: n.erlangName() == responseName, methods) + if len(filtered) == 1: + print "method_call_and_response(#%s{}, #%s{}) -> true;" % (m.erlangName(), + responseName) + def packMethodFields(fields): packed = [] bitfield = None @@ -299,6 +307,7 @@ def genErl(spec): -export([is_method_synchronous/1]). -export([method_record/1]). -export([method_fieldnames/1]). +-export([method_call_and_response/2]). -export([decode_method_fields/2]). -export([decode_properties/2]). -export([encode_method_fields/1]). @@ -328,6 +337,9 @@ bitvalue(undefined) -> 0. for m in methods: genMethodFieldNames(m) print "method_fieldnames(Name) -> exit({unknown_method_name, Name})." + for m in methods: genMethodCallResponse(m, methods) + print "method_call_and_response(_Call, _Response) -> false." + for m in methods: genDecodeMethodFields(m) print "decode_method_fields(Name, BinaryFields) ->" print " rabbit_misc:frame_error(Name, BinaryFields)." -- cgit v1.2.1 From 1ec6d9783f58dfb889c2fdb119f709351577ecc4 Mon Sep 17 00:00:00 2001 From: Matthew Sackman Date: Fri, 29 Jan 2010 14:12:09 +0000 Subject: Remove the response verification as errors should cause the channel or connection to be closed --- codegen.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/codegen.py b/codegen.py index ece768a9..44559731 100644 --- a/codegen.py +++ b/codegen.py @@ -166,14 +166,6 @@ def genErl(spec): def genMethodFieldNames(m): print "method_fieldnames(%s) -> %s;" % (m.erlangName(), fieldNameList(m.arguments)) - def genMethodCallResponse(m, methods): - if not m.erlangName().endswith("_ok'"): - responseName = "'" + erlangize(m.klass.name) + '.' + erlangize(m.name) + "_ok'" - filtered = filter(lambda n: n.erlangName() == responseName, methods) - if len(filtered) == 1: - print "method_call_and_response(#%s{}, #%s{}) -> true;" % (m.erlangName(), - responseName) - def packMethodFields(fields): packed = [] bitfield = None @@ -307,7 +299,6 @@ def genErl(spec): -export([is_method_synchronous/1]). -export([method_record/1]). -export([method_fieldnames/1]). --export([method_call_and_response/2]). -export([decode_method_fields/2]). -export([decode_properties/2]). -export([encode_method_fields/1]). @@ -337,9 +328,6 @@ bitvalue(undefined) -> 0. for m in methods: genMethodFieldNames(m) print "method_fieldnames(Name) -> exit({unknown_method_name, Name})." - for m in methods: genMethodCallResponse(m, methods) - print "method_call_and_response(_Call, _Response) -> false." - for m in methods: genDecodeMethodFields(m) print "decode_method_fields(Name, BinaryFields) ->" print " rabbit_misc:frame_error(Name, BinaryFields)." -- cgit v1.2.1 From 7fc3228a0ede49b24ec8b1ce90433e05577c701b Mon Sep 17 00:00:00 2001 From: Matthew Sackman Date: Wed, 17 Feb 2010 15:56:38 +0000 Subject: Add support for extracting field names for class properties --- codegen.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/codegen.py b/codegen.py index 91c70e81..d3b70d6c 100644 --- a/codegen.py +++ b/codegen.py @@ -291,6 +291,9 @@ def genErl(spec): print 'amqp_exception(?%s) -> %s;' % \ (n, n.lower()) + def genClassPropsFieldnames(cls): + print "class_properties_fieldnames('P_%s') -> %s;" % (erlangize(cls.name), fieldNameList(cls.fields)) + methods = spec.allMethods() printFileHeader() @@ -310,6 +313,7 @@ def genErl(spec): -export([encode_properties/1]). -export([lookup_amqp_exception/1]). -export([amqp_exception/1]). +-export([class_properties_fieldnames/1]). bitvalue(true) -> 1; bitvalue(false) -> 0; @@ -354,6 +358,9 @@ bitvalue(undefined) -> 0. for(c,v,cls) in spec.constants: genAmqpException(c,v,cls) print "amqp_exception(_Code) -> undefined." + for c in spec.allClasses(): genClassPropsFieldnames(c) + print "class_properties_fieldnames(PropName) -> exit({unknown_class_properties_name, PropName})." + def genHrl(spec): def erlType(domain): return erlangTypeMap[spec.resolveDomain(domain)] -- cgit v1.2.1 From ac7293c3d70b6962886ebb17e92d238850417f1c Mon Sep 17 00:00:00 2001 From: Matthew Sackman Date: Wed, 17 Feb 2010 16:05:40 +0000 Subject: Backed out changeset 4922b15fa148 as it's not needed. --- codegen.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/codegen.py b/codegen.py index d3b70d6c..91c70e81 100644 --- a/codegen.py +++ b/codegen.py @@ -291,9 +291,6 @@ def genErl(spec): print 'amqp_exception(?%s) -> %s;' % \ (n, n.lower()) - def genClassPropsFieldnames(cls): - print "class_properties_fieldnames('P_%s') -> %s;" % (erlangize(cls.name), fieldNameList(cls.fields)) - methods = spec.allMethods() printFileHeader() @@ -313,7 +310,6 @@ def genErl(spec): -export([encode_properties/1]). -export([lookup_amqp_exception/1]). -export([amqp_exception/1]). --export([class_properties_fieldnames/1]). bitvalue(true) -> 1; bitvalue(false) -> 0; @@ -358,9 +354,6 @@ bitvalue(undefined) -> 0. for(c,v,cls) in spec.constants: genAmqpException(c,v,cls) print "amqp_exception(_Code) -> undefined." - for c in spec.allClasses(): genClassPropsFieldnames(c) - print "class_properties_fieldnames(PropName) -> exit({unknown_class_properties_name, PropName})." - def genHrl(spec): def erlType(domain): return erlangTypeMap[spec.resolveDomain(domain)] -- cgit v1.2.1