Mercurial > scratch
comparison pydershell/pydershell.py @ 27:7f12db104246
Added evaluate, new_array, and new_object functions to JsSandbox class.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Tue, 08 Sep 2009 09:38:46 -0700 |
parents | b7037cd0f375 |
children | f974d4a80473 |
comparison
equal
deleted
inserted
replaced
26:b7037cd0f375 | 27:7f12db104246 |
---|---|
425 return SafeJsObjectWrapper(self, jsvalue, this) | 425 return SafeJsObjectWrapper(self, jsvalue, this) |
426 else: | 426 else: |
427 # It's a primitive value. | 427 # It's a primitive value. |
428 return jsvalue | 428 return jsvalue |
429 | 429 |
430 def new_array(self, *contents): | |
431 array = self.wrap_jsobject(self.cx.new_array_object()) | |
432 for item in contents: | |
433 array.push(self.wrap_pyobject(item)) | |
434 return array | |
435 | |
436 def new_object(self, **contents): | |
437 obj = self.wrap_jsobject(self.cx.new_object()) | |
438 for name in contents: | |
439 obj[name] = self.wrap_pyobject(contents[name]) | |
440 | |
441 def evaluate(self, code, filename='<string>', lineno=1): | |
442 retval = self.cx.evaluate_script(self.root.wrapped_jsobject, | |
443 code, filename, lineno) | |
444 return self.wrap_jsobject(retval) | |
445 | |
430 def run_script(self, filename): | 446 def run_script(self, filename): |
431 """ | 447 """ |
432 Runs the given JS script, returning 0 on success, -1 on failure. | 448 Runs the given JS script, returning 0 on success, -1 on failure. |
433 """ | 449 """ |
434 | 450 |