]> sigrok.org Git - libsigrok.git/blobdiff - bindings/cxx/enums.py
bindings: Add QuantityFlag::mask_from_flags() method.
[libsigrok.git] / bindings / cxx / enums.py
index 1941f783a8b3bcc92c0c606e0f3b3348aae85700..fb00102a3bf0a86400654aa59c79f4d7e2c401eb 100644 (file)
@@ -146,6 +146,18 @@ for enum, (classname, classbrief) in classes.items():
     if os.path.exists(filename):
         print >> code, str.join('', open(filename).readlines())
 
-    # Instantiate EnumValue template for SWIG wrappers
-    print >> swig, '%%template(EnumValue%s) EnumValue<%s, enum %s>;' % (
+    # 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())