[pywin32-checkins] /hgrepo/p/py/pywin32/pywin32: 4 new changesets
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: <pyw...@li...> - 2011-05-02 02:41:12
|
changeset 11095402fa78 in /hgrepo/p/py/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgrepo/p/py/pywin32/pywin32?cmd=changeset;node=11095402fa78 summary: a single SWIG for py2k and py3k changeset 0c7c0fcba126 in /hgrepo/p/py/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgrepo/p/py/pywin32/pywin32?cmd=changeset;node=0c7c0fcba126 summary: get adsi building in py3k changeset 851ff06494eb in /hgrepo/p/py/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgrepo/p/py/pywin32/pywin32?cmd=changeset;node=851ff06494eb summary: mapi and exchange modules working under py3k changeset 236b256c13bf in /hgrepo/p/py/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgrepo/p/py/pywin32/pywin32?cmd=changeset;node=236b256c13bf summary: update CHANGES.txt for recent swig work diffstat: .hgignore | 2 +- CHANGES.txt | 5 + SWIG/pywin32_swig.patch | 240 ++++++++++++++++++++++++++++++++++ SWIG/swig.exe | SWIG/swig_py3k.exe | com/win32comext/adsi/src/PyADSIUtil.cpp | 82 +++++------ com/win32comext/adsi/src/PyDSOPObjects.cpp | 14 +- com/win32comext/adsi/src/adsi.i | 16 +- com/win32comext/mapi/src/PyIMAPIStatus.i | 2 +- com/win32comext/mapi/src/exchange.i | 31 ++-- com/win32comext/mapi/src/exchdapi.i | 16 +- com/win32comext/mapi/src/mapi.i | 34 ++-- com/win32comext/mapi/src/mapilib.i | 6 +- setup.py | 26 +--- 14 files changed, 346 insertions(+), 128 deletions(-) diffs (truncated from 881 to 300 lines): diff -r 521b09dc35f8 -r 236b256c13bf .hgignore --- a/.hgignore Fri Apr 29 21:40:01 2011 -0600 +++ b/.hgignore Mon May 02 12:39:21 2011 +1000 @@ -21,7 +21,7 @@ com/win32comext/adsi/src/*.h com/win32comext/mapi/src/*.cpp com/win32comext/mapi/src/*.h -win32/src/*_py2_swig.cpp +win32/src/*_swig.cpp # Generated from message files diff -r 521b09dc35f8 -r 236b256c13bf CHANGES.txt --- a/CHANGES.txt Fri Apr 29 21:40:01 2011 -0600 +++ b/CHANGES.txt Mon May 02 12:39:21 2011 +1000 @@ -7,6 +7,11 @@ Since build 216: ---------------- +* The win32com.adsi and win32com.mapi packages have been upgraded to work on + Python 3.x and as a result, there is a slight risk that regressions to + these packages have been introduced in the Python 2.x versions. Please + file a bug if any problems are found. + * Pythonwin now warns, but allows you to continue, when saving a file with an invalid encoding line (bug 3139486) diff -r 521b09dc35f8 -r 236b256c13bf SWIG/pywin32_swig.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SWIG/pywin32_swig.patch Mon May 02 12:39:21 2011 +1000 @@ -0,0 +1,242 @@ +This is a patch to create the customized version of SWIG used for pywin32. + +The patch is against SWIG-1.1p5 which can be found at: + + https://sourceforge.net/projects/swig/files/swig/1.1p5/ + +or + + http://starship.python.net/crew/mhammond/downloads/swig1.1p5.tar.gz + +To build the version of SWIG: + +* Unpack the swig tarball +* Apply this patch. +* Change to the "Win" directory +* Execute 'nmake -f makefile.vc +* Copy the newly created swig.exe from the swig tree to the pywin32 tree. + + +Huge thanks to Amaury Forgeot d'Arc and Roger Upole for rescuing this! + + +--- SWIG1.1p5-orig\Modules\python.cxx 1998-01-03 17:17:40.000000000 +1100 ++++ SWIG1.1p5\Modules\python.cxx 2011-04-29 23:28:30.860296500 +1000 +@@ -61,6 +61,8 @@ + + static int doc_index = 0; + static DocString *doc_strings = 0; ++static int PythonCom = 0; // Generate PyWin32 header files ++static char *PythonCom_Parent = "IUnknown"; + + static char *usage = "\ + Python Options (available with -python)\n\ +@@ -113,6 +115,14 @@ + } else if (strcmp(argv[i],"-docstring") == 0) { + docstring = 1; + mark_arg(i); ++ } else if (strcmp(argv[i],"-pythoncom") == 0) { ++ PythonCom = 1; ++ mark_arg(i); ++ } else if (strcmp(argv[i],"-com_interface_parent") == 0) { ++ mark_arg(i); ++ PythonCom_Parent = copy_string(argv[i+1]); ++ mark_arg(i+1); ++ i++; + } else if (strcmp(argv[i],"-help") == 0) { + fputs(usage,stderr); + } +@@ -258,6 +268,47 @@ + } + fprintf(f_wrappers,"\t { NULL, NULL }\n"); + fprintf(f_wrappers,"};\n"); ++ if (PythonCom) { ++ fprintf(f_wrappers,"PyComTypeObject Py%s::type(\"Py%s\",", module, module); ++ fprintf(f_wrappers,"\t&Py%s::type,\n", PythonCom_Parent); ++ fprintf(f_wrappers,"\tsizeof(Py%s),\n", module); ++ fprintf(f_wrappers,"\t%sMethods,\n", module); ++ fprintf(f_wrappers,"\tGET_PYCOM_CTOR(Py%s));", module); ++ } ++} ++ ++// --------------------------------------------------------------------- ++// PYTHON::print_com_header() ++// ++// Prints out the COM header file ++// --------------------------------------------------------------------- ++ ++void PYTHON::print_com_header() { ++ char fn_header[256]; ++ sprintf(fn_header, "Py%s.h", module); ++ FILE *f_header = fopen(fn_header, "w"); ++ ++ if (!f_header) { ++ fprintf(stderr, "Unable to open %s\n", fn_header); ++ SWIG_exit(1); ++ } ++ ++ fprintf(f_header, "class Py%s : public Py%s\n", module, PythonCom_Parent); ++ fprintf(f_header, "{\npublic:\nMAKE_PYCOM_CTOR(Py%s);\n", module); ++ fprintf(f_header, "static PyComTypeObject type;\nstatic %s *GetI(PyObject *self);\n", module); ++ ++ Method *n = head; ++ ++ n = head; ++ while (n) { ++ fprintf(f_header, "\tstatic PyObject *%s(PyObject *self, PyObject *args);\n", n->name); ++ n = n->next; ++ } ++ ++ fprintf(f_header, "protected:\n\tPy%s(IUnknown *);\n\t~Py%s();\n", module, module); ++ fprintf(f_header, "};\n\n"); ++ ++ fclose(f_header); + } + + // --------------------------------------------------------------------- +@@ -376,6 +427,8 @@ + void PYTHON::initialize_cmodule(void) + { + int i; ++ if (PythonCom) ++ return; + fprintf(f_header,"#define SWIG_init init%s\n\n", module); + fprintf(f_header,"#define SWIG_name \"%s\"\n", module); + +@@ -389,7 +442,13 @@ + fprintf(f_init,"extern \"C\" \n"); + fprintf(f_init,"#endif\n"); + ++ fprintf(f_init, "#if (PY_VERSION_HEX < 0x03000000)\n"); ++ fprintf(f_init, "#define MODINIT_ERROR_RETURN\n"); + fprintf(f_init,"SWIGEXPORT(void,init%s)() {\n",module); ++ fprintf(f_init, "#else\n"); ++ fprintf(f_init, "#define MODINIT_ERROR_RETURN NULL\n"); ++ fprintf(f_init,"SWIGEXPORT(PyObject*, PyInit_%s)(void) {\n",module); ++ fprintf(f_init, "#endif\n"); + fprintf(f_init,"\t PyObject *m, *d;\n"); + + if (InitNames) { +@@ -400,8 +459,26 @@ + } + } + fprintf(f_init,"\t SWIG_globals = SWIG_newvarlink();\n"); ++ fprintf(f_init, "#if (PY_VERSION_HEX < 0x03000000)\n"); + fprintf(f_init,"\t m = Py_InitModule(\"%s\", %sMethods);\n", module, module); + fprintf(f_init,"\t d = PyModule_GetDict(m);\n"); ++ fprintf(f_init, "#else\n"); ++ fprintf(f_init, ++ " static PyModuleDef %s_def = {\n" ++ " PyModuleDef_HEAD_INIT,\n" ++ " \"%s\",\n" ++ " \"\",\n" ++ " -1,\n" ++ " %sMethods,\n" ++ " };\n" ++ " m = PyModule_Create(&%s_def);\n" ++ " if (!m)\n" ++ " return NULL;\n" ++ " d = PyModule_GetDict(m);\n" ++ " if (!d)\n" ++ " return NULL;\n", ++ module, module, module, module); ++ fprintf(f_init, "#endif\n"); + } + + +@@ -417,6 +494,9 @@ + + print_methods(); + close_cmodule(); ++ if (PythonCom) { ++ print_com_header(); ++ } + if ((doc_entry) && (module)){ + String temp; + temp << "Python Module : "; +@@ -469,7 +549,13 @@ + // -------------------------------------------------------------------- + void PYTHON::close_cmodule(void) + { +- emit_ptr_equivalence(f_init); ++ if (PythonCom) ++ return; ++// pywin32 doesn't need the pointer type-equivalency mappings. ++// emit_ptr_equivalence(f_init); ++ fprintf(f_init, "#if (PY_VERSION_HEX > 0x03000000)\n"); ++ fprintf(f_init,"\treturn m;\n"); ++ fprintf(f_init, "#endif\n"); + fprintf(f_init,"}\n"); + } + +@@ -598,9 +684,12 @@ + // ---------------------------------------------------------------------- + void PYTHON::emit_function_header(WrapperFunction &emit_to, char *wname) + { +- emit_to.def << "static PyObject *" << wname ++ if (!PythonCom) ++ emit_to.def << "static "; ++ emit_to.def << "PyObject *" << wname + << "(PyObject *self, PyObject *args) {"; +- emit_to.code << tab4 << "self = self;\n"; ++ if (!PythonCom) ++ emit_to.code << tab4 << "self = self;\n"; + } + + // ---------------------------------------------------------------------- +@@ -612,8 +701,13 @@ + // + // Returns the name of the variable to use as the self pointer + // ---------------------------------------------------------------------- +-char *PYTHON::convert_self(WrapperFunction &) ++char *PYTHON::convert_self(WrapperFunction &f) + { ++ if (PythonCom) { ++ f.code << "\t" << module << " *_swig_self;\n"; ++ f.code << "\t" << "if ((_swig_self=GetI(self))==NULL) return NULL;\n"; ++ return "_swig_self->"; ++ } + // Default behaviour is no translation + return ""; + } +@@ -625,7 +719,14 @@ + // ---------------------------------------------------------------------- + char *PYTHON::make_funcname_wrapper(char *fnName) + { +- return name_wrapper(fnName,""); ++ if (PythonCom) { ++ String wrapper; ++ wrapper << "Py" << module << "::" << fnName; ++ return wrapper; ++ } ++ else { ++ return name_wrapper(fnName,""); ++ } + } + + // ---------------------------------------------------------------------- +@@ -1629,7 +1730,13 @@ + // ----------------------------------------------------------------------- + + void PYTHON::add_native(char *name, char *funcname) { +- add_method(name, funcname); ++ if (PythonCom) { ++ String method; ++ method << "Py" << module << "::" << funcname; ++ add_method(name, method); ++ } else { ++ add_method(name, funcname); ++ } + if (shadow) { + func << name << " = " << module << "." << name << "\n\n"; + } +--- SWIG1.1p5-orig\Modules\python.h 1997-07-25 15:18:50.000000000 +1000 ++++ SWIG1.1p5\Modules\python.h 2011-04-22 10:53:17.287056400 +1000 +@@ -140,6 +140,7 @@ + // Add for Python-COM support + virtual void initialize_cmodule(); + virtual void close_cmodule(); ++ virtual void print_com_header(); + virtual void emit_function_header(WrapperFunction &emit_to, char *wname); + virtual char *convert_self(WrapperFunction &f); + virtual char *make_funcname_wrapper(char *fnName); diff -r 521b09dc35f8 -r 236b256c13bf SWIG/swig.exe Binary file SWIG/swig.exe has changed diff -r 521b09dc35f8 -r 236b256c13bf SWIG/swig_py3k.exe Binary file SWIG/swig_py3k.exe has changed diff -r 521b09dc35f8 -r 236b256c13bf com/win32comext/adsi/src/PyADSIUtil.cpp --- a/com/win32comext/adsi/src/PyADSIUtil.cpp Fri Apr 29 21:40:01 2011 -0600 +++ b/com/win32comext/adsi/src/PyADSIUtil.cpp Mon May 02 12:39:21 2011 +1000 @@ -111,9 +111,14 @@ case ADSTYPE_OCTET_STRING: { void *buf; - ob = PyBuffer_New(v.OctetString.dwLength); - ob->ob_type->tp_as_buffer->bf_getwritebuffer(ob, 0, &buf); - memcpy(buf, v.OctetString.lpValue, v.OctetString.dwLength); + DWORD bufSize = v.OctetString.dwLength; + if (!(ob=PyBuffer_New(bufSize))) + return NULL; + if (!PyWinObject_AsWriteBuffer(ob, &buf, &bufSize)){ + Py_DECREF(ob); + return NULL; + } + memcpy(buf, v.OctetString.lpValue, bufSize); } break; case ADSTYPE_UTC_TIME: @@ -128,11 +133,16 @@ case ADSTYPE_PROV_SPECIFIC: |