mirror of https://github.com/axmolengine/axmol.git
Merge branch 'gles20'
This commit is contained in:
commit
bc19f40239
|
@ -9,10 +9,6 @@
|
|||
#include "js_bindings_ccbreader.h"
|
||||
#include "js_bindings_system_registration.h"
|
||||
|
||||
#if JSB_ENABLE_DEBUGGER
|
||||
#include "js_bindings_dbg.h"
|
||||
#endif
|
||||
|
||||
USING_NS_CC;
|
||||
using namespace CocosDenshion;
|
||||
|
||||
|
|
|
@ -41,9 +41,6 @@
|
|||
#endif
|
||||
|
||||
#include "js_bindings_config.h"
|
||||
#if JSB_ENABLE_DEBUGGER
|
||||
#include "js_bindings_dbg.h"
|
||||
#endif
|
||||
|
||||
pthread_t debugThread;
|
||||
string inData;
|
||||
|
@ -332,6 +329,7 @@ ScriptingCore::ScriptingCore()
|
|||
// set utf8 strings internally (we don't need utf16)
|
||||
JS_SetCStringsAreUTF8();
|
||||
this->addRegisterCallback(registerDefaultClasses);
|
||||
this->runLoop = new SimpleRunLoop();
|
||||
}
|
||||
|
||||
void ScriptingCore::string_report(jsval val) {
|
||||
|
@ -1413,6 +1411,17 @@ jsval cccolor3b_to_jsval(JSContext* cx, const ccColor3B& v) {
|
|||
|
||||
#pragma mark - Debug
|
||||
|
||||
void SimpleRunLoop::update(float dt) {
|
||||
pthread_mutex_lock(&g_qMutex);
|
||||
while (queue.size() > 0) {
|
||||
vector<string>::iterator first = queue.begin();
|
||||
string str = *first;
|
||||
ScriptingCore::getInstance()->debugProcessInput(str);
|
||||
queue.erase(first);
|
||||
}
|
||||
pthread_mutex_unlock(&g_qMutex);
|
||||
}
|
||||
|
||||
void ScriptingCore::debugProcessInput(string str) {
|
||||
JSString* jsstr = JS_NewStringCopyZ(cx_, str.c_str());
|
||||
jsval argv[3] = {
|
||||
|
@ -1450,6 +1459,9 @@ void ScriptingCore::enableDebugger() {
|
|||
JS_DefineFunction(cx_, global_, "startDebugger", JSBDebug_StartDebugger, 3, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
// start bg thread
|
||||
pthread_create(&debugThread, NULL, serverEntryPoint, NULL);
|
||||
|
||||
CCScheduler* scheduler = CCDirector::sharedDirector()->getScheduler();
|
||||
scheduler->scheduleUpdateForTarget(this->runLoop, 0, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,12 +27,20 @@ typedef void (*sc_register_sth)(JSContext* cx, JSObject* global);
|
|||
|
||||
void registerDefaultClasses(JSContext* cx, JSObject* global);
|
||||
|
||||
|
||||
class SimpleRunLoop : public CCObject
|
||||
{
|
||||
public:
|
||||
void update(float d);
|
||||
};
|
||||
|
||||
class ScriptingCore : public CCScriptEngineProtocol
|
||||
{
|
||||
JSRuntime *rt_;
|
||||
JSContext *cx_;
|
||||
JSObject *global_;
|
||||
JSObject *debugGlobal_;
|
||||
SimpleRunLoop* runLoop;
|
||||
|
||||
ScriptingCore();
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue