Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.2 KiB

  1. #ifndef __DISPTCH2_H__
  2. #define __DISPTCH2_H__
  3. #include "dispatch.h"
  4. template <class T>
  5. class ATL_NO_VTABLE CDispatchImpl : public T
  6. {
  7. public:
  8. // IDispatch
  9. STDMETHOD(GetTypeInfoCount)(UINT* pctinfo)
  10. {
  11. *pctinfo = 1;
  12. return S_OK;
  13. }
  14. STDMETHOD(GetTypeInfo)(UINT itinfo, LCID lcid, ITypeInfo** pptinfo)
  15. {
  16. return gm_tih.GetTypeInfo(itinfo, lcid, pptinfo);
  17. }
  18. STDMETHOD(GetIDsOfNames)(REFIID riid, LPOLESTR* rgszNames, UINT cNames,
  19. LCID lcid, DISPID* rgdispid)
  20. {
  21. return gm_tih.GetIDsOfNames(riid, rgszNames, cNames, lcid, rgdispid);
  22. }
  23. STDMETHOD(Invoke)(DISPID dispidMember, REFIID riid,
  24. LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult,
  25. EXCEPINFO* pexcepinfo, UINT* puArgErr)
  26. {
  27. // VBScript does not distinguish between a propget and a method
  28. // implement that behavior for other languages.
  29. //
  30. if (wFlags & (DISPATCH_METHOD | DISPATCH_PROPERTYGET))
  31. wFlags |= DISPATCH_METHOD | DISPATCH_PROPERTYGET;
  32. return gm_tih.Invoke((IDispatch*)this, dispidMember, riid, lcid,
  33. wFlags, pdispparams, pvarResult, pexcepinfo,
  34. puArgErr);
  35. }
  36. protected:
  37. static CComTypeInfoHolder gm_tih;
  38. static HRESULT GetTI(LCID lcid, ITypeInfo** ppInfo)
  39. {
  40. return gm_tih.GetTI(lcid, ppInfo);
  41. }
  42. };
  43. // LIBID_ASPTypeLibrary is version 3.0
  44. template <class T>
  45. CComTypeInfoHolder CDispatchImpl<T>::gm_tih =
  46. {&__uuidof(T), &LIBID_ASPTypeLibrary, 3, 0, NULL, 0, NULL, 0};
  47. typedef CDispatchImpl<IApplicationObject> IApplicationObjectImpl;
  48. typedef CDispatchImpl<IASPError> IASPErrorImpl;
  49. typedef CDispatchImpl<IReadCookie> IReadCookieImpl;
  50. typedef CDispatchImpl<IRequest> IRequestImpl;
  51. typedef CDispatchImpl<IRequestDictionary> IRequestDictionaryImpl;
  52. typedef CDispatchImpl<IResponse> IResponseImpl;
  53. typedef CDispatchImpl<IScriptingContext> IScriptingContextImpl;
  54. typedef CDispatchImpl<IServer> IServerImpl;
  55. typedef CDispatchImpl<ISessionObject> ISessionObjectImpl;
  56. typedef CDispatchImpl<IStringList> IStringListImpl;
  57. typedef CDispatchImpl<IVariantDictionary> IVariantDictionaryImpl;
  58. typedef CDispatchImpl<IWriteCookie> IWriteCookieImpl;
  59. #endif // __DISPTCH2_H__