mirror of https://github.com/axmolengine/axmol.git
Merge pull request #2395 from dumganhar/iss2064-js-node-tranf
fixed #2064: Exposing cc.Node.nodeTo***Transform to JS since it's used in CocoFrameworkJS.
This commit is contained in:
commit
7e7de97706
|
@ -1 +1 @@
|
||||||
fd1fb139a7505d087883dc9eff612594905edb6c
|
ea71fe2a7534446c774678ae4ced20de8fcb5ec8
|
|
@ -1502,6 +1502,31 @@ JSBool jsval_to_ccdictionary(JSContext* cx, jsval v, CCDictionary** ret) {
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JSBool jsval_to_ccaffinetransform(JSContext* cx, jsval v, CCAffineTransform* ret)
|
||||||
|
{
|
||||||
|
JSObject *tmp;
|
||||||
|
jsval jsa, jsb, jsc, jsd, jstx, jsty;
|
||||||
|
double a, b, c, d, tx, ty;
|
||||||
|
JSBool ok = JS_ValueToObject(cx, v, &tmp) &&
|
||||||
|
JS_GetProperty(cx, tmp, "a", &jsa) &&
|
||||||
|
JS_GetProperty(cx, tmp, "b", &jsb) &&
|
||||||
|
JS_GetProperty(cx, tmp, "c", &jsc) &&
|
||||||
|
JS_GetProperty(cx, tmp, "d", &jsd) &&
|
||||||
|
JS_GetProperty(cx, tmp, "tx", &jstx) &&
|
||||||
|
JS_GetProperty(cx, tmp, "ty", &jsty) &&
|
||||||
|
JS_ValueToNumber(cx, jsa, &a) &&
|
||||||
|
JS_ValueToNumber(cx, jsb, &b) &&
|
||||||
|
JS_ValueToNumber(cx, jsc, &c) &&
|
||||||
|
JS_ValueToNumber(cx, jsd, &d) &&
|
||||||
|
JS_ValueToNumber(cx, jstx, &tx) &&
|
||||||
|
JS_ValueToNumber(cx, jsty, &ty);
|
||||||
|
|
||||||
|
JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments");
|
||||||
|
|
||||||
|
*ret = CCAffineTransformMake(a, b, c, d, tx, ty);
|
||||||
|
return JS_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
// From native type to jsval
|
// From native type to jsval
|
||||||
jsval int32_to_jsval( JSContext *cx, int32_t number )
|
jsval int32_to_jsval( JSContext *cx, int32_t number )
|
||||||
{
|
{
|
||||||
|
@ -1629,6 +1654,24 @@ jsval cccolor3b_to_jsval(JSContext* cx, const ccColor3B& v) {
|
||||||
return JSVAL_NULL;
|
return JSVAL_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jsval ccaffinetransform_to_jsval(JSContext* cx, CCAffineTransform& t)
|
||||||
|
{
|
||||||
|
CCLOG("native xxx: a = %f, b = %f, c = %f, d = %f, tx = %f, ty = %f", t.a, t.b, t.c, t.d, t.tx, t.ty);
|
||||||
|
|
||||||
|
JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL);
|
||||||
|
if (!tmp) return JSVAL_NULL;
|
||||||
|
JSBool ok = JS_DefineProperty(cx, tmp, "a", DOUBLE_TO_JSVAL(t.a), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
|
JS_DefineProperty(cx, tmp, "b", DOUBLE_TO_JSVAL(t.b), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
|
JS_DefineProperty(cx, tmp, "c", DOUBLE_TO_JSVAL(t.c), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
|
JS_DefineProperty(cx, tmp, "d", DOUBLE_TO_JSVAL(t.d), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
|
JS_DefineProperty(cx, tmp, "tx", DOUBLE_TO_JSVAL(t.tx), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||||
|
JS_DefineProperty(cx, tmp, "ty", DOUBLE_TO_JSVAL(t.ty), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
if (ok) {
|
||||||
|
return OBJECT_TO_JSVAL(tmp);
|
||||||
|
}
|
||||||
|
return JSVAL_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - Debug
|
#pragma mark - Debug
|
||||||
|
|
||||||
void SimpleRunLoop::update(float dt) {
|
void SimpleRunLoop::update(float dt) {
|
||||||
|
|
|
@ -223,6 +223,7 @@ JSBool jsval_to_ccarray(JSContext* cx, jsval v, CCArray** ret);
|
||||||
JSBool jsval_to_ccdictionary(JSContext* cx, jsval v, CCDictionary** ret);
|
JSBool jsval_to_ccdictionary(JSContext* cx, jsval v, CCDictionary** ret);
|
||||||
JSBool jsval_to_ccacceleration(JSContext* cx,jsval v, CCAcceleration* ret);
|
JSBool jsval_to_ccacceleration(JSContext* cx,jsval v, CCAcceleration* ret);
|
||||||
JSBool jsvals_variadic_to_ccarray( JSContext *cx, jsval *vp, int argc, CCArray** ret);
|
JSBool jsvals_variadic_to_ccarray( JSContext *cx, jsval *vp, int argc, CCArray** ret);
|
||||||
|
JSBool jsval_to_ccaffinetransform(JSContext* cx, jsval v, CCAffineTransform* ret);
|
||||||
|
|
||||||
// from native
|
// from native
|
||||||
jsval int32_to_jsval( JSContext *cx, int32_t l);
|
jsval int32_to_jsval( JSContext *cx, int32_t l);
|
||||||
|
@ -239,6 +240,8 @@ jsval cccolor3b_to_jsval(JSContext* cx, const ccColor3B& v);
|
||||||
jsval ccdictionary_to_jsval(JSContext* cx, CCDictionary *dict);
|
jsval ccdictionary_to_jsval(JSContext* cx, CCDictionary *dict);
|
||||||
jsval ccarray_to_jsval(JSContext* cx, CCArray *arr);
|
jsval ccarray_to_jsval(JSContext* cx, CCArray *arr);
|
||||||
jsval ccacceleration_to_jsval(JSContext* cx, CCAcceleration& v);
|
jsval ccacceleration_to_jsval(JSContext* cx, CCAcceleration& v);
|
||||||
|
jsval ccaffinetransform_to_jsval(JSContext* cx, CCAffineTransform& t);
|
||||||
|
|
||||||
|
|
||||||
JSObject* NewGlobalObject(JSContext* cx, bool debug = false);
|
JSObject* NewGlobalObject(JSContext* cx, bool debug = false);
|
||||||
JSBool jsStartDebugger(JSContext* cx, unsigned argc, jsval* vp);
|
JSBool jsStartDebugger(JSContext* cx, unsigned argc, jsval* vp);
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
62389915a85ebfbc4e1218b1b8e240b1013db859
|
6744be4108703e3312906a288a0766316e2dfba6
|
|
@ -1 +1 @@
|
||||||
Subproject commit cc4765d066b0997d53e4e8b45b38180716c10318
|
Subproject commit 1a84b5e4529b9c37f245953afff8251db7eb9727
|
|
@ -35,7 +35,7 @@ classes = CCSprite.* CCScene CCNode.* CCDirector CCLayer.* CCMenu.* CCTouch CC.*
|
||||||
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
|
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
|
||||||
# functions from all classes.
|
# functions from all classes.
|
||||||
|
|
||||||
skip = CCNode::[.*Transform convertToWindowSpace ^setPosition$ getGrid setGLServerState description getUserObject .*UserData getGLServerState .*schedule],
|
skip = CCNode::[convertToWindowSpace ^setPosition$ getGrid setGLServerState description getUserObject .*UserData getGLServerState .*schedule],
|
||||||
CCSprite::[getQuad displayFrame getBlendFunc ^setPosition$ setBlendFunc setSpriteBatchNode getSpriteBatchNode],
|
CCSprite::[getQuad displayFrame getBlendFunc ^setPosition$ setBlendFunc setSpriteBatchNode getSpriteBatchNode],
|
||||||
CCSpriteBatchNode::[getBlendFunc setBlendFunc],
|
CCSpriteBatchNode::[getBlendFunc setBlendFunc],
|
||||||
CCMotionStreak::[getBlendFunc setBlendFunc],
|
CCMotionStreak::[getBlendFunc setBlendFunc],
|
||||||
|
|
Loading…
Reference in New Issue