mirror of https://github.com/axmolengine/axmol.git
merge dualface's pull request for fixing CCLayer script support and fix error for js-binding
This commit is contained in:
parent
7ad2484a91
commit
4e7fca3185
|
@ -1 +1 @@
|
|||
a9d5159141c92d549c9d9e8c9fed53517792589d
|
||||
277dcf61e5fb78a98293b107aa71f6d71b836f93
|
|
@ -809,6 +809,11 @@ int ScriptingCore::executeAccelerometerEvent(CCLayer *pLayer, CCAcceleration *pA
|
|||
return 1;
|
||||
}
|
||||
|
||||
int ScriptingCore::executeLayerKeypadEvent(CCLayer* pLayer, int eventType)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int ScriptingCore::executeCustomTouchesEvent(int eventType,
|
||||
CCSet *pTouches, JSObject *obj)
|
||||
|
@ -925,39 +930,39 @@ CCAcceleration jsval_to_ccacceleration(JSContext *cx, jsval v) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
CCArray* jsvals_variadic_to_ccarray( JSContext *cx, jsval *vp, int argc)
|
||||
{
|
||||
JSBool ok = JS_FALSE;
|
||||
CCArray* pArray = CCArray::create();
|
||||
for( int i=0; i < argc; i++ )
|
||||
{
|
||||
double num = 0.0;
|
||||
// optimization: JS_ValueToNumber is expensive. And can convert an string like "12" to a number
|
||||
if( JSVAL_IS_NUMBER(*vp)) {
|
||||
ok = JS_ValueToNumber(cx, *vp, &num );
|
||||
if (!ok) {
|
||||
break;
|
||||
}
|
||||
pArray->addObject(CCInteger::create((int)num));
|
||||
}
|
||||
CCArray* jsvals_variadic_to_ccarray( JSContext *cx, jsval *vp, int argc)
|
||||
{
|
||||
JSBool ok = JS_FALSE;
|
||||
CCArray* pArray = CCArray::create();
|
||||
for( int i=0; i < argc; i++ )
|
||||
{
|
||||
double num = 0.0;
|
||||
// optimization: JS_ValueToNumber is expensive. And can convert an string like "12" to a number
|
||||
if( JSVAL_IS_NUMBER(*vp)) {
|
||||
ok = JS_ValueToNumber(cx, *vp, &num );
|
||||
if (!ok) {
|
||||
break;
|
||||
}
|
||||
pArray->addObject(CCInteger::create((int)num));
|
||||
}
|
||||
else if (JSVAL_IS_STRING(*vp))
|
||||
{
|
||||
JSStringWrapper str(JSVAL_TO_STRING(*vp), cx);
|
||||
pArray->addObject(CCString::create(str));
|
||||
}
|
||||
else
|
||||
{
|
||||
js_proxy_t* p;
|
||||
JSObject* obj = JSVAL_TO_OBJECT(*vp);
|
||||
JS_GET_NATIVE_PROXY(p, obj);
|
||||
if (p) {
|
||||
pArray->addObject((CCObject*)p->ptr);
|
||||
}
|
||||
}
|
||||
// next
|
||||
vp++;
|
||||
}
|
||||
return pArray;
|
||||
}
|
||||
else
|
||||
{
|
||||
js_proxy_t* p;
|
||||
JSObject* obj = JSVAL_TO_OBJECT(*vp);
|
||||
JS_GET_NATIVE_PROXY(p, obj);
|
||||
if (p) {
|
||||
pArray->addObject((CCObject*)p->ptr);
|
||||
}
|
||||
}
|
||||
// next
|
||||
vp++;
|
||||
}
|
||||
return pArray;
|
||||
}
|
||||
|
||||
CCRect jsval_to_ccrect(JSContext *cx, jsval v) {
|
||||
|
@ -1498,26 +1503,26 @@ JSBool jsSocketClose(JSContext* cx, unsigned argc, jsval* vp)
|
|||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool jsb_set_reserved_slot(JSObject *obj, uint32_t idx, jsval value)
|
||||
{
|
||||
JSClass *klass = JS_GetClass(obj);
|
||||
unsigned int slots = JSCLASS_RESERVED_SLOTS(klass);
|
||||
if( idx >= slots )
|
||||
return JS_FALSE;
|
||||
|
||||
JS_SetReservedSlot(obj, idx, value);
|
||||
|
||||
return JS_TRUE;
|
||||
JSBool jsb_set_reserved_slot(JSObject *obj, uint32_t idx, jsval value)
|
||||
{
|
||||
JSClass *klass = JS_GetClass(obj);
|
||||
unsigned int slots = JSCLASS_RESERVED_SLOTS(klass);
|
||||
if( idx >= slots )
|
||||
return JS_FALSE;
|
||||
|
||||
JS_SetReservedSlot(obj, idx, value);
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool jsb_get_reserved_slot(JSObject *obj, uint32_t idx, jsval& ret)
|
||||
{
|
||||
JSClass *klass = JS_GetClass(obj);
|
||||
unsigned int slots = JSCLASS_RESERVED_SLOTS(klass);
|
||||
if( idx >= slots )
|
||||
return JS_FALSE;
|
||||
|
||||
ret = JS_GetReservedSlot(obj, idx);
|
||||
|
||||
return JS_TRUE;
|
||||
JSBool jsb_get_reserved_slot(JSObject *obj, uint32_t idx, jsval& ret)
|
||||
{
|
||||
JSClass *klass = JS_GetClass(obj);
|
||||
unsigned int slots = JSCLASS_RESERVED_SLOTS(klass);
|
||||
if( idx >= slots )
|
||||
return JS_FALSE;
|
||||
|
||||
ret = JS_GetReservedSlot(obj, idx);
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
|
|
@ -84,6 +84,7 @@ public:
|
|||
virtual int executeLayerTouchesEvent(CCLayer* pLayer, int eventType, CCSet *pTouches);
|
||||
virtual int executeLayerTouchEvent(CCLayer* pLayer, int eventType, CCTouch *pTouch);
|
||||
virtual int executeAccelerometerEvent(CCLayer* pLayer, CCAcceleration* pAccelerationValue);
|
||||
virtual int executeLayerKeypadEvent(CCLayer* pLayer, int eventType);
|
||||
|
||||
bool executeFunctionWithObjectData(CCNode *self, const char *name, JSObject *obj);
|
||||
int executeFunctionWithOwner(jsval owner, const char *name, jsval data);
|
||||
|
|
Loading…
Reference in New Issue