jscript: Store regexp last_index value as jsval.
This commit is contained in:
parent
228aab23be
commit
a3f7f0f7de
|
@ -84,7 +84,7 @@ typedef struct {
|
||||||
JSRegExp *jsregexp;
|
JSRegExp *jsregexp;
|
||||||
BSTR str;
|
BSTR str;
|
||||||
INT last_index;
|
INT last_index;
|
||||||
VARIANT last_index_var;
|
jsval_t last_index_val;
|
||||||
} RegExpInstance;
|
} RegExpInstance;
|
||||||
|
|
||||||
static const WCHAR sourceW[] = {'s','o','u','r','c','e',0};
|
static const WCHAR sourceW[] = {'s','o','u','r','c','e',0};
|
||||||
|
@ -3308,8 +3308,8 @@ static inline RegExpInstance *regexp_from_vdisp(vdisp_t *vdisp)
|
||||||
static void set_last_index(RegExpInstance *This, DWORD last_index)
|
static void set_last_index(RegExpInstance *This, DWORD last_index)
|
||||||
{
|
{
|
||||||
This->last_index = last_index;
|
This->last_index = last_index;
|
||||||
VariantClear(&This->last_index_var);
|
jsval_release(This->last_index_val);
|
||||||
num_set_val(&This->last_index_var, last_index);
|
This->last_index_val = jsval_number(last_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT do_regexp_match_next(script_ctx_t *ctx, RegExpInstance *regexp, DWORD rem_flags,
|
static HRESULT do_regexp_match_next(script_ctx_t *ctx, RegExpInstance *regexp, DWORD rem_flags,
|
||||||
|
@ -3542,13 +3542,13 @@ static HRESULT RegExp_lastIndex(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
|
||||||
case DISPATCH_PROPERTYGET: {
|
case DISPATCH_PROPERTYGET: {
|
||||||
RegExpInstance *regexp = regexp_from_vdisp(jsthis);
|
RegExpInstance *regexp = regexp_from_vdisp(jsthis);
|
||||||
|
|
||||||
return variant_to_jsval(®exp->last_index_var, r);
|
return jsval_copy(regexp->last_index_val, r);
|
||||||
}
|
}
|
||||||
case DISPATCH_PROPERTYPUT: {
|
case DISPATCH_PROPERTYPUT: {
|
||||||
RegExpInstance *regexp = regexp_from_vdisp(jsthis);
|
RegExpInstance *regexp = regexp_from_vdisp(jsthis);
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
||||||
hres = jsval_to_variant(argv[0], ®exp->last_index_var);
|
hres = jsval_copy(argv[0], ®exp->last_index_val);
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
return hres;
|
return hres;
|
||||||
|
|
||||||
|
@ -3765,7 +3765,7 @@ static void RegExp_destructor(jsdisp_t *dispex)
|
||||||
|
|
||||||
if(This->jsregexp)
|
if(This->jsregexp)
|
||||||
js_DestroyRegExp(This->jsregexp);
|
js_DestroyRegExp(This->jsregexp);
|
||||||
VariantClear(&This->last_index_var);
|
jsval_release(This->last_index_val);
|
||||||
SysFreeString(This->str);
|
SysFreeString(This->str);
|
||||||
heap_free(This);
|
heap_free(This);
|
||||||
}
|
}
|
||||||
|
@ -3857,7 +3857,7 @@ HRESULT create_regexp(script_ctx_t *ctx, const WCHAR *exp, int len, DWORD flags,
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
num_set_int(®exp->last_index_var, 0);
|
regexp->last_index_val = jsval_number(0);
|
||||||
|
|
||||||
*ret = ®exp->dispex;
|
*ret = ®exp->dispex;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
|
Loading…
Reference in New Issue