Skip to content

Commit 053fc95

Browse files
author
Vano
committed
GBIND_METHODS_(APPEND/PREPEND) macros
1 parent 9cd5834 commit 053fc95

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

cppscript.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@ def add_class(cursor, macros):
351351
child_cursors = [i for i in child_cursors if gdclass_macro.extent.start.offset != i.extent.start.offset]
352352

353353
group, subgroup = '', ''
354-
bind_methods_append, bind_methods_prepend = '', ''
355354
start, end = cursor.extent.start.offset, cursor.extent.end.offset
356355
class_macros = sorted([m for m in keyword_macros if start < m.extent.start.offset < end] + child_cursors, key=lambda x: x.extent.start.offset)
357356

@@ -481,10 +480,10 @@ def process_macros(item, macros, properties, is_ignored=False):
481480
is_ignored = True
482481

483482
case 'GBIND_METHODS_APPEND':
484-
bind_methods_append += get_macro_body(filecontent, macro)
483+
class_defs['bind_methods_append'] += get_macro_body(filecontent, macro)
485484

486485
case 'GBIND_METHODS_PREPEND':
487-
bind_methods_prepend += get_macro_body(filecontent, macro)
486+
class_defs['bind_methods_prepend'] += get_macro_body(filecontent, macro)
488487

489488

490489
return not is_ignored
@@ -641,6 +640,8 @@ def write_header(file, defs, env):
641640
header_rpc_config = 'void {}::_rpc_config() {{{}}}\n'.format(
642641
class_name_full, '\n' + header_rpc_config if header_rpc_config != '' else '')
643642
header_bind_methods = '\n\n'.join(i for i in [Hmethod, Hvirtual_method, Hstatic_method, Hvaragr_method, Hprop, Hsignal, Henum, Hbitfield, Hconst] if i != '')
643+
header_bind_methods = content['bind_methods_append'] + header_bind_methods + content['bind_methods_prepend']
644+
644645
header_defs += [f'// {class_name_full} : {content["base"]}\n',
645646
'void {}::_bind_methods() {{{}}}\n'.format(
646647
class_name_full, '\n' + header_bind_methods if header_bind_methods != '' else ''),

src/cppscript_defs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,7 @@ void function(decltype(property) value) { \
4848
#define GINIT_LEVEL_SERVERS(...)
4949
#define GINIT_LEVEL_SCENE(...)
5050
#define GINIT_LEVEL_EDITOR(...)
51+
#define GBIND_METHODS_APPEND(...)
52+
#define GBIND_METHODS_PREPEND(...)
5153

5254
#endif // CPPSCRIPT_HEADER

0 commit comments

Comments
 (0)