summaryrefslogtreecommitdiff
path: root/modules/gdnative/SCsub
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-11-09 23:40:54 +0100
committerGitHub <noreply@github.com>2017-11-09 23:40:54 +0100
commit0de6cba7e7e114f71fabb3dbe02cf260f7d3e2c6 (patch)
tree4e0680552e6608888217d7ca31bd726e6e28a06c /modules/gdnative/SCsub
parented57f0a0d40e7fa8dde222c48cd5649d3f80008e (diff)
parent983404e0ce60ce82f7a488bd74cd3097cd7f34bf (diff)
Merge pull request #12779 from karroffel/gdnative-api-struct-refactor
[GDNative] refactored API struct into core and extensions
Diffstat (limited to 'modules/gdnative/SCsub')
-rw-r--r--modules/gdnative/SCsub62
1 files changed, 55 insertions, 7 deletions
diff --git a/modules/gdnative/SCsub b/modules/gdnative/SCsub
index a6ae143947..c0d1d114d7 100644
--- a/modules/gdnative/SCsub
+++ b/modules/gdnative/SCsub
@@ -35,12 +35,37 @@ def _build_gdnative_api_struct_header(api):
'extern "C" {',
'#endif',
'',
+ 'enum GDNATIVE_API_TYPES {',
+ '\tGDNATIVE_' + api['core']['type'] + ','
+ ]
+
+ 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 {',
- '\tvoid *next;',
- '\tconst char *version;',
+ '\tunsigned int type;',
+ '\tconst void *next;',
+ '\tunsigned int num_extensions;',
+ '\tconst void **extensions;',
]
- for funcdef in api['api']:
+ 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'],
+ ''
+ ]
+
+ 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_gdnative_api_version,',
+ '\t' + str(len(api['extensions'])) + ',',
+ '\tgdnative_extensions_pointers,',
]
- for funcdef in api['api']:
+ for funcdef in api['core']['api']:
out.append('\t%s,' % funcdef['name'])
out.append('};\n')