On Mon, Mar 10, 2014 at 5:45 PM, Terence-Lee Davis <[email protected]> wrote:
> Hey Ben
>
> Thanks a lot for the reply to the topic!
>
> I went back to my code and made the appropriate changes but still no change
> to the error I get. Also, for some reason the compiler errors out when I
> attempt to adjust this->context to type "v8::Persistent<v8::Context>" with:
>
> error: no match for 'operator=' in
> '((ASEngine::Engine*)this)->ASEngine::Engine::context =
> v8::Context::New(((ASEngine::Engine*)this)->ASEngine::Engine::isolate, 0u,
> v8::Handle<v8::ObjectTemplate>(), v8::Handle<v8::Value>())'
>
>
>
> If it helps I am using V8 version 3.22 (I checked out to this version from
> master because I had a feeling master had a few issues).
>
> I did however adjust my class to look like this now:
>
> ASEngine::Engine::Engine()
> {
> printf("eScript | DEBUG | Constructing engine\n");
>
> V8::Initialize();
> this->isolate = Isolate::GetCurrent();
> HandleScope scope(this->isolate);
> this->context = Context::New(this->isolate);
> Persistent<Context> persistent_context(this->isolate, this->context);
> printf("Script | DEBUG | Done constructing engine\n");
> }
>
> v8::Local<v8::Context> ASEngine::Engine::GetContext()
> {
> return Local<Context>::New(this->isolate, this->context);
> }
>
>
> As I adjusted the class above, I adjusted the code in Init() to:
>
> Server::asEngine = new ASEngine::Engine();
> HandleScope handleScope(Server::asEngine->isolate);
> Context::Scope scope(Server::asEngine->GetContext());
> Handle<String> source2 = String::NewFromUtf8(Server::asEngine->isolate,
> "test;");
> Handle<Script> script2 = Script::Compile(source2);
> Handle<Value> result2 = script2->Run();
>
> I still get the exact same error.

That's because the Context object is still wrapped in a Local and that
Local gets zeroed when the HandleScope it was created in goes out of
scope.  Turn it into a Persistent<Context>, assign it with
this->context.Reset(isolate, context) and all should be well.

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to