Hi all,
I have recently integrated V8 into a Mac OS X application. I can run
the application fine, but when I try to request the scripts from the
debugger I keep getting the following response.
{"seq":0,"request_seq":
117,"type":"response","command":"source","success":false,"message":"No
source","running":true}
I know I am loading and running JavaScript code because I get
callbacks to my bound C functions. I have modeled my integration from
the lineprocessor sample, and I know I am using a debuggable libv8.a
because I can request the code if I do everything from within the main
function:
void CopyPasteFromLineProcessor()
{
.. Line processor code with a few tweaks
while(true)
{
... Make a callback to JS via a function handle
}
}
bool useApp = true;
int main(int argc, char *argv[])
{
int retVal = 0;
if(useApp)
{
// This code path will not work with debugger
retVal = NSApplicationMain(argc, (const char **)argv);
}
else
{
// this code path will work with the debugger but it will
block indefinitely.
CopyPasteCodeFromLineProcessor();
}
}
Application Code (Objective-C):
-(void) SetupJS // Called by Application Main thread
{
v8::Locker locker;
JSManager::Instance().Init();
// bind some C functions to the JS global namespace
....
JSManager::Instance().Start();
}
// Callback made by Mac OS X CVDisplayLink thread (not Application
Main Thread)
+(void) OnRenderTick
{
v8::Locker locker;
JSManager::Instance().Update();
}
JS Manager Code:
void JSManager::Init()
{
v8::HandleScope handle_scope;
v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
mGlobalObjDef = v8::Persistent<v8::ObjectTemplate>::New(global);
v8::Debug::SetDebugMessageDispatchHandler(DispatchDebugMessages,
true);
v8::Debug::EnableAgent("MyApp", 9222, false);
}
void JSManager::Start()
{
v8::HandleScope handle_scope;
mContext = v8::Context::New(NULL, mGlobalObjDef);
v8::Context::Scope context_scope(mContext);
debug_message_context =
v8::Persistent<v8::Context>::New(mContext);
.. Fish out the handles to some JS functions I want to call
}
void JSManager::Update
{
v8::HandleScope current_scope;
.. Call that JS function handle I found in the start method
}
I am sure I am just doing something wrong but I can't put my finger on
it. Any help would be greatly appreciated.
Thanks!
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users