[pywin32-checkins] /hgroot/pywin32/pywin32: Add a counterpart to VB's Nothing, from...
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: <pyw...@li...> - 2013-04-07 23:12:08
|
changeset 461250d92627 in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=461250d92627 summary: Add a counterpart to VB's Nothing, from patch 3609027 by Stefan Schukat diffstat: com/win32com/src/MiscTypes.cpp | 32 ++++++++++++++++++++++++++++++++ com/win32com/src/PythonCOM.cpp | 7 ++++++- com/win32com/src/include/PythonCOM.h | 10 +++++++++- com/win32com/src/oleargs.cpp | 6 ++++++ 4 files changed, 53 insertions(+), 2 deletions(-) diffs (116 lines): diff -r 582b206cd792 -r 461250d92627 com/win32com/src/MiscTypes.cpp --- a/com/win32com/src/MiscTypes.cpp Mon Apr 01 05:36:54 2013 -0400 +++ b/com/win32com/src/MiscTypes.cpp Sun Apr 07 19:11:08 2013 -0400 @@ -195,6 +195,38 @@ } +// code changed by ssc +///////////////////////////////////////////////////////////////////////////// +// class PyOleNothing +PyOleNothing::PyOleNothing() +{ + ob_type = &PyOleNothingType; + _Py_NewReference(this); +} + +static void nothing_dealloc(PyOleNothing *o) +{ + delete o; +} + +PyTypeObject PyOleNothingType = +{ + PYWIN_OBJECT_HEAD + "PyOleNothing", + sizeof(PyOleNothingType), + 0, + (destructor)nothing_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ +}; +// end code changed by ssc + ///////////////////////////////////////////////////////////////////////////// // class PyOleEmpty PyOleEmpty::PyOleEmpty() diff -r 582b206cd792 -r 461250d92627 com/win32com/src/PythonCOM.cpp --- a/com/win32com/src/PythonCOM.cpp Mon Apr 01 05:36:54 2013 -0400 +++ b/com/win32com/src/PythonCOM.cpp Sun Apr 07 19:11:08 2013 -0400 @@ -35,7 +35,7 @@ PyObject *g_obEmpty = NULL; PyObject *g_obMissing = NULL; PyObject *g_obArgNotFound = NULL; - +PyObject *g_obNothing = NULL; PyObject *PyCom_InternalError = NULL; // Storage related functions. @@ -2154,6 +2154,11 @@ g_obArgNotFound = new PyOleArgNotFound; PyDict_SetItemString(dict, "ArgNotFound", g_obArgNotFound); +// code changed by ssc + g_obNothing = new PyOleNothing; + PyDict_SetItemString(dict, "Nothing", g_obNothing); +// end code changed by ssc + // Add some symbolic constants to the module // pycom_Error = PyString_FromString("pythoncom.error"); if (PyWinExc_COMError==NULL) diff -r 582b206cd792 -r 461250d92627 com/win32com/src/include/PythonCOM.h --- a/com/win32com/src/include/PythonCOM.h Mon Apr 01 05:36:54 2013 -0400 +++ b/com/win32com/src/include/PythonCOM.h Sun Apr 07 19:11:08 2013 -0400 @@ -227,6 +227,7 @@ extern PYCOM_EXPORT PyTypeObject PyOleEmptyType; // equivalent to VT_EMPTY extern PYCOM_EXPORT PyTypeObject PyOleMissingType; // special Python handling. extern PYCOM_EXPORT PyTypeObject PyOleArgNotFoundType; // special VT_ERROR value +extern PYCOM_EXPORT PyTypeObject PyOleNothingType; // special VT_ERROR value // ALL of these set an appropriate Python error on bad return. @@ -415,7 +416,7 @@ EXCEPINFO FAR* pexcepinfo, UINT FAR* puArgErr, PyObject *addnlArgs); ///////////////////////////////////////////////////////////////////////////// -// class PyOleEmpty +// Various special purpose singletons class PYCOM_EXPORT PyOleEmpty : public PyObject { public: @@ -434,6 +435,13 @@ PyOleArgNotFound(); }; +class PYCOM_EXPORT PyOleNothing : public PyObject +{ +public: + PyOleNothing(); +}; + + // We need to dynamically create C++ Python objects // These helpers allow each type object to create it. #define MAKE_PYCOM_CTOR(classname) static PyIUnknown * classname::PyObConstruct(IUnknown *pInitObj) {return new classname(pInitObj);} diff -r 582b206cd792 -r 461250d92627 com/win32com/src/oleargs.cpp --- a/com/win32com/src/oleargs.cpp Mon Apr 01 05:36:54 2013 -0400 +++ b/com/win32com/src/oleargs.cpp Sun Apr 07 19:11:08 2013 -0400 @@ -216,6 +216,12 @@ else if (obj->ob_type == &PyOleEmptyType) { bGoodEmpty = TRUE; } +// code changed by ssc + else if (obj->ob_type == &PyOleNothingType) { + V_VT(var) = VT_DISPATCH; + V_DISPATCH(var) = NULL; + } +// end code changed by ssc else if (obj->ob_type == &PyOleArgNotFoundType) { // use default parameter |