diff options
author | Matthias Radestock <matthias@rabbitmq.com> | 2012-11-05 17:24:58 +0000 |
---|---|---|
committer | Matthias Radestock <matthias@rabbitmq.com> | 2012-11-05 17:24:58 +0000 |
commit | d7432000dfda38dec0f42fd8729058f06c38521d (patch) | |
tree | 1d0816b404f4588daed3e7f120f93c38944faa7e /codegen.py | |
parent | c0574c50ecf4250df2900c96cdcd1cc27de4baa9 (diff) | |
download | rabbitmq-server-d7432000dfda38dec0f42fd8729058f06c38521d.tar.gz |
switch back to using macrosbug25269
in order to eek out a bit more performance
but at least make the macro signature uniform and pull out the conditional
Diffstat (limited to 'codegen.py')
-rw-r--r-- | codegen.py | 38 |
1 files changed, 25 insertions, 13 deletions
@@ -235,8 +235,8 @@ def genErl(spec): return '<<' + ps + ', _:%d, R0/binary>>' % (16 - len(fields),) def writePropFieldLine(field): i = str(field.index) - print " {F%s, R%s} = if P%s =:= 0 -> {undefined, R%s}; true -> %s_prop(R%s) end," % \ - (i, str(field.index + 1), i, i, erlType(field.domain), i) + print " {F%s, R%s} = if P%s =:= 0 -> {undefined, R%s}; true -> ?%s_PROP(R%s, L%s, V%s, X%s) end," % \ + (i, str(field.index + 1), i, i, erlType(field.domain).upper(), i, i, i, i) if len(c.fields) == 0: print "decode_properties(%d, _) ->" % (c.index,) @@ -419,17 +419,29 @@ shortstr_size(S) -> _ -> exit(method_field_shortstr_overflow) end. -shortstr_prop(<<L:8/unsigned, S:L/binary, X/binary>>) -> - {S, X}. - -table_prop(<<L:32/unsigned, T:L/binary, X/binary>>) -> - {rabbit_binary_parser:parse_table(T), X}. - -octet_prop(<<I:8/unsigned, X/binary>>) -> - {I, X}. - -timestamp_prop(<<I:64/unsigned, X/binary>>) -> - {I, X}. +-define(SHORTSTR_PROP(R, L, V, X), + begin + <<L:8/unsigned, V:L/binary, X/binary>> = R, + {V, X} + end). + +-define(TABLE_PROP(R, L, V, X), + begin + <<L:32/unsigned, V:L/binary, X/binary>> = R, + {rabbit_binary_parser:parse_table(V), X} + end). + +-define(OCTET_PROP(R, L, V, X), + begin + <<V:8/unsigned, X/binary>> = R, + {V, X} + end). + +-define(TIMESTAMP_PROP(R, L, V, X), + begin + <<V:64/unsigned, X/binary>> = R, + {V, X} + end). """ version = "{%d, %d, %d}" % (spec.major, spec.minor, spec.revision) if version == '{8, 0, 0}': version = '{0, 8, 0}' |