Adding CCControl js binding.

This commit is contained in:
James Chen 2013-07-25 20:52:16 +08:00
parent 1aadf55b59
commit 8626455d69
5 changed files with 174 additions and 47 deletions

View File

@ -168,11 +168,14 @@ static void removeJSTouchObject(JSContext *cx, Touch *x, jsval &jsret) {
}
}
void ScriptingCore::executeJSFunctionWithThisObj(jsval thisObj, jsval callback,
jsval *data) {
jsval retval;
void ScriptingCore::executeJSFunctionWithThisObj(jsval thisObj,
jsval callback,
uint32_t argc/* = 0*/,
jsval* vp/* = NULL*/,
jsval* retVal/* = NULL*/)
{
if(callback != JSVAL_VOID || thisObj != JSVAL_VOID) {
JS_CallFunctionValue(cx_, JSVAL_TO_OBJECT(thisObj), callback, 1, data, &retval);
JS_CallFunctionValue(cx_, JSVAL_TO_OBJECT(thisObj), callback, argc, vp, retVal);
}
}
@ -1099,9 +1102,9 @@ JSBool jsval_to_int32( JSContext *cx, jsval vp, int32_t *outval )
JSBool ok = JS_TRUE;
double dp;
ok &= JS_ValueToNumber(cx, vp, &dp);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments");
ok &= !isnan(dp);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments");
*outval = (int32_t)dp;
@ -1113,9 +1116,9 @@ JSBool jsval_to_uint32( JSContext *cx, jsval vp, uint32_t *outval )
JSBool ok = JS_TRUE;
double dp;
ok &= JS_ValueToNumber(cx, vp, &dp);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments");
ok &= !isnan(dp);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments");
*outval = (uint32_t)dp;
@ -1127,9 +1130,9 @@ JSBool jsval_to_uint16( JSContext *cx, jsval vp, uint16_t *outval )
JSBool ok = JS_TRUE;
double dp;
ok &= JS_ValueToNumber(cx, vp, &dp);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments");
ok &= !isnan(dp);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments");
*outval = (uint16_t)dp;
@ -1139,9 +1142,9 @@ JSBool jsval_to_uint16( JSContext *cx, jsval vp, uint16_t *outval )
JSBool jsval_to_long_long(JSContext *cx, jsval vp, long long* r) {
JSObject *tmp_arg;
JSBool ok = JS_ValueToObject( cx, vp, &tmp_arg );
JSB_PRECONDITION2( ok, cx, JS_FALSE, "Error converting value to object");
JSB_PRECONDITION2( tmp_arg && JS_IsTypedArrayObject( tmp_arg ), cx, JS_FALSE, "Not a TypedArray object");
JSB_PRECONDITION2( JS_GetTypedArrayByteLength( tmp_arg ) == sizeof(long long), cx, JS_FALSE, "Invalid Typed Array length");
JSB_PRECONDITION3( ok, cx, JS_FALSE, "Error converting value to object");
JSB_PRECONDITION3( tmp_arg && JS_IsTypedArrayObject( tmp_arg ), cx, JS_FALSE, "Not a TypedArray object");
JSB_PRECONDITION3( JS_GetTypedArrayByteLength( tmp_arg ) == sizeof(long long), cx, JS_FALSE, "Invalid Typed Array length");
uint32_t* arg_array = (uint32_t*)JS_GetArrayBufferViewData( tmp_arg );
long long ret = arg_array[0];
@ -1153,8 +1156,8 @@ JSBool jsval_to_long_long(JSContext *cx, jsval vp, long long* r) {
}
JSBool jsval_to_std_string(JSContext *cx, jsval v, std::string* ret) {
JSString *tmp = JS_ValueToString(cx, v);
JSB_PRECONDITION2(tmp, cx, JS_FALSE, "Error processing arguments");
JSString *tmp = v.isString() ? JS_ValueToString(cx, v) : NULL;
JSB_PRECONDITION3(tmp, cx, JS_FALSE, "Error processing arguments");
JSStringWrapper str(tmp);
*ret = str.get();
@ -1165,13 +1168,14 @@ JSBool jsval_to_ccpoint(JSContext *cx, jsval v, Point* ret) {
JSObject *tmp;
jsval jsx, jsy;
double x, y;
JSBool ok = JS_ValueToObject(cx, v, &tmp) &&
JSBool ok = v.isObject() &&
JS_ValueToObject(cx, v, &tmp) &&
JS_GetProperty(cx, tmp, "x", &jsx) &&
JS_GetProperty(cx, tmp, "y", &jsy) &&
JS_ValueToNumber(cx, jsx, &x) &&
JS_ValueToNumber(cx, jsy, &y);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments");
ret->x = (float)x;
ret->y = (float)y;
@ -1182,17 +1186,18 @@ JSBool jsval_to_ccacceleration(JSContext* cx,jsval v, Acceleration* ret) {
JSObject *tmp;
jsval jsx, jsy, jsz, jstimestamp;
double x, y, timestamp, z;
JSBool ok = JS_ValueToObject(cx, v, &tmp) &&
JS_GetProperty(cx, tmp, "x", &jsx) &&
JS_GetProperty(cx, tmp, "y", &jsy) &&
JS_GetProperty(cx, tmp, "z", &jsz) &&
JS_GetProperty(cx, tmp, "timestamp", &jstimestamp) &&
JS_ValueToNumber(cx, jsx, &x) &&
JS_ValueToNumber(cx, jsy, &y) &&
JS_ValueToNumber(cx, jsz, &z) &&
JS_ValueToNumber(cx, jstimestamp, &timestamp);
JSBool ok = v.isObject() &&
JS_ValueToObject(cx, v, &tmp) &&
JS_GetProperty(cx, tmp, "x", &jsx) &&
JS_GetProperty(cx, tmp, "y", &jsy) &&
JS_GetProperty(cx, tmp, "z", &jsz) &&
JS_GetProperty(cx, tmp, "timestamp", &jstimestamp) &&
JS_ValueToNumber(cx, jsx, &x) &&
JS_ValueToNumber(cx, jsy, &y) &&
JS_ValueToNumber(cx, jsz, &z) &&
JS_ValueToNumber(cx, jstimestamp, &timestamp);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments");
ret->x = x;
ret->y = y;
@ -1234,7 +1239,7 @@ JSBool jsvals_variadic_to_ccarray( JSContext *cx, jsval *vp, int argc, Array** r
vp++;
}
*ret = pArray;
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments");
return ok;
}
@ -1242,7 +1247,8 @@ JSBool jsval_to_ccrect(JSContext *cx, jsval v, Rect* ret) {
JSObject *tmp;
jsval jsx, jsy, jswidth, jsheight;
double x, y, width, height;
JSBool ok = JS_ValueToObject(cx, v, &tmp) &&
JSBool ok = v.isObject() &&
JS_ValueToObject(cx, v, &tmp) &&
JS_GetProperty(cx, tmp, "x", &jsx) &&
JS_GetProperty(cx, tmp, "y", &jsy) &&
JS_GetProperty(cx, tmp, "width", &jswidth) &&
@ -1252,7 +1258,7 @@ JSBool jsval_to_ccrect(JSContext *cx, jsval v, Rect* ret) {
JS_ValueToNumber(cx, jswidth, &width) &&
JS_ValueToNumber(cx, jsheight, &height);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments");
ret->origin.x = x;
ret->origin.y = y;
@ -1265,13 +1271,14 @@ JSBool jsval_to_ccsize(JSContext *cx, jsval v, Size* ret) {
JSObject *tmp;
jsval jsw, jsh;
double w, h;
JSBool ok = JS_ValueToObject(cx, v, &tmp) &&
JSBool ok = v.isObject() &&
JS_ValueToObject(cx, v, &tmp) &&
JS_GetProperty(cx, tmp, "width", &jsw) &&
JS_GetProperty(cx, tmp, "height", &jsh) &&
JS_ValueToNumber(cx, jsw, &w) &&
JS_ValueToNumber(cx, jsh, &h);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments");
ret->width = w;
ret->height = h;
return JS_TRUE;
@ -1281,7 +1288,8 @@ JSBool jsval_to_cccolor4b(JSContext *cx, jsval v, Color4B* ret) {
JSObject *tmp;
jsval jsr, jsg, jsb, jsa;
double r, g, b, a;
JSBool ok = JS_ValueToObject(cx, v, &tmp) &&
JSBool ok = v.isObject() &&
JS_ValueToObject(cx, v, &tmp) &&
JS_GetProperty(cx, tmp, "r", &jsr) &&
JS_GetProperty(cx, tmp, "g", &jsg) &&
JS_GetProperty(cx, tmp, "b", &jsb) &&
@ -1291,7 +1299,7 @@ JSBool jsval_to_cccolor4b(JSContext *cx, jsval v, Color4B* ret) {
JS_ValueToNumber(cx, jsb, &b) &&
JS_ValueToNumber(cx, jsa, &a);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments");
ret->r = r;
ret->g = g;
@ -1304,7 +1312,8 @@ JSBool jsval_to_cccolor4f(JSContext *cx, jsval v, Color4F* ret) {
JSObject *tmp;
jsval jsr, jsg, jsb, jsa;
double r, g, b, a;
JSBool ok = JS_ValueToObject(cx, v, &tmp) &&
JSBool ok = v.isObject() &&
JS_ValueToObject(cx, v, &tmp) &&
JS_GetProperty(cx, tmp, "r", &jsr) &&
JS_GetProperty(cx, tmp, "g", &jsg) &&
JS_GetProperty(cx, tmp, "b", &jsb) &&
@ -1314,7 +1323,7 @@ JSBool jsval_to_cccolor4f(JSContext *cx, jsval v, Color4F* ret) {
JS_ValueToNumber(cx, jsb, &b) &&
JS_ValueToNumber(cx, jsa, &a);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments");
ret->r = r;
ret->g = g;
ret->b = b;
@ -1326,7 +1335,8 @@ JSBool jsval_to_cccolor3b(JSContext *cx, jsval v, Color3B* ret) {
JSObject *tmp;
jsval jsr, jsg, jsb;
double r, g, b;
JSBool ok = JS_ValueToObject(cx, v, &tmp) &&
JSBool ok = v.isObject() &&
JS_ValueToObject(cx, v, &tmp) &&
JS_GetProperty(cx, tmp, "r", &jsr) &&
JS_GetProperty(cx, tmp, "g", &jsg) &&
JS_GetProperty(cx, tmp, "b", &jsb) &&
@ -1334,7 +1344,7 @@ JSBool jsval_to_cccolor3b(JSContext *cx, jsval v, Color3B* ret) {
JS_ValueToNumber(cx, jsg, &g) &&
JS_ValueToNumber(cx, jsb, &b);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments");
ret->r = r;
ret->g = g;
@ -1345,9 +1355,9 @@ JSBool jsval_to_cccolor3b(JSContext *cx, jsval v, Color3B* ret) {
JSBool jsval_to_ccarray_of_CCPoint(JSContext* cx, jsval v, Point **points, int *numPoints) {
// Parsing sequence
JSObject *jsobj;
JSBool ok = JS_ValueToObject( cx, v, &jsobj );
JSB_PRECONDITION2( ok, cx, JS_FALSE, "Error converting value to object");
JSB_PRECONDITION2( jsobj && JS_IsArrayObject( cx, jsobj), cx, JS_FALSE, "Object must be an array");
JSBool ok = v.isObject() && JS_ValueToObject( cx, v, &jsobj );
JSB_PRECONDITION3( ok, cx, JS_FALSE, "Error converting value to object");
JSB_PRECONDITION3( jsobj && JS_IsArrayObject( cx, jsobj), cx, JS_FALSE, "Object must be an array");
uint32_t len;
JS_GetArrayLength(cx, jsobj, &len);
@ -1359,7 +1369,7 @@ JSBool jsval_to_ccarray_of_CCPoint(JSContext* cx, jsval v, Point **points, int *
JS_GetElement(cx, jsobj, i, &valarg);
ok = jsval_to_ccpoint(cx, valarg, &array[i]);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments");
}
*numPoints = len;
@ -1371,9 +1381,9 @@ JSBool jsval_to_ccarray_of_CCPoint(JSContext* cx, jsval v, Point **points, int *
JSBool jsval_to_ccarray(JSContext* cx, jsval v, Array** ret) {
JSObject *jsobj;
JSBool ok = JS_ValueToObject( cx, v, &jsobj );
JSB_PRECONDITION2( ok, cx, JS_FALSE, "Error converting value to object");
JSB_PRECONDITION2( jsobj && JS_IsArrayObject( cx, jsobj), cx, JS_FALSE, "Object must be an array");
JSBool ok = v.isObject() && JS_ValueToObject( cx, v, &jsobj );
JSB_PRECONDITION3( ok, cx, JS_FALSE, "Error converting value to object");
JSB_PRECONDITION3( jsobj && JS_IsArrayObject( cx, jsobj), cx, JS_FALSE, "Object must be an array");
uint32_t len = 0;
JS_GetArrayLength(cx, jsobj, &len);
@ -1658,7 +1668,7 @@ JSBool jsval_to_ccaffinetransform(JSContext* cx, jsval v, AffineTransform* ret)
JS_ValueToNumber(cx, jstx, &tx) &&
JS_ValueToNumber(cx, jsty, &ty);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
JSB_PRECONDITION3(ok, cx, JS_FALSE, "Error processing arguments");
*ret = AffineTransformMake(a, b, c, d, tx, ty);
return JS_TRUE;

View File

@ -94,7 +94,7 @@ public:
bool executeFunctionWithObjectData(Node *self, const char *name, JSObject *obj);
JSBool executeFunctionWithOwner(jsval owner, const char *name, uint32_t argc = 0, jsval* vp = NULL, jsval* retVal = NULL);
void executeJSFunctionWithThisObj(jsval thisObj, jsval callback, jsval *data);
void executeJSFunctionWithThisObj(jsval thisObj, jsval callback, uint32_t argc = 0, jsval* vp = NULL, jsval* retVal = NULL);
/**
* will eval the specified string

View File

@ -135,6 +135,24 @@ cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_SENTENCE = 3;
*/
cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_ALL_CHARACTERS = 4;
cc.CONTROL_EVENT_TOTAL_NUMBER = 9;
cc.CONTROL_EVENT_TOUCH_DOWN = 1 << 0; // A touch-down event in the control.
cc.CONTROL_EVENT_TOUCH_DRAG_INSIDE = 1 << 1; // An event where a finger is dragged inside the bounds of the control.
cc.CONTROL_EVENT_TOUCH_DRAG_OUTSIDE = 1 << 2; // An event where a finger is dragged just outside the bounds of the control.
cc.CONTROL_EVENT_TOUCH_DRAG_ENTER = 1 << 3; // An event where a finger is dragged into the bounds of the control.
cc.CONTROL_EVENT_TOUCH_DRAG_EXIT = 1 << 4; // An event where a finger is dragged from within a control to outside its bounds.
cc.CONTROL_EVENT_TOUCH_UP_INSIDE = 1 << 5; // A touch-up event in the control where the finger is inside the bounds of the control.
cc.CONTROL_EVENT_TOUCH_UP_OUTSIDE = 1 << 6; // A touch-up event in the control where the finger is outside the bounds of the control.
cc.CONTROL_EVENT_TOUCH_CANCEL = 1 << 7; // A system event canceling the current touches for the control.
cc.CONTROL_EVENT_VALUECHANGED = 1 << 8; // A touch dragging or otherwise manipulating a control; causing it to emit a series of different values.
cc.CONTROL_STATE_NORMAL = 1 << 0; // The normal; or default state of a control梩hat is; enabled but neither selected nor highlighted.
cc.CONTROL_STATE_HIGHLIGHTED = 1 << 1; // Highlighted state of a control. A control enters this state when a touch down; drag inside or drag enter is performed. You can retrieve and set this value through the highlighted property.
cc.CONTROL_STATE_DISABLED = 1 << 2; // Disabled state of a control. This state indicates that the control is currently disabled. You can retrieve and set this value through the enabled property.
cc.CONTROL_STATE_SELECTED = 1 << 3; // Selected state of a control. This state indicates that the control is currently selected. You can retrieve and set this value through the selected property.
cc.CONTROL_STATE_INITIAL = 1 << 3;
// PhysicsDebugNode
cc.PhysicsDebugNode.create = function( space ) {
var s = space;

View File

@ -71,6 +71,9 @@
} while(0)
#endif
#define JSB_PRECONDITION3( condition, context, ret_value, ...) do { \
if( ! (condition) ) return (ret_value); \
} while(0)
/** @def JSB_REPRESENT_LONGLONG_AS_STR

View File

@ -572,10 +572,104 @@ static JSBool js_cocos2dx_CCEditBox_setDelegate(JSContext *cx, uint32_t argc, js
return JS_FALSE;
}
class JSB_ControlButtonTarget : public Object {
public:
virtual void onEvent(Object *controlButton, ControlEvent event) {
js_proxy_t * p;
JS_GET_PROXY(p, controlButton);
if (!p) {
log("Failed to get proxy for control button");
return;
}
jsval dataVal[2];
dataVal[0] = OBJECT_TO_JSVAL(p->obj);
int arg1 = event;
dataVal[1] = INT_TO_JSVAL(arg1);
ScriptingCore::getInstance()->executeJSFunctionWithThisObj(OBJECT_TO_JSVAL(_jsTarget), OBJECT_TO_JSVAL(_jsFunc));//, 2, dataVal);
}
void setJSTarget(JSObject* pJSTarget)
{
_jsTarget = pJSTarget;
JSContext* cx = ScriptingCore::getInstance()->getGlobalContext();
JS_AddNamedObjectRoot(cx, &_jsTarget, "JSB_ControlButtonTarget");
}
void setJSAction(JSObject* jsFunc) {
_jsFunc = jsFunc;
JSContext* cx = ScriptingCore::getInstance()->getGlobalContext();
JS_AddNamedObjectRoot(cx, &_jsFunc, "JSB_ControlButtonTarget");
}
private:
JSObject* _jsTarget;
JSObject* _jsFunc;
};
static JSBool js_cocos2dx_CCControl_addTargetWithActionForControlEvents(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
JSBool ok = JS_TRUE;
if (argc == 3) {
JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]);
JS_GET_NATIVE_PROXY(proxy, tmpObj);
cocos2d::Object *arg0 = (cocos2d::Object *)(proxy ? proxy->ptr : NULL);
TEST_NATIVE_OBJECT(cx, arg0);
int arg2;
ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2);
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing control event");
// save the delegate
JSObject *jsDelegate = JSVAL_TO_OBJECT(argv[0]);
JSB_ControlButtonTarget* nativeDelegate = new JSB_ControlButtonTarget();
nativeDelegate->setJSTarget(jsDelegate);
nativeDelegate->setJSAction(JSVAL_TO_OBJECT(argv[1]));
cobj->addTargetWithActionForControlEvents(nativeDelegate, cccontrol_selector(JSB_ControlButtonTarget::onEvent), arg2);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 3);
return JS_FALSE;
}
static JSBool js_cocos2dx_CCControl_removeTargetWithActionForControlEvents(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JSObject *obj = JS_THIS_OBJECT(cx, vp);
js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object");
if (argc == 3) {
obj = JSVAL_TO_OBJECT(argv[0]);
JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::Object *arg0 = (cocos2d::Object *)(proxy ? proxy->ptr : NULL);
TEST_NATIVE_OBJECT(cx, arg0);
obj = JSVAL_TO_OBJECT(argv[2]);
JS_GET_NATIVE_PROXY(proxy, obj);
cocos2d::extension::ControlEvent *arg2 = (cocos2d::extension::ControlEvent *)(proxy ? proxy->ptr : NULL);
TEST_NATIVE_OBJECT(cx, arg2);
return JS_TRUE;
}
JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 3);
return JS_FALSE;
}
extern JSObject* jsb_ScrollView_prototype;
extern JSObject* jsb_TableView_prototype;
extern JSObject* jsb_EditBox_prototype;
extern JSObject* jsb_Control_prototype;
void register_all_cocos2dx_extension_manual(JSContext* cx, JSObject* global)
{
@ -583,6 +677,8 @@ void register_all_cocos2dx_extension_manual(JSContext* cx, JSObject* global)
JS_DefineFunction(cx, jsb_TableView_prototype, "setDelegate", js_cocos2dx_CCTableView_setDelegate, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_TableView_prototype, "setDataSource", js_cocos2dx_CCTableView_setDataSource, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_EditBox_prototype, "setDelegate", js_cocos2dx_CCEditBox_setDelegate, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_Control_prototype, "addTargetWithActionForControlEvents", js_cocos2dx_CCControl_addTargetWithActionForControlEvents, 3, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsb_Control_prototype, "removeTargetWithActionForControlEvents", js_cocos2dx_CCControl_removeTargetWithActionForControlEvents, 3, JSPROP_READONLY | JSPROP_PERMANENT);
JSObject *tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.TableView; })()"));
JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCTableView_create, 3, JSPROP_READONLY | JSPROP_PERMANENT);