codekingpro/portable-devtools
115k
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, then5// use the macros to populate it.6//7// See Register.cpp and AXScript.cpp for examples on its use.8 9#ifndef __PYTHONCOMREGISTER_H__10#define __PYTHONCOMREGISTER_H__11 12#include "PythonCOMServer.h" // Need defns in this file...13 14typedef struct {15 const GUID *pGUID; // The supported IID - required16 const char *interfaceName; // Name of the interface - required17 const char *iidName; // Name of the IID that goes into the dict. - required18 PyTypeObject *pTypeOb; // the type object for client PyI* side - NULL for server only support.19 pfnPyGatewayConstructor ctor; // Gateway (PyG*) interface constructor - NULL for client only support20 21} PyCom_InterfaceSupportInfo;22 23#define PYCOM_INTERFACE_IID_ONLY(ifc) \24 { \25 &IID_I##ifc, "I" #ifc, "IID_I" #ifc, NULL, NULL \26 }27#define PYCOM_INTERFACE_CLSID_ONLY(ifc) \28 { \29 &CLSID_##ifc, "CLSID_" #ifc, "CLSID_" #ifc, NULL, NULL \30 }31#define PYCOM_INTERFACE_CATID_ONLY(ifc) \32 { \33 &CATID_##ifc, "CATID_" #ifc, "CATID_" #ifc, NULL, NULL \34 }35#define PYCOM_INTERFACE_CLIENT_ONLY(ifc) \36 { \37 &IID_I##ifc, "I" #ifc, "IID_I" #ifc, &PyI##ifc::type, NULL \38 }39#define PYCOM_INTERFACE_SERVER_ONLY(ifc) \40 { \41 &IID_I##ifc, "I" #ifc, "IID_I" #ifc, NULL, GET_PYGATEWAY_CTOR(PyG##ifc) \42 }43#define PYCOM_INTERFACE_FULL(ifc) \44 { \45 &IID_I##ifc, "I" #ifc, "IID_I" #ifc, &PyI##ifc::type, GET_PYGATEWAY_CTOR(PyG##ifc) \46 }47 48// Versions that use __uuidof() to get the IID, which seems to avoid the need49// to link with a lib holding the IIDs. Note that almost all extensions50// build with __uuidof() being the default; the build failed at 'shell' - so51// we could consider making this the default and making the 'explicit' version52// above the special case.53#define PYCOM_INTERFACE_IID_ONLY_UUIDOF(ifc) \54 { \55 &__uuidof(I##ifc), "I" #ifc, "IID_I" #ifc, NULL, NULL \56 }57#define PYCOM_INTERFACE_CLIENT_ONLY_UUIDOF(ifc) \58 { \59 &__uuidof(I##ifc), "I" #ifc, "IID_I" #ifc, &PyI##ifc::type, NULL \60 }61#define PYCOM_INTERFACE_SERVER_ONLY_UUIDOF(ifc) \62 { \63 &__uuidof(I##ifc), "I" #ifc, "IID_I" #ifc, NULL, GET_PYGATEWAY_CTOR(PyG##ifc) \64 }65#define PYCOM_INTERFACE_FULL_UUIDOF(ifc) \66 { \67 &__uuidof(I##ifc), "I" #ifc, "IID_I" #ifc, &PyI##ifc::type, GET_PYGATEWAY_CTOR(PyG##ifc) \68 }69 70// Prototypes for the register functions71 72// Register a PythonCOM extension module73PYCOM_EXPORT int PyCom_RegisterExtensionSupport(PyObject *dict, const PyCom_InterfaceSupportInfo *pInterfaces,74 int numEntries);75 76// THESE SHOULD NO LONGER BE USED. Instead, use the functions above passing an77// array of PyCom_InterfaceSupportInfo objects.78 79PYCOM_EXPORT int PyCom_RegisterClientType(PyTypeObject *typeOb, const GUID *guid);80 81HRESULT PYCOM_EXPORT PyCom_RegisterGatewayObject(REFIID iid, pfnPyGatewayConstructor ctor, const char *interfaceName);82PYCOM_EXPORT int PyCom_IsGatewayRegistered(REFIID iid);83 84#endif /* __PYTHONCOMREGISTER_H__ */85 