Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9d79990

Browse files
committed
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.
1 parent d69711c commit 9d79990

15 files changed

Lines changed: 3255 additions & 3 deletions

File tree

Mac/Modules/ae/_AEmodule.c

Lines changed: 138 additions & 0 deletions
Large diffs are not rendered by default.

Mac/Modules/app/_Appmodule.c

Lines changed: 201 additions & 0 deletions
Large diffs are not rendered by default.

Mac/Modules/app/appsupport.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ class MyObjectDefinition(GlobalObjectDefinition):
118118
module.addobject(object)
119119

120120
ThemeDrawingState = OpaqueByValueType("ThemeDrawingState", "ThemeDrawingStateObj")
121-
Method = MethodGenerator
121+
Method = WeakLinkMethodGenerator
122122

123123

124124
# Create the generator classes used to populate the lists
125-
Function = OSErrFunctionGenerator
126-
##Method = OSErrMethodGenerator
125+
Function = OSErrWeakLinkFunctionGenerator
126+
##Method = OSErrWeakLinkMethodGenerator
127127

128128
# Create and populate the lists
129129
functions = []

Mac/Modules/cf/cfscan.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def makeblacklistnames(self):
9595
"CFStringCreateMutableWithExternalCharactersNoCopy", # Not a clue...
9696
"CFStringSetExternalCharactersNoCopy",
9797
"CFStringGetCharacterAtIndex", # No format for single unichars yet.
98+
"kCFStringEncodingInvalidId", # incompatible constant declaration
9899
]
99100

100101
def makegreylist(self):

Mac/Modules/cm/_Cmmodule.c

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ static PyObject *CmpInstObj_CloseComponent(ComponentInstanceObject *_self, PyObj
109109
{
110110
PyObject *_res = NULL;
111111
OSErr _err;
112+
#ifndef CloseComponent
113+
PyMac_PRECHECK(CloseComponent);
114+
#endif
112115
if (!PyArg_ParseTuple(_args, ""))
113116
return NULL;
114117
_err = CloseComponent(_self->ob_itself);
@@ -122,6 +125,9 @@ static PyObject *CmpInstObj_GetComponentInstanceError(ComponentInstanceObject *_
122125
{
123126
PyObject *_res = NULL;
124127
OSErr _err;
128+
#ifndef GetComponentInstanceError
129+
PyMac_PRECHECK(GetComponentInstanceError);
130+
#endif
125131
if (!PyArg_ParseTuple(_args, ""))
126132
return NULL;
127133
_err = GetComponentInstanceError(_self->ob_itself);
@@ -135,6 +141,9 @@ static PyObject *CmpInstObj_SetComponentInstanceError(ComponentInstanceObject *_
135141
{
136142
PyObject *_res = NULL;
137143
OSErr theError;
144+
#ifndef SetComponentInstanceError
145+
PyMac_PRECHECK(SetComponentInstanceError);
146+
#endif
138147
if (!PyArg_ParseTuple(_args, "h",
139148
&theError))
140149
return NULL;
@@ -149,6 +158,9 @@ static PyObject *CmpInstObj_GetComponentInstanceStorage(ComponentInstanceObject
149158
{
150159
PyObject *_res = NULL;
151160
Handle _rv;
161+
#ifndef GetComponentInstanceStorage
162+
PyMac_PRECHECK(GetComponentInstanceStorage);
163+
#endif
152164
if (!PyArg_ParseTuple(_args, ""))
153165
return NULL;
154166
_rv = GetComponentInstanceStorage(_self->ob_itself);
@@ -161,6 +173,9 @@ static PyObject *CmpInstObj_SetComponentInstanceStorage(ComponentInstanceObject
161173
{
162174
PyObject *_res = NULL;
163175
Handle theStorage;
176+
#ifndef SetComponentInstanceStorage
177+
PyMac_PRECHECK(SetComponentInstanceStorage);
178+
#endif
164179
if (!PyArg_ParseTuple(_args, "O&",
165180
ResObj_Convert, &theStorage))
166181
return NULL;
@@ -177,6 +192,9 @@ static PyObject *CmpInstObj_GetComponentInstanceA5(ComponentInstanceObject *_sel
177192
{
178193
PyObject *_res = NULL;
179194
long _rv;
195+
#ifndef GetComponentInstanceA5
196+
PyMac_PRECHECK(GetComponentInstanceA5);
197+
#endif
180198
if (!PyArg_ParseTuple(_args, ""))
181199
return NULL;
182200
_rv = GetComponentInstanceA5(_self->ob_itself);
@@ -192,6 +210,9 @@ static PyObject *CmpInstObj_SetComponentInstanceA5(ComponentInstanceObject *_sel
192210
{
193211
PyObject *_res = NULL;
194212
long theA5;
213+
#ifndef SetComponentInstanceA5
214+
PyMac_PRECHECK(SetComponentInstanceA5);
215+
#endif
195216
if (!PyArg_ParseTuple(_args, "l",
196217
&theA5))
197218
return NULL;
@@ -208,6 +229,9 @@ static PyObject *CmpInstObj_ComponentFunctionImplemented(ComponentInstanceObject
208229
PyObject *_res = NULL;
209230
long _rv;
210231
short ftnNumber;
232+
#ifndef ComponentFunctionImplemented
233+
PyMac_PRECHECK(ComponentFunctionImplemented);
234+
#endif
211235
if (!PyArg_ParseTuple(_args, "h",
212236
&ftnNumber))
213237
return NULL;
@@ -222,6 +246,9 @@ static PyObject *CmpInstObj_GetComponentVersion(ComponentInstanceObject *_self,
222246
{
223247
PyObject *_res = NULL;
224248
long _rv;
249+
#ifndef GetComponentVersion
250+
PyMac_PRECHECK(GetComponentVersion);
251+
#endif
225252
if (!PyArg_ParseTuple(_args, ""))
226253
return NULL;
227254
_rv = GetComponentVersion(_self->ob_itself);
@@ -235,6 +262,9 @@ static PyObject *CmpInstObj_ComponentSetTarget(ComponentInstanceObject *_self, P
235262
PyObject *_res = NULL;
236263
long _rv;
237264
ComponentInstance target;
265+
#ifndef ComponentSetTarget
266+
PyMac_PRECHECK(ComponentSetTarget);
267+
#endif
238268
if (!PyArg_ParseTuple(_args, "O&",
239269
CmpInstObj_Convert, &target))
240270
return NULL;
@@ -361,6 +391,9 @@ static PyObject *CmpObj_UnregisterComponent(ComponentObject *_self, PyObject *_a
361391
{
362392
PyObject *_res = NULL;
363393
OSErr _err;
394+
#ifndef UnregisterComponent
395+
PyMac_PRECHECK(UnregisterComponent);
396+
#endif
364397
if (!PyArg_ParseTuple(_args, ""))
365398
return NULL;
366399
_err = UnregisterComponent(_self->ob_itself);
@@ -378,6 +411,9 @@ static PyObject *CmpObj_GetComponentInfo(ComponentObject *_self, PyObject *_args
378411
Handle componentName;
379412
Handle componentInfo;
380413
Handle componentIcon;
414+
#ifndef GetComponentInfo
415+
PyMac_PRECHECK(GetComponentInfo);
416+
#endif
381417
if (!PyArg_ParseTuple(_args, "O&O&O&",
382418
ResObj_Convert, &componentName,
383419
ResObj_Convert, &componentInfo,
@@ -398,6 +434,9 @@ static PyObject *CmpObj_OpenComponent(ComponentObject *_self, PyObject *_args)
398434
{
399435
PyObject *_res = NULL;
400436
ComponentInstance _rv;
437+
#ifndef OpenComponent
438+
PyMac_PRECHECK(OpenComponent);
439+
#endif
401440
if (!PyArg_ParseTuple(_args, ""))
402441
return NULL;
403442
_rv = OpenComponent(_self->ob_itself);
@@ -410,6 +449,9 @@ static PyObject *CmpObj_ResolveComponentAlias(ComponentObject *_self, PyObject *
410449
{
411450
PyObject *_res = NULL;
412451
Component _rv;
452+
#ifndef ResolveComponentAlias
453+
PyMac_PRECHECK(ResolveComponentAlias);
454+
#endif
413455
if (!PyArg_ParseTuple(_args, ""))
414456
return NULL;
415457
_rv = ResolveComponentAlias(_self->ob_itself);
@@ -425,6 +467,9 @@ static PyObject *CmpObj_GetComponentPublicIndString(ComponentObject *_self, PyOb
425467
Str255 theString;
426468
short strListID;
427469
short index;
470+
#ifndef GetComponentPublicIndString
471+
PyMac_PRECHECK(GetComponentPublicIndString);
472+
#endif
428473
if (!PyArg_ParseTuple(_args, "O&hh",
429474
PyMac_GetStr255, theString,
430475
&strListID,
@@ -444,6 +489,9 @@ static PyObject *CmpObj_GetComponentRefcon(ComponentObject *_self, PyObject *_ar
444489
{
445490
PyObject *_res = NULL;
446491
long _rv;
492+
#ifndef GetComponentRefcon
493+
PyMac_PRECHECK(GetComponentRefcon);
494+
#endif
447495
if (!PyArg_ParseTuple(_args, ""))
448496
return NULL;
449497
_rv = GetComponentRefcon(_self->ob_itself);
@@ -456,6 +504,9 @@ static PyObject *CmpObj_SetComponentRefcon(ComponentObject *_self, PyObject *_ar
456504
{
457505
PyObject *_res = NULL;
458506
long theRefcon;
507+
#ifndef SetComponentRefcon
508+
PyMac_PRECHECK(SetComponentRefcon);
509+
#endif
459510
if (!PyArg_ParseTuple(_args, "l",
460511
&theRefcon))
461512
return NULL;
@@ -470,6 +521,9 @@ static PyObject *CmpObj_OpenComponentResFile(ComponentObject *_self, PyObject *_
470521
{
471522
PyObject *_res = NULL;
472523
short _rv;
524+
#ifndef OpenComponentResFile
525+
PyMac_PRECHECK(OpenComponentResFile);
526+
#endif
473527
if (!PyArg_ParseTuple(_args, ""))
474528
return NULL;
475529
_rv = OpenComponentResFile(_self->ob_itself);
@@ -485,6 +539,9 @@ static PyObject *CmpObj_GetComponentResource(ComponentObject *_self, PyObject *_
485539
OSType resType;
486540
short resID;
487541
Handle theResource;
542+
#ifndef GetComponentResource
543+
PyMac_PRECHECK(GetComponentResource);
544+
#endif
488545
if (!PyArg_ParseTuple(_args, "O&h",
489546
PyMac_GetOSType, &resType,
490547
&resID))
@@ -506,6 +563,9 @@ static PyObject *CmpObj_GetComponentIndString(ComponentObject *_self, PyObject *
506563
Str255 theString;
507564
short strListID;
508565
short index;
566+
#ifndef GetComponentIndString
567+
PyMac_PRECHECK(GetComponentIndString);
568+
#endif
509569
if (!PyArg_ParseTuple(_args, "O&hh",
510570
PyMac_GetStr255, theString,
511571
&strListID,
@@ -525,6 +585,9 @@ static PyObject *CmpObj_CountComponentInstances(ComponentObject *_self, PyObject
525585
{
526586
PyObject *_res = NULL;
527587
long _rv;
588+
#ifndef CountComponentInstances
589+
PyMac_PRECHECK(CountComponentInstances);
590+
#endif
528591
if (!PyArg_ParseTuple(_args, ""))
529592
return NULL;
530593
_rv = CountComponentInstances(_self->ob_itself);
@@ -538,6 +601,9 @@ static PyObject *CmpObj_SetDefaultComponent(ComponentObject *_self, PyObject *_a
538601
PyObject *_res = NULL;
539602
OSErr _err;
540603
short flags;
604+
#ifndef SetDefaultComponent
605+
PyMac_PRECHECK(SetDefaultComponent);
606+
#endif
541607
if (!PyArg_ParseTuple(_args, "h",
542608
&flags))
543609
return NULL;
@@ -554,6 +620,9 @@ static PyObject *CmpObj_CaptureComponent(ComponentObject *_self, PyObject *_args
554620
PyObject *_res = NULL;
555621
Component _rv;
556622
Component capturingComponent;
623+
#ifndef CaptureComponent
624+
PyMac_PRECHECK(CaptureComponent);
625+
#endif
557626
if (!PyArg_ParseTuple(_args, "O&",
558627
CmpObj_Convert, &capturingComponent))
559628
return NULL;
@@ -568,6 +637,9 @@ static PyObject *CmpObj_UncaptureComponent(ComponentObject *_self, PyObject *_ar
568637
{
569638
PyObject *_res = NULL;
570639
OSErr _err;
640+
#ifndef UncaptureComponent
641+
PyMac_PRECHECK(UncaptureComponent);
642+
#endif
571643
if (!PyArg_ParseTuple(_args, ""))
572644
return NULL;
573645
_err = UncaptureComponent(_self->ob_itself);
@@ -582,6 +654,9 @@ static PyObject *CmpObj_GetComponentIconSuite(ComponentObject *_self, PyObject *
582654
PyObject *_res = NULL;
583655
OSErr _err;
584656
Handle iconSuite;
657+
#ifndef GetComponentIconSuite
658+
PyMac_PRECHECK(GetComponentIconSuite);
659+
#endif
585660
if (!PyArg_ParseTuple(_args, ""))
586661
return NULL;
587662
_err = GetComponentIconSuite(_self->ob_itself,
@@ -669,6 +744,9 @@ static PyObject *Cm_RegisterComponentResource(PyObject *_self, PyObject *_args)
669744
Component _rv;
670745
ComponentResourceHandle cr;
671746
short global;
747+
#ifndef RegisterComponentResource
748+
PyMac_PRECHECK(RegisterComponentResource);
749+
#endif
672750
if (!PyArg_ParseTuple(_args, "O&h",
673751
ResObj_Convert, &cr,
674752
&global))
@@ -686,6 +764,9 @@ static PyObject *Cm_FindNextComponent(PyObject *_self, PyObject *_args)
686764
Component _rv;
687765
Component aComponent;
688766
ComponentDescription looking;
767+
#ifndef FindNextComponent
768+
PyMac_PRECHECK(FindNextComponent);
769+
#endif
689770
if (!PyArg_ParseTuple(_args, "O&O&",
690771
CmpObj_Convert, &aComponent,
691772
CmpDesc_Convert, &looking))
@@ -702,6 +783,9 @@ static PyObject *Cm_CountComponents(PyObject *_self, PyObject *_args)
702783
PyObject *_res = NULL;
703784
long _rv;
704785
ComponentDescription looking;
786+
#ifndef CountComponents
787+
PyMac_PRECHECK(CountComponents);
788+
#endif
705789
if (!PyArg_ParseTuple(_args, "O&",
706790
CmpDesc_Convert, &looking))
707791
return NULL;
@@ -715,6 +799,9 @@ static PyObject *Cm_GetComponentListModSeed(PyObject *_self, PyObject *_args)
715799
{
716800
PyObject *_res = NULL;
717801
long _rv;
802+
#ifndef GetComponentListModSeed
803+
PyMac_PRECHECK(GetComponentListModSeed);
804+
#endif
718805
if (!PyArg_ParseTuple(_args, ""))
719806
return NULL;
720807
_rv = GetComponentListModSeed();
@@ -728,6 +815,9 @@ static PyObject *Cm_CloseComponentResFile(PyObject *_self, PyObject *_args)
728815
PyObject *_res = NULL;
729816
OSErr _err;
730817
short refnum;
818+
#ifndef CloseComponentResFile
819+
PyMac_PRECHECK(CloseComponentResFile);
820+
#endif
731821
if (!PyArg_ParseTuple(_args, "h",
732822
&refnum))
733823
return NULL;
@@ -744,6 +834,9 @@ static PyObject *Cm_OpenDefaultComponent(PyObject *_self, PyObject *_args)
744834
ComponentInstance _rv;
745835
OSType componentType;
746836
OSType componentSubType;
837+
#ifndef OpenDefaultComponent
838+
PyMac_PRECHECK(OpenDefaultComponent);
839+
#endif
747840
if (!PyArg_ParseTuple(_args, "O&O&",
748841
PyMac_GetOSType, &componentType,
749842
PyMac_GetOSType, &componentSubType))
@@ -761,6 +854,9 @@ static PyObject *Cm_RegisterComponentResourceFile(PyObject *_self, PyObject *_ar
761854
long _rv;
762855
short resRefNum;
763856
short global;
857+
#ifndef RegisterComponentResourceFile
858+
PyMac_PRECHECK(RegisterComponentResourceFile);
859+
#endif
764860
if (!PyArg_ParseTuple(_args, "hh",
765861
&resRefNum,
766862
&global))

0 commit comments

Comments
 (0)