diff options
author | karroffel <therzog@mail.de> | 2018-05-10 21:36:26 +0200 |
---|---|---|
committer | karroffel <therzog@mail.de> | 2018-05-10 22:03:06 +0200 |
commit | 70866bbafd74d277a7f8aedcd2c8bf23a0cce99d (patch) | |
tree | 73c350e41ba500518ed36685aa31d5459e6464a3 /modules/gdnative/SCsub | |
parent | 486ec499f33b4062625b859509127db765fa23e1 (diff) |
changed GDNative API json format
Diffstat (limited to 'modules/gdnative/SCsub')
-rw-r--r-- | modules/gdnative/SCsub | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/modules/gdnative/SCsub b/modules/gdnative/SCsub index 8654ef3d82..6d2f8ce8ad 100644 --- a/modules/gdnative/SCsub +++ b/modules/gdnative/SCsub @@ -23,7 +23,8 @@ def _build_gdnative_api_struct_header(api): '\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( '\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('\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( - '\t\t\tcase GDNATIVE_EXT_%s:' % api['extensions'][name]['type']) + '\t\t\tcase GDNATIVE_EXT_%s:' % ext['type']) gdnative_api_init_macro.append( '\t\t\t\t_gdnative_wrapper_{0}_api_struct = (godot_gdnative_ext_{0}_api_struct *)' ' _gdnative_wrapper_api_struct->extensions[i];'.format(name)) @@ -61,8 +63,8 @@ def _build_gdnative_api_struct_header(api): '\tGDNATIVE_' + api['core']['type'] + ',' ] - for name in api['extensions']: - out += ['\tGDNATIVE_EXT_' + api['extensions'][name]['type'] + ','] + for ext in api['extensions']: + out += ['\tGDNATIVE_EXT_' + ext['type'] + ','] out += ['};', ''] @@ -88,8 +90,9 @@ def _build_gdnative_api_struct_header(api): return ret_val - for name in api['extensions']: - out += generate_extension_struct(name, api['extensions'][name], False) + for ext in api['extensions']: + name = ext['name'] + out += generate_extension_struct(name, ext, False) out += [ 'typedef struct godot_gdnative_core_api_struct {', @@ -151,12 +154,14 @@ def _build_gdnative_api_struct_source(api): return ret_val - for name in api['extensions']: - out += get_extension_struct_definition(name, api['extensions'][name], False) + for ext in api['extensions']: + name = ext['name'] + out += get_extension_struct_definition(name, ext, False) 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 += ['};\n'] @@ -214,7 +219,8 @@ def _build_gdnative_wrapper_code(api): '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 += [''] @@ -232,8 +238,9 @@ def _build_gdnative_wrapper_code(api): out.append('}') out.append('') - for name in api['extensions']: - for funcdef in api['extensions'][name]['api']: + for ext in api['extensions']: + name = ext['name'] + for funcdef in ext['api']: 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)) @@ -267,7 +274,7 @@ def build_gdnative_wrapper_code(target, source, env): 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) gd_wrapper_env = env.Clone() |