summaryrefslogtreecommitdiff
path: root/modules/gdnative/gdnative_builders.py
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdnative/gdnative_builders.py')
-rw-r--r--modules/gdnative/gdnative_builders.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/modules/gdnative/gdnative_builders.py b/modules/gdnative/gdnative_builders.py
index 8a1cd049af..f9d1ed9dc5 100644
--- a/modules/gdnative/gdnative_builders.py
+++ b/modules/gdnative/gdnative_builders.py
@@ -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 = {',