summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Hood <0x6e6562@gmail.com>2009-11-05 15:11:41 +0000
committerBen Hood <0x6e6562@gmail.com>2009-11-05 15:11:41 +0000
commit8fc025bd1df07f429ee442363fc131355147e58f (patch)
tree700eab5983fbcdde0e3807f11b9aa069233d0e73
parent3e86a1b9881957309d432c8b2e5f295a07f8f920 (diff)
parent1dd1714e10a70ac0765f3062e79d23e00ade2000 (diff)
downloadrabbitmq-server-8fc025bd1df07f429ee442363fc131355147e58f.tar.gz
Merged bug21775 into default
-rw-r--r--codegen.py27
1 files changed, 24 insertions, 3 deletions
diff --git a/codegen.py b/codegen.py
index 533192c5..1c5b2b54 100644
--- a/codegen.py
+++ b/codegen.py
@@ -228,12 +228,12 @@ def genErl(spec):
print " rabbit_binary_generator:encode_properties(%s, %s);" % \
(fieldTypeList(c.fields), fieldTempList(c.fields))
- def massageConstantClass(cls):
+ def messageConstantClass(cls):
# We do this because 0.8 uses "soft error" and 8.1 uses "soft-error".
return erlangConstantName(cls)
def genLookupException(c,v,cls):
- mCls = massageConstantClass(cls)
+ mCls = messageConstantClass(cls)
if mCls == 'SOFT_ERROR': genLookupException1(c,'false')
elif mCls == 'HARD_ERROR': genLookupException1(c, 'true')
elif mCls == '': pass
@@ -244,6 +244,20 @@ def genErl(spec):
print 'lookup_amqp_exception(%s) -> {%s, ?%s, <<"%s">>};' % \
(n.lower(), hardErrorBoolStr, n, n)
+ def genIsAmqpHardErrorCode(c,v,cls):
+ mCls = messageConstantClass(cls)
+ if mCls == 'SOFT_ERROR' : genIsAmqpHardErrorCode1(c,'false')
+ elif mCls == 'HARD_ERROR' : genIsAmqpHardErrorCode1(c,'true')
+ elif mCls == '' : pass
+ else: raise 'Unkown constant class', cls
+
+ def genIsAmqpHardErrorCode1(c,hardErrorBoolStr):
+ n = erlangConstantName(c)
+ print 'is_amqp_hard_error_code(?%s) -> %s;' % \
+ (n, hardErrorBoolStr)
+ print 'is_amqp_hard_error_code(%s) -> %s;' % \
+ (n.lower(), hardErrorBoolStr)
+
methods = spec.allMethods()
print """-module(rabbit_framing).
@@ -260,6 +274,7 @@ def genErl(spec):
-export([encode_method_fields/1]).
-export([encode_properties/1]).
-export([lookup_amqp_exception/1]).
+-export([is_amqp_hard_error_code/1]).
bitvalue(true) -> 1;
bitvalue(false) -> 0;
@@ -296,8 +311,14 @@ bitvalue(undefined) -> 0.
for (c,v,cls) in spec.constants: genLookupException(c,v,cls)
print "lookup_amqp_exception(Code) ->"
print " rabbit_log:warning(\"Unknown AMQP error code '~p'~n\", [Code]),"
- print " {true, ?INTERNAL_ERROR, <<\"INTERNAL_ERROR\">>}."
+ print " {true, ?INTERNAL_ERROR, <<\"INTERNAL_ERROR\">>}."
+ for(c,v,cls) in spec.constants: genIsAmqpHardErrorCode(c,v,cls)
+ print "is_amqp_hard_error_code(Code) when is_integer(Code) ->"
+ print " true;"
+ print "is_amqp_hard_error_code(Code) ->"
+ print " rabbit_log:warning(\"Unknown AMQP error code '~p'~n\", [Code]),"
+ print " true."
def genHrl(spec):
def erlType(domain):