From 6aa9bd0c41b7ec12e03cc3bd7d21de39188a8311 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Sat, 19 Apr 2014 15:26:39 +0400 Subject: [PATCH] Removed enum constants from generated types --- libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/__init__.py | 3 --- .../libuavcan_dsdl_compiler/data_type_template.tmpl | 6 ------ 2 files changed, 9 deletions(-) diff --git a/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/__init__.py b/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/__init__.py index af4afaa4bc..276730ce7d 100644 --- a/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/__init__.py +++ b/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/__init__.py @@ -8,7 +8,6 @@ import sys, os, logging, errno from mako.template import Template from pyuavcan import dsdl -MAX_BITLEN_FOR_ENUM = 31 OUTPUT_FILE_EXTENSION = 'hpp' OUTPUT_FILE_PERMISSIONS = 0o444 # Read only for all TEMPLATE_FILENAME = os.path.join(os.path.dirname(__file__), 'data_type_template.tmpl') @@ -167,12 +166,10 @@ def generate_one_type(t): def inject_constant_info(constants): for c in constants: if c.type.kind == c.type.KIND_FLOAT: - c.cpp_use_enum = False float(c.string_value) # Making sure that this is a valid float literal c.cpp_value = c.string_value else: int(c.string_value) # Making sure that this is a valid integer literal - c.cpp_use_enum = c.value >= 0 and c.type.bitlen <= MAX_BITLEN_FOR_ENUM c.cpp_value = c.string_value if c.type.kind == c.type.KIND_UNSIGNED_INT: c.cpp_value += 'U' diff --git a/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/data_type_template.tmpl b/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/data_type_template.tmpl index 1766070b63..7395b24203 100644 --- a/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/data_type_template.tmpl +++ b/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/data_type_template.tmpl @@ -83,11 +83,7 @@ struct UAVCAN_EXPORT ${t.cpp_type_name} // Constants % for a in constants: - % if a.cpp_use_enum: - enum { ${a.name} = ${a.cpp_value} }; // ${a.init_expression} - % else: static const typename ::uavcan::StorageType< typename ConstantTypes::${a.name} >::Type ${a.name}; // ${a.init_expression} - %endif % endfor // Fields @@ -257,12 +253,10 @@ ${extend_signature_per_field('', t.fields)} */ <%def name="define_out_of_line_constants(scope_prefix, constants)"> % for a in constants: - % if not a.cpp_use_enum: template const typename ::uavcan::StorageType< typename ${scope_prefix}<_tmpl>::ConstantTypes::${a.name} >::Type ${scope_prefix}<_tmpl>::${a.name} = ${a.cpp_value}; // ${a.init_expression} - %endif % endfor % if t.kind == t.KIND_SERVICE: