Commit 6c5588f9 authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

scrrun: Add typelib support.

parent 45f240c0
MODULE = scrrun.dll
IMPORTS = uuid
IMPORTS = uuid oleaut32
C_SRCS = \
filesystem.c \
......
......@@ -26,6 +26,7 @@
#include "ole2.h"
#include "dispex.h"
#include "scrrun.h"
#include "scrrun_private.h"
#include "wine/debug.h"
......@@ -90,19 +91,26 @@ static HRESULT WINAPI filesys_GetTypeInfoCount(IFileSystem3 *iface, UINT *pctinf
static HRESULT WINAPI filesys_GetTypeInfo(IFileSystem3 *iface, UINT iTInfo,
LCID lcid, ITypeInfo **ppTInfo)
{
FIXME("(%p)->(%u %u %p)\n", iface, iTInfo, lcid, ppTInfo);
return E_NOTIMPL;
}
TRACE("(%p)->(%u %u %p)\n", iface, iTInfo, lcid, ppTInfo);
return get_typeinfo(IFileSystem3_tid, ppTInfo);}
static HRESULT WINAPI filesys_GetIDsOfNames(IFileSystem3 *iface, REFIID riid,
LPOLESTR *rgszNames, UINT cNames,
LCID lcid, DISPID *rgDispId)
{
FIXME("(%p)->(%s %p %u %u %p)\n", iface, debugstr_guid(riid), rgszNames, cNames,
lcid, rgDispId);
ITypeInfo *typeinfo;
HRESULT hr;
return E_NOTIMPL;
TRACE("(%p)->(%s %p %u %u %p)\n", iface, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
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,
......@@ -110,10 +118,21 @@ static HRESULT WINAPI filesys_Invoke(IFileSystem3 *iface, DISPID dispIdMember,
DISPPARAMS *pDispParams, VARIANT *pVarResult,
EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", iface, dispIdMember, debugstr_guid(riid),
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
ITypeInfo *typeinfo;
HRESULT hr;
return E_NOTIMPL;
TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", iface, dispIdMember, debugstr_guid(riid),
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
hr = get_typeinfo(IFileSystem3_tid, &typeinfo);
if(SUCCEEDED(hr))
{
hr = ITypeInfo_Invoke(typeinfo, &iface, dispIdMember, wFlags,
pDispParams, pVarResult, pExcepInfo, puArgErr);
ITypeInfo_Release(typeinfo);
}
return hr;
}
static HRESULT WINAPI filesys_get_Drives(IFileSystem3 *iface, IDriveCollection **ppdrives)
......
......@@ -27,6 +27,7 @@
#include <initguid.h>
#include "scrrun.h"
#include "scrrun_private.h"
#include "wine/debug.h"
......@@ -36,8 +37,6 @@ static HINSTANCE scrrun_instance;
typedef HRESULT (*fnCreateInstance)(LPVOID *ppObj);
extern HRESULT WINAPI FileSystem_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
static HRESULT WINAPI scrruncf_QueryInterface(IClassFactory *iface, REFIID riid, LPVOID *ppv )
{
*ppv = NULL;
......@@ -88,6 +87,70 @@ static const struct IClassFactoryVtbl scrruncf_vtbl =
static IClassFactory FileSystemFactory = { &scrruncf_vtbl };
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);
}
BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
{
TRACE("%p, %u, %p\n", hinst, reason, reserved);
......@@ -101,6 +164,7 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
scrrun_instance = hinst;
break;
case DLL_PROCESS_DETACH:
release_typelib();
break;
}
return TRUE;
......
/*
* 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 WINAPI FileSystem_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**) 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment