]> git.notmuchmail.org Git - apitrace/blobdiff - base.py
Allow failure handling for functions without return value.
[apitrace] / base.py
diff --git a/base.py b/base.py
index a901aeb0e0d860365bcf4dd69aa116882469e16f..24641bc16aefb4648ed90d3832bbe9190c9f89a3 100644 (file)
--- a/base.py
+++ b/base.py
@@ -289,8 +289,12 @@ class Function:
 
     def fail_impl(self):
         if self.fail is not None:
-            assert self.type is not Void
-            print '            return %s;' % self.fail
+            if self.type is Void:
+                assert self.fail == ''
+                print '            return;' 
+            else:
+                assert self.fail != ''
+                print '            return %s;' % self.fail
         else:
             print '            ExitProcess(0);'
 
@@ -323,11 +327,15 @@ class Function:
             print '    Log::EndReturn();'
             self.type.wrap_instance('result')
         print '    Log::EndCall();'
+        self.post_call_impl()
         if self.type is not Void:
             print '    return result;'
         print '}'
         print
 
+    def post_call_impl(self):
+        pass
+
 
 class Interface(Type):
 
@@ -448,13 +456,26 @@ class _String(Type):
         Type.__init__(self, "String")
 
     def __str__(self):
-        return "char *"
+        return "const char *"
 
     def dump(self, instance):
         print '    Log::DumpString((const char *)%s);' % instance
 
 String = _String()
 
+class _WString(Type):
+
+    def __init__(self):
+        Type.__init__(self, "WString")
+
+    def __str__(self):
+        return "const wchar_t *"
+
+    def dump(self, instance):
+        print '    Log::DumpWString(%s);' % instance
+
+WString = _WString()
+
 
 SChar = Intrinsic("signed char", "%i")
 UChar = Intrinsic("unsigned char", "%u")