pywin32-checkins Mailing List for Python for Windows Extensions (Page 101)
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
(6) |
Jul
(50) |
Aug
(11) |
Sep
(24) |
Oct
(184) |
Nov
(118) |
Dec
(22) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(31) |
Feb
(25) |
Mar
(34) |
Apr
(105) |
May
(49) |
Jun
(38) |
Jul
(39) |
Aug
(7) |
Sep
(98) |
Oct
(79) |
Nov
(20) |
Dec
(17) |
2005 |
Jan
(66) |
Feb
(32) |
Mar
(43) |
Apr
(30) |
May
(58) |
Jun
(30) |
Jul
(16) |
Aug
(4) |
Sep
(21) |
Oct
(42) |
Nov
(11) |
Dec
(14) |
2006 |
Jan
(42) |
Feb
(30) |
Mar
(22) |
Apr
(1) |
May
(9) |
Jun
(15) |
Jul
(20) |
Aug
(9) |
Sep
(8) |
Oct
(1) |
Nov
(9) |
Dec
(43) |
2007 |
Jan
(52) |
Feb
(45) |
Mar
(20) |
Apr
(12) |
May
(59) |
Jun
(39) |
Jul
(35) |
Aug
(31) |
Sep
(17) |
Oct
(20) |
Nov
(4) |
Dec
(4) |
2008 |
Jan
(28) |
Feb
(111) |
Mar
(4) |
Apr
(27) |
May
(40) |
Jun
(27) |
Jul
(32) |
Aug
(94) |
Sep
(87) |
Oct
(153) |
Nov
(336) |
Dec
(331) |
2009 |
Jan
(298) |
Feb
(127) |
Mar
(20) |
Apr
(8) |
May
|
Jun
(10) |
Jul
(6) |
Aug
|
Sep
(2) |
Oct
(2) |
Nov
|
Dec
(1) |
2010 |
Jan
(7) |
Feb
(1) |
Mar
|
Apr
|
May
(15) |
Jun
(4) |
Jul
(3) |
Aug
(28) |
Sep
(1) |
Oct
(19) |
Nov
(16) |
Dec
(6) |
2011 |
Jan
(2) |
Feb
(18) |
Mar
(17) |
Apr
(12) |
May
(5) |
Jun
(11) |
Jul
(7) |
Aug
(2) |
Sep
(2) |
Oct
(4) |
Nov
(4) |
Dec
|
2012 |
Jan
(6) |
Feb
(2) |
Mar
|
Apr
(8) |
May
(4) |
Jun
(3) |
Jul
(13) |
Aug
(27) |
Sep
(8) |
Oct
(9) |
Nov
(3) |
Dec
(2) |
2013 |
Jan
|
Feb
(1) |
Mar
(5) |
Apr
(10) |
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(9) |
2014 |
Jan
(2) |
Feb
(4) |
Mar
(4) |
Apr
(1) |
May
(4) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
(1) |
2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
(6) |
May
(2) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
(3) |
Feb
(2) |
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: Mark H. <mha...@us...> - 2006-07-11 06:58:54
|
Update of /cvsroot/pywin32/pywin32/AutoDuck In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15527 Modified Files: makedfromi.py Log Message: Roger notes that once he rearranged win32gui, we stopped crashing after 90 methods - so no longer need to 'split' win32gui in the chm Index: makedfromi.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/AutoDuck/makedfromi.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** makedfromi.py 30 Jan 2005 13:37:24 -0000 1.7 --- makedfromi.py 11 Jul 2006 06:58:52 -0000 1.8 *************** *** 86,90 **** # autoduck seems to crash when > ~97 methods. Loop multiple times, # creating a synthetic module name when this happens. ! max_methods = 90 method_num = 0 chunk_number = 0 --- 86,92 ---- # autoduck seems to crash when > ~97 methods. Loop multiple times, # creating a synthetic module name when this happens. ! # Hrmph - maybe this was related to the way we generate - ! # see rev 1.80 of win32gui.i for a change that prevents this! ! max_methods = 999 method_num = 0 chunk_number = 0 |
From: Mark H. <mha...@us...> - 2006-07-11 05:18:32
|
Update of /cvsroot/pywin32/pywin32/Pythonwin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11002 Modified Files: win32cmd.cpp win32uimodule.cpp win32virt.cpp win32win.cpp Log Message: Fix bugs [1512715 ] CVirtualHelper::call / do_call double DODECREF Bug ? and [1489690 ] Memory Leak: PyCWnd objects are never freed. Thanks to kxroberto for help tracking these down. Index: win32virt.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32virt.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** win32virt.cpp 7 Oct 2004 08:45:24 -0000 1.2 --- win32virt.cpp 11 Jul 2006 05:18:30 -0000 1.3 *************** *** 54,58 **** py_ob = py_bob; Py_INCREF(py_ob); - // Py_XINCREF(handler); } CVirtualHelper::~CVirtualHelper() --- 54,57 ---- *************** *** 387,391 **** PyObject *arglst = Py_BuildValue("((iiiii(ii)))",msg->hwnd,msg->message,msg->wParam,msg->lParam,msg->time,msg->pt.x,msg->pt.y); BOOL ret = do_call(arglst); - DODECREF(arglst); // my reference. return ret; } --- 386,389 ---- *************** *** 396,400 **** PyObject *arglst = Py_BuildValue("iill",nID, nCode, (long)pExtra, (long)pHandlerInfo); BOOL ret = do_call(arglst); - DODECREF(arglst); // my reference. return ret; } --- 394,397 ---- Index: win32uimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32uimodule.cpp,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** win32uimodule.cpp 21 Jun 2006 12:23:22 -0000 1.31 --- win32uimodule.cpp 11 Jul 2006 05:18:30 -0000 1.32 *************** *** 774,779 **** result = gui_call_object( pCallbackCaller, newarglst ); DODECREF(newarglst); ! } else result = gui_call_object( themeth, thearglst ); DODECREF(thearglst); if (result==NULL) { --- 774,785 ---- result = gui_call_object( pCallbackCaller, newarglst ); DODECREF(newarglst); ! } else { ! // Only ref to 'themeth' may be map - and if the message hook ! // updates the map (ie, removes the function), things get ! // a little pear-shaped - as witnessed in bug 1489690. ! Py_XINCREF(themeth); result = gui_call_object( themeth, thearglst ); + Py_XDECREF(themeth); + } DODECREF(thearglst); if (result==NULL) { Index: win32win.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32win.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** win32win.cpp 18 Apr 2005 13:36:46 -0000 1.9 --- win32win.cpp 11 Jul 2006 05:18:30 -0000 1.10 *************** *** 264,268 **** CHECK_NO_ARGS(args); CWnd *pWnd = new CPythonWndFramework< CWnd >(); ! return ui_assoc_object::make( PyCWnd::type, pWnd ); } // @pymethod |PyCWnd|CreateWindow|Creates the actual window --- 264,273 ---- CHECK_NO_ARGS(args); CWnd *pWnd = new CPythonWndFramework< CWnd >(); ! PyCWnd *pRet = (PyCWnd *)ui_assoc_object::make( PyCWnd::type, pWnd ); ! // We explicitly created this CWnd, so we must explicitly nuke it! ! if (pRet) { ! pRet->bManualDelete = TRUE; ! } ! return pRet; } // @pymethod |PyCWnd|CreateWindow|Creates the actual window Index: win32cmd.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32cmd.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** win32cmd.cpp 1 Sep 1999 23:33:00 -0000 1.1 --- win32cmd.cpp 11 Jul 2006 05:18:30 -0000 1.2 *************** *** 220,224 **** if (pList->Lookup(message, oldMethod)) { pList->RemoveKey(message); ! // DODECREF((PyObject *)oldMethod); DODECREF(hookedObject); } --- 220,224 ---- if (pList->Lookup(message, oldMethod)) { pList->RemoveKey(message); ! // oldMethod is returned - don't drop its reference. DODECREF(hookedObject); } |
From: Mark H. <mha...@us...> - 2006-07-10 13:10:19
|
Update of /cvsroot/pywin32/pywin32/SWIG/swig_lib/python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6077/SWIG/swig_lib/python Modified Files: pythoncom.i Log Message: Add IDispatch as a 'native' SWIG type. Index: pythoncom.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/SWIG/swig_lib/python/pythoncom.i,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pythoncom.i 21 Oct 2005 06:14:03 -0000 1.3 --- pythoncom.i 10 Jul 2006 13:10:08 -0000 1.4 *************** *** 74,77 **** --- 74,81 ---- $target = &temp; } + %typemap(python,ignore) IDispatch **OUTPUT(IDispatch *temp) + { + $target = &temp; + } %{ *************** *** 113,116 **** --- 117,124 ---- } + %typemap(python,argout) IDispatch **OUTPUT { + MAKE_OUTPUT_INTERFACE($source, $target, IID_IDispatch) + } + %typemap(python,freearg) IUnknown *INPUT, IUnknown *INPUT_NULLOK, |
From: Mark H. <mha...@us...> - 2006-07-10 13:09:07
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/adsi/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5719/com/win32comext/adsi/src Modified Files: PyIADsContainer.i Log Message: Add IADsContainer.GetObject Index: PyIADsContainer.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/adsi/src/PyIADsContainer.i,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyIADsContainer.i 5 May 2000 00:42:00 -0000 1.1 --- PyIADsContainer.i 10 Jul 2006 13:08:57 -0000 1.2 *************** *** 28,31 **** --- 28,36 ---- %} + // @pyswig <o PyIDispatch>|GetObject| + // @pyparm string|class||Specifies the name of the object class as known in the underlying directory and identical to the one retrieved through the get_Class property method. If the class name is None, the provider returns the first item found in the container. + // @pyparm string|relativeName||Specifies the name of the object as known in the underlying directory and identical to the one retrieved through the get_Name property method. + HRESULT GetObject(WCHAR *INPUT_NULLOK, WCHAR *INPUT_NULLOK, IDispatch **OUTPUT); + // @pyswig int|get_Count| HRESULT get_Count(long *OUTPUT); |
From: Mark H. <mha...@us...> - 2006-07-02 23:30:15
|
Update of /cvsroot/pywin32/pywin32/win32/Demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23610 Modified Files: win32gui_menu.py Log Message: Demonstrate owner-draw of the icon only via HBMMENU_CALLBACK. Index: win32gui_menu.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Demos/win32gui_menu.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** win32gui_menu.py 2 Jul 2006 06:46:36 -0000 1.3 --- win32gui_menu.py 2 Jul 2006 23:30:12 -0000 1.4 *************** *** 128,137 **** # item to the menu. index = 0 ! self.menu_item_map[index] = (hicon, "Menu with icon") item, extras = PackMENUITEMINFO(fType=win32con.MFT_OWNERDRAW, ! dwTypeData=index, wID=1009) InsertMenuItem(menu, 0, 1, item) # Create a sub-menu, and put a few funky ones there. self.sub_menu = sub_menu = CreatePopupMenu() --- 128,170 ---- # item to the menu. index = 0 ! self.menu_item_map[index] = (hicon, "Menu with owner-draw icon") item, extras = PackMENUITEMINFO(fType=win32con.MFT_OWNERDRAW, ! dwItemData=index, wID=1009) InsertMenuItem(menu, 0, 1, item) + # Add another icon-based icon - but this time using HBMMENU_CALLBACK + # in the hbmpItem elt, so we only need to draw the icon (ie, not the + # text or checkmark) + index = 1 + self.menu_item_map[index] = (hicon, None) + item, extras = PackMENUITEMINFO(text="Menu with o-d icon 2", + dwItemData=index, + hbmpItem=win32con.HBMMENU_CALLBACK, + wID=1010) + InsertMenuItem(menu, 0, 1, item) + + # Add another icon-based icon - this time by converting + # via bitmap. Note the icon background when selected is ugly :( + hdcBitmap = CreateCompatibleDC(0) + hdcScreen = GetDC(0) + hbm = CreateCompatibleBitmap(hdcScreen, ico_x, ico_y) + hbmOld = SelectObject(hdcBitmap, hbm) + SetBkMode(hdcBitmap, win32con.TRANSPARENT) + # Fill the background. + brush = GetSysColorBrush(win32con.COLOR_MENU) + FillRect(hdcBitmap, (0, 0, 16, 16), brush) + # unclear if brush needs to be freed. Best clue I can find is: + # "GetSysColorBrush returns a cached brush instead of allocating a new + # one." - implies no DeleteObject. + # draw the icon + DrawIconEx(hdcBitmap, 0, 0, hicon, ico_x, ico_y, 0, 0, win32con.DI_NORMAL) + SelectObject(hdcBitmap, hbmOld) + DeleteDC(hdcBitmap) + item, extras = PackMENUITEMINFO(text="Menu with icon", + hbmpItem=hbm, + wID=1011) + InsertMenuItem(menu, 0, 1, item) + # Create a sub-menu, and put a few funky ones there. self.sub_menu = sub_menu = CreatePopupMenu() *************** *** 164,189 **** SetMenuDefaultItem(menu, 1000, 0) - # For reference: old code that converted icon to bitmap (but that - # code left an ugly background on the icons when the item was selected) - """ - hdcBitmap = CreateCompatibleDC(0) - hdcScreen = GetDC(0) - hbm = CreateCompatibleBitmap(hdcScreen, ico_x, ico_y) - hbmOld = SelectObject(hdcBitmap, hbm) - SetBkMode(hdcBitmap, win32con.TRANSPARENT) - # Fill the background. - brush = GetSysColorBrush(win32con.COLOR_MENU) - FillRect(hdcBitmap, (0, 0, 16, 16), brush) - # unclear if brush needs to be freed. Best clue I can find is: - # "GetSysColorBrush returns a cached brush instead of allocating a new - # one." - implies no DeleteObject. - # draw the icon - DrawIconEx(hdcBitmap, 0, 0, hicon, ico_x, ico_y, 0, 0, win32con.DI_NORMAL) - SelectObject(hdcBitmap, hbmOld) - DeleteDC(hdcBitmap) - item, extras = PackMENUITEMINFO(text="Menu with icon", - hbmpItem=hbm, - wID=1009) - """ def OnDestroy(self, hwnd, msg, wparam, lparam): --- 197,200 ---- *************** *** 251,264 **** hicon, text = self.menu_item_map[itemData] ! dc = GetDC(hwnd) ! oldFont = SelectObject(dc, self.font_menu) ! cx, cy = GetTextExtentPoint32(dc, text) ! SelectObject(dc, oldFont) ! ReleaseDC(hwnd, dc) ! ! cx += GetSystemMetrics(win32con.SM_CXMENUCHECK) ! cx += self.menu_icon_width + self.icon_x_pad ! ! cy = GetSystemMetrics(win32con.SM_CYMENU) new_data = struct.pack(fmt, ctlType, ctlID, itemID, cx, cy, itemData) PySetMemory(lparam, new_data) --- 262,282 ---- hicon, text = self.menu_item_map[itemData] ! if text is None: ! # Only drawing icon due to HBMMENU_CALLBACK ! cx = self.menu_icon_width ! cy = self.menu_icon_height ! else: ! # drawing the lot! ! dc = GetDC(hwnd) ! oldFont = SelectObject(dc, self.font_menu) ! cx, cy = GetTextExtentPoint32(dc, text) ! SelectObject(dc, oldFont) ! ReleaseDC(hwnd, dc) ! ! cx += GetSystemMetrics(win32con.SM_CXMENUCHECK) ! cx += self.menu_icon_width + self.icon_x_pad ! ! cy = GetSystemMetrics(win32con.SM_CYMENU) ! new_data = struct.pack(fmt, ctlType, ctlID, itemID, cx, cy, itemData) PySetMemory(lparam, new_data) *************** *** 274,307 **** hicon, text = self.menu_item_map[itemData] ! # If the user has selected the item, use the selected ! # text and background colors to display the item. ! selected = itemState & win32con.ODS_SELECTED ! if selected: ! crText = SetTextColor(hDC, GetSysColor(win32con.COLOR_HIGHLIGHTTEXT)) ! crBkgnd = SetBkColor(hDC, GetSysColor(win32con.COLOR_HIGHLIGHT)) ! ! each_pad = self.icon_x_pad / 2 ! x_icon = left + GetSystemMetrics(win32con.SM_CXMENUCHECK) + each_pad ! x_text = x_icon + self.menu_icon_width + each_pad ! ! # Draw text first, specifying a complete rect to fill - this sets ! # up the background (but overwrites anything else already there!) ! # Select the font, draw it, and restore the previous font. ! hfontOld = SelectObject(hDC, self.font_menu) ! ExtTextOut(hDC, x_text, top+2, win32con.ETO_OPAQUE, rect, text) ! SelectObject(hDC, hfontOld) ! ! # Icon image next. Icons are transparent - no need to handle ! # selection specially. ! DrawIconEx(hDC, x_icon, top+2, hicon, ! self.menu_icon_width, self.menu_icon_height, ! 0, 0, win32con.DI_NORMAL) ! ! # Return the text and background colors to their ! # normal state (not selected). ! if selected: ! SetTextColor(hDC, crText) ! SetBkColor(hDC, crBkgnd) ! def main(): --- 292,330 ---- hicon, text = self.menu_item_map[itemData] ! if text is None: ! # This means the menu-item had HBMMENU_CALLBACK - so all we ! # draw is the icon. rect is the entire area we should use. ! DrawIconEx(hDC, left, top, hicon, right-left, bot-top, ! 0, 0, win32con.DI_NORMAL) ! else: ! # If the user has selected the item, use the selected ! # text and background colors to display the item. ! selected = itemState & win32con.ODS_SELECTED ! if selected: ! crText = SetTextColor(hDC, GetSysColor(win32con.COLOR_HIGHLIGHTTEXT)) ! crBkgnd = SetBkColor(hDC, GetSysColor(win32con.COLOR_HIGHLIGHT)) ! ! each_pad = self.icon_x_pad / 2 ! x_icon = left + GetSystemMetrics(win32con.SM_CXMENUCHECK) + each_pad ! x_text = x_icon + self.menu_icon_width + each_pad ! ! # Draw text first, specifying a complete rect to fill - this sets ! # up the background (but overwrites anything else already there!) ! # Select the font, draw it, and restore the previous font. ! hfontOld = SelectObject(hDC, self.font_menu) ! ExtTextOut(hDC, x_text, top+2, win32con.ETO_OPAQUE, rect, text) ! SelectObject(hDC, hfontOld) ! ! # Icon image next. Icons are transparent - no need to handle ! # selection specially. ! DrawIconEx(hDC, x_icon, top+2, hicon, ! self.menu_icon_width, self.menu_icon_height, ! 0, 0, win32con.DI_NORMAL) ! ! # Return the text and background colors to their ! # normal state (not selected). ! if selected: ! SetTextColor(hDC, crText) ! SetBkColor(hDC, crBkgnd) def main(): |
From: Mark H. <mha...@us...> - 2006-07-02 23:28:49
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23151/win32/lib Modified Files: win32gui_struct.py Log Message: Correct confusion in win32gui_struct between 'dwTypeData' and 'dwItemData' Index: win32gui_struct.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32gui_struct.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** win32gui_struct.py 12 Apr 2005 03:33:45 -0000 1.8 --- win32gui_struct.py 2 Jul 2006 23:28:46 -0000 1.9 *************** *** 47,55 **** def PackMENUITEMINFO(fType=None, fState=None, wID=None, hSubMenu=None, ! hbmpChecked=None, hbmpUnchecked=None, dwTypeData=None, ! text=None, hbmpItem=None): # 'extras' are objects the caller must keep a reference to (as their # memory is used) for the lifetime of the INFO item. extras = [] fMask = 0 if fType is None: fType = 0 --- 47,65 ---- def PackMENUITEMINFO(fType=None, fState=None, wID=None, hSubMenu=None, ! hbmpChecked=None, hbmpUnchecked=None, dwItemData=None, ! text=None, hbmpItem=None, dwTypeData=None): # 'extras' are objects the caller must keep a reference to (as their # memory is used) for the lifetime of the INFO item. extras = [] + # ack - dwItemData and dwTypeData were confused for a while... + assert dwItemData is None or dwTypeData is None, \ + "sorry - these were confused - you probably want dwItemData" + # if we are a long way past 209, then we can nuke the above... + if dwTypeData is not None: + import warnings + warnings.warn("PackMENUITEMINFO: please use dwItemData instead of dwTypeData") + if dwItemData is None: + dwItemData = dwTypeData or 0 + fMask = 0 if fType is None: fType = 0 *************** *** 69,73 **** "neither or both checkmark bmps must be given" fMask |= win32con.MIIM_CHECKMARKS ! if dwTypeData is None: dwTypeData = 0 else: fMask |= win32con.MIIM_DATA if hbmpItem is None: hbmpItem = 0 --- 79,83 ---- "neither or both checkmark bmps must be given" fMask |= win32con.MIIM_CHECKMARKS ! if dwItemData is None: dwItemData = 0 else: fMask |= win32con.MIIM_DATA if hbmpItem is None: hbmpItem = 0 *************** *** 87,91 **** cch = 0 # Create the struct. - dwItemData = 0 item = struct.pack( menuitem_fmt, --- 97,100 ---- |
From: Mark H. <mha...@us...> - 2006-07-02 06:46:40
|
Update of /cvsroot/pywin32/pywin32/win32/Demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8468 Modified Files: win32gui_menu.py Log Message: demo of owner-drawn menus. Index: win32gui_menu.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Demos/win32gui_menu.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** win32gui_menu.py 7 Sep 2004 02:05:36 -0000 1.2 --- win32gui_menu.py 2 Jul 2006 06:46:36 -0000 1.3 *************** *** 29,32 **** --- 29,35 ---- win32con.WM_COMMAND: self.OnCommand, win32con.WM_USER+20 : self.OnTaskbarNotify, + # owner-draw related handlers. + win32con.WM_MEASUREITEM: self.OnMeasureItem, + win32con.WM_DRAWITEM: self.OnDrawItem, } # Register the Window class. *************** *** 54,58 **** --- 57,76 ---- hicon = LoadIcon(0, win32con.IDI_APPLICATION) self.iconPathName = iconPathName + + # Load up some information about menus needed by our owner-draw code. + # The font to use on the menu. + ncm = SystemParametersInfo(win32con.SPI_GETNONCLIENTMETRICS) + self.font_menu = CreateFontIndirect(ncm['lfMenuFont']) + # spacing for our ownerdraw menus - not sure exactly what constants + # should be used (and if you owner-draw all items on the menu, it + # doesn't matter!) + self.menu_icon_height = GetSystemMetrics(win32con.SM_CYMENU) - 4 + self.menu_icon_width = self.menu_icon_height + self.icon_x_pad = 8 # space from end of icon to start of text. + # A map we use to stash away data we need for ownerdraw. Keyed + # by integer ID - that ID will be set in dwTypeData of the menu item. + self.menu_item_map = {} + # Finally, create the menu self.createMenu() *************** *** 87,93 **** InsertMenuItem(menu, 0, 1, item) ! # Create one with an icon - this is a fair bit more work, as we need ! # to convert the icon to a bitmap. ! # First load the icon. ico_x = GetSystemMetrics(win32con.SM_CXSMICON) ico_y = GetSystemMetrics(win32con.SM_CYSMICON) --- 105,118 ---- InsertMenuItem(menu, 0, 1, item) ! # Owner-draw menus mainly from: ! # http://windowssdk.msdn.microsoft.com/en-us/library/ms647558.aspx ! # and: ! # http://www.codeguru.com/cpp/controls/menu/bitmappedmenus/article.php/c165 ! ! # Create one with an icon - this is *lots* more work - we do it ! # owner-draw! The primary reason is to handle transparency better - ! # converting to a bitmap causes the background to be incorrect when ! # the menu item is selected. I can't see a simpler way. ! # First, load the icon we want to use. ico_x = GetSystemMetrics(win32con.SM_CXSMICON) ico_y = GetSystemMetrics(win32con.SM_CYSMICON) *************** *** 100,120 **** DestroyIcon(large[0]) ! hdcBitmap = CreateCompatibleDC(0) ! hdcScreen = GetDC(0) ! hbm = CreateCompatibleBitmap(hdcScreen, ico_x, ico_y) ! hbmOld = SelectObject(hdcBitmap, hbm) ! # Fill the background. ! brush = GetSysColorBrush(win32con.COLOR_MENU) ! FillRect(hdcBitmap, (0, 0, 16, 16), brush) ! # unclear if brush needs to be feed. Best clue I can find is: ! # "GetSysColorBrush returns a cached brush instead of allocating a new ! # one." - implies no DeleteObject ! # draw the icon ! DrawIconEx(hdcBitmap, 0, 0, hicon, ico_x, ico_y, 0, 0, win32con.DI_NORMAL) ! SelectObject(hdcBitmap, hbmOld) ! DeleteDC(hdcBitmap) ! ! item, extras = PackMENUITEMINFO(text="Menu with icon", ! hbmpItem=hbm, wID=1009) InsertMenuItem(menu, 0, 1, item) --- 125,134 ---- DestroyIcon(large[0]) ! # Stash away the text and hicon in our map, and add the owner-draw ! # item to the menu. ! index = 0 ! self.menu_item_map[index] = (hicon, "Menu with icon") ! item, extras = PackMENUITEMINFO(fType=win32con.MFT_OWNERDRAW, ! dwTypeData=index, wID=1009) InsertMenuItem(menu, 0, 1, item) *************** *** 149,153 **** # Set 'Exit' as the default option. SetMenuDefaultItem(menu, 1000, 0) ! def OnDestroy(self, hwnd, msg, wparam, lparam): nid = (self.hwnd, 0) --- 163,190 ---- # Set 'Exit' as the default option. SetMenuDefaultItem(menu, 1000, 0) ! ! # For reference: old code that converted icon to bitmap (but that ! # code left an ugly background on the icons when the item was selected) ! """ ! hdcBitmap = CreateCompatibleDC(0) ! hdcScreen = GetDC(0) ! hbm = CreateCompatibleBitmap(hdcScreen, ico_x, ico_y) ! hbmOld = SelectObject(hdcBitmap, hbm) ! SetBkMode(hdcBitmap, win32con.TRANSPARENT) ! # Fill the background. ! brush = GetSysColorBrush(win32con.COLOR_MENU) ! FillRect(hdcBitmap, (0, 0, 16, 16), brush) ! # unclear if brush needs to be freed. Best clue I can find is: ! # "GetSysColorBrush returns a cached brush instead of allocating a new ! # one." - implies no DeleteObject. ! # draw the icon ! DrawIconEx(hdcBitmap, 0, 0, hicon, ico_x, ico_y, 0, 0, win32con.DI_NORMAL) ! SelectObject(hdcBitmap, hbmOld) ! DeleteDC(hdcBitmap) ! item, extras = PackMENUITEMINFO(text="Menu with icon", ! hbmpItem=hbm, ! wID=1009) ! """ ! def OnDestroy(self, hwnd, msg, wparam, lparam): nid = (self.hwnd, 0) *************** *** 175,181 **** def OnCommand(self, hwnd, msg, wparam, lparam): id = LOWORD(wparam) - print "OnCommand for control ID", id - def OnCommand(self, hwnd, msg, wparam, lparam): - id = LOWORD(wparam) if id == 1000: print "Goodbye" --- 212,215 ---- *************** *** 208,211 **** --- 242,308 ---- print "OnCommand for ID", id + # Owner-draw related functions. We only have 1 owner-draw item, but + # we pretend we have more than that :) + def OnMeasureItem(self, hwnd, msg, wparam, lparam): + fmt = "6i" + buf = PyMakeBuffer(struct.calcsize(fmt), lparam) + data = struct.unpack(fmt, buf) + ctlType, ctlID, itemID, itemWidth, itemHeight, itemData = data + + hicon, text = self.menu_item_map[itemData] + dc = GetDC(hwnd) + oldFont = SelectObject(dc, self.font_menu) + cx, cy = GetTextExtentPoint32(dc, text) + SelectObject(dc, oldFont) + ReleaseDC(hwnd, dc) + + cx += GetSystemMetrics(win32con.SM_CXMENUCHECK) + cx += self.menu_icon_width + self.icon_x_pad + + cy = GetSystemMetrics(win32con.SM_CYMENU) + new_data = struct.pack(fmt, ctlType, ctlID, itemID, cx, cy, itemData) + PySetMemory(lparam, new_data) + return True + + def OnDrawItem(self, hwnd, msg, wparam, lparam): + fmt = "12i" + data = struct.unpack(fmt, PyGetString(lparam, struct.calcsize(fmt))) + ctlType, ctlID, itemID, itemAction, itemState, hwndItem, \ + hDC, left, top, right, bot, itemData = data + + rect = left, top, right, bot + hicon, text = self.menu_item_map[itemData] + + # If the user has selected the item, use the selected + # text and background colors to display the item. + selected = itemState & win32con.ODS_SELECTED + if selected: + crText = SetTextColor(hDC, GetSysColor(win32con.COLOR_HIGHLIGHTTEXT)) + crBkgnd = SetBkColor(hDC, GetSysColor(win32con.COLOR_HIGHLIGHT)) + + each_pad = self.icon_x_pad / 2 + x_icon = left + GetSystemMetrics(win32con.SM_CXMENUCHECK) + each_pad + x_text = x_icon + self.menu_icon_width + each_pad + + # Draw text first, specifying a complete rect to fill - this sets + # up the background (but overwrites anything else already there!) + # Select the font, draw it, and restore the previous font. + hfontOld = SelectObject(hDC, self.font_menu) + ExtTextOut(hDC, x_text, top+2, win32con.ETO_OPAQUE, rect, text) + SelectObject(hDC, hfontOld) + + # Icon image next. Icons are transparent - no need to handle + # selection specially. + DrawIconEx(hDC, x_icon, top+2, hicon, + self.menu_icon_width, self.menu_icon_height, + 0, 0, win32con.DI_NORMAL) + + # Return the text and background colors to their + # normal state (not selected). + if selected: + SetTextColor(hDC, crText) + SetBkColor(hDC, crBkgnd) + + def main(): w=MainWindow() |
From: Mark H. <mha...@us...> - 2006-07-02 06:44:56
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7602 Modified Files: PyWinTypesmodule.cpp Log Message: Make it a little clearer we are calling Py_FatalError Index: PyWinTypesmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypesmodule.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** PyWinTypesmodule.cpp 1 Jun 2006 07:58:07 -0000 1.20 --- PyWinTypesmodule.cpp 2 Jul 2006 06:44:46 -0000 1.21 *************** *** 126,130 **** PyThreadState *threadStateSave = PyThreadState_Swap(NULL); if (threadStateSave==NULL) ! Py_FatalError("Can not setup interpreter state, as current state is invalid"); PyWin_InterpreterState = threadStateSave->interp; --- 126,130 ---- PyThreadState *threadStateSave = PyThreadState_Swap(NULL); if (threadStateSave==NULL) ! Py_FatalError("pywintypes: can not setup interpreter state, as current state is invalid"); PyWin_InterpreterState = threadStateSave->interp; |
From: Mark H. <mha...@us...> - 2006-07-02 06:44:36
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6052 Modified Files: win32gui.i Log Message: * Roger Upole helped with SPI_GETNONCLIENTMETRICS and SPI_SETNONCLIENTMETRICS support in SystemParametersInfo. * ExtTextOut (from win32ui), SetBkColor and DrawAnimatedRects. * Document that PySetString probably isn't what you want, and add PySetMemory which just takes bytes. Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.82 retrieving revision 1.83 diff -C2 -d -r1.82 -r1.83 *** win32gui.i 27 Jun 2006 09:48:42 -0000 1.82 --- win32gui.i 2 Jul 2006 06:43:36 -0000 1.83 *************** *** 1098,1101 **** --- 1098,1111 ---- } + BOOL PyWinObject_AsLOGFONT(PyObject *ob, LOGFONT *plf) + { + if (!PyLOGFONT_Check(ob)){ + PyErr_SetString(PyExc_TypeError, "Object must be a PyLOGFONT"); + return FALSE; + } + *plf=*((PyLOGFONT *)ob)->GetLF(); + return TRUE; + } + BOOL CALLBACK EnumFontFamProc(const LOGFONT FAR *lpelf, const TEXTMETRIC *lpntm, DWORD FontType, LPARAM lParam) { *************** *** 1288,1292 **** %{ ! // @pyswig object|PySetString|Copies a string to an address (null terminated) static PyObject *PySetString(PyObject *self, PyObject *args) { --- 1298,1303 ---- %{ ! // @pyswig object|PySetString|Copies a string to an address (null terminated). ! // You almost certainly should use <om win32gui.PySetMemory> instead. static PyObject *PySetString(PyObject *self, PyObject *args) { *************** *** 1322,1325 **** --- 1333,1360 ---- %native (PySetString) PySetString; + %{ + // @pyswig object|PySetMemory|Copies bytes to an address. + static PyObject *PySetMemory(PyObject *self, PyObject *args) + { + long addr; + char *src; + int nbytes; + + // @pyparm int|addr||Address of the memory to reference + // @pyparm string or buffer|String||The string to copy + if (!PyArg_ParseTuple(args, "ls#:PySetMemory",&addr,&src,&nbytes)) + return NULL; + + if (IsBadWritePtr((void *)addr, nbytes)) { + PyErr_SetString(PyExc_ValueError, + "The value is not a valid address for writing"); + return NULL; + } + memcpy( (void *)addr, src, nbytes); + Py_INCREF(Py_None); + return Py_None; + } + %} + %native (PySetMemory) PySetMemory; *************** *** 3469,3472 **** --- 3504,3579 ---- UINT uFormat); // @pyparm int|Format||Formatting flags, combination of win32con.DT_* values + %{ + //@pyswig int|ExtTextOut|Writes text to a DC. + static PyObject *PyExtTextOut(PyObject *self, PyObject *args) + { + char *text; + int strLen, x, y; + UINT options; + PyObject *rectObject, *widthObject = NULL; + RECT rect, *rectPtr; + int *widths = NULL; + int hdc; + if (!PyArg_ParseTuple (args, "iiiiOs#|O", + &hdc, + &x, // @pyparm x|int||The x coordinate to write the text to. + &y, // @pyparm y|int||The y coordinate to write the text to. + &options, // @pyparm nOptions|int||Specifies the rectangle type. This parameter can be one, both, or neither of ETO_CLIPPED and ETO_OPAQUE + &rectObject,// @pyparm (left, top, right, bottom)|rect||Specifies the text's bounding rectangle. (Can be None.) + &text, // @pyparm text|string||The text to write. + &strLen, + &widthObject)) // @pyparm (width1, width2, ...)|tuple||Optional array of values that indicate distance between origins of character cells. + return NULL; + + // Parse out rectangle object + if (rectObject != Py_None) { + if (!PyArg_ParseTuple(rectObject, "iiii", &rect.left, + &rect.top, &rect.right, &rect.bottom)) + return NULL; + rectPtr = ▭ + } + else + rectPtr = NULL; + + // Parse out widths + if (widthObject) { + BOOL error = !PyTuple_Check(widthObject); + if (!error) { + int len = PyTuple_Size(widthObject); + if (len == (strLen - 1)) { + widths = new int[len + 1]; + for (int i = 0; i < len; i++) { + PyObject *item = PyTuple_GetItem(widthObject, i); + if (!PyInt_Check(item)) + error = TRUE; + else + widths[i] = PyInt_AsLong(item); + } + } + } + if (error) { + delete [] widths; + return PyErr_Format(PyExc_TypeError, + "The width param must be a tuple of integers with a length one less than that of the string"); + } + } + + BOOL ok; + Py_BEGIN_ALLOW_THREADS; + // @pyseeapi ExtTextOut + ok = ExtTextOut((HDC)hdc, x, y, options, rectPtr, text, strLen, widths); + Py_END_ALLOW_THREADS; + delete [] widths; + if (!ok) + return PyWin_SetAPIError("ExtTextOut"); + Py_INCREF(Py_None); + return Py_None; + // @rdesc Always none. If the function fails, an exception is raised. + } + + %} + %native (ExtTextOut) PyExtTextOut; + + // @pyswig int|SetTextColor|Changes the text color for a device context // @rdesc Returns the previous color, or CLR_INVALID on failure *************** *** 3481,3488 **** --- 3588,3608 ---- int mode); // @pyparm int|BkMode||OPAQUE or TRANSPARENT + // @pyswig int|SetBkColor|Sets the background color for a device context + // @rdesc Returns the previous color, or CLR_INVALID on failure + int SetBkColor( + HDC hdc, // @pyparm int/<o PyHANDLE>|hdc||Handle to a device context + COLORREF col); // @pyparm int|color|| + // @pyswig |DrawEdge| BOOLAPI DrawEdge(HDC hdc, RECT *INPUT, UINT edge, UINT grfFlags); // @pyswig |FillRect| int FillRect(HDC hDC, RECT *INPUT, HBRUSH hbr); + // @pyswig |DrawAnimatedRects| + BOOLAPI DrawAnimatedRects( + HWND hwnd, // @pyparm int|hwnd||handle to clipping window + int idAni, // @pyparm int|idAni||type of animation + RECT *INPUT, // @pyparm RECT|minCoords||rectangle coordinates (minimized) + RECT *INPUT // // @pyparm RECT|restCoords||rectangle coordinates (restored) + ); // @pyswig |CreateSolidBrush| HBRUSH CreateSolidBrush(COLORREF color); *************** *** 4225,4228 **** --- 4345,4380 ---- } + BOOL PyWinObject_AsNONCLIENTMETRICS(PyObject *ob, NONCLIENTMETRICS *ncm) + { + static char *keywords[]={"iBorderWidth","iScrollWidth","iScrollHeight", + "iCaptionWidth","iCaptionHeight","lfCaptionFont", + "iSmCaptionWidth","iSmCaptionHeight","lfSmCaptionFont", + "iMenuWidth","iMenuHeight","lfMenuFont","lfStatusFont", + "lfMessageFont", NULL}; + BOOL ret; + ZeroMemory(ncm, sizeof(NONCLIENTMETRICS)); + ncm->cbSize=sizeof(NONCLIENTMETRICS); + + if (!PyDict_Check(ob)){ + PyErr_SetString(PyExc_TypeError, "NONCLIENTMETRICS must be a dict"); + return FALSE; + } + PyObject *dummy_args=PyTuple_New(0); + if (dummy_args==NULL) // should not happen, interpreter apparently caches the empty tuple + return FALSE; + ret=PyArg_ParseTupleAndKeywords(dummy_args, ob, "iiiiiO&iiO&iiO&O&O&:NONCLIENTMETRICS", keywords, + &ncm->iBorderWidth, &ncm->iScrollWidth, &ncm->iScrollHeight, + &ncm->iCaptionWidth, &ncm->iCaptionHeight, + PyWinObject_AsLOGFONT, &ncm->lfCaptionFont, + &ncm->iSmCaptionWidth, &ncm->iSmCaptionHeight, + PyWinObject_AsLOGFONT, &ncm->lfSmCaptionFont, + &ncm->iMenuWidth, &ncm->iMenuHeight, + PyWinObject_AsLOGFONT, &ncm->lfMenuFont, + PyWinObject_AsLOGFONT, &ncm->lfStatusFont, + PyWinObject_AsLOGFONT, &ncm->lfMessageFont); + Py_DECREF(dummy_args); + return ret; + } + static PyObject *PySystemParametersInfo(PyObject *self, PyObject *args, PyObject *kwargs) { *************** *** 4642,4647 **** goto done; break; #endif // !MS_WINCE ! // below are not handled yet // @flag SPI_SETDESKPATTERN|Unsupported (obsolete) --- 4794,4822 ---- goto done; break; + // @flag SPI_GETNONCLIENTMETRICS|Param must be None. The result is a dict. + case SPI_GETNONCLIENTMETRICS: + // @flag SPI_SETNONCLIENTMETRICS|Param is a dict in the form of a NONCLIENTMETRICS struct, as returned by SPI_GETNONCLIENTMETRICS operation + case SPI_SETNONCLIENTMETRICS: + buflen = sizeof(NONCLIENTMETRICS); + pvParam=malloc(buflen); + if (pvParam==NULL){ + PyErr_Format(PyExc_MemoryError,"Unable to allocate %d bytes", buflen); + goto done; + } + if (Action==SPI_GETNONCLIENTMETRICS){ + if (obParam!=Py_None) { + PyErr_Format(PyExc_ValueError, + "Don't supply a param for SPI_GETNONCLIENTMETRICS"); + goto done; + } + memset(pvParam, 0, buflen); + ((NONCLIENTMETRICS *)pvParam)->cbSize = buflen; + } + else + if (!PyWinObject_AsNONCLIENTMETRICS(obParam, (NONCLIENTMETRICS *)pvParam)) + goto done; + break; #endif // !MS_WINCE ! // below are not handled yet // @flag SPI_SETDESKPATTERN|Unsupported (obsolete) *************** *** 4660,4665 **** // @flag SPI_GETMINIMIZEDMETRICS|Not implemented yet // @flag SPI_SETMINIMIZEDMETRICS|Not implemented yet - // @flag SPI_GETNONCLIENTMETRICS|Not implemented yet - // @flag SPI_SETNONCLIENTMETRICS|Not implemented yet // @flag SPI_GETICONMETRICS|Not implemented yet // @flag SPI_SETICONMETRICS|Not implemented yet --- 4835,4838 ---- *************** *** 4785,4788 **** --- 4958,4981 ---- } break; + + case SPI_GETNONCLIENTMETRICS: { + NONCLIENTMETRICS *p = (NONCLIENTMETRICS *)pvParam; + ret = Py_BuildValue("{s:i,s:i,s:i,s:i,s:i,s:N,s:i,s:i,s:N,s:i,s:i,s:N,s:N,s:N}", + "iBorderWidth", p->iBorderWidth, + "iScrollWidth", p->iScrollWidth, + "iScrollHeight", p->iScrollHeight, + "iCaptionWidth", p->iCaptionWidth, + "iCaptionHeight", p->iCaptionHeight, + "lfCaptionFont", new PyLOGFONT(&p->lfCaptionFont), + "iSmCaptionWidth", p->iSmCaptionWidth, + "iSmCaptionHeight", p->iSmCaptionHeight, + "lfSmCaptionFont", new PyLOGFONT(&p->lfSmCaptionFont), + "iMenuWidth", p->iMenuWidth, + "iMenuHeight", p->iMenuHeight, + "lfMenuFont", new PyLOGFONT(&p->lfMenuFont), + "lfStatusFont", new PyLOGFONT(&p->lfStatusFont), + "lfMessageFont",new PyLOGFONT(&p->lfMessageFont)); + break; + } #endif // !MS_WINCE *************** *** 4800,4803 **** --- 4993,4998 ---- case SPI_SETANIMATION: #endif // !MS_WINCE + case SPI_GETNONCLIENTMETRICS: + case SPI_SETNONCLIENTMETRICS: case SPI_GETMOUSE: case SPI_SETMOUSE: |
From: Mark H. <mha...@us...> - 2006-06-23 00:33:34
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29671 Modified Files: win32process.i Log Message: Add CreateRemoteThread Index: win32process.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32process.i,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** win32process.i 10 Jan 2006 03:43:21 -0000 1.17 --- win32process.i 23 Jun 2006 00:33:30 -0000 1.18 *************** *** 382,385 **** --- 382,442 ---- %native (beginthreadex) mybeginthreadex; + %{ + // @pyswig <o PyHANDLE>, int|CreateRemoteThread|creates a thread that runs in + // the virtual address space of another process. + static PyObject *myCreateRemoteThread(PyObject *self, PyObject *args) + { + PyObject *obFunc, *obArgs, *obSA; + unsigned stackSize, flags; + int hprocess; + if (!PyArg_ParseTuple(args, "iOiOOi", + &hprocess, // @pyparm int|hprocess||The handle to the remote process. + &obSA, // @pyparm <o PySECURITY_ATTRIBUTES>|sa||The security attributes, or None + &stackSize, // @pyparm int|stackSize||Stack size for the new thread, or zero for the default size. + &obFunc, // @pyparm function|entryPoint||The thread function's address. + &obArgs, // @pyparm tuple|args||Args passed to the function. + &flags)) // @pyparm int|flags|| + return NULL; + if (!PyInt_Check(obFunc)) { + PyErr_SetString(PyExc_TypeError, "function must be an address"); + return NULL; + } + if (!PyInt_Check(obArgs)) { + PyErr_SetString(PyExc_TypeError, "args must be an address"); + return NULL; + } + SECURITY_ATTRIBUTES *pSA; + if (!PyWinObject_AsSECURITY_ATTRIBUTES( obSA, &pSA, TRUE )) + return NULL; + + HANDLE (WINAPI *pfnCreateRemoteThread)( HANDLE, LPSECURITY_ATTRIBUTES, SIZE_T, LPTHREAD_START_ROUTINE, LPVOID, DWORD, LPDWORD) = NULL; + HMODULE hmod = GetModuleHandle("kernel32.dll"); + if (hmod) + pfnCreateRemoteThread = (HANDLE (WINAPI *)( HANDLE, LPSECURITY_ATTRIBUTES, SIZE_T, LPTHREAD_START_ROUTINE, LPVOID, DWORD, LPDWORD)) + GetProcAddress(hmod, "CreateRemoteThread"); + if (pfnCreateRemoteThread==NULL) + return PyWin_SetAPIError("CreateRemoteThread", E_NOTIMPL); + + PyEval_InitThreads(); + HANDLE handle; + DWORD tid; + handle = (*pfnCreateRemoteThread)((HANDLE)hprocess, pSA, stackSize, + (LPTHREAD_START_ROUTINE )PyLong_AsVoidPtr(obFunc), + PyLong_AsVoidPtr(obArgs), + flags, &tid); + if (handle==(HANDLE)-1 || handle==(HANDLE)0) { + return PyWin_SetAPIError("CreateRemoteThread"); + } + // @comm The result is a tuple of the thread handle and thread ID. + PyObject *obHandle = PyWinObject_FromHANDLE((HANDLE)handle); + PyObject *rc = Py_BuildValue("Oi", obHandle, tid); + Py_DECREF(obHandle); + return rc; + } + + %} + + %native (CreateRemoteThread) myCreateRemoteThread; + #endif // MS_WINCE |
From: Mark H. <mha...@us...> - 2006-06-22 13:56:01
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27401/pywin/framework Modified Files: intpydde.py Log Message: Don't bother 'print'ing dde status messages if there's no status bar. Index: intpydde.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/intpydde.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** intpydde.py 1 Sep 1999 23:33:45 -0000 1.1 --- intpydde.py 22 Jun 2006 13:55:49 -0000 1.2 *************** *** 53,56 **** win32ui.SetStatusText(msg) except win32ui.error: ! print msg --- 53,56 ---- win32ui.SetStatusText(msg) except win32ui.error: ! pass |
From: Mark H. <mha...@us...> - 2006-06-21 12:23:25
|
Update of /cvsroot/pywin32/pywin32/Pythonwin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13965/Pythonwin Modified Files: win32uimodule.cpp Log Message: Update copyright (2004->2006) and remove my email addy from Pythonwin interactive window. Index: win32uimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32uimodule.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** win32uimodule.cpp 10 Jan 2006 04:39:43 -0000 1.30 --- win32uimodule.cpp 21 Jun 2006 12:23:22 -0000 1.31 *************** *** 2233,2237 **** ui_module_error = PyString_FromString(errorName); PyDict_SetItemString(dict, "error", ui_module_error); ! PyObject *copyright = PyString_FromString("Copyright 1994-2004 Mark Hammond (mha...@sk...)"); PyDict_SetItemString(dict, "copyright", copyright); Py_XDECREF(copyright); --- 2233,2239 ---- ui_module_error = PyString_FromString(errorName); PyDict_SetItemString(dict, "error", ui_module_error); ! // drop email addy - too many ppl use it for support requests for other ! // tools that simply embed Pythonwin... ! PyObject *copyright = PyString_FromString("Copyright 1994-2006 Mark Hammond"); PyDict_SetItemString(dict, "copyright", copyright); Py_XDECREF(copyright); |
From: Mark H. <mha...@us...> - 2006-06-21 12:19:43
|
Update of /cvsroot/pywin32/pywin32/com/win32com/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12463/win32com/test Modified Files: testPyComTest.py Log Message: test 64bit longs. Index: testPyComTest.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/testPyComTest.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** testPyComTest.py 13 Feb 2006 01:23:48 -0000 1.23 --- testPyComTest.py 21 Jun 2006 12:19:40 -0000 1.24 *************** *** 189,192 **** --- 189,195 ---- if o.GetSetVariant(o) != o: raise error, "GetSetVariant (dispatch) failed" + for l in sys.maxint, sys.maxint+1, 1 << 65L: + if o.GetSetVariant(l) != l: + raise error, "GetSetVariant (long) failed" if o.TestByRefVariant(2) != 4: raise error, "TestByRefVariant failed" |
From: Mark H. <mha...@us...> - 2006-06-21 12:19:00
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11442/win32com/src Modified Files: oleargs.cpp Log Message: Transfer Python longs as 64 bit integers if possible, other wish fall back to a double (which we previously did if we didn't fit into 32 bits) Index: oleargs.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/oleargs.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** oleargs.cpp 14 Mar 2006 12:12:44 -0000 1.35 --- oleargs.cpp 21 Jun 2006 12:18:51 -0000 1.36 *************** *** 66,85 **** else if (PyLong_Check(obj)) { ! double dval = PyLong_AsDouble(obj); ! BOOL isDword = FALSE; ! if (dval >= 0 && dval < (double)ULONG_MAX) ! { ! DWORD dwval = (DWORD)dval; ! if ((double)dwval == dval) ! { ! V_VT(var) = VT_UI4; ! V_UI4(var) = dwval; ! isDword = TRUE; ! } ! } ! if (!isDword) ! { V_VT(var) = VT_R8; V_R8(var) = dval; } } --- 66,91 ---- else if (PyLong_Check(obj)) { ! __int64 lval = PyLong_AsLongLong(obj); ! if (PyErr_Occurred() && !PyErr_ExceptionMatches(PyExc_OverflowError)) ! return FALSE; ! if (PyErr_Occurred()) { ! PyErr_Clear(); ! // too big for 64 bits! Use a double. ! double dval = PyLong_AsDouble(obj); V_VT(var) = VT_R8; V_R8(var) = dval; + } else { + // 64 bits is OK - but if it fits in 32 we will + // use that. + if (lval >= 0 && lval <= ULONG_MAX) { + V_VT(var) = VT_UI4; + V_UI4(var) = (unsigned long)lval; + } else if (lval >= LONG_MIN && lval <= LONG_MAX) { + V_VT(var) = VT_I4; + V_I4(var) = (long)lval; + } else { + V_VT(var) = VT_I8; + V_I8(var) = lval; + } } } |
From: Mark H. <mha...@us...> - 2006-06-21 12:15:49
|
Update of /cvsroot/pywin32/pywin32/com/win32com/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10922/win32com/test Modified Files: daodump.py Log Message: Get tests working with recent DAO versions. Index: daodump.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/daodump.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** daodump.py 18 Nov 2002 11:20:06 -0000 1.2 --- daodump.py 21 Jun 2006 12:15:46 -0000 1.3 *************** *** 49,63 **** def test(): ! import win32com.client.gencache ! if win32com.client.gencache.GetModuleForProgID("DAO.DBEngine.35") is None: ! print "DAO 3.5 does not seem to be installed or have makepy support" ! else: ! TestEngine(win32com.client.Dispatch("DAO.DBEngine.35")) ! ! if win32com.client.gencache.GetModuleForProgID("DAO.DBEngine.30") is None: ! print "DAO 3.0 does not seem to be installed or have makepy support" ! else: ! TestEngine(win32com.client.Dispatch("DAO.DBEngine.30")) ! if __name__=='__main__': --- 49,60 ---- def test(): ! for progid in ("DAO.DBEngine.36", "DAO.DBEngine.35", "DAO.DBEngine.30"): ! try: ! ob = win32com.client.gencache.EnsureDispatch(progid) ! except pythoncom.com_error: ! print progid, "does not seem to be installed" ! else: ! TestEngine(ob) ! break if __name__=='__main__': |
From: Mark H. <mha...@us...> - 2006-06-21 12:14:44
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/axdebug In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10118/win32comext/axdebug Modified Files: debugger.py Log Message: A 'parent' module may not be what the debugger expects. Index: debugger.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axdebug/debugger.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** debugger.py 18 Jun 2006 13:18:26 -0000 1.2 --- debugger.py 21 Jun 2006 12:14:42 -0000 1.3 *************** *** 38,42 **** # keep = keep and module.__name__=='__main__' if module and keep: ! # print "keeping", module.__name__ node = ModuleTreeNode(module) built_nodes[module] = node --- 38,42 ---- # keep = keep and module.__name__=='__main__' if module and keep: ! # print "keeping", module.__name__ node = ModuleTreeNode(module) built_nodes[module] = node *************** *** 52,56 **** parentModule = sys.modules[parent] BuildModule(parentModule, built_nodes, rootNode, create_node_fn, create_node_args) ! parentNode = built_nodes[parentModule].realNode node.Attach(parentNode) --- 52,57 ---- parentModule = sys.modules[parent] BuildModule(parentModule, built_nodes, rootNode, create_node_fn, create_node_args) ! if parentModule in built_nodes: ! parentNode = built_nodes[parentModule].realNode node.Attach(parentNode) |
From: Mark H. <mha...@us...> - 2006-06-21 12:08:09
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7734 Modified Files: test_win32file.py Log Message: Check the smallest possible buffer size works. Index: test_win32file.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32file.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** test_win32file.py 21 Mar 2006 01:10:00 -0000 1.9 --- test_win32file.py 21 Jun 2006 12:08:06 -0000 1.10 *************** *** 362,366 **** nbytes = win32file.GetOverlappedResult(dh, overlapped, True) if nbytes: ! bits = win32file.FILE_NOTIFY_INFORMATION(buf, 8192) changes.extend(bits) else: --- 362,366 ---- nbytes = win32file.GetOverlappedResult(dh, overlapped, True) if nbytes: ! bits = win32file.FILE_NOTIFY_INFORMATION(buf, nbytes) changes.extend(bits) else: |
From: Mark H. <mha...@us...> - 2006-06-21 12:07:24
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7706 Modified Files: test_win32api.py Log Message: Test short unicode names. Index: test_win32api.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32api.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** test_win32api.py 15 Mar 2006 04:00:08 -0000 1.9 --- test_win32api.py 21 Jun 2006 12:07:21 -0000 1.10 *************** *** 95,98 **** --- 95,116 ---- "Expected long name ('%s') to be original name ('%s')" % (long_name, fname)) + def testShortUnicodeNames(self): + try: + me = __file__ + except NameError: + me = sys.argv[0] + fname = os.path.abspath(me) + # passing unicode should cause GetShortPathNameW to be called. + short_name = win32api.GetShortPathName(unicode(fname)) + self.failUnless(isinstance(short_name, unicode)) + long_name = win32api.GetLongPathName(short_name) + self.failUnless(long_name==fname, \ + "Expected long name ('%s') to be original name ('%s')" % (long_name, fname)) + self.failUnlessEqual(long_name, win32api.GetLongPathNameW(short_name)) + long_name = win32api.GetLongPathNameW(short_name) + self.failUnless(type(long_name)==unicode, "GetLongPathNameW returned type '%s'" % (type(long_name),)) + self.failUnless(long_name==fname, \ + "Expected long name ('%s') to be original name ('%s')" % (long_name, fname)) + def testLongLongPathNames(self): # We need filename where the FQN is > 256 - simplest way is to create a |
From: Mark H. <mha...@us...> - 2006-06-21 12:06:55
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7105 Modified Files: win32apimodule.cpp Log Message: GetShortPathName returns Unicode if unicode is passed, and add VkKeyScan and VkKeyScanEx Index: win32apimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** win32apimodule.cpp 1 Jun 2006 07:58:07 -0000 1.58 --- win32apimodule.cpp 21 Jun 2006 12:06:52 -0000 1.59 *************** *** 1222,1225 **** --- 1222,1264 ---- } + // @pymethod int|win32api|VkKeyScan|Translates a character to the corresponding virtual-key code and shift state. + static PyObject * + PyVkKeyScan(PyObject * self, PyObject * args) + { + char *key; + int len; + // @pyparm chr|char||Specifies a character + if (!PyArg_ParseTuple(args, "s#:VkKeyScan", &key, &len)) + return (NULL); + if (len != 1) + return PyErr_Format(PyExc_ValueError, "arg must be a string of length 1"); + int ret; + PyW32_BEGIN_ALLOW_THREADS + // @pyseeapi VkKeyScan + ret = VkKeyScan(key[0]); + PyW32_END_ALLOW_THREADS + return PyInt_FromLong(ret); + } + + // @pymethod int|win32api|VkKeyScanEx|Translates a character to the corresponding virtual-key code and shift state. + static PyObject * + PyVkKeyScanEx(PyObject * self, PyObject * args) + { + char *key; + int len; + long kl; + // @pyparm chr|char||Specifies a character + if (!PyArg_ParseTuple(args, "s#l:VkKeyScanEx", &key, &len, &kl)) + return (NULL); + if (len != 1) + return PyErr_Format(PyExc_ValueError, "arg must be a string of length 1"); + int ret; + PyW32_BEGIN_ALLOW_THREADS + // @pyseeapi VkKeyScanEx + ret = VkKeyScanEx(key[0], (HKL)kl); + PyW32_END_ALLOW_THREADS + return PyInt_FromLong(ret); + } + // @pymethod int|win32api|GetLastError|Retrieves the calling threads last error code value. static PyObject * *************** *** 1661,1679 **** PyGetShortPathName(PyObject * self, PyObject * args) { ! char *path; ! if (!PyArg_ParseTuple(args, "s:GetShortPathName", &path)) return NULL; ! char szOutPath[_MAX_PATH]; ! // @pyseeapi GetShortPathName ! PyW32_BEGIN_ALLOW_THREADS ! DWORD rc = GetShortPathName(path, szOutPath, sizeof(szOutPath)); ! PyW32_END_ALLOW_THREADS ! if (rc==0) ! return ReturnAPIError("GetShortPathName"); ! if (rc>=sizeof(szOutPath)) ! return ReturnError("The pathname would be too big!!!"); ! return Py_BuildValue("s", szOutPath); // @comm The short path name is an 8.3 compatible file name. As the input path does // not need to be absolute, the returned name may be longer than the input path. } --- 1700,1741 ---- PyGetShortPathName(PyObject * self, PyObject * args) { ! PyObject *obPath; ! // @pyparm string/unicode|path||If a unicode object is passed, ! // GetShortPathNameW will be called and a unicode object returned. ! if (!PyArg_ParseTuple(args, "O:GetShortPathName", &obPath)) return NULL; ! if (PyString_Check(obPath)) { ! char *path; ! if (!PyWinObject_AsString(obPath, &path)) ! return NULL; ! ! char szOutPath[_MAX_PATH]; ! // @pyseeapi GetShortPathName ! PyW32_BEGIN_ALLOW_THREADS ! DWORD rc = GetShortPathName(path, szOutPath, sizeof(szOutPath)); ! PyW32_END_ALLOW_THREADS ! if (rc==0) ! return ReturnAPIError("GetShortPathName"); ! if (rc>=sizeof(szOutPath)) ! return ReturnError("The pathname would be too big!!!"); ! return Py_BuildValue("s", szOutPath); ! } else { ! WCHAR *path; ! if (!PyWinObject_AsWCHAR(obPath, &path)) ! return NULL; ! WCHAR szOutPath[_MAX_PATH]; ! // @pyseeapi GetShortPathName ! PyW32_BEGIN_ALLOW_THREADS ! DWORD rc = GetShortPathNameW(path, szOutPath, sizeof(szOutPath)); ! PyW32_END_ALLOW_THREADS ! if (rc==0) ! return ReturnAPIError("GetShortPathNameW"); ! if (rc>=sizeof(szOutPath)) ! return ReturnError("The (unicode) pathname would be too big!!!"); ! return Py_BuildValue("u", szOutPath); ! } // @comm The short path name is an 8.3 compatible file name. As the input path does // not need to be absolute, the returned name may be longer than the input path. + return PyErr_Format(PyExc_RuntimeError, "not reached!?"); } *************** *** 4853,4856 **** --- 4915,4920 ---- {"Unicode", PyWin_NewUnicode, 1}, // @pymeth Unicode|Creates a new <o PyUnicode> object {"UpdateResource", PyUpdateResource, 1 }, // @pymeth UpdateResource|Updates a resource in a PE file. + {"VkKeyScan", PyVkKeyScan, 1}, // @pymeth VkKeyScan|Translates a character to the corresponding virtual-key code and shift state. + {"VkKeyScanEx", PyVkKeyScanEx, 1}, // @pymeth VkKeyScan|Translates a character to the corresponding virtual-key code and shift state. {"WinExec", PyWinExec, 1}, // @pymeth WinExec|Execute a program. {"WinHelp", PyWinHelp, 1}, // @pymeth WinHelp|Invokes the Windows Help engine. |
From: Mark H. <mha...@us...> - 2006-06-21 11:59:40
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4174 Modified Files: win32gui.i Log Message: GetWindowPlacement/SetWindowPlacement and autoduck clarifications. Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.78 retrieving revision 1.79 diff -C2 -d -r1.78 -r1.79 *** win32gui.i 20 Mar 2006 03:10:38 -0000 1.78 --- win32gui.i 21 Jun 2006 11:59:24 -0000 1.79 *************** *** 2139,2142 **** --- 2139,2144 ---- // @pyswig HMENU|LoadMenu|Loads a menu + // @pyparm int|hinstance|| + // @pyparm int/string|resource_id|| HMENU LoadMenu(HINSTANCE hInst, RESOURCE_ID name); *************** *** 2146,2149 **** --- 2148,2153 ---- #ifndef MS_WINCE // @pyswig |SetMenu|Sets the menu for the specified window. + // @pyparm int|hwnd|| + // @pyparm int|hmenu|| BOOLAPI SetMenu( HWND hwnd, HMENU hmenu ); #endif *************** *** 2153,2156 **** --- 2157,2162 ---- // @pyswig HCURSOR|LoadIcon|Loads an icon + // @pyparm int|hinstance|| + // @pyparm int/string|resource_id|| HICON LoadIcon(HINSTANCE hInst, RESOURCE_ID name); *************** *** 2571,2575 **** UINT uFlags // window-positioning flags ); ! %{ // @pyswig int|RegisterClass|Registers a window class. --- 2577,2642 ---- UINT uFlags // window-positioning flags ); ! ! %{ ! // @pyswig tuple|GetWindowPlacement|Returns placement information about the current window. ! static PyObject * ! PyGetWindowPlacement(PyObject *self, PyObject *args) ! { ! int hwnd; ! if (!PyArg_ParseTuple(args, "i:GetWindowPlacement", &hwnd)) ! return NULL; ! ! WINDOWPLACEMENT pment; ! pment.length=sizeof(pment); ! BOOL ok; ! Py_BEGIN_ALLOW_THREADS ! ok = GetWindowPlacement( (HWND)hwnd, &pment ); ! Py_END_ALLOW_THREADS ! if (!ok) ! return PyWin_SetAPIError("GetWindowPlacement"); ! // @rdesc The result is a tuple of ! // (flags, showCmd, (minposX, minposY), (maxposX, maxposY), (normalposX, normalposY)) ! // @flagh Item|Description ! // @flag flags|One of the WPF_* constants ! // @flag showCmd|Current state - one of the SW_* constants. ! // @flag minpos|Specifies the coordinates of the window's upper-left corner when the window is minimized. ! // @flag maxpos|Specifies the coordinates of the window's upper-left corner when the window is maximized. ! // @flag normalpos|Specifies the window's coordinates when the window is in the restored position. ! return Py_BuildValue("(ii(ii)(ii)(iiii))",pment.flags, pment.showCmd, ! pment.ptMinPosition.x,pment.ptMinPosition.y, ! pment.ptMaxPosition.x,pment.ptMaxPosition.y, ! pment.rcNormalPosition.left, pment.rcNormalPosition.top, ! pment.rcNormalPosition.right, pment.rcNormalPosition.bottom); ! } ! // @pyswig |SetWindowPlacement|Sets the windows placement ! static PyObject * ! PySetWindowPlacement(PyObject *self, PyObject *args) ! { ! int hwnd; ! WINDOWPLACEMENT pment; ! pment.length=sizeof(pment); ! // @pyparm (tuple)|placement||A tuple representing the WINDOWPLACEMENT structure. ! if (!PyArg_ParseTuple(args,"i(ii(ii)(ii)(iiii)):SetWindowPlacement", ! &hwnd, ! &pment.flags, &pment.showCmd, ! &pment.ptMinPosition.x,&pment.ptMinPosition.y, ! &pment.ptMaxPosition.x,&pment.ptMaxPosition.y, ! &pment.rcNormalPosition.left, &pment.rcNormalPosition.top, ! &pment.rcNormalPosition.right, &pment.rcNormalPosition.bottom)) ! return NULL; ! BOOL rc; ! Py_BEGIN_ALLOW_THREADS ! rc = SetWindowPlacement( (HWND)hwnd, &pment ); ! Py_END_ALLOW_THREADS ! if (!rc) ! return PyWin_SetAPIError("SetWindowPlacement"); ! Py_INCREF(Py_None); ! return Py_None; ! } ! ! %} ! %native (GetWindowPlacement) PyGetWindowPlacement; ! %native (SetWindowPlacement) PySetWindowPlacement; ! %{ // @pyswig int|RegisterClass|Registers a window class. *************** *** 2692,2697 **** BOOL GetMessage(MSG *OUTPUT, HWND hwnd, // @pyparm int|hwnd|| ! UINT min, // @pyparm int|max|| ! UINT max); // @pyparm int|min|| // @pyswig int|TranslateMessage| --- 2759,2764 ---- BOOL GetMessage(MSG *OUTPUT, HWND hwnd, // @pyparm int|hwnd|| ! UINT min, // @pyparm int|min|| ! UINT max); // @pyparm int|max|| // @pyswig int|TranslateMessage| |
From: Mark H. <mha...@us...> - 2006-06-18 13:18:32
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/axdebug In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv824 Modified Files: __init__.py adb.py codecontainer.py contexts.py debugger.py documents.py dump.py expressions.py gateways.py stackframe.py util.py Log Message: convert tabs to spaces via reindent.py Index: expressions.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axdebug/expressions.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** expressions.py 18 Jun 2006 13:09:36 -0000 1.4 --- expressions.py 18 Jun 2006 13:18:26 -0000 1.5 *************** *** 10,156 **** # Given an object, return a nice string def MakeNiceString(ob): ! stream = cStringIO.StringIO() ! pprint(ob, stream) ! return string.strip(stream.getvalue()) class ProvideExpressionContexts(gateways.ProvideExpressionContexts): ! pass class ExpressionContext(gateways.DebugExpressionContext): ! def __init__(self, frame): ! self.frame = frame ! def ParseLanguageText(self, code, radix, delim, flags): ! return _wrap(Expression(self.frame, code, radix, delim, flags), axdebug.IID_IDebugExpression) ! def GetLanguageInfo(self): ! # print "GetLanguageInfo" ! return "Python", "{DF630910-1C1D-11d0-AE36-8C0F5E000000}" ! class Expression(gateways.DebugExpression): ! def __init__(self, frame, code, radix, delim, flags): ! self.callback = None ! self.frame = frame ! self.code = code ! self.radix = radix ! self.delim = delim ! self.flags = flags ! self.isComplete = 0 ! self.result=None ! self.hresult = winerror.E_UNEXPECTED ! def Start(self, callback): ! try: ! try: ! try: ! self.result = eval(self.code, self.frame.f_globals, self.frame.f_locals) ! except SyntaxError: ! exec self.code in self.frame.f_globals, self.frame.f_locals ! self.result = "" ! self.hresult = 0 ! except: ! l = traceback.format_exception_only(sys.exc_info()[0], sys.exc_info()[1]) ! # l is a list of strings with trailing "\n" ! self.result = string.join(map(lambda s:s[:-1], l), "\n") ! self.hresult = winerror.E_FAIL ! finally: ! self.isComplete = 1 ! callback.onComplete() ! def Abort(self): ! print "** ABORT **" ! ! def QueryIsComplete(self): ! return self.isComplete ! ! def GetResultAsString(self): ! # print "GetStrAsResult returning", self.result ! return self.hresult, MakeNiceString(self.result) ! ! def GetResultAsDebugProperty(self): ! result = _wrap(DebugProperty(self.code, self.result, None, self.hresult), axdebug.IID_IDebugProperty) ! return self.hresult, result def MakeEnumDebugProperty(object, dwFieldSpec, nRadix, iid, stackFrame = None): ! name_vals = [] ! if hasattr(object, "has_key"): # If it is a dict. ! name_vals = object.items() ! dictionary = object ! elif hasattr(object, "__dict__"): #object with dictionary, module ! name_vals = object.__dict__.items() ! dictionary = object.__dict__ ! infos = [] ! for name, val in name_vals: ! infos.append(GetPropertyInfo(name, val, dwFieldSpec, nRadix, 0, dictionary, stackFrame)) ! return _wrap(EnumDebugPropertyInfo(infos), axdebug.IID_IEnumDebugPropertyInfo) def GetPropertyInfo(obname, obvalue, dwFieldSpec, nRadix, hresult=0, dictionary = None, stackFrame = None): ! # returns a tuple ! name = typ = value = fullname = attrib = dbgprop = None ! if dwFieldSpec & axdebug.DBGPROP_INFO_VALUE: ! value = MakeNiceString(obvalue) ! if dwFieldSpec & axdebug.DBGPROP_INFO_NAME: ! name = obname ! if dwFieldSpec & axdebug.DBGPROP_INFO_TYPE: ! if hresult: ! typ = "Error" ! else: ! try: ! typ = type(obvalue).__name__ ! except AttributeError: ! typ = str(type(obvalue)) ! if dwFieldSpec & axdebug.DBGPROP_INFO_FULLNAME: ! fullname = obname ! if dwFieldSpec & axdebug.DBGPROP_INFO_ATTRIBUTES: ! if hasattr(obvalue, "has_key") or hasattr(obvalue, "__dict__"): # If it is a dict or object ! attrib = axdebug.DBGPROP_ATTRIB_VALUE_IS_EXPANDABLE ! else: ! attrib = 0 ! if dwFieldSpec & axdebug.DBGPROP_INFO_DEBUGPROP: ! dbgprop = _wrap(DebugProperty(name, obvalue, None, hresult, dictionary, stackFrame), axdebug.IID_IDebugProperty) ! return name, typ, value, fullname, attrib, dbgprop from win32com.server.util import ListEnumeratorGateway class EnumDebugPropertyInfo(ListEnumeratorGateway): ! """A class to expose a Python sequence as an EnumDebugCodeContexts ! Create an instance of this class passing a sequence (list, tuple, or ! any sequence protocol supporting object) and it will automatically ! support the EnumDebugCodeContexts interface for the object. ! """ ! _public_methods_ = ListEnumeratorGateway._public_methods_ + ["GetCount"] ! _com_interfaces_ = [ axdebug.IID_IEnumDebugPropertyInfo] ! def GetCount(self): ! return len(self._list_) ! def _wrap(self, ob): ! return ob class DebugProperty: ! _com_interfaces_ = [axdebug.IID_IDebugProperty] ! _public_methods_ = ['GetPropertyInfo', 'GetExtendedInfo', 'SetValueAsString', ! 'EnumMembers', 'GetParent' ! ] ! def __init__(self, name, value, parent = None, hresult = 0, dictionary = None, stackFrame = None): ! self.name = name ! self.value = value ! self.parent = parent ! self.hresult = hresult ! self.dictionary = dictionary ! self.stackFrame = stackFrame ! def GetPropertyInfo(self, dwFieldSpec, nRadix): ! return GetPropertyInfo(self.name, self.value, dwFieldSpec, nRadix, self.hresult, dictionary, stackFrame) ! def GetExtendedInfo(self): ### Note - not in the framework. ! RaiseNotImpl("DebugProperty::GetExtendedInfo") ! def SetValueAsString(self, value, radix): ! if self.stackFrame and self.dictionary: ! self.dictionary[self.name]= eval(value,self.stackFrame.f_globals, self.stackFrame.f_locals) ! else: ! RaiseNotImpl("DebugProperty::SetValueAsString") ! def EnumMembers(self, dwFieldSpec, nRadix, iid): ! # Returns IEnumDebugPropertyInfo ! return MakeEnumDebugProperty(self.value, dwFieldSpec, nRadix, iid, self.stackFrame) ! def GetParent(self): ! # return IDebugProperty ! RaiseNotImpl("DebugProperty::GetParent") --- 10,156 ---- # Given an object, return a nice string def MakeNiceString(ob): ! stream = cStringIO.StringIO() ! pprint(ob, stream) ! return string.strip(stream.getvalue()) class ProvideExpressionContexts(gateways.ProvideExpressionContexts): ! pass class ExpressionContext(gateways.DebugExpressionContext): ! def __init__(self, frame): ! self.frame = frame ! def ParseLanguageText(self, code, radix, delim, flags): ! return _wrap(Expression(self.frame, code, radix, delim, flags), axdebug.IID_IDebugExpression) ! def GetLanguageInfo(self): ! # print "GetLanguageInfo" ! return "Python", "{DF630910-1C1D-11d0-AE36-8C0F5E000000}" ! class Expression(gateways.DebugExpression): ! def __init__(self, frame, code, radix, delim, flags): ! self.callback = None ! self.frame = frame ! self.code = code ! self.radix = radix ! self.delim = delim ! self.flags = flags ! self.isComplete = 0 ! self.result=None ! self.hresult = winerror.E_UNEXPECTED ! def Start(self, callback): ! try: ! try: ! try: ! self.result = eval(self.code, self.frame.f_globals, self.frame.f_locals) ! except SyntaxError: ! exec self.code in self.frame.f_globals, self.frame.f_locals ! self.result = "" ! self.hresult = 0 ! except: ! l = traceback.format_exception_only(sys.exc_info()[0], sys.exc_info()[1]) ! # l is a list of strings with trailing "\n" ! self.result = string.join(map(lambda s:s[:-1], l), "\n") ! self.hresult = winerror.E_FAIL ! finally: ! self.isComplete = 1 ! callback.onComplete() ! def Abort(self): ! print "** ABORT **" ! ! def QueryIsComplete(self): ! return self.isComplete ! ! def GetResultAsString(self): ! # print "GetStrAsResult returning", self.result ! return self.hresult, MakeNiceString(self.result) ! ! def GetResultAsDebugProperty(self): ! result = _wrap(DebugProperty(self.code, self.result, None, self.hresult), axdebug.IID_IDebugProperty) ! return self.hresult, result def MakeEnumDebugProperty(object, dwFieldSpec, nRadix, iid, stackFrame = None): ! name_vals = [] ! if hasattr(object, "has_key"): # If it is a dict. ! name_vals = object.items() ! dictionary = object ! elif hasattr(object, "__dict__"): #object with dictionary, module ! name_vals = object.__dict__.items() ! dictionary = object.__dict__ ! infos = [] ! for name, val in name_vals: ! infos.append(GetPropertyInfo(name, val, dwFieldSpec, nRadix, 0, dictionary, stackFrame)) ! return _wrap(EnumDebugPropertyInfo(infos), axdebug.IID_IEnumDebugPropertyInfo) def GetPropertyInfo(obname, obvalue, dwFieldSpec, nRadix, hresult=0, dictionary = None, stackFrame = None): ! # returns a tuple ! name = typ = value = fullname = attrib = dbgprop = None ! if dwFieldSpec & axdebug.DBGPROP_INFO_VALUE: ! value = MakeNiceString(obvalue) ! if dwFieldSpec & axdebug.DBGPROP_INFO_NAME: ! name = obname ! if dwFieldSpec & axdebug.DBGPROP_INFO_TYPE: ! if hresult: ! typ = "Error" ! else: ! try: ! typ = type(obvalue).__name__ ! except AttributeError: ! typ = str(type(obvalue)) ! if dwFieldSpec & axdebug.DBGPROP_INFO_FULLNAME: ! fullname = obname ! if dwFieldSpec & axdebug.DBGPROP_INFO_ATTRIBUTES: ! if hasattr(obvalue, "has_key") or hasattr(obvalue, "__dict__"): # If it is a dict or object ! attrib = axdebug.DBGPROP_ATTRIB_VALUE_IS_EXPANDABLE ! else: ! attrib = 0 ! if dwFieldSpec & axdebug.DBGPROP_INFO_DEBUGPROP: ! dbgprop = _wrap(DebugProperty(name, obvalue, None, hresult, dictionary, stackFrame), axdebug.IID_IDebugProperty) ! return name, typ, value, fullname, attrib, dbgprop from win32com.server.util import ListEnumeratorGateway class EnumDebugPropertyInfo(ListEnumeratorGateway): ! """A class to expose a Python sequence as an EnumDebugCodeContexts ! Create an instance of this class passing a sequence (list, tuple, or ! any sequence protocol supporting object) and it will automatically ! support the EnumDebugCodeContexts interface for the object. ! """ ! _public_methods_ = ListEnumeratorGateway._public_methods_ + ["GetCount"] ! _com_interfaces_ = [ axdebug.IID_IEnumDebugPropertyInfo] ! def GetCount(self): ! return len(self._list_) ! def _wrap(self, ob): ! return ob class DebugProperty: ! _com_interfaces_ = [axdebug.IID_IDebugProperty] ! _public_methods_ = ['GetPropertyInfo', 'GetExtendedInfo', 'SetValueAsString', ! 'EnumMembers', 'GetParent' ! ] ! def __init__(self, name, value, parent = None, hresult = 0, dictionary = None, stackFrame = None): ! self.name = name ! self.value = value ! self.parent = parent ! self.hresult = hresult ! self.dictionary = dictionary ! self.stackFrame = stackFrame ! def GetPropertyInfo(self, dwFieldSpec, nRadix): ! return GetPropertyInfo(self.name, self.value, dwFieldSpec, nRadix, self.hresult, dictionary, stackFrame) ! def GetExtendedInfo(self): ### Note - not in the framework. ! RaiseNotImpl("DebugProperty::GetExtendedInfo") ! def SetValueAsString(self, value, radix): ! if self.stackFrame and self.dictionary: ! self.dictionary[self.name]= eval(value,self.stackFrame.f_globals, self.stackFrame.f_locals) ! else: ! RaiseNotImpl("DebugProperty::SetValueAsString") ! def EnumMembers(self, dwFieldSpec, nRadix, iid): ! # Returns IEnumDebugPropertyInfo ! return MakeEnumDebugProperty(self.value, dwFieldSpec, nRadix, iid, self.stackFrame) ! def GetParent(self): ! # return IDebugProperty ! RaiseNotImpl("DebugProperty::GetParent") Index: gateways.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axdebug/gateways.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gateways.py 6 Jan 2000 04:45:44 -0000 1.2 --- gateways.py 18 Jun 2006 13:18:26 -0000 1.3 *************** *** 11,453 **** class EnumDebugCodeContexts(ListEnumeratorGateway): ! """A class to expose a Python sequence as an EnumDebugCodeContexts ! Create an instance of this class passing a sequence (list, tuple, or ! any sequence protocol supporting object) and it will automatically ! support the EnumDebugCodeContexts interface for the object. ! """ ! _com_interfaces_ = [ axdebug.IID_IEnumDebugCodeContexts ] class EnumDebugStackFrames(ListEnumeratorGateway): ! """A class to expose a Python sequence as an EnumDebugStackFrames ! Create an instance of this class passing a sequence (list, tuple, or ! any sequence protocol supporting object) and it will automatically ! support the EnumDebugStackFrames interface for the object. ! """ ! _com_interfaces_ = [ axdebug.IID_IEnumDebugStackFrames ] class EnumDebugApplicationNodes(ListEnumeratorGateway): ! """A class to expose a Python sequence as an EnumDebugStackFrames ! Create an instance of this class passing a sequence (list, tuple, or ! any sequence protocol supporting object) and it will automatically ! support the EnumDebugApplicationNodes interface for the object. ! """ ! _com_interfaces_ = [ axdebug.IID_IEnumDebugApplicationNodes ] class EnumRemoteDebugApplications(ListEnumeratorGateway): ! _com_interfaces_ = [ axdebug.IID_IEnumRemoteDebugApplications ] class EnumRemoteDebugApplicationThreads(ListEnumeratorGateway): ! _com_interfaces_ = [ axdebug.IID_IEnumRemoteDebugApplicationThreads ] class DebugDocumentInfo: ! _public_methods_ = ["GetName", "GetDocumentClassId"] ! _com_interfaces_ = [axdebug.IID_IDebugDocumentInfo] ! def __init__(self): ! pass ! def GetName(self, dnt): ! """ Get the one of the name of the document ! dnt -- int DOCUMENTNAMETYPE ! """ ! RaiseNotImpl("GetName") ! def GetDocumentClassId(self): ! """ ! Result must be an IID object (or string representing one). ! """ ! RaiseNotImpl("GetDocumentClassId") ! class DebugDocumentProvider(DebugDocumentInfo): ! _public_methods_ = DebugDocumentInfo._public_methods_ + ["GetDocument"] ! _com_interfaces_ = DebugDocumentInfo._com_interfaces_ + [axdebug.IID_IDebugDocumentProvider] ! def GetDocument(self): ! RaiseNotImpl("GetDocument") class DebugApplicationNode(DebugDocumentProvider): ! """Provides the functionality of IDebugDocumentProvider, plus a context within a project tree. ! """ ! _public_methods_ = string.split("""EnumChildren GetParent SetDocumentProvider ! Close Attach Detach""") + \ ! DebugDocumentProvider._public_methods_ ! _com_interfaces_ = [axdebug.IID_IDebugDocumentProvider] + \ ! DebugDocumentProvider._com_interfaces_ ! def __init__(self): ! DebugDocumentProvider.__init__(self) ! def EnumChildren(self): ! # Result is type PyIEnumDebugApplicationNodes ! RaiseNotImpl("EnumChildren") ! def GetParent(self): ! # result is type PyIDebugApplicationNode ! RaiseNotImpl("GetParent") ! def SetDocumentProvider(self, pddp): # PyIDebugDocumentProvider pddp ! # void result. ! RaiseNotImpl("SetDocumentProvider") ! def Close(self): ! # void result. ! RaiseNotImpl("Close") ! def Attach(self, parent): # PyIDebugApplicationNode ! # void result. ! RaiseNotImpl("Attach") ! def Detach(self): ! # void result. ! RaiseNotImpl("Detach") class DebugApplicationNodeEvents: ! """Event interface for DebugApplicationNode object. ! """ ! _public_methods_ = string.split("onAddChild onRemoveChild onDetach") ! _com_interfaces_ = [axdebug.IID_IDebugApplicationNodeEvents] ! def __init__(self): ! pass ! def onAddChild(self, child): # PyIDebugApplicationNode ! # void result. ! RaiseNotImpl("onAddChild") ! def onRemoveChild(self, child): # PyIDebugApplicationNode ! # void result. ! RaiseNotImpl("onRemoveChild") ! def onDetach(self): ! # void result. ! RaiseNotImpl("onDetach") ! def onAttach(self, parent): # PyIDebugApplicationNode ! # void result. ! RaiseNotImpl("onAttach") class DebugDocument(DebugDocumentInfo): ! """The base interface to all debug documents. ! """ ! _public_methods_ = DebugDocumentInfo._public_methods_ ! _com_interfaces_ = [axdebug.IID_IDebugDocument] + DebugDocumentInfo._com_interfaces_ class DebugDocumentText(DebugDocument): ! """The interface to a text only debug document. ! """ ! _com_interfaces_ = [axdebug.IID_IDebugDocumentText] + \ ! DebugDocument._com_interfaces_ ! _public_methods_ = ["GetDocumentAttributes", "GetSize", ! "GetPositionOfLine", "GetLineOfPosition", "GetText", ! "GetPositionOfContext", "GetContextOfPosition"] + \ ! DebugDocument._public_methods_ ! def __init__(self): ! pass ! # IDebugDocumentText ! def GetDocumentAttributes(self): ! # Result is int (TEXT_DOC_ATTR) ! RaiseNotImpl("GetDocumentAttributes") ! def GetSize(self): ! # Result is (numLines, numChars) ! RaiseNotImpl("GetSize") ! def GetPositionOfLine(self, cLineNumber): ! # Result is int char position ! RaiseNotImpl("GetPositionOfLine") ! def GetLineOfPosition(self, charPos): ! # Result is int, int (lineNo, offset) ! RaiseNotImpl("GetLineOfPosition") ! def GetText(self, charPos, maxChars, wantAttr): ! """Params ! charPos -- integer ! maxChars -- integer ! wantAttr -- Should the function compute attributes. ! Return value must be (string, attribtues). attributes may be ! None if(not wantAttr) ! """ ! RaiseNotImpl("GetText") ! def GetPositionOfContext(self, debugDocumentContext): ! """Params ! debugDocumentContext -- a PyIDebugDocumentContext object. ! ! Return value must be (charPos, numChars) ! """ ! RaiseNotImpl("GetPositionOfContext") ! def GetContextOfPosition(self, charPos, maxChars): ! """Params are integers. ! Return value must be PyIDebugDocumentContext object ! """ ! print self ! RaiseNotImpl("GetContextOfPosition") class DebugDocumentTextExternalAuthor: ! """Allow external editors to edit file-based debugger documents, and to notify the document when the source file has been changed. ! """ ! _public_methods_ = ["GetPathName", "GetFileName", "NotifyChanged"] ! _com_interfaces_ = [axdebug.IID_IDebugDocumentTextExternalAuthor] ! def __init__(self): ! pass ! def GetPathName(self): ! """Return the full path (including file name) to the document's source file. ! ! Result must be (filename, fIsOriginal), where ! - if fIsOriginalPath is TRUE if the path refers to the original file for the document. ! - if fIsOriginalPath is FALSE if the path refers to a newly created temporary file. ! raise Exception(winerror.E_FAIL) if no source file can be created/determined. ! """ ! RaiseNotImpl("GetPathName") ! ! def GetFileName(self): ! """Return just the name of the document, with no path information. (Used for "Save As...") ! Result is a string ! """ ! RaiseNotImpl("GetFileName") ! ! def NotifyChanged(self): ! """ Notify the host that the document's source file has been saved and ! that its contents should be refreshed. ! """ ! RaiseNotImpl("NotifyChanged") class DebugDocumentTextEvents: ! _public_methods_ = string.split("""onDestroy onInsertText onRemoveText ! onReplaceText onUpdateTextAttributes onUpdateDocumentAttributes""") ! _com_interfaces_ = [ axdebug.IID_IDebugDocumentTextEvents ] ! def __init__(self): ! pass ! def onDestroy(self): ! # Result is void. ! RaiseNotImpl("onDestroy") ! def onInsertText(self, cCharacterPosition, cNumToInsert): ! # Result is void. ! RaiseNotImpl("onInsertText") ! def onRemoveText(self, cCharacterPosition, cNumToRemove): ! # Result is void. ! RaiseNotImpl("onRemoveText") ! def onReplaceText(self, cCharacterPosition, cNumToReplace): ! # Result is void. ! RaiseNotImpl("onReplaceText") ! def onUpdateTextAttributes(self, cCharacterPosition, cNumToUpdate): ! # Result is void. ! RaiseNotImpl("onUpdateTextAttributes") ! def onUpdateDocumentAttributes(self,textdocattr): # TEXT_DOC_ATTR ! # Result is void. ! RaiseNotImpl("onUpdateDocumentAttributes") class DebugDocumentContext: ! _public_methods_ = [ 'GetDocument', 'EnumCodeContexts'] ! _com_interfaces_ = [ axdebug.IID_IDebugDocumentContext ] ! def __init__(self): ! pass ! def GetDocument(self): ! """Return value must be a PyIDebugDocument object ! """ ! RaiseNotImpl("GetDocument") ! def EnumCodeContexts(self): ! """Return value must be a PyIEnumDebugCodeContexts object ! """ ! RaiseNotImpl("EnumCodeContexts") class DebugCodeContext: ! _public_methods_ = [ 'GetDocumentContext', 'SetBreakPoint'] ! _com_interfaces_ = [ axdebug.IID_IDebugCodeContext ] ! def __init__(self): ! pass ! def GetDocumentContext(self): ! """Return value must be a PyIDebugDocumentContext object ! """ ! RaiseNotImpl("GetDocumentContext") ! def SetBreakPoint(self, bps): ! """bps -- an integer with flags. ! """ ! RaiseNotImpl("SetBreakPoint") class DebugStackFrame: ! """Abstraction representing a logical stack frame on the stack of a thread.""" ! _public_methods_ = [ 'GetCodeContext', 'GetDescriptionString', 'GetLanguageString', 'GetThread', 'GetDebugProperty'] ! _com_interfaces_ = [ axdebug.IID_IDebugStackFrame ] ! def __init__(self): ! pass ! def GetCodeContext(self): ! """Returns the current code context associated with the stack frame. ! Return value must be a IDebugCodeContext object ! """ ! RaiseNotImpl("GetCodeContext") ! def GetDescriptionString(self, fLong): ! """Returns a textual description of the stack frame. ! ! fLong -- A flag indicating if the long name is requested. ! """ ! RaiseNotImpl("GetDescriptionString") ! def GetLanguageString(self): ! """Returns a short or long textual description of the language. ! ! fLong -- A flag indicating if the long name is requested. ! """ ! RaiseNotImpl("GetLanguageString") ! def GetThread(self): ! """ Returns the thread associated with this stack frame. ! Result must be a IDebugApplicationThread ! """ ! RaiseNotImpl("GetThread") ! def GetDebugProperty(self): ! RaiseNotImpl("GetDebugProperty") class DebugDocumentHost: ! """The interface from the IDebugDocumentHelper back to ! the smart host or language engine. This interface ! exposes host specific functionality such as syntax coloring. ! """ ! _public_methods_ = [ 'GetDeferredText', 'GetScriptTextAttributes', 'OnCreateDocumentContext', 'GetPathName', 'GetFileName', 'NotifyChanged'] ! _com_interfaces_ = [ axdebug.IID_IDebugDocumentHost ] ! def __init__(self): ! pass ! def GetDeferredText(self, dwTextStartCookie, maxChars, bWantAttr): ! RaiseNotImpl("GetDeferredText") ! ! def GetScriptTextAttributes(self, codeText, delimterText, flags): ! # Result must be an attribute sequence of same "length" as the code. ! RaiseNotImpl("GetScriptTextAttributes") ! ! def OnCreateDocumentContext(self): ! # Result must be a PyIUnknown ! RaiseNotImpl("OnCreateDocumentContext") ! ! def GetPathName(self): ! # Result must be (string, int) where the int is a BOOL ! # - TRUE if the path refers to the original file for the document. ! # - FALSE if the path refers to a newly created temporary file. ! # - raise Exception(scode=E_FAIL) if no source file can be created/determined. ! RaiseNotImpl("GetPathName") ! ! def GetFileName(self): ! # Result is a string with just the name of the document, no path information. ! RaiseNotImpl("GetFileName") ! ! def NotifyChanged(self): ! RaiseNotImpl("NotifyChanged") # Additional gateway related functions. class DebugDocumentTextConnectServer: ! _public_methods_ = win32com.server.connect.IConnectionPointContainer_methods + win32com.server.connect.IConnectionPoint_methods ! _com_interfaces_ = [pythoncom.IID_IConnectionPoint, pythoncom.IID_IConnectionPointContainer] ! # IConnectionPoint interfaces ! def __init__(self): ! self.cookieNo = -1 ! self.connections = {} ! def EnumConnections(self): ! RaiseNotImpl("EnumConnections") ! def GetConnectionInterface(self): ! RaiseNotImpl("GetConnectionInterface") ! def GetConnectionPointContainer(self): ! return _wrap(self) ! def Advise(self, pUnk): ! # Creates a connection to the client. Simply allocate a new cookie, ! # find the clients interface, and store it in a dictionary. ! interface = pUnk.QueryInterface(axdebug.IID_IDebugDocumentTextEvents,1) ! self.cookieNo = self.cookieNo + 1 ! self.connections[self.cookieNo] = interface ! return self.cookieNo ! def Unadvise(self, cookie): ! # Destroy a connection - simply delete interface from the map. ! try: ! del self.connections[cookie] ! except KeyError: ! return Exception(scode=winerror.E_UNEXPECTED) ! # IConnectionPointContainer interfaces ! def EnumConnectionPoints(self): ! RaiseNotImpl("EnumConnectionPoints") ! def FindConnectionPoint(self, iid): ! # Find a connection we support. Only support the single event interface. ! if iid==axdebug.IID_IDebugDocumentTextEvents: ! return _wrap(self) ! raise Exception(scode=winerror.E_NOINTERFACE) # ?? class RemoteDebugApplicationEvents: ! _public_methods_ = ["OnConnectDebugger","OnDisconnectDebugger","OnSetName","OnDebugOutput","OnClose","OnEnterBreakPoint","OnLeaveBreakPoint","OnCreateThread","OnDestroyThread","OnBreakFlagChange"] ! _com_interfaces_ = [axdebug.IID_IRemoteDebugApplicationEvents] ! def OnConnectDebugger(self, appDebugger): ! """appDebugger -- a PyIApplicationDebugger ! """ ! RaiseNotImpl("OnConnectDebugger") ! def OnDisconnectDebugger(self): ! RaiseNotImpl("OnDisconnectDebugger") ! def OnSetName(self, name): ! RaiseNotImpl("OnSetName") ! def OnDebugOutput(self, string): ! RaiseNotImpl("OnDebugOutput") ! def OnClose(self): ! RaiseNotImpl("OnClose") ! def OnEnterBreakPoint(self, rdat): ! """rdat -- PyIRemoteDebugApplicationThread ! """ ! RaiseNotImpl("OnEnterBreakPoint") ! def OnLeaveBreakPoint(self, rdat): ! """rdat -- PyIRemoteDebugApplicationThread ! """ ! RaiseNotImpl("OnLeaveBreakPoint") ! def OnCreateThread(self, rdat): ! """rdat -- PyIRemoteDebugApplicationThread ! """ ! RaiseNotImpl("OnCreateThread") ! def OnDestroyThread(self, rdat): ! """rdat -- PyIRemoteDebugApplicationThread ! """ ! RaiseNotImpl("OnDestroyThread") ! def OnBreakFlagChange(self, abf, rdat): ! """abf -- int - one of the axdebug.APPBREAKFLAGS constants ! rdat -- PyIRemoteDebugApplicationThread ! RaiseNotImpl("OnBreakFlagChange") ! """ class DebugExpressionContext: ! _public_methods_ = ["ParseLanguageText", "GetLanguageInfo"] ! _com_interfaces_ = [axdebug.IID_IDebugExpressionContext] ! def __init__(self): ! pass ! def ParseLanguageText(self, code, radix, delim, flags): ! """ ! result is IDebugExpression ! """ ! RaiseNotImpl("ParseLanguageText") ! def GetLanguageInfo(self): ! """ ! result is (string langName, iid langId) ! """ ! RaiseNotImpl("GetLanguageInfo") class DebugExpression: ! _public_methods_ = ["Start", "Abort", "QueryIsComplete", "GetResultAsString", "GetResultAsDebugProperty"] ! _com_interfaces_ = [axdebug.IID_IDebugExpression] ! def Start(self, callback): ! """ ! callback -- an IDebugExpressionCallback ! ! result - void ! """ ! RaiseNotImpl("Start") ! def Abort(self): ! """ ! no params ! result -- void ! """ ! RaiseNotImpl("Abort") ! def QueryIsComplete(self): ! """ ! no params ! result -- void ! """ ! RaiseNotImpl("QueryIsComplete") ! def GetResultAsString(self): ! RaiseNotImpl("GetResultAsString") ! def GetResultAsDebugProperty(self): ! RaiseNotImpl("GetResultAsDebugProperty") class ProvideExpressionContexts: ! _public_methods_ = ["EnumExpressionContexts"] ! _com_interfaces_ = [axdebug.IID_IProvideExpressionContexts] ! def EnumExpressionContexts(self): ! RaiseNotImpl("EnumExpressionContexts") ! --- 11,452 ---- class EnumDebugCodeContexts(ListEnumeratorGateway): ! """A class to expose a Python sequence as an EnumDebugCodeContexts ! Create an instance of this class passing a sequence (list, tuple, or ! any sequence protocol supporting object) and it will automatically ! support the EnumDebugCodeContexts interface for the object. ! """ ! _com_interfaces_ = [ axdebug.IID_IEnumDebugCodeContexts ] class EnumDebugStackFrames(ListEnumeratorGateway): ! """A class to expose a Python sequence as an EnumDebugStackFrames ! Create an instance of this class passing a sequence (list, tuple, or ! any sequence protocol supporting object) and it will automatically ! support the EnumDebugStackFrames interface for the object. ! """ ! _com_interfaces_ = [ axdebug.IID_IEnumDebugStackFrames ] class EnumDebugApplicationNodes(ListEnumeratorGateway): ! """A class to expose a Python sequence as an EnumDebugStackFrames ! Create an instance of this class passing a sequence (list, tuple, or ! any sequence protocol supporting object) and it will automatically ! support the EnumDebugApplicationNodes interface for the object. ! """ ! _com_interfaces_ = [ axdebug.IID_IEnumDebugApplicationNodes ] class EnumRemoteDebugApplications(ListEnumeratorGateway): ! _com_interfaces_ = [ axdebug.IID_IEnumRemoteDebugApplications ] class EnumRemoteDebugApplicationThreads(ListEnumeratorGateway): ! _com_interfaces_ = [ axdebug.IID_IEnumRemoteDebugApplicationThreads ] class DebugDocumentInfo: ! _public_methods_ = ["GetName", "GetDocumentClassId"] ! _com_interfaces_ = [axdebug.IID_IDebugDocumentInfo] ! def __init__(self): ! pass ! def GetName(self, dnt): ! """ Get the one of the name of the document ! dnt -- int DOCUMENTNAMETYPE ! """ ! RaiseNotImpl("GetName") ! def GetDocumentClassId(self): ! """ ! Result must be an IID object (or string representing one). ! """ ! RaiseNotImpl("GetDocumentClassId") ! class DebugDocumentProvider(DebugDocumentInfo): ! _public_methods_ = DebugDocumentInfo._public_methods_ + ["GetDocument"] ! _com_interfaces_ = DebugDocumentInfo._com_interfaces_ + [axdebug.IID_IDebugDocumentProvider] ! def GetDocument(self): ! RaiseNotImpl("GetDocument") class DebugApplicationNode(DebugDocumentProvider): ! """Provides the functionality of IDebugDocumentProvider, plus a context within a project tree. ! """ ! _public_methods_ = string.split("""EnumChildren GetParent SetDocumentProvider ! Close Attach Detach""") + \ ! DebugDocumentProvider._public_methods_ ! _com_interfaces_ = [axdebug.IID_IDebugDocumentProvider] + \ ! DebugDocumentProvider._com_interfaces_ ! def __init__(self): ! DebugDocumentProvider.__init__(self) ! def EnumChildren(self): ! # Result is type PyIEnumDebugApplicationNodes ! RaiseNotImpl("EnumChildren") ! def GetParent(self): ! # result is type PyIDebugApplicationNode ! RaiseNotImpl("GetParent") ! def SetDocumentProvider(self, pddp): # PyIDebugDocumentProvider pddp ! # void result. ! RaiseNotImpl("SetDocumentProvider") ! def Close(self): ! # void result. ! RaiseNotImpl("Close") ! def Attach(self, parent): # PyIDebugApplicationNode ! # void result. ! RaiseNotImpl("Attach") ! def Detach(self): ! # void result. ! RaiseNotImpl("Detach") class DebugApplicationNodeEvents: ! """Event interface for DebugApplicationNode object. ! """ ! _public_methods_ = string.split("onAddChild onRemoveChild onDetach") ! _com_interfaces_ = [axdebug.IID_IDebugApplicationNodeEvents] ! def __init__(self): ! pass ! def onAddChild(self, child): # PyIDebugApplicationNode ! # void result. ! RaiseNotImpl("onAddChild") ! def onRemoveChild(self, child): # PyIDebugApplicationNode ! # void result. ! RaiseNotImpl("onRemoveChild") ! def onDetach(self): ! # void result. ! RaiseNotImpl("onDetach") ! def onAttach(self, parent): # PyIDebugApplicationNode ! # void result. ! RaiseNotImpl("onAttach") class DebugDocument(DebugDocumentInfo): ! """The base interface to all debug documents. ! """ ! _public_methods_ = DebugDocumentInfo._public_methods_ ! _com_interfaces_ = [axdebug.IID_IDebugDocument] + DebugDocumentInfo._com_interfaces_ class DebugDocumentText(DebugDocument): ! """The interface to a text only debug document. ! """ ! _com_interfaces_ = [axdebug.IID_IDebugDocumentText] + \ ! DebugDocument._com_interfaces_ ! _public_methods_ = ["GetDocumentAttributes", "GetSize", ! "GetPositionOfLine", "GetLineOfPosition", "GetText", ! "GetPositionOfContext", "GetContextOfPosition"] + \ ! DebugDocument._public_methods_ ! def __init__(self): ! pass ! # IDebugDocumentText ! def GetDocumentAttributes(self): ! # Result is int (TEXT_DOC_ATTR) ! RaiseNotImpl("GetDocumentAttributes") ! def GetSize(self): ! # Result is (numLines, numChars) ! RaiseNotImpl("GetSize") ! def GetPositionOfLine(self, cLineNumber): ! # Result is int char position ! RaiseNotImpl("GetPositionOfLine") ! def GetLineOfPosition(self, charPos): ! # Result is int, int (lineNo, offset) ! RaiseNotImpl("GetLineOfPosition") ! def GetText(self, charPos, maxChars, wantAttr): ! """Params ! charPos -- integer ! maxChars -- integer ! wantAttr -- Should the function compute attributes. ! Return value must be (string, attribtues). attributes may be ! None if(not wantAttr) ! """ ! RaiseNotImpl("GetText") ! def GetPositionOfContext(self, debugDocumentContext): ! """Params ! debugDocumentContext -- a PyIDebugDocumentContext object. ! ! Return value must be (charPos, numChars) ! """ ! RaiseNotImpl("GetPositionOfContext") ! def GetContextOfPosition(self, charPos, maxChars): ! """Params are integers. ! Return value must be PyIDebugDocumentContext object ! """ ! print self ! RaiseNotImpl("GetContextOfPosition") class DebugDocumentTextExternalAuthor: ! """Allow external editors to edit file-based debugger documents, and to notify the document when the source file has been changed. ! """ ! _public_methods_ = ["GetPathName", "GetFileName", "NotifyChanged"] ! _com_interfaces_ = [axdebug.IID_IDebugDocumentTextExternalAuthor] ! def __init__(self): ! pass ! def GetPathName(self): ! """Return the full path (including file name) to the document's source file. ! Result must be (filename, fIsOriginal), where ! - if fIsOriginalPath is TRUE if the path refers to the original file for the document. ! - if fIsOriginalPath is FALSE if the path refers to a newly created temporary file. ! raise Exception(winerror.E_FAIL) if no source file can be created/determined. ! """ ! RaiseNotImpl("GetPathName") ! ! def GetFileName(self): ! """Return just the name of the document, with no path information. (Used for "Save As...") ! ! Result is a string ! """ ! RaiseNotImpl("GetFileName") ! ! def NotifyChanged(self): ! """ Notify the host that the document's source file has been saved and ! that its contents should be refreshed. ! """ ! RaiseNotImpl("NotifyChanged") class DebugDocumentTextEvents: ! _public_methods_ = string.split("""onDestroy onInsertText onRemoveText ! onReplaceText onUpdateTextAttributes onUpdateDocumentAttributes""") ! _com_interfaces_ = [ axdebug.IID_IDebugDocumentTextEvents ] ! def __init__(self): ! pass ! def onDestroy(self): ! # Result is void. ! RaiseNotImpl("onDestroy") ! def onInsertText(self, cCharacterPosition, cNumToInsert): ! # Result is void. ! RaiseNotImpl("onInsertText") ! def onRemoveText(self, cCharacterPosition, cNumToRemove): ! # Result is void. ! RaiseNotImpl("onRemoveText") ! def onReplaceText(self, cCharacterPosition, cNumToReplace): ! # Result is void. ! RaiseNotImpl("onReplaceText") ! def onUpdateTextAttributes(self, cCharacterPosition, cNumToUpdate): ! # Result is void. ! RaiseNotImpl("onUpdateTextAttributes") ! def onUpdateDocumentAttributes(self,textdocattr): # TEXT_DOC_ATTR ! # Result is void. ! RaiseNotImpl("onUpdateDocumentAttributes") class DebugDocumentContext: ! _public_methods_ = [ 'GetDocument', 'EnumCodeContexts'] ! _com_interfaces_ = [ axdebug.IID_IDebugDocumentContext ] ! def __init__(self): ! pass ! def GetDocument(self): ! """Return value must be a PyIDebugDocument object ! """ ! RaiseNotImpl("GetDocument") ! def EnumCodeContexts(self): ! """Return value must be a PyIEnumDebugCodeContexts object ! """ ! RaiseNotImpl("EnumCodeContexts") class DebugCodeContext: ! _public_methods_ = [ 'GetDocumentContext', 'SetBreakPoint'] ! _com_interfaces_ = [ axdebug.IID_IDebugCodeContext ] ! def __init__(self): ! pass ! def GetDocumentContext(self): ! """Return value must be a PyIDebugDocumentContext object ! """ ! RaiseNotImpl("GetDocumentContext") ! def SetBreakPoint(self, bps): ! """bps -- an integer with flags. ! """ ! RaiseNotImpl("SetBreakPoint") class DebugStackFrame: ! """Abstraction representing a logical stack frame on the stack of a thread.""" ! _public_methods_ = [ 'GetCodeContext', 'GetDescriptionString', 'GetLanguageString', 'GetThread', 'GetDebugProperty'] ! _com_interfaces_ = [ axdebug.IID_IDebugStackFrame ] ! def __init__(self): ! pass ! def GetCodeContext(self): ! """Returns the current code context associated with the stack frame. ! Return value must be a IDebugCodeContext object ! """ ! RaiseNotImpl("GetCodeContext") ! def GetDescriptionString(self, fLong): ! """Returns a textual description of the stack frame. ! fLong -- A flag indicating if the long name is requested. ! """ ! RaiseNotImpl("GetDescriptionString") ! def GetLanguageString(self): ! """Returns a short or long textual description of the language. ! ! fLong -- A flag indicating if the long name is requested. ! """ ! RaiseNotImpl("GetLanguageString") ! def GetThread(self): ! """ Returns the thread associated with this stack frame. ! ! Result must be a IDebugApplicationThread ! """ ! RaiseNotImpl("GetThread") ! def GetDebugProperty(self): ! RaiseNotImpl("GetDebugProperty") class DebugDocumentHost: ! """The interface from the IDebugDocumentHelper back to ! the smart host or language engine. This interface ! exposes host specific functionality such as syntax coloring. ! """ ! _public_methods_ = [ 'GetDeferredText', 'GetScriptTextAttributes', 'OnCreateDocumentContext', 'GetPathName', 'GetFileName', 'NotifyChanged'] ! _com_interfaces_ = [ axdebug.IID_IDebugDocumentHost ] ! def __init__(self): ! pass ! def GetDeferredText(self, dwTextStartCookie, maxChars, bWantAttr): ! RaiseNotImpl("GetDeferredText") ! ! def GetScriptTextAttributes(self, codeText, delimterText, flags): ! # Result must be an attribute sequence of same "length" as the code. ! RaiseNotImpl("GetScriptTextAttributes") ! ! def OnCreateDocumentContext(self): ! # Result must be a PyIUnknown ! RaiseNotImpl("OnCreateDocumentContext") ! ! def GetPathName(self): ! # Result must be (string, int) where the int is a BOOL ! # - TRUE if the path refers to the original file for the document. ! # - FALSE if the path refers to a newly created temporary file. ! # - raise Exception(scode=E_FAIL) if no source file can be created/determined. ! RaiseNotImpl("GetPathName") ! ! def GetFileName(self): ! # Result is a string with just the name of the document, no path information. ! RaiseNotImpl("GetFileName") ! ! def NotifyChanged(self): ! RaiseNotImpl("NotifyChanged") # Additional gateway related functions. class DebugDocumentTextConnectServer: ! _public_methods_ = win32com.server.connect.IConnectionPointContainer_methods + win32com.server.connect.IConnectionPoint_methods ! _com_interfaces_ = [pythoncom.IID_IConnectionPoint, pythoncom.IID_IConnectionPointContainer] ! # IConnectionPoint interfaces ! def __init__(self): ! self.cookieNo = -1 ! self.connections = {} ! def EnumConnections(self): ! RaiseNotImpl("EnumConnections") ! def GetConnectionInterface(self): ! RaiseNotImpl("GetConnectionInterface") ! def GetConnectionPointContainer(self): ! return _wrap(self) ! def Advise(self, pUnk): ! # Creates a connection to the client. Simply allocate a new cookie, ! # find the clients interface, and store it in a dictionary. ! interface = pUnk.QueryInterface(axdebug.IID_IDebugDocumentTextEvents,1) ! self.cookieNo = self.cookieNo + 1 ! self.connections[self.cookieNo] = interface ! return self.cookieNo ! def Unadvise(self, cookie): ! # Destroy a connection - simply delete interface from the map. ! try: ! del self.connections[cookie] ! except KeyError: ! return Exception(scode=winerror.E_UNEXPECTED) ! # IConnectionPointContainer interfaces ! def EnumConnectionPoints(self): ! RaiseNotImpl("EnumConnectionPoints") ! def FindConnectionPoint(self, iid): ! # Find a connection we support. Only support the single event interface. ! if iid==axdebug.IID_IDebugDocumentTextEvents: ! return _wrap(self) ! raise Exception(scode=winerror.E_NOINTERFACE) # ?? class RemoteDebugApplicationEvents: ! _public_methods_ = ["OnConnectDebugger","OnDisconnectDebugger","OnSetName","OnDebugOutput","OnClose","OnEnterBreakPoint","OnLeaveBreakPoint","OnCreateThread","OnDestroyThread","OnBreakFlagChange"] ! _com_interfaces_ = [axdebug.IID_IRemoteDebugApplicationEvents] ! def OnConnectDebugger(self, appDebugger): ! """appDebugger -- a PyIApplicationDebugger ! """ ! RaiseNotImpl("OnConnectDebugger") ! def OnDisconnectDebugger(self): ! RaiseNotImpl("OnDisconnectDebugger") ! def OnSetName(self, name): ! RaiseNotImpl("OnSetName") ! def OnDebugOutput(self, string): ! RaiseNotImpl("OnDebugOutput") ! def OnClose(self): ! RaiseNotImpl("OnClose") ! def OnEnterBreakPoint(self, rdat): ! """rdat -- PyIRemoteDebugApplicationThread ! """ ! RaiseNotImpl("OnEnterBreakPoint") ! def OnLeaveBreakPoint(self, rdat): ! """rdat -- PyIRemoteDebugApplicationThread ! """ ! RaiseNotImpl("OnLeaveBreakPoint") ! def OnCreateThread(self, rdat): ! """rdat -- PyIRemoteDebugApplicationThread ! """ ! RaiseNotImpl("OnCreateThread") ! def OnDestroyThread(self, rdat): ! """rdat -- PyIRemoteDebugApplicationThread ! """ ! RaiseNotImpl("OnDestroyThread") ! def OnBreakFlagChange(self, abf, rdat): ! """abf -- int - one of the axdebug.APPBREAKFLAGS constants ! rdat -- PyIRemoteDebugApplicationThread ! RaiseNotImpl("OnBreakFlagChange") ! """ class DebugExpressionContext: ! _public_methods_ = ["ParseLanguageText", "GetLanguageInfo"] ! _com_interfaces_ = [axdebug.IID_IDebugExpressionContext] ! def __init__(self): ! pass ! def ParseLanguageText(self, code, radix, delim, flags): ! """ ! result is IDebugExpression ! """ ! RaiseNotImpl("ParseLanguageText") ! def GetLanguageInfo(self): ! """ ! result is (string langName, iid langId) ! """ ! RaiseNotImpl("GetLanguageInfo") class DebugExpression: ! _public_methods_ = ["Start", "Abort", "QueryIsComplete", "GetResultAsString", "GetResultAsDebugProperty"] ! _com_interfaces_ = [axdebug.IID_IDebugExpression] ! def Start(self, callback): ! """ ! callback -- an IDebugExpressionCallback ! result - void ! """ ! RaiseNotImpl("Start") ! def Abort(self): ! """ ! no params ! result -- void ! """ ! RaiseNotImpl("Abort") ! def QueryIsComplete(self): ! """ ! no params ! result -- void ! """ ! RaiseNotImpl("QueryIsComplete") ! def GetResultAsString(self): ! RaiseNotImpl("GetResultAsString") ! ! def GetResultAsDebugProperty(self): ! RaiseNotImpl("GetResultAsDebugProperty") class ProvideExpressionContexts: ! _public_methods_ = ["EnumExpressionContexts"] ! _com_interfaces_ = [axdebug.IID_IProvideExpressionContexts] ! def EnumExpressionContexts(self): ! RaiseNotImpl("EnumExpressionContexts") Index: dump.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axdebug/dump.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** dump.py 1 Sep 1999 23:09:01 -0000 1.1 --- dump.py 18 Jun 2006 13:18:26 -0000 1.2 *************** *** 6,49 **** def DumpDebugApplicationNode(node, level = 0): ! # Recursive dump of a DebugApplicationNode ! spacer = " " * level ! for desc, attr in [("Node Name", axdebug.DOCUMENTNAMETYPE_APPNODE), ! ("Title", axdebug.DOCUMENTNAMETYPE_TITLE), ! ("Filename", axdebug.DOCUMENTNAMETYPE_FILE_TAIL), ! ("URL", axdebug.DOCUMENTNAMETYPE_URL), ! ]: ! try: ! info = node.GetName(attr) ! except pythoncom.com_error: ! info = "<N/A>" ! print "%s%s: %s" % (spacer, desc, info) ! try: ! doc = node.GetDocument() ! except pythoncom.com_error: ! doc = None ! if doc: ! doctext = doc.QueryInterface(axdebug.IID_IDebugDocumentText) ! numLines, numChars = doctext.GetSize() ! # text, attr = doctext.GetText(0, 20, 1) ! text, attr = doctext.GetText(0, numChars, 1) ! print "%sText is %s, %d bytes long" % (spacer, repr(text[:40]+"..."), len(text)) ! else: ! print "%s%s" % (spacer, "<No document available>") ! ! for child in Enumerator(node.EnumChildren()): ! DumpDebugApplicationNode(child, level+1) ! def dumpall(): ! dm=pythoncom.CoCreateInstance(axdebug.CLSID_MachineDebugManager,None,pythoncom.CLSCTX_ALL, axdebug.IID_IMachineDebugManager) ! e=Enumerator(dm.EnumApplications()) ! for app in e: ! print "Application: %s" % app.GetName() ! node = app.GetRootNode() # of type PyIDebugApplicationNode->PyIDebugDocumentProvider->PyIDebugDocumentInfo ! DumpDebugApplicationNode(node) if __name__=='__main__': ! try: ! dumpall() ! except: ! traceback.print_exc() ! --- 6,48 ---- def DumpDebugApplicationNode(node, level = 0): ! # Recursive dump of a DebugApplicationNode ! spacer = " " * level ! for desc, attr in [("Node Name", axdebug.DOCUMENTNAMETYPE_APPNODE), ! ("Title", axdebug.DOCUMENTNAMETYPE_TITLE), ! ("Filename", axdebug.DOCUMENTNAMETYPE_FILE_TAIL), ! ("URL", axdebug.DOCUMENTNAMETYPE_URL), ! ]: ! try: ! info = node.GetName(attr) ! except pythoncom.com_error: ! info = "<N/A>" ! print "%s%s: %s" % (spacer, desc, info) ! try: ! doc = node.GetDocument() ! except pythoncom.com_error: ! doc = None ! if doc: ! doctext = doc.QueryInterface(axdebug.IID_IDebugDocumentText) ! numLines, numChars = doctext.GetSize() ! # text, attr = doctext.GetText(0, 20, 1) ! text, attr = doctext.GetText(0, numChars, 1) ! print "%sText is %s, %d bytes long" % (spacer, repr(text[:40]+"..."), len(text)) ! else: ! print "%s%s" % (spacer, "<No document available>") ! ! for child in Enumerator(node.EnumChildren()): ! DumpDebugApplicationNode(child, level+1) ! def dumpall(): ! dm=pythoncom.CoCreateInstance(axdebug.CLSID_MachineDebugManager,None,pythoncom.CLSCTX_ALL, axdebug.IID_IMachineDebugManager) ! e=Enumerator(dm.EnumApplications()) ! for app in e: ! print "Application: %s" % app.GetName() ! node = app.GetRootNode() # of type PyIDebugApplicationNode->PyIDebugDocumentProvider->PyIDebugDocumentInfo ! DumpDebugApplicationNode(node) if __name__=='__main__': ! try: ! dumpall() ! except: ! traceback.print_exc() Index: adb.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axdebug/adb.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** adb.py 11 Apr 2005 13:04:41 -0000 1.4 --- adb.py 18 Jun 2006 13:18:26 -0000 1.5 *************** *** 11,21 **** def fnull(*args): ! pass try: ! os.environ["DEBUG_AXDEBUG"] ! debugging = 1 except KeyError: ! debugging = 0 traceenter = fnull # trace enter of functions --- 11,21 ---- def fnull(*args): ! pass try: ! os.environ["DEBUG_AXDEBUG"] ! debugging = 1 except KeyError: ! debugging = 0 traceenter = fnull # trace enter of functions *************** *** 23,416 **** if debugging: ! traceenter = trace # trace enter of functions ! tracev = trace # verbose trace class OutputReflector: ! def __init__(self, file, writefunc): ! self.writefunc = writefunc ! self.file = file ! def __getattr__(self,name): ! return getattr(self.file, name) ! def write(self,message): ! self.writefunc(message) ! self.file.write(message) def _dumpf(frame): ! if frame is None: ! return "<None>" ! else: ! addn = "(with trace!)" ! if frame.f_trace is None: ! addn = " **No Trace Set **" ! return "Frame at %d, file %s, line: %d%s" % (id(frame), frame.f_code.co_filename, frame.f_lineno, addn) g_adb = None def OnSetBreakPoint(codeContext, breakPointState, lineNo): ! try: ! fileName = codeContext.codeContainer.GetFileName() ! # inject the code into linecache. ! import linecache ! linecache.cache[fileName] = 0, 0, codeContext.codeContainer.GetText(), fileName ! g_adb._OnSetBreakPoint(fileName, codeContext, breakPointState, lineNo+1) ! except: ! traceback.print_exc() class Adb(bdb.Bdb,gateways.RemoteDebugApplicationEvents): ! def __init__(self): ! self.debugApplication = None ! self.debuggingThread = None ! self.debuggingThreadStateHandle = None ! self.stackSnifferCookie = self.stackSniffer = None ! self.codeContainerProvider = None ! self.debuggingThread = None ! self.breakFlags = None ! self.breakReason = None ! self.appDebugger = None ! self.appEventConnection = None ! self.logicalbotframe = None # Anything at this level or below does not exist! ! self.currentframe = None # The frame we are currently in. ! self.recursiveData = [] # Data saved for each reentery on this thread. ! bdb.Bdb.__init__(self) ! self._threadprotectlock = thread.allocate_lock() ! self.reset() ! def canonic(self, fname): ! if fname[0]=='<': ! return fname ! return bdb.Bdb.canonic(self, fname) ! def reset(self): ! traceenter("adb.reset") ! bdb.Bdb.reset(self) ! ! def __xxxxx__set_break(self, filename, lineno, cond = None): ! # As per standard one, except no linecache checking! ! if not self.breaks.has_key(filename): ! self.breaks[filename] = [] ! list = self.breaks[filename] ! if lineno in list: ! return 'There is already a breakpoint there!' ! list.append(lineno) ! if cond is not None: self.cbreaks[filename, lineno]=cond ! ! def stop_here(self, frame): ! traceenter("stop_here", _dumpf(frame), _dumpf(self.stopframe)) ! # As per bdb.stop_here, except for logicalbotframe ! ## if self.stopframe is None: ! ## return 1 ! if frame is self.stopframe: ! return 1 ! ! tracev("stop_here said 'No'!") ! return 0 ! ! def break_here(self, frame): ! traceenter("break_here", self.breakFlags, _dumpf(frame)) ! self.breakReason = None ! if self.breakFlags==axdebug.APPBREAKFLAG_DEBUGGER_HALT: ! self.breakReason = axdebug.BREAKREASON_DEBUGGER_HALT ! elif self.breakFlags==axdebug.APPBREAKFLAG_DEBUGGER_BLOCK: ! self.breakReason = axdebug.BREAKREASON_DEBUGGER_BLOCK ! elif self.breakFlags==axdebug.APPBREAKFLAG_STEP: ! self.breakReason = axdebug.BREAKREASON_STEP ! else: ! print "Calling base 'break_here' with", self.breaks ! if bdb.Bdb.break_here(self, frame): ! self.breakReason = axdebug.BREAKREASON_BREAKPOINT ! return self.breakReason is not None ! ! def break_anywhere(self, frame): ! traceenter("break_anywhere", _dumpf(frame)) ! if self.breakFlags==axdebug.APPBREAKFLAG_DEBUGGER_HALT: ! self.breakReason = axdebug.BREAKREASON_DEBUGGER_HALT ! return 1 ! rc = bdb.Bdb.break_anywhere(self, frame) ! tracev("break_anywhere",_dumpf(frame),"returning",rc) ! return rc ! def dispatch_return(self, frame, arg): ! traceenter("dispatch_return", _dumpf(frame), arg) ! if self.logicalbotframe is frame: ! # We dont want to debug parent frames. ! tracev("dispatch_return resetting sys.trace") ! sys.settrace(None) ! return ! # self.bSetTrace = 0 ! self.currentframe = frame.f_back ! return bdb.Bdb.dispatch_return(self, frame, arg) ! def dispatch_line(self, frame): ! traceenter("dispatch_line", _dumpf(frame), _dumpf(self.botframe)) ! # trace("logbotframe is", _dumpf(self.logicalbotframe), "botframe is", self.botframe) ! if frame is self.logicalbotframe: ! trace("dispatch_line", _dumpf(frame), "for bottom frame returing tracer") ! # The next code executed in the frame above may be a builtin (eg, apply()) ! # in which sys.trace needs to be set. ! sys.settrace(self.trace_dispatch) ! # And return the tracer incase we are about to execute Python code, ! # in which case sys tracer is ignored! ! return self.trace_dispatch ! ! if self.codeContainerProvider.FromFileName(frame.f_code.co_filename) is None: ! trace("dispatch_line has no document for", _dumpf(frame), "- skipping trace!") ! return None ! self.currentframe = frame # So the stack sniffer knows our most recent, debuggable code. ! return bdb.Bdb.dispatch_line(self, frame) ! ! def dispatch_call(self, frame, arg): ! traceenter("dispatch_call",_dumpf(frame)) ! frame.f_locals['__axstack_address__'] = axdebug.GetStackAddress() ! if frame is self.botframe: ! trace("dispatch_call is self.botframe - returning tracer") ! return self.trace_dispatch ! # Not our bottom frame. If we have a document for it, ! # then trace it, otherwise run at full speed. ! if self.codeContainerProvider.FromFileName(frame.f_code.co_filename) is None: ! trace("dispatch_call has no document for", _dumpf(frame), "- skipping trace!") ! ## sys.settrace(None) ! return None ! return self.trace_dispatch ! ! # rc = bdb.Bdb.dispatch_call(self, frame, arg) ! # trace("dispatch_call", _dumpf(frame),"returned",rc) ! # return rc ! def trace_dispatch(self, frame, event, arg): ! traceenter("trace_dispatch", _dumpf(frame), event, arg) ! if self.debugApplication is None: ! trace("trace_dispatch has no application!") ! return # None ! return bdb.Bdb.trace_dispatch(self, frame, event, arg) ! # ! # The user functions do bugger all! ! # ! # def user_call(self, frame, argument_list): ! # traceenter("user_call",_dumpf(frame)) ! def user_line(self, frame): ! traceenter("user_line",_dumpf(frame)) ! # Traces at line zero ! if frame.f_lineno!=0: ! breakReason = self.breakReason ! if breakReason is None: ! breakReason = axdebug.BREAKREASON_STEP ! self._HandleBreakPoint(frame, None, breakReason) ! def user_return(self, frame, return_value): ! # traceenter("user_return",_dumpf(frame),return_value) ! bdb.Bdb.user_return(self, frame, return_value) ! ! def user_exception(self, frame, (exc_type, exc_value, exc_traceback)): ! # traceenter("user_exception") ! bdb.Bdb.user_exception(self, frame, (exc_type, exc_value, exc_traceback)) ! ! def _HandleBreakPoint(self, frame, tb, reason): ! traceenter("Calling HandleBreakPoint with reason", reason,"at frame", _dumpf(frame)) ! traceenter(" Current frame is", _dumpf(self.currentframe)) ! try: ! resumeAction = self.debugApplication.HandleBreakPoint(reason) ! tracev("HandleBreakPoint returned with ", resumeAction) ! except pythoncom.com_error, details: ! # Eeek - the debugger is dead, or something serious is happening. ! # Assume we should continue ! resumeAction = axdebug.BREAKRESUMEACTION_CONTINUE ! trace("HandleBreakPoint FAILED with", details) ! ! self.stack = [] ! self.curindex = 0 ! if resumeAction == axdebug.BREAKRESUMEACTION_ABORT: ! self.set_quit() ! elif resumeAction == axdebug.BREAKRESUMEACTION_CONTINUE: ! tracev("resume action is continue") ! self.set_continue() ! elif resumeAction == axdebug.BREAKRESUMEACTION_STEP_INTO: ! tracev("resume action is step") ! self.set_step() ! elif resumeAction == axdebug.BREAKRESUMEACTION_STEP_OVER: ! tracev("resume action is next") ! self.set_next(frame) ! elif resumeAction == axdebug.BREAKRESUMEACTION_STEP_OUT: ! tracev("resume action is stop out") ! self.set_return(frame) ! else: ! assert(0, "unknown resume action flags") ! self.breakReason = None ! def set_trace(self): ! self.breakReason = axdebug.BREAKREASON_LANGUAGE_INITIATED ! bdb.Bdb.set_trace(self) ! def CloseApp(self): ! traceenter("ClosingApp") ! self.reset() ! self.logicalbotframe = None ! if self.stackSnifferCookie is not None: ! try: ! self.debugApplication.RemoveStackFrameSniffer(self.stackSnifferCookie) ! except pythoncom.com_error: ! trace("*** Could not RemoveStackFrameSniffer %d" % (self.stackSnifferCookie)) ! if self.stackSniffer: ! _wrap_remove(self.stackSniffer) ! self.stackSnifferCookie = self.stackSniffer = None - if self.appEventConnection is not None: - self.appEventConnection.Disconnect() - self.appEventConnection = None - self.debugApplication = None - self.appDebugger = None - if self.codeContainerProvider is not None: - self.codeContainerProvider.Close() - self.codeContainerProvider = None - - def AttachApp(self, debugApplication, codeContainerProvider): - # traceenter("AttachApp", debugApplication, codeContainerProvider) - self.codeContainerProvider = codeContainerProvider - self.debugApplication = debugApplication - self.stackSniffer = _wrap(stackframe.DebugStackFrameSniffer(self), axdebug.IID_IDebugStackFrameSniffer) - self.stackSnifferCookie = debugApplication.AddStackFrameSniffer(self.stackSniffer) - # trace("StackFrameSniffer added (%d)" % self.stackSnifferCookie) - - # Connect to the application events. - self.appEventConnection = win32com.client.connect.SimpleCo... [truncated message content] |
From: Mark H. <mha...@us...> - 2006-06-18 13:10:59
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/axscript/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28862/axscript/client Modified Files: framework.py Log Message: Move towards better unicode support - allow extended chars in comments. Index: framework.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axscript/client/framework.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** framework.py 11 Apr 2005 13:04:40 -0000 1.21 --- framework.py 18 Jun 2006 13:09:33 -0000 1.22 *************** *** 522,526 **** def AddScriptlet(self, defaultName, code, itemName, subItemName, eventName, delimiter, sourceContextCookie, startLineNumber): # trace ("AddScriptlet", defaultName, code, itemName, subItemName, eventName, delimiter, sourceContextCookie, startLineNumber) ! self.DoAddScriptlet(defaultName, str(code), itemName, subItemName, eventName, delimiter,sourceContextCookie, startLineNumber) def ParseScriptText(self, code, itemName, context, delimiter, sourceContextCookie, startLineNumber, flags, bWantResult): --- 522,526 ---- def AddScriptlet(self, defaultName, code, itemName, subItemName, eventName, delimiter, sourceContextCookie, startLineNumber): # trace ("AddScriptlet", defaultName, code, itemName, subItemName, eventName, delimiter, sourceContextCookie, startLineNumber) ! self.DoAddScriptlet(defaultName, code, itemName, subItemName, eventName, delimiter,sourceContextCookie, startLineNumber) def ParseScriptText(self, code, itemName, context, delimiter, sourceContextCookie, startLineNumber, flags, bWantResult): *************** *** 536,540 **** # About to execute the code. self.RegisterNewNamedItems() ! return self.DoParseScriptText(str(code), sourceContextCookie, startLineNumber, bWantResult, flags) # --- 536,540 ---- # About to execute the code. self.RegisterNewNamedItems() ! return self.DoParseScriptText(code, sourceContextCookie, startLineNumber, bWantResult, flags) # *************** *** 550,554 **** # (but even for those blocks, the "onClick" information is still missing!?!?!?) ! # self.DoAddScriptlet(None, str(code), itemName, subItemName, eventName, delimiter,sourceContextCookie, startLineNumber) return None # --- 550,554 ---- # (but even for those blocks, the "onClick" information is still missing!?!?!?) ! # self.DoAddScriptlet(None, code, itemName, subItemName, eventName, delimiter,sourceContextCookie, startLineNumber) return None # *************** *** 653,657 **** def AddNamedItem(self, name, flags): if self.scriptSite is None: raise Exception(scode=winerror.E_INVALIDARG) - name = str(name) # Convert from Unicode. try: unknown = self.scriptSite.GetItemInfo(name, axscript.SCRIPTINFO_IUNKNOWN)[0] --- 653,656 ---- |
From: Mark H. <mha...@us...> - 2006-06-18 13:09:50
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/axscript/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28862/axscript/test Modified Files: testHost.py Log Message: Move towards better unicode support - allow extended chars in comments. Index: testHost.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axscript/test/testHost.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** testHost.py 10 Nov 2003 02:21:03 -0000 1.3 --- testHost.py 18 Jun 2006 13:09:35 -0000 1.4 *************** *** 108,112 **** end sub """ ! PyScript = """\ prop = "Property Value" def hello(arg1): --- 108,113 ---- end sub """ ! PyScript = u"""\ ! # A unicode \xa9omment. prop = "Property Value" def hello(arg1): |
From: Mark H. <mha...@us...> - 2006-06-18 13:09:47
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/axdebug In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28862/axdebug Modified Files: codecontainer.py expressions.py Log Message: Move towards better unicode support - allow extended chars in comments. Index: expressions.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axdebug/expressions.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** expressions.py 11 Apr 2005 13:04:42 -0000 1.3 --- expressions.py 18 Jun 2006 13:09:36 -0000 1.4 *************** *** 30,34 **** self.callback = None self.frame = frame ! self.code = str(code) self.radix = radix self.delim = delim --- 30,34 ---- self.callback = None self.frame = frame ! self.code = code self.radix = radix self.delim = delim Index: codecontainer.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axdebug/codecontainer.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** codecontainer.py 1 Jun 2002 02:40:10 -0000 1.2 --- codecontainer.py 18 Jun 2006 13:09:36 -0000 1.3 *************** *** 25,32 **** def __init__(self, text, fileName = "<Remove Me!>", sourceContext = 0, startLineNumber = 0, site = None, debugDocument = None): self.sourceContext = sourceContext # The source context added by a smart host. ! self.text = None if text: ! self.text = str(text)# Convert from Unicode if necessary. ! self._buildlines() self.nextLineNo = 0 self.fileName = fileName --- 25,31 ---- def __init__(self, text, fileName = "<Remove Me!>", sourceContext = 0, startLineNumber = 0, site = None, debugDocument = None): self.sourceContext = sourceContext # The source context added by a smart host. ! self.text = text if text: ! self._buildlines() self.nextLineNo = 0 self.fileName = fileName |
From: Mark H. <mha...@us...> - 2006-05-24 08:40:46
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14178 Modified Files: odbc.cpp Log Message: Using SQL_VARCHAR/SQL_WVARCHAR instead of SQL_CHAR/SQL_WCHAR prevents padding of zero byte strings with SQLServer. Index: odbc.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/odbc.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** odbc.cpp 15 Mar 2006 04:01:35 -0000 1.16 --- odbc.cpp 24 May 2006 08:40:41 -0000 1.17 *************** *** 863,867 **** strcpy(ib->bind_area, val); ! int sqlType = SQL_CHAR; if (len > 255) { --- 863,867 ---- strcpy(ib->bind_area, val); ! int sqlType = SQL_VARCHAR; // SQL_CHAR can cause padding in some drivers.. if (len > 255) { *************** *** 907,911 **** wcscpy((WCHAR *)ib->bind_area, wval); ! int sqlType = SQL_WCHAR; if (nbytes > 255) { --- 907,912 ---- wcscpy((WCHAR *)ib->bind_area, wval); ! // See above re SQL_VARCHAR ! int sqlType = SQL_WVARCHAR; if (nbytes > 255) { |