From: Jack Jansen Date: Mon, 25 Mar 2002 10:56:59 +0000 (+0000) Subject: Backport of _Fmmodule.c 1.6 and fmsupport.py 1.6: X-Git-Tag: v2.2.1c2~44 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6f2fd304d5e821c02420563832d1ec8ce1992e2c;p=thirdparty%2FPython%2Fcpython.git Backport of _Fmmodule.c 1.6 and fmsupport.py 1.6: Weaklink most toolbox modules, improving backward compatibility. Modules will no longer fail to load if a single routine is missing on the curent OS version, in stead calling the missing routine will raise an exception. Should finally fix 531398. 2.2.1 candidate. Also blacklisted some constants with definitions that were not Python-compatible. --- diff --git a/Mac/Modules/fm/_Fmmodule.c b/Mac/Modules/fm/_Fmmodule.c index 009f34d2f92b..e6497f2c5425 100644 --- a/Mac/Modules/fm/_Fmmodule.c +++ b/Mac/Modules/fm/_Fmmodule.c @@ -64,6 +64,9 @@ static PyObject *Fm_Error; static PyObject *Fm_InitFonts(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; +#ifndef InitFonts + PyMac_PRECHECK(InitFonts); +#endif if (!PyArg_ParseTuple(_args, "")) return NULL; InitFonts(); @@ -78,6 +81,9 @@ static PyObject *Fm_GetFontName(PyObject *_self, PyObject *_args) PyObject *_res = NULL; short familyID; Str255 name; +#ifndef GetFontName + PyMac_PRECHECK(GetFontName); +#endif if (!PyArg_ParseTuple(_args, "h", &familyID)) return NULL; @@ -93,6 +99,9 @@ static PyObject *Fm_GetFNum(PyObject *_self, PyObject *_args) PyObject *_res = NULL; Str255 name; short familyID; +#ifndef GetFNum + PyMac_PRECHECK(GetFNum); +#endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetStr255, name)) return NULL; @@ -109,6 +118,9 @@ static PyObject *Fm_RealFont(PyObject *_self, PyObject *_args) Boolean _rv; short fontNum; short size; +#ifndef RealFont + PyMac_PRECHECK(RealFont); +#endif if (!PyArg_ParseTuple(_args, "hh", &fontNum, &size)) @@ -126,6 +138,9 @@ static PyObject *Fm_SetFontLock(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean lockFlag; +#ifndef SetFontLock + PyMac_PRECHECK(SetFontLock); +#endif if (!PyArg_ParseTuple(_args, "b", &lockFlag)) return NULL; @@ -140,6 +155,9 @@ static PyObject *Fm_SetFScaleDisable(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean fscaleDisable; +#ifndef SetFScaleDisable + PyMac_PRECHECK(SetFScaleDisable); +#endif if (!PyArg_ParseTuple(_args, "b", &fscaleDisable)) return NULL; @@ -153,6 +171,9 @@ static PyObject *Fm_FontMetrics(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; FMetricRec theMetrics; +#ifndef FontMetrics + PyMac_PRECHECK(FontMetrics); +#endif if (!PyArg_ParseTuple(_args, "")) return NULL; FontMetrics(&theMetrics); @@ -165,6 +186,9 @@ static PyObject *Fm_SetFractEnable(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean fractEnable; +#ifndef SetFractEnable + PyMac_PRECHECK(SetFractEnable); +#endif if (!PyArg_ParseTuple(_args, "b", &fractEnable)) return NULL; @@ -178,6 +202,9 @@ static PyObject *Fm_GetDefFontSize(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short _rv; +#ifndef GetDefFontSize + PyMac_PRECHECK(GetDefFontSize); +#endif if (!PyArg_ParseTuple(_args, "")) return NULL; _rv = GetDefFontSize(); @@ -192,6 +219,9 @@ static PyObject *Fm_IsOutline(PyObject *_self, PyObject *_args) Boolean _rv; Point numer; Point denom; +#ifndef IsOutline + PyMac_PRECHECK(IsOutline); +#endif if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetPoint, &numer, PyMac_GetPoint, &denom)) @@ -207,6 +237,9 @@ static PyObject *Fm_SetOutlinePreferred(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean outlinePreferred; +#ifndef SetOutlinePreferred + PyMac_PRECHECK(SetOutlinePreferred); +#endif if (!PyArg_ParseTuple(_args, "b", &outlinePreferred)) return NULL; @@ -220,6 +253,9 @@ static PyObject *Fm_GetOutlinePreferred(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; +#ifndef GetOutlinePreferred + PyMac_PRECHECK(GetOutlinePreferred); +#endif if (!PyArg_ParseTuple(_args, "")) return NULL; _rv = GetOutlinePreferred(); @@ -232,6 +268,9 @@ static PyObject *Fm_SetPreserveGlyph(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean preserveGlyph; +#ifndef SetPreserveGlyph + PyMac_PRECHECK(SetPreserveGlyph); +#endif if (!PyArg_ParseTuple(_args, "b", &preserveGlyph)) return NULL; @@ -245,6 +284,9 @@ static PyObject *Fm_GetPreserveGlyph(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Boolean _rv; +#ifndef GetPreserveGlyph + PyMac_PRECHECK(GetPreserveGlyph); +#endif if (!PyArg_ParseTuple(_args, "")) return NULL; _rv = GetPreserveGlyph(); @@ -259,6 +301,9 @@ static PyObject *Fm_FlushFonts(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; OSErr _err; +#ifndef FlushFonts + PyMac_PRECHECK(FlushFonts); +#endif if (!PyArg_ParseTuple(_args, "")) return NULL; _err = FlushFonts(); @@ -273,6 +318,9 @@ static PyObject *Fm_GetSysFont(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short _rv; +#ifndef GetSysFont + PyMac_PRECHECK(GetSysFont); +#endif if (!PyArg_ParseTuple(_args, "")) return NULL; _rv = GetSysFont(); @@ -285,6 +333,9 @@ static PyObject *Fm_GetAppFont(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; short _rv; +#ifndef GetAppFont + PyMac_PRECHECK(GetAppFont); +#endif if (!PyArg_ParseTuple(_args, "")) return NULL; _rv = GetAppFont(); @@ -300,6 +351,9 @@ static PyObject *Fm_QDTextBounds(PyObject *_self, PyObject *_args) int inText__len__; int inText__in_len__; Rect bounds; +#ifndef QDTextBounds + PyMac_PRECHECK(QDTextBounds); +#endif if (!PyArg_ParseTuple(_args, "s#", &inText__in__, &inText__in_len__)) return NULL; diff --git a/Mac/Modules/fm/fmsupport.py b/Mac/Modules/fm/fmsupport.py index 10d3fce801f5..20ae29235457 100644 --- a/Mac/Modules/fm/fmsupport.py +++ b/Mac/Modules/fm/fmsupport.py @@ -70,7 +70,7 @@ FMetricRecPtr = OpaqueType('FMetricRec', 'FMRec') module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff) # Create the generator classes used to populate the lists -Function = OSErrFunctionGenerator +Function = OSErrWeakLinkFunctionGenerator # Create and populate the lists functions = []