[GDNative] add initial core 1.1 extension

This commit is contained in:
Thomas Herzog
2018-08-30 19:18:55 +02:00
parent 9e43129906
commit 492b4cf837
12 changed files with 241 additions and 21 deletions

View File

@ -82,10 +82,35 @@ def _build_gdnative_api_struct_header(api):
return ret_val
def generate_core_extension_struct(core):
ret_val = []
if core['next']:
ret_val += generate_core_extension_struct(core['next'])
ret_val += [
'typedef struct godot_gdnative_core_' + ('{0}_{1}'.format(core['version']['major'], core['version']['minor'])) + '_api_struct {',
'\tunsigned int type;',
'\tgodot_gdnative_api_version version;',
'\tconst godot_gdnative_api_struct *next;',
]
for funcdef in core['api']:
args = ', '.join(['%s%s' % (_spaced(t), n) for t, n in funcdef['arguments']])
ret_val.append('\t%s(*%s)(%s);' % (_spaced(funcdef['return_type']), funcdef['name'], args))
ret_val += ['} godot_gdnative_core_' + '{0}_{1}'.format(core['version']['major'], core['version']['minor']) + '_api_struct;', '']
return ret_val
for ext in api['extensions']:
name = ext['name']
out += generate_extension_struct(name, ext, False)
if api['core']['next']:
out += generate_core_extension_struct(api['core']['next'])
out += [
'typedef struct godot_gdnative_core_api_struct {',
'\tunsigned int type;',
@ -146,6 +171,27 @@ def _build_gdnative_api_struct_source(api):
ret_val += ['};\n']
return ret_val
def get_core_struct_definition(core):
ret_val = []
if core['next']:
ret_val += get_core_struct_definition(core['next'])
ret_val += [
'extern const godot_gdnative_core_' + ('{0}_{1}_api_struct api_{0}_{1}'.format(core['version']['major'], core['version']['minor'])) + ' = {',
'\tGDNATIVE_' + core['type'] + ',',
'\t{' + str(core['version']['major']) + ', ' + str(core['version']['minor']) + '},',
'\t' + ('NULL' if not core['next'] else ('(const godot_gdnative_api_struct *)& api_{0}_{1}'.format(core['version']['major'], core['version']['minor']))) + ','
]
for funcdef in core['api']:
ret_val.append('\t%s,' % funcdef['name'])
ret_val += ['};\n']
return ret_val
for ext in api['extensions']:
name = ext['name']
@ -158,6 +204,9 @@ def _build_gdnative_api_struct_source(api):
out += ['\t(godot_gdnative_api_struct *)&api_extension_' + name + '_struct,']
out += ['};\n']
if api['core']['next']:
out += get_core_struct_definition(api['core']['next'])
out += [
'extern const godot_gdnative_core_api_struct api_struct = {',