Hallo,

I just tried to port my wrapper code from v8 2.0 to the v8 3.2. Now
I'm facing with a problem I cannot fix on my own and I cannot find any
examples or details descriptions in this group.

Here my detailed problem:
We developed a JavaScript API for our framework using v8 2.0.
We added several object templates and function templates to wrap
several of our C++ classes (device classes etc.)
Our software allows to load several JavaScript files concurrently each
allowing (independently) access to our framework. Different C++
threads can invoke functions inside the individual JavaScript files to
change the behavior of our applications. (Locks avoid that v8 is
called concurrently by different threads)

Therefore, we created one (static) global object template holding
several function templates of the individual wrapper objects like
this:

v8::Handle<FunctionTemplate>
templateHandle(FunctionTemplate::New(cppConstructorOfObjectToBeWrapped));
templateHandle->SetClassName(v8::String::New("javascriptClassName));

Handle<ObjectTemplate> objectTemplate(templateHandle-
>InstanceTemplate());
objectTemplate->SetInternalFieldCount(1);
objectTemplate->Set(v8::String::New("doanything"),
FunctionTemplate::New(cppDoAnythingFunction));

Local<ObjectTemplate> globalTemplateObject =
Local<ObjectTemplate>(ObjectTemplate::New());
globalTemplateObject->Set(String::New("javascriptClassName"),
templateHandle);

And created a context using the global object template:

...
v8::Locker locker;
v8::HandleScope handleScope;
v8::Persistent<v8::Context> contextObject = Context::New(NULL,
globalTemplateObject);
Context::Scope contextScope(contextObject);
...

For the first time everything goes fine.
Now we would like to reuse the global object for further context
objects (e.g. each time a new scriptfile has to be loaded).
Everything was fine using v8 2.0.
However, now v8 3.2 crashes with an "Access violation ..." at objects-
inl.h, line 2926: ACCESSORS(TemplateInfo, property_list, Object,
kPropertyListOffset)

I guess that I'm not allowed to reuse the static global object
template again in different context objects. Or that I do have to
defined them in a different way - I also tried a
Persistent<ObjectTemplate> object but this also crashes...

I also tried to create a new template object for each new context
(only for testing), but I need a static template object of the
individual wrapper objects to create new instances of the JavaScript
objects for e.g. return values of the wrapped functions
(objectTemplate()->NewInstance();)...

Do you have any hint what I can do to fix the problem?
Some more descriptions about contexts and multi threading would be
very helpful...

Thanks,
Jan

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

Reply via email to