summaryrefslogtreecommitdiffstats
path: root/Mac/Modules/win
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2000-06-02 21:35:07 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2000-06-02 21:35:07 (GMT)
commite79dc76f53dfa18fb08c35f71b049259642c0142 (patch)
tree2d9cc6228cc713336a01d9ff09571eacff3a2ba0 /Mac/Modules/win
parent33d1ad28cba273b94c70ffc22deb6c53b0c1b068 (diff)
downloadcpython-e79dc76f53dfa18fb08c35f71b049259642c0142.zip
cpython-e79dc76f53dfa18fb08c35f71b049259642c0142.tar.gz
cpython-e79dc76f53dfa18fb08c35f71b049259642c0142.tar.bz2
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Macmodule and macosmodule have also been carbonified. Some functionality is still missing there.
Diffstat (limited to 'Mac/Modules/win')
-rw-r--r--Mac/Modules/win/Winmodule.c171
-rw-r--r--Mac/Modules/win/winedit.py16
-rw-r--r--Mac/Modules/win/winscan.py25
-rw-r--r--Mac/Modules/win/winsupport.py2
4 files changed, 154 insertions, 60 deletions
diff --git a/Mac/Modules/win/Winmodule.c b/Mac/Modules/win/Winmodule.c
index 9542447..a03d493 100644
--- a/Mac/Modules/win/Winmodule.c
+++ b/Mac/Modules/win/Winmodule.c
@@ -78,10 +78,12 @@ WinObj_Convert(v, p_itself)
PyObject *v;
WindowPtr *p_itself;
{
+#ifndef TARGET_API_MAC_CARBON
if (DlgObj_Check(v)) {
*p_itself = ((WindowObject *)v)->ob_itself;
return 1;
}
+#endif
if (v == Py_None) { *p_itself = NULL; return 1; }
if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
@@ -102,19 +104,6 @@ static void WinObj_dealloc(self)
PyMem_DEL(self);
}
-static PyObject *WinObj_MacCloseWindow(_self, _args)
- WindowObject *_self;
- PyObject *_args;
-{
- PyObject *_res = NULL;
- if (!PyArg_ParseTuple(_args, ""))
- return NULL;
- MacCloseWindow(_self->ob_itself);
- Py_INCREF(Py_None);
- _res = Py_None;
- return _res;
-}
-
static PyObject *WinObj_GetWindowOwnerCount(_self, _args)
WindowObject *_self;
PyObject *_args;
@@ -181,6 +170,8 @@ static PyObject *WinObj_GetWindowAttributes(_self, _args)
return _res;
}
+#ifndef TARGET_API_MAC_CARBON
+
static PyObject *WinObj_SetWinColor(_self, _args)
WindowObject *_self;
PyObject *_args;
@@ -196,6 +187,7 @@ static PyObject *WinObj_SetWinColor(_self, _args)
_res = Py_None;
return _res;
}
+#endif
static PyObject *WinObj_SetWindowContentColor(_self, _args)
WindowObject *_self;
@@ -280,6 +272,8 @@ static PyObject *WinObj_ClipAbove(_self, _args)
return _res;
}
+#ifndef TARGET_API_MAC_CARBON
+
static PyObject *WinObj_SaveOld(_self, _args)
WindowObject *_self;
PyObject *_args;
@@ -292,6 +286,9 @@ static PyObject *WinObj_SaveOld(_self, _args)
_res = Py_None;
return _res;
}
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
static PyObject *WinObj_DrawNew(_self, _args)
WindowObject *_self;
@@ -308,6 +305,7 @@ static PyObject *WinObj_DrawNew(_self, _args)
_res = Py_None;
return _res;
}
+#endif
static PyObject *WinObj_PaintOne(_self, _args)
WindowObject *_self;
@@ -713,7 +711,7 @@ static PyObject *WinObj_GetWindowProxyFSSpec(_self, _args)
&outFile);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
- PyMac_BuildFSSpec, &outFile);
+ PyMac_BuildFSSpec, outFile);
return _res;
}
@@ -1319,6 +1317,8 @@ static PyObject *WinObj_TrackGoAway(_self, _args)
return _res;
}
+#ifndef TARGET_API_MAC_CARBON
+
static PyObject *WinObj_GetAuxWin(_self, _args)
WindowObject *_self;
PyObject *_args;
@@ -1335,6 +1335,7 @@ static PyObject *WinObj_GetAuxWin(_self, _args)
ResObj_New, awHndl);
return _res;
}
+#endif
static PyObject *WinObj_GetWindowPort(_self, _args)
WindowObject *_self;
@@ -1435,6 +1436,8 @@ static PyObject *WinObj_GetWindowGoAwayFlag(_self, _args)
return _res;
}
+#ifndef TARGET_API_MAC_CARBON
+
static PyObject *WinObj_GetWindowZoomFlag(_self, _args)
WindowObject *_self;
PyObject *_args;
@@ -1448,6 +1451,9 @@ static PyObject *WinObj_GetWindowZoomFlag(_self, _args)
_rv);
return _res;
}
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
static PyObject *WinObj_GetWindowStructureRgn(_self, _args)
WindowObject *_self;
@@ -1464,6 +1470,9 @@ static PyObject *WinObj_GetWindowStructureRgn(_self, _args)
_res = Py_None;
return _res;
}
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
static PyObject *WinObj_GetWindowContentRgn(_self, _args)
WindowObject *_self;
@@ -1480,6 +1489,9 @@ static PyObject *WinObj_GetWindowContentRgn(_self, _args)
_res = Py_None;
return _res;
}
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
static PyObject *WinObj_GetWindowUpdateRgn(_self, _args)
WindowObject *_self;
@@ -1496,6 +1508,9 @@ static PyObject *WinObj_GetWindowUpdateRgn(_self, _args)
_res = Py_None;
return _res;
}
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
static PyObject *WinObj_GetWindowTitleWidth(_self, _args)
WindowObject *_self;
@@ -1510,6 +1525,7 @@ static PyObject *WinObj_GetWindowTitleWidth(_self, _args)
_rv);
return _res;
}
+#endif
static PyObject *WinObj_GetNextWindow(_self, _args)
WindowObject *_self;
@@ -1587,35 +1603,7 @@ static PyObject *WinObj_SetWindowUserState(_self, _args)
return _res;
}
-static PyObject *WinObj_GetWindowDataHandle(_self, _args)
- WindowObject *_self;
- PyObject *_args;
-{
- PyObject *_res = NULL;
- Handle _rv;
- if (!PyArg_ParseTuple(_args, ""))
- return NULL;
- _rv = GetWindowDataHandle(_self->ob_itself);
- _res = Py_BuildValue("O&",
- ResObj_New, _rv);
- return _res;
-}
-
-static PyObject *WinObj_SetWindowDataHandle(_self, _args)
- WindowObject *_self;
- PyObject *_args;
-{
- PyObject *_res = NULL;
- Handle data;
- if (!PyArg_ParseTuple(_args, "O&",
- ResObj_Convert, &data))
- return NULL;
- SetWindowDataHandle(_self->ob_itself,
- data);
- Py_INCREF(Py_None);
- _res = Py_None;
- return _res;
-}
+#ifndef TARGET_API_MAC_CARBON
static PyObject *WinObj_CloseWindow(_self, _args)
WindowObject *_self;
@@ -1629,6 +1617,7 @@ static PyObject *WinObj_CloseWindow(_self, _args)
_res = Py_None;
return _res;
}
+#endif
static PyObject *WinObj_MoveWindow(_self, _args)
WindowObject *_self;
@@ -1666,8 +1655,6 @@ static PyObject *WinObj_ShowWindow(_self, _args)
}
static PyMethodDef WinObj_methods[] = {
- {"MacCloseWindow", (PyCFunction)WinObj_MacCloseWindow, 1,
- "() -> None"},
{"GetWindowOwnerCount", (PyCFunction)WinObj_GetWindowOwnerCount, 1,
"() -> (UInt32 outCount)"},
{"CloneWindow", (PyCFunction)WinObj_CloneWindow, 1,
@@ -1676,8 +1663,11 @@ static PyMethodDef WinObj_methods[] = {
"() -> (WindowClass outClass)"},
{"GetWindowAttributes", (PyCFunction)WinObj_GetWindowAttributes, 1,
"() -> (WindowAttributes outAttributes)"},
+
+#ifndef TARGET_API_MAC_CARBON
{"SetWinColor", (PyCFunction)WinObj_SetWinColor, 1,
"(WCTabHandle newColorTable) -> None"},
+#endif
{"SetWindowContentColor", (PyCFunction)WinObj_SetWindowContentColor, 1,
"() -> (RGBColor color)"},
{"GetWindowContentColor", (PyCFunction)WinObj_GetWindowContentColor, 1,
@@ -1688,10 +1678,16 @@ static PyMethodDef WinObj_methods[] = {
"(PixPatHandle pixPat) -> None"},
{"ClipAbove", (PyCFunction)WinObj_ClipAbove, 1,
"() -> None"},
+
+#ifndef TARGET_API_MAC_CARBON
{"SaveOld", (PyCFunction)WinObj_SaveOld, 1,
"() -> None"},
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
{"DrawNew", (PyCFunction)WinObj_DrawNew, 1,
"(Boolean update) -> None"},
+#endif
{"PaintOne", (PyCFunction)WinObj_PaintOne, 1,
"(RgnHandle clobberedRgn) -> None"},
{"PaintBehind", (PyCFunction)WinObj_PaintBehind, 1,
@@ -1810,8 +1806,11 @@ static PyMethodDef WinObj_methods[] = {
"(Point thePt, short partCode) -> (Boolean _rv)"},
{"TrackGoAway", (PyCFunction)WinObj_TrackGoAway, 1,
"(Point thePt) -> (Boolean _rv)"},
+
+#ifndef TARGET_API_MAC_CARBON
{"GetAuxWin", (PyCFunction)WinObj_GetAuxWin, 1,
"() -> (Boolean _rv, AuxWinHandle awHndl)"},
+#endif
{"GetWindowPort", (PyCFunction)WinObj_GetWindowPort, 1,
"() -> (CGrafPtr _rv)"},
{"SetPortWindowPort", (PyCFunction)WinObj_SetPortWindowPort, 1,
@@ -1826,16 +1825,31 @@ static PyMethodDef WinObj_methods[] = {
"() -> (Boolean _rv)"},
{"GetWindowGoAwayFlag", (PyCFunction)WinObj_GetWindowGoAwayFlag, 1,
"() -> (Boolean _rv)"},
+
+#ifndef TARGET_API_MAC_CARBON
{"GetWindowZoomFlag", (PyCFunction)WinObj_GetWindowZoomFlag, 1,
"() -> (Boolean _rv)"},
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
{"GetWindowStructureRgn", (PyCFunction)WinObj_GetWindowStructureRgn, 1,
"(RgnHandle r) -> None"},
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
{"GetWindowContentRgn", (PyCFunction)WinObj_GetWindowContentRgn, 1,
"(RgnHandle r) -> None"},
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
{"GetWindowUpdateRgn", (PyCFunction)WinObj_GetWindowUpdateRgn, 1,
"(RgnHandle r) -> None"},
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
{"GetWindowTitleWidth", (PyCFunction)WinObj_GetWindowTitleWidth, 1,
"() -> (short _rv)"},
+#endif
{"GetNextWindow", (PyCFunction)WinObj_GetNextWindow, 1,
"() -> (WindowPtr _rv)"},
{"GetWindowStandardState", (PyCFunction)WinObj_GetWindowStandardState, 1,
@@ -1846,12 +1860,11 @@ static PyMethodDef WinObj_methods[] = {
"(Rect r) -> None"},
{"SetWindowUserState", (PyCFunction)WinObj_SetWindowUserState, 1,
"(Rect r) -> None"},
- {"GetWindowDataHandle", (PyCFunction)WinObj_GetWindowDataHandle, 1,
- "() -> (Handle _rv)"},
- {"SetWindowDataHandle", (PyCFunction)WinObj_SetWindowDataHandle, 1,
- "(Handle data) -> None"},
+
+#ifndef TARGET_API_MAC_CARBON
{"CloseWindow", (PyCFunction)WinObj_CloseWindow, 1,
"() -> None"},
+#endif
{"MoveWindow", (PyCFunction)WinObj_MoveWindow, 1,
"(short hGlobal, short vGlobal, Boolean front) -> None"},
{"ShowWindow", (PyCFunction)WinObj_ShowWindow, 1,
@@ -2110,6 +2123,8 @@ static PyObject *Win_FrontNonFloatingWindow(_self, _args)
return _res;
}
+#ifndef TARGET_API_MAC_CARBON
+
static PyObject *Win_SetDeskCPat(_self, _args)
PyObject *_self;
PyObject *_args;
@@ -2124,6 +2139,7 @@ static PyObject *Win_SetDeskCPat(_self, _args)
_res = Py_None;
return _res;
}
+#endif
static PyObject *Win_CheckUpdate(_self, _args)
PyObject *_self;
@@ -2174,6 +2190,8 @@ static PyObject *Win_FrontWindow(_self, _args)
return _res;
}
+#ifndef TARGET_API_MAC_CARBON
+
static PyObject *Win_InitWindows(_self, _args)
PyObject *_self;
PyObject *_args;
@@ -2186,6 +2204,9 @@ static PyObject *Win_InitWindows(_self, _args)
_res = Py_None;
return _res;
}
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
static PyObject *Win_GetWMgrPort(_self, _args)
PyObject *_self;
@@ -2200,6 +2221,9 @@ static PyObject *Win_GetWMgrPort(_self, _args)
GrafObj_New, wPort);
return _res;
}
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
static PyObject *Win_GetCWMgrPort(_self, _args)
PyObject *_self;
@@ -2214,6 +2238,9 @@ static PyObject *Win_GetCWMgrPort(_self, _args)
GrafObj_New, wMgrCPort);
return _res;
}
+#endif
+
+#ifndef TARGET_API_MAC_CARBON_NOTYET
static PyObject *Win_IsValidWindowPtr(_self, _args)
PyObject *_self;
@@ -2230,6 +2257,9 @@ static PyObject *Win_IsValidWindowPtr(_self, _args)
_rv);
return _res;
}
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
static PyObject *Win_InitFloatingWindows(_self, _args)
PyObject *_self;
@@ -2245,6 +2275,9 @@ static PyObject *Win_InitFloatingWindows(_self, _args)
_res = Py_None;
return _res;
}
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
static PyObject *Win_InvalRect(_self, _args)
PyObject *_self;
@@ -2260,6 +2293,9 @@ static PyObject *Win_InvalRect(_self, _args)
_res = Py_None;
return _res;
}
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
static PyObject *Win_InvalRgn(_self, _args)
PyObject *_self;
@@ -2275,6 +2311,9 @@ static PyObject *Win_InvalRgn(_self, _args)
_res = Py_None;
return _res;
}
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
static PyObject *Win_ValidRect(_self, _args)
PyObject *_self;
@@ -2290,6 +2329,9 @@ static PyObject *Win_ValidRect(_self, _args)
_res = Py_None;
return _res;
}
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
static PyObject *Win_ValidRgn(_self, _args)
PyObject *_self;
@@ -2305,6 +2347,7 @@ static PyObject *Win_ValidRgn(_self, _args)
_res = Py_None;
return _res;
}
+#endif
static PyObject *Win_CollapseAllWindows(_self, _args)
PyObject *_self;
@@ -2410,32 +2453,62 @@ static PyMethodDef Win_methods[] = {
"() -> (Boolean _rv)"},
{"FrontNonFloatingWindow", (PyCFunction)Win_FrontNonFloatingWindow, 1,
"() -> (WindowPtr _rv)"},
+
+#ifndef TARGET_API_MAC_CARBON
{"SetDeskCPat", (PyCFunction)Win_SetDeskCPat, 1,
"(PixPatHandle deskPixPat) -> None"},
+#endif
{"CheckUpdate", (PyCFunction)Win_CheckUpdate, 1,
"() -> (Boolean _rv, EventRecord theEvent)"},
{"MacFindWindow", (PyCFunction)Win_MacFindWindow, 1,
"(Point thePoint) -> (short _rv, WindowPtr window)"},
{"FrontWindow", (PyCFunction)Win_FrontWindow, 1,
"() -> (WindowPtr _rv)"},
+
+#ifndef TARGET_API_MAC_CARBON
{"InitWindows", (PyCFunction)Win_InitWindows, 1,
"() -> None"},
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
{"GetWMgrPort", (PyCFunction)Win_GetWMgrPort, 1,
"() -> (GrafPtr wPort)"},
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
{"GetCWMgrPort", (PyCFunction)Win_GetCWMgrPort, 1,
"() -> (CGrafPtr wMgrCPort)"},
+#endif
+
+#ifndef TARGET_API_MAC_CARBON_NOTYET
{"IsValidWindowPtr", (PyCFunction)Win_IsValidWindowPtr, 1,
"(GrafPtr grafPort) -> (Boolean _rv)"},
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
{"InitFloatingWindows", (PyCFunction)Win_InitFloatingWindows, 1,
"() -> None"},
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
{"InvalRect", (PyCFunction)Win_InvalRect, 1,
"(Rect badRect) -> None"},
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
{"InvalRgn", (PyCFunction)Win_InvalRgn, 1,
"(RgnHandle badRgn) -> None"},
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
{"ValidRect", (PyCFunction)Win_ValidRect, 1,
"(Rect goodRect) -> None"},
+#endif
+
+#ifndef TARGET_API_MAC_CARBON
{"ValidRgn", (PyCFunction)Win_ValidRgn, 1,
"(RgnHandle goodRgn) -> None"},
+#endif
{"CollapseAllWindows", (PyCFunction)Win_CollapseAllWindows, 1,
"(Boolean collapse) -> None"},
{"PinRect", (PyCFunction)Win_PinRect, 1,
diff --git a/Mac/Modules/win/winedit.py b/Mac/Modules/win/winedit.py
index 6a81b9b..bf43a43 100644
--- a/Mac/Modules/win/winedit.py
+++ b/Mac/Modules/win/winedit.py
@@ -40,29 +40,34 @@ methods.append(f)
f = Method(Boolean, 'GetWindowZoomFlag',
(WindowRef, 'theWindow', InMode),
+ condition='#ifndef TARGET_API_MAC_CARBON'
)
methods.append(f)
f = Method(void, 'GetWindowStructureRgn',
(WindowRef, 'theWindow', InMode),
(RgnHandle, 'r', InMode),
+ condition='#ifndef TARGET_API_MAC_CARBON'
)
methods.append(f)
f = Method(void, 'GetWindowContentRgn',
(WindowRef, 'theWindow', InMode),
(RgnHandle, 'r', InMode),
+ condition='#ifndef TARGET_API_MAC_CARBON'
)
methods.append(f)
f = Method(void, 'GetWindowUpdateRgn',
(WindowRef, 'theWindow', InMode),
(RgnHandle, 'r', InMode),
+ condition='#ifndef TARGET_API_MAC_CARBON'
)
methods.append(f)
f = Method(short, 'GetWindowTitleWidth',
(WindowRef, 'theWindow', InMode),
+ condition='#ifndef TARGET_API_MAC_CARBON'
)
methods.append(f)
@@ -96,20 +101,11 @@ f = Method(void, 'SetWindowUserState',
)
methods.append(f)
-f = Method(Handle, 'GetWindowDataHandle',
- (WindowRef, 'theWindow', InMode),
-)
-methods.append(f)
-f = Method(void, 'SetWindowDataHandle',
- (WindowRef, 'theWindow', InMode),
- (Handle, 'data', InMode),
-)
-methods.append(f)
-
# These have Mac prefixed to their name in the 3.1 universal headers,
# so we add the old/real names by hand.
f = Method(void, 'CloseWindow',
(WindowPtr, 'theWindow', InMode),
+ condition='#ifndef TARGET_API_MAC_CARBON'
)
methods.append(f)
diff --git a/Mac/Modules/win/winscan.py b/Mac/Modules/win/winscan.py
index 22f0d1a..b0f0fb3 100644
--- a/Mac/Modules/win/winscan.py
+++ b/Mac/Modules/win/winscan.py
@@ -41,10 +41,33 @@ class MyScanner(Scanner):
'GetWindowProperty',
'GetWindowPropertySize',
'RemoveWindowProperty',
+ 'MacCloseWindow',
# Constants with funny definitions
'kMouseUpOutOfSlop',
]
-
+
+ def makegreylist(self):
+ return [
+ ('#ifndef TARGET_API_MAC_CARBON', [
+ 'GetAuxWin',
+ 'GetWindowDataHandle',
+ 'SaveOld',
+ 'DrawNew',
+ 'SetWinColor',
+ 'SetDeskCPat',
+ 'InitWindows',
+ 'InitFloatingWindows',
+ 'GetWMgrPort',
+ 'GetCWMgrPort',
+ 'ValidRgn', # Use versions with Window in their name
+ 'ValidRect',
+ 'InvalRgn',
+ 'InvalRect',
+ ]),
+ ('#ifndef TARGET_API_MAC_CARBON_NOTYET', [
+ 'IsValidWindowPtr',
+ ])]
+
def makeblacklisttypes(self):
return [
'ProcPtr',
diff --git a/Mac/Modules/win/winsupport.py b/Mac/Modules/win/winsupport.py
index a6104d8..cc1c750 100644
--- a/Mac/Modules/win/winsupport.py
+++ b/Mac/Modules/win/winsupport.py
@@ -87,10 +87,12 @@ class MyObjectDefinition(GlobalObjectDefinition):
GlobalObjectDefinition.outputInitStructMembers(self)
Output("SetWRefCon(itself, (long)it);")
def outputCheckConvertArg(self):
+ Output("#ifndef TARGET_API_MAC_CARBON")
OutLbrace("if (DlgObj_Check(v))")
Output("*p_itself = ((WindowObject *)v)->ob_itself;")
Output("return 1;")
OutRbrace()
+ Output("#endif")
Out("""
if (v == Py_None) { *p_itself = NULL; return 1; }
if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }