ReactOS 0.4.16-dev-297-gc569aee
caller.c File Reference
#include <stdio.h>
#include <ole2.h>
#include <dispex.h>
#include <activscp.h>
#include <objsafe.h>
#include "wine/test.h"
Include dependency graph for caller.c:

Go to the source code of this file.

Classes

struct  conv_results_t
 

Macros

#define COBJMACROS
 
#define CONST_VTABLE
 
#define IActiveScriptParse_QueryInterface   IActiveScriptParse32_QueryInterface
 
#define IActiveScriptParse_Release   IActiveScriptParse32_Release
 
#define IActiveScriptParse_InitNew   IActiveScriptParse32_InitNew
 
#define IActiveScriptParse_ParseScriptText   IActiveScriptParse32_ParseScriptText
 
#define DEFINE_EXPECT(func)    static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
 
#define SET_EXPECT(func)    expect_ ## func = TRUE
 
#define CHECK_EXPECT2(func)
 
#define CHECK_EXPECT(func)
 
#define CHECK_CALLED(func)
 
#define DISPID_TEST_TESTARGCONV   0x1000
 
#define call_change_type(a, b, c, d)   _call_change_type(__LINE__,a,b,c,d)
 
#define change_type_fail(a, b, c, d)   _change_type_fail(__LINE__,a,b,c,d)
 
#define parse_script_a(p, s)   _parse_script_a(__LINE__,p,s)
 

Functions

 DEFINE_EXPECT (testArgConv)
 
static BSTR a2bstr (const char *str)
 
static int strcmp_wa (LPCWSTR strw, const char *stra)
 
static void _call_change_type (unsigned line, IVariantChangeType *change_type, VARIANT *dst, VARIANT *src, VARTYPE vt)
 
static void _change_type_fail (unsigned line, IVariantChangeType *change_type, VARIANT *src, VARTYPE vt, HRESULT exhres)
 
static void test_change_type (IVariantChangeType *change_type, VARIANT *src, const conv_results_t *ex)
 
static void test_change_types (IVariantChangeType *change_type, IDispatch *obj_disp)
 
static void test_caller (IServiceProvider *caller, IDispatch *arg_obj)
 
static HRESULT WINAPI DispatchEx_QueryInterface (IDispatchEx *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI DispatchEx_AddRef (IDispatchEx *iface)
 
static ULONG WINAPI DispatchEx_Release (IDispatchEx *iface)
 
static HRESULT WINAPI DispatchEx_GetTypeInfoCount (IDispatchEx *iface, UINT *pctinfo)
 
static HRESULT WINAPI DispatchEx_GetTypeInfo (IDispatchEx *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
 
static HRESULT WINAPI DispatchEx_GetIDsOfNames (IDispatchEx *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
 
static HRESULT WINAPI DispatchEx_Invoke (IDispatchEx *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
 
static HRESULT WINAPI DispatchEx_DeleteMemberByName (IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
 
static HRESULT WINAPI DispatchEx_DeleteMemberByDispID (IDispatchEx *iface, DISPID id)
 
static HRESULT WINAPI DispatchEx_GetMemberProperties (IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
 
static HRESULT WINAPI DispatchEx_GetMemberName (IDispatchEx *iface, DISPID id, BSTR *pbstrName)
 
static HRESULT WINAPI DispatchEx_GetNextDispID (IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
 
static HRESULT WINAPI DispatchEx_GetNameSpaceParent (IDispatchEx *iface, IUnknown **ppunk)
 
static HRESULT WINAPI Test_GetDispID (IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
 
static HRESULT WINAPI Test_InvokeEx (IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp, VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
 
static HRESULT WINAPI ActiveScriptSite_QueryInterface (IActiveScriptSite *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI ActiveScriptSite_AddRef (IActiveScriptSite *iface)
 
static ULONG WINAPI ActiveScriptSite_Release (IActiveScriptSite *iface)
 
static HRESULT WINAPI ActiveScriptSite_GetLCID (IActiveScriptSite *iface, LCID *plcid)
 
static HRESULT WINAPI ActiveScriptSite_GetItemInfo (IActiveScriptSite *iface, LPCOLESTR pstrName, DWORD dwReturnMask, IUnknown **ppiunkItem, ITypeInfo **ppti)
 
static HRESULT WINAPI ActiveScriptSite_GetDocVersionString (IActiveScriptSite *iface, BSTR *pbstrVersion)
 
static HRESULT WINAPI ActiveScriptSite_OnScriptTerminate (IActiveScriptSite *iface, const VARIANT *pvarResult, const EXCEPINFO *pexcepinfo)
 
static HRESULT WINAPI ActiveScriptSite_OnStateChange (IActiveScriptSite *iface, SCRIPTSTATE ssScriptState)
 
static HRESULT WINAPI ActiveScriptSite_OnScriptError (IActiveScriptSite *iface, IActiveScriptError *pscripterror)
 
static HRESULT WINAPI ActiveScriptSite_OnEnterScript (IActiveScriptSite *iface)
 
static HRESULT WINAPI ActiveScriptSite_OnLeaveScript (IActiveScriptSite *iface)
 
static void _parse_script_a (unsigned line, IActiveScriptParse *parser, const char *script)
 
static IActiveScriptParse * create_script (void)
 
static void run_scripts (void)
 
static BOOL check_jscript (void)
 
 START_TEST (caller)
 

Variables

static const CLSID CLSID_JScript
 
static const WCHAR testW [] = {'t','e','s','t',0}
 
static IVariantChangeTypescript_change_type
 
static IDispatchstored_obj
 
static IDispatchExVtbl testObjVtbl
 
static IDispatchEx testObj = { &testObjVtbl }
 
static const IActiveScriptSiteVtbl ActiveScriptSiteVtbl
 
static IActiveScriptSite ActiveScriptSite = { &ActiveScriptSiteVtbl }
 

Macro Definition Documentation

◆ call_change_type

#define call_change_type (   a,
  b,
  c,
  d 
)    _call_change_type(__LINE__,a,b,c,d)

Definition at line 110 of file caller.c.

◆ change_type_fail

#define change_type_fail (   a,
  b,
  c,
  d 
)    _change_type_fail(__LINE__,a,b,c,d)

Definition at line 121 of file caller.c.

◆ CHECK_CALLED

#define CHECK_CALLED (   func)
Value:
do { \
ok(called_ ## func, "expected " #func "\n"); \
expect_ ## func = called_ ## func = FALSE; \
}while(0)
#define FALSE
Definition: types.h:117
GLenum func
Definition: glext.h:6028
#define expect_(expected, got, precision)
Definition: font.c:29

Definition at line 68 of file caller.c.

◆ CHECK_EXPECT

#define CHECK_EXPECT (   func)
Value:
do { \
CHECK_EXPECT2(func); \
expect_ ## func = FALSE; \
}while(0)

Definition at line 62 of file caller.c.

◆ CHECK_EXPECT2

#define CHECK_EXPECT2 (   func)
Value:
do { \
ok(expect_ ##func, "unexpected call " #func "\n"); \
called_ ## func = TRUE; \
}while(0)
#define TRUE
Definition: types.h:120

Definition at line 56 of file caller.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file caller.c.

◆ CONST_VTABLE

#define CONST_VTABLE

Definition at line 22 of file caller.c.

◆ DEFINE_EXPECT

#define DEFINE_EXPECT (   func)     static BOOL expect_ ## func = FALSE, called_ ## func = FALSE

Definition at line 50 of file caller.c.

◆ DISPID_TEST_TESTARGCONV

#define DISPID_TEST_TESTARGCONV   0x1000

Definition at line 81 of file caller.c.

◆ IActiveScriptParse_InitNew

#define IActiveScriptParse_InitNew   IActiveScriptParse32_InitNew

Definition at line 42 of file caller.c.

◆ IActiveScriptParse_ParseScriptText

#define IActiveScriptParse_ParseScriptText   IActiveScriptParse32_ParseScriptText

Definition at line 43 of file caller.c.

◆ IActiveScriptParse_QueryInterface

#define IActiveScriptParse_QueryInterface   IActiveScriptParse32_QueryInterface

Definition at line 40 of file caller.c.

◆ IActiveScriptParse_Release

#define IActiveScriptParse_Release   IActiveScriptParse32_Release

Definition at line 41 of file caller.c.

◆ parse_script_a

#define parse_script_a (   p,
  s 
)    _parse_script_a(__LINE__,p,s)

Definition at line 489 of file caller.c.

◆ SET_EXPECT

#define SET_EXPECT (   func)     expect_ ## func = TRUE

Definition at line 53 of file caller.c.

Function Documentation

◆ _call_change_type()

static void _call_change_type ( unsigned  line,
IVariantChangeType change_type,
VARIANT dst,
VARIANT src,
VARTYPE  vt 
)
static

Definition at line 111 of file caller.c.

112{
114
116 hres = IVariantChangeType_ChangeType(change_type, dst, src, 0, vt);
117 ok_(__FILE__,line)(hres == S_OK, "ChangeType(%d) failed: %08x\n", vt, hres);
118 ok_(__FILE__,line)(V_VT(dst) == vt, "V_VT(dst) = %d\n", V_VT(dst));
119}
#define ok_(x1, x2)
Definition: atltest.h:61
static REFPROPVARIANT PROPVAR_CHANGE_FLAGS VARTYPE vt
Definition: suminfo.c:91
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
#define S_OK
Definition: intsafe.h:52
HRESULT hres
Definition: protocol.c:465
static HRESULT change_type(VARIANT *dst, VARIANT *src, VARTYPE vt, IServiceProvider *caller)
Definition: dispex.c:914
#define V_VT(A)
Definition: oleauto.h:211
Definition: parser.c:49
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:568

◆ _change_type_fail()

static void _change_type_fail ( unsigned  line,
IVariantChangeType change_type,
VARIANT src,
VARTYPE  vt,
HRESULT  exhres 
)
static

Definition at line 122 of file caller.c.

123{
124 VARIANT v;
126
127 V_VT(&v) = VT_EMPTY;
128 hres = IVariantChangeType_ChangeType(change_type, &v, src, 0, vt);
129 ok_(__FILE__,line)(hres == exhres, "ChangeType failed: %08x, expected %08x\n", hres, exhres);
130}
@ VT_EMPTY
Definition: compat.h:2295
const GLdouble * v
Definition: gl.h:2040

◆ _parse_script_a()

static void _parse_script_a ( unsigned  line,
IActiveScriptParse *  parser,
const char script 
)
static

Definition at line 490 of file caller.c.

491{
492 BSTR str;
494
495 str = a2bstr(script);
498 ok_(__FILE__,line)(hres == S_OK, "ParseScriptText failed: %08x\n", hres);
499}
#define IActiveScriptParse_ParseScriptText
Definition: caller.c:43
static BSTR a2bstr(const char *str)
Definition: caller.c:83
#define NULL
Definition: types.h:112
OLECHAR * BSTR
Definition: compat.h:2293
script
Definition: msipriv.h:383
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
const WCHAR * str
Definition: import.c:81

◆ a2bstr()

static BSTR a2bstr ( const char str)
static

Definition at line 83 of file caller.c.

84{
85 BSTR ret;
86 int len;
87
88 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
91
92 return ret;
93}
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
GLenum GLsizei len
Definition: glext.h:6722
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:339
int ret

Referenced by _parse_script_a(), check_jscript(), and test_change_types().

◆ ActiveScriptSite_AddRef()

static ULONG WINAPI ActiveScriptSite_AddRef ( IActiveScriptSite iface)
static

Definition at line 415 of file caller.c.

416{
417 return 2;
418}

◆ ActiveScriptSite_GetDocVersionString()

static HRESULT WINAPI ActiveScriptSite_GetDocVersionString ( IActiveScriptSite iface,
BSTR pbstrVersion 
)
static

Definition at line 442 of file caller.c.

443{
444 return E_NOTIMPL;
445}
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ ActiveScriptSite_GetItemInfo()

static HRESULT WINAPI ActiveScriptSite_GetItemInfo ( IActiveScriptSite iface,
LPCOLESTR  pstrName,
DWORD  dwReturnMask,
IUnknown **  ppiunkItem,
ITypeInfo **  ppti 
)
static

Definition at line 431 of file caller.c.

433{
434 ok(dwReturnMask == SCRIPTINFO_IUNKNOWN, "unexpected dwReturnMask %x\n", dwReturnMask);
435 ok(!ppti, "ppti != NULL\n");
436 ok(!strcmp_wa(pstrName, "test"), "pstrName = %s\n", wine_dbgstr_w(pstrName));
437
438 *ppiunkItem = (IUnknown*)&testObj;
439 return S_OK;
440}
#define ok(value,...)
Definition: atltest.h:57
static int strcmp_wa(LPCWSTR strw, const char *stra)
Definition: caller.c:95
static IDispatchEx testObj
Definition: caller.c:398
#define wine_dbgstr_w
Definition: kernel32.h:34

◆ ActiveScriptSite_GetLCID()

static HRESULT WINAPI ActiveScriptSite_GetLCID ( IActiveScriptSite iface,
LCID plcid 
)
static

Definition at line 425 of file caller.c.

426{
427 *plcid = GetUserDefaultLCID();
428 return S_OK;
429}
LCID WINAPI GetUserDefaultLCID(void)
Definition: locale.c:1211

◆ ActiveScriptSite_OnEnterScript()

static HRESULT WINAPI ActiveScriptSite_OnEnterScript ( IActiveScriptSite iface)
static

Definition at line 463 of file caller.c.

464{
465 return E_NOTIMPL;
466}

◆ ActiveScriptSite_OnLeaveScript()

static HRESULT WINAPI ActiveScriptSite_OnLeaveScript ( IActiveScriptSite iface)
static

Definition at line 468 of file caller.c.

469{
470 return E_NOTIMPL;
471}

◆ ActiveScriptSite_OnScriptError()

static HRESULT WINAPI ActiveScriptSite_OnScriptError ( IActiveScriptSite iface,
IActiveScriptError pscripterror 
)
static

Definition at line 458 of file caller.c.

459{
460 return E_NOTIMPL;
461}

◆ ActiveScriptSite_OnScriptTerminate()

static HRESULT WINAPI ActiveScriptSite_OnScriptTerminate ( IActiveScriptSite iface,
const VARIANT pvarResult,
const EXCEPINFO *  pexcepinfo 
)
static

Definition at line 447 of file caller.c.

449{
450 return E_NOTIMPL;
451}

◆ ActiveScriptSite_OnStateChange()

static HRESULT WINAPI ActiveScriptSite_OnStateChange ( IActiveScriptSite iface,
SCRIPTSTATE  ssScriptState 
)
static

Definition at line 453 of file caller.c.

454{
455 return E_NOTIMPL;
456}

◆ ActiveScriptSite_QueryInterface()

static HRESULT WINAPI ActiveScriptSite_QueryInterface ( IActiveScriptSite iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 400 of file caller.c.

401{
403 *ppv = iface;
404 }else if(IsEqualGUID(&IID_IActiveScriptSite, riid)) {
405 *ppv = iface;
406 }else {
407 *ppv = NULL;
408 return E_NOINTERFACE;
409 }
410
411 IUnknown_AddRef((IUnknown*)*ppv);
412 return S_OK;
413}
const GUID IID_IUnknown
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ ActiveScriptSite_Release()

static ULONG WINAPI ActiveScriptSite_Release ( IActiveScriptSite iface)
static

Definition at line 420 of file caller.c.

421{
422 return 1;
423}

◆ check_jscript()

static BOOL check_jscript ( void  )
static

Definition at line 559 of file caller.c.

560{
561 IActiveScriptProperty *script_prop;
562 IActiveScriptParse *parser;
563 BSTR str;
565
567 if(!parser)
568 return FALSE;
569
570 str = a2bstr("if(!('localeCompare' in String.prototype)) throw 1;");
573
574 if(hres == S_OK)
575 hres = IActiveScriptParse_QueryInterface(parser, &IID_IActiveScriptProperty, (void**)&script_prop);
577 if(hres == S_OK)
578 IActiveScriptProperty_Release(script_prop);
579
580 return hres == S_OK;
581}
static IActiveScriptParse * create_script(void)
Definition: caller.c:501
#define IActiveScriptParse_Release
Definition: caller.c:41
#define IActiveScriptParse_QueryInterface
Definition: caller.c:40

Referenced by START_TEST().

◆ create_script()

static IActiveScriptParse * create_script ( void  )
static

Definition at line 501 of file caller.c.

502{
503 IActiveScriptParse *parser;
506
507 hres = CoCreateInstance(&CLSID_JScript, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
508 &IID_IActiveScript, (void**)&script);
509 if(FAILED(hres))
510 return NULL;
511
512 hres = IActiveScript_QueryInterface(script, &IID_IActiveScriptParse, (void**)&parser);
513 ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres);
514
516 ok(hres == S_OK, "InitNew failed: %08x\n", hres);
517
518 hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
519 ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
520
521 hres = IActiveScript_AddNamedItem(script, testW,
522 SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS);
523 ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres);
524
525 hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_STARTED);
526 ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres);
527
528 IActiveScript_Release(script);
529
530 return parser;
531}
@ SCRIPTSTATE_STARTED
Definition: activscp.idl:58
static const WCHAR testW[]
Definition: caller.c:76
static const CLSID CLSID_JScript
Definition: caller.c:47
#define IActiveScriptParse_InitNew
Definition: caller.c:42
static IActiveScriptSite ActiveScriptSite
Definition: caller.c:487
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define FAILED(hr)
Definition: intsafe.h:51

Referenced by check_jscript(), run_scripts(), test_ActiveXObject(), test_CreateObject(), and test_GetObject().

◆ DEFINE_EXPECT()

DEFINE_EXPECT ( testArgConv  )

◆ DispatchEx_AddRef()

static ULONG WINAPI DispatchEx_AddRef ( IDispatchEx iface)
static

Definition at line 262 of file caller.c.

263{
264 return 2;
265}

◆ DispatchEx_DeleteMemberByDispID()

static HRESULT WINAPI DispatchEx_DeleteMemberByDispID ( IDispatchEx iface,
DISPID  id 
)
static

Definition at line 307 of file caller.c.

308{
309 ok(0, "unexpected call\n");
310 return E_NOTIMPL;
311}

◆ DispatchEx_DeleteMemberByName()

static HRESULT WINAPI DispatchEx_DeleteMemberByName ( IDispatchEx iface,
BSTR  bstrName,
DWORD  grfdex 
)
static

Definition at line 301 of file caller.c.

302{
303 ok(0, "unexpected call %s %x\n", wine_dbgstr_w(bstrName), grfdex);
304 return E_NOTIMPL;
305}

◆ DispatchEx_GetIDsOfNames()

static HRESULT WINAPI DispatchEx_GetIDsOfNames ( IDispatchEx iface,
REFIID  riid,
LPOLESTR rgszNames,
UINT  cNames,
LCID  lcid,
DISPID rgDispId 
)
static

Definition at line 285 of file caller.c.

288{
289 ok(0, "unexpected call\n");
290 return E_NOTIMPL;
291}

◆ DispatchEx_GetMemberName()

static HRESULT WINAPI DispatchEx_GetMemberName ( IDispatchEx iface,
DISPID  id,
BSTR pbstrName 
)
static

Definition at line 319 of file caller.c.

320{
321 ok(0, "unexpected call\n");
322 return E_NOTIMPL;
323}

◆ DispatchEx_GetMemberProperties()

static HRESULT WINAPI DispatchEx_GetMemberProperties ( IDispatchEx iface,
DISPID  id,
DWORD  grfdexFetch,
DWORD pgrfdex 
)
static

Definition at line 313 of file caller.c.

314{
315 ok(0, "unexpected call\n");
316 return E_NOTIMPL;
317}

◆ DispatchEx_GetNameSpaceParent()

static HRESULT WINAPI DispatchEx_GetNameSpaceParent ( IDispatchEx iface,
IUnknown **  ppunk 
)
static

Definition at line 331 of file caller.c.

332{
333 ok(0, "unexpected call\n");
334 return E_NOTIMPL;
335}

◆ DispatchEx_GetNextDispID()

static HRESULT WINAPI DispatchEx_GetNextDispID ( IDispatchEx iface,
DWORD  grfdex,
DISPID  id,
DISPID pid 
)
static

Definition at line 325 of file caller.c.

326{
327 ok(0, "unexpected call\n");
328 return E_NOTIMPL;
329}

◆ DispatchEx_GetTypeInfo()

static HRESULT WINAPI DispatchEx_GetTypeInfo ( IDispatchEx iface,
UINT  iTInfo,
LCID  lcid,
ITypeInfo **  ppTInfo 
)
static

Definition at line 278 of file caller.c.

280{
281 ok(0, "unexpected call\n");
282 return E_NOTIMPL;
283}

◆ DispatchEx_GetTypeInfoCount()

static HRESULT WINAPI DispatchEx_GetTypeInfoCount ( IDispatchEx iface,
UINT pctinfo 
)
static

Definition at line 272 of file caller.c.

273{
274 ok(0, "unexpected call\n");
275 return E_NOTIMPL;
276}

◆ DispatchEx_Invoke()

static HRESULT WINAPI DispatchEx_Invoke ( IDispatchEx iface,
DISPID  dispIdMember,
REFIID  riid,
LCID  lcid,
WORD  wFlags,
DISPPARAMS *  pDispParams,
VARIANT pVarResult,
EXCEPINFO *  pExcepInfo,
UINT puArgErr 
)
static

Definition at line 293 of file caller.c.

296{
297 ok(0, "unexpected call\n");
298 return E_NOTIMPL;
299}

◆ DispatchEx_QueryInterface()

static HRESULT WINAPI DispatchEx_QueryInterface ( IDispatchEx iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 246 of file caller.c.

247{
249 *ppv = iface;
250 }else if(IsEqualGUID(riid, &IID_IDispatch) || IsEqualGUID(riid, &IID_IDispatchEx)) {
251 *ppv = iface;
252 }else if(IsEqualGUID(&IID_IObjectSafety, riid)) {
253 ok(0, "Unexpected IID_IObjectSafety query\n");
254 }else {
255 *ppv = NULL;
256 return E_NOINTERFACE;
257 }
258
259 return S_OK;
260}
const GUID IID_IDispatch

◆ DispatchEx_Release()

static ULONG WINAPI DispatchEx_Release ( IDispatchEx iface)
static

Definition at line 267 of file caller.c.

268{
269 return 1;
270}

◆ run_scripts()

static void run_scripts ( void  )
static

Definition at line 533 of file caller.c.

534{
535 IActiveScriptParse *parser;
537
539
540 hres = IActiveScriptParse_QueryInterface(parser, &IID_IVariantChangeType, (void**)&script_change_type);
541 ok(hres == S_OK, "Could not get IVariantChangeType iface: %08x\n", hres);
542
543 SET_EXPECT(testArgConv);
545 "var obj = {"
546 " toString: function() { return 'strval'; },"
547 " valueOf: function() { return 10; }"
548 "};"
549 "testArgConv(obj);");
550 CHECK_CALLED(testArgConv);
551
553 IDispatch_Release(stored_obj);
554 IVariantChangeType_Release(script_change_type);
555
557}
#define SET_EXPECT(func)
Definition: caller.c:53
static IVariantChangeType * script_change_type
Definition: caller.c:78
#define parse_script_a(p, s)
Definition: caller.c:489
static void test_change_types(IVariantChangeType *change_type, IDispatch *obj_disp)
Definition: caller.c:171
#define CHECK_CALLED(func)
Definition: caller.c:68
static IDispatch * stored_obj
Definition: caller.c:79

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( caller  )

Definition at line 583 of file caller.c.

584{
586
587 if(check_jscript())
588 run_scripts();
589 else
590 win_skip("Broken (too old) jscript\n");
591
593}
static BOOL check_jscript(void)
Definition: caller.c:559
static void run_scripts(void)
Definition: caller.c:533
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define win_skip
Definition: test.h:163

◆ strcmp_wa()

static int strcmp_wa ( LPCWSTR  strw,
const char stra 
)
static

Definition at line 95 of file caller.c.

96{
97 CHAR buf[512];
98 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), 0, 0);
99 return lstrcmpA(buf, stra);
100}
#define WideCharToMultiByte
Definition: compat.h:111
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4195
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static const char * strw(LPCWSTR x)
Definition: actctx.c:49
char CHAR
Definition: xmlstorage.h:175

Referenced by ActiveScriptSite_GetItemInfo(), test_change_type(), test_change_types(), and Test_GetDispID().

◆ test_caller()

static void test_caller ( IServiceProvider caller,
IDispatch arg_obj 
)
static

Definition at line 232 of file caller.c.

233{
236
237 hres = IServiceProvider_QueryService(caller, &SID_VariantConversion, &IID_IVariantChangeType, (void**)&change_type);
238 ok(hres == S_OK, "Could not get SID_VariantConversion service: %08x\n", hres);
239
240 ok(change_type == script_change_type, "change_type != script_change_type\n");
242
243 IVariantChangeType_Release(change_type);
244}

Referenced by Test_InvokeEx().

◆ test_change_type()

static void test_change_type ( IVariantChangeType change_type,
VARIANT src,
const conv_results_t ex 
)
static

Definition at line 132 of file caller.c.

133{
134 VARIANT v;
135
137 ok(V_I4(&v) == ex->int_result, "V_I4(v) = %d, expected %d\n", V_I4(&v), ex->int_result);
138
140 ok(V_UI2(&v) == (UINT16)ex->int_result, "V_UI2(v) = %u, expected %u\n", V_UI2(&v), (UINT16)ex->int_result);
141
143 ok(!strcmp_wa(V_BSTR(&v), ex->str_result), "V_BSTR(v) = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v)), ex->str_result);
144 VariantClear(&v);
145
147 ok(V_BOOL(&v) == ex->bool_result, "V_BOOL(v) = %x, expected %x\n", V_BOOL(&v), ex->bool_result);
148
149 if(ex->test_double) {
151 ok(V_R8(&v) == ex->double_result, "V_R8(v) = %lf, expected %lf\n", V_R8(&v), ex->double_result);
152
154 ok(V_R4(&v) == (float)ex->double_result, "V_R4(v) = %f, expected %f\n", V_R4(&v), (float)ex->double_result);
155 }
156
157 if(V_VT(src) == VT_NULL)
159 else
161
162 if(V_VT(src) == VT_EMPTY)
164 else
166
168 ok(V_I2(&v) == (INT16)ex->int_result, "V_I2(v) = %d, expected %d\n", V_I2(&v), ex->int_result);
169}
unsigned short UINT16
signed short INT16
#define call_change_type(a, b, c, d)
Definition: caller.c:110
#define change_type_fail(a, b, c, d)
Definition: caller.c:121
@ VT_BSTR
Definition: compat.h:2303
@ VT_R4
Definition: compat.h:2299
@ VT_NULL
Definition: compat.h:2296
@ VT_UI2
Definition: compat.h:2312
@ VT_R8
Definition: compat.h:2300
@ VT_I4
Definition: compat.h:2298
@ VT_BOOL
Definition: compat.h:2306
@ VT_I2
Definition: compat.h:2297
#define V_BOOL(A)
Definition: oleauto.h:224
#define V_UI2(A)
Definition: oleauto.h:268
#define V_BSTR(A)
Definition: oleauto.h:226
#define V_I4(A)
Definition: oleauto.h:247
#define V_R4(A)
Definition: oleauto.h:260
#define V_R8(A)
Definition: oleauto.h:262
#define V_I2(A)
Definition: oleauto.h:245
Definition: comerr.c:44
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648

Referenced by test_change_types().

◆ test_change_types()

static void test_change_types ( IVariantChangeType change_type,
IDispatch obj_disp 
)
static

Definition at line 171 of file caller.c.

172{
173 VARIANT v, dst;
174 BSTR str;
176
177 static const conv_results_t bool_results[] = {
178 {0, "false", VARIANT_FALSE, 1,0.0},
179 {1, "true", VARIANT_TRUE, 1,1.0}};
180 static const conv_results_t int_results[] = {
181 {0, "0", VARIANT_FALSE, 1,0.0},
182 {-100, "-100", VARIANT_TRUE, 1,-100.0},
183 {0x10010, "65552", VARIANT_TRUE, 1,65552.0}};
184 static const conv_results_t empty_results =
185 {0, "undefined", VARIANT_FALSE, 0,0};
186 static const conv_results_t null_results =
187 {0, "null", VARIANT_FALSE, 0,0};
188 static const conv_results_t obj_results =
189 {10, "strval", VARIANT_TRUE, 1,10.0};
190
191 V_VT(&v) = VT_BOOL;
192 V_BOOL(&v) = VARIANT_FALSE;
193 test_change_type(change_type, &v, bool_results);
194 V_BOOL(&v) = VARIANT_TRUE;
195 test_change_type(change_type, &v, bool_results+1);
196
197 V_VT(&v) = VT_I4;
198 V_I4(&v) = 0;
199 test_change_type(change_type, &v, int_results);
200 V_I4(&v) = -100;
201 test_change_type(change_type, &v, int_results+1);
202 V_I4(&v) = 0x10010;
203 test_change_type(change_type, &v, int_results+2);
204
205 V_VT(&v) = VT_EMPTY;
206 test_change_type(change_type, &v, &empty_results);
207
208 V_VT(&v) = VT_NULL;
209 test_change_type(change_type, &v, &null_results);
210
211 V_VT(&v) = VT_DISPATCH;
212 V_DISPATCH(&v) = obj_disp;
213 test_change_type(change_type, &v, &obj_results);
214
215 V_VT(&v) = VT_BOOL;
216 V_BOOL(&v) = VARIANT_FALSE;
217 V_VT(&dst) = 0xdead;
218 hres = IVariantChangeType_ChangeType(change_type, &dst, &v, 0, VT_I4);
219 ok(hres == DISP_E_BADVARTYPE, "ChangeType failed: %08x, expected DISP_E_BADVARTYPE\n", hres);
220 ok(V_VT(&dst) == 0xdead, "V_VT(dst) = %d\n", V_VT(&dst));
221
222 /* Test conversion in place */
223 V_VT(&v) = VT_BSTR;
224 V_BSTR(&v) = str = a2bstr("test");
225 hres = IVariantChangeType_ChangeType(change_type, &v, &v, 0, VT_BSTR);
226 ok(hres == S_OK, "ChangeType failed: %08x\n", hres);
227 ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
228 ok(V_BSTR(&v) != str, "V_BSTR(v) == str\n");
229 ok(!strcmp_wa(V_BSTR(&v), "test"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
230}
static void test_change_type(IVariantChangeType *change_type, VARIANT *src, const conv_results_t *ex)
Definition: caller.c:132
@ VT_DISPATCH
Definition: compat.h:2304
#define V_DISPATCH(A)
Definition: oleauto.h:239
#define DISP_E_BADVARTYPE
Definition: winerror.h:2517

Referenced by run_scripts(), and test_caller().

◆ Test_GetDispID()

static HRESULT WINAPI Test_GetDispID ( IDispatchEx iface,
BSTR  bstrName,
DWORD  grfdex,
DISPID pid 
)
static

Definition at line 337 of file caller.c.

338{
339 if(!strcmp_wa(bstrName, "testArgConv")) {
340 ok(grfdex == fdexNameCaseSensitive, "grfdex = %x\n", grfdex);
342 return S_OK;
343 }
344
345 return E_NOTIMPL;
346}
#define DISPID_TEST_TESTARGCONV
Definition: caller.c:81
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3837

◆ Test_InvokeEx()

static HRESULT WINAPI Test_InvokeEx ( IDispatchEx iface,
DISPID  id,
LCID  lcid,
WORD  wFlags,
DISPPARAMS *  pdp,
VARIANT pvarRes,
EXCEPINFO *  pei,
IServiceProvider pspCaller 
)
static

Definition at line 348 of file caller.c.

350{
351 ok(pspCaller != NULL, "pspCaller == NULL\n");
352
353 switch(id) {
355 CHECK_EXPECT(testArgConv);
356
357 ok(wFlags == INVOKE_FUNC, "wFlags = %x\n", wFlags);
358 ok(pdp != NULL, "pdp == NULL\n");
359 ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n");
360 ok(!pvarRes, "pvarRes != NULL\n");
361 ok(pei != NULL, "pei == NULL\n");
362
363 ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs);
364 ok(V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(rgvarg) = %d\n", V_VT(pdp->rgvarg));
365
366 test_caller(pspCaller, V_DISPATCH(pdp->rgvarg));
367
368 stored_obj = V_DISPATCH(pdp->rgvarg);
369 IDispatch_AddRef(stored_obj);
370 break;
371
372 default:
373 ok(0, "unexpected call\n");
374 return E_NOTIMPL;
375 }
376
377 return S_OK;
378}
static void test_caller(IServiceProvider *caller, IDispatch *arg_obj)
Definition: caller.c:232
#define CHECK_EXPECT(func)
Definition: caller.c:62
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:531

Variable Documentation

◆ ActiveScriptSite

IActiveScriptSite ActiveScriptSite = { &ActiveScriptSiteVtbl }
static

Definition at line 487 of file caller.c.

Referenced by create_script().

◆ ActiveScriptSiteVtbl

const IActiveScriptSiteVtbl ActiveScriptSiteVtbl
static
Initial value:
= {
}
static ULONG WINAPI ActiveScriptSite_Release(IActiveScriptSite *iface)
Definition: caller.c:420
static HRESULT WINAPI ActiveScriptSite_OnLeaveScript(IActiveScriptSite *iface)
Definition: caller.c:468
static HRESULT WINAPI ActiveScriptSite_OnStateChange(IActiveScriptSite *iface, SCRIPTSTATE ssScriptState)
Definition: caller.c:453
static HRESULT WINAPI ActiveScriptSite_GetDocVersionString(IActiveScriptSite *iface, BSTR *pbstrVersion)
Definition: caller.c:442
static HRESULT WINAPI ActiveScriptSite_GetItemInfo(IActiveScriptSite *iface, LPCOLESTR pstrName, DWORD dwReturnMask, IUnknown **ppiunkItem, ITypeInfo **ppti)
Definition: caller.c:431
static HRESULT WINAPI ActiveScriptSite_QueryInterface(IActiveScriptSite *iface, REFIID riid, void **ppv)
Definition: caller.c:400
static HRESULT WINAPI ActiveScriptSite_OnEnterScript(IActiveScriptSite *iface)
Definition: caller.c:463
static ULONG WINAPI ActiveScriptSite_AddRef(IActiveScriptSite *iface)
Definition: caller.c:415
static HRESULT WINAPI ActiveScriptSite_OnScriptTerminate(IActiveScriptSite *iface, const VARIANT *pvarResult, const EXCEPINFO *pexcepinfo)
Definition: caller.c:447
static HRESULT WINAPI ActiveScriptSite_GetLCID(IActiveScriptSite *iface, LCID *plcid)
Definition: caller.c:425
static HRESULT WINAPI ActiveScriptSite_OnScriptError(IActiveScriptSite *iface, IActiveScriptError *pscripterror)
Definition: caller.c:458

Definition at line 473 of file caller.c.

◆ CLSID_JScript

const CLSID CLSID_JScript
static
Initial value:
=
{0xf414c260,0x6ac0,0x11cf,{0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58}}

Definition at line 47 of file caller.c.

Referenced by create_script().

◆ script_change_type

IVariantChangeType* script_change_type
static

Definition at line 78 of file caller.c.

Referenced by run_scripts(), and test_caller().

◆ stored_obj

IDispatch* stored_obj
static

Definition at line 79 of file caller.c.

Referenced by run_scripts(), and Test_InvokeEx().

◆ testObj

IDispatchEx testObj = { &testObjVtbl }
static

Definition at line 398 of file caller.c.

Referenced by ActiveScriptSite_GetItemInfo().

◆ testObjVtbl

IDispatchExVtbl testObjVtbl
static
Initial value:
= {
}
static HRESULT WINAPI DispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
Definition: caller.c:313
static ULONG WINAPI DispatchEx_Release(IDispatchEx *iface)
Definition: caller.c:267
static HRESULT WINAPI DispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: caller.c:285
static HRESULT WINAPI DispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
Definition: caller.c:307
static HRESULT WINAPI DispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
Definition: caller.c:331
static HRESULT WINAPI DispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
Definition: caller.c:293
static HRESULT WINAPI DispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
Definition: caller.c:319
static HRESULT WINAPI DispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
Definition: caller.c:325
static HRESULT WINAPI Test_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
Definition: caller.c:337
static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
Definition: caller.c:246
static ULONG WINAPI DispatchEx_AddRef(IDispatchEx *iface)
Definition: caller.c:262
static HRESULT WINAPI DispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: caller.c:278
static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
Definition: caller.c:301
static HRESULT WINAPI DispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
Definition: caller.c:272
static HRESULT WINAPI Test_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp, VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
Definition: caller.c:348

Definition at line 380 of file caller.c.

◆ testW

const WCHAR testW[] = {'t','e','s','t',0}
static

Definition at line 76 of file caller.c.

Referenced by create_script().