From 2672a7dbb0e0acd666abfd2498bb19aeca41fe09 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Sat, 14 Apr 2012 15:17:12 +0100 Subject: [PATCH] Don't abuse NotImplementedError. So that we can distinguish between types we can't support, and those we can support, but haven't. --- retrace.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/retrace.py b/retrace.py index a450f82..9e9af20 100644 --- a/retrace.py +++ b/retrace.py @@ -33,6 +33,10 @@ import specs.stdapi as stdapi import specs.glapi as glapi +class UnsupportedType(Exception): + pass + + class MutableRebuilder(stdapi.Rebuilder): '''Type visitor which derives a mutable type.''' @@ -51,10 +55,6 @@ class MutableRebuilder(stdapi.Rebuilder): # Strip out references return reference.type - def visitOpaque(self, opaque): - # Don't recursule - return opaque - def lookupHandle(handle, value): if handle.key is None: @@ -114,6 +114,9 @@ class ValueAllocator(stdapi.Visitor): def visitPolymorphic(self, polymorphic, lvalue, rvalue): self.visit(polymorphic.defaultType, lvalue, rvalue) + def visitOpaque(self, opaque, lvalue, rvalue): + pass + class ValueDeserializer(stdapi.Visitor): @@ -205,6 +208,9 @@ class ValueDeserializer(stdapi.Visitor): def visitPolymorphic(self, polymorphic, lvalue, rvalue): self.visit(polymorphic.defaultType, lvalue, rvalue) + + def visitOpaque(self, opaque, lvalue, rvalue): + raise UnsupportedType class OpaqueValueDeserializer(ValueDeserializer): @@ -310,6 +316,9 @@ class SwizzledValueRegistrator(stdapi.Visitor): def visitPolymorphic(self, polymorphic, lvalue, rvalue): self.visit(polymorphic.defaultType, lvalue, rvalue) + + def visitOpaque(self, opaque, lvalue, rvalue): + pass class Retracer: @@ -365,7 +374,7 @@ class Retracer: lvalue = arg.name try: self.extractArg(function, arg, arg_type, lvalue, rvalue) - except NotImplementedError: + except UnsupportedType: success = False print ' memset(&%s, 0, sizeof %s); // FIXME' % (arg.name, arg.name) print @@ -385,14 +394,14 @@ class Retracer: lvalue = arg.name try: self.regiterSwizzledValue(arg_type, lvalue, rvalue) - except NotImplementedError: + except UnsupportedType: print ' // XXX: %s' % arg.name if function.type is not stdapi.Void: rvalue = '*call.ret' lvalue = '__result' try: self.regiterSwizzledValue(function.type, lvalue, rvalue) - except NotImplementedError: + except UnsupportedType: raise print ' // XXX: result' @@ -410,7 +419,7 @@ class Retracer: def extractOpaqueArg(self, function, arg, arg_type, lvalue, rvalue): try: ValueAllocator().visit(arg_type, lvalue, rvalue) - except NotImplementedError: + except UnsupportedType: pass OpaqueValueDeserializer().visit(arg_type, lvalue, rvalue) -- 2.7.4