[GDNative] refactored API struct into core and extensions
This commit is contained in:
parent
05fc741bdb
commit
983404e0ce
2 changed files with 5830 additions and 5763 deletions
|
@ -35,12 +35,37 @@ def _build_gdnative_api_struct_header(api):
|
|||
'extern "C" {',
|
||||
'#endif',
|
||||
'',
|
||||
'typedef struct godot_gdnative_api_struct {',
|
||||
'\tvoid *next;',
|
||||
'\tconst char *version;',
|
||||
'enum GDNATIVE_API_TYPES {',
|
||||
'\tGDNATIVE_' + api['core']['type'] + ','
|
||||
]
|
||||
|
||||
for funcdef in api['api']:
|
||||
for name in api['extensions']:
|
||||
out += ['\tGDNATIVE_' + api['extensions'][name]['type'] + ',']
|
||||
|
||||
out += ['};', '']
|
||||
|
||||
for name in api['extensions']:
|
||||
out += [
|
||||
'typedef struct godot_gdnative_' + name + '_api_struct {',
|
||||
'\tunsigned int type;',
|
||||
'\tconst void *next;'
|
||||
]
|
||||
|
||||
for funcdef in api['extensions'][name]['api']:
|
||||
args = ', '.join(['%s%s' % (_spaced(t), n) for t, n in funcdef['arguments']])
|
||||
out.append('\t%s(*%s)(%s);' % (_spaced(funcdef['return_type']), funcdef['name'], args))
|
||||
|
||||
out += ['} godot_gdnative_' + name + '_api_struct;', '']
|
||||
|
||||
out += [
|
||||
'typedef struct godot_gdnative_api_struct {',
|
||||
'\tunsigned int type;',
|
||||
'\tconst void *next;',
|
||||
'\tunsigned int num_extensions;',
|
||||
'\tconst void **extensions;',
|
||||
]
|
||||
|
||||
for funcdef in api['core']['api']:
|
||||
args = ', '.join(['%s%s' % (_spaced(t), n) for t, n in funcdef['arguments']])
|
||||
out.append('\t%s(*%s)(%s);' % (_spaced(funcdef['return_type']), funcdef['name'], args))
|
||||
|
||||
|
@ -61,14 +86,37 @@ def _build_gdnative_api_struct_source(api):
|
|||
'/* THIS FILE IS GENERATED DO NOT EDIT */',
|
||||
'',
|
||||
'#include <gdnative_api_struct.gen.h>',
|
||||
'',
|
||||
'const char *_gdnative_api_version = "%s";' % api['version'],
|
||||
'extern const godot_gdnative_api_struct api_struct = {',
|
||||
'\tNULL,',
|
||||
'\t_gdnative_api_version,',
|
||||
''
|
||||
]
|
||||
|
||||
for funcdef in api['api']:
|
||||
for name in api['extensions']:
|
||||
out += [
|
||||
'extern const godot_gdnative_' + name + '_api_struct api_extension_' + name + '_struct = {',
|
||||
'\tGDNATIVE_' + api['extensions'][name]['type'] + ',',
|
||||
'\tNULL,'
|
||||
]
|
||||
|
||||
for funcdef in api['extensions'][name]['api']:
|
||||
out.append('\t%s,' % funcdef['name'])
|
||||
|
||||
out += ['};\n']
|
||||
|
||||
out += ['', 'const void *gdnative_extensions_pointers[] = {']
|
||||
|
||||
for name in api['extensions']:
|
||||
out += ['\t(void *)&api_extension_' + name + '_struct,']
|
||||
|
||||
out += ['};\n']
|
||||
|
||||
out += [
|
||||
'extern const godot_gdnative_api_struct api_struct = {',
|
||||
'\tGDNATIVE_' + api['core']['type'] + ',',
|
||||
'\tNULL,',
|
||||
'\t' + str(len(api['extensions'])) + ',',
|
||||
'\tgdnative_extensions_pointers,',
|
||||
]
|
||||
|
||||
for funcdef in api['core']['api']:
|
||||
out.append('\t%s,' % funcdef['name'])
|
||||
out.append('};\n')
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"version": "1.0.0",
|
||||
"core": {
|
||||
"type": "CORE_1_0_0",
|
||||
"api": [
|
||||
{
|
||||
"name": "godot_color_new_rgba",
|
||||
|
@ -5598,7 +5599,13 @@
|
|||
"arguments": [
|
||||
["const godot_string *", "p_message"]
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"extensions": {
|
||||
"nativescript": {
|
||||
"type": "NATIVESCRIPT_1_0_0",
|
||||
"api": [
|
||||
{
|
||||
"name": "godot_nativescript_register_class",
|
||||
"return_type": "void",
|
||||
|
@ -5659,14 +5666,24 @@
|
|||
"arguments": [
|
||||
["godot_object *", "p_instance"]
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"pluginscript": {
|
||||
"type": "PLUGINSCRIPT_1_0_0",
|
||||
"api": [
|
||||
{
|
||||
"name": "godot_pluginscript_register_language",
|
||||
"return_type": "void",
|
||||
"arguments": [
|
||||
["const godot_pluginscript_language_desc *", "language_desc"]
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"nativearvr": {
|
||||
"type": "NATIVEARVR_1_0_0",
|
||||
"api": [
|
||||
{
|
||||
"name": "godot_arvr_register_interface",
|
||||
"return_type": "void",
|
||||
|
@ -5754,4 +5771,6 @@
|
|||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue