static bool js_cocos2dx_CCTableView_setDataSource(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::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); if (argc == 1) { JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource(); pNativeSource->setTableViewDataSource(JSVAL_TO_OBJECT(argv[0])); __Dictionary* userDict = static_cast<__Dictionary*>(cobj->getUserObject()); if (NULL == userDict) { userDict = new __Dictionary(); cobj->setUserObject(userDict); userDict->release(); } userDict->setObject(pNativeSource, KEY_TABLEVIEW_DATA_SOURCE); cobj->setDataSource(pNativeSource); pNativeSource->release(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } JS_ReportError(cx, "wrong number of arguments"); return false; }
static JSBool js_cocos2dx_CCTableView_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; if (argc == 3 || argc == 2) { JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource(); pNativeSource->setTableViewDataSource(JSVAL_TO_OBJECT(argv[0])); cocos2d::Size arg1; ok &= jsval_to_ccsize(cx, argv[1], &arg1); cocos2d::extension::TableView* ret = NULL; ret = new TableView(); ret->autorelease(); ret->setDataSource(pNativeSource); jsval jsret; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy<cocos2d::extension::TableView>(cx, ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); if (argc == 2) { ret->initWithViewSize(arg1); } else { cocos2d::Node* arg2; do { js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[2]); proxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, JS_FALSE, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); ret->initWithViewSize(arg1, arg2); } ret->reloadData(); Dictionary* userDict = new Dictionary(); userDict->setObject(pNativeSource, KEY_TABLEVIEW_DATA_SOURCE); ret->setUserObject(userDict); userDict->release(); pNativeSource->release(); JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments"); return JS_FALSE; }
static bool js_cocos2dx_CCTableView_init(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_TableView_dequeueCell : Invalid Native Object"); bool ok = true; if (argc == 3 || argc == 2) { JSB_TableViewDataSource* pNativeSource = new (std::nothrow) JSB_TableViewDataSource(); JS::RootedObject jsdata(cx, args.get(0).toObjectOrNull()); pNativeSource->setTableViewDataSource(jsdata); cobj->setDataSource(pNativeSource); JS_SetProperty(cx, obj, "_dataSource", args.get(0)); cocos2d::Size arg1; ok &= jsval_to_ccsize(cx, args.get(1), &arg1); if (argc == 2) { cobj->initWithViewSize(arg1); } else { cocos2d::Node* arg2; do { JS::RootedObject tmpObj(cx, args.get(2).toObjectOrNull()); proxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); cobj->initWithViewSize(arg1, arg2); } cobj->reloadData(); __Dictionary* userDict = new (std::nothrow) __Dictionary(); userDict->setObject(pNativeSource, KEY_TABLEVIEW_DATA_SOURCE); cobj->setUserObject(userDict); userDict->release(); pNativeSource->release(); args.rval().setUndefined(); return true; } JS_ReportError(cx, "wrong number of arguments"); return false; }
static bool js_cocos2dx_CCTableView_init(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::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_TableView_dequeueCell : Invalid Native Object"); bool ok = true; if (argc == 3 || argc == 2) { JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource(); pNativeSource->setTableViewDataSource(JSVAL_TO_OBJECT(argv[0])); cobj->setDataSource(pNativeSource); cocos2d::Size arg1; ok &= jsval_to_ccsize(cx, argv[1], &arg1); if (argc == 2) { cobj->initWithViewSize(arg1); } else { cocos2d::Node* arg2; do { js_proxy_t *proxy; JSObject *tmpObj = JSVAL_TO_OBJECT(argv[2]); proxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); cobj->initWithViewSize(arg1, arg2); } cobj->reloadData(); __Dictionary* userDict = new __Dictionary(); userDict->setObject(pNativeSource, KEY_TABLEVIEW_DATA_SOURCE); cobj->setUserObject(userDict); userDict->release(); pNativeSource->release(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } JS_ReportError(cx, "wrong number of arguments"); return false; }
static bool js_cocos2dx_CCTableView_setDataSource(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); if (argc == 1) { JSB_TableViewDataSource* pNativeSource = new (std::nothrow) JSB_TableViewDataSource(); JS::RootedObject jsdata(cx, args.get(0).toObjectOrNull()); pNativeSource->setTableViewDataSource(jsdata); JS_SetProperty(cx, obj, "_dataSource", args.get(0)); __Dictionary* userDict = static_cast<__Dictionary*>(cobj->getUserObject()); if (NULL == userDict) { userDict = new (std::nothrow) __Dictionary(); cobj->setUserObject(userDict); userDict->release(); } userDict->setObject(pNativeSource, KEY_TABLEVIEW_DATA_SOURCE); cobj->setDataSource(pNativeSource); pNativeSource->release(); args.rval().setUndefined(); return true; } JS_ReportError(cx, "wrong number of arguments"); return false; }
static bool js_cocos2dx_CCTableView_create(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; if (argc == 3 || argc == 2) { JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource(); pNativeSource->setTableViewDataSource(args.get(0).toObjectOrNull()); cocos2d::Size arg1; ok &= jsval_to_ccsize(cx, args.get(1), &arg1); cocos2d::extension::TableView* ret = NULL; ret = new TableView(); ret->autorelease(); ret->setDataSource(pNativeSource); jsval jsret; do { if (ret) { js_proxy_t *proxy = js_get_or_create_proxy<cocos2d::extension::TableView>(cx, ret); jsret = OBJECT_TO_JSVAL(proxy->obj); } else { jsret = JSVAL_NULL; } } while (0); if (argc == 2) { ret->initWithViewSize(arg1); } else { cocos2d::Node* arg2; do { js_proxy_t *proxy; JSObject *tmpObj = args.get(2).toObjectOrNull(); proxy = jsb_get_js_proxy(tmpObj); arg2 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); } while (0); JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); ret->initWithViewSize(arg1, arg2); } ret->reloadData(); __Dictionary* userDict = new __Dictionary(); userDict->setObject(pNativeSource, KEY_TABLEVIEW_DATA_SOURCE); ret->setUserObject(userDict); userDict->release(); pNativeSource->release(); args.rval().set(jsret); return true; } JS_ReportError(cx, "wrong number of arguments"); return false; }