summaryrefslogtreecommitdiff
path: root/specs
diff options
context:
space:
mode:
authorJose Fonseca <jfonseca@vmware.com>2016-05-18 14:55:02 +0100
committerJose Fonseca <jfonseca@vmware.com>2016-05-18 14:55:02 +0100
commit5c881ed0854317794c97c3abf8f1ce394031f61d (patch)
tree51787d71935249b1e2a74845b29705adbffcfa05 /specs
parentc0cfbd20bd5a24bc62acb06f35320b2c667b392b (diff)
specs/scripts: Several improvements to enable parsing d3d12 headers.
Diffstat (limited to 'specs')
-rwxr-xr-xspecs/scripts/cxx2api.py30
1 files changed, 27 insertions, 3 deletions
diff --git a/specs/scripts/cxx2api.py b/specs/scripts/cxx2api.py
index fcad15c6..95986eb5 100755
--- a/specs/scripts/cxx2api.py
+++ b/specs/scripts/cxx2api.py
@@ -151,7 +151,13 @@ class type_dumper_t(type_visitor.type_visitor_t):
self.result = "Double"
def visit_array(self):
- raise NotImplementedError
+ base_type = dump_type(self.type.base)
+ length = self.type.size
+ try:
+ int(length)
+ except ValueError:
+ length = '"%s"' % length
+ self.result = 'Array(%s, %s)' % (base_type, length)
def visit_pointer(self):
base_type = dump_type(self.type.base)
@@ -176,7 +182,13 @@ class type_dumper_t(type_visitor.type_visitor_t):
self.result = 'Pointer(%s)' % base_type
def visit_reference(self):
- self.result = 'Reference(%s)' % dump_type(self.type.base)
+ base_type = dump_type(self.type.base)
+ if base_type == 'Const(IID)':
+ self.result = 'REFIID'
+ elif base_type == 'Const(GUID)':
+ self.result = 'REFGUID'
+ else:
+ self.result = 'Reference(%s)' % base_type
def visit_const(self):
self.result = 'Const(%s)' % dump_type(self.type.base)
@@ -185,6 +197,9 @@ class type_dumper_t(type_visitor.type_visitor_t):
decl = self.type.declaration
self.result = dump_decl(decl)
+ def visit_free_function_type(self):
+ self.result = 'Opaque("%s")' % self.type
+
def dump_type(type):
visitor = type_dumper_t(type)
@@ -251,7 +266,7 @@ class decl2_dumper_t(decl_visitor.decl_visitor_t):
def visit_struct(self, decl_name, decl):
struct = decl
print(r'%s = Struct(%r, [' % (decl_name, decl_name))
- for variable in struct.variables():
+ for variable in struct.variables(allow_empty=True):
var_type = dump_type(variable.type)
print(r' (%s, %r),' % (var_type, variable.name))
print(r'])')
@@ -335,6 +350,9 @@ class decl2_dumper_t(decl_visitor.decl_visitor_t):
arg_types = self.convert_args(function.arguments)
s.write(' StdFunction(%s, %r, [%s]),\n' % (ret_type, function.name, arg_types))
+ def visit_free_operator(self):
+ pass
+
def main():
defines = []
@@ -393,6 +411,8 @@ def main():
'_WIN32_WINNT=0x%04X' % winver,
'WINVER=0x%04X' % winver,
'NTDDI_VERSION=0x%04X0000' % winver,
+ # Prevent headers from requiring a rpcndr.h version beyond MinGW's
+ '__REQUIRED_RPCNDR_H_VERSION__=475',
# Avoid C++ helper classes
'D3D10_NO_HELPERS',
'D3D11_NO_HELPERS',
@@ -455,6 +475,10 @@ def main():
for decl in global_ns.declarations:
if not decl_filter(decl):
continue
+
+ if sys.stdout.isatty():
+ print('# ' + str(decl))
+
visitor.decl = decl
algorithm.apply_visitor(visitor, decl)
visitor.finish()