Add split built-in, also sort knownNatives for my own sanity (should sort builtins.tbl and jsbuiltins.cpp by function while at it, but too tired).

This commit is contained in:
Brendan Eich
2008-08-21 04:13:07 -07:00
parent ace0e8305f
commit 11844b50d1
5 changed files with 36 additions and 20 deletions

View File

@@ -303,6 +303,17 @@ js_String_p_replace_str3(JSContext* cx, JSString* str, JSString* patstr, JSStrin
return JSVAL_TO_STRING(vp[0]);
}
JSString* FASTCALL
js_String_p_split(JSContext* cx, JSString* str, JSString* sepstr)
{
// FIXME: optimize by calling into a lower level exported from jsstr.cpp.
jsval vp[3] = { JSVAL_NULL, STRING_TO_JSVAL(str), STRING_TO_JSVAL(sepstr) };
if (!js_str_split(cx, 2, vp))
return NULL;
JS_ASSERT(JSVAL_IS_STRING(vp[0]));
return JSVAL_TO_STRING(vp[0]);
}
jsdouble FASTCALL
js_StringToNumber(JSContext* cx, JSString* str)
{