@@ -694,6 +694,50 @@ void QuickJSBuiltinBinder::bind_builtin_propties_manually() {
694
694
binder->get_builtin_binder ().register_property (Variant::COLOR, " v" , getter, setter, 6 );
695
695
}
696
696
697
+ { // Rect2
698
+ JSCFunctionMagic *getter = [](JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, int magic) -> JSValue {
699
+ ECMAScriptGCHandler *bind = BINDING_DATA_FROM_JS (ctx, this_val);
700
+ const Rect2 *ptr = bind->getRect2 ();
701
+ switch (magic) {
702
+ case 0 :
703
+ return QuickJSBinder::variant_to_var (ctx, ptr->size + ptr->position );
704
+ }
705
+ return JS_UNDEFINED;
706
+ };
707
+ JSCFunctionMagic *setter = [](JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, int magic) -> JSValue {
708
+ ECMAScriptGCHandler *bind = BINDING_DATA_FROM_JS (ctx, this_val);
709
+ Rect2 *ptr = bind->getRect2 ();
710
+ switch (magic) {
711
+ case 0 :
712
+ #ifdef DEBUG_METHODS_ENABLED
713
+ ERR_FAIL_COND_V (!QuickJSBinder::validate_type (ctx, Variant::VECTOR2, argv[0 ]), (JS_ThrowTypeError (ctx, " Vector2 expected for Rect2.end" )));
714
+ #endif
715
+ ptr->size = Vector2 (QuickJSBinder::var_to_variant (ctx, argv[0 ])) - ptr->position ;
716
+ break ;
717
+ }
718
+ return JS_DupValue (ctx, argv[0 ]);
719
+ };
720
+ binder->get_builtin_binder ().register_property (Variant::RECT2, " end" , getter, setter, 0 );
721
+
722
+ binder->get_builtin_binder ().register_method (
723
+ Variant::RECT2,
724
+ " grow_margin" ,
725
+ [](JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) {
726
+ #ifdef DEBUG_METHODS_ENABLED
727
+ ERR_FAIL_COND_V (argc < 2 , (JS_ThrowTypeError (ctx, " Two arguments expected for Rect2.grow_margin" )));
728
+ #endif
729
+ ECMAScriptGCHandler *bind = BINDING_DATA_FROM_JS (ctx, this_val);
730
+ Rect2 *ptr = bind->getRect2 ();
731
+ #ifdef DEBUG_METHODS_ENABLED
732
+ ERR_FAIL_COND_V (!QuickJSBinder::validate_type (ctx, Variant::INT, argv[0 ]), (JS_ThrowTypeError (ctx, " number expected for argument 0 of Rect2.grow_margin" )));
733
+ ERR_FAIL_COND_V (!QuickJSBinder::validate_type (ctx, Variant::REAL, argv[0 ]), (JS_ThrowTypeError (ctx, " number expected for argument 1 of Rect2.grow_margin" )));
734
+ #endif
735
+ Rect2 ret = ptr->grow_margin (Margin (QuickJSBinder::js_to_int (ctx, argv[0 ])), QuickJSBinder::js_to_number (ctx, argv[1 ]));
736
+ return QuickJSBinder::variant_to_var (ctx, ret);
737
+ },
738
+ 2 );
739
+ }
740
+
697
741
{ // PoolByteArray
698
742
// PoolByteArray.prototype.compress
699
743
binder->get_builtin_binder ().register_method (
0 commit comments