From 7955721cb996aa1bd6abfc87f8aa981670f596cd Mon Sep 17 00:00:00 2001 From: "dongtao.han" Date: Thu, 25 Feb 2016 09:46:34 +0800 Subject: [PATCH 1/2] exported api. --- cocos/scripting/js-bindings/manual/ScriptingCore.h | 2 +- cocos/scripting/js-bindings/manual/js_manual_conversions.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.h b/cocos/scripting/js-bindings/manual/ScriptingCore.h index 1ce66079e9..6c4c2c6fdd 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.h +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.h @@ -657,7 +657,7 @@ JSObject* jsb_ref_autoreleased_get_or_create_jsobject(JSContext *cx, cocos2d::Re * The reference created from JSObject to native object is weak because it won't retain it. * The behavior is exactly the same with 'jsb_ref_get_or_create_jsobject' when CC_ENABLE_GC_FOR_NATIVE_OBJECTS desactivated. */ -JSObject* jsb_get_or_create_weak_jsobject(JSContext *cx, void *native, js_type_class_t *typeClass, const char* debug); +CC_JS_DLL JSObject* jsb_get_or_create_weak_jsobject(JSContext *cx, void *native, js_type_class_t *typeClass, const char* debug); /** * Register finalize hook and its owner as an entry in _js_hook_owner_map, diff --git a/cocos/scripting/js-bindings/manual/js_manual_conversions.h b/cocos/scripting/js-bindings/manual/js_manual_conversions.h index 0ba1aa0a64..dc09c22e4d 100644 --- a/cocos/scripting/js-bindings/manual/js_manual_conversions.h +++ b/cocos/scripting/js-bindings/manual/js_manual_conversions.h @@ -263,7 +263,7 @@ jsval ushort_to_jsval( JSContext *cx, unsigned short number ); jsval long_to_jsval( JSContext *cx, long number ); jsval ulong_to_jsval(JSContext* cx, unsigned long v); jsval long_long_to_jsval(JSContext* cx, long long v); -jsval std_string_to_jsval(JSContext* cx, const std::string& v); +CC_JS_DLL jsval std_string_to_jsval(JSContext* cx, const std::string& v); jsval c_string_to_jsval(JSContext* cx, const char* v, size_t length = -1); jsval ccpoint_to_jsval(JSContext* cx, const cocos2d::Point& v); jsval ccrect_to_jsval(JSContext* cx, const cocos2d::Rect& v); From 34b1c1bc18afc4d8585c4a969db780ecdb7f13db Mon Sep 17 00:00:00 2001 From: "dongtao.han" Date: Thu, 25 Feb 2016 09:47:19 +0800 Subject: [PATCH 2/2] exported js_get_type_from_native for cocos2d::Node type. --- cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp | 5 +++++ cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp index ca55670387..1f8bc98cae 100644 --- a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp +++ b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp @@ -544,6 +544,11 @@ JSObject* getObjectFromNamespace(JSContext* cx, JS::HandleObject ns, const char return NULL; } +js_type_class_t *js_get_type_from_node(cocos2d::Node* native_obj) +{ + return js_get_type_from_native(native_obj); +} + void js_add_FinalizeHook(JSContext *cx, JS::HandleObject target) { JS::RootedObject proto(cx, jsb_FinalizeHook_prototype); diff --git a/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp b/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp index ddce1dd7e8..8ccf4ec87e 100644 --- a/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp +++ b/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp @@ -83,6 +83,11 @@ inline js_type_class_t *js_get_type_from_native(T* native_obj) { return found ? typeProxyIter->second : nullptr; } +/** +* get type from a cocos2d::Node, call function(js_get_type_from_native) above. +*/ +CC_JS_DLL js_type_class_t *js_get_type_from_node(cocos2d::Node* native_obj); + /** * Gets or creates a JSObject based on native_obj. * If native_obj is subclass of Ref, it will use the jsb_ref functions.