On Jul 6, 4:23 pm, Matthias Ernst <[email protected]> wrote:
> On Wed, Jul 6, 2011 at 4:09 PM, HdcDst <[email protected]> wrote:
> > I am using the following C code in my Program:
>
> > 1:      HandleScope handle_scope;
> > 2:      Handle<ObjectTemplate> global = ObjectTemplate::New();
> > 3:      Handle<ObjectTemplate> point_templ = ObjectTemplate::New();
> > 4:      point_templ->SetInternalFieldCount(1);
> > 5:      point_templ->SetAccessor(String::New("x"), Point::GetPointX,
> > 6:      Point::SetPointX);
> > 7:      point_templ->SetAccessor(String::New("y"), Point::GetPointY,
> > 8:      Point::SetPointY);
> > 9:      Point *p = new Point(3,4);
> > 10:     Local<Object> obj = point_templ->NewInstance();
> > 11:     obj->SetInternalField(0, External::New(p));
>
> > But when at line 10: "Local<Object> obj = point_templ-
> >>NewInstance();"
> > The Program stops with a memory access error.
> > Does anyone has an Idea, what's wrong in my code?
>
> > --
> > v8-users mailing list
> > [email protected]
> >http://groups.google.com/group/v8-users
>
> Some relevant context is missing from your example.
> So I can only guess: are you executing within a Context::Scope?
> What is the point of "global"? It smells as if you meant to
> instantiate a context.
This helped.
The problem was, that I tried to instantiat a template before I set up
a context scope.
Setting up a context, getting the global object instead the global
template, and then setting
the point_object as a property of the global object worked.
-- HdcDst

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to