static bool js_cocos2dx_CCScrollView_setDelegate(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); if (argc == 1) { // save the delegate JSObject *jsDelegate = JSVAL_TO_OBJECT(argv[0]); JSB_ScrollViewDelegate* nativeDelegate = new JSB_ScrollViewDelegate(); nativeDelegate->setJSDelegate(jsDelegate); cobj->setUserObject(nativeDelegate); cobj->setDelegate(nativeDelegate); nativeDelegate->release(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return false; }
static bool js_cocos2dx_CCScrollView_setDelegate(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); if (argc == 1) { // save the delegate JSObject *jsDelegate = args.get(0).toObjectOrNull(); JSB_ScrollViewDelegate* nativeDelegate = new JSB_ScrollViewDelegate(); nativeDelegate->setJSDelegate(jsDelegate); cobj->setUserObject(nativeDelegate); cobj->setDelegate(nativeDelegate); nativeDelegate->release(); args.rval().setUndefined(); return true; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return false; }