How to bind global object custom one.

Feb 4, 2013 at 3:30 PM
Does anyone know how to make global object equal to any custom object?
I'm trying to implement DOM in C# and use v8 to process scripts. And I need to make global object to be equal to window object (like it implemented in browsers).
Feb 4, 2013 at 11:32 PM
You could put everything in an object and then invoke the code via, args, ...)
Feb 5, 2013 at 3:24 PM
If I understand you correctly I will have to have specific scripts. And unfortunately it will not work for me. I need to be able to process any scripts from outside sources.

I guess my main problem is to catch the call to global object's properties usage. Library have methods that are called when script tries to access properties of other objects. But when script is trying to call property of global object then those methods are not used. I only receive message that property is not defined. Any ideas how to achieve that?
Feb 5, 2013 at 4:47 PM
Ariman, do you need to trap global writes - e.g., when the script sets a global property? Or do you only care about global reads?
Feb 6, 2013 at 7:42 AM
Preferably both. But if you have a solution for reads I will gladly take it.
Feb 6, 2013 at 12:39 PM
Unfortunately I don't think I have a good solution for you. ClearScript lets you merge custom objects into the global object, so that the properties and methods of custom objects appear within the global namespace, but that doesn't sound like it does what you need.
Feb 19, 2013 at 2:07 PM
Thanks for the link. ClearScript is an interesting library. But it does not have required feature.

However I think I've found the solution for my problem on my own. Inclusion of my object to v8 prototype chain seems to do the trick.