summaryrefslogtreecommitdiff
path: root/codegen.py
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@rabbitmq.com>2010-08-02 16:36:35 +0100
committerMatthew Sackman <matthew@rabbitmq.com>2010-08-02 16:36:35 +0100
commit4b3a79ec87a5bcc5295e6becbd88164f1b18738c (patch)
treeea45ae1a6b323e37d348015635585662f4506309 /codegen.py
parent67a67d0384902b6e15bc1293ec8e02aba4b84f34 (diff)
parent35da42c0701892fd3f19f5c2a33e07d139fb198c (diff)
downloadrabbitmq-server-4b3a79ec87a5bcc5295e6becbd88164f1b18738c.tar.gz
Merging bug 23022 onto default
Diffstat (limited to 'codegen.py')
-rw-r--r--codegen.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/codegen.py b/codegen.py
index 420fc870..14229753 100644
--- a/codegen.py
+++ b/codegen.py
@@ -315,11 +315,16 @@ def genErl(spec):
methods = spec.allMethods()
printFileHeader()
- print """-module(rabbit_framing).
--include("rabbit_framing.hrl").
-
+ module = "rabbit_framing_amqp_%d_%d" % (spec.major, spec.minor)
+ if spec.revision != 0:
+ module = "%s_%d" % (module, spec.revision)
+ if module == "rabbit_framing_amqp_8_0":
+ module = "rabbit_framing_amqp_0_8"
+ print "-module(%s)." % module
+ print """-include("rabbit_framing.hrl").
+
+-export([version/0]).
-export([lookup_method_name/1]).
-
-export([method_id/1]).
-export([method_has_content/1]).
-export([is_method_synchronous/1]).
@@ -395,6 +400,7 @@ def genErl(spec):
print """
%% Method signatures
-ifdef(use_specs).
+-spec(version/0 :: () -> {non_neg_integer(), non_neg_integer(), non_neg_integer()}).
-spec(lookup_method_name/1 :: (amqp_method()) -> amqp_method_name()).
-spec(method_id/1 :: (amqp_method_name()) -> amqp_method()).
-spec(method_has_content/1 :: (amqp_method_name()) -> boolean()).
@@ -414,6 +420,10 @@ bitvalue(true) -> 1;
bitvalue(false) -> 0;
bitvalue(undefined) -> 0.
"""
+ version = "{%d, %d, %d}" % (spec.major, spec.minor, spec.revision)
+ if version == '{8, 0, 0}': version = '{0, 8, 0}'
+ print "version() -> %s." % (version)
+
for m in methods: genLookupMethodName(m)
print "lookup_method_name({_ClassId, _MethodId} = Id) -> exit({unknown_method_id, Id})."
@@ -472,8 +482,6 @@ def genHrl(spec):
methods = spec.allMethods()
printFileHeader()
- print "-define(PROTOCOL_VERSION_MAJOR, %d)." % (spec.major)
- print "-define(PROTOCOL_VERSION_MINOR, %d)." % (spec.minor)
print "-define(PROTOCOL_PORT, %d)." % (spec.port)
for (c,v,cls) in spec.constants: