Author: Stephan <[email protected]>
Branch: 
Changeset: r174:76227d710405
Date: 2012-01-06 14:59 +0100
http://bitbucket.org/pypy/lang-js/changeset/76227d710405/

Log:    reorganized Function bultins

diff --git a/js/builtins.py b/js/builtins.py
--- a/js/builtins.py
+++ b/js/builtins.py
@@ -140,44 +140,6 @@
 
         #raise JsTypeError('this is not a function object')
 
-#class W_Apply(W_NewBuiltin):
-    #def __init__(self, ctx):
-        #W_NewBuiltin.__init__(self)
-        #self.ctx = ctx
-
-    #def Call(self, args=[], this=None):
-        #try:
-            #if isnull_or_undefined(args[0]):
-                #thisArg = self.ctx.get_global()
-            #else:
-                #thisArg = args[0].ToObject()
-        #except IndexError:
-            #thisArg = self.ctx.get_global()
-
-        #try:
-            #arrayArgs = args[1]
-            #callargs = arrayArgs.tolist()
-        #except IndexError:
-            #callargs = []
-        #return this.Call(callargs, this=thisArg)
-
-#class W_Call(W_NewBuiltin):
-    #def __init__(self, ctx):
-        #W_NewBuiltin.__init__(self)
-        #self.ctx = ctx
-
-    #def Call(self, args=[], this=None):
-        #if len(args) >= 1:
-            #if isnull_or_undefined(args[0]):
-                #thisArg = self.ctx.get_global()
-            #else:
-                #thisArg = args[0]
-            #callargs = args[1:]
-        #else:
-            #thisArg = self.ctx.get_global()
-            #callargs = []
-        #return this.Call(callargs, this = thisArg)
-
 #class W_ValueToString(W_NewBuiltin):
     #"this is the toString function for objects with Value"
     #mytype = ''
diff --git a/js/builtins_function.py b/js/builtins_function.py
--- a/js/builtins_function.py
+++ b/js/builtins_function.py
@@ -1,6 +1,38 @@
+from js.jsobj import isnull_or_undefined
+
 def to_string(this, *args):
     return this.ToString()
 
 def empty(this, *args):
     from js.jsobj import w_Undefined
     return w_Undefined
+
+# 15.3.4.4 Function.prototype.call
+def call(this, *args):
+    if len(args) >= 1:
+        if isnull_or_undefined(args[0]):
+            thisArg = self.ctx.get_global()
+        else:
+            thisArg = args[0]
+        callargs = args[1:]
+    else:
+        thisArg = self.ctx.get_global()
+        callargs = []
+    return this.Call(callargs, this = thisArg)
+
+# 15.3.4.3 Function.prototype.apply (thisArg, argArray)
+def apply(this, *args):
+    try:
+        if isnull_or_undefined(args[0]):
+            thisArg = self.ctx.get_global()
+        else:
+            thisArg = args[0].ToObject()
+    except IndexError:
+        thisArg = self.ctx.get_global()
+
+    try:
+        arrayArgs = args[1]
+        callargs = arrayArgs.tolist()
+    except IndexError:
+        callargs = []
+    return this.Call(callargs, this=thisArg)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to