Module: wine Branch: master Commit: 08a16a28767923391b870132bd19dbb7cd94cf46 URL: http://source.winehq.org/git/wine.git/?a=commit;h=08a16a28767923391b870132bd...
Author: Piotr Caban piotr@codeweavers.com Date: Fri Feb 15 15:10:27 2013 +0100
vbscript: Added partial implementation of IDispatch methods in IRegExp2.
---
dlls/vbscript/vbregexp.c | 97 +++++++++++++++++++++++++++++++++++++--- dlls/vbscript/vbscript.h | 1 + dlls/vbscript/vbscript_main.c | 1 + 3 files changed, 91 insertions(+), 8 deletions(-)
diff --git a/dlls/vbscript/vbregexp.c b/dlls/vbscript/vbregexp.c index 2bf866b..1afe44b 100644 --- a/dlls/vbscript/vbregexp.c +++ b/dlls/vbscript/vbregexp.c @@ -23,6 +23,62 @@
WINE_DEFAULT_DEBUG_CHANNEL(vbscript);
+#define REGEXP_TID_LIST \ + XDIID(RegExp2) \ + XDIID(Match2) \ + XDIID(MatchCollection2) \ + XDIID(SubMatches) + +typedef enum { +#define XDIID(iface) iface ## _tid, +REGEXP_TID_LIST +#undef XDIID + REGEXP_LAST_tid +} regexp_tid_t; + +static REFIID tid_ids[] = { +#define XDIID(iface) &IID_I ## iface, +REGEXP_TID_LIST +#undef XDIID +}; + +static ITypeLib *typelib; +static ITypeInfo *typeinfos[REGEXP_LAST_tid]; + +static HRESULT init_regexp_typeinfo(regexp_tid_t tid) +{ + HRESULT hres; + + if(!typelib) { + static const WCHAR vbscript_dll3W[] = {'v','b','s','c','r','i','p','t','.','d','l','l','\','3',0}; + ITypeLib *tl; + + hres = LoadTypeLib(vbscript_dll3W, &tl); + if(FAILED(hres)) { + ERR("LoadRegTypeLib failed: %08x\n", hres); + return hres; + } + + if(InterlockedCompareExchangePointer((void**)&typelib, tl, NULL)) + ITypeLib_Release(tl); + } + + if(!typeinfos[tid]) { + ITypeInfo *ti; + + hres = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &ti); + if(FAILED(hres)) { + ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_ids[tid]), hres); + return hres; + } + + if(InterlockedCompareExchangePointer((void**)(typeinfos+tid), ti, NULL)) + ITypeInfo_Release(ti); + } + + return S_OK; +} + typedef struct { IRegExp2 IRegExp2_iface; IRegExp IRegExp_iface; @@ -78,8 +134,9 @@ static ULONG WINAPI RegExp2_Release(IRegExp2 *iface)
TRACE("(%p) ref=%d\n", This, ref);
- if(!ref) + if(!ref) { heap_free(This); + }
return ref; } @@ -87,8 +144,11 @@ static ULONG WINAPI RegExp2_Release(IRegExp2 *iface) static HRESULT WINAPI RegExp2_GetTypeInfoCount(IRegExp2 *iface, UINT *pctinfo) { RegExp2 *This = impl_from_IRegExp2(iface); - FIXME("(%p)->(%p)\n", This, pctinfo); - return E_NOTIMPL; + + TRACE("(%p)->(%p)\n", This, pctinfo); + + *pctinfo = 1; + return S_OK; }
static HRESULT WINAPI RegExp2_GetTypeInfo(IRegExp2 *iface, @@ -103,9 +163,11 @@ static HRESULT WINAPI RegExp2_GetIDsOfNames(IRegExp2 *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) { RegExp2 *This = impl_from_IRegExp2(iface); - FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames, - lcid, rgDispId); - return E_NOTIMPL; + + TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), + rgszNames, cNames, lcid, rgDispId); + + return ITypeInfo_GetIDsOfNames(typeinfos[RegExp2_tid], rgszNames, cNames, rgDispId); }
static HRESULT WINAPI RegExp2_Invoke(IRegExp2 *iface, DISPID dispIdMember, @@ -113,9 +175,12 @@ static HRESULT WINAPI RegExp2_Invoke(IRegExp2 *iface, DISPID dispIdMember, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) { RegExp2 *This = impl_from_IRegExp2(iface); - FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid), + + TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid), lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); - return E_NOTIMPL; + + return ITypeInfo_Invoke(typeinfos[RegExp2_tid], iface, dispIdMember, wFlags, + pDispParams, pVarResult, pExcepInfo, puArgErr); }
static HRESULT WINAPI RegExp2_get_Pattern(IRegExp2 *iface, BSTR *pPattern) @@ -357,6 +422,10 @@ HRESULT WINAPI VBScriptRegExpFactory_CreateInstance(IClassFactory *iface, IUnkno
TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppv);
+ hres = init_regexp_typeinfo(RegExp2_tid); + if(FAILED(hres)) + return hres; + ret = heap_alloc_zero(sizeof(*ret)); if(!ret) return E_OUTOFMEMORY; @@ -370,3 +439,15 @@ HRESULT WINAPI VBScriptRegExpFactory_CreateInstance(IClassFactory *iface, IUnkno IRegExp2_Release(&ret->IRegExp2_iface); return hres; } + +void release_regexp_typelib(void) +{ + DWORD i; + + for(i=0; i<REGEXP_LAST_tid; i++) { + if(typeinfos[i]) + ITypeInfo_Release(typeinfos[i]); + } + if(typelib) + ITypeLib_Release(typelib); +} diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 868a9f4..e3d96d8 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -342,6 +342,7 @@ TID_LIST } tid_t;
HRESULT get_typeinfo(tid_t,ITypeInfo**) DECLSPEC_HIDDEN; +void release_regexp_typelib(void) DECLSPEC_HIDDEN;
#ifndef INT32_MIN #define INT32_MIN (-2147483647-1) diff --git a/dlls/vbscript/vbscript_main.c b/dlls/vbscript/vbscript_main.c index eefb7a5..9ff2a51 100644 --- a/dlls/vbscript/vbscript_main.c +++ b/dlls/vbscript/vbscript_main.c @@ -285,6 +285,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv) break; case DLL_PROCESS_DETACH: release_typelib(); + release_regexp_typelib(); }
return TRUE;