'document not defined' message while running script;

1,664 views
Skip to first unread message

Ravi

unread,
Jun 30, 2009, 12:31:52 PM6/30/09
to v8-users
Hi,

I've been studying and trying to embed the V8 engine into a sample C++
application here. I'm passing in a JavaScript to the library to
compile and run. I've added few callbacks to handle some functions
like 'write', 'alert', etc.

However, if there is a line like "document.write("Hello, world!")",
the script fails to run saying "ReferenceError: Document is not
defined".

Do we have to provide a template for 'Document' as well? Please let me
know if I'm missing something. I've been going through the
documentation, but, could not find anything related to this.

Thank you,
Ravi

Stephan Beal

unread,
Jun 30, 2009, 12:38:38 PM6/30/09
to v8-u...@googlegroups.com
On Tue, Jun 30, 2009 at 6:31 PM, Ravi<chin...@yahoo.com> wrote:
> However, if there is a line like "document.write("Hello, world!")",
> the script fails to run saying "ReferenceError: Document is not
> defined".

The Document object is part of the browser, not part of the core JS
language, and thus you won't find it in v8. v8 only implements the
EMCAScript language itself, and not related standards like DOM.

--
----- stephan beal
http://wanderinghorse.net/home/stephan/

Ravi

unread,
Jun 30, 2009, 1:34:11 PM6/30/09
to v8-users

Thanks Stephan. Is there anyway to handle such objects through
templates?

Thank you,
Ravi

On Jun 30, 12:38 pm, Stephan Beal <sgb...@googlemail.com> wrote:

Stephan Beal

unread,
Jun 30, 2009, 2:06:06 PM6/30/09
to v8-u...@googlegroups.com
On Tue, Jun 30, 2009 at 7:34 PM, Ravi<chin...@yahoo.com> wrote:
> Thanks Stephan. Is there anyway to handle such objects through
> templates?

Several members of this list have implemented various class bindings
using either template- or macro-based solutions. Mine (templates) is
here:

http://code.google.com/p/v8-juice/

On the "related works" section of that page you'll find links to others.

You can read a fairly detailed description of the class-binding features at:

http://code.google.com/p/v8-juice/wiki/CreatingJSClasses
http://code.google.com/p/v8-juice/wiki/ClassBinder

Happy hacking!

Ravi

unread,
Jun 30, 2009, 2:19:34 PM6/30/09
to v8-users

Thanks Stephan! That is quite helpful.

Thnak you,
Ravi


On Jun 30, 2:06 pm, Stephan Beal <sgb...@googlemail.com> wrote:
> On Tue, Jun 30, 2009 at 7:34 PM, Ravi<chinn...@yahoo.com> wrote:
> > Thanks Stephan. Is there anyway to handle such objects through
> > templates?
>
> Several members of this list have implemented various class bindings
> using either template- or macro-based solutions. Mine (templates) is
> here:
>
> http://code.google.com/p/v8-juice/
>
> On the "related works" section of that page you'll find links to others.
>
> You can read a fairly detailed description of the class-binding features at:
>
> http://code.google.com/p/v8-juice/wiki/CreatingJSClasseshttp://code.google.com/p/v8-juice/wiki/ClassBinder
Reply all
Reply to author
Forward
0 new messages