Hi,
I'playing with C++ Addons and Node.js. I try to understand some things,
behond the classics tutorials available on the web. I try to execute
arbitrary javascript code from C++ and undersand context, scope, ... from
v8.
There is a "DisplayThis" method in C++ "hello" module (it started with
"Hello World") :
Handle<Value> DisplayThis(const Arguments &args) {
HandleScope scope;
Local<Function> eval = Local<Function>::Cast(
Context::GetCurrent()->Global()->Get(String::New("eval")) );
Local<Value> arguments[1] = { String::New("console.log(this);") };
Local<Value> result = eval->Call(Context::GetCurrent()->Global(), 1,
arguments);
return scope.Close(result);
}
I call it from JS :
var hello = require("./build/Release/hello");
var dummy = "LOL";
hello.DisplayThis();
I get a result, but some things are missing. When the code display "this",
I don't see "dummy", nor "module", "require" and perhaps others things. If
I just display "this" from node they are displayed. It seems like the
context of execution is different.
WHY ? And how to get the good "this" (one from javascript calling scope).
There is something important to undersantd here.
Thanks.
Sam.
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" 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.