Beispiel #1
0
 public override object Construct(ExecutionContext GLOBAL, JSObjectBase a, ExecutionContext x)
 {
     JSObject result;
     int alen = (int)JSObject.ToNumber(GLOBAL, a.GetItem(GLOBAL, "length").GetValue(GLOBAL));
     if (alen > 0) result = new StringObject(GLOBAL, a.GetItem(GLOBAL, "0").GetValue(GLOBAL).ToString());
     else result = new StringObject(GLOBAL, "");
     result.DefProp(GLOBAL, "constructor", this);
     return result;
 }
Beispiel #2
0
 public StringFun(ExecutionContext GLOBAL)
 {
     JSObject prototype = new StringObject(GLOBAL, "");
     prototype.SetItem(GLOBAL, "toString", new JSNativeMethod(typeof(JSObject), "ToString"));
     prototype.SetItem(GLOBAL, "valueOf", new JSNativeMethod(typeof(JSObject), "ToPrimitive"));
     prototype.SetItem(GLOBAL, "substring", new JSNativeMethod(typeof(StringObject), "Substring"));
     prototype.SetItem(GLOBAL, "split", new JSNativeMethod(typeof(StringObject), "Split"));
     prototype.SetItem(GLOBAL, "fromCharCode", new JSNativeMethod(typeof(StringObject), "fromCharCode"));
     prototype.SetItem(GLOBAL, "charCodeAt", new JSNativeMethod(typeof(StringObject), "charCodeAt"));
     prototype.SetItem(GLOBAL, "charAt", new JSNativeMethod(typeof(StringObject), "charAt"));
     DefProp(GLOBAL, "prototype", prototype, false, false, false, false);
 }