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.
On Mon, Mar 10, 2014 at 3:55 PM, Ben Noordhuis <[email protected]> wrote:
> On Mon, Mar 10, 2014 at 3:24 PM, Zinglish <[email protected]> wrote:
> > Hi guys
> >
> > I have an issue when attempting to embed a very simple V8 flow into my
> > application. Basically I have a wrapper class that holds a global Isolate
> > (Which I will use everywhere) and also holds the context (Since I want
> all
> > events to share any global variables). When I try entering the context I
> > create in my wrapper class in main, I get this error:
> >
> >> #
> >> # Fatal error in ../src/api.h, line 402
> >> # CHECK(that == __null || !(*reinterpret_cast<v8::internal::Context**>(
> >> const_cast<v8::Context*>(that)))->IsFailure()) failed
> >> #
> >> ==== C stack trace ===============================
> >> 1: V8_Fatal
> >> 2: v8::Utils::OpenHandle(v8::Context const*, bool)
> >> 3: v8::Context::Enter()
> >> 4: init(int, char**)
> >> 5: ??
> >> 6: ??
> >> 7: ??
> >
> >
> >
> > Here's my wrapper class (JSEngine.cpp):
> >
> > JSEngine::Engine()
> > {
> > printf("Script | 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, context: %lu\n",
> > this->context);
> > }
> >
> > All I wanted this to do is initalize the V8 engine and create a single
> > Isolate and Context.
> >
> >
> >
> > Here's my Init (Which throws the error shown in the first quote block
> when
> > it hits the second line):
> >
> > HandleScope handleScope(Server::asEngine->isolate);
> > printf("Set scope to isolate\n");
> > Server::asEngine->context->Enter();
> > printf("Set scope to context\n");
> >
> > Handle<String> source = String::NewFromUtf8(Server::asEngine->isolate,
> "var
> > test = 5;");
> > Handle<Script> script = Script::Compile(source);
> > Handle<Value> result = script->Run();
> >
> >
> > I feel like I am doing something really dumb that it doesn't work as I
> > expect. All I essentially did was attempt to split up the most basic
> example
> > into a class so I could grasp the concept and idea of embedding V8.
> >
> > Thank you ahead of time if you do post a reply.
>
> I suspect that you need to change this->context from Local<Context> or
> Handle<Context> to a Persistent<Context>. You can rematerialize the
> handle in your Init() function with `Local<Context> context =
> Local<Context>::New(this->isolate, this->context)`.
>
> By the way, you can use `Context::Scope context_scope(context)`
> instead of manually entering and exiting the context. The
> Context::Scope destructor will automatically exit the context when the
> context_scope variable goes out of scope.
>
> --
> --
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "v8-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/v8-users/vji3EwZZN7k/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
--
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.