Skip to content

Commit bedb532

Browse files
committed
Fix properties binding which setter/getter from base classes.
Close #48
1 parent 283cfe4 commit bedb532

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

quickjs/quickjs_binder.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,10 +985,27 @@ JSClassID QuickJSBinder::register_class(const ClassDB::ClassInfo *p_cls) {
985985
if (Map<StringName, JSValue>::Element *E = methods.find(prop.setter)) {
986986
setter = E->get();
987987
JS_DupValue(ctx, setter);
988+
} else if (MethodBind *mb = prop._setptr) {
989+
if (godot_methods.size() >= internal_godot_method_id) {
990+
godot_methods.resize(godot_methods.size() + 1);
991+
}
992+
godot_methods.write[internal_godot_method_id] = mb;
993+
String setter_name = prop.setter;
994+
setter = JS_NewCFunctionMagic(ctx, &QuickJSBinder::object_method, setter_name.ascii().get_data(), mb->get_argument_count(), JS_CFUNC_generic_magic, internal_godot_method_id);
995+
++internal_godot_method_id;
988996
}
997+
989998
if (Map<StringName, JSValue>::Element *E = methods.find(prop.getter)) {
990999
getter = E->get();
9911000
JS_DupValue(ctx, getter);
1001+
} else if (MethodBind *mb = prop._getptr) {
1002+
if (godot_methods.size() >= internal_godot_method_id) {
1003+
godot_methods.resize(godot_methods.size() + 1);
1004+
}
1005+
godot_methods.write[internal_godot_method_id] = mb;
1006+
String getter_name = prop.getter;
1007+
getter = JS_NewCFunctionMagic(ctx, &QuickJSBinder::object_method, getter_name.ascii().get_data(), mb->get_argument_count(), JS_CFUNC_generic_magic, internal_godot_method_id);
1008+
++internal_godot_method_id;
9921009
}
9931010
}
9941011

0 commit comments

Comments
 (0)