2 * Copyright 2013 Piotr 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
22 #include <vbsregexp55.h>
24 #define REGEXP_TID_LIST \
27 XDIID(MatchCollection2), \
31 #define XDIID(iface) iface ## _tid
37 static REFIID tid_ids
[] = {
38 #define XDIID(iface) &IID_I ## iface
43 static ITypeLib
*typelib
;
44 static ITypeInfo
*typeinfos
[REGEXP_LAST_tid
];
46 static HRESULT
init_regexp_typeinfo(regexp_tid_t tid
)
51 static const WCHAR vbscript_dll3W
[] = {'v','b','s','c','r','i','p','t','.','d','l','l','\\','3',0};
54 hres
= LoadTypeLib(vbscript_dll3W
, &tl
);
56 ERR("LoadRegTypeLib failed: %08x\n", hres
);
60 if(InterlockedCompareExchangePointer((void**)&typelib
, tl
, NULL
))
67 hres
= ITypeLib_GetTypeInfoOfGuid(typelib
, tid_ids
[tid
], &ti
);
69 ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_ids
[tid
]), hres
);
73 if(InterlockedCompareExchangePointer((void**)(typeinfos
+tid
), ti
, NULL
))
74 ITypeInfo_Release(ti
);
81 ISubMatches ISubMatches_iface
;
86 match_state_t
*result
;
89 typedef struct Match2
{
90 IMatch2 IMatch2_iface
;
96 SubMatches
*sub_matches
;
99 typedef struct MatchCollectionEnum
{
100 IEnumVARIANT IEnumVARIANT_iface
;
104 IMatchCollection2
*mc
;
107 } MatchCollectionEnum
;
109 typedef struct MatchCollection2
{
110 IMatchCollection2 IMatchCollection2_iface
;
111 IMatchCollection IMatchCollection_iface
;
120 typedef struct RegExp2
{
121 IRegExp2 IRegExp2_iface
;
122 IRegExp IRegExp_iface
;
132 static inline SubMatches
* impl_from_ISubMatches(ISubMatches
*iface
)
134 return CONTAINING_RECORD(iface
, SubMatches
, ISubMatches_iface
);
137 static HRESULT WINAPI
SubMatches_QueryInterface(
138 ISubMatches
*iface
, REFIID riid
, void **ppv
)
140 SubMatches
*This
= impl_from_ISubMatches(iface
);
142 if(IsEqualGUID(riid
, &IID_IUnknown
)) {
143 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
144 *ppv
= &This
->ISubMatches_iface
;
145 }else if(IsEqualGUID(riid
, &IID_IDispatch
)) {
146 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
147 *ppv
= &This
->ISubMatches_iface
;
148 }else if(IsEqualGUID(riid
, &IID_ISubMatches
)) {
149 TRACE("(%p)->(IID_ISubMatches %p)\n", This
, ppv
);
150 *ppv
= &This
->ISubMatches_iface
;
151 }else if(IsEqualGUID(riid
, &IID_IDispatchEx
)) {
152 TRACE("(%p)->(IID_IDispatchEx %p)\n", This
, ppv
);
154 return E_NOINTERFACE
;
156 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
158 return E_NOINTERFACE
;
161 IUnknown_AddRef((IUnknown
*)*ppv
);
165 static ULONG WINAPI
SubMatches_AddRef(ISubMatches
*iface
)
167 SubMatches
*This
= impl_from_ISubMatches(iface
);
168 LONG ref
= InterlockedIncrement(&This
->ref
);
170 TRACE("(%p) ref=%d\n", This
, ref
);
175 static ULONG WINAPI
SubMatches_Release(ISubMatches
*iface
)
177 SubMatches
*This
= impl_from_ISubMatches(iface
);
178 LONG ref
= InterlockedDecrement(&This
->ref
);
180 TRACE("(%p) ref=%d\n", This
, ref
);
183 heap_free(This
->match
);
184 heap_free(This
->result
);
191 static HRESULT WINAPI
SubMatches_GetTypeInfoCount(ISubMatches
*iface
, UINT
*pctinfo
)
193 SubMatches
*This
= impl_from_ISubMatches(iface
);
195 TRACE("(%p)->(%p)\n", This
, pctinfo
);
201 static HRESULT WINAPI
SubMatches_GetTypeInfo(ISubMatches
*iface
,
202 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
204 SubMatches
*This
= impl_from_ISubMatches(iface
);
205 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
209 static HRESULT WINAPI
SubMatches_GetIDsOfNames(ISubMatches
*iface
,
210 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
212 SubMatches
*This
= impl_from_ISubMatches(iface
);
214 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
),
215 rgszNames
, cNames
, lcid
, rgDispId
);
217 return ITypeInfo_GetIDsOfNames(typeinfos
[SubMatches_tid
], rgszNames
, cNames
, rgDispId
);
220 static HRESULT WINAPI
SubMatches_Invoke(ISubMatches
*iface
, DISPID dispIdMember
,
221 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
222 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
224 SubMatches
*This
= impl_from_ISubMatches(iface
);
226 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
227 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
229 return ITypeInfo_Invoke(typeinfos
[SubMatches_tid
], iface
, dispIdMember
, wFlags
,
230 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
233 static HRESULT WINAPI
SubMatches_get_Item(ISubMatches
*iface
,
234 LONG index
, VARIANT
*pSubMatch
)
236 SubMatches
*This
= impl_from_ISubMatches(iface
);
238 TRACE("(%p)->(%d %p)\n", This
, index
, pSubMatch
);
243 if(!This
->result
|| index
<0 || index
>=This
->result
->paren_count
)
246 if(This
->result
->parens
[index
].index
== -1) {
247 V_VT(pSubMatch
) = VT_EMPTY
;
249 V_VT(pSubMatch
) = VT_BSTR
;
250 V_BSTR(pSubMatch
) = SysAllocStringLen(
251 This
->match
+This
->result
->parens
[index
].index
,
252 This
->result
->parens
[index
].length
);
254 if(!V_BSTR(pSubMatch
))
255 return E_OUTOFMEMORY
;
261 static HRESULT WINAPI
SubMatches_get_Count(ISubMatches
*iface
, LONG
*pCount
)
263 SubMatches
*This
= impl_from_ISubMatches(iface
);
265 TRACE("(%p)->(%p)\n", This
, pCount
);
273 *pCount
= This
->result
->paren_count
;
277 static HRESULT WINAPI
SubMatches_get__NewEnum(ISubMatches
*iface
, IUnknown
**ppEnum
)
279 SubMatches
*This
= impl_from_ISubMatches(iface
);
280 FIXME("(%p)->(%p)\n", This
, ppEnum
);
284 static const ISubMatchesVtbl SubMatchesVtbl
= {
285 SubMatches_QueryInterface
,
288 SubMatches_GetTypeInfoCount
,
289 SubMatches_GetTypeInfo
,
290 SubMatches_GetIDsOfNames
,
293 SubMatches_get_Count
,
294 SubMatches_get__NewEnum
297 static HRESULT
create_sub_matches(DWORD pos
, match_state_t
*result
, SubMatches
**sub_matches
)
303 hres
= init_regexp_typeinfo(SubMatches_tid
);
307 ret
= heap_alloc_zero(sizeof(*ret
));
309 return E_OUTOFMEMORY
;
311 ret
->ISubMatches_iface
.lpVtbl
= &SubMatchesVtbl
;
313 ret
->result
= result
;
315 ret
->match
= heap_alloc((result
->match_len
+1) * sizeof(WCHAR
));
318 return E_OUTOFMEMORY
;
320 memcpy(ret
->match
, result
->cp
-result
->match_len
, result
->match_len
*sizeof(WCHAR
));
321 ret
->match
[result
->match_len
] = 0;
324 for(i
=0; i
<result
->paren_count
; i
++)
325 if(result
->parens
[i
].index
!= -1)
326 result
->parens
[i
].index
-= pos
;
336 static inline Match2
* impl_from_IMatch2(IMatch2
*iface
)
338 return CONTAINING_RECORD(iface
, Match2
, IMatch2_iface
);
341 static HRESULT WINAPI
Match2_QueryInterface(
342 IMatch2
*iface
, REFIID riid
, void **ppv
)
344 Match2
*This
= impl_from_IMatch2(iface
);
346 if(IsEqualGUID(riid
, &IID_IUnknown
)) {
347 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
348 *ppv
= &This
->IMatch2_iface
;
349 }else if(IsEqualGUID(riid
, &IID_IDispatch
)) {
350 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
351 *ppv
= &This
->IMatch2_iface
;
352 }else if(IsEqualGUID(riid
, &IID_IMatch2
)) {
353 TRACE("(%p)->(IID_IMatch2 %p)\n", This
, ppv
);
354 *ppv
= &This
->IMatch2_iface
;
355 }else if(IsEqualGUID(riid
, &IID_IMatch
)) {
356 TRACE("(%p)->(IID_IMatch %p)\n", This
, ppv
);
357 *ppv
= &This
->IMatch_iface
;
358 }else if(IsEqualGUID(riid
, &IID_IDispatchEx
)) {
359 TRACE("(%p)->(IID_IDispatchEx %p)\n", This
, ppv
);
361 return E_NOINTERFACE
;
363 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
365 return E_NOINTERFACE
;
368 IUnknown_AddRef((IUnknown
*)*ppv
);
372 static ULONG WINAPI
Match2_AddRef(IMatch2
*iface
)
374 Match2
*This
= impl_from_IMatch2(iface
);
375 LONG ref
= InterlockedIncrement(&This
->ref
);
377 TRACE("(%p) ref=%d\n", This
, ref
);
382 static ULONG WINAPI
Match2_Release(IMatch2
*iface
)
384 Match2
*This
= impl_from_IMatch2(iface
);
385 LONG ref
= InterlockedDecrement(&This
->ref
);
387 TRACE("(%p) ref=%d\n", This
, ref
);
390 ISubMatches_Release(&This
->sub_matches
->ISubMatches_iface
);
397 static HRESULT WINAPI
Match2_GetTypeInfoCount(IMatch2
*iface
, UINT
*pctinfo
)
399 Match2
*This
= impl_from_IMatch2(iface
);
401 TRACE("(%p)->(%p)\n", This
, pctinfo
);
407 static HRESULT WINAPI
Match2_GetTypeInfo(IMatch2
*iface
,
408 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
410 Match2
*This
= impl_from_IMatch2(iface
);
411 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
415 static HRESULT WINAPI
Match2_GetIDsOfNames(IMatch2
*iface
,
416 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
418 Match2
*This
= impl_from_IMatch2(iface
);
420 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
),
421 rgszNames
, cNames
, lcid
, rgDispId
);
423 return ITypeInfo_GetIDsOfNames(typeinfos
[Match2_tid
], rgszNames
, cNames
, rgDispId
);
426 static HRESULT WINAPI
Match2_Invoke(IMatch2
*iface
, DISPID dispIdMember
,
427 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
428 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
430 Match2
*This
= impl_from_IMatch2(iface
);
432 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
433 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
435 return ITypeInfo_Invoke(typeinfos
[Match2_tid
], iface
, dispIdMember
, wFlags
,
436 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
439 static HRESULT WINAPI
Match2_get_Value(IMatch2
*iface
, BSTR
*pValue
)
441 Match2
*This
= impl_from_IMatch2(iface
);
443 TRACE("(%p)->(%p)\n", This
, pValue
);
448 if(!This
->sub_matches
->match
) {
453 *pValue
= SysAllocString(This
->sub_matches
->match
);
454 return *pValue
? S_OK
: E_OUTOFMEMORY
;
457 static HRESULT WINAPI
Match2_get_FirstIndex(IMatch2
*iface
, LONG
*pFirstIndex
)
459 Match2
*This
= impl_from_IMatch2(iface
);
461 TRACE("(%p)->(%p)\n", This
, pFirstIndex
);
466 *pFirstIndex
= This
->index
;
470 static HRESULT WINAPI
Match2_get_Length(IMatch2
*iface
, LONG
*pLength
)
472 Match2
*This
= impl_from_IMatch2(iface
);
474 TRACE("(%p)->(%p)\n", This
, pLength
);
479 if(This
->sub_matches
->result
)
480 *pLength
= This
->sub_matches
->result
->match_len
;
486 static HRESULT WINAPI
Match2_get_SubMatches(IMatch2
*iface
, IDispatch
**ppSubMatches
)
488 Match2
*This
= impl_from_IMatch2(iface
);
490 TRACE("(%p)->(%p)\n", This
, ppSubMatches
);
495 *ppSubMatches
= (IDispatch
*)&This
->sub_matches
->ISubMatches_iface
;
496 ISubMatches_AddRef(&This
->sub_matches
->ISubMatches_iface
);
500 static const IMatch2Vtbl Match2Vtbl
= {
501 Match2_QueryInterface
,
504 Match2_GetTypeInfoCount
,
506 Match2_GetIDsOfNames
,
509 Match2_get_FirstIndex
,
511 Match2_get_SubMatches
514 static inline Match2
*impl_from_IMatch(IMatch
*iface
)
516 return CONTAINING_RECORD(iface
, Match2
, IMatch_iface
);
519 static HRESULT WINAPI
Match_QueryInterface(IMatch
*iface
, REFIID riid
, void **ppv
)
521 Match2
*This
= impl_from_IMatch(iface
);
522 return IMatch2_QueryInterface(&This
->IMatch2_iface
, riid
, ppv
);
525 static ULONG WINAPI
Match_AddRef(IMatch
*iface
)
527 Match2
*This
= impl_from_IMatch(iface
);
528 return IMatch2_AddRef(&This
->IMatch2_iface
);
531 static ULONG WINAPI
Match_Release(IMatch
*iface
)
533 Match2
*This
= impl_from_IMatch(iface
);
534 return IMatch2_Release(&This
->IMatch2_iface
);
537 static HRESULT WINAPI
Match_GetTypeInfoCount(IMatch
*iface
, UINT
*pctinfo
)
539 Match2
*This
= impl_from_IMatch(iface
);
540 return IMatch2_GetTypeInfoCount(&This
->IMatch2_iface
, pctinfo
);
543 static HRESULT WINAPI
Match_GetTypeInfo(IMatch
*iface
, UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
545 Match2
*This
= impl_from_IMatch(iface
);
546 return IMatch2_GetTypeInfo(&This
->IMatch2_iface
, iTInfo
, lcid
, ppTInfo
);
549 static HRESULT WINAPI
Match_GetIDsOfNames(IMatch
*iface
, REFIID riid
,
550 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
552 Match2
*This
= impl_from_IMatch(iface
);
553 return IMatch2_GetIDsOfNames(&This
->IMatch2_iface
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
556 static HRESULT WINAPI
Match_Invoke(IMatch
*iface
, DISPID dispIdMember
,
557 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
558 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
560 Match2
*This
= impl_from_IMatch(iface
);
561 return IMatch2_Invoke(&This
->IMatch2_iface
, dispIdMember
, riid
, lcid
,
562 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
565 static HRESULT WINAPI
Match_get_Value(IMatch
*iface
, BSTR
*pValue
)
567 Match2
*This
= impl_from_IMatch(iface
);
568 return IMatch2_get_Value(&This
->IMatch2_iface
, pValue
);
571 static HRESULT WINAPI
Match_get_FirstIndex(IMatch
*iface
, LONG
*pFirstIndex
)
573 Match2
*This
= impl_from_IMatch(iface
);
574 return IMatch2_get_FirstIndex(&This
->IMatch2_iface
, pFirstIndex
);
577 static HRESULT WINAPI
Match_get_Length(IMatch
*iface
, LONG
*pLength
)
579 Match2
*This
= impl_from_IMatch(iface
);
580 return IMatch2_get_Length(&This
->IMatch2_iface
, pLength
);
583 static IMatchVtbl MatchVtbl
= {
584 Match_QueryInterface
,
587 Match_GetTypeInfoCount
,
592 Match_get_FirstIndex
,
596 static HRESULT
create_match2(DWORD pos
, match_state_t
**result
, IMatch2
**match
)
601 hres
= init_regexp_typeinfo(Match2_tid
);
605 ret
= heap_alloc_zero(sizeof(*ret
));
607 return E_OUTOFMEMORY
;
610 hres
= create_sub_matches(pos
, result
? *result
: NULL
, &ret
->sub_matches
);
618 ret
->IMatch2_iface
.lpVtbl
= &Match2Vtbl
;
619 ret
->IMatch_iface
.lpVtbl
= &MatchVtbl
;
622 *match
= &ret
->IMatch2_iface
;
626 static inline MatchCollectionEnum
* impl_from_IMatchCollectionEnum(IEnumVARIANT
*iface
)
628 return CONTAINING_RECORD(iface
, MatchCollectionEnum
, IEnumVARIANT_iface
);
631 static HRESULT WINAPI
MatchCollectionEnum_QueryInterface(
632 IEnumVARIANT
*iface
, REFIID riid
, void **ppv
)
634 MatchCollectionEnum
*This
= impl_from_IMatchCollectionEnum(iface
);
636 if(IsEqualGUID(riid
, &IID_IUnknown
)) {
637 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
638 *ppv
= &This
->IEnumVARIANT_iface
;
639 }else if(IsEqualGUID(riid
, &IID_IEnumVARIANT
)) {
640 TRACE("(%p)->(IID_IEnumVARIANT %p)\n", This
, ppv
);
641 *ppv
= &This
->IEnumVARIANT_iface
;
643 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
645 return E_NOINTERFACE
;
648 IUnknown_AddRef((IUnknown
*)*ppv
);
652 static ULONG WINAPI
MatchCollectionEnum_AddRef(IEnumVARIANT
*iface
)
654 MatchCollectionEnum
*This
= impl_from_IMatchCollectionEnum(iface
);
655 LONG ref
= InterlockedIncrement(&This
->ref
);
657 TRACE("(%p) ref=%d\n", This
, ref
);
662 static ULONG WINAPI
MatchCollectionEnum_Release(IEnumVARIANT
*iface
)
664 MatchCollectionEnum
*This
= impl_from_IMatchCollectionEnum(iface
);
665 LONG ref
= InterlockedDecrement(&This
->ref
);
667 TRACE("(%p) ref=%d\n", This
, ref
);
670 IMatchCollection2_Release(This
->mc
);
677 static HRESULT WINAPI
MatchCollectionEnum_Next(IEnumVARIANT
*iface
,
678 ULONG celt
, VARIANT
*rgVar
, ULONG
*pCeltFetched
)
680 MatchCollectionEnum
*This
= impl_from_IMatchCollectionEnum(iface
);
684 TRACE("(%p)->(%u %p %p)\n", This
, celt
, rgVar
, pCeltFetched
);
686 if(This
->pos
>=This
->count
) {
692 for(i
=0; i
<celt
&& This
->pos
+i
<This
->count
; i
++) {
693 V_VT(rgVar
+i
) = VT_DISPATCH
;
694 hres
= IMatchCollection2_get_Item(This
->mc
, This
->pos
+i
, &V_DISPATCH(rgVar
+i
));
700 VariantClear(rgVar
+i
);
710 static HRESULT WINAPI
MatchCollectionEnum_Skip(IEnumVARIANT
*iface
, ULONG celt
)
712 MatchCollectionEnum
*This
= impl_from_IMatchCollectionEnum(iface
);
714 TRACE("(%p)->(%u)\n", This
, celt
);
716 if(This
->pos
+celt
<= This
->count
)
719 This
->pos
= This
->count
;
723 static HRESULT WINAPI
MatchCollectionEnum_Reset(IEnumVARIANT
*iface
)
725 MatchCollectionEnum
*This
= impl_from_IMatchCollectionEnum(iface
);
727 TRACE("(%p)\n", This
);
733 static HRESULT WINAPI
MatchCollectionEnum_Clone(IEnumVARIANT
*iface
, IEnumVARIANT
**ppEnum
)
735 MatchCollectionEnum
*This
= impl_from_IMatchCollectionEnum(iface
);
736 FIXME("(%p)->(%p)\n", This
, ppEnum
);
740 static const IEnumVARIANTVtbl MatchCollectionEnum_Vtbl
= {
741 MatchCollectionEnum_QueryInterface
,
742 MatchCollectionEnum_AddRef
,
743 MatchCollectionEnum_Release
,
744 MatchCollectionEnum_Next
,
745 MatchCollectionEnum_Skip
,
746 MatchCollectionEnum_Reset
,
747 MatchCollectionEnum_Clone
750 static HRESULT
create_enum_variant_mc2(IMatchCollection2
*mc
, ULONG pos
, IEnumVARIANT
**enum_variant
)
752 MatchCollectionEnum
*ret
;
754 ret
= heap_alloc_zero(sizeof(*ret
));
756 return E_OUTOFMEMORY
;
758 ret
->IEnumVARIANT_iface
.lpVtbl
= &MatchCollectionEnum_Vtbl
;
761 IMatchCollection2_get_Count(mc
, &ret
->count
);
763 IMatchCollection2_AddRef(mc
);
765 *enum_variant
= &ret
->IEnumVARIANT_iface
;
769 static inline MatchCollection2
* impl_from_IMatchCollection2(IMatchCollection2
*iface
)
771 return CONTAINING_RECORD(iface
, MatchCollection2
, IMatchCollection2_iface
);
774 static HRESULT WINAPI
MatchCollection2_QueryInterface(
775 IMatchCollection2
*iface
, REFIID riid
, void **ppv
)
777 MatchCollection2
*This
= impl_from_IMatchCollection2(iface
);
779 if(IsEqualGUID(riid
, &IID_IUnknown
)) {
780 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
781 *ppv
= &This
->IMatchCollection2_iface
;
782 }else if(IsEqualGUID(riid
, &IID_IDispatch
)) {
783 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
784 *ppv
= &This
->IMatchCollection2_iface
;
785 }else if(IsEqualGUID(riid
, &IID_IMatchCollection2
)) {
786 TRACE("(%p)->(IID_IMatchCollection2 %p)\n", This
, ppv
);
787 *ppv
= &This
->IMatchCollection2_iface
;
788 }else if(IsEqualGUID(riid
, &IID_IMatchCollection
)) {
789 TRACE("(%p)->(IID_IMatchCollection %p)\n", This
, ppv
);
790 *ppv
= &This
->IMatchCollection_iface
;
791 }else if(IsEqualGUID(riid
, &IID_IDispatchEx
)) {
792 TRACE("(%p)->(IID_IDispatchEx %p)\n", This
, ppv
);
794 return E_NOINTERFACE
;
796 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
798 return E_NOINTERFACE
;
801 IUnknown_AddRef((IUnknown
*)*ppv
);
805 static ULONG WINAPI
MatchCollection2_AddRef(IMatchCollection2
*iface
)
807 MatchCollection2
*This
= impl_from_IMatchCollection2(iface
);
808 LONG ref
= InterlockedIncrement(&This
->ref
);
810 TRACE("(%p) ref=%d\n", This
, ref
);
815 static ULONG WINAPI
MatchCollection2_Release(IMatchCollection2
*iface
)
817 MatchCollection2
*This
= impl_from_IMatchCollection2(iface
);
818 LONG ref
= InterlockedDecrement(&This
->ref
);
820 TRACE("(%p) ref=%d\n", This
, ref
);
825 for(i
=0; i
<This
->count
; i
++)
826 IMatch2_Release(This
->matches
[i
]);
827 heap_free(This
->matches
);
835 static HRESULT WINAPI
MatchCollection2_GetTypeInfoCount(IMatchCollection2
*iface
, UINT
*pctinfo
)
837 MatchCollection2
*This
= impl_from_IMatchCollection2(iface
);
839 TRACE("(%p)->(%p)\n", This
, pctinfo
);
845 static HRESULT WINAPI
MatchCollection2_GetTypeInfo(IMatchCollection2
*iface
,
846 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
848 MatchCollection2
*This
= impl_from_IMatchCollection2(iface
);
849 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
853 static HRESULT WINAPI
MatchCollection2_GetIDsOfNames(IMatchCollection2
*iface
,
854 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
856 MatchCollection2
*This
= impl_from_IMatchCollection2(iface
);
858 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
),
859 rgszNames
, cNames
, lcid
, rgDispId
);
861 return ITypeInfo_GetIDsOfNames(typeinfos
[MatchCollection2_tid
], rgszNames
, cNames
, rgDispId
);
864 static HRESULT WINAPI
MatchCollection2_Invoke(IMatchCollection2
*iface
, DISPID dispIdMember
,
865 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
866 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
868 MatchCollection2
*This
= impl_from_IMatchCollection2(iface
);
870 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
871 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
873 return ITypeInfo_Invoke(typeinfos
[MatchCollection2_tid
], iface
, dispIdMember
, wFlags
,
874 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
877 static HRESULT WINAPI
MatchCollection2_get_Item(IMatchCollection2
*iface
,
878 LONG index
, IDispatch
**ppMatch
)
880 MatchCollection2
*This
= impl_from_IMatchCollection2(iface
);
882 TRACE("(%p)->()\n", This
);
887 if(index
<0 || index
>=This
->count
)
890 *ppMatch
= (IDispatch
*)This
->matches
[index
];
891 IMatch2_AddRef(This
->matches
[index
]);
895 static HRESULT WINAPI
MatchCollection2_get_Count(IMatchCollection2
*iface
, LONG
*pCount
)
897 MatchCollection2
*This
= impl_from_IMatchCollection2(iface
);
899 TRACE("(%p)->()\n", This
);
904 *pCount
= This
->count
;
908 static HRESULT WINAPI
MatchCollection2_get__NewEnum(IMatchCollection2
*iface
, IUnknown
**ppEnum
)
910 MatchCollection2
*This
= impl_from_IMatchCollection2(iface
);
912 TRACE("(%p)->(%p)\n", This
, ppEnum
);
917 return create_enum_variant_mc2(&This
->IMatchCollection2_iface
, 0, (IEnumVARIANT
**)ppEnum
);
920 static const IMatchCollection2Vtbl MatchCollection2Vtbl
= {
921 MatchCollection2_QueryInterface
,
922 MatchCollection2_AddRef
,
923 MatchCollection2_Release
,
924 MatchCollection2_GetTypeInfoCount
,
925 MatchCollection2_GetTypeInfo
,
926 MatchCollection2_GetIDsOfNames
,
927 MatchCollection2_Invoke
,
928 MatchCollection2_get_Item
,
929 MatchCollection2_get_Count
,
930 MatchCollection2_get__NewEnum
933 static inline MatchCollection2
*impl_from_IMatchCollection(IMatchCollection
*iface
)
935 return CONTAINING_RECORD(iface
, MatchCollection2
, IMatchCollection_iface
);
938 static HRESULT WINAPI
MatchCollection_QueryInterface(IMatchCollection
*iface
, REFIID riid
, void **ppv
)
940 MatchCollection2
*This
= impl_from_IMatchCollection(iface
);
941 return IMatchCollection2_QueryInterface(&This
->IMatchCollection2_iface
, riid
, ppv
);
944 static ULONG WINAPI
MatchCollection_AddRef(IMatchCollection
*iface
)
946 MatchCollection2
*This
= impl_from_IMatchCollection(iface
);
947 return IMatchCollection2_AddRef(&This
->IMatchCollection2_iface
);
950 static ULONG WINAPI
MatchCollection_Release(IMatchCollection
*iface
)
952 MatchCollection2
*This
= impl_from_IMatchCollection(iface
);
953 return IMatchCollection2_Release(&This
->IMatchCollection2_iface
);
956 static HRESULT WINAPI
MatchCollection_GetTypeInfoCount(IMatchCollection
*iface
, UINT
*pctinfo
)
958 MatchCollection2
*This
= impl_from_IMatchCollection(iface
);
959 return IMatchCollection2_GetTypeInfoCount(&This
->IMatchCollection2_iface
, pctinfo
);
962 static HRESULT WINAPI
MatchCollection_GetTypeInfo(IMatchCollection
*iface
,
963 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
965 MatchCollection2
*This
= impl_from_IMatchCollection(iface
);
966 return IMatchCollection2_GetTypeInfo(&This
->IMatchCollection2_iface
, iTInfo
, lcid
, ppTInfo
);
969 static HRESULT WINAPI
MatchCollection_GetIDsOfNames(IMatchCollection
*iface
, REFIID riid
,
970 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
972 MatchCollection2
*This
= impl_from_IMatchCollection(iface
);
973 return IMatchCollection2_GetIDsOfNames(&This
->IMatchCollection2_iface
,
974 riid
, rgszNames
, cNames
, lcid
, rgDispId
);
977 static HRESULT WINAPI
MatchCollection_Invoke(IMatchCollection
*iface
, DISPID dispIdMember
,
978 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
,
979 EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
981 MatchCollection2
*This
= impl_from_IMatchCollection(iface
);
982 return IMatchCollection2_Invoke(&This
->IMatchCollection2_iface
, dispIdMember
,
983 riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
986 static HRESULT WINAPI
MatchCollection_get_Item(IMatchCollection
*iface
, LONG index
, IDispatch
**ppMatch
)
988 MatchCollection2
*This
= impl_from_IMatchCollection(iface
);
989 return IMatchCollection2_get_Item(&This
->IMatchCollection2_iface
, index
, ppMatch
);
992 static HRESULT WINAPI
MatchCollection_get_Count(IMatchCollection
*iface
, LONG
*pCount
)
994 MatchCollection2
*This
= impl_from_IMatchCollection(iface
);
995 return IMatchCollection2_get_Count(&This
->IMatchCollection2_iface
, pCount
);
998 static HRESULT WINAPI
MatchCollection_get__NewEnum(IMatchCollection
*iface
, IUnknown
**ppEnum
)
1000 MatchCollection2
*This
= impl_from_IMatchCollection(iface
);
1001 return IMatchCollection2_get__NewEnum(&This
->IMatchCollection2_iface
, ppEnum
);
1004 static const IMatchCollectionVtbl MatchCollectionVtbl
= {
1005 MatchCollection_QueryInterface
,
1006 MatchCollection_AddRef
,
1007 MatchCollection_Release
,
1008 MatchCollection_GetTypeInfoCount
,
1009 MatchCollection_GetTypeInfo
,
1010 MatchCollection_GetIDsOfNames
,
1011 MatchCollection_Invoke
,
1012 MatchCollection_get_Item
,
1013 MatchCollection_get_Count
,
1014 MatchCollection_get__NewEnum
1017 static HRESULT
add_match(IMatchCollection2
*iface
, IMatch2
*add
)
1019 MatchCollection2
*This
= impl_from_IMatchCollection2(iface
);
1021 TRACE("(%p)->(%p)\n", This
, add
);
1024 This
->matches
= heap_alloc(8*sizeof(IMatch
*));
1026 return E_OUTOFMEMORY
;
1028 }else if(This
->size
== This
->count
) {
1029 IMatch2
**new_matches
= heap_realloc(This
->matches
, 2*This
->size
*sizeof(IMatch
*));
1031 return E_OUTOFMEMORY
;
1033 This
->matches
= new_matches
;
1037 This
->matches
[This
->count
++] = add
;
1038 IMatch2_AddRef(add
);
1042 static HRESULT
create_match_collection2(IMatchCollection2
**match_collection
)
1044 MatchCollection2
*ret
;
1047 hres
= init_regexp_typeinfo(MatchCollection2_tid
);
1051 ret
= heap_alloc_zero(sizeof(*ret
));
1053 return E_OUTOFMEMORY
;
1055 ret
->IMatchCollection2_iface
.lpVtbl
= &MatchCollection2Vtbl
;
1056 ret
->IMatchCollection_iface
.lpVtbl
= &MatchCollectionVtbl
;
1059 *match_collection
= &ret
->IMatchCollection2_iface
;
1063 static inline RegExp2
*impl_from_IRegExp2(IRegExp2
*iface
)
1065 return CONTAINING_RECORD(iface
, RegExp2
, IRegExp2_iface
);
1068 static HRESULT WINAPI
RegExp2_QueryInterface(IRegExp2
*iface
, REFIID riid
, void **ppv
)
1070 RegExp2
*This
= impl_from_IRegExp2(iface
);
1072 if(IsEqualGUID(riid
, &IID_IUnknown
)) {
1073 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
1074 *ppv
= &This
->IRegExp2_iface
;
1075 }else if(IsEqualGUID(riid
, &IID_IDispatch
)) {
1076 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
1077 *ppv
= &This
->IRegExp2_iface
;
1078 }else if(IsEqualGUID(riid
, &IID_IRegExp2
)) {
1079 TRACE("(%p)->(IID_IRegExp2 %p)\n", This
, ppv
);
1080 *ppv
= &This
->IRegExp2_iface
;
1081 }else if(IsEqualGUID(riid
, &IID_IRegExp
)) {
1082 TRACE("(%p)->(IID_IRegExp %p)\n", This
, ppv
);
1083 *ppv
= &This
->IRegExp_iface
;
1084 }else if(IsEqualGUID(riid
, &IID_IDispatchEx
)) {
1085 TRACE("(%p)->(IID_IDispatchEx %p)\n", This
, ppv
);
1087 return E_NOINTERFACE
;
1089 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
1091 return E_NOINTERFACE
;
1094 IUnknown_AddRef((IUnknown
*)*ppv
);
1098 static ULONG WINAPI
RegExp2_AddRef(IRegExp2
*iface
)
1100 RegExp2
*This
= impl_from_IRegExp2(iface
);
1101 LONG ref
= InterlockedIncrement(&This
->ref
);
1103 TRACE("(%p) ref=%d\n", This
, ref
);
1108 static ULONG WINAPI
RegExp2_Release(IRegExp2
*iface
)
1110 RegExp2
*This
= impl_from_IRegExp2(iface
);
1111 LONG ref
= InterlockedDecrement(&This
->ref
);
1113 TRACE("(%p) ref=%d\n", This
, ref
);
1116 heap_free(This
->pattern
);
1118 regexp_destroy(This
->regexp
);
1119 heap_pool_free(&This
->pool
);
1126 static HRESULT WINAPI
RegExp2_GetTypeInfoCount(IRegExp2
*iface
, UINT
*pctinfo
)
1128 RegExp2
*This
= impl_from_IRegExp2(iface
);
1130 TRACE("(%p)->(%p)\n", This
, pctinfo
);
1136 static HRESULT WINAPI
RegExp2_GetTypeInfo(IRegExp2
*iface
,
1137 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
1139 RegExp2
*This
= impl_from_IRegExp2(iface
);
1140 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
1144 static HRESULT WINAPI
RegExp2_GetIDsOfNames(IRegExp2
*iface
, REFIID riid
,
1145 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
1147 RegExp2
*This
= impl_from_IRegExp2(iface
);
1149 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
),
1150 rgszNames
, cNames
, lcid
, rgDispId
);
1152 return ITypeInfo_GetIDsOfNames(typeinfos
[RegExp2_tid
], rgszNames
, cNames
, rgDispId
);
1155 static HRESULT WINAPI
RegExp2_Invoke(IRegExp2
*iface
, DISPID dispIdMember
,
1156 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1157 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1159 RegExp2
*This
= impl_from_IRegExp2(iface
);
1161 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
1162 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1164 return ITypeInfo_Invoke(typeinfos
[RegExp2_tid
], iface
, dispIdMember
, wFlags
,
1165 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1168 static HRESULT WINAPI
RegExp2_get_Pattern(IRegExp2
*iface
, BSTR
*pPattern
)
1170 RegExp2
*This
= impl_from_IRegExp2(iface
);
1172 TRACE("(%p)->(%p)\n", This
, pPattern
);
1177 if(!This
->pattern
) {
1182 *pPattern
= SysAllocString(This
->pattern
);
1183 return *pPattern
? S_OK
: E_OUTOFMEMORY
;
1186 static HRESULT WINAPI
RegExp2_put_Pattern(IRegExp2
*iface
, BSTR pattern
)
1188 RegExp2
*This
= impl_from_IRegExp2(iface
);
1192 TRACE("(%p)->(%s)\n", This
, wine_dbgstr_w(pattern
));
1195 heap_free(This
->pattern
);
1197 regexp_destroy(This
->regexp
);
1198 This
->regexp
= NULL
;
1200 This
->pattern
= NULL
;
1204 size
= (SysStringLen(pattern
)+1) * sizeof(WCHAR
);
1205 p
= heap_alloc(size
);
1207 return E_OUTOFMEMORY
;
1209 heap_free(This
->pattern
);
1211 memcpy(p
, pattern
, size
);
1213 regexp_destroy(This
->regexp
);
1214 This
->regexp
= NULL
;
1219 static HRESULT WINAPI
RegExp2_get_IgnoreCase(IRegExp2
*iface
, VARIANT_BOOL
*pIgnoreCase
)
1221 RegExp2
*This
= impl_from_IRegExp2(iface
);
1223 TRACE("(%p)->(%p)\n", This
, pIgnoreCase
);
1228 *pIgnoreCase
= This
->flags
& REG_FOLD
? VARIANT_TRUE
: VARIANT_FALSE
;
1232 static HRESULT WINAPI
RegExp2_put_IgnoreCase(IRegExp2
*iface
, VARIANT_BOOL ignoreCase
)
1234 RegExp2
*This
= impl_from_IRegExp2(iface
);
1236 TRACE("(%p)->(%s)\n", This
, ignoreCase
? "true" : "false");
1239 This
->flags
|= REG_FOLD
;
1241 This
->flags
&= ~REG_FOLD
;
1245 static HRESULT WINAPI
RegExp2_get_Global(IRegExp2
*iface
, VARIANT_BOOL
*pGlobal
)
1247 RegExp2
*This
= impl_from_IRegExp2(iface
);
1249 TRACE("(%p)->(%p)\n", This
, pGlobal
);
1254 *pGlobal
= This
->flags
& REG_GLOB
? VARIANT_TRUE
: VARIANT_FALSE
;
1258 static HRESULT WINAPI
RegExp2_put_Global(IRegExp2
*iface
, VARIANT_BOOL global
)
1260 RegExp2
*This
= impl_from_IRegExp2(iface
);
1262 TRACE("(%p)->(%s)\n", This
, global
? "true" : "false");
1265 This
->flags
|= REG_GLOB
;
1267 This
->flags
&= ~REG_GLOB
;
1271 static HRESULT WINAPI
RegExp2_get_Multiline(IRegExp2
*iface
, VARIANT_BOOL
*pMultiline
)
1273 RegExp2
*This
= impl_from_IRegExp2(iface
);
1275 TRACE("(%p)->(%p)\n", This
, pMultiline
);
1280 *pMultiline
= This
->flags
& REG_MULTILINE
? VARIANT_TRUE
: VARIANT_FALSE
;
1284 static HRESULT WINAPI
RegExp2_put_Multiline(IRegExp2
*iface
, VARIANT_BOOL multiline
)
1286 RegExp2
*This
= impl_from_IRegExp2(iface
);
1288 TRACE("(%p)->(%s)\n", This
, multiline
? "true" : "false");
1291 This
->flags
|= REG_MULTILINE
;
1293 This
->flags
&= ~REG_MULTILINE
;
1297 static HRESULT WINAPI
RegExp2_Execute(IRegExp2
*iface
,
1298 BSTR sourceString
, IDispatch
**ppMatches
)
1300 RegExp2
*This
= impl_from_IRegExp2(iface
);
1301 match_state_t
*result
;
1303 IMatchCollection2
*match_collection
;
1304 IMatch2
*add
= NULL
;
1307 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(sourceString
), ppMatches
);
1309 if(!This
->pattern
) {
1310 DWORD i
, len
= SysStringLen(sourceString
);
1312 hres
= create_match_collection2(&match_collection
);
1316 for(i
=0; i
<=len
; i
++) {
1317 hres
= create_match2(i
, NULL
, &add
);
1321 hres
= add_match(match_collection
, add
);
1324 IMatch2_Release(add
);
1326 if(!(This
->flags
& REG_GLOB
))
1331 IMatchCollection2_Release(match_collection
);
1335 *ppMatches
= (IDispatch
*)match_collection
;
1340 This
->regexp
= regexp_new(NULL
, &This
->pool
, This
->pattern
,
1341 strlenW(This
->pattern
), This
->flags
, FALSE
);
1345 hres
= regexp_set_flags(&This
->regexp
, NULL
, &This
->pool
, This
->flags
);
1350 hres
= create_match_collection2(&match_collection
);
1356 result
= alloc_match_state(This
->regexp
, NULL
, pos
);
1358 hres
= E_OUTOFMEMORY
;
1362 hres
= regexp_execute(This
->regexp
, NULL
, &This
->pool
,
1363 sourceString
, SysStringLen(sourceString
), result
);
1370 hres
= create_match2(result
->cp
-result
->match_len
-sourceString
, &result
, &add
);
1374 hres
= add_match(match_collection
, add
);
1375 IMatch2_Release(add
);
1379 if(!(This
->flags
& REG_GLOB
))
1384 IMatchCollection2_Release(match_collection
);
1388 *ppMatches
= (IDispatch
*)match_collection
;
1392 static HRESULT WINAPI
RegExp2_Test(IRegExp2
*iface
, BSTR sourceString
, VARIANT_BOOL
*pMatch
)
1394 RegExp2
*This
= impl_from_IRegExp2(iface
);
1395 match_state_t
*result
;
1399 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(sourceString
), pMatch
);
1401 if(!This
->pattern
) {
1402 *pMatch
= VARIANT_TRUE
;
1407 This
->regexp
= regexp_new(NULL
, &This
->pool
, This
->pattern
,
1408 strlenW(This
->pattern
), This
->flags
, FALSE
);
1412 hres
= regexp_set_flags(&This
->regexp
, NULL
, &This
->pool
, This
->flags
);
1417 mark
= heap_pool_mark(&This
->pool
);
1418 result
= alloc_match_state(This
->regexp
, &This
->pool
, sourceString
);
1420 heap_pool_clear(mark
);
1421 return E_OUTOFMEMORY
;
1424 hres
= regexp_execute(This
->regexp
, NULL
, &This
->pool
,
1425 sourceString
, SysStringLen(sourceString
), result
);
1427 heap_pool_clear(mark
);
1430 *pMatch
= VARIANT_TRUE
;
1431 }else if(hres
== S_FALSE
) {
1432 *pMatch
= VARIANT_FALSE
;
1438 static HRESULT WINAPI
RegExp2_Replace(IRegExp2
*iface
, BSTR sourceString
,
1439 VARIANT replaceVar
, BSTR
*pDestString
)
1441 RegExp2
*This
= impl_from_IRegExp2(iface
);
1442 FIXME("(%p)->(%s %s %p)\n", This
, debugstr_w(sourceString
),
1443 debugstr_variant(&replaceVar
), pDestString
);
1447 static const IRegExp2Vtbl RegExp2Vtbl
= {
1448 RegExp2_QueryInterface
,
1451 RegExp2_GetTypeInfoCount
,
1452 RegExp2_GetTypeInfo
,
1453 RegExp2_GetIDsOfNames
,
1455 RegExp2_get_Pattern
,
1456 RegExp2_put_Pattern
,
1457 RegExp2_get_IgnoreCase
,
1458 RegExp2_put_IgnoreCase
,
1461 RegExp2_get_Multiline
,
1462 RegExp2_put_Multiline
,
1468 static inline RegExp2
*impl_from_IRegExp(IRegExp
*iface
)
1470 return CONTAINING_RECORD(iface
, RegExp2
, IRegExp_iface
);
1473 static HRESULT WINAPI
RegExp_QueryInterface(IRegExp
*iface
, REFIID riid
, void **ppv
)
1475 RegExp2
*This
= impl_from_IRegExp(iface
);
1476 return IRegExp2_QueryInterface(&This
->IRegExp2_iface
, riid
, ppv
);
1479 static ULONG WINAPI
RegExp_AddRef(IRegExp
*iface
)
1481 RegExp2
*This
= impl_from_IRegExp(iface
);
1482 return IRegExp2_AddRef(&This
->IRegExp2_iface
);
1485 static ULONG WINAPI
RegExp_Release(IRegExp
*iface
)
1487 RegExp2
*This
= impl_from_IRegExp(iface
);
1488 return IRegExp2_Release(&This
->IRegExp2_iface
);
1491 static HRESULT WINAPI
RegExp_GetTypeInfoCount(IRegExp
*iface
, UINT
*pctinfo
)
1493 RegExp2
*This
= impl_from_IRegExp(iface
);
1494 return IRegExp2_GetTypeInfoCount(&This
->IRegExp2_iface
, pctinfo
);
1497 static HRESULT WINAPI
RegExp_GetTypeInfo(IRegExp
*iface
,
1498 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
1500 RegExp2
*This
= impl_from_IRegExp(iface
);
1501 return IRegExp2_GetTypeInfo(&This
->IRegExp2_iface
, iTInfo
, lcid
, ppTInfo
);
1504 static HRESULT WINAPI
RegExp_GetIDsOfNames(IRegExp
*iface
, REFIID riid
,
1505 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
1507 RegExp2
*This
= impl_from_IRegExp(iface
);
1508 return IRegExp2_GetIDsOfNames(&This
->IRegExp2_iface
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
1511 static HRESULT WINAPI
RegExp_Invoke(IRegExp
*iface
, DISPID dispIdMember
,
1512 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1513 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1515 RegExp2
*This
= impl_from_IRegExp(iface
);
1516 return IRegExp2_Invoke(&This
->IRegExp2_iface
, dispIdMember
, riid
, lcid
,
1517 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1520 static HRESULT WINAPI
RegExp_get_Pattern(IRegExp
*iface
, BSTR
*pPattern
)
1522 RegExp2
*This
= impl_from_IRegExp(iface
);
1523 return IRegExp2_get_Pattern(&This
->IRegExp2_iface
, pPattern
);
1526 static HRESULT WINAPI
RegExp_put_Pattern(IRegExp
*iface
, BSTR pPattern
)
1528 RegExp2
*This
= impl_from_IRegExp(iface
);
1529 return IRegExp2_put_Pattern(&This
->IRegExp2_iface
, pPattern
);
1532 static HRESULT WINAPI
RegExp_get_IgnoreCase(IRegExp
*iface
, VARIANT_BOOL
*pIgnoreCase
)
1534 RegExp2
*This
= impl_from_IRegExp(iface
);
1535 return IRegExp2_get_IgnoreCase(&This
->IRegExp2_iface
, pIgnoreCase
);
1538 static HRESULT WINAPI
RegExp_put_IgnoreCase(IRegExp
*iface
, VARIANT_BOOL pIgnoreCase
)
1540 RegExp2
*This
= impl_from_IRegExp(iface
);
1541 return IRegExp2_put_IgnoreCase(&This
->IRegExp2_iface
, pIgnoreCase
);
1544 static HRESULT WINAPI
RegExp_get_Global(IRegExp
*iface
, VARIANT_BOOL
*pGlobal
)
1546 RegExp2
*This
= impl_from_IRegExp(iface
);
1547 return IRegExp2_get_Global(&This
->IRegExp2_iface
, pGlobal
);
1550 static HRESULT WINAPI
RegExp_put_Global(IRegExp
*iface
, VARIANT_BOOL pGlobal
)
1552 RegExp2
*This
= impl_from_IRegExp(iface
);
1553 return IRegExp2_put_Global(&This
->IRegExp2_iface
, pGlobal
);
1556 static HRESULT WINAPI
RegExp_Execute(IRegExp
*iface
,
1557 BSTR sourceString
, IDispatch
**ppMatches
)
1559 RegExp2
*This
= impl_from_IRegExp(iface
);
1560 return IRegExp2_Execute(&This
->IRegExp2_iface
, sourceString
, ppMatches
);
1563 static HRESULT WINAPI
RegExp_Test(IRegExp
*iface
, BSTR sourceString
, VARIANT_BOOL
*pMatch
)
1565 RegExp2
*This
= impl_from_IRegExp(iface
);
1566 return IRegExp2_Test(&This
->IRegExp2_iface
, sourceString
, pMatch
);
1569 static HRESULT WINAPI
RegExp_Replace(IRegExp
*iface
, BSTR sourceString
,
1570 BSTR replaceString
, BSTR
*pDestString
)
1572 RegExp2
*This
= impl_from_IRegExp(iface
);
1575 V_VT(&replace
) = VT_BSTR
;
1576 V_BSTR(&replace
) = replaceString
;
1577 return IRegExp2_Replace(&This
->IRegExp2_iface
, sourceString
, replace
, pDestString
);
1580 static IRegExpVtbl RegExpVtbl
= {
1581 RegExp_QueryInterface
,
1584 RegExp_GetTypeInfoCount
,
1586 RegExp_GetIDsOfNames
,
1590 RegExp_get_IgnoreCase
,
1591 RegExp_put_IgnoreCase
,
1599 HRESULT WINAPI
VBScriptRegExpFactory_CreateInstance(IClassFactory
*iface
, IUnknown
*pUnkOuter
, REFIID riid
, void **ppv
)
1604 TRACE("(%p %s %p)\n", pUnkOuter
, debugstr_guid(riid
), ppv
);
1606 hres
= init_regexp_typeinfo(RegExp2_tid
);
1610 ret
= heap_alloc_zero(sizeof(*ret
));
1612 return E_OUTOFMEMORY
;
1614 ret
->IRegExp2_iface
.lpVtbl
= &RegExp2Vtbl
;
1615 ret
->IRegExp_iface
.lpVtbl
= &RegExpVtbl
;
1618 heap_pool_init(&ret
->pool
);
1620 hres
= IRegExp2_QueryInterface(&ret
->IRegExp2_iface
, riid
, ppv
);
1621 IRegExp2_Release(&ret
->IRegExp2_iface
);
1625 void release_regexp_typelib(void)
1629 for(i
=0; i
<REGEXP_LAST_tid
; i
++) {
1631 ITypeInfo_Release(typeinfos
[i
]);
1634 ITypeLib_Release(typelib
);