Skip to content
2 changes: 2 additions & 0 deletions frameworks/js-bindings/bindings/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ LOCAL_MODULE := cocos_jsb_static

LOCAL_MODULE_FILENAME := libcocos2dxjsb

LOCAL_ARM_MODE := arm

LOCAL_SRC_FILES := auto/jsb_cocos2dx_auto.cpp \
auto/jsb_cocos2dx_builder_auto.cpp \
auto/jsb_cocos2dx_extension_auto.cpp \
Expand Down
2 changes: 1 addition & 1 deletion frameworks/js-bindings/bindings/manual/ScriptingCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <assert.h>
#include <memory>

#define ENGINE_VERSION "Cocos2d-JS v3.4 Beta0"
#define ENGINE_VERSION "Cocos2d-JS v3.4"

void js_log(const char *format, ...);

Expand Down
2 changes: 1 addition & 1 deletion frameworks/js-bindings/bindings/script/jsb_cocos2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

// CCConfig.js
//
cc.ENGINE_VERSION = "Cocos2d-JS v3.4 Beta0";
cc.ENGINE_VERSION = "Cocos2d-JS v3.4";

cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0;
cc.DIRECTOR_STATS_POSITION = {x: 0, y: 0};
Expand Down
2 changes: 1 addition & 1 deletion frameworks/js-bindings/cocos2d-x
Submodule cocos2d-x updated 1 files
+2 −0 cocos/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ THE SOFTWARE.
#include "ConsoleCommand.h"

#include "cocos2d_specifics.hpp"
#include "jsb_cocos2dx_auto.hpp"
#include "cocos2d.h"
#include "ConfigParser.h"

Expand Down Expand Up @@ -95,22 +96,22 @@ bool startScript()

bool runtime_FileUtils_addSearchPath(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
bool ok = true;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj);
cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, false, "cocos2dx_FileUtils_addSearchPath : Invalid Native Object");
if (argc == 1 || argc == 2) {
std::string arg0;
bool arg1 = false;

ok &= jsval_to_std_string(cx, argv[0], &arg0);
ok &= jsval_to_std_string(cx, args.get(0), &arg0);
JSB_PRECONDITION2(ok, cx, false, "cocos2dx_FileUtils_addSearchPath : Error processing arguments");

if (argc == 2)
{
arg1 = JS::ToBoolean(JS::RootedValue(cx, argv[1]));
arg1 = JS::ToBoolean(args.get(1));
}

if (! FileUtils::getInstance()->isAbsolutePath(arg0))
Expand All @@ -130,7 +131,7 @@ bool runtime_FileUtils_addSearchPath(JSContext *cx, uint32_t argc, jsval *vp)
#endif
}

JS_SET_RVAL(cx, vp, JSVAL_VOID);
args.rval().setUndefined();
return true;
}

Expand All @@ -140,15 +141,15 @@ bool runtime_FileUtils_addSearchPath(JSContext *cx, uint32_t argc, jsval *vp)

bool runtime_FileUtils_setSearchPaths(JSContext *cx, uint32_t argc, jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
bool ok = true;
JSObject *obj = JS_THIS_OBJECT(cx, vp);
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj);
cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_setSearchPaths : Invalid Native Object");
if (argc == 1) {
std::vector<std::string> vecPaths, writePaths;
ok &= jsval_to_std_vector_string(cx, argv[0], &vecPaths);
ok &= jsval_to_std_vector_string(cx, args.get(0), &vecPaths);
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_setSearchPaths : Error processing arguments");

std::vector<std::string> originPath; // for IOS platform.
Expand All @@ -175,29 +176,19 @@ bool runtime_FileUtils_setSearchPaths(JSContext *cx, uint32_t argc, jsval *vp)
}

cobj->setSearchPaths(vecPaths);

JS_SET_RVAL(cx, vp, JSVAL_VOID);
args.rval().setUndefined();
return true;
}

JS_ReportError(cx, "js_cocos2dx_FileUtils_setSearchPaths : wrong number of arguments: %d, was expecting %d", argc, 1);
return false;
}

void register_FileUtils(JSContext *cx, JSObject *global) {
JS::RootedValue nsval(cx);
JS::RootedObject ns(cx);
JS_GetProperty(cx, global, "cc", &nsval);
if (nsval == JSVAL_VOID) {
return;
} else {
JS_ValueToObject(cx, nsval, &ns);
}
global = ns;

JSObject *tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.FileUtils.getInstance(); })()"));
JS_DefineFunction(cx, tmpObj, "addSearchPath", runtime_FileUtils_addSearchPath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE);
JS_DefineFunction(cx, tmpObj, "setSearchPaths", runtime_FileUtils_setSearchPaths, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE);
void register_FileUtils(JSContext* cx, JS::HandleObject global) {
JS::RootedObject proto(cx, jsb_cocos2d_FileUtils_prototype);
JS_DefineFunction(cx, proto, "addSearchPath", runtime_FileUtils_addSearchPath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE);
JS_DefineFunction(cx, proto, "setSearchPaths", runtime_FileUtils_setSearchPaths, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE);
}

void initRuntime()
Expand Down
2 changes: 1 addition & 1 deletion tools/bindings-generator