mirror of https://github.com/axmolengine/axmol.git
Merge pull request #14668 from pandamicro/v3
Sync v3 and Fix win32 js project crash issue
This commit is contained in:
commit
41218a65e7
|
@ -2,6 +2,8 @@ cocos2d-x-3.10 December ? 2015
|
|||
[NEW] Core: Added Application::getVersion() to get the app version.
|
||||
[NEW] UI: Add PageView indicator.
|
||||
[NEW] Label: Add three Overflow type to new label, see release note for more information.
|
||||
[NEW] UI: UIText::clone supports clone the text effect.
|
||||
[NEW] Label: Add methods to query label effect state.
|
||||
|
||||
[REFINE] UI: RichText support new line element.
|
||||
[REFINE] UI: Set focus to Widget when touched.
|
||||
|
|
|
@ -91,4 +91,4 @@ protected:
|
|||
NS_CC_END
|
||||
|
||||
/// @endcond
|
||||
#endif // __FUNDATION__CCCOMPONENT_H__
|
||||
#endif // __CC_FRAMEWORK_COMPONENT_H__
|
||||
|
|
|
@ -75,4 +75,4 @@ private:
|
|||
NS_CC_END
|
||||
|
||||
/// @endcond
|
||||
#endif // __FUNDATION__CCCOMPONENT_H__
|
||||
#endif // __CC_FRAMEWORK_COMCONTAINER_H__
|
||||
|
|
|
@ -69,4 +69,4 @@ private:
|
|||
|
||||
}
|
||||
|
||||
#endif // __FUNDATION__CCCOMPONENT_H__
|
||||
#endif // __CC_EXTENTIONS_CCCOMATTRIBUTE_H__
|
||||
|
|
|
@ -112,4 +112,4 @@ private:
|
|||
|
||||
}
|
||||
|
||||
#endif // __FUNDATION__CCCOMPONENT_H__
|
||||
#endif // __CC_EXTENTIONS_CCCOMAUDIO_H__
|
||||
|
|
|
@ -82,4 +82,4 @@ public:
|
|||
|
||||
}
|
||||
|
||||
#endif // __FUNDATION__CCCOMPONENT_H__
|
||||
#endif // __CC_EXTENTIONS_CCCOMCONTROLLER_H__
|
||||
|
|
|
@ -84,4 +84,4 @@ private:
|
|||
};
|
||||
|
||||
}
|
||||
#endif // __FUNDATION__CCCOMPONENT_H__
|
||||
#endif // __CC_EXTENTIONS_CCCOMRENDER_H__
|
||||
|
|
|
@ -162,4 +162,4 @@ private:
|
|||
|
||||
}
|
||||
|
||||
#endif // __FUNDATION__CCCOMPONENT_H__
|
||||
#endif // __CC_EXTENTIONS_CCINPUTDELEGATE_H__
|
||||
|
|
|
@ -56,20 +56,6 @@ getDuration : function (
|
|||
return 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method create
|
||||
* @param {String} arg0
|
||||
* @param {String} arg1
|
||||
* @return {cc.Animation3D}
|
||||
*/
|
||||
create : function (
|
||||
str,
|
||||
str
|
||||
)
|
||||
{
|
||||
return cc.Animation3D;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method Animation3D
|
||||
* @constructor
|
||||
|
|
|
@ -4903,6 +4903,32 @@ getElapsed : function (
|
|||
*/
|
||||
cc.Sequence = {
|
||||
|
||||
/**
|
||||
* @method init
|
||||
* @param {Array} arg0
|
||||
* @return {bool}
|
||||
*/
|
||||
init : function (
|
||||
array
|
||||
)
|
||||
{
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method initWithTwoActions
|
||||
* @param {cc.FiniteTimeAction} arg0
|
||||
* @param {cc.FiniteTimeAction} arg1
|
||||
* @return {bool}
|
||||
*/
|
||||
initWithTwoActions : function (
|
||||
finitetimeaction,
|
||||
finitetimeaction
|
||||
)
|
||||
{
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method Sequence
|
||||
* @constructor
|
||||
|
@ -5043,6 +5069,32 @@ RepeatForever : function (
|
|||
*/
|
||||
cc.Spawn = {
|
||||
|
||||
/**
|
||||
* @method init
|
||||
* @param {Array} arg0
|
||||
* @return {bool}
|
||||
*/
|
||||
init : function (
|
||||
array
|
||||
)
|
||||
{
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method initWithTwoActions
|
||||
* @param {cc.FiniteTimeAction} arg0
|
||||
* @param {cc.FiniteTimeAction} arg1
|
||||
* @return {bool}
|
||||
*/
|
||||
initWithTwoActions : function (
|
||||
finitetimeaction,
|
||||
finitetimeaction
|
||||
)
|
||||
{
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method Spawn
|
||||
* @constructor
|
||||
|
|
|
@ -115,38 +115,6 @@ bool js_cocos2dx_3d_Animation3D_getDuration(JSContext *cx, uint32_t argc, jsval
|
|||
JS_ReportError(cx, "js_cocos2dx_3d_Animation3D_getDuration : wrong number of arguments: %d, was expecting %d", argc, 0);
|
||||
return false;
|
||||
}
|
||||
bool js_cocos2dx_3d_Animation3D_create(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
bool ok = true;
|
||||
if (argc == 1) {
|
||||
std::string arg0;
|
||||
ok &= jsval_to_std_string(cx, args.get(0), &arg0);
|
||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Animation3D_create : Error processing arguments");
|
||||
|
||||
auto ret = cocos2d::Animation3D::create(arg0);
|
||||
js_type_class_t *typeClass = js_get_type_from_native<cocos2d::Animation3D>(ret);
|
||||
JS::RootedObject jsret(cx, jsb_ref_autoreleased_create_jsobject(cx, ret, typeClass, "cocos2d::Animation3D"));
|
||||
args.rval().set(OBJECT_TO_JSVAL(jsret));
|
||||
return true;
|
||||
}
|
||||
if (argc == 2) {
|
||||
std::string arg0;
|
||||
std::string arg1;
|
||||
ok &= jsval_to_std_string(cx, args.get(0), &arg0);
|
||||
ok &= jsval_to_std_string(cx, args.get(1), &arg1);
|
||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Animation3D_create : Error processing arguments");
|
||||
|
||||
auto ret = cocos2d::Animation3D::create(arg0, arg1);
|
||||
js_type_class_t *typeClass = js_get_type_from_native<cocos2d::Animation3D>(ret);
|
||||
JS::RootedObject jsret(cx, jsb_ref_autoreleased_create_jsobject(cx, ret, typeClass, "cocos2d::Animation3D"));
|
||||
args.rval().set(OBJECT_TO_JSVAL(jsret));
|
||||
return true;
|
||||
}
|
||||
JS_ReportError(cx, "js_cocos2dx_3d_Animation3D_create : wrong number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool js_cocos2dx_3d_Animation3D_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
|
@ -190,10 +158,7 @@ void js_register_cocos2dx_3d_Animation3D(JSContext *cx, JS::HandleObject global)
|
|||
JS_FS_END
|
||||
};
|
||||
|
||||
static JSFunctionSpec st_funcs[] = {
|
||||
JS_FN("create", js_cocos2dx_3d_Animation3D_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FS_END
|
||||
};
|
||||
JSFunctionSpec *st_funcs = NULL;
|
||||
|
||||
jsb_cocos2d_Animation3D_prototype = JS_InitClass(
|
||||
cx, global,
|
||||
|
|
|
@ -16,7 +16,6 @@ bool js_cocos2dx_3d_Animation3D_initWithFile(JSContext *cx, uint32_t argc, jsval
|
|||
bool js_cocos2dx_3d_Animation3D_init(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_3d_Animation3D_getBoneCurveByName(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_3d_Animation3D_getDuration(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_3d_Animation3D_create(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_3d_Animation3D_Animation3D(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
||||
extern JSClass *jsb_cocos2d_Animate3D_class;
|
||||
|
|
|
@ -7635,7 +7635,7 @@ bool js_cocos2dx_Director_getInstance(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
|
||||
auto ret = cocos2d::Director::getInstance();
|
||||
js_type_class_t *typeClass = js_get_type_from_native<cocos2d::Director>(ret);
|
||||
JS::RootedObject jsret(cx, jsb_ref_singleton_get_or_create_jsobject(cx, ret, typeClass, "cocos2d::Director"));
|
||||
JS::RootedObject jsret(cx, jsb_ref_get_or_create_jsobject(cx, ret, typeClass, "cocos2d::Director"));
|
||||
args.rval().set(OBJECT_TO_JSVAL(jsret));
|
||||
return true;
|
||||
}
|
||||
|
@ -12214,6 +12214,68 @@ void js_register_cocos2dx_ActionInterval(JSContext *cx, JS::HandleObject global)
|
|||
JSClass *jsb_cocos2d_Sequence_class;
|
||||
JSObject *jsb_cocos2d_Sequence_prototype;
|
||||
|
||||
bool js_cocos2dx_Sequence_init(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
bool ok = true;
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::Sequence* cobj = (cocos2d::Sequence *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sequence_init : Invalid Native Object");
|
||||
if (argc == 1) {
|
||||
cocos2d::Vector<cocos2d::FiniteTimeAction *> arg0;
|
||||
ok &= jsval_to_ccvector(cx, args.get(0), &arg0);
|
||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Sequence_init : Error processing arguments");
|
||||
bool ret = cobj->init(arg0);
|
||||
jsval jsret = JSVAL_NULL;
|
||||
jsret = BOOLEAN_TO_JSVAL(ret);
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "js_cocos2dx_Sequence_init : wrong number of arguments: %d, was expecting %d", argc, 1);
|
||||
return false;
|
||||
}
|
||||
bool js_cocos2dx_Sequence_initWithTwoActions(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
bool ok = true;
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::Sequence* cobj = (cocos2d::Sequence *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sequence_initWithTwoActions : Invalid Native Object");
|
||||
if (argc == 2) {
|
||||
cocos2d::FiniteTimeAction* arg0 = nullptr;
|
||||
cocos2d::FiniteTimeAction* arg1 = nullptr;
|
||||
do {
|
||||
if (args.get(0).isNull()) { arg0 = nullptr; break; }
|
||||
if (!args.get(0).isObject()) { ok = false; break; }
|
||||
js_proxy_t *jsProxy;
|
||||
JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
|
||||
jsProxy = jsb_get_js_proxy(tmpObj);
|
||||
arg0 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object");
|
||||
} while (0);
|
||||
do {
|
||||
if (args.get(1).isNull()) { arg1 = nullptr; break; }
|
||||
if (!args.get(1).isObject()) { ok = false; break; }
|
||||
js_proxy_t *jsProxy;
|
||||
JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull());
|
||||
jsProxy = jsb_get_js_proxy(tmpObj);
|
||||
arg1 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object");
|
||||
} while (0);
|
||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Sequence_initWithTwoActions : Error processing arguments");
|
||||
bool ret = cobj->initWithTwoActions(arg0, arg1);
|
||||
jsval jsret = JSVAL_NULL;
|
||||
jsret = BOOLEAN_TO_JSVAL(ret);
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "js_cocos2dx_Sequence_initWithTwoActions : wrong number of arguments: %d, was expecting %d", argc, 2);
|
||||
return false;
|
||||
}
|
||||
bool js_cocos2dx_Sequence_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
|
@ -12266,6 +12328,8 @@ void js_register_cocos2dx_Sequence(JSContext *cx, JS::HandleObject global) {
|
|||
};
|
||||
|
||||
static JSFunctionSpec funcs[] = {
|
||||
JS_FN("init", js_cocos2dx_Sequence_init, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("initWithTwoActions", js_cocos2dx_Sequence_initWithTwoActions, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("ctor", js_cocos2dx_Sequence_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FS_END
|
||||
};
|
||||
|
@ -12678,6 +12742,68 @@ void js_register_cocos2dx_RepeatForever(JSContext *cx, JS::HandleObject global)
|
|||
JSClass *jsb_cocos2d_Spawn_class;
|
||||
JSObject *jsb_cocos2d_Spawn_prototype;
|
||||
|
||||
bool js_cocos2dx_Spawn_init(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
bool ok = true;
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::Spawn* cobj = (cocos2d::Spawn *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Spawn_init : Invalid Native Object");
|
||||
if (argc == 1) {
|
||||
cocos2d::Vector<cocos2d::FiniteTimeAction *> arg0;
|
||||
ok &= jsval_to_ccvector(cx, args.get(0), &arg0);
|
||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Spawn_init : Error processing arguments");
|
||||
bool ret = cobj->init(arg0);
|
||||
jsval jsret = JSVAL_NULL;
|
||||
jsret = BOOLEAN_TO_JSVAL(ret);
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "js_cocos2dx_Spawn_init : wrong number of arguments: %d, was expecting %d", argc, 1);
|
||||
return false;
|
||||
}
|
||||
bool js_cocos2dx_Spawn_initWithTwoActions(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
bool ok = true;
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::Spawn* cobj = (cocos2d::Spawn *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Spawn_initWithTwoActions : Invalid Native Object");
|
||||
if (argc == 2) {
|
||||
cocos2d::FiniteTimeAction* arg0 = nullptr;
|
||||
cocos2d::FiniteTimeAction* arg1 = nullptr;
|
||||
do {
|
||||
if (args.get(0).isNull()) { arg0 = nullptr; break; }
|
||||
if (!args.get(0).isObject()) { ok = false; break; }
|
||||
js_proxy_t *jsProxy;
|
||||
JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull());
|
||||
jsProxy = jsb_get_js_proxy(tmpObj);
|
||||
arg0 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object");
|
||||
} while (0);
|
||||
do {
|
||||
if (args.get(1).isNull()) { arg1 = nullptr; break; }
|
||||
if (!args.get(1).isObject()) { ok = false; break; }
|
||||
js_proxy_t *jsProxy;
|
||||
JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull());
|
||||
jsProxy = jsb_get_js_proxy(tmpObj);
|
||||
arg1 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object");
|
||||
} while (0);
|
||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Spawn_initWithTwoActions : Error processing arguments");
|
||||
bool ret = cobj->initWithTwoActions(arg0, arg1);
|
||||
jsval jsret = JSVAL_NULL;
|
||||
jsret = BOOLEAN_TO_JSVAL(ret);
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "js_cocos2dx_Spawn_initWithTwoActions : wrong number of arguments: %d, was expecting %d", argc, 2);
|
||||
return false;
|
||||
}
|
||||
bool js_cocos2dx_Spawn_constructor(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
|
@ -12730,6 +12856,8 @@ void js_register_cocos2dx_Spawn(JSContext *cx, JS::HandleObject global) {
|
|||
};
|
||||
|
||||
static JSFunctionSpec funcs[] = {
|
||||
JS_FN("init", js_cocos2dx_Spawn_init, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("initWithTwoActions", js_cocos2dx_Spawn_initWithTwoActions, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("ctor", js_cocos2dx_Spawn_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FS_END
|
||||
};
|
||||
|
@ -16726,7 +16854,7 @@ bool js_cocos2dx_Configuration_getInstance(JSContext *cx, uint32_t argc, jsval *
|
|||
|
||||
auto ret = cocos2d::Configuration::getInstance();
|
||||
js_type_class_t *typeClass = js_get_type_from_native<cocos2d::Configuration>(ret);
|
||||
JS::RootedObject jsret(cx, jsb_ref_singleton_get_or_create_jsobject(cx, ret, typeClass, "cocos2d::Configuration"));
|
||||
JS::RootedObject jsret(cx, jsb_ref_get_or_create_jsobject(cx, ret, typeClass, "cocos2d::Configuration"));
|
||||
args.rval().set(OBJECT_TO_JSVAL(jsret));
|
||||
return true;
|
||||
}
|
||||
|
@ -55950,7 +56078,7 @@ bool js_cocos2dx_GLProgramCache_getInstance(JSContext *cx, uint32_t argc, jsval
|
|||
|
||||
auto ret = cocos2d::GLProgramCache::getInstance();
|
||||
js_type_class_t *typeClass = js_get_type_from_native<cocos2d::GLProgramCache>(ret);
|
||||
JS::RootedObject jsret(cx, jsb_ref_singleton_get_or_create_jsobject(cx, ret, typeClass, "cocos2d::GLProgramCache"));
|
||||
JS::RootedObject jsret(cx, jsb_ref_get_or_create_jsobject(cx, ret, typeClass, "cocos2d::GLProgramCache"));
|
||||
args.rval().set(OBJECT_TO_JSVAL(jsret));
|
||||
return true;
|
||||
}
|
||||
|
@ -58157,7 +58285,7 @@ bool js_cocos2dx_AnimationCache_getInstance(JSContext *cx, uint32_t argc, jsval
|
|||
|
||||
auto ret = cocos2d::AnimationCache::getInstance();
|
||||
js_type_class_t *typeClass = js_get_type_from_native<cocos2d::AnimationCache>(ret);
|
||||
JS::RootedObject jsret(cx, jsb_ref_singleton_get_or_create_jsobject(cx, ret, typeClass, "cocos2d::AnimationCache"));
|
||||
JS::RootedObject jsret(cx, jsb_ref_get_or_create_jsobject(cx, ret, typeClass, "cocos2d::AnimationCache"));
|
||||
args.rval().set(OBJECT_TO_JSVAL(jsret));
|
||||
return true;
|
||||
}
|
||||
|
@ -59307,7 +59435,7 @@ bool js_cocos2dx_SpriteFrameCache_getInstance(JSContext *cx, uint32_t argc, jsva
|
|||
|
||||
auto ret = cocos2d::SpriteFrameCache::getInstance();
|
||||
js_type_class_t *typeClass = js_get_type_from_native<cocos2d::SpriteFrameCache>(ret);
|
||||
JS::RootedObject jsret(cx, jsb_ref_singleton_get_or_create_jsobject(cx, ret, typeClass, "cocos2d::SpriteFrameCache"));
|
||||
JS::RootedObject jsret(cx, jsb_ref_get_or_create_jsobject(cx, ret, typeClass, "cocos2d::SpriteFrameCache"));
|
||||
args.rval().set(OBJECT_TO_JSVAL(jsret));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -648,6 +648,8 @@ bool js_cocos2dx_Sequence_constructor(JSContext *cx, uint32_t argc, jsval *vp);
|
|||
void js_cocos2dx_Sequence_finalize(JSContext *cx, JSObject *obj);
|
||||
void js_register_cocos2dx_Sequence(JSContext *cx, JS::HandleObject global);
|
||||
void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj);
|
||||
bool js_cocos2dx_Sequence_init(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Sequence_initWithTwoActions(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Sequence_Sequence(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
||||
extern JSClass *jsb_cocos2d_Repeat_class;
|
||||
|
@ -683,6 +685,8 @@ bool js_cocos2dx_Spawn_constructor(JSContext *cx, uint32_t argc, jsval *vp);
|
|||
void js_cocos2dx_Spawn_finalize(JSContext *cx, JSObject *obj);
|
||||
void js_register_cocos2dx_Spawn(JSContext *cx, JS::HandleObject global);
|
||||
void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj);
|
||||
bool js_cocos2dx_Spawn_init(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Spawn_initWithTwoActions(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Spawn_Spawn(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
||||
extern JSClass *jsb_cocos2d_RotateTo_class;
|
||||
|
|
|
@ -698,7 +698,7 @@ bool js_cocos2dx_studio_ActionManagerEx_getInstance(JSContext *cx, uint32_t argc
|
|||
|
||||
auto ret = cocostudio::ActionManagerEx::getInstance();
|
||||
js_type_class_t *typeClass = js_get_type_from_native<cocostudio::ActionManagerEx>(ret);
|
||||
JS::RootedObject jsret(cx, jsb_ref_singleton_get_or_create_jsobject(cx, ret, typeClass, "cocostudio::ActionManagerEx"));
|
||||
JS::RootedObject jsret(cx, jsb_ref_get_or_create_jsobject(cx, ret, typeClass, "cocostudio::ActionManagerEx"));
|
||||
args.rval().set(OBJECT_TO_JSVAL(jsret));
|
||||
return true;
|
||||
}
|
||||
|
@ -5172,7 +5172,7 @@ bool js_cocos2dx_studio_ArmatureDataManager_getInstance(JSContext *cx, uint32_t
|
|||
|
||||
auto ret = cocostudio::ArmatureDataManager::getInstance();
|
||||
js_type_class_t *typeClass = js_get_type_from_native<cocostudio::ArmatureDataManager>(ret);
|
||||
JS::RootedObject jsret(cx, jsb_ref_singleton_get_or_create_jsobject(cx, ret, typeClass, "cocostudio::ArmatureDataManager"));
|
||||
JS::RootedObject jsret(cx, jsb_ref_get_or_create_jsobject(cx, ret, typeClass, "cocostudio::ArmatureDataManager"));
|
||||
args.rval().set(OBJECT_TO_JSVAL(jsret));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -64,8 +64,8 @@ static bool js_cocos2dx_Sprite3D_createAsync(JSContext *cx, uint32_t argc, jsval
|
|||
auto lambda = [=](Sprite3D* larg0, void* larg1) -> void{
|
||||
|
||||
jsval largv[2];
|
||||
js_proxy_t* proxy = js_get_or_create_proxy(cx, larg0);
|
||||
largv[0] = proxy ? OBJECT_TO_JSVAL(proxy->obj) : JS::UndefinedValue();
|
||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||
largv[0] = OBJECT_TO_JSVAL(js_get_or_create_jsobject<Sprite3D>(cx, larg0));
|
||||
JSB_HeapValueWrapper* v = (JSB_HeapValueWrapper*)larg1;
|
||||
largv[1] = v->get();
|
||||
|
||||
|
@ -280,8 +280,7 @@ bool js_cocos2dx_Terrain_create(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
ret = Terrain::create(arg0, arg1);
|
||||
}
|
||||
|
||||
js_proxy_t *jsProxy = js_get_or_create_proxy<Terrain>(cx, (Terrain*)ret);
|
||||
args.rval().set(OBJECT_TO_JSVAL(jsProxy->obj));
|
||||
args.rval().set(OBJECT_TO_JSVAL(js_get_or_create_jsobject<Terrain>(cx, ret)));
|
||||
return true;
|
||||
}
|
||||
JS_ReportError(cx, "wrong number of arguments");
|
||||
|
@ -342,6 +341,42 @@ bool js_cocos2dx_Terrain_getHeightData(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
return false;
|
||||
}
|
||||
|
||||
// this code cannot be automated since it must use
|
||||
// get_or_create_jsobject instead of create_jsobject
|
||||
// since Animation3D::create() might return an existing copy
|
||||
// since it caches them
|
||||
bool js_cocos2dx_3d_Animation3D_create(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
bool ok = true;
|
||||
if (argc == 1) {
|
||||
std::string arg0;
|
||||
ok &= jsval_to_std_string(cx, args.get(0), &arg0);
|
||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Animation3D_create : Error processing arguments");
|
||||
|
||||
auto ret = cocos2d::Animation3D::create(arg0);
|
||||
js_type_class_t *typeClass = js_get_type_from_native<cocos2d::Animation3D>(ret);
|
||||
JS::RootedObject jsret(cx, jsb_ref_autoreleased_get_or_create_jsobject(cx, ret, typeClass, "cocos2d::Animation3D"));
|
||||
args.rval().set(OBJECT_TO_JSVAL(jsret));
|
||||
return true;
|
||||
}
|
||||
if (argc == 2) {
|
||||
std::string arg0;
|
||||
std::string arg1;
|
||||
ok &= jsval_to_std_string(cx, args.get(0), &arg0);
|
||||
ok &= jsval_to_std_string(cx, args.get(1), &arg1);
|
||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Animation3D_create : Error processing arguments");
|
||||
|
||||
auto ret = cocos2d::Animation3D::create(arg0, arg1);
|
||||
js_type_class_t *typeClass = js_get_type_from_native<cocos2d::Animation3D>(ret);
|
||||
JS::RootedObject jsret(cx, jsb_ref_autoreleased_get_or_create_jsobject(cx, ret, typeClass, "cocos2d::Animation3D"));
|
||||
args.rval().set(OBJECT_TO_JSVAL(jsret));
|
||||
return true;
|
||||
}
|
||||
JS_ReportError(cx, "js_cocos2dx_3d_Animation3D_create : wrong number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
void register_all_cocos2dx_3d_manual(JSContext *cx, JS::HandleObject global)
|
||||
{
|
||||
JS::RootedValue tmpVal(cx);
|
||||
|
@ -357,6 +392,10 @@ void register_all_cocos2dx_3d_manual(JSContext *cx, JS::HandleObject global)
|
|||
tmpObj.set(tmpVal.toObjectOrNull());
|
||||
JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_Terrain_create, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
|
||||
JS_GetProperty(cx, ccObj, "Animation3D", &tmpVal);
|
||||
tmpObj.set(tmpVal.toObjectOrNull());
|
||||
JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_3d_Animation3D_create, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
|
||||
JS_GetProperty(cx, ccObj, "Bundle3D", &tmpVal);
|
||||
tmpObj.set(tmpVal.toObjectOrNull());
|
||||
JS_DefineFunction(cx, tmpObj, "getTrianglesList", js_cocos2dx_Bundle3D_getTrianglesList, 1, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
|
|
|
@ -430,8 +430,9 @@ void registerDefaultClasses(JSContext* cx, JS::HandleObject global) {
|
|||
JS_DefineFunction(cx, global, "__isObjectValid", ScriptingCore::isObjectValid, 1, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
}
|
||||
|
||||
static void sc_finalize(JSFreeOp *freeOp, JSObject *obj) {
|
||||
CCLOGINFO("jsbindings: finalizing JS object %p (global class)", obj);
|
||||
static void sc_finalize(JSFreeOp *freeOp, JSObject *obj)
|
||||
{
|
||||
CCLOG("jsbindings: finalizing JS object %p (global class)", obj);
|
||||
}
|
||||
|
||||
//static JSClass global_class = {
|
||||
|
@ -1181,10 +1182,17 @@ bool ScriptingCore::handleTouchesEvent(void* nativeObj, cocos2d::EventTouch::Eve
|
|||
|
||||
// AddNamedObjectRoot(this->_cx, &jsretArr, "touchArray");
|
||||
int count = 0;
|
||||
|
||||
|
||||
js_type_class_t *typeClassEvent = nullptr;
|
||||
js_type_class_t *typeClassTouch = nullptr;
|
||||
|
||||
if (touches.size()>0)
|
||||
typeClassTouch = js_get_type_from_native<cocos2d::Touch>(touches[0]);
|
||||
typeClassEvent = js_get_type_from_native<cocos2d::Event>(event);
|
||||
|
||||
for (const auto& touch : touches)
|
||||
{
|
||||
JS::RootedValue jsret(_cx, OBJECT_TO_JSVAL(js_get_or_create_jsobject<cocos2d::Touch>(this->_cx, touch)));
|
||||
JS::RootedValue jsret(_cx, OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(_cx, touch, typeClassTouch, "cocos2d::Touch")));
|
||||
if (!JS_SetElement(this->_cx, jsretArr, count, jsret))
|
||||
{
|
||||
break;
|
||||
|
@ -1192,19 +1200,14 @@ bool ScriptingCore::handleTouchesEvent(void* nativeObj, cocos2d::EventTouch::Eve
|
|||
++count;
|
||||
}
|
||||
|
||||
do
|
||||
js_proxy_t* p = jsb_get_native_proxy(nativeObj);
|
||||
if (p)
|
||||
{
|
||||
js_proxy_t * p = jsb_get_native_proxy(nativeObj);
|
||||
if (!p) break;
|
||||
|
||||
jsval dataVal[2];
|
||||
dataVal[0] = OBJECT_TO_JSVAL(jsretArr);
|
||||
dataVal[1] = OBJECT_TO_JSVAL(js_get_or_create_jsobject<cocos2d::Event>(_cx, event));
|
||||
|
||||
dataVal[1] = OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(_cx, event, typeClassEvent, "cocos2d::Event"));
|
||||
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), funcName.c_str(), 2, dataVal, jsvalRet);
|
||||
|
||||
|
||||
} while(false);
|
||||
}
|
||||
|
||||
// JS_RemoveObjectRoot(this->_cx, &jsretArr);
|
||||
|
||||
|
@ -1231,37 +1234,18 @@ bool ScriptingCore::handleTouchEvent(void* nativeObj, cocos2d::EventTouch::Event
|
|||
std::string funcName = getTouchFuncName(eventCode);
|
||||
bool ret = false;
|
||||
|
||||
do
|
||||
js_proxy_t * p = jsb_get_native_proxy(nativeObj);
|
||||
if (p)
|
||||
{
|
||||
js_proxy_t * p = jsb_get_native_proxy(nativeObj);
|
||||
if (!p) break;
|
||||
|
||||
js_type_class_t *typeClassTouch = js_get_type_from_native<cocos2d::Touch>(touch);
|
||||
js_type_class_t *typeClassEvent = js_get_type_from_native<cocos2d::Event>(event);
|
||||
|
||||
jsval dataVal[2];
|
||||
dataVal[0] = OBJECT_TO_JSVAL(js_get_or_create_jsobject<cocos2d::Touch>(_cx, touch));
|
||||
dataVal[1] = OBJECT_TO_JSVAL(js_get_or_create_jsobject<cocos2d::Event>(_cx, event));
|
||||
|
||||
// if (jsvalRet != nullptr)
|
||||
// {
|
||||
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), funcName.c_str(), 2, dataVal, jsvalRet);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// JS::RootedValue retval(_cx);
|
||||
// executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), funcName.c_str(), 2, dataVal, &retval);
|
||||
// if(retval.isNull())
|
||||
// {
|
||||
// ret = false;
|
||||
// }
|
||||
// else if(retval.isBoolean())
|
||||
// {
|
||||
// ret = retval.toBoolean();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// ret = false;
|
||||
// }
|
||||
// }
|
||||
} while(false);
|
||||
dataVal[0] = OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(_cx, touch, typeClassTouch, "cocos2d::Touch"));
|
||||
dataVal[1] = OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(_cx, event, typeClassEvent, "cocos2d::Event"));
|
||||
|
||||
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), funcName.c_str(), 2, dataVal, jsvalRet);
|
||||
}
|
||||
|
||||
removeJSObject(_cx, touch);
|
||||
removeJSObject(_cx, event);
|
||||
|
@ -1282,37 +1266,15 @@ bool ScriptingCore::handleMouseEvent(void* nativeObj, cocos2d::EventMouse::Mouse
|
|||
std::string funcName = getMouseFuncName(eventType);
|
||||
bool ret = false;
|
||||
|
||||
do
|
||||
js_proxy_t * p = jsb_get_native_proxy(nativeObj);
|
||||
if (p)
|
||||
{
|
||||
js_proxy_t * p = jsb_get_native_proxy(nativeObj);
|
||||
if (!p) break;
|
||||
|
||||
jsval dataVal[1];
|
||||
dataVal[0] = OBJECT_TO_JSVAL(js_get_or_create_jsobject<cocos2d::Event>(_cx, event));
|
||||
|
||||
// if (jsvalRet != nullptr)
|
||||
// {
|
||||
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), funcName.c_str(), 1, dataVal, jsvalRet);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// JS::RootedValue retval(_cx);
|
||||
// executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), funcName.c_str(), 1, dataVal, &retval);
|
||||
// if(retval.isNull())
|
||||
// {
|
||||
// ret = false;
|
||||
// }
|
||||
// else if(retval.isBoolean())
|
||||
// {
|
||||
// ret = retval.toBoolean();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// ret = false;
|
||||
// }
|
||||
// }
|
||||
} while(false);
|
||||
|
||||
js_type_class_t *typeClass = js_get_type_from_native<cocos2d::Event>(event);
|
||||
dataVal[0] = OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(_cx, event, typeClass, "cocos2d::Event"));
|
||||
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), funcName.c_str(), 1, dataVal, jsvalRet);
|
||||
}
|
||||
|
||||
removeJSObject(_cx, event);
|
||||
|
||||
return ret;
|
||||
|
@ -1396,10 +1358,11 @@ bool ScriptingCore::handleKeybardEvent(void* nativeObj, cocos2d::EventKeyboard::
|
|||
return false;
|
||||
|
||||
bool ret = false;
|
||||
|
||||
|
||||
js_type_class_t *typeClass = js_get_type_from_native<cocos2d::Event>(event);
|
||||
jsval args[2] = {
|
||||
int32_to_jsval(_cx, (int32_t)keyCode),
|
||||
OBJECT_TO_JSVAL(js_get_or_create_jsobject<cocos2d::Event>(_cx, event))
|
||||
OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(_cx, event, typeClass, "cocos2d::Event"))
|
||||
};
|
||||
|
||||
if (isPressed)
|
||||
|
@ -1425,9 +1388,11 @@ bool ScriptingCore::handleFocusEvent(void* nativeObj, cocos2d::ui::Widget* widge
|
|||
if (nullptr == p)
|
||||
return false;
|
||||
|
||||
js_type_class_t *typeClass = js_get_type_from_native<cocos2d::ui::Widget>(widgetLoseFocus);
|
||||
|
||||
jsval args[2] = {
|
||||
OBJECT_TO_JSVAL(js_get_or_create_jsobject<cocos2d::ui::Widget>(_cx, widgetLoseFocus)),
|
||||
OBJECT_TO_JSVAL(js_get_or_create_jsobject<cocos2d::ui::Widget>(_cx, widgetGetFocus))
|
||||
OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(_cx, widgetLoseFocus, typeClass, "cocos2d::ui::Widget")),
|
||||
OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(_cx, widgetGetFocus, typeClass, "cocos2d::ui::Widget"))
|
||||
};
|
||||
|
||||
bool ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onFocusChanged", 2, args);
|
||||
|
@ -1446,7 +1411,9 @@ int ScriptingCore::executeCustomTouchesEvent(EventTouch::EventCode eventType,
|
|||
int count = 0;
|
||||
for (auto& touch : touches)
|
||||
{
|
||||
jsval jsret = OBJECT_TO_JSVAL(js_get_or_create_jsobject<Touch>(this->_cx, touch));
|
||||
js_type_class_t *typeClass = js_get_type_from_native<cocos2d::Touch>(touch);
|
||||
|
||||
jsval jsret = OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(this->_cx, touch, typeClass, "cocos2d::Touch"));
|
||||
JS::RootedValue jsval(_cx, jsret);
|
||||
if (!JS_SetElement(this->_cx, jsretArr, count, jsval)) {
|
||||
break;
|
||||
|
@ -1467,20 +1434,20 @@ int ScriptingCore::executeCustomTouchesEvent(EventTouch::EventCode eventType,
|
|||
}
|
||||
|
||||
|
||||
int ScriptingCore::executeCustomTouchEvent(EventTouch::EventCode eventType,
|
||||
Touch *pTouch, JSObject *obj)
|
||||
int ScriptingCore::executeCustomTouchEvent(EventTouch::EventCode eventType, Touch *touch, JSObject *obj)
|
||||
{
|
||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||
|
||||
JS::RootedValue retval(_cx);
|
||||
std::string funcName = getTouchFuncName(eventType);
|
||||
|
||||
jsval jsTouch = OBJECT_TO_JSVAL(js_get_or_create_jsobject<Touch>(this->_cx, pTouch));
|
||||
js_type_class_t *typeClass = js_get_type_from_native<cocos2d::Touch>(touch);
|
||||
jsval jsTouch = OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(this->_cx, touch, typeClass, "cocos2d::Touch"));
|
||||
|
||||
executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), funcName.c_str(), 1, &jsTouch, &retval);
|
||||
|
||||
// Remove touch object from global hash table and unroot it.
|
||||
removeJSObject(this->_cx, pTouch);
|
||||
removeJSObject(this->_cx, touch);
|
||||
|
||||
return 1;
|
||||
|
||||
|
@ -1488,19 +1455,20 @@ int ScriptingCore::executeCustomTouchEvent(EventTouch::EventCode eventType,
|
|||
|
||||
|
||||
int ScriptingCore::executeCustomTouchEvent(EventTouch::EventCode eventType,
|
||||
Touch *pTouch, JSObject *obj,
|
||||
Touch *touch, JSObject *obj,
|
||||
JS::MutableHandleValue retval)
|
||||
{
|
||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||
|
||||
std::string funcName = getTouchFuncName(eventType);
|
||||
|
||||
jsval jsTouch = OBJECT_TO_JSVAL(js_get_or_create_jsobject<Touch>(this->_cx, pTouch));
|
||||
js_type_class_t *typeClass = js_get_type_from_native<cocos2d::Touch>(touch);
|
||||
jsval jsTouch = OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(this->_cx, touch, typeClass, "cocos2d::Touch"));
|
||||
|
||||
executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), funcName.c_str(), 1, &jsTouch, retval);
|
||||
|
||||
// Remove touch object from global hash table and unroot it.
|
||||
removeJSObject(this->_cx, pTouch);
|
||||
removeJSObject(this->_cx, touch);
|
||||
|
||||
return 1;
|
||||
|
||||
|
@ -1611,6 +1579,7 @@ void ScriptingCore::unrootObject(Ref* ref)
|
|||
js_proxy_t* nproxy;
|
||||
js_proxy_t* jsproxy;
|
||||
void *ptr = (void*)ref;
|
||||
|
||||
nproxy = jsb_get_native_proxy(ptr);
|
||||
if (nproxy) {
|
||||
JSContext *cx = getGlobalContext();
|
||||
|
@ -1621,7 +1590,7 @@ void ScriptingCore::unrootObject(Ref* ref)
|
|||
jsproxy = jsb_get_js_proxy(handle);
|
||||
RemoveObjectRoot(cx, &jsproxy->obj);
|
||||
|
||||
CCLOG("Unrooting %p - %p: %s", ref, &jsproxy->obj, typeid(*ref).name());
|
||||
CCLOG("Unrooting #2 %p - %p: %s", ref, &jsproxy->obj, typeid(*ref).name());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1900,14 +1869,14 @@ void ScriptingCore::enableDebugger(unsigned int port)
|
|||
}
|
||||
}
|
||||
|
||||
JS::HandleObject NewGlobalObject(JSContext* cx, bool debug)
|
||||
JSObject* NewGlobalObject(JSContext* cx, bool debug)
|
||||
{
|
||||
JS::CompartmentOptions options;
|
||||
options.setVersion(JSVERSION_LATEST);
|
||||
|
||||
JS::RootedObject glob(cx, JS_NewGlobalObject(cx, &global_class, &shellTrustedPrincipals, JS::DontFireOnNewGlobalHook, options));
|
||||
if (!glob) {
|
||||
return JS::NullPtr();
|
||||
return nullptr;
|
||||
}
|
||||
JSAutoCompartment ac(cx, glob);
|
||||
bool ok = true;
|
||||
|
@ -1917,7 +1886,7 @@ JS::HandleObject NewGlobalObject(JSContext* cx, bool debug)
|
|||
if (ok && debug)
|
||||
ok = JS_DefineDebuggerObject(cx, glob);
|
||||
if (!ok)
|
||||
return JS::NullPtr();
|
||||
return nullptr;
|
||||
|
||||
JS_FireOnNewGlobalObject(cx, glob);
|
||||
|
||||
|
@ -2018,33 +1987,38 @@ JSObject* jsb_ref_autoreleased_create_jsobject(JSContext *cx, cocos2d::Ref *ref,
|
|||
return js_obj;
|
||||
}
|
||||
|
||||
JSObject* jsb_ref_singleton_create_jsobject(JSContext *cx, cocos2d::Ref *ref, js_type_class_t *typeClass, const char* debug)
|
||||
{
|
||||
JS::RootedObject proto(cx, typeClass->proto.ref());
|
||||
JS::RootedObject parent(cx, typeClass->parentProto.ref());
|
||||
JS::RootedObject js_obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
|
||||
js_proxy_t* newproxy = jsb_new_proxy(ref, js_obj);
|
||||
jsb_ref_singleton_init(cx, &newproxy->obj, ref, debug);
|
||||
return js_obj;
|
||||
}
|
||||
|
||||
// get_or_create
|
||||
JSObject* jsb_ref_get_or_create_jsobject(JSContext *cx, cocos2d::Ref *ref, js_type_class_t *typeClass, const char* debug)
|
||||
{
|
||||
auto proxy = jsb_get_native_proxy(ref);
|
||||
if (proxy)
|
||||
return proxy->obj;
|
||||
// else
|
||||
return jsb_ref_create_jsobject(cx, ref, typeClass, debug);
|
||||
|
||||
// don't auto-release, don't retain.
|
||||
JS::RootedObject proto(cx, typeClass->proto.ref());
|
||||
JS::RootedObject parent(cx, typeClass->parentProto.ref());
|
||||
JS::RootedObject js_obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent));
|
||||
js_proxy_t* newproxy = jsb_new_proxy(ref, js_obj);
|
||||
#if CC_ENABLE_GC_FOR_NATIVE_OBJECTS
|
||||
CC_UNUSED_PARAM(newproxy);
|
||||
// don't retain it.
|
||||
ref->_scriptOwned = true;
|
||||
#else
|
||||
// don't autorelease it
|
||||
JS::AddNamedObjectRoot(cx, &newproxy->obj, debug);
|
||||
#endif
|
||||
|
||||
return js_obj;
|
||||
}
|
||||
|
||||
JSObject* jsb_ref_singleton_get_or_create_jsobject(JSContext *cx, cocos2d::Ref *ref, js_type_class_t *typeClass, const char* debug)
|
||||
// get_or_create: REf is already autoreleased (or created)
|
||||
JSObject* jsb_ref_autoreleased_get_or_create_jsobject(JSContext *cx, cocos2d::Ref *ref, js_type_class_t *typeClass, const char* debug)
|
||||
{
|
||||
auto proxy = jsb_get_native_proxy(ref);
|
||||
if (proxy)
|
||||
return proxy->obj;
|
||||
// else
|
||||
return jsb_ref_singleton_create_jsobject(cx, ref, typeClass, debug);
|
||||
return jsb_ref_autoreleased_create_jsobject(cx, ref, typeClass, debug);
|
||||
}
|
||||
|
||||
// ref_init
|
||||
|
@ -2071,34 +2045,24 @@ void jsb_ref_autoreleased_init(JSContext* cx, JS::Heap<JSObject*> *obj, Ref* ref
|
|||
(void)obj;
|
||||
ref->_scriptOwned = true;
|
||||
// retain it, since the object is autoreleased
|
||||
ret->retain();
|
||||
ref->retain();
|
||||
#else
|
||||
// don't autorelease it, since it is already autoreleased
|
||||
JS::AddNamedObjectRoot(cx, obj, debug);
|
||||
#endif
|
||||
}
|
||||
|
||||
void jsb_ref_singleton_init(JSContext* cx, JS::Heap<JSObject*> *obj, Ref* ref, const char* debug)
|
||||
{
|
||||
// CCLOG("jsb_ref_singleton_init: JSObject address = %p. %s", obj->get(), debug);
|
||||
#if CC_ENABLE_GC_FOR_NATIVE_OBJECTS
|
||||
(void)cx;
|
||||
(void)obj;
|
||||
ref->_scriptOwned = true;
|
||||
// don't retain it: it is a singleton
|
||||
#else
|
||||
// don't autorelease it: it is a singleton
|
||||
JS::AddNamedObjectRoot(cx, obj, debug);
|
||||
#endif
|
||||
}
|
||||
|
||||
// finalize
|
||||
void jsb_ref_finalize(JSFreeOp* fop, JSObject* obj)
|
||||
{
|
||||
#if CC_ENABLE_GC_FOR_NATIVE_OBJECTS
|
||||
js_proxy_t* nproxy;
|
||||
js_proxy_t* jsproxy;
|
||||
jsproxy = jsb_get_js_proxy(obj);
|
||||
|
||||
CCLOG("jsb_ref_finalize #1: JSObject address = %p", obj);
|
||||
|
||||
JS::RootedObject jsobj(fop->runtime(), obj);
|
||||
jsproxy = jsb_get_js_proxy(jsobj);
|
||||
if (jsproxy)
|
||||
{
|
||||
auto ref = static_cast<cocos2d::Ref*>(jsproxy->ptr);
|
||||
|
@ -2106,7 +2070,7 @@ void jsb_ref_finalize(JSFreeOp* fop, JSObject* obj)
|
|||
|
||||
if (ref)
|
||||
{
|
||||
CCLOG("jsb_ref_finalize: JSObject address = %p (%s)", obj, typeid(*ref).name());
|
||||
CCLOG("jsb_ref_finalize #2: JSObject address = %p (%s)", obj, typeid(*ref).name());
|
||||
|
||||
jsb_remove_proxy(nproxy, jsproxy);
|
||||
ref->release();
|
||||
|
|
|
@ -517,7 +517,7 @@ public:
|
|||
void restartVM();
|
||||
};
|
||||
|
||||
JS::HandleObject NewGlobalObject(JSContext* cx, bool debug = false);
|
||||
JSObject* NewGlobalObject(JSContext* cx, bool debug = false);
|
||||
|
||||
bool jsb_set_reserved_slot(JSObject *obj, uint32_t idx, jsval value);
|
||||
bool jsb_get_reserved_slot(JSObject *obj, uint32_t idx, jsval& ret);
|
||||
|
@ -565,12 +565,6 @@ void jsb_ref_init(JSContext* cx, JS::Heap<JSObject*> *obj, cocos2d::Ref* ref, co
|
|||
*/
|
||||
void jsb_ref_autoreleased_init(JSContext* cx, JS::Heap<JSObject*> *obj, cocos2d::Ref* ref, const char* debug);
|
||||
|
||||
/**
|
||||
* Generic initialization function for Singletons
|
||||
* Similar to jsb_ref_init(), but call it to initialize singletons
|
||||
*/
|
||||
void jsb_ref_singleton_init(JSContext* cx, JS::Heap<JSObject*> *obj, cocos2d::Ref* ref, const char* debug);
|
||||
|
||||
/**
|
||||
* Generic finalize used by objects that are subclass of Ref
|
||||
*/
|
||||
|
@ -595,23 +589,20 @@ JSObject* jsb_ref_create_jsobject(JSContext *cx, cocos2d::Ref *ref, js_type_clas
|
|||
*/
|
||||
JSObject* jsb_ref_autoreleased_create_jsobject(JSContext *cx, cocos2d::Ref *ref, js_type_class_t *typeClass, const char* debug);
|
||||
|
||||
/**
|
||||
* Creates a new JSObject of a certain type (typeClass) and creates a proxy associated with and the Singleton (ref)
|
||||
* Similar to jsb_ref_create_jsobject(), but call it if you know that Ref is a Singleton
|
||||
*/
|
||||
JSObject* jsb_ref_singleton_create_jsobject(JSContext *cx, cocos2d::Ref *ref, js_type_class_t *typeClass, const char* debug);
|
||||
|
||||
/**
|
||||
It will try to get the associated JSObjct for ref.
|
||||
If it can't find it, it will create a new one associating it to Ref
|
||||
If it can't find it, it will create a new one associating it to Ref.
|
||||
Call this function for objects that were already created and initialized, when returning `getChild()`
|
||||
*/
|
||||
JSObject* jsb_ref_get_or_create_jsobject(JSContext *cx, cocos2d::Ref *ref, js_type_class_t *typeClass, const char* debug);
|
||||
|
||||
/**
|
||||
It will try to get the associated JSObjct for ref.
|
||||
If it can't find it, it will create a new one associating it to Ref
|
||||
Call this function for objects that might return an already existing copy when you create them. For example, `Animation3D::create()`;
|
||||
*/
|
||||
JSObject* jsb_ref_singleton_get_or_create_jsobject(JSContext *cx, cocos2d::Ref *ref, js_type_class_t *typeClass, const char* debug);
|
||||
JSObject* jsb_ref_autoreleased_get_or_create_jsobject(JSContext *cx, cocos2d::Ref *ref, js_type_class_t *typeClass, const char* debug);
|
||||
|
||||
|
||||
void removeJSObject(JSContext* cx, void* nativeObj);
|
||||
|
||||
|
|
|
@ -203,10 +203,9 @@ bool js_cocos2dx_EventTouch_getTouches(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
JS::RootedValue arrElement(cx);
|
||||
|
||||
//First, check whether object is associated with js object.
|
||||
js_proxy_t* jsproxy = js_get_or_create_proxy<cocos2d::Touch>(cx, touchObj);
|
||||
if (jsproxy) {
|
||||
arrElement = OBJECT_TO_JSVAL(jsproxy->obj);
|
||||
}
|
||||
auto jsobj = js_get_or_create_jsobject<cocos2d::Touch>(cx, touchObj);
|
||||
if (jsobj)
|
||||
arrElement = OBJECT_TO_JSVAL(jsobj);
|
||||
if (!JS_SetElement(cx, jsretArr, i, arrElement)) {
|
||||
break;
|
||||
}
|
||||
|
@ -4558,8 +4557,7 @@ bool js_PlistParser_getInstance(JSContext *cx, unsigned argc, JS::Value *vp)
|
|||
jsret = OBJECT_TO_JSVAL(p->obj);
|
||||
} else {
|
||||
// create a new js obj of that class
|
||||
js_proxy_t *proxy = js_get_or_create_proxy<SAXParser>(cx, parser);
|
||||
jsret = OBJECT_TO_JSVAL(proxy->obj);
|
||||
jsret = OBJECT_TO_JSVAL(js_get_or_create_jsobject<SAXParser>(cx, parser));
|
||||
}
|
||||
} else {
|
||||
jsret = JSVAL_NULL;
|
||||
|
@ -4878,8 +4876,8 @@ bool js_cocos2dx_RenderTexture_saveToFile(JSContext *cx, uint32_t argc, jsval *v
|
|||
jsval largv[2];
|
||||
do {
|
||||
if (larg0) {
|
||||
js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::RenderTexture>(cx, (cocos2d::RenderTexture*)larg0);
|
||||
largv[0] = OBJECT_TO_JSVAL(jsProxy->obj);
|
||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||
largv[0] = OBJECT_TO_JSVAL(js_get_or_create_jsobject<cocos2d::RenderTexture>(cx, (cocos2d::RenderTexture*)larg0));
|
||||
} else {
|
||||
largv[0] = JSVAL_NULL;
|
||||
}
|
||||
|
@ -4949,8 +4947,8 @@ bool js_cocos2dx_RenderTexture_saveToFile(JSContext *cx, uint32_t argc, jsval *v
|
|||
jsval largv[2];
|
||||
do {
|
||||
if (larg0) {
|
||||
js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::RenderTexture>(cx, (cocos2d::RenderTexture*)larg0);
|
||||
largv[0] = OBJECT_TO_JSVAL(jsProxy->obj);
|
||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||
largv[0] = OBJECT_TO_JSVAL(js_get_or_create_jsobject<cocos2d::RenderTexture>(cx, (cocos2d::RenderTexture*)larg0));
|
||||
} else {
|
||||
largv[0] = JSVAL_NULL;
|
||||
}
|
||||
|
@ -5314,17 +5312,11 @@ bool js_cocos2dx_Scene_getPhysics3DWorld(JSContext *cx, uint32_t argc, jsval *vp
|
|||
{
|
||||
cocos2d::Physics3DWorld* ret = cobj->getPhysics3DWorld();
|
||||
jsval jsret = JSVAL_NULL;
|
||||
do
|
||||
if (ret)
|
||||
{
|
||||
if (ret)
|
||||
{
|
||||
js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::Physics3DWorld>(cx, (cocos2d::Physics3DWorld*)ret);
|
||||
jsret = OBJECT_TO_JSVAL(jsProxy->obj);
|
||||
} else
|
||||
{
|
||||
jsret = JSVAL_NULL;
|
||||
}
|
||||
} while (0);
|
||||
js_type_class_t *typeClass = js_get_type_from_native<cocos2d::Physics3DWorld>(ret);
|
||||
jsret = OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(cx, ret, typeClass, "cocos2d::Physics3DWorld"));
|
||||
}
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
|
@ -5400,15 +5392,11 @@ bool js_cocos2dx_Scene_getNavMesh(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
if (argc == 0) {
|
||||
cocos2d::NavMesh* ret = cobj->getNavMesh();
|
||||
jsval jsret = JSVAL_NULL;
|
||||
do {
|
||||
if (ret) {
|
||||
js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::NavMesh>(cx, (cocos2d::NavMesh*)ret);
|
||||
jsret = OBJECT_TO_JSVAL(jsProxy->obj);
|
||||
}
|
||||
else {
|
||||
jsret = JSVAL_NULL;
|
||||
}
|
||||
} while (0);
|
||||
if (ret)
|
||||
{
|
||||
js_type_class_t *typeClass = js_get_type_from_native<cocos2d::NavMesh>(ret);
|
||||
jsret = OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(cx, ret, typeClass, "cocos2d::NavMesh"));
|
||||
}
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
|
@ -5657,14 +5645,9 @@ bool js_cocos2dx_AutoPolygon_generatePolygon(JSContext *cx, uint32_t argc, jsval
|
|||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AutoPolygon_generatePolygon : Error processing arguments");
|
||||
cocos2d::PolygonInfo* ret = new cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0));
|
||||
jsval jsret = JSVAL_NULL;
|
||||
do {
|
||||
if (ret) {
|
||||
js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::PolygonInfo>(cx, ret);
|
||||
jsret = OBJECT_TO_JSVAL(jsProxy->obj);
|
||||
} else {
|
||||
jsret = JSVAL_NULL;
|
||||
}
|
||||
} while (0);
|
||||
if (ret) {
|
||||
jsret = OBJECT_TO_JSVAL(js_get_or_create_jsobject<cocos2d::PolygonInfo>(cx, ret));
|
||||
}
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
|
@ -5676,14 +5659,9 @@ bool js_cocos2dx_AutoPolygon_generatePolygon(JSContext *cx, uint32_t argc, jsval
|
|||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AutoPolygon_generatePolygon : Error processing arguments");
|
||||
cocos2d::PolygonInfo* ret = new cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0, arg1));
|
||||
jsval jsret = JSVAL_NULL;
|
||||
do {
|
||||
if (ret) {
|
||||
js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::PolygonInfo>(cx, ret);
|
||||
jsret = OBJECT_TO_JSVAL(jsProxy->obj);
|
||||
} else {
|
||||
jsret = JSVAL_NULL;
|
||||
}
|
||||
} while (0);
|
||||
if (ret) {
|
||||
jsret = OBJECT_TO_JSVAL(js_get_or_create_jsobject<cocos2d::PolygonInfo>(cx, ret));
|
||||
}
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
|
@ -5697,14 +5675,9 @@ bool js_cocos2dx_AutoPolygon_generatePolygon(JSContext *cx, uint32_t argc, jsval
|
|||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AutoPolygon_generatePolygon : Error processing arguments");
|
||||
cocos2d::PolygonInfo* ret = new cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0, arg1, arg2));
|
||||
jsval jsret = JSVAL_NULL;
|
||||
do {
|
||||
if (ret) {
|
||||
js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::PolygonInfo>(cx, ret);
|
||||
jsret = OBJECT_TO_JSVAL(jsProxy->obj);
|
||||
} else {
|
||||
jsret = JSVAL_NULL;
|
||||
}
|
||||
} while (0);
|
||||
if (ret) {
|
||||
jsret = OBJECT_TO_JSVAL(js_get_or_create_jsobject<cocos2d::PolygonInfo>(cx, ret));
|
||||
}
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
|
@ -5720,14 +5693,9 @@ bool js_cocos2dx_AutoPolygon_generatePolygon(JSContext *cx, uint32_t argc, jsval
|
|||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AutoPolygon_generatePolygon : Error processing arguments");
|
||||
cocos2d::PolygonInfo* ret = new cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0, arg1, arg2, arg3));
|
||||
jsval jsret = JSVAL_NULL;
|
||||
do {
|
||||
if (ret) {
|
||||
js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::PolygonInfo>(cx, ret);
|
||||
jsret = OBJECT_TO_JSVAL(jsProxy->obj);
|
||||
} else {
|
||||
jsret = JSVAL_NULL;
|
||||
}
|
||||
} while (0);
|
||||
if (ret) {
|
||||
jsret = OBJECT_TO_JSVAL(js_get_or_create_jsobject<cocos2d::PolygonInfo>(cx, ret));
|
||||
}
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -150,13 +150,8 @@ JSObject* js_get_or_create_jsobject(JSContext *cx, typename std::enable_if<!std:
|
|||
template<class T>
|
||||
JSObject* js_get_or_create_jsobject(JSContext *cx, typename std::enable_if<std::is_base_of<cocos2d::Ref,T>::value,T>::type *native_obj)
|
||||
{
|
||||
js_proxy_t *proxy = jsb_get_native_proxy(native_obj);
|
||||
if (proxy)
|
||||
return proxy->obj;
|
||||
|
||||
// else
|
||||
js_type_class_t* typeClass = js_get_type_from_native<T>(native_obj);
|
||||
return jsb_ref_autoreleased_create_jsobject(cx, native_obj, typeClass, typeid(*native_obj).name());
|
||||
return jsb_ref_get_or_create_jsobject(cx, native_obj, typeClass, typeid(*native_obj).name());
|
||||
}
|
||||
|
||||
JS::Value anonEvaluate(JSContext *cx, JS::HandleObject thisObj, const char* string);
|
||||
|
|
|
@ -1761,9 +1761,10 @@ jsval ccarray_to_jsval(JSContext* cx, __Array *arr)
|
|||
JS::RootedValue arrElement(cx);
|
||||
|
||||
//First, check whether object is associated with js object.
|
||||
js_proxy_t* jsproxy = js_get_or_create_proxy<cocos2d::Ref>(cx, obj);
|
||||
if (jsproxy) {
|
||||
arrElement = OBJECT_TO_JSVAL(jsproxy->obj);
|
||||
js_type_class_t *typeClass = js_get_type_from_native<cocos2d::Ref>(obj);
|
||||
auto jsobj = jsb_ref_get_or_create_jsobject(cx, obj, typeClass, "cocos2d::Ref");
|
||||
if (jsobj) {
|
||||
arrElement = OBJECT_TO_JSVAL(jsobj);
|
||||
}
|
||||
else {
|
||||
__String* strVal = NULL;
|
||||
|
@ -1812,9 +1813,10 @@ jsval ccdictionary_to_jsval(JSContext* cx, __Dictionary* dict)
|
|||
JS::RootedValue dictElement(cx);
|
||||
Ref* obj = pElement->getObject();
|
||||
//First, check whether object is associated with js object.
|
||||
js_proxy_t* jsproxy = js_get_or_create_proxy<cocos2d::Ref>(cx, obj);
|
||||
if (jsproxy) {
|
||||
dictElement = OBJECT_TO_JSVAL(jsproxy->obj);
|
||||
js_type_class_t *typeClass = js_get_type_from_native<cocos2d::Ref>(obj);
|
||||
auto jsobj = jsb_ref_get_or_create_jsobject(cx, obj, typeClass, "cocos2d::Ref");
|
||||
if (jsobj) {
|
||||
dictElement = OBJECT_TO_JSVAL(jsobj);
|
||||
}
|
||||
else {
|
||||
__String* strVal = NULL;
|
||||
|
|
|
@ -563,19 +563,13 @@ cc.ActionInterval.prototype._ctor = function(d) {
|
|||
};
|
||||
|
||||
cc.Sequence.prototype._ctor = function(tempArray) {
|
||||
var paramArray = (tempArray instanceof Array) ? tempArray : arguments;
|
||||
var paramArray = (tempArray instanceof Array) ? tempArray : Array.prototype.slice.call(arguments);
|
||||
var last = paramArray.length - 1;
|
||||
if ((last >= 0) && (paramArray[last] == null))
|
||||
cc.log("parameters should not be ending with null in Javascript");
|
||||
|
||||
if (last >= 0) {
|
||||
var prev = paramArray[0];
|
||||
for (var i = 1; i < last; i++) {
|
||||
if (paramArray[i]) {
|
||||
prev = cc.Sequence.create(prev, paramArray[i]);
|
||||
}
|
||||
}
|
||||
this.initWithTwoActions(prev, paramArray[last]);
|
||||
this.init(paramArray);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -588,19 +582,13 @@ cc.RepeatForever.prototype._ctor = function(action) {
|
|||
};
|
||||
|
||||
cc.Spawn.prototype._ctor = function(tempArray) {
|
||||
var paramArray = (tempArray instanceof Array) ? tempArray : arguments;
|
||||
var paramArray = (tempArray instanceof Array) ? tempArray : Array.prototype.slice.call(arguments);
|
||||
var last = paramArray.length - 1;
|
||||
if ((last >= 0) && (paramArray[last] == null))
|
||||
cc.log("parameters should not be ending with null in Javascript");
|
||||
|
||||
if (last >= 0) {
|
||||
var prev = paramArray[0];
|
||||
for (var i = 1; i < last; i++) {
|
||||
if (paramArray[i]) {
|
||||
prev = cc.Spawn.create(prev, paramArray[i]);
|
||||
}
|
||||
}
|
||||
this.initWithTwoActions(prev, paramArray[last]);
|
||||
this.init(paramArray);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1208,4 +1196,4 @@ cc.Menu.create = function(menuItems) {
|
|||
return cc.Menu._create.apply(null, items);
|
||||
};
|
||||
|
||||
cc.TMXLayer.prototype.tileFlagsAt = cc.TMXLayer.prototype.getTileFlagsAt;
|
||||
cc.TMXLayer.prototype.tileFlagsAt = cc.TMXLayer.prototype.getTileFlagsAt;
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
-- @return Control#Control self (return value: cc.Control)
|
||||
|
||||
--------------------------------
|
||||
-- Returns a point corresponding to the touh location converted into the<br>
|
||||
-- Returns a point corresponding to the touch location converted into the<br>
|
||||
-- control space coordinates.<br>
|
||||
-- param touch A Touch object that represents a touch.
|
||||
-- @function [parent=#Control] getTouchLocation
|
||||
|
|
|
@ -145,7 +145,7 @@
|
|||
-- @return bool#bool ret (return value: bool)
|
||||
|
||||
--------------------------------
|
||||
-- Sets the font of the label, changes the label to a BMFont if neccessary.<br>
|
||||
-- Sets the font of the label, changes the label to a BMFont if necessary.<br>
|
||||
-- param fntFile The name of the font to change to<br>
|
||||
-- param state The state that uses the specified fntFile. The values are described<br>
|
||||
-- in "CCControlState".
|
||||
|
|
|
@ -107,7 +107,7 @@ void Control::sendActionsForControlEvents(EventType controlEvents)
|
|||
// For each control events
|
||||
for (int i = 0; i < kControlEventTotalNumber; i++)
|
||||
{
|
||||
// If the given controlEvents bitmask contains the curent event
|
||||
// If the given controlEvents bitmask contains the current event
|
||||
if (((int)controlEvents & (1 << i)))
|
||||
{
|
||||
// Call invocations
|
||||
|
@ -135,7 +135,7 @@ void Control::addTargetWithActionForControlEvents(Ref* target, Handler action, E
|
|||
// For each control events
|
||||
for (int i = 0; i < kControlEventTotalNumber; i++)
|
||||
{
|
||||
// If the given controlEvents bitmask contains the curent event
|
||||
// If the given controlEvents bitmask contains the current event
|
||||
if (((int)controlEvents & (1 << i)))
|
||||
{
|
||||
this->addTargetWithActionForControlEvent(target, action, (EventType)(1<<i));
|
||||
|
@ -148,7 +148,7 @@ void Control::addTargetWithActionForControlEvents(Ref* target, Handler action, E
|
|||
/**
|
||||
* Adds a target and action for a particular event to an internal dispatch
|
||||
* table.
|
||||
* The action message may optionnaly include the sender and the event as
|
||||
* The action message may optionally include the sender and the event as
|
||||
* parameters, in that order.
|
||||
* When you call this method, target is not retained.
|
||||
*
|
||||
|
@ -173,7 +173,7 @@ void Control::removeTargetWithActionForControlEvents(Ref* target, Handler action
|
|||
// For each control events
|
||||
for (int i = 0; i < kControlEventTotalNumber; i++)
|
||||
{
|
||||
// If the given controlEvents bitmask contains the curent event
|
||||
// If the given controlEvents bitmask contains the current event
|
||||
if (((int)controlEvents & (1 << i)))
|
||||
{
|
||||
this->removeTargetWithActionForControlEvent(target, action, (EventType)(1 << i));
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
/** The possible state for a control. */
|
||||
enum class State
|
||||
{
|
||||
NORMAL = 1 << 0, // The normal, or default state of a control¡ªthat is, enabled but neither selected nor highlighted.
|
||||
NORMAL = 1 << 0, // The normal, or default state of a control that is, enabled but neither selected nor highlighted.
|
||||
HIGH_LIGHTED = 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.
|
||||
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.
|
||||
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.
|
||||
|
@ -122,7 +122,7 @@ public:
|
|||
/**
|
||||
* Adds a target and action for a particular event (or events) to an internal
|
||||
* dispatch table.
|
||||
* The action message may optionnaly include the sender and the event as
|
||||
* The action message may optionally include the sender and the event as
|
||||
* parameters, in that order.
|
||||
* When you call this method, target is not retained.
|
||||
*
|
||||
|
@ -138,7 +138,7 @@ public:
|
|||
* Removes a target and action for a particular event (or events) from an
|
||||
* internal dispatch table.
|
||||
*
|
||||
* @param target The target object—that is, the object to which the action
|
||||
* @param target The target object that is, the object to which the action
|
||||
* message is sent. Pass nil to remove all targets paired with action and the
|
||||
* specified control events.
|
||||
* @param action A selector identifying an action message. Pass NULL to remove
|
||||
|
@ -149,7 +149,7 @@ public:
|
|||
virtual void removeTargetWithActionForControlEvents(Ref* target, Handler action, EventType controlEvents);
|
||||
|
||||
/**
|
||||
* Returns a point corresponding to the touh location converted into the
|
||||
* Returns a point corresponding to the touch location converted into the
|
||||
* control space coordinates.
|
||||
* @param touch A Touch object that represents a touch.
|
||||
*/
|
||||
|
@ -190,7 +190,7 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
protected:
|
||||
/**
|
||||
* Returns an Invocation object able to construct messages using a given
|
||||
* target-action pair. (The invocation may optionnaly include the sender and
|
||||
* target-action pair. (The invocation may optionally include the sender and
|
||||
* the event as parameters, in that order)
|
||||
*
|
||||
* @param target The target object.
|
||||
|
@ -217,11 +217,11 @@ protected:
|
|||
/**
|
||||
* Adds a target and action for a particular event to an internal dispatch
|
||||
* table.
|
||||
* The action message may optionnaly include the sender and the event as
|
||||
* The action message may optionally include the sender and the event as
|
||||
* parameters, in that order.
|
||||
* When you call this method, target is not retained.
|
||||
*
|
||||
* @param target The target object¡ªthat is, the object to which the action
|
||||
* @param target The target object that is, the object to which the action
|
||||
* message is sent. It cannot be nil. The target is not retained.
|
||||
* @param action A selector identifying an action message. It cannot be NULL.
|
||||
* @param controlEvent A control event for which the action message is sent.
|
||||
|
@ -233,7 +233,7 @@ protected:
|
|||
* Removes a target and action for a particular event from an internal dispatch
|
||||
* table.
|
||||
*
|
||||
* @param target The target object¡ªthat is, the object to which the action
|
||||
* @param target The target object that is, the object to which the action
|
||||
* message is sent. Pass nil to remove all targets paired with action and the
|
||||
* specified control events.
|
||||
* @param action A selector identifying an action message. Pass NULL to remove
|
||||
|
|
|
@ -134,7 +134,7 @@ public:
|
|||
virtual float getTitleTTFSizeForState(State state);
|
||||
|
||||
/**
|
||||
* Sets the font of the label, changes the label to a BMFont if neccessary.
|
||||
* Sets the font of the label, changes the label to a BMFont if necessary.
|
||||
* @param fntFile The name of the font to change to
|
||||
* @param state The state that uses the specified fntFile. The values are described
|
||||
* in "CCControlState".
|
||||
|
|
|
@ -71,7 +71,7 @@ protected:
|
|||
void updateSliderPosition(Vec2 location);
|
||||
bool checkSliderPosition(Vec2 location);
|
||||
|
||||
//maunally put in the setters
|
||||
//manually put in the setters
|
||||
CC_SYNTHESIZE_READONLY(float, _hue, Hue);
|
||||
virtual void setHue(float val);
|
||||
CC_SYNTHESIZE_READONLY(float, _huePercentage, HuePercentage);
|
||||
|
|
|
@ -129,7 +129,7 @@ protected:
|
|||
/** Returns the value for the given location. */
|
||||
float valueForLocation(Vec2 location);
|
||||
|
||||
//maunally put in the setters
|
||||
//manually put in the setters
|
||||
/** Contains the receiver's current value. */
|
||||
CC_SYNTHESIZE_READONLY(float, _value, Value);
|
||||
|
||||
|
|
|
@ -323,7 +323,7 @@ protected:
|
|||
*/
|
||||
Node* _container;
|
||||
/**
|
||||
* Determiens whether user touch is moved after begin phase.
|
||||
* Determines whether user touch is moved after begin phase.
|
||||
*/
|
||||
bool _touchMoved;
|
||||
/**
|
||||
|
|
|
@ -119,7 +119,7 @@ protected:
|
|||
/** Although the scale is on a Particle System level, the affector can also be scaled.
|
||||
*/
|
||||
Vec3 _affectorScale;
|
||||
/** Because the public attribute ´position?is sometimes used for both localspace and worldspace
|
||||
/** Because the public attribute position is sometimes used for both localspace and worldspace
|
||||
position, the mDerivedPosition attribute is introduced.
|
||||
*/
|
||||
Vec3 _derivedPosition;
|
||||
|
|
|
@ -104,7 +104,7 @@ void PUAffectorTranslator::translate(PUScriptCompiler* compiler, PUAbstractNode
|
|||
}
|
||||
else if (prop->name == token[TOKEN_POSITION])
|
||||
{
|
||||
// Property: positon
|
||||
// Property: position
|
||||
if (passValidateProperty(compiler, prop, token[TOKEN_POSITION], VAL_VECTOR3))
|
||||
{
|
||||
Vec3 val;
|
||||
|
|
|
@ -734,9 +734,9 @@ void PUBillboardChain::setBlendFunc(const BlendFunc& blendFunc)
|
|||
|
||||
GLuint PUBillboardChain::getTextureName()
|
||||
{
|
||||
if (TextureCache::getInstance()->isDirty())
|
||||
if (Director::getInstance()->getTextureCache()->isDirty())
|
||||
{
|
||||
if (TextureCache::getInstance()->getTextureForKey(_texFile) == nullptr)
|
||||
if (Director::getInstance()->getTextureCache()->getTextureForKey(_texFile) == nullptr)
|
||||
{
|
||||
_texture = nullptr;
|
||||
this->init("");
|
||||
|
|
|
@ -107,7 +107,7 @@ public:
|
|||
bool alwaysUsePosition(void) const {return _alwaysUsePosition;};
|
||||
|
||||
/** Set the boolean to indicate whether the position of the particle that is handled must be used for emission of
|
||||
the new particle or whether the contact point of the physics actor must be used. This only applies if a physics angine
|
||||
the new particle or whether the contact point of the physics actor must be used. This only applies if a physics engine
|
||||
is used, otherwise the default is used.
|
||||
*/
|
||||
void setAlwaysUsePosition(bool alwaysUsePosition) {_alwaysUsePosition = alwaysUsePosition;};
|
||||
|
@ -143,14 +143,14 @@ protected:
|
|||
|
||||
/** Store the technique value to keep up to speed.
|
||||
@remarks
|
||||
If the ParticleTechnique has been destroyed, the DoPlacementParticleEventHandler isn´t automatically
|
||||
If the ParticleTechnique has been destroyed, the DoPlacementParticleEventHandler isn't automatically
|
||||
notified. Using the pointer causes an exception.
|
||||
*/
|
||||
PUParticleSystem3D* _system;
|
||||
|
||||
/** Store the emitter value to keep up to speed.
|
||||
@remarks
|
||||
If the ParticleEmitter has been destroyed, the DoPlacementParticleEventHandler isn´t automatically
|
||||
If the ParticleEmitter has been destroyed, the DoPlacementParticleEventHandler isn't automatically
|
||||
notified. Using the pointer causes an exception.
|
||||
*/
|
||||
PUEmitter* _emitter;
|
||||
|
|
|
@ -258,7 +258,7 @@ class CC_DLL PUDynamicAttributeCurved : public PUDynamicAttribute
|
|||
inline ControlPointList::iterator getLastValidIterator(void);
|
||||
};
|
||||
|
||||
/* This class generates values based on an oscillating functione (i.e. Sine).
|
||||
/* This class generates values based on an oscillating function (i.e. Sine).
|
||||
*/
|
||||
class CC_DLL PUDynamicAttributeOscillate : public PUDynamicAttribute
|
||||
{
|
||||
|
|
|
@ -108,7 +108,7 @@ void PUEmitterTranslator::translate(PUScriptCompiler* compiler, PUAbstractNode *
|
|||
}
|
||||
else if (prop->name == token[TOKEN_POSITION])
|
||||
{
|
||||
// Property: positon
|
||||
// Property: position
|
||||
if (passValidateProperty(compiler, prop, token[TOKEN_POSITION], VAL_VECTOR3))
|
||||
{
|
||||
Vec3 val;
|
||||
|
|
|
@ -133,7 +133,7 @@ public:
|
|||
/** Destructor **/
|
||||
~MeshInfo (void);
|
||||
|
||||
/** Generate a random number. The ´high?argument determines that numbers are
|
||||
/** Generate a random number. The high argument determines that numbers are
|
||||
returned between [0..high] **/
|
||||
float getGaussianRandom (float high, float cutoff = 4);
|
||||
|
||||
|
@ -196,7 +196,7 @@ public:
|
|||
/** Returns the type op distribution.
|
||||
@remarks
|
||||
There are several ways to emit particles on the surface of a mesh. This attribute indicates
|
||||
the type of distrubution on the surface.
|
||||
the type of distribution on the surface.
|
||||
*/
|
||||
const MeshInfo::MeshSurfaceDistribution getDistribution (void) const;
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ void PUObserver::destroyEventHandler(PUEventHandler* eventHandler)
|
|||
{
|
||||
if (*it == eventHandler)
|
||||
{
|
||||
// Detroy it
|
||||
// Destroy it
|
||||
//ParticleSystemManager::getSingletonPtr()->destroyEventHandler(*it);
|
||||
(*it)->release();
|
||||
_eventHandlers.erase(it);
|
||||
|
|
|
@ -159,7 +159,7 @@ public:
|
|||
bool getObserveUntilEvent(void) const;
|
||||
|
||||
/** Sets the value of mObserveUntilEvent. This value determines whether observation must be continued
|
||||
after an event ocurred and the event handlers are called.
|
||||
after an event occurred and the event handlers are called.
|
||||
*/
|
||||
void setObserveUntilEvent(bool observeUntilEvent);
|
||||
|
||||
|
@ -213,8 +213,8 @@ protected:
|
|||
// Particle type to be observed. Default is that all particles are observed.
|
||||
PUParticle3D::ParticleType _particleTypeToObserve;
|
||||
|
||||
/** Determines whether mParticleTypeToObserve is set. If ´true? only that particles of the specified type
|
||||
are observed. If ´false?(= default), all particles are observed.
|
||||
/** Determines whether mParticleTypeToObserve is set. If true only that particles of the specified type
|
||||
are observed. If false (= default), all particles are observed.
|
||||
*/
|
||||
bool _particleTypeToObserveSet;
|
||||
|
||||
|
|
|
@ -50,13 +50,13 @@ public:
|
|||
*/
|
||||
virtual bool observe (PUParticle3D* particle, float timeElapsed) override;
|
||||
|
||||
/** The _processParticle() function is overridden, because we don´t observe an individual particle.
|
||||
even if there isn´t a particle left anymore (and that is the situation we want to validate).
|
||||
/** The _processParticle() function is overridden, because we don't observe an individual particle.
|
||||
even if there isn't a particle left anymore (and that is the situation we want to validate).
|
||||
*/
|
||||
virtual void updateObserver(PUParticle3D* particle, float timeElapsed, bool firstParticle) override;
|
||||
|
||||
/** Instead of the _processParticle(), the _postProcessParticles() is used because it is called
|
||||
even if there isn´t a particle left anymore (and that is the situation we want to validate).
|
||||
even if there isn't a particle left anymore (and that is the situation we want to validate).
|
||||
*/
|
||||
virtual void postUpdateObserver(float timeElapsed) override;
|
||||
|
||||
|
|
|
@ -1011,7 +1011,7 @@ void PUParticleSystem3D::initParticleForExpiration( PUParticle3D* particle, floa
|
|||
it->particleExpired(this, particle);
|
||||
}
|
||||
///** Externs are also called to perform expiration activities. If needed, affectors and emitters may be added, but at the moment
|
||||
// there is no reason for (and we don´t want to waste cpu resources).
|
||||
// there is no reason for (and we don't want to waste cpu resources).
|
||||
//*/
|
||||
//if (!mExterns.empty())
|
||||
//{
|
||||
|
|
|
@ -55,7 +55,7 @@ bool PURandomiserTranslator::translateChildProperty( PUScriptCompiler* compiler,
|
|||
}
|
||||
else if (prop->name == token[TOKEN_RND_MAX_DEVIATION_X])
|
||||
{
|
||||
// Property: rand_aff_max_deviation_x (depreacted and replaced by 'max_deviation_x')
|
||||
// Property: rand_aff_max_deviation_x (deprecated and replaced by 'max_deviation_x')
|
||||
if (passValidateProperty(compiler, prop, token[TOKEN_RND_MAX_DEVIATION_X], VAL_REAL))
|
||||
{
|
||||
float val = 0.0f;
|
||||
|
|
|
@ -589,9 +589,9 @@ bool PUParticle3DEntityRender::initRender( const std::string &texFile )
|
|||
|
||||
GLuint PUParticle3DEntityRender::getTextureName()
|
||||
{
|
||||
if (TextureCache::getInstance()->isDirty())
|
||||
if (Director::getInstance()->getTextureCache()->isDirty())
|
||||
{
|
||||
if (TextureCache::getInstance()->getTextureForKey(_texFile) == nullptr)
|
||||
if (Director::getInstance()->getTextureCache()->getTextureForKey(_texFile) == nullptr)
|
||||
{
|
||||
_texture = nullptr;
|
||||
this->initRender("");
|
||||
|
|
|
@ -89,7 +89,7 @@ void PUTechniqueTranslator::translate(PUScriptCompiler* compiler, PUAbstractNode
|
|||
}
|
||||
else if (prop->name == token[TOKEN_POSITION])
|
||||
{
|
||||
// Property: positon
|
||||
// Property: position
|
||||
if (passValidateProperty(compiler, prop, token[TOKEN_POSITION], VAL_VECTOR3))
|
||||
{
|
||||
Vec3 val;
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
*/
|
||||
void setRotationSpeed(PUDynamicAttribute* dynRotationSpeed);
|
||||
|
||||
/** Returns the rotation defined in the the affector.
|
||||
/** Returns the rotation defined in the affector.
|
||||
*/
|
||||
PUDynamicAttribute* getRotation(void) const;
|
||||
|
||||
|
|
|
@ -62,9 +62,9 @@ NS_CC_BEGIN
|
|||
// /** Defines the speed of generating spawnpoints. In each Particle Technique update
|
||||
// 'mIterations' vertices are traversed.
|
||||
// @remarks
|
||||
// Setting this attribute to a higher value is needed if the emssion rate of the emitter
|
||||
// Setting this attribute to a higher value is needed if the emission rate of the emitter
|
||||
// is high. On slower computers, emitting the particles may exceed generating the
|
||||
// spawnpoints (because this is not done at once, but per Particle Tehcnique update).
|
||||
// spawnpoints (because this is not done at once, but per Particle Technique update).
|
||||
// */
|
||||
// unsigned short mIterations;
|
||||
//
|
||||
|
|
|
@ -253,7 +253,7 @@ void AssetsManager::downloadAndUncompress()
|
|||
void AssetsManager::update()
|
||||
{
|
||||
// all operation in checkUpdate, nothing need to do
|
||||
// keep this function for compatiblity
|
||||
// keep this function for compatibility
|
||||
}
|
||||
|
||||
bool AssetsManager::uncompress()
|
||||
|
@ -308,8 +308,8 @@ bool AssetsManager::uncompress()
|
|||
const size_t filenameLength = strlen(fileName);
|
||||
if (fileName[filenameLength-1] == '/')
|
||||
{
|
||||
// Entry is a direcotry, so create it.
|
||||
// If the directory exists, it will failed scilently.
|
||||
// Entry is a directory, so create it.
|
||||
// If the directory exists, it will failed silently.
|
||||
if (!FileUtils::getInstance()->createDirectory(fullPath))
|
||||
{
|
||||
CCLOG("can not create directory %s", fullPath.c_str());
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
// Error caused by creating a file to store downloaded data
|
||||
CREATE_FILE,
|
||||
/** Error caused by network
|
||||
-- network unavaivable
|
||||
-- network unavailable
|
||||
-- timeout
|
||||
-- ...
|
||||
*/
|
||||
|
|
|
@ -833,7 +833,7 @@ void AssetsManagerEx::onError(const network::DownloadTask& task,
|
|||
int errorCodeInternal,
|
||||
const std::string& errorStr)
|
||||
{
|
||||
// Skip version error occured
|
||||
// Skip version error occurred
|
||||
if (task.identifier == VERSION_ID)
|
||||
{
|
||||
CCLOG("AssetsManagerEx : Fail to download version file, step skipped\n");
|
||||
|
|
|
@ -149,7 +149,7 @@ protected:
|
|||
*/
|
||||
const DownloadUnits& getFailedAssets() const;
|
||||
|
||||
/** @brief Function for destorying the downloaded version file and manifest file
|
||||
/** @brief Function for destroying the downloaded version file and manifest file
|
||||
*/
|
||||
void destroyDownloadedVersion();
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"version":"v3-deps-78",
|
||||
"zip_file_size":"119277304",
|
||||
"version":"v3-deps-79",
|
||||
"zip_file_size":"124402591",
|
||||
"repo_name":"cocos2d-x-3rd-party-libs-bin",
|
||||
"repo_parent":"https://github.com/cocos2d/",
|
||||
"move_dirs":{
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
"src/TouchesTest/TouchesTest.js",
|
||||
"src/SchedulerTest/SchedulerTest.js",
|
||||
"src/MenuTest/MenuTest.js",
|
||||
"src/MemoryModelTest/MemoryModelTest.js",
|
||||
"src/ActionsTest/ActionsTest.js",
|
||||
"src/TileMapTest/TileMapTest.js",
|
||||
"src/TransitionsTest/TransitionsTest.js",
|
||||
|
|
|
@ -0,0 +1,256 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2008-2010 Ricardo Quesada
|
||||
Copyright (c) 2011-2012 cocos2d-x.org
|
||||
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
var memoryModelTestSceneIdx = -1;
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// MemoryModelTestBase
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
var MemoryModelTestBase = BaseTestLayer.extend({
|
||||
_title:"",
|
||||
_subtitle:"",
|
||||
|
||||
onRestartCallback:function (sender) {
|
||||
var s = new MemoryModelTestScene();
|
||||
s.addChild(restartMemoryModelTest());
|
||||
director.runScene(s);
|
||||
},
|
||||
onNextCallback:function (sender) {
|
||||
var s = new MemoryModelTestScene();
|
||||
s.addChild(nextMemoryModelTest());
|
||||
director.runScene(s);
|
||||
},
|
||||
onBackCallback:function (sender) {
|
||||
var s = new MemoryModelTestScene();
|
||||
s.addChild(previousMemoryModelTest());
|
||||
director.runScene(s);
|
||||
},
|
||||
|
||||
// automation
|
||||
numberOfPendingTests:function() {
|
||||
return ( (arrayOfMemoryModelTest.length-1) - memoryModelTestSceneIdx );
|
||||
},
|
||||
|
||||
getTestNumber:function() {
|
||||
return memoryModelTestSceneIdx;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// Set property on sprite
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
var SetPropertyMemoryModelTest = MemoryModelTestBase.extend({
|
||||
_title:"Set Property Test",
|
||||
_subtitle:"See console for possible errors",
|
||||
|
||||
ctor:function () {
|
||||
this._super();
|
||||
var sprite = new cc.Sprite(s_grossini_dance_atlas, cc.rect(0, 0, 85, 121));
|
||||
var tag = 10;
|
||||
this.addChild(sprite, 0, tag);
|
||||
var x = winSize.width / 2;
|
||||
var y = winSize.height / 2;
|
||||
sprite.setPosition(x, y);
|
||||
|
||||
// add random property
|
||||
sprite.randomProperty = "hello world";
|
||||
|
||||
sprite = this.getChildByTag(tag);
|
||||
|
||||
// should print "hello world"
|
||||
this.log(sprite.randomProperty);
|
||||
},
|
||||
});
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// Using Ivar 1: from ctor to onEnter
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
var Ivar1MemoryModelTest = MemoryModelTestBase.extend({
|
||||
_title:"Using ivars to hold C++ objects",
|
||||
_subtitle:"From ctor to onEnter",
|
||||
|
||||
ctor:function () {
|
||||
this._super();
|
||||
this.sprite = new cc.Sprite(s_grossini_dance_atlas, cc.rect(0, 0, 85, 121));
|
||||
},
|
||||
onEnter:function() {
|
||||
this._super();
|
||||
this.addChild(this.sprite);
|
||||
var x = winSize.width / 2;
|
||||
var y = winSize.height / 2;
|
||||
this.sprite.setPosition(x, y);
|
||||
},
|
||||
});
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// Using Ivar 2: from ctor to update
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
var Ivar2MemoryModelTest = MemoryModelTestBase.extend({
|
||||
_title:"Using ivars to hold C++ objects",
|
||||
_subtitle:"From ctor to update",
|
||||
|
||||
ctor:function () {
|
||||
this._super();
|
||||
this.sprite = new cc.Sprite(s_grossini_dance_atlas, cc.rect(0, 0, 85, 121));
|
||||
this.scheduleOnce(this.showSprite, 0.5);
|
||||
},
|
||||
showSprite:function() {
|
||||
this.addChild(this.sprite);
|
||||
var x = winSize.width / 2;
|
||||
var y = winSize.height / 2;
|
||||
this.sprite.setPosition(x, y);
|
||||
},
|
||||
});
|
||||
|
||||
var MemoryModelTestScene = TestScene.extend({
|
||||
runThisTest:function (num) {
|
||||
memoryModelTestSceneIdx = (num || num == 0) ? (num - 1) : -1;
|
||||
var layer = nextMemoryModelTest();
|
||||
this.addChild(layer);
|
||||
|
||||
director.runScene(this);
|
||||
}
|
||||
});
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// Using Local vars
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
var LocalVarMemoryModelTest = MemoryModelTestBase.extend({
|
||||
_title:"Using local vars + GC",
|
||||
_subtitle:"native objects should get destroyed",
|
||||
|
||||
ctor:function () {
|
||||
this._super();
|
||||
var sprite1 = new cc.Sprite(s_grossini_dance_atlas, cc.rect(0, 0, 85, 121));
|
||||
var sprite2 = new cc.Sprite(s_grossini_dance_atlas, cc.rect(0, 0, 85, 121));
|
||||
var sprite3 = new cc.Sprite(s_grossini_dance_atlas, cc.rect(0, 0, 85, 121));
|
||||
var a = 10;
|
||||
//cc.sys.dumpRoot();
|
||||
cc.sys.garbageCollect();
|
||||
cc.log(sprite1);
|
||||
cc.log(sprite2);
|
||||
cc.log(sprite3);
|
||||
cc.log(a);
|
||||
},
|
||||
});
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// Using Local vars
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
var RetainRootsMemoryModelTest = MemoryModelTestBase.extend({
|
||||
_title:"retain must root",
|
||||
_subtitle:"native objects should not get destroyed",
|
||||
|
||||
ctor:function () {
|
||||
this._super();
|
||||
var sprite = new cc.Sprite(s_grossini_dance_atlas, cc.rect(0, 0, 85, 121));
|
||||
// addChild should root the sprite
|
||||
this.addChild(sprite);
|
||||
cc.sys.garbageCollect();
|
||||
|
||||
var x = winSize.width / 2;
|
||||
var y = winSize.height / 2;
|
||||
sprite.setPosition(x, y);
|
||||
},
|
||||
});
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// Testing Root/Unroot
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
var RootUnrootMemoryModelTest = MemoryModelTestBase.extend({
|
||||
_title:"root/unroot",
|
||||
_subtitle:"rooting/unrooting with GC memory model",
|
||||
|
||||
ctor:function () {
|
||||
this._super();
|
||||
var sprite = new cc.Sprite(s_grossini_dance_atlas, cc.rect(0, 0, 85, 121));
|
||||
// addChild should root the sprite
|
||||
this.addChild(sprite);
|
||||
|
||||
// should unroot the sprite
|
||||
this.removeChild(sprite)
|
||||
cc.sys.garbageCollect();
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
//
|
||||
// Entry point
|
||||
//
|
||||
var MemoryModelTestScene = TestScene.extend({
|
||||
runThisTest:function (num) {
|
||||
memoryModelTestSceneIdx = (num || num == 0) ? (num - 1) : -1;
|
||||
var layer = nextMemoryModelTest();
|
||||
this.addChild(layer);
|
||||
|
||||
director.runScene(this);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//
|
||||
// Flow control
|
||||
//
|
||||
|
||||
var arrayOfMemoryModelTest = [
|
||||
SetPropertyMemoryModelTest,
|
||||
Ivar1MemoryModelTest,
|
||||
Ivar2MemoryModelTest,
|
||||
LocalVarMemoryModelTest,
|
||||
RetainRootsMemoryModelTest,
|
||||
RootUnrootMemoryModelTest,
|
||||
];
|
||||
|
||||
var nextMemoryModelTest = function () {
|
||||
memoryModelTestSceneIdx++;
|
||||
memoryModelTestSceneIdx = memoryModelTestSceneIdx % arrayOfMemoryModelTest.length;
|
||||
|
||||
return new arrayOfMemoryModelTest[memoryModelTestSceneIdx]();
|
||||
};
|
||||
var previousMemoryModelTest = function () {
|
||||
memoryModelTestSceneIdx--;
|
||||
if (memoryModelTestSceneIdx < 0)
|
||||
memoryModelTestSceneIdx += arrayOfMemoryModelTest.length;
|
||||
|
||||
return new arrayOfMemoryModelTest[memoryModelTestSceneIdx]();
|
||||
};
|
||||
var restartMemoryModelTest = function () {
|
||||
return new arrayOfMemoryModelTest[memoryModelTestSceneIdx]();
|
||||
};
|
||||
|
|
@ -479,6 +479,15 @@ var testNames = [
|
|||
return new MaterialSystemTestScene();
|
||||
}
|
||||
},
|
||||
{
|
||||
title:"Memory Model Test",
|
||||
resource:g_menu,
|
||||
platforms: PLATFORM_JSB,
|
||||
linksrc:"src/MemoryModelTest/MemoryModelTest.js",
|
||||
testScene:function () {
|
||||
return new MemoryModelTestScene();
|
||||
}
|
||||
},
|
||||
{
|
||||
title:"Menu Test",
|
||||
resource:g_menu,
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit b940871c1dfff94c0220364539dd9d0583995719
|
||||
Subproject commit 26b56a42b7ea74ca7acb4003c7f98fe149741503
|
|
@ -87,8 +87,8 @@ skip = Node::[^setPosition$ setGLServerState description getUserObject .*UserDat
|
|||
Range::[*],
|
||||
NotificationObserver::[*],
|
||||
Image::[initWithString initWithImageData],
|
||||
Sequence::[create init],
|
||||
Spawn::[create init],
|
||||
Sequence::[create],
|
||||
Spawn::[create],
|
||||
RotateTo::[calculateAngles],
|
||||
GLProgram::[getProgram setUniformLocationWith(1|2|3|4)fv setUniformLocationWith(2|3|4)iv setUniformLocationWithMatrix(2|3|4)fv],
|
||||
GLProgramState::[setUniformVec4 setVertexAttribPointer],
|
||||
|
|
|
@ -43,7 +43,7 @@ skip = Skeleton3D::[create],
|
|||
Sprite3D::[getAABB getMeshArrayByName createAsync],
|
||||
Mesh::[create getMeshCommand getAABB getDefaultGLProgram getMeshVertexAttribute draw setTexture getTexture],
|
||||
Sprite3DCache::[addSprite3DData getSpriteData],
|
||||
Animation3D::[getBoneCurves],
|
||||
Animation3D::[create getBoneCurves],
|
||||
Animate3D::[getKeyFrameUserInfo],
|
||||
TextureCube::[setTexParameters],
|
||||
Terrain::[getAABB getQuadTree create getHeightData],
|
||||
|
|
Loading…
Reference in New Issue