Example #1
0
  public void initialize(GlobalObject globalObject, JSObject proto) {
    // String.foo()
    defineNonEnumerableProperty(this, "fromCharCode", new FromCharCode(globalObject));

    // String.prototype.foo()
    proto.setPrototype(globalObject.getPrototypeFor("Object"));
    defineNonEnumerableProperty(proto, "constructor", this);
    defineNonEnumerableProperty(proto, "toString", new ToString(globalObject));
    defineNonEnumerableProperty(proto, "valueOf", new ValueOf(globalObject));
    defineNonEnumerableProperty(proto, "charAt", new CharAt(globalObject));
    defineNonEnumerableProperty(proto, "charCodeAt", new CharCodeAt(globalObject));
    defineNonEnumerableProperty(proto, "concat", new Concat(globalObject));
    defineNonEnumerableProperty(proto, "indexOf", new IndexOf(globalObject));
    defineNonEnumerableProperty(proto, "lastIndexOf", new LastIndexOf(globalObject));
    defineNonEnumerableProperty(proto, "localeCompare", new LocaleCompare(globalObject));
    defineNonEnumerableProperty(proto, "match", new Match(globalObject));
    defineNonEnumerableProperty(proto, "search", new Search(globalObject));
    defineNonEnumerableProperty(proto, "slice", new Slice(globalObject));
    defineNonEnumerableProperty(proto, "split", new Split(globalObject));
    defineNonEnumerableProperty(proto, "substring", new Substring(globalObject));
    defineNonEnumerableProperty(
        proto, "substr", new Substr(globalObject)); // Alias, 'cause node likes this
    defineNonEnumerableProperty(proto, "toLowerCase", new ToLowerCase(globalObject));
    defineNonEnumerableProperty(proto, "toUpperCase", new ToUpperCase(globalObject));
    defineNonEnumerableProperty(proto, "toLocaleLowerCase", new ToLocaleLowerCase(globalObject));
    defineNonEnumerableProperty(proto, "toLocaleUpperCase", new ToLocaleUpperCase(globalObject));
    defineNonEnumerableProperty(proto, "trim", new Trim(globalObject));
    defineNonEnumerableProperty(
        proto, "replace", new Replace(globalObject)); // http://es5.github.com/#x15.5.4.11
  }
Example #2
0
 @Override
 public void initialize(GlobalObject globalObject, JSObject proto) {
   proto.setPrototype(globalObject.getPrototypeFor("Object"));
   defineNonEnumerableProperty(proto, "constructor", this);
   defineNonEnumerableProperty(proto, "toString", new ToString(globalObject));
   defineNonEnumerableProperty(proto, "apply", new Apply(globalObject));
   defineNonEnumerableProperty(proto, "call", new Call(globalObject));
   defineNonEnumerableProperty(proto, "bind", new Bind(globalObject));
 }
Example #3
0
  @Override
  public void initialize(GlobalObject globalObject, JSObject proto) {
    proto.setPrototype(globalObject.getPrototypeFor("Object"));

    defineNonEnumerableProperty(proto, "constructor", this);
    defineNonEnumerableProperty(proto, "toString", new ToString(globalObject));
    defineNonEnumerableProperty(proto, "toLocaleString", new ToString(globalObject));
    defineNonEnumerableProperty(proto, "valueOf", new ValueOf(globalObject));
    defineNonEnumerableProperty(proto, "toFixed", new ToFixed(globalObject));
    defineNonEnumerableProperty(proto, "toExponential", new ToExponential(globalObject));
    defineNonEnumerableProperty(proto, "toPrecision", new ToPrecision(globalObject));

    defineReadOnlyProperty(this, globalObject, "NaN", Double.NaN);
    defineReadOnlyProperty(this, globalObject, "POSITIVE_INFINITY", Double.POSITIVE_INFINITY);
    defineReadOnlyProperty(this, globalObject, "NEGATIVE_INFINITY", Double.NEGATIVE_INFINITY);
    defineReadOnlyProperty(this, globalObject, "MIN_VALUE", Double.MIN_VALUE);
    defineReadOnlyProperty(this, globalObject, "MAX_VALUE", Double.MAX_VALUE);
    defineReadOnlyProperty(globalObject, globalObject, "NaN", Double.NaN);
    defineReadOnlyProperty(globalObject, globalObject, "Infinity", Double.POSITIVE_INFINITY);
  }