Outside of the browser (and in a stand alone project that references
the V8.lib), I'm trying to load and compile some JavaScript code which
contains a few references to various Browser DOM related objects. As I
don't actually need to fully execute the code (as the intention is to
perform some code analysis), I'd like to translate the following
JavaScript into C++ code for use with the V8 API.
this.window = this;
this.navigator = {
userAgent : "MSIE"
};
this.document = {
documentElement : {}
};
I just haven't been able to get my head around the API. I have a work
around (which is to simply execute the code above directly as
JavaScript), although I'd really appreciate someone helping me how to
properly add the equivalent code in C++.
I'm using the shell.cc as the starter for my code parser. I've tried
various combinations of GetPrototype, etc., but can't seem to get the
reference to the global object working properly.
This, for example, throws an exception:
global->Set(String::New("window"), global);
I assume it's too early (as I put it before the Context::New). But,
when I move it after the context is created with the global object,
the window property isn't set.
This JavaScript code will fail (with window type is undefined).
if (!window) this.window = this;
(Since the JavaScript code isn't mine, I'd rather not fix it just so
that it compiles).
Thanks!
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users