Commit 001d1a43 authored by Shaun Ren's avatar Shaun Ren Committed by Alexandre Julliard

sapi: Implement ISpeechObjectToken::Invoke.

parent b6c17607
...@@ -5,6 +5,7 @@ DELAYIMPORTS = winmm ...@@ -5,6 +5,7 @@ DELAYIMPORTS = winmm
SOURCES = \ SOURCES = \
async.c \ async.c \
automation.c \ automation.c \
dispatch.c \
main.c \ main.c \
mmaudio.c \ mmaudio.c \
resource.c \ resource.c \
......
/*
* ITypeInfo cache for IDispatch
*
* Copyright 2019 Zebediah Figura
*
* 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
*/
#include "wine/debug.h"
#define COBJMACROS
#include "objbase.h"
#include "sapiddk.h"
#include "sapi_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(sapi);
static ITypeLib *typelib;
static ITypeInfo *typeinfos[last_tid];
static REFIID tid_id[] =
{
&IID_ISpeechObjectToken,
};
HRESULT get_typeinfo(enum type_id tid, ITypeInfo **ret)
{
HRESULT hr;
if (!typelib)
{
ITypeLib *tl;
hr = LoadRegTypeLib(&LIBID_SpeechLib, 5, 4, LOCALE_SYSTEM_DEFAULT, &tl);
if (FAILED(hr))
{
ERR("Failed to load typelib, hr %#lx.\n", hr);
return hr;
}
if (InterlockedCompareExchangePointer((void **)&typelib, tl, NULL))
ITypeLib_Release(tl);
}
if (!typeinfos[tid])
{
ITypeInfo *typeinfo;
hr = ITypeLib_GetTypeInfoOfGuid(typelib, tid_id[tid], &typeinfo);
if (FAILED(hr))
{
ERR("Failed to get type info for %s, hr %#lx.\n", debugstr_guid(tid_id[tid]), hr);
return hr;
}
if (InterlockedCompareExchangePointer((void **)(typeinfos + tid), typeinfo, NULL))
ITypeInfo_Release(typeinfo);
}
ITypeInfo_AddRef(*ret = typeinfos[tid]);
return S_OK;
}
void release_typelib(void)
{
unsigned int i;
for (i = 0; i < ARRAY_SIZE(typeinfos); ++i)
{
if (typeinfos[i])
ITypeInfo_Release(typeinfos[i]);
}
if (typelib)
ITypeLib_Release(typelib);
}
...@@ -52,3 +52,12 @@ HRESULT mmaudio_out_create( IUnknown *outer, REFIID iid, void **obj ); ...@@ -52,3 +52,12 @@ HRESULT mmaudio_out_create( IUnknown *outer, REFIID iid, void **obj );
HRESULT token_category_create( IUnknown *outer, REFIID iid, void **obj ); HRESULT token_category_create( IUnknown *outer, REFIID iid, void **obj );
HRESULT token_enum_create( IUnknown *outer, REFIID iid, void **obj ); HRESULT token_enum_create( IUnknown *outer, REFIID iid, void **obj );
HRESULT token_create( IUnknown *outer, REFIID iid, void **obj ); HRESULT token_create( IUnknown *outer, REFIID iid, void **obj );
enum type_id
{
ISpeechObjectToken_tid,
last_tid
};
HRESULT get_typeinfo( enum type_id tid, ITypeInfo **typeinfo );
void release_typelib( void );
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#include "wine/test.h" #include "wine/test.h"
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
static void test_data_key(void) static void test_data_key(void)
{ {
ISpRegDataKey *data_key; ISpRegDataKey *data_key;
...@@ -669,6 +671,8 @@ static void test_object_token(void) ...@@ -669,6 +671,8 @@ static void test_object_token(void)
ISpObjectTokenCategory *cat; ISpObjectTokenCategory *cat;
DWORD regid; DWORD regid;
IUnknown *obj; IUnknown *obj;
DISPPARAMS params;
VARIANT arg, ret;
hr = CoCreateInstance( &CLSID_SpObjectToken, NULL, CLSCTX_INPROC_SERVER, hr = CoCreateInstance( &CLSID_SpObjectToken, NULL, CLSCTX_INPROC_SERVER,
&IID_ISpObjectToken, (void **)&token ); &IID_ISpObjectToken, (void **)&token );
...@@ -915,6 +919,22 @@ static void test_object_token(void) ...@@ -915,6 +919,22 @@ static void test_object_token(void)
ok( tempB && !wcscmp( tempB, L"TestToken" ), "got %s\n", wine_dbgstr_w( tempB ) ); ok( tempB && !wcscmp( tempB, L"TestToken" ), "got %s\n", wine_dbgstr_w( tempB ) );
SysFreeString( tempB ); SysFreeString( tempB );
memset( &params, 0, sizeof(params) );
params.cArgs = 1;
params.cNamedArgs = 0;
params.rgvarg = &arg;
VariantInit( &arg );
V_VT( &arg ) = VT_I4;
V_I4( &arg ) = 0x409;
VariantInit( &ret );
hr = ISpeechObjectToken_Invoke( speech_token, DISPID_SOTGetDescription, &IID_NULL,
0, DISPATCH_METHOD, &params, &ret, NULL, NULL );
ok( hr == S_OK, "got %08lx\n", hr );
ok( V_VT( &ret ) == VT_BSTR, "got %#x\n", V_VT( &ret ) );
ok( V_BSTR( &ret ) && !wcscmp( V_BSTR( &ret ), L"409 - TestToken" ),
"got %s\n", wine_dbgstr_w( V_BSTR( &ret ) ) );
VariantClear( &ret );
ISpeechObjectToken_Release( speech_token ); ISpeechObjectToken_Release( speech_token );
ISpObjectToken_Release( test_class_token ); ISpObjectToken_Release( test_class_token );
......
...@@ -1801,8 +1801,18 @@ static HRESULT WINAPI speech_token_Invoke( ISpeechObjectToken *iface, ...@@ -1801,8 +1801,18 @@ static HRESULT WINAPI speech_token_Invoke( ISpeechObjectToken *iface,
EXCEPINFO *excepinfo, EXCEPINFO *excepinfo,
UINT *argerr ) UINT *argerr )
{ {
FIXME( "stub\n" ); ITypeInfo *ti;
return E_NOTIMPL; HRESULT hr;
TRACE( "(%p)->(%ld %s %#lx %#x %p %p %p %p)\n", iface, dispid,
debugstr_guid( iid ), lcid, flags, params, result, excepinfo, argerr );
if (FAILED(hr = get_typeinfo( ISpeechObjectToken_tid, &ti )))
return hr;
hr = ITypeInfo_Invoke( ti, iface, dispid, flags, params, result, excepinfo, argerr );
ITypeInfo_Release( ti );
return hr;
} }
static HRESULT WINAPI speech_token_get_Id( ISpeechObjectToken *iface, static HRESULT WINAPI speech_token_get_Id( ISpeechObjectToken *iface,
......
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