header = open(os.path.join(outdirname, 'include/libsigrok/enums.hpp'), 'w')
code = open(os.path.join(outdirname, 'enums.cpp'), 'w')
+swig = open(os.path.join(outdirname, '../swig/enums.i'), 'w')
for file in (header, code):
print >> file, "/* Generated file - edit enums.py instead! */"
filename = os.path.join(dirname, "%s_methods.cpp" % classname)
if os.path.exists(filename):
print >> code, str.join('', open(filename).readlines())
+
+ # Map EnumValue::id() and EnumValue::name() as SWIG attributes.
+ print >> swig, '%%attribute(sigrok::%s, int, id, id);' % classname
+ print >> swig, '%%attributestring(sigrok::%s, std::string, name, name);' % classname
+
+ # Instantiate EnumValue template for SWIG
+ print >> swig, '%%template(EnumValue%s) sigrok::EnumValue<sigrok::%s, enum %s>;' % (
+ classname, classname, enum_name)
+
+ # Apply any language-specific extras.
+ print >> swig, '%%enumextras(%s);' % classname
+
+ # Declare additional attributes if present
+ filename = os.path.join(dirname, "%s_methods.i" % classname)
+ if os.path.exists(filename):
+ print >> swig, str.join('', open(filename).readlines())