arguments.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * Copyright 2011 Michal Zietek
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  17. */
  18. #include <stdarg.h>
  19. #define COBJMACROS
  20. #define CONST_VTABLE
  21. #include <windef.h>
  22. #include <winbase.h>
  23. #include <ole2.h>
  24. #include "wscript.h"
  25. #include <wine/debug.h>
  26. WINE_DEFAULT_DEBUG_CHANNEL(wscript);
  27. WCHAR **argums;
  28. int numOfArgs;
  29. static HRESULT WINAPI Arguments2_QueryInterface(IArguments2 *iface, REFIID riid, void **ppv)
  30. {
  31. WINE_TRACE("(%s %p)\n", wine_dbgstr_guid(riid), ppv);
  32. if(IsEqualGUID(&IID_IUnknown, riid)
  33. || IsEqualGUID(&IID_IDispatch, riid)
  34. || IsEqualGUID(&IID_IArguments2, riid)) {
  35. *ppv = iface;
  36. return S_OK;
  37. }
  38. *ppv = NULL;
  39. return E_NOINTERFACE;
  40. }
  41. static ULONG WINAPI Arguments2_AddRef(IArguments2 *iface)
  42. {
  43. return 2;
  44. }
  45. static ULONG WINAPI Arguments2_Release(IArguments2 *iface)
  46. {
  47. return 1;
  48. }
  49. static HRESULT WINAPI Arguments2_GetTypeInfoCount(IArguments2 *iface, UINT *pctinfo)
  50. {
  51. WINE_TRACE("(%p)\n", pctinfo);
  52. *pctinfo = 1;
  53. return S_OK;
  54. }
  55. static HRESULT WINAPI Arguments2_GetTypeInfo(IArguments2 *iface, UINT iTInfo, LCID lcid,
  56. ITypeInfo **ppTInfo)
  57. {
  58. WINE_TRACE("(%x %x %p\n", iTInfo, lcid, ppTInfo);
  59. ITypeInfo_AddRef(arguments_ti);
  60. *ppTInfo = arguments_ti;
  61. return S_OK;
  62. }
  63. static HRESULT WINAPI Arguments2_GetIDsOfNames(IArguments2 *iface, REFIID riid, LPOLESTR *rgszNames,
  64. UINT cNames, LCID lcid, DISPID *rgDispId)
  65. {
  66. WINE_TRACE("(%s %p %d %x %p)\n", wine_dbgstr_guid(riid), rgszNames,
  67. cNames, lcid, rgDispId);
  68. return ITypeInfo_GetIDsOfNames(arguments_ti, rgszNames, cNames, rgDispId);
  69. }
  70. static HRESULT WINAPI Arguments2_Invoke(IArguments2 *iface, DISPID dispIdMember, REFIID riid,
  71. LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
  72. EXCEPINFO *pExcepInfo, UINT *puArgErr)
  73. {
  74. WINE_TRACE("(%d %p %p)\n", dispIdMember, pDispParams, pVarResult);
  75. return ITypeInfo_Invoke(arguments_ti, iface, dispIdMember, wFlags, pDispParams,
  76. pVarResult, pExcepInfo, puArgErr);
  77. }
  78. static HRESULT WINAPI Arguments2_Item(IArguments2 *iface, LONG index, BSTR *out_Value)
  79. {
  80. WINE_TRACE("(%d %p)\n", index, out_Value);
  81. if(index<0 || index >= numOfArgs)
  82. return E_INVALIDARG;
  83. if(!(*out_Value = SysAllocString(argums[index])))
  84. return E_OUTOFMEMORY;
  85. return S_OK;
  86. }
  87. static HRESULT WINAPI Arguments2_Count(IArguments2 *iface, LONG *out_Count)
  88. {
  89. WINE_TRACE("(%p)\n", out_Count);
  90. *out_Count = numOfArgs;
  91. return S_OK;
  92. }
  93. static HRESULT WINAPI Arguments2_get_length(IArguments2 *iface, LONG *out_Count)
  94. {
  95. WINE_TRACE("(%p)\n", out_Count);
  96. *out_Count = numOfArgs;
  97. return S_OK;
  98. }
  99. static const IArguments2Vtbl Arguments2Vtbl = {
  100. Arguments2_QueryInterface,
  101. Arguments2_AddRef,
  102. Arguments2_Release,
  103. Arguments2_GetTypeInfoCount,
  104. Arguments2_GetTypeInfo,
  105. Arguments2_GetIDsOfNames,
  106. Arguments2_Invoke,
  107. Arguments2_Item,
  108. Arguments2_Count,
  109. Arguments2_get_length
  110. };
  111. IArguments2 arguments_obj = { &Arguments2Vtbl };