Eval'ing code in non-global / user defined scope.

30 views
Skip to first unread message

mcot

unread,
Feb 28, 2011, 4:50:00 PM2/28/11
to PyV8
Would it be possible to add something to pyv8 such that the
JSContext.eval() could evaluate the code in a given scope?

I think the scope could either be a function defined in JavaScript or
Python. The best example I have to show this feature would be:

// JavaScript Example
function xyz() {
this.x = 5;
this.y = 10;
}
someObj = new xyz()

code = "this.x = 10; this.y = 20"
scopeObject = someObj // modifies x and y in xyz



// Python Example
class XYZ(PyV8.JSClass):
def __init__(self):
self.x = 5;
self.y = 10;

class Global(PyV8.JSClass):

def __init__(self):
self.someObj = XYZ()

code = "this.x = 10; this.y = 20"
scopeObject = someObj // modifies x and y in XYZ




Demolishun

unread,
Nov 27, 2012, 8:30:45 AM11/27/12
to py...@googlegroups.com
Isn't this how contexts work already?
Reply all
Reply to author
Forward
0 new messages