vrclient/gen_wrapper: Introduce get_params() helper function.

This commit is contained in:
Józef Kucia 2018-07-30 12:46:39 +02:00
parent d687b83fcb
commit 92f395ddd5

View file

@ -125,8 +125,11 @@ print_sizes = []
class_versions = {}
def get_params(f):
return [p for p in f.get_children() if p.kind == clang.cindex.CursorKind.PARM_DECL]
def get_param_count(f):
return len([p for p in f.get_children() if p.kind == clang.cindex.CursorKind.PARM_DECL])
return len(get_params(f))
def ivrclientcore_init(cppname, method):
if "002" in cppname:
@ -211,8 +214,7 @@ def handle_method(cfile, classname, winclassname, cppname, method, cpp, cpp_h, e
parambytes = 8 #_this + return pointer
else:
parambytes = 4 #_this
for param in list(method.get_children()):
if param.kind == clang.cindex.CursorKind.PARM_DECL:
for param in get_params(method):
parambytes += param.type.get_size()
cfile.write("DEFINE_THISCALL_WRAPPER(%s_%s, %s)\n" % (winclassname, used_name, parambytes))
cpp_h.write("extern ")
@ -237,8 +239,7 @@ def handle_method(cfile, classname, winclassname, cppname, method, cpp, cpp_h, e
do_lin_to_win = None
do_wrap = None
do_unwrap = None
for param in list(method.get_children()):
if param.kind == clang.cindex.CursorKind.PARM_DECL:
for param in get_params(method):
if param.type.kind == clang.cindex.TypeKind.POINTER and \
param.type.get_pointee().kind == clang.cindex.TypeKind.UNEXPOSED:
#unspecified function pointer
@ -325,8 +326,7 @@ def handle_method(cfile, classname, winclassname, cppname, method, cpp, cpp_h, e
unnamed = 'a'
first = True
next_is_size = False
for param in list(method.get_children()):
if param.kind == clang.cindex.CursorKind.PARM_DECL:
for param in get_params(method):
if not first:
cpp.write(", ")
else: