Skip to content

Commit 26498d9

Browse files
shaunrenjulliard
authored andcommitted
sapi: Add stub implementation for ISpeechObjectTokens::get__NewEnum.
1 parent ca6f3a7 commit 26498d9

File tree

2 files changed

+141
-2
lines changed

2 files changed

+141
-2
lines changed

dlls/sapi/tests/token.c

+26
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ static void test_token_enum(void)
248248
HRESULT hr;
249249
IDispatch *disp;
250250
ISpeechObjectTokens *speech_tokens;
251+
IUnknown *unk;
252+
IEnumVARIANT *enumvar;
251253
ISpObjectToken *tokens[5];
252254
ISpObjectToken *out_tokens[5];
253255
WCHAR token_id[MAX_PATH];
@@ -348,6 +350,30 @@ static void test_token_enum(void)
348350
&IID_ISpObjectTokenEnumBuilder, (void **)&token_enum );
349351
ok( hr == S_OK, "got %08lx\n", hr );
350352

353+
hr = ISpObjectTokenEnumBuilder_QueryInterface( token_enum,
354+
&IID_ISpeechObjectTokens,
355+
(void **)&speech_tokens );
356+
ok( hr == S_OK, "got %08lx\n", hr );
357+
358+
hr = ISpObjectTokenEnumBuilder_SetAttribs( token_enum, NULL, NULL );
359+
ok( hr == S_OK, "got %08lx\n", hr );
360+
hr = ISpObjectTokenEnumBuilder_AddTokens( token_enum, 3, tokens );
361+
ok( hr == S_OK, "got %08lx\n", hr );
362+
363+
hr = ISpeechObjectTokens_get__NewEnum( speech_tokens, &unk );
364+
ok( hr == S_OK, "got %08lx\n", hr );
365+
hr = IUnknown_QueryInterface( unk, &IID_IEnumVARIANT, (void **)&enumvar );
366+
ok( hr == S_OK, "got %08lx\n", hr );
367+
IUnknown_Release( unk );
368+
IEnumVARIANT_Release( enumvar );
369+
370+
ISpeechObjectTokens_Release( speech_tokens );
371+
ISpObjectTokenEnumBuilder_Release( token_enum );
372+
373+
hr = CoCreateInstance( &CLSID_SpObjectTokenEnum, NULL, CLSCTX_INPROC_SERVER,
374+
&IID_ISpObjectTokenEnumBuilder, (void **)&token_enum );
375+
ok( hr == S_OK, "got %08lx\n", hr );
376+
351377
/* Vendor attribute must exist */
352378
hr = ISpObjectTokenEnumBuilder_SetAttribs( token_enum, L"Vendor", NULL );
353379
ok( hr == S_OK, "got %08lx\n", hr );

dlls/sapi/token.c

+115-2
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,20 @@ static struct token_enum *impl_from_ISpeechObjectTokens( ISpeechObjectTokens *if
599599
return CONTAINING_RECORD( iface, struct token_enum, ISpeechObjectTokens_iface );
600600
}
601601

602+
struct enum_var
603+
{
604+
IEnumVARIANT IEnumVARIANT_iface;
605+
LONG ref;
606+
607+
ISpObjectTokenEnumBuilder *token_enum;
608+
ULONG index;
609+
};
610+
611+
static struct enum_var *impl_from_IEnumVARIANT( IEnumVARIANT *iface )
612+
{
613+
return CONTAINING_RECORD( iface, struct enum_var, IEnumVARIANT_iface );
614+
}
615+
602616
static HRESULT WINAPI token_category_EnumTokens( ISpObjectTokenCategory *iface,
603617
LPCWSTR req, LPCWSTR opt,
604618
IEnumSpObjectTokens **enum_tokens )
@@ -1145,6 +1159,86 @@ const struct ISpObjectTokenEnumBuilderVtbl token_enum_vtbl =
11451159
token_enum_Sort
11461160
};
11471161

1162+
static HRESULT WINAPI enum_var_QueryInterface( IEnumVARIANT *iface,
1163+
REFIID iid, void **obj )
1164+
{
1165+
struct enum_var *This = impl_from_IEnumVARIANT( iface );
1166+
1167+
TRACE( "(%p)->(%s %p)\n", This, debugstr_guid( iid ), obj );
1168+
1169+
if (IsEqualIID( iid, &IID_IUnknown ) ||
1170+
IsEqualIID( iid, &IID_IEnumVARIANT ))
1171+
{
1172+
IEnumVARIANT_AddRef( iface );
1173+
*obj = iface;
1174+
return S_OK;
1175+
}
1176+
1177+
*obj = NULL;
1178+
FIXME( "interface %s not implemented\n", debugstr_guid( iid ) );
1179+
return E_NOINTERFACE;
1180+
}
1181+
1182+
static ULONG WINAPI enum_var_AddRef( IEnumVARIANT *iface )
1183+
{
1184+
struct enum_var *This = impl_from_IEnumVARIANT( iface );
1185+
ULONG ref = InterlockedIncrement( &This->ref );
1186+
1187+
TRACE( "(%p) ref = %lu\n", This, ref );
1188+
return ref;
1189+
}
1190+
1191+
static ULONG WINAPI enum_var_Release( IEnumVARIANT *iface )
1192+
{
1193+
struct enum_var *This = impl_from_IEnumVARIANT( iface );
1194+
ULONG ref = InterlockedDecrement( &This->ref );
1195+
1196+
TRACE( "(%p) ref = %lu\n", This, ref );
1197+
1198+
if (!ref)
1199+
{
1200+
ISpObjectTokenEnumBuilder_Release( This->token_enum );
1201+
free( This );
1202+
}
1203+
return ref;
1204+
}
1205+
1206+
static HRESULT WINAPI enum_var_Next( IEnumVARIANT *iface, ULONG count,
1207+
VARIANT *vars, ULONG *fetched )
1208+
{
1209+
FIXME( "stub\n" );
1210+
return E_NOTIMPL;
1211+
}
1212+
1213+
static HRESULT WINAPI enum_var_Skip( IEnumVARIANT *iface, ULONG count )
1214+
{
1215+
FIXME( "stub\n" );
1216+
return E_NOTIMPL;
1217+
}
1218+
1219+
static HRESULT WINAPI enum_var_Reset( IEnumVARIANT *iface )
1220+
{
1221+
FIXME( "stub\n" );
1222+
return E_NOTIMPL;
1223+
}
1224+
1225+
static HRESULT WINAPI enum_var_Clone( IEnumVARIANT *iface, IEnumVARIANT **new_enum )
1226+
{
1227+
FIXME( "stub\n" );
1228+
return E_NOTIMPL;
1229+
}
1230+
1231+
static const IEnumVARIANTVtbl enum_var_vtbl =
1232+
{
1233+
enum_var_QueryInterface,
1234+
enum_var_AddRef,
1235+
enum_var_Release,
1236+
enum_var_Next,
1237+
enum_var_Skip,
1238+
enum_var_Reset,
1239+
enum_var_Clone
1240+
};
1241+
11481242
static HRESULT WINAPI speech_tokens_QueryInterface( ISpeechObjectTokens *iface,
11491243
REFIID iid, void **obj )
11501244
{
@@ -1233,8 +1327,27 @@ static HRESULT WINAPI speech_tokens_Item( ISpeechObjectTokens *iface,
12331327
static HRESULT WINAPI speech_tokens_get__NewEnum( ISpeechObjectTokens *iface,
12341328
IUnknown **new_enum )
12351329
{
1236-
FIXME( "stub\n" );
1237-
return E_NOTIMPL;
1330+
struct enum_var *enum_var;
1331+
HRESULT hr;
1332+
1333+
TRACE( "(%p)->(%p)\n", iface, new_enum );
1334+
1335+
if (!new_enum) return E_POINTER;
1336+
if (!(enum_var = malloc( sizeof(*enum_var) ))) return E_OUTOFMEMORY;
1337+
1338+
enum_var->IEnumVARIANT_iface.lpVtbl = &enum_var_vtbl;
1339+
enum_var->ref = 1;
1340+
enum_var->index = 0;
1341+
if (FAILED(hr = ISpeechObjectTokens_QueryInterface( iface, &IID_ISpObjectTokenEnumBuilder,
1342+
(void **)&enum_var->token_enum )))
1343+
{
1344+
free( enum_var );
1345+
return hr;
1346+
}
1347+
1348+
*new_enum = (IUnknown *)&enum_var->IEnumVARIANT_iface;
1349+
1350+
return S_OK;
12381351
}
12391352

12401353
static const ISpeechObjectTokensVtbl speech_tokens_vtbl =

0 commit comments

Comments
 (0)