2 * Copyright 2008 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/debug.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(jscript
);
34 jsval_t last_index_val
;
37 static inline RegExpInstance
*regexp_from_jsdisp(jsdisp_t
*jsdisp
)
39 return CONTAINING_RECORD(jsdisp
, RegExpInstance
, dispex
);
42 static inline RegExpInstance
*regexp_from_vdisp(vdisp_t
*vdisp
)
44 return regexp_from_jsdisp(vdisp
->u
.jsdisp
);
47 static void set_last_index(RegExpInstance
*This
, DWORD last_index
)
49 This
->last_index
= last_index
;
50 jsval_release(This
->last_index_val
);
51 This
->last_index_val
= jsval_number(last_index
);
54 static HRESULT
do_regexp_match_next(script_ctx_t
*ctx
, RegExpInstance
*regexp
,
55 DWORD rem_flags
, jsstr_t
*jsstr
, const WCHAR
*str
, match_state_t
*ret
)
59 hres
= regexp_execute(regexp
->jsregexp
, ctx
, &ctx
->tmp_heap
,
60 str
, jsstr_length(jsstr
), ret
);
64 if(rem_flags
& REM_RESET_INDEX
)
65 set_last_index(regexp
, 0);
69 if(!(rem_flags
& REM_NO_CTX_UPDATE
) && ctx
->last_match
!= jsstr
) {
70 jsstr_release(ctx
->last_match
);
71 ctx
->last_match
= jsstr_addref(jsstr
);
74 if(!(rem_flags
& REM_NO_CTX_UPDATE
)) {
75 DWORD i
, n
= min(ARRAY_SIZE(ctx
->match_parens
), ret
->paren_count
);
77 for(i
=0; i
< n
; i
++) {
78 if(ret
->parens
[i
].index
== -1) {
79 ctx
->match_parens
[i
].index
= 0;
80 ctx
->match_parens
[i
].length
= 0;
82 ctx
->match_parens
[i
].index
= ret
->parens
[i
].index
;
83 ctx
->match_parens
[i
].length
= ret
->parens
[i
].length
;
87 if(n
< ARRAY_SIZE(ctx
->match_parens
))
88 memset(ctx
->match_parens
+n
, 0, sizeof(ctx
->match_parens
) - n
*sizeof(ctx
->match_parens
[0]));
91 set_last_index(regexp
, ret
->cp
-str
);
93 if(!(rem_flags
& REM_NO_CTX_UPDATE
)) {
94 ctx
->last_match_index
= ret
->cp
-str
-ret
->match_len
;
95 ctx
->last_match_length
= ret
->match_len
;
101 HRESULT
regexp_match_next(script_ctx_t
*ctx
, jsdisp_t
*dispex
,
102 DWORD rem_flags
, jsstr_t
*jsstr
, match_state_t
**ret
)
104 RegExpInstance
*regexp
= regexp_from_jsdisp(dispex
);
105 match_state_t
*match
;
110 if((rem_flags
& REM_CHECK_GLOBAL
) && !(regexp
->jsregexp
->flags
& REG_GLOB
)) {
111 if(rem_flags
& REM_ALLOC_RESULT
)
116 str
= jsstr_flatten(jsstr
);
118 return E_OUTOFMEMORY
;
120 if(rem_flags
& REM_ALLOC_RESULT
) {
121 match
= alloc_match_state(regexp
->jsregexp
, NULL
, str
);
123 return E_OUTOFMEMORY
;
127 mark
= heap_pool_mark(&ctx
->tmp_heap
);
129 if(rem_flags
& REM_NO_PARENS
) {
130 match
= alloc_match_state(regexp
->jsregexp
, &ctx
->tmp_heap
, NULL
);
132 heap_pool_clear(mark
);
133 return E_OUTOFMEMORY
;
135 match
->cp
= (*ret
)->cp
;
136 match
->match_len
= (*ret
)->match_len
;
141 hres
= do_regexp_match_next(ctx
, regexp
, rem_flags
, jsstr
, str
, match
);
143 if(rem_flags
& REM_NO_PARENS
) {
144 (*ret
)->cp
= match
->cp
;
145 (*ret
)->match_len
= match
->match_len
;
148 heap_pool_clear(mark
);
150 if(hres
!= S_OK
&& (rem_flags
& REM_ALLOC_RESULT
)) {
158 static HRESULT
regexp_match(script_ctx_t
*ctx
, jsdisp_t
*dispex
, jsstr_t
*jsstr
, BOOL gflag
,
159 match_result_t
**match_result
, DWORD
*result_cnt
)
161 RegExpInstance
*This
= regexp_from_jsdisp(dispex
);
162 match_result_t
*ret
= NULL
;
163 match_state_t
*result
;
164 DWORD i
=0, ret_size
= 0;
169 mark
= heap_pool_mark(&ctx
->tmp_heap
);
171 str
= jsstr_flatten(jsstr
);
173 return E_OUTOFMEMORY
;
175 result
= alloc_match_state(This
->jsregexp
, &ctx
->tmp_heap
, str
);
177 heap_pool_clear(mark
);
178 return E_OUTOFMEMORY
;
182 hres
= do_regexp_match_next(ctx
, This
, 0, jsstr
, str
, result
);
183 if(hres
== S_FALSE
) {
193 match_result_t
*old_ret
= ret
;
195 ret
= heap_realloc(old_ret
, (ret_size
<<= 1) * sizeof(match_result_t
));
199 ret
= heap_alloc((ret_size
=4) * sizeof(match_result_t
));
202 hres
= E_OUTOFMEMORY
;
207 ret
[i
].index
= result
->cp
- str
- result
->match_len
;
208 ret
[i
++].length
= result
->match_len
;
210 if(!gflag
&& !(This
->jsregexp
->flags
& REG_GLOB
)) {
216 heap_pool_clear(mark
);
227 static HRESULT
RegExp_get_source(script_ctx_t
*ctx
, jsdisp_t
*jsthis
, jsval_t
*r
)
231 *r
= jsval_string(jsstr_addref(regexp_from_jsdisp(jsthis
)->str
));
235 static HRESULT
RegExp_get_global(script_ctx_t
*ctx
, jsdisp_t
*jsthis
, jsval_t
*r
)
239 *r
= jsval_bool(!!(regexp_from_jsdisp(jsthis
)->jsregexp
->flags
& REG_GLOB
));
243 static HRESULT
RegExp_get_ignoreCase(script_ctx_t
*ctx
, jsdisp_t
*jsthis
, jsval_t
*r
)
247 *r
= jsval_bool(!!(regexp_from_jsdisp(jsthis
)->jsregexp
->flags
& REG_FOLD
));
251 static HRESULT
RegExp_get_multiline(script_ctx_t
*ctx
, jsdisp_t
*jsthis
, jsval_t
*r
)
255 *r
= jsval_bool(!!(regexp_from_jsdisp(jsthis
)->jsregexp
->flags
& REG_MULTILINE
));
259 static INT
index_from_val(script_ctx_t
*ctx
, jsval_t v
)
264 hres
= to_number(ctx
, v
, &n
);
269 return is_int32(n
) ? n
: 0;
272 static HRESULT
RegExp_get_lastIndex(script_ctx_t
*ctx
, jsdisp_t
*jsthis
, jsval_t
*r
)
274 RegExpInstance
*regexp
= regexp_from_jsdisp(jsthis
);
278 return jsval_copy(regexp
->last_index_val
, r
);
281 static HRESULT
RegExp_set_lastIndex(script_ctx_t
*ctx
, jsdisp_t
*jsthis
, jsval_t value
)
283 RegExpInstance
*regexp
= regexp_from_jsdisp(jsthis
);
288 jsval_release(regexp
->last_index_val
);
289 hres
= jsval_copy(value
, ®exp
->last_index_val
);
293 regexp
->last_index
= index_from_val(ctx
, value
);
297 static HRESULT
RegExp_toString(script_ctx_t
*ctx
, vdisp_t
*jsthis
, WORD flags
, unsigned argc
, jsval_t
*argv
,
300 RegExpInstance
*regexp
;
307 if(!is_vclass(jsthis
, JSCLASS_REGEXP
)) {
308 WARN("Not a RegExp\n");
309 return JS_E_REGEXP_EXPECTED
;
312 regexp
= regexp_from_vdisp(jsthis
);
317 len
= jsstr_length(regexp
->str
) + 2;
319 f
= regexp
->jsregexp
->flags
;
324 if(f
& REG_MULTILINE
)
327 ret
= jsstr_alloc_buf(len
, &ptr
);
329 return E_OUTOFMEMORY
;
332 ptr
+= jsstr_flush(regexp
->str
, ptr
);
339 if(f
& REG_MULTILINE
)
342 *r
= jsval_string(ret
);
346 static HRESULT
create_match_array(script_ctx_t
*ctx
, jsstr_t
*input_str
,
347 const match_state_t
*result
, IDispatch
**ret
)
355 input
= jsstr_flatten(input_str
);
357 return E_OUTOFMEMORY
;
359 hres
= create_array(ctx
, result
->paren_count
+1, &array
);
363 for(i
=0; i
< result
->paren_count
; i
++) {
364 if(result
->parens
[i
].index
!= -1)
365 str
= jsstr_substr(input_str
, result
->parens
[i
].index
, result
->parens
[i
].length
);
369 hres
= E_OUTOFMEMORY
;
373 hres
= jsdisp_propput_idx(array
, i
+1, jsval_string(str
));
379 while(SUCCEEDED(hres
)) {
380 hres
= jsdisp_propput_name(array
, L
"index", jsval_number(result
->cp
-input
-result
->match_len
));
384 hres
= jsdisp_propput_name(array
, L
"lastIndex", jsval_number(result
->cp
-input
));
388 hres
= jsdisp_propput_name(array
, L
"input", jsval_string(jsstr_addref(input_str
)));
392 str
= jsstr_alloc_len(result
->cp
-result
->match_len
, result
->match_len
);
394 hres
= E_OUTOFMEMORY
;
397 hres
= jsdisp_propput_name(array
, L
"0", jsval_string(str
));
403 jsdisp_release(array
);
407 *ret
= to_disp(array
);
411 static HRESULT
run_exec(script_ctx_t
*ctx
, vdisp_t
*jsthis
, jsval_t arg
,
412 jsstr_t
**input
, match_state_t
**result
, BOOL
*ret
)
414 RegExpInstance
*regexp
;
415 match_state_t
*match
;
416 DWORD last_index
= 0;
421 if(!is_vclass(jsthis
, JSCLASS_REGEXP
)) {
422 FIXME("Not a RegExp\n");
426 regexp
= regexp_from_vdisp(jsthis
);
428 hres
= to_flat_string(ctx
, arg
, &jsstr
, &string
);
432 if(regexp
->jsregexp
->flags
& REG_GLOB
) {
433 if(regexp
->last_index
< 0) {
434 jsstr_release(jsstr
);
435 set_last_index(regexp
, 0);
438 *input
= jsstr_empty();
442 last_index
= regexp
->last_index
;
445 match
= alloc_match_state(regexp
->jsregexp
, &ctx
->tmp_heap
, string
+last_index
);
447 jsstr_release(jsstr
);
448 return E_OUTOFMEMORY
;
451 hres
= regexp_match_next(ctx
, ®exp
->dispex
, REM_RESET_INDEX
, jsstr
, &match
);
453 jsstr_release(jsstr
);
462 jsstr_release(jsstr
);
466 static HRESULT
RegExp_exec(script_ctx_t
*ctx
, vdisp_t
*jsthis
, WORD flags
, unsigned argc
, jsval_t
*argv
,
469 match_state_t
*match
;
477 mark
= heap_pool_mark(&ctx
->tmp_heap
);
479 hres
= run_exec(ctx
, jsthis
, argc
? argv
[0] : jsval_string(jsstr_empty()), &string
, &match
, &b
);
481 heap_pool_clear(mark
);
489 hres
= create_match_array(ctx
, string
, match
, &ret
);
491 *r
= jsval_disp(ret
);
497 heap_pool_clear(mark
);
498 jsstr_release(string
);
502 static HRESULT
RegExp_test(script_ctx_t
*ctx
, vdisp_t
*jsthis
, WORD flags
, unsigned argc
, jsval_t
*argv
,
505 match_state_t
*match
;
513 mark
= heap_pool_mark(&ctx
->tmp_heap
);
514 hres
= run_exec(ctx
, jsthis
, argc
? argv
[0] : jsval_string(undef_str
= jsstr_undefined()), NULL
, &match
, &b
);
515 heap_pool_clear(mark
);
517 jsstr_release(undef_str
);
526 static HRESULT
RegExp_value(script_ctx_t
*ctx
, vdisp_t
*jsthis
, WORD flags
, unsigned argc
, jsval_t
*argv
,
533 return JS_E_FUNCTION_EXPECTED
;
535 FIXME("unimplemented flags %x\n", flags
);
542 static void RegExp_destructor(jsdisp_t
*dispex
)
544 RegExpInstance
*This
= regexp_from_jsdisp(dispex
);
547 regexp_destroy(This
->jsregexp
);
548 jsval_release(This
->last_index_val
);
549 jsstr_release(This
->str
);
553 static const builtin_prop_t RegExp_props
[] = {
554 {L
"exec", RegExp_exec
, PROPF_METHOD
|1},
555 {L
"global", NULL
,0, RegExp_get_global
},
556 {L
"ignoreCase", NULL
,0, RegExp_get_ignoreCase
},
557 {L
"lastIndex", NULL
,0, RegExp_get_lastIndex
, RegExp_set_lastIndex
},
558 {L
"multiline", NULL
,0, RegExp_get_multiline
},
559 {L
"source", NULL
,0, RegExp_get_source
},
560 {L
"test", RegExp_test
, PROPF_METHOD
|1},
561 {L
"toString", RegExp_toString
, PROPF_METHOD
}
564 static const builtin_info_t RegExp_info
= {
566 {NULL
, RegExp_value
, 0},
567 ARRAY_SIZE(RegExp_props
),
573 static const builtin_prop_t RegExpInst_props
[] = {
574 {L
"global", NULL
,0, RegExp_get_global
},
575 {L
"ignoreCase", NULL
,0, RegExp_get_ignoreCase
},
576 {L
"lastIndex", NULL
,0, RegExp_get_lastIndex
, RegExp_set_lastIndex
},
577 {L
"multiline", NULL
,0, RegExp_get_multiline
},
578 {L
"source", NULL
,0, RegExp_get_source
}
581 static const builtin_info_t RegExpInst_info
= {
583 {NULL
, RegExp_value
, 0},
584 ARRAY_SIZE(RegExpInst_props
),
590 static HRESULT
alloc_regexp(script_ctx_t
*ctx
, jsdisp_t
*object_prototype
, RegExpInstance
**ret
)
592 RegExpInstance
*regexp
;
595 regexp
= heap_alloc_zero(sizeof(RegExpInstance
));
597 return E_OUTOFMEMORY
;
600 hres
= init_dispex(®exp
->dispex
, ctx
, &RegExp_info
, object_prototype
);
602 hres
= init_dispex_from_constr(®exp
->dispex
, ctx
, &RegExpInst_info
, ctx
->regexp_constr
);
613 HRESULT
create_regexp(script_ctx_t
*ctx
, jsstr_t
*src
, DWORD flags
, jsdisp_t
**ret
)
615 RegExpInstance
*regexp
;
619 str
= jsstr_flatten(src
);
621 return E_OUTOFMEMORY
;
623 TRACE("%s %x\n", debugstr_wn(str
, jsstr_length(src
)), flags
);
625 hres
= alloc_regexp(ctx
, NULL
, ®exp
);
629 regexp
->str
= jsstr_addref(src
);
630 regexp
->last_index_val
= jsval_number(0);
632 regexp
->jsregexp
= regexp_new(ctx
, &ctx
->tmp_heap
, str
, jsstr_length(regexp
->str
), flags
, FALSE
);
633 if(!regexp
->jsregexp
) {
634 WARN("regexp_new failed\n");
635 jsdisp_release(®exp
->dispex
);
639 *ret
= ®exp
->dispex
;
643 HRESULT
create_regexp_var(script_ctx_t
*ctx
, jsval_t src_arg
, jsval_t
*flags_arg
, jsdisp_t
**ret
)
646 const WCHAR
*opt
= NULL
;
650 if(is_object_instance(src_arg
)) {
653 obj
= iface_to_jsdisp(get_object(src_arg
));
655 if(is_class(obj
, JSCLASS_REGEXP
)) {
656 RegExpInstance
*regexp
= regexp_from_jsdisp(obj
);
658 hres
= create_regexp(ctx
, regexp
->str
, regexp
->jsregexp
->flags
, ret
);
667 if(is_undefined(src_arg
))
670 hres
= to_string(ctx
, src_arg
, &src
);
674 if(flags_arg
&& !is_undefined(*flags_arg
)) {
677 hres
= to_string(ctx
, *flags_arg
, &opt_str
);
678 if(SUCCEEDED(hres
)) {
679 opt
= jsstr_flatten(opt_str
);
681 hres
= parse_regexp_flags(opt
, jsstr_length(opt_str
), &flags
);
683 hres
= E_OUTOFMEMORY
;
684 jsstr_release(opt_str
);
689 hres
= create_regexp(ctx
, src
, flags
, ret
);
694 HRESULT
regexp_string_match(script_ctx_t
*ctx
, jsdisp_t
*re
, jsstr_t
*jsstr
, jsval_t
*r
)
696 RegExpInstance
*regexp
= regexp_from_jsdisp(re
);
697 match_result_t
*match_result
;
698 unsigned match_cnt
, i
;
703 str
= jsstr_flatten(jsstr
);
705 return E_OUTOFMEMORY
;
707 if(!(regexp
->jsregexp
->flags
& REG_GLOB
)) {
708 match_state_t
*match
;
711 mark
= heap_pool_mark(&ctx
->tmp_heap
);
712 match
= alloc_match_state(regexp
->jsregexp
, &ctx
->tmp_heap
, str
);
714 heap_pool_clear(mark
);
715 return E_OUTOFMEMORY
;
718 hres
= regexp_match_next(ctx
, ®exp
->dispex
, 0, jsstr
, &match
);
720 heap_pool_clear(mark
);
728 hres
= create_match_array(ctx
, jsstr
, match
, &ret
);
730 *r
= jsval_disp(ret
);
736 heap_pool_clear(mark
);
740 hres
= regexp_match(ctx
, ®exp
->dispex
, jsstr
, FALSE
, &match_result
, &match_cnt
);
752 hres
= create_array(ctx
, match_cnt
, &array
);
756 for(i
=0; i
< match_cnt
; i
++) {
759 tmp_str
= jsstr_substr(jsstr
, match_result
[i
].index
, match_result
[i
].length
);
761 hres
= E_OUTOFMEMORY
;
765 hres
= jsdisp_propput_idx(array
, i
, jsval_string(tmp_str
));
766 jsstr_release(tmp_str
);
771 while(SUCCEEDED(hres
)) {
772 hres
= jsdisp_propput_name(array
, L
"index", jsval_number(match_result
[match_cnt
-1].index
));
776 hres
= jsdisp_propput_name(array
, L
"lastIndex",
777 jsval_number(match_result
[match_cnt
-1].index
+ match_result
[match_cnt
-1].length
));
781 hres
= jsdisp_propput_name(array
, L
"input", jsval_string(jsstr
));
785 heap_free(match_result
);
787 if(SUCCEEDED(hres
) && r
)
788 *r
= jsval_obj(array
);
790 jsdisp_release(array
);
794 static HRESULT
global_idx(script_ctx_t
*ctx
, DWORD idx
, jsval_t
*r
)
798 ret
= jsstr_substr(ctx
->last_match
, ctx
->match_parens
[idx
].index
, ctx
->match_parens
[idx
].length
);
800 return E_OUTOFMEMORY
;
802 *r
= jsval_string(ret
);
806 static HRESULT
RegExpConstr_get_idx1(script_ctx_t
*ctx
, jsdisp_t
*jsthis
, jsval_t
*r
)
809 return global_idx(ctx
, 0, r
);
812 static HRESULT
RegExpConstr_get_idx2(script_ctx_t
*ctx
, jsdisp_t
*jsthis
, jsval_t
*r
)
815 return global_idx(ctx
, 1, r
);
818 static HRESULT
RegExpConstr_get_idx3(script_ctx_t
*ctx
, jsdisp_t
*jsthis
, jsval_t
*r
)
821 return global_idx(ctx
, 2, r
);
824 static HRESULT
RegExpConstr_get_idx4(script_ctx_t
*ctx
, jsdisp_t
*jsthis
, jsval_t
*r
)
827 return global_idx(ctx
, 3, r
);
830 static HRESULT
RegExpConstr_get_idx5(script_ctx_t
*ctx
, jsdisp_t
*jsthis
, jsval_t
*r
)
833 return global_idx(ctx
, 4, r
);
836 static HRESULT
RegExpConstr_get_idx6(script_ctx_t
*ctx
, jsdisp_t
*jsthis
, jsval_t
*r
)
839 return global_idx(ctx
, 5, r
);
842 static HRESULT
RegExpConstr_get_idx7(script_ctx_t
*ctx
, jsdisp_t
*jsthis
, jsval_t
*r
)
845 return global_idx(ctx
, 6, r
);
848 static HRESULT
RegExpConstr_get_idx8(script_ctx_t
*ctx
, jsdisp_t
*jsthis
, jsval_t
*r
)
851 return global_idx(ctx
, 7, r
);
854 static HRESULT
RegExpConstr_get_idx9(script_ctx_t
*ctx
, jsdisp_t
*jsthis
, jsval_t
*r
)
857 return global_idx(ctx
, 8, r
);
860 static HRESULT
RegExpConstr_get_leftContext(script_ctx_t
*ctx
, jsdisp_t
*jsthis
, jsval_t
*r
)
866 ret
= jsstr_substr(ctx
->last_match
, 0, ctx
->last_match_index
);
868 return E_OUTOFMEMORY
;
870 *r
= jsval_string(ret
);
874 static HRESULT
RegExpConstr_get_rightContext(script_ctx_t
*ctx
, jsdisp_t
*jsthis
, jsval_t
*r
)
880 ret
= jsstr_substr(ctx
->last_match
, ctx
->last_match_index
+ctx
->last_match_length
,
881 jsstr_length(ctx
->last_match
) - ctx
->last_match_index
- ctx
->last_match_length
);
883 return E_OUTOFMEMORY
;
885 *r
= jsval_string(ret
);
889 static HRESULT
RegExpConstr_value(script_ctx_t
*ctx
, vdisp_t
*jsthis
, WORD flags
, unsigned argc
, jsval_t
*argv
,
895 case DISPATCH_METHOD
:
897 if(is_object_instance(argv
[0])) {
898 jsdisp_t
*jsdisp
= iface_to_jsdisp(get_object(argv
[0]));
900 if(is_class(jsdisp
, JSCLASS_REGEXP
)) {
901 if(argc
> 1 && !is_undefined(argv
[1])) {
902 jsdisp_release(jsdisp
);
903 return JS_E_REGEXP_SYNTAX
;
907 *r
= jsval_obj(jsdisp
);
909 jsdisp_release(jsdisp
);
912 jsdisp_release(jsdisp
);
917 case DISPATCH_CONSTRUCT
: {
921 hres
= create_regexp_var(ctx
, argc
? argv
[0] : jsval_undefined(), argc
> 1 ? argv
+1 : NULL
, &ret
);
932 FIXME("unimplemented flags: %x\n", flags
);
939 static const builtin_prop_t RegExpConstr_props
[] = {
940 {L
"$1", NULL
,0, RegExpConstr_get_idx1
, builtin_set_const
},
941 {L
"$2", NULL
,0, RegExpConstr_get_idx2
, builtin_set_const
},
942 {L
"$3", NULL
,0, RegExpConstr_get_idx3
, builtin_set_const
},
943 {L
"$4", NULL
,0, RegExpConstr_get_idx4
, builtin_set_const
},
944 {L
"$5", NULL
,0, RegExpConstr_get_idx5
, builtin_set_const
},
945 {L
"$6", NULL
,0, RegExpConstr_get_idx6
, builtin_set_const
},
946 {L
"$7", NULL
,0, RegExpConstr_get_idx7
, builtin_set_const
},
947 {L
"$8", NULL
,0, RegExpConstr_get_idx8
, builtin_set_const
},
948 {L
"$9", NULL
,0, RegExpConstr_get_idx9
, builtin_set_const
},
949 {L
"leftContext", NULL
,0, RegExpConstr_get_leftContext
, builtin_set_const
},
950 {L
"rightContext", NULL
,0, RegExpConstr_get_rightContext
, builtin_set_const
}
953 static const builtin_info_t RegExpConstr_info
= {
955 DEFAULT_FUNCTION_VALUE
,
956 ARRAY_SIZE(RegExpConstr_props
),
962 HRESULT
create_regexp_constr(script_ctx_t
*ctx
, jsdisp_t
*object_prototype
, jsdisp_t
**ret
)
964 RegExpInstance
*regexp
;
967 hres
= alloc_regexp(ctx
, object_prototype
, ®exp
);
971 hres
= create_builtin_constructor(ctx
, RegExpConstr_value
, L
"RegExp", &RegExpConstr_info
,
972 PROPF_CONSTR
|2, ®exp
->dispex
, ret
);
974 jsdisp_release(®exp
->dispex
);
978 HRESULT
parse_regexp_flags(const WCHAR
*str
, DWORD str_len
, DWORD
*ret
)
983 for (p
= str
; p
< str
+str_len
; p
++) {
992 flags
|= REG_MULTILINE
;
998 WARN("wrong flag %c\n", *p
);