Update of /cvsroot/pywin32/pywin32/Pythonwin
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3631/Pythonwin
Modified Files:
Tag: py3k
ddeconv.cpp ddemodule.h stddde.cpp win32ui.h win32uiExt.h
win32uimodule.cpp win32virt.cpp
Log Message:
merge various fixes and changes from the trunk
Index: win32ui.h
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32ui.h,v
retrieving revision 1.7.2.4
retrieving revision 1.7.2.5
diff -C2 -d -r1.7.2.4 -r1.7.2.5
*** win32ui.h 1 Oct 2008 13:50:54 -0000 1.7.2.4
--- win32ui.h 6 Dec 2008 01:48:26 -0000 1.7.2.5
***************
*** 313,318 ****
BOOL retval( PyObject* &ret );
BOOL retval( CREATESTRUCT &cs );
! BOOL retval( char * &ret );
! BOOL retval( WCHAR *&ret );
BOOL retval( CString &ret );
BOOL retval( MSG *msg);
--- 313,319 ----
BOOL retval( PyObject* &ret );
BOOL retval( CREATESTRUCT &cs );
! // Note the lack of 'char *' or 'WCHAR *' support - this makes it
! // too hard for memory management when converting between strings and
! // unicode. Use the CString one instead.
BOOL retval( CString &ret );
BOOL retval( MSG *msg);
Index: ddemodule.h
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/ddemodule.h,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -C2 -d -r1.1.4.1 -r1.1.4.2
*** ddemodule.h 29 Aug 2008 05:53:28 -0000 1.1.4.1
--- ddemodule.h 6 Dec 2008 01:48:26 -0000 1.1.4.2
***************
*** 24,28 ****
};
-
template <class T>
class PythonDDETopicFramework : public T
--- 24,27 ----
***************
*** 39,43 ****
return !rc;
}
! virtual BOOL NSRequest(const TCHAR * szItem, void** ppData, DWORD* dwSize)
{
PyObject *args = Py_BuildValue("(N)", PyWinObject_FromTCHAR(szItem));
--- 38,42 ----
return !rc;
}
! virtual BOOL NSRequest(const TCHAR *szItem, CDDEAllocator &allocr)
{
PyObject *args = Py_BuildValue("(N)", PyWinObject_FromTCHAR(szItem));
***************
*** 45,55 ****
CVirtualHelper helper("Request", this);
if (helper.call_args(args) ) {
! TCHAR * strret ;
if (helper.retval(strret)) {
! PyObject * look ;
! helper.retval(look) ;
! *dwSize = PyObject_Length(look)+1 ;
! *ppData = (void*)strret ;
! return TRUE ;
}
}
--- 44,52 ----
CVirtualHelper helper("Request", this);
if (helper.call_args(args) ) {
! CString strret;
if (helper.retval(strret)) {
! // seems strange we can't use DdeCreateStringHandle, but that is
! // a different handle type
! return allocr.Alloc(strret);
}
}
Index: win32uiExt.h
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32uiExt.h,v
retrieving revision 1.14.2.1
retrieving revision 1.14.2.2
diff -C2 -d -r1.14.2.1 -r1.14.2.2
*** win32uiExt.h 29 Aug 2008 05:53:29 -0000 1.14.2.1
--- win32uiExt.h 6 Dec 2008 01:48:26 -0000 1.14.2.2
***************
*** 828,834 ****
// @xref <om PyCMDIChildWnd.GetMessageString>
if (helper.call((int &)nID)) {
! char *ret;
! if (helper.retval(ret))
! rMessage = ret;
}
else
--- 828,832 ----
// @xref <om PyCMDIChildWnd.GetMessageString>
if (helper.call((int &)nID)) {
! helper.retval(rMessage);
}
else
Index: win32uimodule.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32uimodule.cpp,v
retrieving revision 1.39.2.7
retrieving revision 1.39.2.8
diff -C2 -d -r1.39.2.7 -r1.39.2.8
*** win32uimodule.cpp 26 Nov 2008 07:17:38 -0000 1.39.2.7
--- win32uimodule.cpp 6 Dec 2008 01:48:26 -0000 1.39.2.8
***************
*** 789,792 ****
--- 789,808 ----
}
+ // @pymethod |win32ui|DisplayTraceback|Displays a traceback in a dialog box.
+ static PyObject *
+ ui_python_display_traceback( PyObject *self, PyObject *args )
+ {
+ PyObject *obTitle = Py_None;
+ PyObject *t, *v, *tb;
+ if (!PyArg_ParseTuple(args, "(OOO)|O:DisplayTraceback", &t, &v, &tb, &obTitle))
+ return NULL;
+ TCHAR *title;
+ if (!PyWinObject_AsTCHAR(obTitle, &title, TRUE))
+ return NULL;
+ DisplayPythonTraceback(t, v, tb, title);
+ PyWinObject_FreeTCHAR(title);
+ RETURN_NONE;
+ }
+
// @pymethod |win32ui|OutputDebugString|Sends a string to the Windows debugging device.
static PyObject *
***************
*** 1899,1902 ****
--- 1915,1919 ----
{"DestroyDebuggerThread", ui_destroy_debugger_thread, 1}, // @pymeth DestroyDebuggerThread|Cleans up the debugger thread.
{"DoWaitCursor", ui_do_wait_cursor, 1}, // @pymeth DoWaitCursor|Changes the cursor to/from a wait cursor.
+ {"DisplayTraceback", ui_python_display_traceback, 1}, // @pymeth DisplayTraceback|Displays a traceback in a dialog box.
{"Enable3dControls", ui_enable_3d_controls, 1 }, // @pymeth Enable3dControls|Enables 3d controls for the application.
{"FindWindow", PyCWnd::FindWindow, 1}, // @pymeth FindWindow|Searches for the specified top-level window
Index: stddde.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/stddde.cpp,v
retrieving revision 1.5.2.1
retrieving revision 1.5.2.2
diff -C2 -d -r1.5.2.1 -r1.5.2.2
*** stddde.cpp 29 Aug 2008 05:53:29 -0000 1.5.2.1
--- stddde.cpp 6 Dec 2008 01:48:26 -0000 1.5.2.2
***************
*** 178,182 ****
}
! BOOL CDDEItem::Request(UINT wFmt, void** ppData, DWORD* pdwSize)
{
return FALSE;
--- 178,182 ----
}
! BOOL CDDEItem::Request(UINT wFmt, CDDEAllocator &allocr)
{
return FALSE;
***************
*** 184,188 ****
//CT BEGIN
! BOOL CDDEItem::NSRequest(const TCHAR* szItem, void** ppData, DWORD* pdwSize)
{
return FALSE;
--- 184,188 ----
//CT BEGIN
! BOOL CDDEItem::NSRequest(const TCHAR* szItem, CDDEAllocator &allocr)
{
return FALSE;
***************
*** 240,250 ****
}
! BOOL CDDEStringItem::Request(UINT wFmt, void** ppData, DWORD* pdwSize)
{
ASSERT(wFmt == CF_TEXT);
! ASSERT(ppData);
! *ppData = (void*)(const TCHAR*)m_strData;
! *pdwSize = m_strData.GetLength() + 1; // allow for the null
! return TRUE;
}
--- 240,247 ----
}
! BOOL CDDEStringItem::Request(UINT wFmt, CDDEAllocator &allocr)
{
ASSERT(wFmt == CF_TEXT);
! return allocr.Alloc(m_strData);
}
***************
*** 320,324 ****
BOOL CDDETopic::Request(UINT wFmt, const TCHAR* pszItem,
! void** ppData, DWORD* pdwSize)
{
//
--- 317,321 ----
BOOL CDDETopic::Request(UINT wFmt, const TCHAR* pszItem,
! CDDEAllocator &allocr)
{
//
***************
*** 331,343 ****
//CT BEGIN
if (pItem->m_strName == "") {
! BOOL ret = NSRequest(pszItem, ppData, pdwSize);
return ret ;
}
//CT END
! return pItem->Request(wFmt, ppData, pdwSize);
}
//CT BEGIN
! BOOL CDDETopic::NSRequest(const TCHAR * szItem, void** ppData, DWORD* dwsize)
{
return FALSE ;
--- 328,340 ----
//CT BEGIN
if (pItem->m_strName == "") {
! BOOL ret = NSRequest(pszItem, allocr);
return ret ;
}
//CT END
! return pItem->Request(wFmt, allocr);
}
//CT BEGIN
! BOOL CDDETopic::NSRequest(const TCHAR *szItem, CDDEAllocator &allocr)
{
return FALSE ;
***************
*** 542,551 ****
}
! BOOL CDDEConv::Request(const TCHAR* pszItem, void** ppData, DWORD* pdwSize)
{
ASSERT(m_pServer);
ASSERT(pszItem);
- ASSERT(ppData);
- ASSERT(pdwSize);
CHSZ hszItem (m_pServer, pszItem);
--- 539,546 ----
}
! BOOL CDDEConv::Request(const TCHAR* pszItem, CString &ret)
{
ASSERT(m_pServer);
ASSERT(pszItem);
CHSZ hszItem (m_pServer, pszItem);
***************
*** 554,558 ****
--- 549,557 ----
m_hConv,
hszItem,
+ #if defined(UNICODE)
+ CF_UNICODETEXT,
+ #else
CF_TEXT,
+ #endif
XTYP_REQUEST,
DDE_TIMEOUT,
***************
*** 560,567 ****
if (!hData) {
-
- // Failed
- *pdwSize = 0;
- *ppData = NULL;
return FALSE;
}
--- 559,562 ----
***************
*** 570,581 ****
// Copy the result data
//
!
! BYTE* pData = ::DdeAccessData(hData, pdwSize);
! ASSERT(*pdwSize);
! *ppData = new char[*pdwSize];
! ASSERT(*ppData);
! memcpy(*ppData, pData, *pdwSize);
::DdeUnaccessData(hData);
!
return TRUE;
}
--- 565,578 ----
// Copy the result data
//
! DWORD dwSize;
! BYTE* pData = ::DdeAccessData(hData, &dwSize);
! DWORD nChars = (dwSize / sizeof(TCHAR))-1;
! ret = CString((TCHAR *)pData, nChars);
::DdeUnaccessData(hData);
! // MSDN sez 'When an application has finished using the data handle
! // returned by DdeClientTransaction, the application should free the
! // handle by calling the DdeFreeDataHandle function.' - which would
! // be about now!
! ::DdeFreeDataHandle(hData);
return TRUE;
}
***************
*** 693,697 ****
IMPLEMENT_DYNCREATE(CDDESystemItem_TopicList, CDDESystemItem);
! BOOL CDDESystemItem_TopicList::Request(UINT wFmt, void** ppData, DWORD* pdwSize)
{
//
--- 690,694 ----
IMPLEMENT_DYNCREATE(CDDESystemItem_TopicList, CDDESystemItem);
! BOOL CDDESystemItem_TopicList::Request(UINT wFmt, CDDEAllocator &allocr)
{
//
***************
*** 728,740 ****
// Set up the return info
//
!
! *ppData = (void*)(const TCHAR*)strTopics;
! *pdwSize = strTopics.GetLength() + 1; // include room for the NULL
! return TRUE;
}
IMPLEMENT_DYNCREATE(CDDESystemItem_ItemList, CDDESystemItem);
! BOOL CDDESystemItem_ItemList::Request(UINT wFmt, void** ppData, DWORD* pdwSize)
{
//
--- 725,734 ----
// Set up the return info
//
! return allocr.Alloc(strTopics);
}
IMPLEMENT_DYNCREATE(CDDESystemItem_ItemList, CDDESystemItem);
! BOOL CDDESystemItem_ItemList::Request(UINT wFmt, CDDEAllocator &allocr)
{
//
***************
*** 769,781 ****
// Set up the return info
//
!
! *ppData = (void*)(const TCHAR*)strItems;
! *pdwSize = strItems.GetLength() + 1; // include room for the NULL
! return TRUE;
}
IMPLEMENT_DYNCREATE(CDDESystemItem_FormatList, CDDESystemItem);
! BOOL CDDESystemItem_FormatList::Request(UINT wFmt, void** ppData, DWORD* pdwSize)
{
//
--- 763,772 ----
// Set up the return info
//
! return allocr.Alloc(strItems);
}
IMPLEMENT_DYNCREATE(CDDESystemItem_FormatList, CDDESystemItem);
! BOOL CDDESystemItem_FormatList::Request(UINT wFmt, CDDEAllocator &allocr)
{
//
***************
*** 850,857 ****
// Set up the return info
//
!
! *ppData = (void*)(const TCHAR*)strFormats;
! *pdwSize = strFormats.GetLength() + 1; // include romm for the NULL
! return TRUE;
}
--- 841,845 ----
// Set up the return info
//
! return allocr.Alloc(strFormats);
}
***************
*** 859,866 ****
BOOL CDDEServerSystemTopic::Request(UINT wFmt, const TCHAR* pszItem,
! void** ppData, DWORD* pdwSize)
{
m_pServer->Status(_T("System topic request: %s"), pszItem);
! return CDDETopic::Request(wFmt, pszItem, ppData, pdwSize);
}
--- 847,854 ----
BOOL CDDEServerSystemTopic::Request(UINT wFmt, const TCHAR* pszItem,
! CDDEAllocator &allocr)
{
m_pServer->Status(_T("System topic request: %s"), pszItem);
! return CDDETopic::Request(wFmt, pszItem, allocr);
}
***************
*** 1694,1702 ****
// a generic one for the topic
//
Status(_T("Request %s|%s"), (const TCHAR*)strTopic, (const TCHAR*)strItem);
dwLength = 0;
! if (!Request(wFmt, strTopic, strItem, &pData, &dwLength)) {
!
//
// Nobody accepted the request
--- 1682,1691 ----
// a generic one for the topic
//
+ { // scope for locals.
+ CDDEAllocator allocr(m_dwDDEInstance, hszItem, wFmt, phReturnData);
Status(_T("Request %s|%s"), (const TCHAR*)strTopic, (const TCHAR*)strItem);
dwLength = 0;
! if (!Request(wFmt, strTopic, strItem, allocr)) {
//
// Nobody accepted the request
***************
*** 1710,1725 ****
}
! //
! // There is some data so build a DDE data object to return
! //
!
! *phReturnData = ::DdeCreateDataHandle(m_dwDDEInstance,
! (unsigned char*)pData,
! dwLength,
! 0,
! hszItem,
! wFmt,
! 0);
!
break;
--- 1699,1704 ----
}
! } // end locals scope
! // Data already setup via 'allocr' param, so we are done.
break;
***************
*** 1805,1809 ****
BOOL CDDEServer::Request(UINT wFmt, const TCHAR* pszTopic, const TCHAR* pszItem,
! void** ppData, DWORD* pdwSize)
{
//
--- 1784,1788 ----
BOOL CDDEServer::Request(UINT wFmt, const TCHAR* pszTopic, const TCHAR* pszItem,
! CDDEAllocator &allocr)
{
//
***************
*** 1814,1818 ****
if (!pTopic) return FALSE;
! return pTopic->Request(wFmt, pszItem, ppData, pdwSize);
}
--- 1793,1797 ----
if (!pTopic) return FALSE;
! return pTopic->Request(wFmt, pszItem, allocr);
}
Index: win32virt.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32virt.cpp,v
retrieving revision 1.6.2.1
retrieving revision 1.6.2.2
diff -C2 -d -r1.6.2.1 -r1.6.2.2
*** win32virt.cpp 29 Aug 2008 05:53:30 -0000 1.6.2.1
--- win32virt.cpp 6 Dec 2008 01:48:26 -0000 1.6.2.2
***************
*** 545,580 ****
}
- BOOL CVirtualHelper::retval( char *&ret )
- {
- ASSERT(retVal);
- if (!retVal)
- return FALSE; // failed - assume didnt work in non debug
- if (retVal==Py_None) {
- ret = NULL;
- return TRUE;
- }
- CEnterLeavePython _celp;
- ret = PyString_AsString(retVal);
- if (ret == NULL) {
- gui_print_error();
- return FALSE;
- }
- return TRUE;
- }
-
- BOOL CVirtualHelper::retval(WCHAR *&ret )
- {
- ASSERT(retVal);
- if (!retVal)
- return FALSE; // failed - assume didnt work in non debug
- CEnterLeavePython _celp;
- // ??? This leaks memory, but this overload is not actually used anywhere ???
- if (!PyWinObject_AsWCHAR(retVal, &ret, TRUE)){
- gui_print_error();
- return FALSE;
- }
- return TRUE;
- }
-
BOOL CVirtualHelper::retval( CString &ret )
{
--- 545,548 ----
Index: ddeconv.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/ddeconv.cpp,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -C2 -d -r1.1.4.1 -r1.1.4.2
*** ddeconv.cpp 29 Aug 2008 05:53:28 -0000 1.1.4.1
--- ddeconv.cpp 6 Dec 2008 01:48:26 -0000 1.1.4.2
***************
*** 82,95 ****
if (!PyWinObject_AsTCHAR(obCmd, &szCmd, FALSE))
return NULL;
GUI_BGN_SAVE;
! void *ppData ;
! DWORD pdwSize ;
! BOOL ok = pConv->Request(szCmd, &ppData, &pdwSize);
GUI_END_SAVE;
PyWinObject_FreeTCHAR(szCmd);
if (!ok)
RETURN_DDE_ERR("Request failed");
! PyObject * result = PyWinObject_FromTCHAR((TCHAR *)ppData);
! free(ppData) ;
return result ;
}
--- 82,93 ----
if (!PyWinObject_AsTCHAR(obCmd, &szCmd, FALSE))
return NULL;
+ CString ret;
GUI_BGN_SAVE;
! BOOL ok = pConv->Request(szCmd, ret);
GUI_END_SAVE;
PyWinObject_FreeTCHAR(szCmd);
if (!ok)
RETURN_DDE_ERR("Request failed");
! PyObject * result = PyWinObject_FromTCHAR((const TCHAR *)ret);
return result ;
}
|