diff options
| -rw-r--r-- | codegen.py | 48 | ||||
| -rw-r--r-- | include/rabbit_framing_spec.hrl | 11 |
2 files changed, 40 insertions, 19 deletions
diff --git a/codegen.py b/codegen.py index 5ea47734a4..b8152423b4 100644 --- a/codegen.py +++ b/codegen.py @@ -390,22 +390,9 @@ def genHrl(spec): thingsPerLine = typesPerLine) return "-type(%s ::\n\t%s)." % (typeName, sTs) - def prettySpec(fName, fArgs, fValue, fModule = "rabbit_framing", multiLine = False, itemsPerLine = 4): - """If multiLine is True, EACH argument and the value must me a list. -Note to self: Defining a separate type would be better than using multiLine. -""" - if multiLine: - args = ",\n".join([multiLineFormat(arg, - "\t( ", " | ", "\n\t| ", " )", - thingsPerLine = itemsPerLine) - for arg in fArgs]) - vals = multiLineFormat(fValue, - "( ", " | ", "\n\t | ", " )", - thingsPerLine = itemsPerLine) - return "-spec(%s:%s ::\n%s\n\t-> %s)." % (fModule, fName, args, vals) - else: - args = ", ".join(fArgs) - return "-spec(%s:%s :: (%s) -> %s)." % (fModule, fName, args, fValue) + def prettySpec(fName, fArgs, fValue, fModule = "rabbit_framing"): + args = ", ".join(fArgs) + return "-spec(%s:%s :: (%s) -> %s)." % (fModule, fName, args, fValue) methods = spec.allMethods() @@ -439,6 +426,17 @@ Note to self: Defining a separate type would be better than using multiLine. fieldNames = [erlangize(f.name) for f in fieldNames] print prettyType("amqp_method_field_name()", fieldNames) + print prettyType("amqp_property_record()", + ["#'P_%s'{}" % erlangize(c.name) for c in spec.allClasses()]) + print prettyType("amqp_exception()", + ["'%s'" % erlangConstantName(c).lower() for (c, v, cls) in spec.constants]) + print prettyType("amqp_exception_code()", + ["%i" % v for (c, v, cls) in spec.constants]) + classIds = set() + for m in methods: + classIds.add(m.klass.index) + #print prettyType("amqp_class_id()", + # ["%i" % ci for ci in classIds]) print "%% Method signatures" print prettySpec("lookup_method_name/1", @@ -459,6 +457,24 @@ Note to self: Defining a separate type would be better than using multiLine. print prettySpec("method_fieldnames/1", ["amqp_method_name()"], "[amqp_method_field_name()]") + print prettySpec("decode_method_fields/2", + ["amqp_method_name()", "binary()"], + "amqp_method_record()") + print prettySpec("decode_properties/2", + ["non_neg_integer()", "binary()"], + "amqp_property_record()") + print prettySpec("encode_method_fields/1", + ["amqp_method_record()"], + "binary()") + print prettySpec("encode_properties/1", + ["amqp_method_record()"], + "binary()") + print prettySpec("lookup_amqp_exception/1", + ["amqp_exception()"], + "{boolean(), amqp_exception_code(), binary()}") + print prettySpec("amqp_exception/1", + ["amqp_exception_code()"], + "amqp_exception()") def generateErl(specPath): genErl(AmqpSpec(specPath)) diff --git a/include/rabbit_framing_spec.hrl b/include/rabbit_framing_spec.hrl index 447947b77b..5344695e92 100644 --- a/include/rabbit_framing_spec.hrl +++ b/include/rabbit_framing_spec.hrl @@ -41,11 +41,16 @@ %% we could make this more precise but ultimately are limited by %% dialyzer's lack of support for recursive types -type(amqp_table() :: [{binary(), amqp_field_type(), any()}]). +%% TODO Remove this +-type(amqp_class_id() :: + ( 100 | 70 | 40 | 10 + | 110 | 80 | 50 | 20 + | 120 | 90 | 60 | 30 )). %% TODO: make this more precise --type(amqp_class_id() :: non_neg_integer()). -%% TODO: make this more precise +%% TODO: Are these tuples of the form {P_basic_property, any()} ? -type(amqp_properties() :: tuple()). -%% TODO: make this more precise +%% TODO: make this more precise I can't find any restriction on this. +%% Should I just check if it's 16bit ? -type(channel_number() :: non_neg_integer()). -type(resource_name() :: binary()). -type(routing_key() :: binary()). |
