return String_toString(dispex, lcid, flags, dp, retv, ei, sp);
}
+static HRESULT do_attributeless_tag_format(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
+ VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp, const WCHAR *tagname)
+{
+ static const WCHAR tagfmt[] = {'<','%','s','>','%','s','<','/','%','s','>',0};
+ StringInstance *string;
+ BSTR ret;
+
+ if(!is_class(dispex, JSCLASS_STRING)) {
+ WARN("this is not a string object\n");
+ return E_NOTIMPL;
+ }
+
+ string = (StringInstance*)dispex;
+
+ if(retv) {
+ ret = SysAllocStringLen(NULL, string->length + 2*strlenW(tagname) + 5);
+ if(!ret)
+ return E_OUTOFMEMORY;
+
+ sprintfW(ret, tagfmt, tagname, string->str, tagname);
+
+ V_VT(retv) = VT_BSTR;
+ V_BSTR(retv) = ret;
+ }
+ return S_OK;
+}
+
static HRESULT String_anchor(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
static HRESULT String_big(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
- FIXME("\n");
- return E_NOTIMPL;
+ static const WCHAR bigtagW[] = {'B','I','G',0};
+ return do_attributeless_tag_format(dispex, lcid, flags, dp, retv, ei, sp, bigtagW);
}
static HRESULT String_blink(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
- FIXME("\n");
- return E_NOTIMPL;
+ static const WCHAR blinktagW[] = {'B','L','I','N','K',0};
+ return do_attributeless_tag_format(dispex, lcid, flags, dp, retv, ei, sp, blinktagW);
}
static HRESULT String_bold(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
- FIXME("\n");
- return E_NOTIMPL;
+ static const WCHAR boldtagW[] = {'B',0};
+ return do_attributeless_tag_format(dispex, lcid, flags, dp, retv, ei, sp, boldtagW);
}
/* ECMA-262 3rd Edition 15.5.4.5 */
static HRESULT String_fixed(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
- FIXME("\n");
- return E_NOTIMPL;
+ static const WCHAR fixedtagW[] = {'T','T',0};
+ return do_attributeless_tag_format(dispex, lcid, flags, dp, retv, ei, sp, fixedtagW);
}
static HRESULT String_fontcolor(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
static HRESULT String_italics(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
- FIXME("\n");
- return E_NOTIMPL;
+ static const WCHAR italicstagW[] = {'I',0};
+ return do_attributeless_tag_format(dispex, lcid, flags, dp, retv, ei, sp, italicstagW);
}
static HRESULT String_lastIndexOf(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
static HRESULT String_small(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
- FIXME("\n");
- return E_NOTIMPL;
+ static const WCHAR smalltagW[] = {'S','M','A','L','L',0};
+ return do_attributeless_tag_format(dispex, lcid, flags, dp, retv, ei, sp, smalltagW);
}
static HRESULT String_split(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
+ match_result_t *match_result = NULL;
+ DWORD match_cnt, i, match_len = 0;
StringInstance *string;
- match_result_t *match_result;
- DWORD match_cnt, i, len;
- const WCHAR *ptr;
+ const WCHAR *ptr, *ptr2;
VARIANT *arg, var;
DispatchEx *array;
+ BSTR match_str = NULL;
HRESULT hres;
TRACE("\n");
}
}
default:
- FIXME("unsupported vt %d\n", V_VT(arg));
- return E_NOTIMPL;
+ hres = to_string(dispex->ctx, arg, ei, &match_str);
+ if(FAILED(hres))
+ return hres;
+
+ match_len = SysStringLen(match_str);
+ if(!match_len) {
+ SysFreeString(match_str);
+ match_str = NULL;
+ }
}
- hres = create_array(dispex->ctx, match_cnt+1, &array);
+ hres = create_array(dispex->ctx, 0, &array);
if(SUCCEEDED(hres)) {
ptr = string->str;
- for(i=0; i < match_cnt; i++) {
- len = match_result[i].str-ptr;
+ for(i=0;; i++) {
+ if(match_result) {
+ if(i == match_cnt)
+ break;
+ ptr2 = match_result[i].str;
+ }else if(match_str) {
+ ptr2 = strstrW(ptr, match_str);
+ if(!ptr2)
+ break;
+ }else {
+ if(!*ptr)
+ break;
+ ptr2 = ptr+1;
+ }
+
V_VT(&var) = VT_BSTR;
- V_BSTR(&var) = SysAllocStringLen(ptr, len);
+ V_BSTR(&var) = SysAllocStringLen(ptr, ptr2-ptr);
if(!V_BSTR(&var)) {
hres = E_OUTOFMEMORY;
break;
if(FAILED(hres))
break;
- ptr = match_result[i].str + match_result[i].len;
+ if(match_result)
+ ptr = match_result[i].str + match_result[i].len;
+ else if(match_str)
+ ptr = ptr2 + match_len;
+ else
+ ptr++;
}
}
- if(SUCCEEDED(hres)) {
- len = (string->str+string->length) - ptr;
+ if(SUCCEEDED(hres) && (match_str || match_result)) {
+ DWORD len = (string->str+string->length) - ptr;
- V_VT(&var) = VT_BSTR;
- V_BSTR(&var) = SysAllocStringLen(ptr, len);
+ if(len || match_str) {
+ V_VT(&var) = VT_BSTR;
+ V_BSTR(&var) = SysAllocStringLen(ptr, len);
- hres = jsdisp_propput_idx(array, i, lcid, &var, ei, sp);
- SysFreeString(V_BSTR(&var));
+ if(V_BSTR(&var)) {
+ hres = jsdisp_propput_idx(array, i, lcid, &var, ei, sp);
+ SysFreeString(V_BSTR(&var));
+ }else {
+ hres = E_OUTOFMEMORY;
+ }
+ }
}
+ SysFreeString(match_str);
heap_free(match_result);
if(SUCCEEDED(hres) && retv) {
static HRESULT String_strike(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
- FIXME("\n");
- return E_NOTIMPL;
+ static const WCHAR striketagW[] = {'S','T','R','I','K','E',0};
+ return do_attributeless_tag_format(dispex, lcid, flags, dp, retv, ei, sp, striketagW);
}
static HRESULT String_sub(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
- FIXME("\n");
- return E_NOTIMPL;
+ static const WCHAR subtagW[] = {'S','U','B',0};
+ return do_attributeless_tag_format(dispex, lcid, flags, dp, retv, ei, sp, subtagW);
}
/* ECMA-262 3rd Edition 15.5.4.15 */
static HRESULT String_sup(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
- FIXME("\n");
- return E_NOTIMPL;
+ static const WCHAR suptagW[] = {'S','U','P',0};
+ return do_attributeless_tag_format(dispex, lcid, flags, dp, retv, ei, sp, suptagW);
}
static HRESULT String_toLowerCase(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
- FIXME("\n");
- return E_NOTIMPL;
+ StringInstance *string;
+ const WCHAR* str;
+ DWORD length;
+ BSTR bstr;
+
+ TRACE("\n");
+
+ if(is_class(dispex, JSCLASS_STRING)) {
+ string = (StringInstance*)dispex;
+
+ length = string->length;
+ str = string->str;
+ }else {
+ FIXME("not string this not supported\n");
+ return E_NOTIMPL;
+ }
+
+ if(retv) {
+ bstr = SysAllocStringLen(str, length);
+ if (!bstr)
+ return E_OUTOFMEMORY;
+
+ strlwrW(bstr);
+
+ V_VT(retv) = VT_BSTR;
+ V_BSTR(retv) = bstr;
+ }
+ return S_OK;
}
static HRESULT String_toUpperCase(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
{
- FIXME("\n");
- return E_NOTIMPL;
+ StringInstance *string;
+ const WCHAR* str;
+ DWORD length;
+ BSTR bstr;
+
+ TRACE("\n");
+
+ if(is_class(dispex, JSCLASS_STRING)) {
+ string = (StringInstance*)dispex;
+
+ length = string->length;
+ str = string->str;
+ }else {
+ FIXME("not string this not supported\n");
+ return E_NOTIMPL;
+ }
+
+ if(retv) {
+ bstr = SysAllocStringLen(str, length);
+ if (!bstr)
+ return E_OUTOFMEMORY;
+
+ struprW(bstr);
+
+ V_VT(retv) = VT_BSTR;
+ V_BSTR(retv) = bstr;
+ }
+ return S_OK;
}
static HRESULT String_toLocaleLowerCase(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
{smallW, String_small, PROPF_METHOD},
{splitW, String_split, PROPF_METHOD},
{strikeW, String_strike, PROPF_METHOD},
- {substringW, String_substring, PROPF_METHOD},
- {substrW, String_substr, PROPF_METHOD},
{subW, String_sub, PROPF_METHOD},
+ {substrW, String_substr, PROPF_METHOD},
+ {substringW, String_substring, PROPF_METHOD},
{supW, String_sup, PROPF_METHOD},
{toLocaleLowerCaseW, String_toLocaleLowerCase, PROPF_METHOD},
{toLocaleUpperCaseW, String_toLocaleUpperCase, PROPF_METHOD},