@@ -214,19 +214,19 @@ private:
214
214
#define GABSTRACT_CLASS(CLASS_NAME, CLASS_NAME_INH) GCLASS(CLASS_NAME, CLASS_NAME_INH)
215
215
#define GINTERNAL_CLASS(CLASS_NAME, CLASS_NAME_INH) GCLASS(CLASS_NAME, CLASS_NAME_INH)
216
216
217
- #define GENERATE_GETTER_DECLARATION(function, property ) \\
218
- decltype(property) function();
217
+ #define GENERATE_GETTER_DECLARATION(function, prop_type ) \\
218
+ prop_type function();
219
219
220
- #define GENERATE_SETTER_DECLARATION(function, property ) \\
221
- void function(decltype(property) );
220
+ #define GENERATE_SETTER_DECLARATION(function, prop_type ) \\
221
+ void function(prop_type );
222
222
223
- #define GENERATE_GETTER(function, property) \\
224
- decltype(property) function() { \\
223
+ #define GENERATE_GETTER(function, property, prop_type ) \\
224
+ prop_type function() { \\
225
225
return property; \\
226
226
}
227
227
228
- #define GENERATE_SETTER(function, property) \\
229
- void function(decltype(property) value) { \\
228
+ #define GENERATE_SETTER(function, property, prop_type ) \\
229
+ void function(prop_type value) { \\
230
230
this->property = value; \\
231
231
}
232
232
@@ -557,16 +557,16 @@ struct StaticAccess {{
557
557
}}
558
558
\"\"\"
559
559
560
- # (class_name_full, method_name, property_name)
561
- GENERATE_GETTER = 'GENERATE_GETTER({0}::{1}, {0}::{2});\\ n'
560
+ # (class_name_full, method_name, property_name, property_type )
561
+ GENERATE_GETTER = 'GENERATE_GETTER({0}::{1}, {0}::{2}, {3} );\\ n'
562
562
563
- # (method_name, property_name )
563
+ # (method_name, property_type )
564
564
GENERATE_GETTER_DECLARATION = 'GENERATE_GETTER_DECLARATION({0}, {1})'
565
565
566
- # (class_name_full, method_name, property_name)
567
- GENERATE_SETTER = 'GENERATE_SETTER({0}::{1}, {0}::{2});\\ n'
566
+ # (class_name_full, method_name, property_name, property_type )
567
+ GENERATE_SETTER = 'GENERATE_SETTER({0}::{1}, {0}::{2}, {3} );\\ n'
568
568
569
- # (method_name, property_name )
569
+ # (method_name, property_type )
570
570
GENERATE_SETTER_DECLARATION = 'GENERATE_SETTER_DECLARATION({0}, {1})'
571
571
572
572
# (group_name, groug_name_expanded)
@@ -852,6 +852,17 @@ def is_virtual_method(cursor):
852
852
return False
853
853
854
854
855
+ def cursor_get_field_type(cursor):
856
+ spelling = cursor.spelling
857
+ tokens = list(cursor.get_tokens())
858
+ for i in range(len(tokens)):
859
+ if tokens[i].kind == TokenKind.IDENTIFIER and tokens[i].spelling == spelling:
860
+ return ''.join(t.spelling for t in tokens[:i])
861
+
862
+ raise CppScriptException('{}:{}:{}: error: cannot extract type from property \" {}\" '
863
+ .format(cursor.location.file.name, cursor.location.line, cursor.location.column, cursor.spelling))
864
+
865
+
855
866
# Builder
856
867
def generate_header_emitter(target, source, env):
857
868
generated = [env.File(filename_to_gen_filename(str(i), env['cppscript_env'])) for i in source]
@@ -946,6 +957,9 @@ def parse_header(index, filename, filecontent, env):
946
957
class_cursors.append(cursor)
947
958
948
959
case CursorKind.FIELD_DECL:
960
+ print(f\" Cursor '{cursor.spelling}'\" )
961
+ print(f\" Type '{cursor.type.spelling}'\" )
962
+ print([(i.kind, i.spelling) for i in cursor.get_tokens()])
949
963
class_cursors.append(cursor)
950
964
951
965
case CursorKind.ENUM_DECL:
@@ -1202,6 +1216,7 @@ def parse_header(index, filename, filecontent, env):
1202
1216
if process_macros(item, macros, properties, True):
1203
1217
properties |= {
1204
1218
'name': item.spelling,
1219
+ 'type' : cursor_get_field_type(item),
1205
1220
'group' : group,
1206
1221
'subgroup' : subgroup,
1207
1222
'is_static' : item.is_static_method()
@@ -1308,7 +1323,8 @@ def write_header(file, defs, env):
1308
1323
property_set_get_defs += CODE_FORMAT.GENERATE_GETTER.format(
1309
1324
class_name_full,
1310
1325
prop[\" getter\" ],
1311
- prop[\" name\" ]
1326
+ prop[\" name\" ],
1327
+ prop[\" type\" ]
1312
1328
)
1313
1329
gen_getters.append([prop[\" getter\" ], prop[\" name\" ]])
1314
1330
@@ -1323,7 +1339,8 @@ def write_header(file, defs, env):
1323
1339
property_set_get_defs += CODE_FORMAT.GENERATE_SETTER.format(
1324
1340
class_name_full,
1325
1341
prop[\" setter\" ],
1326
- prop[\" name\" ]
1342
+ prop[\" name\" ],
1343
+ prop[\" type\" ]
1327
1344
)
1328
1345
gen_setters.append([prop[\" setter\" ], prop[\" name\" ]])
1329
1346
@@ -1543,9 +1560,9 @@ def write_property_header(new_defs, env):
1543
1560
classcontent = filecontent['content']
1544
1561
for class_name_full, content in classcontent.items():
1545
1562
gen_setgets = [
1546
- ' \\\\\\ n' + CODE_FORMAT.GENERATE_GETTER_DECLARATION.format(method, property)
1563
+ ' \\\\\\ n' + CODE_FORMAT.GENERATE_GETTER_DECLARATION.format(method, next(prop['type'] for prop in content['properties'] if prop['name'] == property) )
1547
1564
for method, property in content['gen_getters']] + [
1548
- ' \\\\\\ n' + CODE_FORMAT.GENERATE_SETTER_DECLARATION.format(method, property)
1565
+ ' \\\\\\ n' + CODE_FORMAT.GENERATE_SETTER_DECLARATION.format(method, next(prop['type'] for prop in content['properties'] if prop['name'] == property) )
1549
1566
for method, property in content['gen_setters']]
1550
1567
1551
1568
body += f'#define GSETGET_{content[\" class_name\" ]}' + ''.join(gen_setgets) + '\\ n\\ n'
0 commit comments