I dont get what you are trying to do?
So you want to call a function that prints contents of the global object?
Besides, you shouldn't need to create a v8::Function for eval, instead, look
into v8::Script. There is most probably an existing eval-like function.
Am Do. Apr. 10 2014 15:24:56 schrieb samonzeweb:
> 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.