diff options
author | Matthew Sackman <matthew@rabbitmq.com> | 2010-11-09 15:08:51 +0000 |
---|---|---|
committer | Matthew Sackman <matthew@rabbitmq.com> | 2010-11-09 15:08:51 +0000 |
commit | 66557f7656d01aa2928ec6cd3b13fe732c92755f (patch) | |
tree | 03a2d38280600d52684ed0d8693a470beb930b43 | |
parent | 7ed10703eeea9379736e32cec751f23c3393aa4c (diff) | |
parent | 74e980e8b5751bff916ce505eb23edc3b44edd3e (diff) | |
download | rabbitmq-server-66557f7656d01aa2928ec6cd3b13fe732c92755f.tar.gz |
Merging bug23480 into default
-rw-r--r-- | codegen.py | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -240,8 +240,6 @@ 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 @@ -278,8 +276,7 @@ def genErl(spec): 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 == '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) + print " F%dLen = shortstr_size(F%d)," % (f.index, f.index) elif type == 'longstr': print " F%dLen = size(F%d)," % (f.index, f.index) else: @@ -426,6 +423,12 @@ def genErl(spec): bitvalue(true) -> 1; bitvalue(false) -> 0; bitvalue(undefined) -> 0. + +shortstr_size(S) -> + case size(S) of + Len when Len =< 255 -> Len; + _ -> exit(method_field_shortstr_overflow) + end. """ version = "{%d, %d, %d}" % (spec.major, spec.minor, spec.revision) if version == '{8, 0, 0}': version = '{0, 8, 0}' |