Update of /cvsroot/pywin32/pywin32/com/win32com/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8151/com/win32com/src
Modified Files:
PyStorage.cpp PythonCOM.cpp
Log Message:
Add CreateStreamOnHGlobal, ReadClassStm and WriteClassStm
Index: PythonCOM.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PythonCOM.cpp,v
retrieving revision 1.44
retrieving revision 1.45
diff -C2 -d -r1.44 -r1.45
*** PythonCOM.cpp 26 Apr 2007 19:30:43 -0000 1.44
--- PythonCOM.cpp 27 Apr 2007 05:45:42 -0000 1.45
***************
*** 48,51 ****
--- 48,54 ----
extern PyObject *pythoncom_WriteClassStg(PyObject *self, PyObject *args);
extern PyObject *pythoncom_ReadClassStg(PyObject *self, PyObject *args);
+ extern PyObject *pythoncom_WriteClassStm(PyObject *self, PyObject *args);
+ extern PyObject *pythoncom_ReadClassStm(PyObject *self, PyObject *args);
+ extern PyObject *pythoncom_CreateStreamOnHGlobal(PyObject *self, PyObject *args);
extern PyObject *pythoncom_GetRecordFromGuids(PyObject *self, PyObject *args);
extern PyObject *pythoncom_GetRecordFromTypeInfo(PyObject *self, PyObject *args);
***************
*** 1791,1794 ****
--- 1794,1798 ----
{ "CreateTypeLib2", pythoncom_CreateTypeLib2, 1}, // @pymeth CreateTypeLib2|Provides access to a new object instance that supports the ICreateTypeLib2 interface.
#endif // MS_WINCE
+ { "CreateStreamOnHGlobal", pythoncom_CreateStreamOnHGlobal, 1 }, // @pymeth CreateStreamOnHGlobal|Creates an in-memory stream storage object
{ "EnableQuitMessage", pythoncom_EnableQuitMessage, 1 }, // @pymeth EnableQuitMessage|Indicates the thread PythonCOM should post a WM_QUIT message to.
{ "FUNCDESC", Py_NewFUNCDESC, 1}, // @pymeth FUNCDESC|Returns a new <o FUNCDESC> object.
***************
*** 1834,1837 ****
--- 1838,1842 ----
#endif // MS_WINCE
{ "ReadClassStg", pythoncom_ReadClassStg, 1}, // @pymeth ReadClassStg|Reads a CLSID from a storage object
+ { "ReadClassStm", pythoncom_ReadClassStm, 1}, // @pymeth ReadClassStm|Reads a CLSID from a <o PyIStream> object
{ "RegisterTypeLib", pythoncom_registertypelib, 1}, // @pymeth RegisterTypeLib|Adds information about a type library to the system registry.
{ "UnRegisterTypeLib", pythoncom_unregistertypelib, 1}, // @pymeth UnRegisterTypeLib|Removes a type library from the system registry.
***************
*** 1855,1858 ****
--- 1860,1864 ----
{ "WrapObject", pythoncom_WrapObject, 1 }, // @pymeth WrapObject|Wraps an object in a gateway.
{ "WriteClassStg", pythoncom_WriteClassStg, 1}, // @pymeth WriteClassStg|Stores a CLSID from a storage object
+ { "WriteClassStm", pythoncom_WriteClassStm, 1}, // @pymeth WriteClassStm|Sets the CLSID of a stream
{ "UnwrapObject", pythoncom_UnwrapObject, 1 }, // @pymeth UnwrapObject|Unwraps a Python instance in a gateway object.
{ "Unicode", pythoncom_Unicode, 1 }, // @pymeth Unicode|Converts a string into a <o PyUnicode> object.
Index: PyStorage.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyStorage.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** PyStorage.cpp 2 Dec 2005 07:53:53 -0000 1.9
--- PyStorage.cpp 27 Apr 2007 05:45:42 -0000 1.10
***************
*** 27,31 ****
return PyWinObject_FromIID(clsidRet);
}
! // @pymethod |pythoncom|WriteClassStg|Writes a CLSID to a storage.
PyObject *pythoncom_WriteClassStg(PyObject *self, PyObject *args)
{
--- 27,32 ----
return PyWinObject_FromIID(clsidRet);
}
!
! // @pymethod |pythoncom|WriteClassStg|Writes a CLSID to a storage object
PyObject *pythoncom_WriteClassStg(PyObject *self, PyObject *args)
{
***************
*** 33,37 ****
PyObject *obCLSID;
if (!PyArg_ParseTuple(args, "OO:WriteClassStg",
! &obStg, // @pyparm <o PyIStorage>|storage||The storage to read the CLSID from.
&obCLSID)) // @pyparm <o PyIID>|iid||The IID to write
return NULL;
--- 34,38 ----
PyObject *obCLSID;
if (!PyArg_ParseTuple(args, "OO:WriteClassStg",
! &obStg, // @pyparm <o PyIStorage>|storage||Storage object into which CLSID will be written.
&obCLSID)) // @pyparm <o PyIID>|iid||The IID to write
return NULL;
***************
*** 54,57 ****
--- 55,124 ----
}
+ // @pymethod <o PyIID>|pythoncom|ReadClassStm|Retrieves the CLSID from a stream
+ PyObject *pythoncom_ReadClassStm(PyObject *self, PyObject *args)
+ {
+ PyObject *obStm;
+ if (!PyArg_ParseTuple(args, "O:ReadClassStm",
+ &obStm)) // @pyparm <o PyIStream>|Stm||An IStream interface
+ return NULL;
+ IStream *pStm;
+ if (!PyCom_InterfaceFromPyObject(obStm, IID_IStream, (void **)&pStm, FALSE))
+ return NULL;
+ CLSID clsidRet;
+ PY_INTERFACE_PRECALL;
+ HRESULT hr = ReadClassStm(pStm, &clsidRet);
+ pStm->Release();
+ PY_INTERFACE_POSTCALL;
+ if (FAILED(hr)) return PyCom_BuildPyException(hr);
+ return PyWinObject_FromIID(clsidRet);
+ }
+
+ // @pymethod |pythoncom|WriteClassStm|Writes a CLSID to a stream.
+ PyObject *pythoncom_WriteClassStm(PyObject *self, PyObject *args)
+ {
+ PyObject *obStm;
+ PyObject *obCLSID;
+ if (!PyArg_ParseTuple(args, "OO:WriteClassStm",
+ &obStm, // @pyparm <o PyIStream>|Stm||An IStream interface
+ &obCLSID)) // @pyparm <o PyIID>|clsid||The IID to write
+ return NULL;
+
+ CLSID clsid;
+ if (!PyWinObject_AsIID(obCLSID, &clsid))
+ return NULL;
+
+ IStream *pStm;
+ if (!PyCom_InterfaceFromPyObject(obStm, IID_IStream, (void **)&pStm, FALSE))
+ return NULL;
+
+ PY_INTERFACE_PRECALL;
+ HRESULT hr = WriteClassStm(pStm, clsid);
+ pStm->Release();
+ PY_INTERFACE_POSTCALL;
+ if (FAILED(hr)) return PyCom_BuildPyException(hr);
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ // @pymethod <o PyIStream>|pythoncom|CreateStreamOnHGlobal|Creates an in-memory stream storage object
+ PyObject *pythoncom_CreateStreamOnHGlobal(PyObject *self, PyObject *args)
+ {
+ PyObject *obhglobal=Py_None;
+ HGLOBAL hglobal=NULL;
+ BOOL bdelete=TRUE;
+ IStream *pIStream=NULL;
+ if (!PyArg_ParseTuple(args, "|Ol:CreateStreamOnHGlobal",
+ &obhglobal, // @pyparm <o PyHANDLE>|hGlobal|None|Global memory handle. If None, a new global memory object is allocated.
+ &bdelete)) // @pyparm bool|DeleteOnRelease|True|Indicates if global memory should be freed when IStream object is destroyed.
+ return NULL;
+ if (!PyWinObject_AsHANDLE(obhglobal, &hglobal, TRUE))
+ return NULL;
+ PY_INTERFACE_PRECALL;
+ HRESULT hr = CreateStreamOnHGlobal(hglobal, bdelete, &pIStream);
+ PY_INTERFACE_POSTCALL;
+ if (FAILED(hr))
+ return PyCom_BuildPyException(hr);
+ return PyCom_PyObjectFromIUnknown(pIStream, IID_IStream, FALSE);
+ }
// @pymethod <o PyIStorage>|pythoncom|StgCreateDocfile|Creates a new compound file storage object using the OLE-provided compound file implementation for the <o PyIStorage> interface.
***************
*** 64,70 ****
if (!PyArg_ParseTuple(args, "Oi|i:StgCreateDocfile",
! &obName, // @pyparm string|name||the path of the compound file to create. It is passed uninterpreted to the file system. This can be a relative name or None. If None, a temporary stream is created.
! &mode, // @pyparm int|mode||Specifies the access mode used to open the storage.
! &reserved)) // @pyparm int|reserved|0|A reserved value
return NULL;
PyWin_AutoFreeBstr bstrName;
--- 131,137 ----
if (!PyArg_ParseTuple(args, "Oi|i:StgCreateDocfile",
! &obName, // @pyparm string|name||the path of the compound file to create. It is passed uninterpreted to the file system. This can be a relative name or None. If None, a temporary stream is created.
! &mode, // @pyparm int|mode||Specifies the access mode used to open the storage.
! &reserved)) // @pyparm int|reserved|0|A reserved value
return NULL;
PyWin_AutoFreeBstr bstrName;
|