static void init(Scriptable scope, boolean sealed) { NativeString obj = new NativeString(""); obj.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed); }
addIdFunctionProperty(ctor, STRING_TAG, ConstructorId_fromCharCode, "fromCharCode", 1); addIdFunctionProperty(ctor, STRING_TAG, ConstructorId_charAt, "charAt", 2); addIdFunctionProperty(ctor, STRING_TAG, ConstructorId_charCodeAt, "charCodeAt", 2); addIdFunctionProperty(ctor, STRING_TAG, ConstructorId_indexOf, "indexOf", 2); addIdFunctionProperty(ctor, STRING_TAG, ConstructorId_lastIndexOf, "lastIndexOf", 2); addIdFunctionProperty(ctor, STRING_TAG, ConstructorId_split, "split", 3); addIdFunctionProperty(ctor, STRING_TAG, ConstructorId_substring, "substring", 3); addIdFunctionProperty(ctor, STRING_TAG, ConstructorId_toLowerCase, "toLowerCase", 1); addIdFunctionProperty(ctor, STRING_TAG, ConstructorId_toUpperCase, "toUpperCase", 1); addIdFunctionProperty(ctor, STRING_TAG, ConstructorId_substr, "substr", 3); addIdFunctionProperty(ctor, STRING_TAG, ConstructorId_concat, "concat", 2); addIdFunctionProperty(ctor, STRING_TAG, ConstructorId_slice, "slice", 3); addIdFunctionProperty(ctor, STRING_TAG, ConstructorId_equalsIgnoreCase, "equalsIgnoreCase", 2); addIdFunctionProperty(ctor, STRING_TAG, ConstructorId_match, "match", 2); addIdFunctionProperty(ctor, STRING_TAG,
private static NativeString realThis(Scriptable thisObj, IdFunctionObject f) { if (!(thisObj instanceof NativeString)) throw incompatibleCallError(f); return (NativeString)thisObj; }
return new NativeString(s); return realThis(thisObj, f).string; String s = realThis(thisObj, f).string; return "(new String(\""+ScriptRuntime.escapeString(s)+"\"))"; return ScriptRuntime.wrapInt(js_indexOf( ScriptRuntime.toString(thisObj), args)); return ScriptRuntime.wrapInt(js_lastIndexOf( ScriptRuntime.toString(thisObj), args)); return js_substring(cx, ScriptRuntime.toString(thisObj), args); return js_substr(ScriptRuntime.toString(thisObj), args); return js_concat(ScriptRuntime.toString(thisObj), args); return js_slice(ScriptRuntime.toString(thisObj), args); return tagify(thisObj, "b", null, null); return tagify(thisObj, "i", null, null); return tagify(thisObj, "tt", null, null); return tagify(thisObj, "strike", null, null);
@Override protected int findInstanceIdInfo(String s) { if (s.equals("length")) { return instanceIdInfo(DONTENUM | READONLY | PERMANENT, Id_length); } return super.findInstanceIdInfo(s); }
default: throw new IllegalArgumentException(String.valueOf(id)); initPrototypeMethod(STRING_TAG, id, s, arity);
static long getLengthProperty(Context cx, Scriptable obj) { // These will both give numeric lengths within Uint32 range. if (obj instanceof NativeString) { return ((NativeString)obj).getLength(); } else if (obj instanceof NativeArray) { return ((NativeArray)obj).getLength(); } return ScriptRuntime.toUint32( ScriptRuntime.getObjectProp(obj, "length", cx)); }
NativeString.init(scope, sealed); NativeBoolean.init(scope, sealed); NativeNumber.init(scope, sealed);