[Python-checkins] CVS: python/dist/src/Mac/Modules/dlg _Dlgmodule.c,1.4,1.4.2.1

Jack Jansen jackjansen@users.sourceforge.net
Thu, 29 Nov 2001 05:23:29 -0800


Update of /cvsroot/python/python/dist/src/Mac/Modules/dlg
In directory usw-pr-cvs1:/tmp/cvs-serv23268/Python/Mac/Modules/dlg

Modified Files:
      Tag: r22b2-branch
	_Dlgmodule.c 
Log Message:
Use the WeakLink generators where it makes sense. This allows the resulting module to be imported on older versions of MacOS that do not support all routines encasulated in the module. Using a routine thats unavailable results in a RuntimeError, "Routine not available on this platform".

Index: _Dlgmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/dlg/_Dlgmodule.c,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -C2 -d -r1.4 -r1.4.2.1
*** _Dlgmodule.c	2001/11/05 16:16:34	1.4
--- _Dlgmodule.c	2001/11/29 13:23:27	1.4.2.1
***************
*** 6,15 ****
  
  
- #ifdef _WIN32
- #include "pywintoolbox.h"
- #else
  #include "macglue.h"
  #include "pymactoolbox.h"
- #endif
  
  /* Macro to test whether a weak-loaded CFM function exists */
