PythonCOMRegister.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Support for PythonCOM and its extensions to register the interfaces,
  2. // gateways and IIDs it supports.
  3. //
  4. // The module can simply declare an array of type PyCom_InterfaceSupportInfo, then
  5. // use the macros to populate it.
  6. //
  7. // See Register.cpp and AXScript.cpp for examples on its use.
  8. #ifndef __PYTHONCOMREGISTER_H__
  9. #define __PYTHONCOMREGISTER_H__
  10. #include "PythonCOMServer.h" // Need defns in this file...
  11. typedef struct {
  12. const GUID *pGUID; // The supported IID - required
  13. const char *interfaceName; // Name of the interface - required
  14. const char *iidName; // Name of the IID that goes into the dict. - required
  15. PyTypeObject *pTypeOb; // the type object for client PyI* side - NULL for server only support.
  16. pfnPyGatewayConstructor ctor; // Gateway (PyG*) interface constructor - NULL for client only support
  17. } PyCom_InterfaceSupportInfo;
  18. #define PYCOM_INTERFACE_IID_ONLY(ifc) \
  19. { \
  20. &IID_I##ifc, "I" #ifc, "IID_I" #ifc, NULL, NULL \
  21. }
  22. #define PYCOM_INTERFACE_CLSID_ONLY(ifc) \
  23. { \
  24. &CLSID_##ifc, "CLSID_" #ifc, "CLSID_" #ifc, NULL, NULL \
  25. }
  26. #define PYCOM_INTERFACE_CATID_ONLY(ifc) \
  27. { \
  28. &CATID_##ifc, "CATID_" #ifc, "CATID_" #ifc, NULL, NULL \
  29. }
  30. #define PYCOM_INTERFACE_CLIENT_ONLY(ifc) \
  31. { \
  32. &IID_I##ifc, "I" #ifc, "IID_I" #ifc, &PyI##ifc::type, NULL \
  33. }
  34. #define PYCOM_INTERFACE_SERVER_ONLY(ifc) \
  35. { \
  36. &IID_I##ifc, "I" #ifc, "IID_I" #ifc, NULL, GET_PYGATEWAY_CTOR(PyG##ifc) \
  37. }
  38. #define PYCOM_INTERFACE_FULL(ifc) \
  39. { \
  40. &IID_I##ifc, "I" #ifc, "IID_I" #ifc, &PyI##ifc::type, GET_PYGATEWAY_CTOR(PyG##ifc) \
  41. }
  42. // Versions that use __uuidof() to get the IID, which seems to avoid the need
  43. // to link with a lib holding the IIDs. Note that almost all extensions
  44. // build with __uuidof() being the default; the build failed at 'shell' - so
  45. // we could consider making this the default and making the 'explicit' version
  46. // above the special case.
  47. #define PYCOM_INTERFACE_IID_ONLY_UUIDOF(ifc) \
  48. { \
  49. &__uuidof(I##ifc), "I" #ifc, "IID_I" #ifc, NULL, NULL \
  50. }
  51. #define PYCOM_INTERFACE_CLIENT_ONLY_UUIDOF(ifc) \
  52. { \
  53. &__uuidof(I##ifc), "I" #ifc, "IID_I" #ifc, &PyI##ifc::type, NULL \
  54. }
  55. #define PYCOM_INTERFACE_SERVER_ONLY_UUIDOF(ifc) \
  56. { \
  57. &__uuidof(I##ifc), "I" #ifc, "IID_I" #ifc, NULL, GET_PYGATEWAY_CTOR(PyG##ifc) \
  58. }
  59. #define PYCOM_INTERFACE_FULL_UUIDOF(ifc) \
  60. { \
  61. &__uuidof(I##ifc), "I" #ifc, "IID_I" #ifc, &PyI##ifc::type, GET_PYGATEWAY_CTOR(PyG##ifc) \
  62. }
  63. // Prototypes for the register functions
  64. // Register a PythonCOM extension module
  65. PYCOM_EXPORT int PyCom_RegisterExtensionSupport(PyObject *dict, const PyCom_InterfaceSupportInfo *pInterfaces,
  66. int numEntries);
  67. // THESE SHOULD NO LONGER BE USED. Instead, use the functions above passing an
  68. // array of PyCom_InterfaceSupportInfo objects.
  69. PYCOM_EXPORT int PyCom_RegisterClientType(PyTypeObject *typeOb, const GUID *guid);
  70. HRESULT PYCOM_EXPORT PyCom_RegisterGatewayObject(REFIID iid, pfnPyGatewayConstructor ctor, const char *interfaceName);
  71. PYCOM_EXPORT int PyCom_IsGatewayRegistered(REFIID iid);
  72. #endif /* __PYTHONCOMREGISTER_H__ */