def Call(self, ctx, args=[], this=None): if len(args) >= 1 and not isnull_or_undefined(args[0]): return W_FloatNumber(args[0].ToNumber(ctx)) elif len(args) >= 1 and args[0] is w_Undefined: return W_FloatNumber(NAN) else: return W_FloatNumber(0.0)
def Call(self, ctx, args=[], this=None): if len(args) >= 1: if isnull_or_undefined(args[0]): thisArg = ctx.get_global() else: thisArg = args[0] callargs = args[1:] else: thisArg = ctx.get_global() callargs = [] return this.Call(ctx, callargs, this = thisArg)
def Call(self, ctx, args=[], this=None): try: if isnull_or_undefined(args[0]): thisArg = ctx.get_global() else: thisArg = args[0].ToObject(ctx) except IndexError: thisArg = ctx.get_global() try: arrayArgs = args[1] if isinstance(arrayArgs, W_ListObject): callargs = arrayArgs.tolist() elif isnull_or_undefined(arrayArgs): callargs = [] else: raise JsTypeError('arrayArgs is not an Array or Arguments object') except IndexError: callargs = [] return this.Call(ctx, callargs, this=thisArg)
def common_join(ctx, this, sep=','): length = this.Get(ctx, 'length').ToUInt32(ctx) l = [] i = 0 while i < length: item = this.Get(ctx, str(i)) if isnull_or_undefined(item): item_string = '' else: item_string = item.ToString(ctx) l.append(item_string) i += 1 return sep.join(l)
def Construct(self, ctx, args=[]): if len(args) >= 1 and not isnull_or_undefined(args[0]): Value = W_FloatNumber(args[0].ToNumber(ctx)) return create_object(ctx, 'Number', Value = Value) return create_object(ctx, 'Number', Value = W_FloatNumber(0.0))
def Construct(self, ctx, args=[]): if len(args) >= 1 and not isnull_or_undefined(args[0]): Value = newbool(args[0].ToBoolean()) return create_object(ctx, 'Boolean', Value = Value) return create_object(ctx, 'Boolean', Value = newbool(False))
def Call(self, ctx, args=[], this=None): if len(args) >= 1 and not isnull_or_undefined(args[0]): return newbool(args[0].ToBoolean()) else: return newbool(False)
def Call(self, ctx, args=[], this=None): if len(args) >= 1 and not isnull_or_undefined(args[0]): return args[0].ToObject(ctx) else: return self.Construct(ctx)