Permalink
Browse files

Refactor opaque type handling.

  • Loading branch information...
1 parent 0b0cd76 commit 6b204fe55b05348e736e0bd295cd4ec92ec535e5 @PeterJohnson PeterJohnson committed Apr 28, 2012
Showing with 9 additions and 4 deletions.
  1. +8 −0 ctypes_core_prefix.py
  2. +1 −4 gen_wrap.py
View
@@ -124,3 +124,11 @@ def from_param(cls, obj):
raise ValueError("Cannot mix enumeration members")
return ctypes.c_uint(obj.value)
+#
+# Memory Managed Types
+#
+class Disposed(ctypes.c_void_p):
+ def __del__(self):
+ if self.value != 0:
+ imaqDispose(self)
+
View
@@ -86,10 +86,7 @@ def block_comment(self, comment):
print("#"*78, file=self.out)
def opaque_struct(self, name):
- print("class %s(ctypes.c_void_p):" % name, file=self.out)
- print(" def __del__(self):", file=self.out)
- print(" if self.value != 0:", file=self.out)
- print(" imaqDispose(self)", file=self.out)
+ print("class %s(Disposed): pass" % name, file=self.out)
def define(self, name, value, comment):
if name in exclude:

0 comments on commit 6b204fe

Please sign in to comment.