[7/8] scrrun: Add typelib support
Alistair Leslie-Hughes
leslie_alistair at hotmail.com
Tue Mar 27 04:43:24 CDT 2012
Hi,
Changelog:
scrrun: Add typelib support
Best Regards
Alistair Leslie-Hughes
-------------- next part --------------
>From 54039813f021c592953eed71c911f6eea50dda19 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Tue, 27 Mar 2012 13:38:56 +1100
Subject: [PATCH] Add typelib support
To: wine-patches <wine-patches at winehq.org>
---
dlls/scrrun/Makefile.in | 2 +-
dlls/scrrun/filesystem.c | 34 ++++++++++++++++-----
dlls/scrrun/scrrun.c | 66 +++++++++++++++++++++++++++++++++++++++++-
dlls/scrrun/scrrun_private.h | 33 +++++++++++++++++++++
4 files changed, 125 insertions(+), 10 deletions(-)
create mode 100644 dlls/scrrun/scrrun_private.h
diff --git a/dlls/scrrun/Makefile.in b/dlls/scrrun/Makefile.in
index 57ebc6a..746a82e 100644
--- a/dlls/scrrun/Makefile.in
+++ b/dlls/scrrun/Makefile.in
@@ -1,5 +1,5 @@
MODULE = scrrun.dll
-IMPORTS = uuid shlwapi
+IMPORTS = uuid shlwapi oleaut32
C_SRCS = \
filesystem.c \
diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c
index 68cbc9f..89f38a3 100644
--- a/dlls/scrrun/filesystem.c
+++ b/dlls/scrrun/filesystem.c
@@ -27,6 +27,7 @@
#include "dispex.h"
#include "shlwapi.h"
#include "scrrun.h"
+#include "scrrun_private.h"
#include "wine/debug.h"
@@ -119,9 +120,8 @@ static HRESULT WINAPI filesys_GetTypeInfo(IFileSystem3 *iface, UINT iTInfo,
{
FileSystem *This = impl_from_IFileSystem3(iface);
- FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
-
- return E_NOTIMPL;
+ TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
+ return get_typeinfo(IFileSystem3_tid, ppTInfo);
}
static HRESULT WINAPI filesys_GetIDsOfNames(IFileSystem3 *iface, REFIID riid,
@@ -129,11 +129,19 @@ static HRESULT WINAPI filesys_GetIDsOfNames(IFileSystem3 *iface, REFIID riid,
LCID lcid, DISPID *rgDispId)
{
FileSystem *This = impl_from_IFileSystem3(iface);
+ ITypeInfo *typeinfo;
+ HRESULT hr;
- FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
- lcid, rgDispId);
+ TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
- return E_NOTIMPL;
+ hr = get_typeinfo(IFileSystem3_tid, &typeinfo);
+ if(SUCCEEDED(hr))
+ {
+ hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
+ ITypeInfo_Release(typeinfo);
+ }
+
+ return hr;
}
static HRESULT WINAPI filesys_Invoke(IFileSystem3 *iface, DISPID dispIdMember,
@@ -142,11 +150,21 @@ static HRESULT WINAPI filesys_Invoke(IFileSystem3 *iface, DISPID dispIdMember,
EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
FileSystem *This = impl_from_IFileSystem3(iface);
+ ITypeInfo *typeinfo;
+ HRESULT hr;
- 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;
+ hr = get_typeinfo(IFileSystem3_tid, &typeinfo);
+ if(SUCCEEDED(hr))
+ {
+ hr = ITypeInfo_Invoke(typeinfo, &This->IFileSystem3_iface, dispIdMember, wFlags,
+ pDispParams, pVarResult, pExcepInfo, puArgErr);
+ ITypeInfo_Release(typeinfo);
+ }
+
+ return hr;
}
static HRESULT WINAPI filesys_get_Drives(IFileSystem3 *iface, IDriveCollection **ppdrives)
diff --git a/dlls/scrrun/scrrun.c b/dlls/scrrun/scrrun.c
index 431ed5a..67cc83b 100644
--- a/dlls/scrrun/scrrun.c
+++ b/dlls/scrrun/scrrun.c
@@ -27,6 +27,7 @@
#include <initguid.h>
#include "scrrun.h"
+#include "scrrun_private.h"
#include "wine/debug.h"
@@ -36,7 +37,69 @@ static HINSTANCE scrrun_instance;
typedef HRESULT (*fnCreateInstance)(LPVOID *ppObj);
-extern HRESULT FileSystem_Create(LPVOID* ppUnk);
+static ITypeLib *typelib;
+static ITypeInfo *typeinfos[LAST_tid];
+
+static REFIID tid_ids[] = {
+ &IID_NULL,
+ &IID_IFileSystem3,
+};
+
+static HRESULT load_typelib(void)
+{
+ HRESULT hres;
+ ITypeLib *tl;
+
+ hres = LoadRegTypeLib(&LIBID_Scripting, 1, 0, LOCALE_SYSTEM_DEFAULT, &tl);
+ if(FAILED(hres)) {
+ ERR("LoadRegTypeLib failed: %08x\n", hres);
+ return hres;
+ }
+
+ if(InterlockedCompareExchangePointer((void**)&typelib, tl, NULL))
+ ITypeLib_Release(tl);
+ return hres;
+}
+
+HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo)
+{
+ HRESULT hres;
+
+ if (!typelib)
+ hres = load_typelib();
+ if (!typelib)
+ return hres;
+
+ 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);
+ }
+
+ *typeinfo = typeinfos[tid];
+ return S_OK;
+}
+
+static void release_typelib(void)
+{
+ unsigned i;
+
+ if(!typelib)
+ return;
+
+ for(i=0; i < sizeof(typeinfos)/sizeof(*typeinfos); i++)
+ if(typeinfos[i])
+ ITypeInfo_Release(typeinfos[i]);
+
+ ITypeLib_Release(typelib);
+}
typedef struct scrruncf
{
@@ -150,6 +213,7 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
scrrun_instance = hinst;
break;
case DLL_PROCESS_DETACH:
+ release_typelib();
break;
}
return TRUE;
diff --git a/dlls/scrrun/scrrun_private.h b/dlls/scrrun/scrrun_private.h
new file mode 100644
index 0000000..c754c58
--- /dev/null
+++ b/dlls/scrrun/scrrun_private.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2012 Alistair Leslie-Hughes
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+#ifndef _SCRRUN_PRIVATE_H_
+#define _SCRRUN_PRIVATE_H
+
+extern HRESULT FileSystem_Create(LPVOID* ppUnk) DECLSPEC_HIDDEN;
+
+typedef enum tid_t
+{
+ NULL_tid,
+ IFileSystem3_tid,
+ LAST_tid
+} tid_t;
+
+HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo) DECLSPEC_HIDDEN;
+
+#endif
+
--
1.7.5.4
More information about the wine-patches
mailing list