issue #2823: Enabling JSB debugger in debug mode. Removing the definition of JSB_ENABLE_DEBUGGER.

This commit is contained in:
James Chen 2013-10-10 16:06:05 +08:00
parent 8afef57679
commit 02f724cd23
7 changed files with 27 additions and 15 deletions

View File

@ -129,6 +129,10 @@ bool AppDelegate::applicationDidFinishLaunching()
sc->start();
#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)
sc->enableDebugger();
#endif
js_log("RUNNING Main");
auto pEngine = ScriptingCore::getInstance();
ScriptEngineManager::getInstance()->setScriptEngine(pEngine);

View File

@ -111,6 +111,10 @@ bool AppDelegate::applicationDidFinishLaunching()
sc->start();
#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)
sc->enableDebugger();
#endif
js_log("RUNNING Main");
auto pEngine = ScriptingCore::getInstance();
ScriptEngineManager::getInstance()->setScriptEngine(pEngine);

View File

@ -54,6 +54,10 @@ bool AppDelegate::applicationDidFinishLaunching()
sc->start();
#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)
sc->enableDebugger();
#endif
auto pEngine = ScriptingCore::getInstance();
ScriptEngineManager::getInstance()->setScriptEngine(pEngine);

View File

@ -58,6 +58,10 @@ bool AppDelegate::applicationDidFinishLaunching()
sc->start();
#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)
sc->enableDebugger();
#endif
auto pEngine = ScriptingCore::getInstance();
ScriptEngineManager::getInstance()->setScriptEngine(pEngine);
#ifdef JS_OBFUSCATED

View File

@ -50,6 +50,10 @@ bool AppDelegate::applicationDidFinishLaunching()
sc->start();
#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)
sc->enableDebugger();
#endif
auto pEngine = ScriptingCore::getInstance();
ScriptEngineManager::getInstance()->setScriptEngine(pEngine);
ScriptingCore::getInstance()->runScript("boot-jsb.js");

View File

@ -408,9 +408,6 @@ JSBool ScriptingCore::evalString(const char *string, jsval *outVal, const char *
void ScriptingCore::start() {
// for now just this
this->createGlobalContext();
#if JSB_ENABLE_DEBUGGER
this->enableDebugger();
#endif //JSB_ENABLE_DEBUGGER
}
void ScriptingCore::addRegisterCallback(sc_register_sth callback) {
@ -478,9 +475,7 @@ void ScriptingCore::createGlobalContext() {
//JS_SetGCZeal(this->cx_, 2, JS_DEFAULT_ZEAL_FREQ);
#endif
this->global_ = NewGlobalObject(cx_);
#if JSB_ENABLE_DEBUGGER
JS_SetDebugMode(cx_, JS_TRUE);
#endif
for (std::vector<sc_register_sth>::iterator it = registrationList.begin(); it != registrationList.end(); it++) {
sc_register_sth callback = *it;
callback(this->cx_, this->global_);
@ -2019,8 +2014,12 @@ JSBool JSBDebug_getEventLoopNestLevel(JSContext* cx, unsigned argc, jsval* vp)
return JS_TRUE;
}
void ScriptingCore::enableDebugger() {
if (debugGlobal_ == NULL) {
void ScriptingCore::enableDebugger()
{
JS_SetDebugMode(cx_, JS_TRUE);
if (debugGlobal_ == NULL)
{
JSAutoCompartment ac0(cx_, global_);
debugGlobal_ = NewGlobalObject(cx_, true);
JS_WrapObject(cx_, &debugGlobal_);

View File

@ -137,13 +137,6 @@
#define JSB_INCLUDE_COCOSDENSHION 1
#endif // JSB_INCLUDE_COCOSDENSHION
/** @def JSB_ENABLE_DEBUGGER
Set this to 1 to enable the debugger
*/
#ifndef JSB_ENABLE_DEBUGGER
#define JSB_ENABLE_DEBUGGER 1
#endif // JSB_ENABLE_DEBUGGER
#if JSB_ENABLE_DEBUGGER
#define JSB_ENSURE_AUTOCOMPARTMENT(cx, obj) \
JSAutoCompartment ac(cx, obj)