--- 6,11 ----
***************
*** 186,189 ****
--- 182,188 ----
  {
  	PyObject *_res = NULL;
+ #ifndef DrawDialog
+ 	PyMac_PRECHECK(DrawDialog);
+ #endif
  	if (!PyArg_ParseTuple(_args, ""))
  		return NULL;
***************
*** 198,201 ****
--- 197,203 ----
  	PyObject *_res = NULL;
  	RgnHandle updateRgn;
+ #ifndef UpdateDialog
+ 	PyMac_PRECHECK(UpdateDialog);
+ #endif
  	if (!PyArg_ParseTuple(_args, "O&",
  	                      ResObj_Convert, &updateRgn))
***************
*** 212,215 ****
--- 214,220 ----
  	PyObject *_res = NULL;
  	DialogItemIndex itemNo;
+ #ifndef HideDialogItem
+ 	PyMac_PRECHECK(HideDialogItem);
+ #endif
  	if (!PyArg_ParseTuple(_args, "h",
  	                      &itemNo))
***************
*** 226,229 ****
--- 231,237 ----
  	PyObject *_res = NULL;
  	DialogItemIndex itemNo;
+ #ifndef ShowDialogItem
+ 	PyMac_PRECHECK(ShowDialogItem);
+ #endif
  	if (!PyArg_ParseTuple(_args, "h",
  	                      &itemNo))
***************
*** 241,244 ****
--- 249,255 ----
  	DialogItemIndexZeroBased _rv;
  	Point thePt;
+ #ifndef FindDialogItem
+ 	PyMac_PRECHECK(FindDialogItem);
+ #endif
  	if (!PyArg_ParseTuple(_args, "O&",
  	                      PyMac_GetPoint, &thePt))
***************
*** 254,257 ****
--- 265,271 ----
  {
  	PyObject *_res = NULL;
+ #ifndef DialogCut
+ 	PyMac_PRECHECK(DialogCut);
+ #endif
  	if (!PyArg_ParseTuple(_args, ""))
  		return NULL;
***************
*** 265,268 ****
--- 279,285 ----
  {
  	PyObject *_res = NULL;
+ #ifndef DialogPaste
+ 	PyMac_PRECHECK(DialogPaste);
+ #endif
  	if (!PyArg_ParseTuple(_args, ""))
  		return NULL;
***************
*** 276,279 ****
--- 293,299 ----
  {
  	PyObject *_res = NULL;
+ #ifndef DialogCopy
+ 	PyMac_PRECHECK(DialogCopy);
+ #endif
  	if (!PyArg_ParseTuple(_args, ""))
  		return NULL;
***************
*** 287,290 ****
--- 307,313 ----
  {
  	PyObject *_res = NULL;
+ #ifndef DialogDelete
+ 	PyMac_PRECHECK(DialogDelete);
+ #endif
  	if (!PyArg_ParseTuple(_args, ""))
  		return NULL;
***************
*** 302,305 ****
--- 325,331 ----
  	Handle item;
  	Rect box;
+ #ifndef GetDialogItem
+ 	PyMac_PRECHECK(GetDialogItem);
+ #endif
  	if (!PyArg_ParseTuple(_args, "h",
  	                      &itemNo))
***************
*** 324,327 ****
--- 350,356 ----
  	Handle item;
  	Rect box;
+ #ifndef SetDialogItem
+ 	PyMac_PRECHECK(SetDialogItem);
+ #endif
  	if (!PyArg_ParseTuple(_args, "hhO&O&",
  	                      &itemNo,
***************
*** 346,349 ****
--- 375,381 ----
  	SInt16 strtSel;
  	SInt16 endSel;
+ #ifndef SelectDialogItemText
+ 	PyMac_PRECHECK(SelectDialogItemText);
+ #endif
  	if (!PyArg_ParseTuple(_args, "hhh",
  	                      &itemNo,
***************
*** 365,368 ****
--- 397,403 ----
  	Handle theHandle;
  	DITLMethod method;
+ #ifndef AppendDITL
+ 	PyMac_PRECHECK(AppendDITL);
+ #endif
  	if (!PyArg_ParseTuple(_args, "O&h",
  	                      ResObj_Convert, &theHandle,
***************
*** 381,384 ****
--- 416,422 ----
  	PyObject *_res = NULL;
  	DialogItemIndex _rv;
+ #ifndef CountDITL
+ 	PyMac_PRECHECK(CountDITL);
+ #endif
  	if (!PyArg_ParseTuple(_args, ""))
  		return NULL;
***************
*** 393,396 ****
--- 431,437 ----
  	PyObject *_res = NULL;
  	DialogItemIndex numberItems;
+ #ifndef ShortenDITL
+ 	PyMac_PRECHECK(ShortenDITL);
+ #endif
  	if (!PyArg_ParseTuple(_args, "h",
  	                      &numberItems))
***************
*** 413,416 ****
--- 454,460 ----
  	Handle itemHandle;
  	Rect box;
+ #ifndef InsertDialogItem
+ 	PyMac_PRECHECK(InsertDialogItem);
+ #endif
  	if (!PyArg_ParseTuple(_args, "hhO&O&",
  	                      &afterItem,
***************
*** 440,443 ****
--- 484,490 ----
  	DialogItemIndex amountToRemove;
  	Boolean disposeItemData;
+ #ifndef RemoveDialogItems
+ 	PyMac_PRECHECK(RemoveDialogItems);
+ #endif
  	if (!PyArg_ParseTuple(_args, "hhb",
  	                      &itemNo,
***************
*** 462,465 ****
--- 509,515 ----
  	EventRecord event;
  	DialogItemIndex itemHit;
+ #ifndef StdFilterProc
+ 	PyMac_PRECHECK(StdFilterProc);
+ #endif
  	if (!PyArg_ParseTuple(_args, ""))
  		return NULL;
***************
*** 479,482 ****
--- 529,535 ----
  	OSErr _err;
  	DialogItemIndex newItem;
+ #ifndef SetDialogDefaultItem
+ 	PyMac_PRECHECK(SetDialogDefaultItem);
+ #endif
  	if (!PyArg_ParseTuple(_args, "h",
  	                      &newItem))
***************
*** 495,498 ****
--- 548,554 ----
  	OSErr _err;
  	DialogItemIndex newItem;
+ #ifndef SetDialogCancelItem
+ 	PyMac_PRECHECK(SetDialogCancelItem);
+ #endif
  	if (!PyArg_ParseTuple(_args, "h",
  	                      &newItem))
***************
*** 511,514 ****
--- 567,573 ----
  	OSErr _err;
  	Boolean tracks;
+ #ifndef SetDialogTracksCursor
+ 	PyMac_PRECHECK(SetDialogTracksCursor);
+ #endif
  	if (!PyArg_ParseTuple(_args, "b",
  	                      &tracks))
***************
*** 526,529 ****
--- 585,591 ----
  	PyObject *_res = NULL;
  	OSErr _err;
+ #ifndef AutoSizeDialog
+ 	PyMac_PRECHECK(AutoSizeDialog);
+ #endif
  	if (!PyArg_ParseTuple(_args, ""))
  		return NULL;
***************
*** 541,544 ****
--- 603,609 ----
  	SInt16 inItemNo;
  	ControlHandle outControl;
+ #ifndef GetDialogItemAsControl
+ 	PyMac_PRECHECK(GetDialogItemAsControl);
+ #endif
  	if (!PyArg_ParseTuple(_args, "h",
  	                      &inItemNo))
***************
*** 560,563 ****
--- 625,631 ----
  	SInt16 inHoriz;
  	SInt16 inVert;
+ #ifndef MoveDialogItem
+ 	PyMac_PRECHECK(MoveDialogItem);
+ #endif
  	if (!PyArg_ParseTuple(_args, "hhh",
  	                      &inItemNo,
***************
*** 582,585 ****
--- 650,656 ----
  	SInt16 inWidth;
  	SInt16 inHeight;
+ #ifndef SizeDialogItem
+ 	PyMac_PRECHECK(SizeDialogItem);
+ #endif
  	if (!PyArg_ParseTuple(_args, "hhh",
  	                      &inItemNo,
***************
*** 603,606 ****
--- 674,680 ----
  	SInt16 ditlID;
  	DITLMethod method;
+ #ifndef AppendDialogItemList
+ 	PyMac_PRECHECK(AppendDialogItemList);
+ #endif
  	if (!PyArg_ParseTuple(_args, "hh",
  	                      &ditlID,
***************
*** 622,625 ****
--- 696,702 ----
  	SInt16 inButtonToPress;
  	UInt32 inSecondsToWait;
+ #ifndef SetDialogTimeout
+ 	PyMac_PRECHECK(SetDialogTimeout);
+ #endif
  	if (!PyArg_ParseTuple(_args, "hl",
  	                      &inButtonToPress,
***************
*** 642,645 ****
--- 719,725 ----
  	UInt32 outSecondsToWait;
  	UInt32 outSecondsRemaining;
+ #ifndef GetDialogTimeout
+ 	PyMac_PRECHECK(GetDialogTimeout);
+ #endif
  	if (!PyArg_ParseTuple(_args, ""))
  		return NULL;
***************
*** 661,664 ****
--- 741,747 ----
  	OSStatus _err;
  	EventMask inMask;
+ #ifndef SetModalDialogEventMask
+ 	PyMac_PRECHECK(SetModalDialogEventMask);
+ #endif
  	if (!PyArg_ParseTuple(_args, "H",
  	                      &inMask))
***************
*** 677,680 ****
--- 760,766 ----
  	OSStatus _err;
  	EventMask outMask;
+ #ifndef GetModalDialogEventMask
+ 	PyMac_PRECHECK(GetModalDialogEventMask);
+ #endif
  	if (!PyArg_ParseTuple(_args, ""))
  		return NULL;
***************
*** 691,694 ****
--- 777,783 ----
  	PyObject *_res = NULL;
  	WindowPtr _rv;
+ #ifndef GetDialogWindow
+ 	PyMac_PRECHECK(GetDialogWindow);
+ #endif
  	if (!PyArg_ParseTuple(_args, ""))
  		return NULL;
***************
*** 703,706 ****
--- 792,798 ----
  	PyObject *_res = NULL;
  	TEHandle _rv;
+ #ifndef GetDialogTextEditHandle
+ 	PyMac_PRECHECK(GetDialogTextEditHandle);
+ #endif
  	if (!PyArg_ParseTuple(_args, ""))
  		return NULL;
***************
*** 715,718 ****
--- 807,813 ----
  	PyObject *_res = NULL;
  	SInt16 _rv;
+ #ifndef GetDialogDefaultItem
+ 	PyMac_PRECHECK(GetDialogDefaultItem);
+ #endif
  	if (!PyArg_ParseTuple(_args, ""))
  		return NULL;
***************
*** 727,730 ****
--- 822,828 ----
  	PyObject *_res = NULL;
  	SInt16 _rv;
+ #ifndef GetDialogCancelItem
+ 	PyMac_PRECHECK(GetDialogCancelItem);
+ #endif
  	if (!PyArg_ParseTuple(_args, ""))
  		return NULL;
***************
*** 739,742 ****
--- 837,843 ----
  	PyObject *_res = NULL;
  	SInt16 _rv;
+ #ifndef GetDialogKeyboardFocusItem
+ 	PyMac_PRECHECK(GetDialogKeyboardFocusItem);
+ #endif
  	if (!PyArg_ParseTuple(_args, ""))
  		return NULL;
***************
*** 750,753 ****
--- 851,857 ----
  {
  	PyObject *_res = NULL;
+ #ifndef SetPortDialogPort
+ 	PyMac_PRECHECK(SetPortDialogPort);
+ #endif
  	if (!PyArg_ParseTuple(_args, ""))
  		return NULL;
***************
*** 762,765 ****
--- 866,872 ----
  	PyObject *_res = NULL;
  	CGrafPtr _rv;
+ #ifndef GetDialogPort
+ 	PyMac_PRECHECK(GetDialogPort);
+ #endif
  	if (!PyArg_ParseTuple(_args, ""))
  		return NULL;
***************
*** 770,773 ****
--- 877,897 ----
  }
  
+ #if !TARGET_API_MAC_CARBON
+ 
+ static PyObject *DlgObj_SetGrafPortOfDialog(DialogObject *_self, PyObject *_args)
+ {
+ 	PyObject *_res = NULL;
+ #ifndef SetGrafPortOfDialog
+ 	PyMac_PRECHECK(SetGrafPortOfDialog);
+ #endif
+ 	if (!PyArg_ParseTuple(_args, ""))
+ 		return NULL;
+ 	SetGrafPortOfDialog(_self->ob_itself);
+ 	Py_INCREF(Py_None);
+ 	_res = Py_None;
+ 	return _res;
+ }
+ #endif
+ 
  static PyMethodDef DlgObj_methods[] = {
  	{"DrawDialog", (PyCFunction)DlgObj_DrawDialog, 1,
***************
*** 852,855 ****
--- 976,983 ----
  	 "() -> (CGrafPtr _rv)"},
  
+ #if !TARGET_API_MAC_CARBON
+ 	{"SetGrafPortOfDialog", (PyCFunction)DlgObj_SetGrafPortOfDialog, 1,
+ 	 "() -> None"},
+ #endif
  	{NULL, NULL, 0}
  };
***************
*** 879,883 ****
  
  PyTypeObject Dialog_Type = {
! 	PyObject_HEAD_INIT(&PyType_Type)
  	0, /*ob_size*/
  	"Dialog", /*tp_name*/
--- 1007,1011 ----
  
  PyTypeObject Dialog_Type = {
! 	PyObject_HEAD_INIT(NULL)
  	0, /*ob_size*/
  	"Dialog", /*tp_name*/
***************
*** 912,915 ****
--- 1040,1046 ----
  	SInt32 refCon;
  	Handle items;
+ #ifndef NewDialog
+ 	PyMac_PRECHECK(NewDialog);
+ #endif
  	if (!PyArg_ParseTuple(_args, "O&O&bhO&blO&",
  	                      PyMac_GetRect, &boundsRect,
***************
*** 942,945 ****
--- 1073,1079 ----
  	SInt16 dialogID;
  	WindowPtr behind;
+ #ifndef GetNewDialog
+ 	PyMac_PRECHECK(GetNewDialog);
+ #endif
  	if (!PyArg_ParseTuple(_args, "hO&",
  	                      &dialogID,
***************
*** 966,969 ****
--- 1100,1106 ----
  	SInt32 refCon;
  	Handle items;
+ #ifndef NewColorDialog
+ 	PyMac_PRECHECK(NewColorDialog);
+ #endif
  	if (!PyArg_ParseTuple(_args, "O&O&bhO&blO&",
  	                      PyMac_GetRect, &boundsRect,
***************
*** 995,998 ****
--- 1132,1138 ----
  	PyObject* modalFilter;
  	DialogItemIndex itemHit;
+ #ifndef ModalDialog
+ 	PyMac_PRECHECK(ModalDialog);
+ #endif
  	if (!PyArg_ParseTuple(_args, "O",
  	                      &modalFilter))
***************
*** 1010,1013 ****
--- 1150,1156 ----
  	Boolean _rv;
  	EventRecord theEvent;
+ #ifndef IsDialogEvent
+ 	PyMac_PRECHECK(IsDialogEvent);
+ #endif
  	if (!PyArg_ParseTuple(_args, "O&",
  	                      PyMac_GetEventRecord, &theEvent))
***************
*** 1026,1029 ****
--- 1169,1175 ----
  	DialogPtr theDialog;
  	DialogItemIndex itemHit;
+ #ifndef DialogSelect
+ 	PyMac_PRECHECK(DialogSelect);
+ #endif
  	if (!PyArg_ParseTuple(_args, "O&",
  	                      PyMac_GetEventRecord, &theEvent))
***************
*** 1045,1048 ****
--- 1191,1197 ----
  	SInt16 alertID;
  	PyObject* modalFilter;
+ #ifndef Alert
+ 	PyMac_PRECHECK(Alert);
+ #endif
  	if (!PyArg_ParseTuple(_args, "hO",
  	                      &alertID,
***************
*** 1062,1065 ****
--- 1211,1217 ----
  	SInt16 alertID;
  	PyObject* modalFilter;
+ #ifndef StopAlert
+ 	PyMac_PRECHECK(StopAlert);
+ #endif
  	if (!PyArg_ParseTuple(_args, "hO",
  	                      &alertID,
***************
*** 1079,1082 ****
--- 1231,1237 ----
  	SInt16 alertID;
  	PyObject* modalFilter;
+ #ifndef NoteAlert
+ 	PyMac_PRECHECK(NoteAlert);
+ #endif
  	if (!PyArg_ParseTuple(_args, "hO",
  	                      &alertID,
***************
*** 1096,1099 ****
--- 1251,1257 ----
  	SInt16 alertID;
  	PyObject* modalFilter;
+ #ifndef CautionAlert
+ 	PyMac_PRECHECK(CautionAlert);
+ #endif
  	if (!PyArg_ParseTuple(_args, "hO",
  	                      &alertID,
***************
*** 1114,1117 ****
--- 1272,1278 ----
  	Str255 param2;
  	Str255 param3;
+ #ifndef ParamText
+ 	PyMac_PRECHECK(ParamText);
+ #endif
  	if (!PyArg_ParseTuple(_args, "O&O&O&O&",
  	                      PyMac_GetStr255, param0,
***************
*** 1134,1137 ****
--- 1295,1301 ----
  	Handle item;
  	Str255 text;
+ #ifndef GetDialogItemText
+ 	PyMac_PRECHECK(GetDialogItemText);
+ #endif
  	if (!PyArg_ParseTuple(_args, "O&",
  	                      ResObj_Convert, &item))
***************
*** 1149,1152 ****
--- 1313,1319 ----
  	Handle item;
  	Str255 text;
+ #ifndef SetDialogItemText
+ 	PyMac_PRECHECK(SetDialogItemText);
+ #endif
  	if (!PyArg_ParseTuple(_args, "O&O&",
  	                      ResObj_Convert, &item,
***************
*** 1164,1167 ****
--- 1331,1337 ----
  	PyObject *_res = NULL;
  	SInt16 _rv;
+ #ifndef GetAlertStage
+ 	PyMac_PRECHECK(GetAlertStage);
+ #endif
  	if (!PyArg_ParseTuple(_args, ""))
  		return NULL;
***************
*** 1176,1179 ****
--- 1346,1352 ----
  	PyObject *_res = NULL;
  	SInt16 fontNum;
+ #ifndef SetDialogFont
+ 	PyMac_PRECHECK(SetDialogFont);
+ #endif
  	if (!PyArg_ParseTuple(_args, "h",
  	                      &fontNum))
***************
*** 1188,1191 ****
--- 1361,1367 ----
  {
  	PyObject *_res = NULL;
+ #ifndef ResetAlertStage
+ 	PyMac_PRECHECK(ResetAlertStage);
+ #endif
  	if (!PyArg_ParseTuple(_args, ""))
  		return NULL;
***************
*** 1205,1208 ****
--- 1381,1387 ----
  	Str255 param2;
  	Str255 param3;
+ #ifndef GetParamText
+ 	PyMac_PRECHECK(GetParamText);
+ #endif
  	if (!PyArg_ParseTuple(_args, "O&O&O&O&",
  	                      PyMac_GetStr255, param0,
***************
*** 1234,1237 ****
--- 1413,1419 ----
  	Handle inItemListHandle;
  	UInt32 inFlags;
+ #ifndef NewFeaturesDialog
+ 	PyMac_PRECHECK(NewFeaturesDialog);
+ #endif
  	if (!PyArg_ParseTuple(_args, "O&O&bhO&blO&l",
  	                      PyMac_GetRect, &inBoundsRect,
***************
*** 1265,1268 ****
--- 1447,1453 ----
  	DialogPtr _rv;
  	WindowPtr window;
+ #ifndef GetDialogFromWindow
+ 	PyMac_PRECHECK(GetDialogFromWindow);
+ #endif
  	if (!PyArg_ParseTuple(_args, "O&",
  	                      WinObj_Convert, &window))