mirror of
https://github.com/godotengine/godot
synced 2024-11-02 12:55:22 +00:00
changed GDNative API json format
This commit is contained in:
parent
486ec499f3
commit
70866bbafd
2 changed files with 29 additions and 19 deletions
|
@ -23,7 +23,8 @@ def _build_gdnative_api_struct_header(api):
|
||||||
'\textern const godot_gdnative_core_api_struct *_gdnative_wrapper_api_struct;'
|
'\textern const godot_gdnative_core_api_struct *_gdnative_wrapper_api_struct;'
|
||||||
]
|
]
|
||||||
|
|
||||||
for name in api['extensions']:
|
for ext in api['extensions']:
|
||||||
|
name = ext['name']
|
||||||
gdnative_api_init_macro.append(
|
gdnative_api_init_macro.append(
|
||||||
'\textern const godot_gdnative_ext_{0}_api_struct *_gdnative_wrapper_{0}_api_struct;'.format(name))
|
'\textern const godot_gdnative_ext_{0}_api_struct *_gdnative_wrapper_{0}_api_struct;'.format(name))
|
||||||
|
|
||||||
|
@ -31,9 +32,10 @@ def _build_gdnative_api_struct_header(api):
|
||||||
gdnative_api_init_macro.append('\tfor (unsigned int i = 0; i < _gdnative_wrapper_api_struct->num_extensions; i++) { ')
|
gdnative_api_init_macro.append('\tfor (unsigned int i = 0; i < _gdnative_wrapper_api_struct->num_extensions; i++) { ')
|
||||||
gdnative_api_init_macro.append('\t\tswitch (_gdnative_wrapper_api_struct->extensions[i]->type) {')
|
gdnative_api_init_macro.append('\t\tswitch (_gdnative_wrapper_api_struct->extensions[i]->type) {')
|
||||||
|
|
||||||
for name in api['extensions']:
|
for ext in api['extensions']:
|
||||||
|
name = ext['name']
|
||||||
gdnative_api_init_macro.append(
|
gdnative_api_init_macro.append(
|
||||||
'\t\t\tcase GDNATIVE_EXT_%s:' % api['extensions'][name]['type'])
|
'\t\t\tcase GDNATIVE_EXT_%s:' % ext['type'])
|
||||||
gdnative_api_init_macro.append(
|
gdnative_api_init_macro.append(
|
||||||
'\t\t\t\t_gdnative_wrapper_{0}_api_struct = (godot_gdnative_ext_{0}_api_struct *)'
|
'\t\t\t\t_gdnative_wrapper_{0}_api_struct = (godot_gdnative_ext_{0}_api_struct *)'
|
||||||
' _gdnative_wrapper_api_struct->extensions[i];'.format(name))
|
' _gdnative_wrapper_api_struct->extensions[i];'.format(name))
|
||||||
|
@ -61,8 +63,8 @@ def _build_gdnative_api_struct_header(api):
|
||||||
'\tGDNATIVE_' + api['core']['type'] + ','
|
'\tGDNATIVE_' + api['core']['type'] + ','
|
||||||
]
|
]
|
||||||
|
|
||||||
for name in api['extensions']:
|
for ext in api['extensions']:
|
||||||
out += ['\tGDNATIVE_EXT_' + api['extensions'][name]['type'] + ',']
|
out += ['\tGDNATIVE_EXT_' + ext['type'] + ',']
|
||||||
|
|
||||||
out += ['};', '']
|
out += ['};', '']
|
||||||
|
|
||||||
|
@ -88,8 +90,9 @@ def _build_gdnative_api_struct_header(api):
|
||||||
return ret_val
|
return ret_val
|
||||||
|
|
||||||
|
|
||||||
for name in api['extensions']:
|
for ext in api['extensions']:
|
||||||
out += generate_extension_struct(name, api['extensions'][name], False)
|
name = ext['name']
|
||||||
|
out += generate_extension_struct(name, ext, False)
|
||||||
|
|
||||||
out += [
|
out += [
|
||||||
'typedef struct godot_gdnative_core_api_struct {',
|
'typedef struct godot_gdnative_core_api_struct {',
|
||||||
|
@ -151,12 +154,14 @@ def _build_gdnative_api_struct_source(api):
|
||||||
|
|
||||||
return ret_val
|
return ret_val
|
||||||
|
|
||||||
for name in api['extensions']:
|
for ext in api['extensions']:
|
||||||
out += get_extension_struct_definition(name, api['extensions'][name], False)
|
name = ext['name']
|
||||||
|
out += get_extension_struct_definition(name, ext, False)
|
||||||
|
|
||||||
out += ['', 'const godot_gdnative_api_struct *gdnative_extensions_pointers[] = {']
|
out += ['', 'const godot_gdnative_api_struct *gdnative_extensions_pointers[] = {']
|
||||||
|
|
||||||
for name in api['extensions']:
|
for ext in api['extensions']:
|
||||||
|
name = ext['name']
|
||||||
out += ['\t(godot_gdnative_api_struct *)&api_extension_' + name + '_struct,']
|
out += ['\t(godot_gdnative_api_struct *)&api_extension_' + name + '_struct,']
|
||||||
|
|
||||||
out += ['};\n']
|
out += ['};\n']
|
||||||
|
@ -214,7 +219,8 @@ def _build_gdnative_wrapper_code(api):
|
||||||
'godot_gdnative_core_api_struct *_gdnative_wrapper_api_struct = 0;',
|
'godot_gdnative_core_api_struct *_gdnative_wrapper_api_struct = 0;',
|
||||||
]
|
]
|
||||||
|
|
||||||
for name in api['extensions']:
|
for ext in api['extensions']:
|
||||||
|
name = ext['name']
|
||||||
out.append('godot_gdnative_ext_' + name + '_api_struct *_gdnative_wrapper_' + name + '_api_struct = 0;')
|
out.append('godot_gdnative_ext_' + name + '_api_struct *_gdnative_wrapper_' + name + '_api_struct = 0;')
|
||||||
|
|
||||||
out += ['']
|
out += ['']
|
||||||
|
@ -232,8 +238,9 @@ def _build_gdnative_wrapper_code(api):
|
||||||
out.append('}')
|
out.append('}')
|
||||||
out.append('')
|
out.append('')
|
||||||
|
|
||||||
for name in api['extensions']:
|
for ext in api['extensions']:
|
||||||
for funcdef in api['extensions'][name]['api']:
|
name = ext['name']
|
||||||
|
for funcdef in ext['api']:
|
||||||
args = ', '.join(['%s%s' % (_spaced(t), n) for t, n in funcdef['arguments']])
|
args = ', '.join(['%s%s' % (_spaced(t), n) for t, n in funcdef['arguments']])
|
||||||
out.append('%s%s(%s) {' % (_spaced(funcdef['return_type']), funcdef['name'], args))
|
out.append('%s%s(%s) {' % (_spaced(funcdef['return_type']), funcdef['name'], args))
|
||||||
|
|
||||||
|
@ -267,7 +274,7 @@ def build_gdnative_wrapper_code(target, source, env):
|
||||||
|
|
||||||
|
|
||||||
if ARGUMENTS.get('gdnative_wrapper', False):
|
if ARGUMENTS.get('gdnative_wrapper', False):
|
||||||
#build wrapper code
|
#build wrapper code
|
||||||
gensource, = gdn_env.Command('gdnative_wrapper_code.gen.cpp', 'gdnative_api.json', build_gdnative_wrapper_code)
|
gensource, = gdn_env.Command('gdnative_wrapper_code.gen.cpp', 'gdnative_api.json', build_gdnative_wrapper_code)
|
||||||
|
|
||||||
gd_wrapper_env = env.Clone()
|
gd_wrapper_env = env.Clone()
|
||||||
|
|
|
@ -5756,8 +5756,9 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"extensions": {
|
"extensions": [
|
||||||
"nativescript": {
|
{
|
||||||
|
"name": "nativescript",
|
||||||
"type": "NATIVESCRIPT",
|
"type": "NATIVESCRIPT",
|
||||||
"version": {
|
"version": {
|
||||||
"major": 1,
|
"major": 1,
|
||||||
|
@ -5942,7 +5943,8 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"pluginscript": {
|
{
|
||||||
|
"name": "pluginscript",
|
||||||
"type": "PLUGINSCRIPT",
|
"type": "PLUGINSCRIPT",
|
||||||
"version": {
|
"version": {
|
||||||
"major": 1,
|
"major": 1,
|
||||||
|
@ -5959,7 +5961,8 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"arvr": {
|
{
|
||||||
|
"name": "arvr",
|
||||||
"type": "ARVR",
|
"type": "ARVR",
|
||||||
"version": {
|
"version": {
|
||||||
"major": 1,
|
"major": 1,
|
||||||
|
@ -6055,5 +6058,5 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue