From: <mha...@us...> - 2003-10-06 13:07:08
|
Update of /cvsroot/pywin32/pywin32/com/win32com/makegw In directory sc8-pr-cvs1:/tmp/cvs-serv28862 Modified Files: __init__.py makegw.py makegwparse.py Log Message: A number of changes on the road to the shell enhancements. Index: __init__.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/makegw/__init__.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** __init__.py 1 Sep 1999 23:00:45 -0000 1.1 --- __init__.py 6 Oct 2003 13:07:02 -0000 1.2 *************** *** 0 **** --- 1 ---- + # indicates a python package. Index: makegw.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/makegw/makegw.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** makegw.py 28 Nov 1999 12:41:12 -0000 1.6 --- makegw.py 6 Oct 2003 13:07:02 -0000 1.7 *************** *** 90,100 **** // Generated by makegw.py ! #include "stdafx.h" ! #include "PythonCOM.h" ''' % (interface.name, desc)) ! if bMakeGateway: ! fout.write('#include "PythonCOMServer.h"\n') ! if interface.base not in ["IUnknown", "IDispatch"]: ! fout.write('#include "Py%s.h"\n' % interface.base) fout.write('#include "Py%s.h"\n\n// @doc - This file contains autoduck documentation\n' % interface.name) if bMakeInterface: ifc_cpp_writer(fout, interface) --- 90,99 ---- // Generated by makegw.py ! #include "shell_pch.h" ''' % (interface.name, desc)) ! # if bMakeGateway: ! # fout.write('#include "PythonCOMServer.h"\n') ! # if interface.base not in ["IUnknown", "IDispatch"]: ! # fout.write('#include "Py%s.h"\n' % interface.base) fout.write('#include "Py%s.h"\n\n// @doc - This file contains autoduck documentation\n' % interface.name) if bMakeInterface: ifc_cpp_writer(fout, interface) *************** *** 186,190 **** return NULL; ''' % strdict) ! argsParseTuple = argsCOM = formatChars = codePost = codePobjects = codeCobjects = cleanup = "" needConversion = 0 # if method.name=="Stat": import win32dbg;win32dbg.brk() --- 185,190 ---- return NULL; ''' % strdict) ! argsParseTuple = argsCOM = formatChars = codePost = \ ! codePobjects = codeCobjects = cleanup = cleanup_gil = "" needConversion = 0 # if method.name=="Stat": import win32dbg;win32dbg.brk() *************** *** 202,205 **** --- 202,206 ---- needConversion = needConversion or argCvt.NeedUSES_CONVERSION() cleanup = cleanup + argCvt.GetInterfaceArgCleanup() + cleanup_gil = cleanup_gil + argCvt.GetInterfaceArgCleanupGIL() comArgName, comArgDeclString = argCvt.GetInterfaceCppObjectInfo() if comArgDeclString: # If we should declare a variable *************** *** 210,213 **** --- 211,215 ---- f.write('\t%s %s;\n\tPyObject *ob%s;\n' % (arg.type, arg.name, arg.name)) + f.write('\t// @pyparm <o Py%s>|%s||Description for %s\n' % (arg.type, arg.name, arg.name)) codePost = codePost + '\tif (bPythonIsHappy && !PyObject_As%s( ob%s, &%s )) bPythonIsHappy = FALSE;\n' % (arg.type, arg.name, arg.name) *************** *** 216,219 **** --- 218,222 ---- argsCOM = argsCOM + ", " + arg.name + cleanup = cleanup + "\tPyObject_Free%s(%s);\n" % (arg.type, arg.name) if needConversion: f.write("\tUSES_CONVERSION;\n") *************** *** 227,230 **** --- 230,234 ---- strdict['argsCOM'] = argsCOM[1:] strdict['cleanup'] = cleanup + strdict['cleanup_gil'] = cleanup_gil f.write(\ ''' HRESULT hr; *************** *** 233,236 **** --- 237,241 ---- %(cleanup)s PY_INTERFACE_POSTCALL; + %(cleanup_gil)s if ( FAILED(hr) ) return PyCom_BuildPyException(hr, p%(ptr)s, IID_%(interfacename)s ); Index: makegwparse.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/makegw/makegwparse.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** makegwparse.py 26 Jul 2003 14:10:49 -0000 1.8 --- makegwparse.py 6 Oct 2003 13:07:02 -0000 1.9 *************** *** 106,109 **** --- 106,117 ---- return "" + def GetInterfaceArgCleanupGIL(self): + """Return cleanup code for C++ args passed to the interface + method that must be executed with the GIL held""" + if DEBUG: + return "/* GetInterfaceArgCleanup (GIL held) output goes here: %s */\n" % self.arg.name + else: + return "" + def GetUnconstType(self): return self.arg.unc_type *************** *** 253,257 **** return "<o unicode>" def GetParsePostCode(self): ! return "\tif (!PyWinObject_AsBstr(ob%s, %s)) bPythonIsHappy = FALSE;\n" % (self.arg.name, self.GetIndirectedArgName(None, 2)) def GetBuildForInterfacePreCode(self): notdirected = self.GetIndirectedArgName(None, 1) --- 261,265 ---- return "<o unicode>" def GetParsePostCode(self): ! return "\tif (bPythonIsHappy && !PyWinObject_AsBstr(ob%s, %s)) bPythonIsHappy = FALSE;\n" % (self.arg.name, self.GetIndirectedArgName(None, 2)) def GetBuildForInterfacePreCode(self): notdirected = self.GetIndirectedArgName(None, 1) *************** *** 273,277 **** return self.arg.unc_type def GetParsePostCode(self): ! return "\tif (!PyWinObject_AsBstr(ob%s, %s)) bPythonIsHappy = FALSE;\n" % (self.arg.name, self.GetIndirectedArgName(None, 2)) def GetInterfaceArgCleanup(self): return "\tSysFreeString(%s);\n" % self.GetIndirectedArgName(None, 1) --- 281,285 ---- return self.arg.unc_type def GetParsePostCode(self): ! return "\tif (bPythonIsHappy && !PyWinObject_AsBstr(ob%s, %s)) bPythonIsHappy = FALSE;\n" % (self.arg.name, self.GetIndirectedArgName(None, 2)) def GetInterfaceArgCleanup(self): return "\tSysFreeString(%s);\n" % self.GetIndirectedArgName(None, 1) *************** *** 337,340 **** --- 345,379 ---- return "\tob%s = PyCom_PyObjectFromSTATSTG(%s);\n\t// STATSTG doco says our responsibility to free\n\tif ((%s).pwcsName) CoTaskMemFree((%s).pwcsName);\n" % (self.arg.name, self.GetIndirectedArgName(None, 1),notdirected,notdirected) + class ArgFormatterGeneric(ArgFormatterPythonCOM): + def _GetPythonTypeDesc(self): + return "<o %s>" % self.arg.type + def GetParsePostCode(self): + return '\tif (!PyObject_As%s(ob%s, &%s) bPythonIsHappy = FALSE;\n' % (self.arg.type, self.arg.name, self.GetIndirectedArgName(None, 1)) + def GetInterfaceArgCleanup(self): + return '\tPyObject_Free%s(%s);\n' % (self.arg.type, self.arg.name) + def GetBuildForInterfacePreCode(self): + notdirected = self.GetIndirectedArgName(None, 1) + return "\tob%s = PyObject_From%s(%s);\n" % (self.arg.name, self.arg.type, self.GetIndirectedArgName(None, 1)) + + class ArgFormatterIDLIST(ArgFormatterPythonCOM): + def _GetPythonTypeDesc(self): + return "<o PyIDL>" + def GetParsePostCode(self): + return '\tif (bPythonIsHappy && !PyObject_AsPIDL(ob%s, &%s)) bPythonIsHappy = FALSE;\n' % (self.arg.name, self.GetIndirectedArgName(None, 1)) + def GetInterfaceArgCleanup(self): + return '\tPyObject_FreePIDL(%s);\n' % (self.arg.name,) + def GetBuildForInterfacePreCode(self): + notdirected = self.GetIndirectedArgName(None, 1) + return "\tob%s = PyObject_FromPIDL(%s);\n" % (self.arg.name, self.GetIndirectedArgName(None, 1)) + + class ArgFormatterHANDLE(ArgFormatterPythonCOM): + def _GetPythonTypeDesc(self): + return "<o PyHANDLE>" + def GetParsePostCode(self): + return '\tif (!PyWinObject_AsHANDLE(ob%s, &%s, FALSE) bPythonIsHappy = FALSE;\n' % (self.arg.name, self.GetIndirectedArgName(None, 1)) + def GetBuildForInterfacePreCode(self): + notdirected = self.GetIndirectedArgName(None, 1) + return "\tob%s = PyWinObject_FromHANDLE(%s);\n" % (self.arg.name, self.GetIndirectedArgName(None, 0)) + class ArgFormatterLARGE_INTEGER(ArgFormatterPythonCOM): def GetKeyName(self): *************** *** 364,368 **** # vs. in params for interface mode. sArg = self.GetIndirectedArgName(1, 2) ! return "\tif (!PyCom_InterfaceFromPyInstanceOrObject(ob%s, IID_%s, (void **)%s, TRUE /* bNoneOK */))\n\t\t bPythonIsHappy = FALSE;\n" % (self.arg.name, self.arg.type, sArg) def GetBuildForInterfacePreCode(self): --- 403,407 ---- # vs. in params for interface mode. sArg = self.GetIndirectedArgName(1, 2) ! return "\tif (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(ob%s, IID_%s, (void **)%s, TRUE /* bNoneOK */))\n\t\t bPythonIsHappy = FALSE;\n" % (self.arg.name, self.arg.type, sArg) def GetBuildForInterfacePreCode(self): *************** *** 374,378 **** def GetInterfaceArgCleanup(self): ! return "\tif (%s) %s->Release();" % (self.arg.name, self.arg.name) class ArgFormatterVARIANT(ArgFormatterPythonCOM): --- 413,417 ---- def GetInterfaceArgCleanup(self): ! return "\tif (%s) %s->Release();\n" % (self.arg.name, self.arg.name) class ArgFormatterVARIANT(ArgFormatterPythonCOM): *************** *** 429,432 **** --- 468,473 ---- "LPCWSTR": (ArgFormatterOLECHAR, 1, 1), "LPWSTR": (ArgFormatterOLECHAR, 1, 1), + "LPCSTR": (ArgFormatterOLECHAR, 1, 1), + "HANDLE": (ArgFormatterHANDLE, 0), "BSTR": (ArgFormatterBSTR, 1, 0), "const IID": (ArgFormatterIID, 0), *************** *** 454,457 **** --- 495,502 ---- "WORD": (ArgFormatterShort, 0), "VARIANT_BOOL": (ArgFormatterShort, 0), + "HWND": (ArgFormatterShort, 0), + "HMENU": (ArgFormatterShort, 0), + "HICON": (ArgFormatterShort, 0), + "UINT": (ArgFormatterShort, 0), "Control": (ArgFormatterInterface, 0, 1), "DataObject": (ArgFormatterInterface, 0, 1), *************** *** 460,463 **** --- 505,510 ---- "DataSource": (ArgFormatterInterface, 0, 1), "DataFormat": (ArgFormatterInterface, 0, 1), + "ITEMIDLIST": (ArgFormatterIDLIST, 0, 1), + "const ITEMIDLIST": (ArgFormatterIDLIST, 0, 1), } *************** *** 562,566 **** # options ret type callconv name # ----------------- -------- -------- -------- ! regex = regex.compile('virtual \\(/\\*.*\\*/ \\)?\\(.*\\) \\(.*\\) \\(.*\\)( ') def __init__(self, good_interface_names ): self.good_interface_names = good_interface_names --- 609,613 ---- # options ret type callconv name # ----------------- -------- -------- -------- ! regex = regex.compile('virtual \\(/\\*.*\\*/ \\)?\\(.*\\) \\(.*\\) \\(.*\\)(\w?') def __init__(self, good_interface_names ): self.good_interface_names = good_interface_names *************** *** 635,638 **** --- 682,686 ---- if Interface.regex.search(line, 0) >=0: name = Interface.regex.group(2) + print name if name==interfaceName: return Interface() |