@@ -44,7 +44,7 @@ def GlobRecursive(path, pattern, **kwargs):
4444 return found
4545
4646
47- KEYWORDS = ['GPROPERTY' , 'GMETHOD' , 'GGROUP' , 'GSUBGROUP' , 'GBITFIELD' , 'GSIGNAL' , 'GRPC' , 'GVARARG' , 'GIGNORE' ]
47+ KEYWORDS = ['GPROPERTY' , 'GMETHOD' , 'GGROUP' , 'GSUBGROUP' , 'GBITFIELD' , 'GSIGNAL' , 'GRPC' , 'GVARARG' , 'GIGNORE' , 'GBIND_METHODS_APPEND' , 'GBIND_METHODS_PREPEND' ]
4848INIT_LEVELS = ['GINIT_LEVEL_CORE' , 'GINIT_LEVEL_SERVERS' , 'GINIT_LEVEL_SCENE' , 'GINIT_LEVEL_EDITOR' ]
4949
5050DONOTEDIT_MSG = "/*-- GENERATED FILE - DO NOT EDIT --*/\n \n "
@@ -341,14 +341,17 @@ def add_class(cursor, macros):
341341 'signals' : [],
342342 'enum_constants' : {},
343343 'constants' : [],
344- 'bitfields' : {}
344+ 'bitfields' : {},
345+ 'bind_methods_append' : '' ,
346+ 'bind_methods_prepend' : ''
345347 }
346348 child_cursors = []
347349 parse_class (cursor , child_cursors )
348350 # Exclude cursors added by GCLASS() macro
349351 child_cursors = [i for i in child_cursors if gdclass_macro .extent .start .offset != i .extent .start .offset ]
350352
351353 group , subgroup = '' , ''
354+ bind_methods_append , bind_methods_prepend = '' , ''
352355 start , end = cursor .extent .start .offset , cursor .extent .end .offset
353356 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 )
354357
@@ -477,6 +480,13 @@ def process_macros(item, macros, properties, is_ignored=False):
477480 case 'GIGNORE' :
478481 is_ignored = True
479482
483+ case 'GBIND_METHODS_APPEND' :
484+ bind_methods_append += get_macro_body (filecontent , macro )
485+
486+ case 'GBIND_METHODS_PREPEND' :
487+ bind_methods_prepend += get_macro_body (filecontent , macro )
488+
489+
480490 return not is_ignored
481491
482492
@@ -524,7 +534,7 @@ def apply_macros(item, macros):
524534
525535 leftover = collapse_list (class_macros , lambda x : x .kind != CursorKind .MACRO_INSTANTIATION , apply_macros )
526536 for macro in leftover :
527- if macro .spelling not in ['GSIGNAL' , 'GGROUP' , 'GSUBGROUP' ] + INIT_LEVELS :
537+ if macro .spelling not in ['GSIGNAL' , 'GGROUP' , 'GSUBGROUP' , 'GBIND_METHODS_APPEND' , 'GBIND_METHODS_PREPEND' ] + INIT_LEVELS :
528538 raise CppScriptException ('{}:{}:{}: error: macro without target member'
529539 .format (filename , macro .location .line , macro .location .column ))
530540 process_macros (None , leftover , None )
0 commit comments