Well, what are you expecting in an empty this object? XD You have nothing 
assigned to it! Therefore, it will stay empty. Again, check the v8 docs and 
look for v8::Script, which esentialy is what oyu want; it lets you run arbitary 
JS code. But to be honest, I would not do this. Consider the binary functions 
as access into the low level, and try to write as much as you can via 
JavaScript. If you wish to use data from an existing object, you could end up 
writing something like this?

```js
var native = require("bindings")("myModule");
module.exports = {
        task: function(inputObject) {
                return native.native_task(this, inputObject);
        }
}
```
```c++
Handle<Value> native_task(const Arguments& args) {
        HandleScope scope;
        Value this = args[0];
        Value inputObject = args[1];
        // Do your stuff...
        return scope.Close(...);
}
```

The advantage is:
        - The lesser files that need to compile, the faster the setup will be.
        - The less native code, the more portable.
        - Mixing native and JS code makes things more readable for you and 
others. Its part of the toolbox principe.

This is just an advice of mine. But if you really MUST execute arbitary JS from 
a native function...

```c++
Handle<Value> runNative(const Arguments& args) {
        HandleScope scope;
        if(!args[0]->isString()) return scope.Close(Null()); // Do proper 
exception throwing here.
        Script evalScript = Script::New(args[0]->toString(), "internal.js");
        return scope.Close( evalScript.run() );
}
```

This is just a mock-up, you should look here: 
http://bespin.cz/~ondras/html/classv8_1_1Script.html
I never used eval in native code, to me, it doesnt sound very appealing anyway. 
:)

Hope this helped!
Am Do. Apr. 10 2014 16:39:10 schrieb samonzeweb:

> It's just code to learn/illustrate interaction between JS and C++, but there 
> is a surprising thing I don't understand. I wrote this code to illustrate a 
> thing wich caused trouble : why I don't see some objects ? The code has no 
> other purpose.
> 
> Later I'll need to execute arbitrary JS code from C++. I've an idea for a 
> potential project. But understand things is necessary.
> 
> 
> 
> Le jeudi 10 avril 2014 15:33:14 UTC+2, Kevin Ingwersen a écrit :
> 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: 
> 


-- 
-- 
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.

Reply via email to