Converted the Carbon modules to use PEP252-style objects, with

descriptors in stead of manual getattr hooks to get at attributes
of the objects.

For Qd I have in stead gotten rid of most of the attribute access
in favor of the carbon-style accessor methods (with the exception
of visRgn, to be done later), and of the Carbon.Qd.qd global object,
for which accessor functions are also available.

For List I have fixed the fact that various methods were incorrectly
generated as functions.

CF is untouched: PEP252 doesn't allow "poor-mans-inheritance" with
basechain, so it will have to wait for PEP253 support.
This commit is contained in:
Jack Jansen 2002-11-29 23:40:48 +00:00
parent 818855939a
commit dbd5701d73
48 changed files with 2447 additions and 2507 deletions

View File

@ -20,6 +20,9 @@
}} while(0)
#ifndef PyDoc_STR
#define PyDoc_STR(x) (x)
#endif
#ifdef WITHOUT_FRAMEWORKS
#include <AppleEvents.h>
#include <AEObjects.h>
@ -35,7 +38,13 @@ extern int _AEDesc_Convert(PyObject *, AEDesc *);
#define AEDesc_Convert _AEDesc_Convert
#endif
static pascal OSErr GenericEventHandler(); /* Forward */
#if UNIVERSAL_INTERFACES_VERSION >= 0x0340
typedef long refcontype;
#else
typedef unsigned long refcontype;
#endif
static pascal OSErr GenericEventHandler(const AppleEvent *request, AppleEvent *reply, refcontype refcon); /* Forward */
AEEventHandlerUPP upp_GenericEventHandler;
@ -820,46 +829,40 @@ static PyMethodDef AEDesc_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain AEDesc_chain = { AEDesc_methods, NULL };
static PyObject *AEDesc_getattr(AEDescObject *self, char *name)
static PyObject *AEDesc_get_type(AEDescObject *self, void *closure)
{
if (strcmp(name, "type") == 0)
return PyMac_BuildOSType(self->ob_itself.descriptorType);
if (strcmp(name, "data") == 0) {
PyObject *res;
#if !TARGET_API_MAC_CARBON
char state;
state = HGetState(self->ob_itself.dataHandle);
HLock(self->ob_itself.dataHandle);
res = PyString_FromStringAndSize(
*self->ob_itself.dataHandle,
GetHandleSize(self->ob_itself.dataHandle));
HUnlock(self->ob_itself.dataHandle);
HSetState(self->ob_itself.dataHandle, state);
#else
Size size;
char *ptr;
OSErr err;
size = AEGetDescDataSize(&self->ob_itself);
if ( (res = PyString_FromStringAndSize(NULL, size)) == NULL )
return NULL;
if ( (ptr = PyString_AsString(res)) == NULL )
return NULL;
if ( (err=AEGetDescData(&self->ob_itself, ptr, size)) < 0 )
return PyMac_Error(err);
#endif
return res;
}
if (strcmp(name, "__members__") == 0)
return Py_BuildValue("[ss]", "data", "type");
return Py_FindMethodInChain(&AEDesc_chain, (PyObject *)self, name);
return PyMac_BuildOSType(self->ob_itself.descriptorType);
}
#define AEDesc_setattr NULL
#define AEDesc_set_type NULL
static PyObject *AEDesc_get_data(AEDescObject *self, void *closure)
{
PyObject *res;
Size size;
char *ptr;
OSErr err;
size = AEGetDescDataSize(&self->ob_itself);
if ( (res = PyString_FromStringAndSize(NULL, size)) == NULL )
return NULL;
if ( (ptr = PyString_AsString(res)) == NULL )
return NULL;
if ( (err=AEGetDescData(&self->ob_itself, ptr, size)) < 0 )
return PyMac_Error(err);
return res;
}
#define AEDesc_set_data NULL
static PyGetSetDef AEDesc_getsetlist[] = {
{"type", (getter)AEDesc_get_type, (setter)AEDesc_set_type, "Type of this AEDesc"},
{"data", (getter)AEDesc_get_data, (setter)AEDesc_set_data, "The raw data in this AEDesc"},
{NULL, NULL, NULL, NULL},
};
#define AEDesc_compare NULL
@ -876,14 +879,31 @@ PyTypeObject AEDesc_Type = {
/* methods */
(destructor) AEDesc_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) AEDesc_getattr, /*tp_getattr*/
(setattrfunc) AEDesc_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) AEDesc_compare, /*tp_compare*/
(reprfunc) AEDesc_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) AEDesc_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
AEDesc_methods, /* tp_methods */
0, /*outputHook_tp_members*/
AEDesc_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* --------------------- End object type AEDesc --------------------- */
@ -1350,12 +1370,6 @@ static PyMethodDef AE_methods[] = {
#if UNIVERSAL_INTERFACES_VERSION >= 0x0340
typedef long refcontype;
#else
typedef unsigned long refcontype;
#endif
static pascal OSErr
GenericEventHandler(const AppleEvent *request, AppleEvent *reply, refcontype refcon)
{

View File

@ -82,6 +82,9 @@ AEMethod = OSErrWeakLinkMethodGenerator
includestuff = includestuff + """
#ifndef PyDoc_STR
#define PyDoc_STR(x) (x)
#endif
#ifdef WITHOUT_FRAMEWORKS
#include <AppleEvents.h>
#include <AEObjects.h>
@ -97,7 +100,13 @@ extern int _AEDesc_Convert(PyObject *, AEDesc *);
#define AEDesc_Convert _AEDesc_Convert
#endif
static pascal OSErr GenericEventHandler(); /* Forward */
#if UNIVERSAL_INTERFACES_VERSION >= 0x0340
typedef long refcontype;
#else
typedef unsigned long refcontype;
#endif
static pascal OSErr GenericEventHandler(const AppleEvent *request, AppleEvent *reply, refcontype refcon); /* Forward */
AEEventHandlerUPP upp_GenericEventHandler;
@ -118,12 +127,6 @@ AEIdleUPP upp_AEIdleProc;
"""
finalstuff = finalstuff + """
#if UNIVERSAL_INTERFACES_VERSION >= 0x0340
typedef long refcontype;
#else
typedef unsigned long refcontype;
#endif
static pascal OSErr
GenericEventHandler(const AppleEvent *request, AppleEvent *reply, refcontype refcon)
{
@ -171,7 +174,32 @@ initstuff = initstuff + """
module = MacModule('_AE', 'AE', includestuff, finalstuff, initstuff)
class AEDescDefinition(GlobalObjectDefinition):
class AEDescDefinition(PEP252Mixin, GlobalObjectDefinition):
getsetlist = [(
'type',
'return PyMac_BuildOSType(self->ob_itself.descriptorType);',
None,
'Type of this AEDesc'
), (
'data',
"""
PyObject *res;
Size size;
char *ptr;
OSErr err;
size = AEGetDescDataSize(&self->ob_itself);
if ( (res = PyString_FromStringAndSize(NULL, size)) == NULL )
return NULL;
if ( (ptr = PyString_AsString(res)) == NULL )
return NULL;
if ( (err=AEGetDescData(&self->ob_itself, ptr, size)) < 0 )
return PyMac_Error(err);
return res;
""",
None,
'The raw data in this AEDesc'
)]
def __init__(self, name, prefix = None, itselftype = None):
GlobalObjectDefinition.__init__(self, name, prefix or name, itselftype or name)
@ -180,41 +208,6 @@ class AEDescDefinition(GlobalObjectDefinition):
def outputFreeIt(self, name):
Output("AEDisposeDesc(&%s);", name)
def outputGetattrHook(self):
Output("""
if (strcmp(name, "type") == 0)
return PyMac_BuildOSType(self->ob_itself.descriptorType);
if (strcmp(name, "data") == 0) {
PyObject *res;
#if !TARGET_API_MAC_CARBON
char state;
state = HGetState(self->ob_itself.dataHandle);
HLock(self->ob_itself.dataHandle);
res = PyString_FromStringAndSize(
*self->ob_itself.dataHandle,
GetHandleSize(self->ob_itself.dataHandle));
HUnlock(self->ob_itself.dataHandle);
HSetState(self->ob_itself.dataHandle, state);
#else
Size size;
char *ptr;
OSErr err;
size = AEGetDescDataSize(&self->ob_itself);
if ( (res = PyString_FromStringAndSize(NULL, size)) == NULL )
return NULL;
if ( (ptr = PyString_AsString(res)) == NULL )
return NULL;
if ( (err=AEGetDescData(&self->ob_itself, ptr, size)) < 0 )
return PyMac_Error(err);
#endif
return res;
}
if (strcmp(name, "__members__") == 0)
return Py_BuildValue("[ss]", "data", "type");
""")
aedescobject = AEDescDefinition('AEDesc')
module.addobject(aedescobject)

View File

@ -95,14 +95,7 @@ static PyMethodDef AliasObj_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain AliasObj_chain = { AliasObj_methods, NULL };
static PyObject *AliasObj_getattr(AliasObject *self, char *name)
{
return Py_FindMethodInChain(&AliasObj_chain, (PyObject *)self, name);
}
#define AliasObj_setattr NULL
#define AliasObj_getsetlist NULL
#define AliasObj_compare NULL
@ -119,14 +112,31 @@ PyTypeObject Alias_Type = {
/* methods */
(destructor) AliasObj_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) AliasObj_getattr, /*tp_getattr*/
(setattrfunc) AliasObj_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) AliasObj_compare, /*tp_compare*/
(reprfunc) AliasObj_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) AliasObj_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
AliasObj_methods, /* tp_methods */
0, /*outputHook_tp_members*/
AliasObj_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* --------------------- End object type Alias ---------------------- */

View File

@ -72,7 +72,7 @@ execfile(string.lower(MODPREFIX) + 'typetest.py')
# Create the generator groups and link them
module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
class AliasDefinition(GlobalObjectDefinition):
class AliasDefinition(PEP252Mixin, GlobalObjectDefinition):
def outputCheckNewArg(self):
Output("if (itself == NULL) return PyMac_Error(resNotFound);")

View File

@ -113,14 +113,7 @@ static PyMethodDef ThemeDrawingStateObj_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain ThemeDrawingStateObj_chain = { ThemeDrawingStateObj_methods, NULL };
static PyObject *ThemeDrawingStateObj_getattr(ThemeDrawingStateObject *self, char *name)
{
return Py_FindMethodInChain(&ThemeDrawingStateObj_chain, (PyObject *)self, name);
}
#define ThemeDrawingStateObj_setattr NULL
#define ThemeDrawingStateObj_getsetlist NULL
#define ThemeDrawingStateObj_compare NULL
@ -137,14 +130,31 @@ PyTypeObject ThemeDrawingState_Type = {
/* methods */
(destructor) ThemeDrawingStateObj_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) ThemeDrawingStateObj_getattr, /*tp_getattr*/
(setattrfunc) ThemeDrawingStateObj_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) ThemeDrawingStateObj_compare, /*tp_compare*/
(reprfunc) ThemeDrawingStateObj_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) ThemeDrawingStateObj_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
ThemeDrawingStateObj_methods, /* tp_methods */
0, /*outputHook_tp_members*/
ThemeDrawingStateObj_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* --------------- End object type ThemeDrawingState ---------------- */

View File

@ -94,7 +94,7 @@ int ThemeButtonDrawInfo_Convert(PyObject *v, ThemeButtonDrawInfo *p_itself)
"""
class MyObjectDefinition(GlobalObjectDefinition):
class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
pass
## def outputCheckNewArg(self):
## Output("if (itself == NULL) return PyMac_Error(resNotFound);")

View File

@ -215,7 +215,7 @@ module = MacModule('_CarbonEvt', 'CarbonEvents', includestuff, finalstuff, inits
class EventHandlerRefObjectDefinition(GlobalObjectDefinition):
class EventHandlerRefObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
def outputStructMembers(self):
Output("%s ob_itself;", self.itselftype)
Output("PyObject *ob_callback;")
@ -227,12 +227,15 @@ class EventHandlerRefObjectDefinition(GlobalObjectDefinition):
Output("RemoveEventHandler(self->ob_itself);")
Output("Py_DECREF(self->ob_callback);")
OutRbrace()
class MyGlobalObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
pass
for typ in RefObjectTypes:
if typ == 'EventHandlerRef':
EventHandlerRefobject = EventHandlerRefObjectDefinition('EventHandlerRef')
else:
execstr = typ + 'object = GlobalObjectDefinition(typ)'
execstr = typ + 'object = MyGlobalObjectDefinition(typ)'
exec execstr
module.addobject(eval(typ + 'object'))

View File

@ -408,14 +408,7 @@ static PyMethodDef EventRef_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain EventRef_chain = { EventRef_methods, NULL };
static PyObject *EventRef_getattr(EventRefObject *self, char *name)
{
return Py_FindMethodInChain(&EventRef_chain, (PyObject *)self, name);
}
#define EventRef_setattr NULL
#define EventRef_getsetlist NULL
#define EventRef_compare NULL
@ -432,14 +425,31 @@ PyTypeObject EventRef_Type = {
/* methods */
(destructor) EventRef_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) EventRef_getattr, /*tp_getattr*/
(setattrfunc) EventRef_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) EventRef_compare, /*tp_compare*/
(reprfunc) EventRef_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) EventRef_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
EventRef_methods, /* tp_methods */
0, /*outputHook_tp_members*/
EventRef_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* -------------------- End object type EventRef -------------------- */
@ -591,14 +601,7 @@ static PyMethodDef EventQueueRef_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain EventQueueRef_chain = { EventQueueRef_methods, NULL };
static PyObject *EventQueueRef_getattr(EventQueueRefObject *self, char *name)
{
return Py_FindMethodInChain(&EventQueueRef_chain, (PyObject *)self, name);
}
#define EventQueueRef_setattr NULL
#define EventQueueRef_getsetlist NULL
#define EventQueueRef_compare NULL
@ -615,14 +618,31 @@ PyTypeObject EventQueueRef_Type = {
/* methods */
(destructor) EventQueueRef_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) EventQueueRef_getattr, /*tp_getattr*/
(setattrfunc) EventQueueRef_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) EventQueueRef_compare, /*tp_compare*/
(reprfunc) EventQueueRef_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) EventQueueRef_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
EventQueueRef_methods, /* tp_methods */
0, /*outputHook_tp_members*/
EventQueueRef_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* ----------------- End object type EventQueueRef ------------------ */
@ -683,14 +703,7 @@ static PyMethodDef EventLoopRef_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain EventLoopRef_chain = { EventLoopRef_methods, NULL };
static PyObject *EventLoopRef_getattr(EventLoopRefObject *self, char *name)
{
return Py_FindMethodInChain(&EventLoopRef_chain, (PyObject *)self, name);
}
#define EventLoopRef_setattr NULL
#define EventLoopRef_getsetlist NULL
#define EventLoopRef_compare NULL
@ -707,14 +720,31 @@ PyTypeObject EventLoopRef_Type = {
/* methods */
(destructor) EventLoopRef_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) EventLoopRef_getattr, /*tp_getattr*/
(setattrfunc) EventLoopRef_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) EventLoopRef_compare, /*tp_compare*/
(reprfunc) EventLoopRef_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) EventLoopRef_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
EventLoopRef_methods, /* tp_methods */
0, /*outputHook_tp_members*/
EventLoopRef_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* ------------------ End object type EventLoopRef ------------------ */
@ -793,14 +823,7 @@ static PyMethodDef EventLoopTimerRef_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain EventLoopTimerRef_chain = { EventLoopTimerRef_methods, NULL };
static PyObject *EventLoopTimerRef_getattr(EventLoopTimerRefObject *self, char *name)
{
return Py_FindMethodInChain(&EventLoopTimerRef_chain, (PyObject *)self, name);
}
#define EventLoopTimerRef_setattr NULL
#define EventLoopTimerRef_getsetlist NULL
#define EventLoopTimerRef_compare NULL
@ -817,14 +840,31 @@ PyTypeObject EventLoopTimerRef_Type = {
/* methods */
(destructor) EventLoopTimerRef_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) EventLoopTimerRef_getattr, /*tp_getattr*/
(setattrfunc) EventLoopTimerRef_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) EventLoopTimerRef_compare, /*tp_compare*/
(reprfunc) EventLoopTimerRef_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) EventLoopTimerRef_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
EventLoopTimerRef_methods, /* tp_methods */
0, /*outputHook_tp_members*/
EventLoopTimerRef_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* --------------- End object type EventLoopTimerRef ---------------- */
@ -948,14 +988,7 @@ static PyMethodDef EventHandlerRef_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain EventHandlerRef_chain = { EventHandlerRef_methods, NULL };
static PyObject *EventHandlerRef_getattr(EventHandlerRefObject *self, char *name)
{
return Py_FindMethodInChain(&EventHandlerRef_chain, (PyObject *)self, name);
}
#define EventHandlerRef_setattr NULL
#define EventHandlerRef_getsetlist NULL
#define EventHandlerRef_compare NULL
@ -972,14 +1005,31 @@ PyTypeObject EventHandlerRef_Type = {
/* methods */
(destructor) EventHandlerRef_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) EventHandlerRef_getattr, /*tp_getattr*/
(setattrfunc) EventHandlerRef_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) EventHandlerRef_compare, /*tp_compare*/
(reprfunc) EventHandlerRef_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) EventHandlerRef_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
EventHandlerRef_methods, /* tp_methods */
0, /*outputHook_tp_members*/
EventHandlerRef_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* ---------------- End object type EventHandlerRef ----------------- */
@ -1043,14 +1093,7 @@ static PyMethodDef EventHandlerCallRef_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain EventHandlerCallRef_chain = { EventHandlerCallRef_methods, NULL };
static PyObject *EventHandlerCallRef_getattr(EventHandlerCallRefObject *self, char *name)
{
return Py_FindMethodInChain(&EventHandlerCallRef_chain, (PyObject *)self, name);
}
#define EventHandlerCallRef_setattr NULL
#define EventHandlerCallRef_getsetlist NULL
#define EventHandlerCallRef_compare NULL
@ -1067,14 +1110,31 @@ PyTypeObject EventHandlerCallRef_Type = {
/* methods */
(destructor) EventHandlerCallRef_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) EventHandlerCallRef_getattr, /*tp_getattr*/
(setattrfunc) EventHandlerCallRef_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) EventHandlerCallRef_compare, /*tp_compare*/
(reprfunc) EventHandlerCallRef_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) EventHandlerCallRef_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
EventHandlerCallRef_methods, /* tp_methods */
0, /*outputHook_tp_members*/
EventHandlerCallRef_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* -------------- End object type EventHandlerCallRef --------------- */
@ -1160,14 +1220,7 @@ static PyMethodDef EventTargetRef_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain EventTargetRef_chain = { EventTargetRef_methods, NULL };
static PyObject *EventTargetRef_getattr(EventTargetRefObject *self, char *name)
{
return Py_FindMethodInChain(&EventTargetRef_chain, (PyObject *)self, name);
}
#define EventTargetRef_setattr NULL
#define EventTargetRef_getsetlist NULL
#define EventTargetRef_compare NULL
@ -1184,14 +1237,31 @@ PyTypeObject EventTargetRef_Type = {
/* methods */
(destructor) EventTargetRef_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) EventTargetRef_getattr, /*tp_getattr*/
(setattrfunc) EventTargetRef_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) EventTargetRef_compare, /*tp_compare*/
(reprfunc) EventTargetRef_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) EventTargetRef_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
EventTargetRef_methods, /* tp_methods */
0, /*outputHook_tp_members*/
EventTargetRef_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* ----------------- End object type EventTargetRef ----------------- */
@ -1252,14 +1322,7 @@ static PyMethodDef EventHotKeyRef_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain EventHotKeyRef_chain = { EventHotKeyRef_methods, NULL };
static PyObject *EventHotKeyRef_getattr(EventHotKeyRefObject *self, char *name)
{
return Py_FindMethodInChain(&EventHotKeyRef_chain, (PyObject *)self, name);
}
#define EventHotKeyRef_setattr NULL
#define EventHotKeyRef_getsetlist NULL
#define EventHotKeyRef_compare NULL
@ -1276,14 +1339,31 @@ PyTypeObject EventHotKeyRef_Type = {
/* methods */
(destructor) EventHotKeyRef_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) EventHotKeyRef_getattr, /*tp_getattr*/
(setattrfunc) EventHotKeyRef_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) EventHotKeyRef_compare, /*tp_compare*/
(reprfunc) EventHotKeyRef_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) EventHotKeyRef_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
EventHotKeyRef_methods, /* tp_methods */
0, /*outputHook_tp_members*/
EventHotKeyRef_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* ----------------- End object type EventHotKeyRef ----------------- */

View File

@ -1266,14 +1266,7 @@ static PyMethodDef CGContextRefObj_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain CGContextRefObj_chain = { CGContextRefObj_methods, NULL };
static PyObject *CGContextRefObj_getattr(CGContextRefObject *self, char *name)
{
return Py_FindMethodInChain(&CGContextRefObj_chain, (PyObject *)self, name);
}
#define CGContextRefObj_setattr NULL
#define CGContextRefObj_getsetlist NULL
#define CGContextRefObj_compare NULL
@ -1290,14 +1283,31 @@ PyTypeObject CGContextRef_Type = {
/* methods */
(destructor) CGContextRefObj_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) CGContextRefObj_getattr, /*tp_getattr*/
(setattrfunc) CGContextRefObj_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) CGContextRefObj_compare, /*tp_compare*/
(reprfunc) CGContextRefObj_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) CGContextRefObj_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
CGContextRefObj_methods, /* tp_methods */
0, /*outputHook_tp_members*/
CGContextRefObj_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* ------------------ End object type CGContextRef ------------------ */

View File

@ -250,7 +250,7 @@ CGPathDrawingMode = int
CGContextRef = OpaqueByValueType("CGContextRef", "CGContextRefObj")
class MyObjectDefinition(GlobalObjectDefinition):
class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
def outputStructMembers(self):
ObjectDefinition.outputStructMembers(self)
def outputCleanupStructMembers(self):

View File

@ -305,14 +305,7 @@ static PyMethodDef CmpInstObj_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain CmpInstObj_chain = { CmpInstObj_methods, NULL };
static PyObject *CmpInstObj_getattr(ComponentInstanceObject *self, char *name)
{
return Py_FindMethodInChain(&CmpInstObj_chain, (PyObject *)self, name);
}
#define CmpInstObj_setattr NULL
#define CmpInstObj_getsetlist NULL
#define CmpInstObj_compare NULL
@ -329,14 +322,31 @@ PyTypeObject ComponentInstance_Type = {
/* methods */
(destructor) CmpInstObj_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) CmpInstObj_getattr, /*tp_getattr*/
(setattrfunc) CmpInstObj_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) CmpInstObj_compare, /*tp_compare*/
(reprfunc) CmpInstObj_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) CmpInstObj_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
CmpInstObj_methods, /* tp_methods */
0, /*outputHook_tp_members*/
CmpInstObj_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* --------------- End object type ComponentInstance ---------------- */
@ -701,14 +711,7 @@ static PyMethodDef CmpObj_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain CmpObj_chain = { CmpObj_methods, NULL };
static PyObject *CmpObj_getattr(ComponentObject *self, char *name)
{
return Py_FindMethodInChain(&CmpObj_chain, (PyObject *)self, name);
}
#define CmpObj_setattr NULL
#define CmpObj_getsetlist NULL
#define CmpObj_compare NULL
@ -725,14 +728,31 @@ PyTypeObject Component_Type = {
/* methods */
(destructor) CmpObj_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) CmpObj_getattr, /*tp_getattr*/
(setattrfunc) CmpObj_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) CmpObj_compare, /*tp_compare*/
(reprfunc) CmpObj_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) CmpObj_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
CmpObj_methods, /* tp_methods */
0, /*outputHook_tp_members*/
CmpObj_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* ------------------- End object type Component -------------------- */

View File

@ -79,14 +79,14 @@ ComponentResult = Type("ComponentResult", "l")
ComponentResourceHandle = OpaqueByValueType("ComponentResourceHandle", "ResObj")
class MyCIObjectDefinition(GlobalObjectDefinition):
class MyCIObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
def outputCheckNewArg(self):
Output("""if (itself == NULL) {
PyErr_SetString(Cm_Error,"NULL ComponentInstance");
return NULL;
}""")
class MyCObjectDefinition(GlobalObjectDefinition):
class MyCObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
def outputCheckNewArg(self):
Output("""if (itself == NULL) {
/* XXXX Or should we return None? */

View File

@ -4543,14 +4543,7 @@ static PyMethodDef CtlObj_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain CtlObj_chain = { CtlObj_methods, NULL };
static PyObject *CtlObj_getattr(ControlObject *self, char *name)
{
return Py_FindMethodInChain(&CtlObj_chain, (PyObject *)self, name);
}
#define CtlObj_setattr NULL
#define CtlObj_getsetlist NULL
static int CtlObj_compare(ControlObject *self, ControlObject *other)
{
@ -4587,14 +4580,31 @@ PyTypeObject Control_Type = {
/* methods */
(destructor) CtlObj_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) CtlObj_getattr, /*tp_getattr*/
(setattrfunc) CtlObj_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) CtlObj_compare, /*tp_compare*/
(reprfunc) CtlObj_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) CtlObj_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
CtlObj_methods, /* tp_methods */
0, /*outputHook_tp_members*/
CtlObj_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* -------------------- End object type Control --------------------- */

View File

@ -490,7 +490,7 @@ PyMac_INIT_TOOLBOX_OBJECT_NEW(ControlHandle, CtlObj_New);
PyMac_INIT_TOOLBOX_OBJECT_CONVERT(ControlHandle, CtlObj_Convert);
"""
class MyObjectDefinition(ObjectIdentityMixin, GlobalObjectDefinition):
class MyObjectDefinition(PEP252Mixin, ObjectIdentityMixin, GlobalObjectDefinition):
def outputStructMembers(self):
GlobalObjectDefinition.outputStructMembers(self)
Output("PyObject *ob_callbackdict;")

View File

@ -964,14 +964,7 @@ static PyMethodDef DlgObj_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain DlgObj_chain = { DlgObj_methods, NULL };
static PyObject *DlgObj_getattr(DialogObject *self, char *name)
{
return Py_FindMethodInChain(&DlgObj_chain, (PyObject *)self, name);
}
#define DlgObj_setattr NULL
#define DlgObj_getsetlist NULL
static int DlgObj_compare(DialogObject *self, DialogObject *other)
{
@ -996,14 +989,31 @@ PyTypeObject Dialog_Type = {
/* methods */
(destructor) DlgObj_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) DlgObj_getattr, /*tp_getattr*/
(setattrfunc) DlgObj_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) DlgObj_compare, /*tp_compare*/
(reprfunc) DlgObj_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) DlgObj_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
DlgObj_methods, /* tp_methods */
0, /*outputHook_tp_members*/
DlgObj_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* --------------------- End object type Dialog --------------------- */

View File

@ -201,7 +201,7 @@ initstuff = initstuff + """
# Define a class which specializes our object definition
class MyObjectDefinition(GlobalObjectDefinition):
class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
def __init__(self, name, prefix = None, itselftype = None):
GlobalObjectDefinition.__init__(self, name, prefix, itselftype)
## This won't work in Carbon, so we disable it for all MacPythons:-(

View File

@ -740,14 +740,7 @@ static PyMethodDef DragObj_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain DragObj_chain = { DragObj_methods, NULL };
static PyObject *DragObj_getattr(DragObjObject *self, char *name)
{
return Py_FindMethodInChain(&DragObj_chain, (PyObject *)self, name);
}
#define DragObj_setattr NULL
#define DragObj_getsetlist NULL
#define DragObj_compare NULL
@ -764,14 +757,31 @@ PyTypeObject DragObj_Type = {
/* methods */
(destructor) DragObj_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) DragObj_getattr, /*tp_getattr*/
(setattrfunc) DragObj_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) DragObj_compare, /*tp_compare*/
(reprfunc) DragObj_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) DragObj_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
DragObj_methods, /* tp_methods */
0, /*outputHook_tp_members*/
DragObj_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* -------------------- End object type DragObj --------------------- */

View File

@ -183,7 +183,7 @@ dragglue_DrawingUPP = NewDragDrawingUPP(dragglue_Drawing);
#endif
"""
class MyObjectDefinition(GlobalObjectDefinition):
class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
def outputCheckNewArg(self):
Output("""if (itself == NULL) {
PyErr_SetString(Drag_Error,"Cannot create null Drag");

View File

@ -43,25 +43,10 @@ includestuff = includestuff + """
"""
class MyObjectDefinition(GlobalObjectDefinition):
def outputCheckNewArg(self):
Output("if (itself == NULL) return PyMac_Error(resNotFound);")
def outputCheckConvertArg(self):
OutLbrace("if (DlgObj_Check(v))")
Output("*p_itself = ((WindowObject *)v)->ob_itself;")
Output("return 1;")
OutRbrace()
Out("""
if (v == Py_None) { *p_itself = NULL; return 1; }
if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
""")
# From here on it's basically all boiler plate...
# Create the generator groups and link them
module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
##object = MyObjectDefinition(OBJECTNAME, OBJECTPREFIX, OBJECTTYPE)
##module.addobject(object)
# Create the generator classes used to populate the lists
Function = OSErrWeakLinkFunctionGenerator
@ -69,7 +54,6 @@ Function = OSErrWeakLinkFunctionGenerator
# Create and populate the lists
functions = []
##methods = []
execfile(INPUTFILE)
# Move TickCount here, for convenience
@ -80,7 +64,6 @@ functions.append(f)
# add the populated lists to the generator groups
# (in a different wordl the scan program would generate this)
for f in functions: module.add(f)
##for f in methods: object.add(f)
WaitNextEvent_body = """
Boolean _rv;

View File

@ -46,7 +46,7 @@ includestuff = includestuff + """
#endif
"""
class MyObjectDefinition(GlobalObjectDefinition):
class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
def outputCheckNewArg(self):
Output("if (itself == NULL) return PyMac_Error(resNotFound);")
def outputCheckConvertArg(self):

View File

@ -31,11 +31,11 @@ initstuff = """
module = MacModule('_IBCarbon', 'IBCarbon', includestuff, finalstuff, initstuff)
class CFReleaserObject(GlobalObjectDefinition):
class CFReleaserObject(PEP252Mixin, GlobalObjectDefinition):
def outputFreeIt(self, name):
Output("CFRelease(%s);" % name)
class CFNibDesc(GlobalObjectDefinition):
class CFNibDesc(PEP252Mixin, GlobalObjectDefinition):
def outputFreeIt(self, name):
Output("DisposeNibReference(%s);" % name)

View File

@ -140,14 +140,7 @@ static PyMethodDef IBNibRefObj_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain IBNibRefObj_chain = { IBNibRefObj_methods, NULL };
static PyObject *IBNibRefObj_getattr(IBNibRefObject *self, char *name)
{
return Py_FindMethodInChain(&IBNibRefObj_chain, (PyObject *)self, name);
}
#define IBNibRefObj_setattr NULL
#define IBNibRefObj_getsetlist NULL
#define IBNibRefObj_compare NULL
@ -164,14 +157,31 @@ PyTypeObject IBNibRef_Type = {
/* methods */
(destructor) IBNibRefObj_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) IBNibRefObj_getattr, /*tp_getattr*/
(setattrfunc) IBNibRefObj_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) IBNibRefObj_compare, /*tp_compare*/
(reprfunc) IBNibRefObj_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) IBNibRefObj_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
IBNibRefObj_methods, /* tp_methods */
0, /*outputHook_tp_members*/
IBNibRefObj_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* -------------------- End object type IBNibRef -------------------- */

View File

@ -54,7 +54,7 @@ includestuff = includestuff + """
"""
class MyObjectDefinition(GlobalObjectDefinition):
class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
def outputCheckNewArg(self):
Output("if (itself == NULL) return PyMac_Error(resNotFound);")
def outputCheckConvertArg(self):

View File

@ -542,6 +542,138 @@ static PyObject *ListObj_LGetCellDataLocation(ListObject *_self, PyObject *_args
return _res;
}
static PyObject *ListObj_GetListPort(ListObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
CGrafPtr _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = GetListPort(_self->ob_itself);
_res = Py_BuildValue("O&",
GrafObj_New, _rv);
return _res;
}
static PyObject *ListObj_GetListVerticalScrollBar(ListObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
ControlHandle _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = GetListVerticalScrollBar(_self->ob_itself);
_res = Py_BuildValue("O&",
CtlObj_New, _rv);
return _res;
}
static PyObject *ListObj_GetListHorizontalScrollBar(ListObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
ControlHandle _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = GetListHorizontalScrollBar(_self->ob_itself);
_res = Py_BuildValue("O&",
CtlObj_New, _rv);
return _res;
}
static PyObject *ListObj_GetListActive(ListObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
Boolean _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = GetListActive(_self->ob_itself);
_res = Py_BuildValue("b",
_rv);
return _res;
}
static PyObject *ListObj_GetListClickTime(ListObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
SInt32 _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = GetListClickTime(_self->ob_itself);
_res = Py_BuildValue("l",
_rv);
return _res;
}
static PyObject *ListObj_GetListRefCon(ListObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
SInt32 _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = GetListRefCon(_self->ob_itself);
_res = Py_BuildValue("l",
_rv);
return _res;
}
static PyObject *ListObj_GetListDefinition(ListObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
Handle _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = GetListDefinition(_self->ob_itself);
_res = Py_BuildValue("O&",
ResObj_New, _rv);
return _res;
}
static PyObject *ListObj_GetListUserHandle(ListObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
Handle _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = GetListUserHandle(_self->ob_itself);
_res = Py_BuildValue("O&",
ResObj_New, _rv);
return _res;
}
static PyObject *ListObj_GetListDataHandle(ListObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
DataHandle _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = GetListDataHandle(_self->ob_itself);
_res = Py_BuildValue("O&",
ResObj_New, _rv);
return _res;
}
static PyObject *ListObj_GetListFlags(ListObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
OptionBits _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = GetListFlags(_self->ob_itself);
_res = Py_BuildValue("l",
_rv);
return _res;
}
static PyObject *ListObj_GetListSelectionFlags(ListObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
OptionBits _rv;
if (!PyArg_ParseTuple(_args, ""))
return NULL;
_rv = GetListSelectionFlags(_self->ob_itself);
_res = Py_BuildValue("l",
_rv);
return _res;
}
static PyObject *ListObj_as_Resource(ListObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
@ -601,48 +733,73 @@ static PyMethodDef ListObj_methods[] = {
PyDoc_STR("(Point theCell) -> None")},
{"LGetCellDataLocation", (PyCFunction)ListObj_LGetCellDataLocation, 1,
PyDoc_STR("(Point theCell) -> (short offset, short len)")},
{"GetListPort", (PyCFunction)ListObj_GetListPort, 1,
PyDoc_STR("() -> (CGrafPtr _rv)")},
{"GetListVerticalScrollBar", (PyCFunction)ListObj_GetListVerticalScrollBar, 1,
PyDoc_STR("() -> (ControlHandle _rv)")},
{"GetListHorizontalScrollBar", (PyCFunction)ListObj_GetListHorizontalScrollBar, 1,
PyDoc_STR("() -> (ControlHandle _rv)")},
{"GetListActive", (PyCFunction)ListObj_GetListActive, 1,
PyDoc_STR("() -> (Boolean _rv)")},
{"GetListClickTime", (PyCFunction)ListObj_GetListClickTime, 1,
PyDoc_STR("() -> (SInt32 _rv)")},
{"GetListRefCon", (PyCFunction)ListObj_GetListRefCon, 1,
PyDoc_STR("() -> (SInt32 _rv)")},
{"GetListDefinition", (PyCFunction)ListObj_GetListDefinition, 1,
PyDoc_STR("() -> (Handle _rv)")},
{"GetListUserHandle", (PyCFunction)ListObj_GetListUserHandle, 1,
PyDoc_STR("() -> (Handle _rv)")},
{"GetListDataHandle", (PyCFunction)ListObj_GetListDataHandle, 1,
PyDoc_STR("() -> (DataHandle _rv)")},
{"GetListFlags", (PyCFunction)ListObj_GetListFlags, 1,
PyDoc_STR("() -> (OptionBits _rv)")},
{"GetListSelectionFlags", (PyCFunction)ListObj_GetListSelectionFlags, 1,
PyDoc_STR("() -> (OptionBits _rv)")},
{"as_Resource", (PyCFunction)ListObj_as_Resource, 1,
PyDoc_STR("() -> (Handle _rv)")},
{NULL, NULL, 0}
};
PyMethodChain ListObj_chain = { ListObj_methods, NULL };
static PyObject *ListObj_getattr(ListObject *self, char *name)
static PyObject *ListObj_get_listFlags(ListObject *self, void *closure)
{
{
if ( strcmp(name, "listFlags") == 0 )
return Py_BuildValue("l", (long)GetListFlags(self->ob_itself) & 0xff);
if ( strcmp(name, "selFlags") == 0 )
return Py_BuildValue("l", (long)GetListSelectionFlags(self->ob_itself) & 0xff);
if ( strcmp(name, "cellSize") == 0 )
return Py_BuildValue("O&", PyMac_BuildPoint, (*self->ob_itself)->cellSize);
}
return Py_FindMethodInChain(&ListObj_chain, (PyObject *)self, name);
return Py_BuildValue("l", (long)GetListFlags(self->ob_itself) & 0xff);
}
static int
ListObj_setattr(ListObject *self, char *name, PyObject *value)
static int ListObj_set_listFlags(ListObject *self, PyObject *v, void *closure)
{
long intval;
int err = 0;
if ( value == NULL ) {
PyErr_SetString(PyExc_AttributeError, "Cannot delete attribute");
return -1;
}
if (strcmp(name, "listFlags") == 0 )
err = PyArg_Parse(value, "B", &(*self->ob_itself)->listFlags);
else if (strcmp(name, "selFlags") == 0 )
err = PyArg_Parse(value, "B", &(*self->ob_itself)->selFlags);
else if (strcmp(name, "cellSize") == 0 )
err = PyArg_Parse(value, "O&", PyMac_GetPoint, &(*self->ob_itself)->cellSize);
else
PyErr_SetString(PyExc_AttributeError, "No such attribute");
if (err) return 0;
else return -1;
if (!PyArg_Parse(v, "B", &(*self->ob_itself)->listFlags)) return -1;
return 0;
}
static PyObject *ListObj_get_selFlags(ListObject *self, void *closure)
{
return Py_BuildValue("l", (long)GetListSelectionFlags(self->ob_itself) & 0xff);
}
static int ListObj_set_selFlags(ListObject *self, PyObject *v, void *closure)
{
if (!PyArg_Parse(v, "B", &(*self->ob_itself)->selFlags)) return -1;
return 0;
}
static PyObject *ListObj_get_cellSize(ListObject *self, void *closure)
{
return Py_BuildValue("O&", PyMac_BuildPoint, (*self->ob_itself)->cellSize);
}
static int ListObj_set_cellSize(ListObject *self, PyObject *v, void *closure)
{
if (!PyArg_Parse(v, "O&", PyMac_GetPoint, &(*self->ob_itself)->cellSize)) return -1;
return 0;
}
static PyGetSetDef ListObj_getsetlist[] = {
{"listFlags", (getter)ListObj_get_listFlags, (setter)ListObj_set_listFlags, NULL},
{"selFlags", (getter)ListObj_get_selFlags, (setter)ListObj_set_selFlags, NULL},
{"cellSize", (getter)ListObj_get_cellSize, (setter)ListObj_set_cellSize, NULL},
{NULL, NULL, NULL, NULL},
};
#define ListObj_compare NULL
@ -659,14 +816,31 @@ PyTypeObject List_Type = {
/* methods */
(destructor) ListObj_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) ListObj_getattr, /*tp_getattr*/
(setattrfunc) ListObj_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) ListObj_compare, /*tp_compare*/
(reprfunc) ListObj_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) ListObj_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
ListObj_methods, /* tp_methods */
0, /*outputHook_tp_members*/
ListObj_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* ---------------------- End object type List ---------------------- */
@ -783,160 +957,6 @@ static PyObject *List_LNew(PyObject *_self, PyObject *_args)
return _res;
}
static PyObject *List_GetListPort(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
CGrafPtr _rv;
ListHandle list;
if (!PyArg_ParseTuple(_args, "O&",
ListObj_Convert, &list))
return NULL;
_rv = GetListPort(list);
_res = Py_BuildValue("O&",
GrafObj_New, _rv);
return _res;
}
static PyObject *List_GetListVerticalScrollBar(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
ControlHandle _rv;
ListHandle list;
if (!PyArg_ParseTuple(_args, "O&",
ListObj_Convert, &list))
return NULL;
_rv = GetListVerticalScrollBar(list);
_res = Py_BuildValue("O&",
CtlObj_New, _rv);
return _res;
}
static PyObject *List_GetListHorizontalScrollBar(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
ControlHandle _rv;
ListHandle list;
if (!PyArg_ParseTuple(_args, "O&",
ListObj_Convert, &list))
return NULL;
_rv = GetListHorizontalScrollBar(list);
_res = Py_BuildValue("O&",
CtlObj_New, _rv);
return _res;
}
static PyObject *List_GetListActive(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
Boolean _rv;
ListHandle list;
if (!PyArg_ParseTuple(_args, "O&",
ListObj_Convert, &list))
return NULL;
_rv = GetListActive(list);
_res = Py_BuildValue("b",
_rv);
return _res;
}
static PyObject *List_GetListClickTime(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
SInt32 _rv;
ListHandle list;
if (!PyArg_ParseTuple(_args, "O&",
ListObj_Convert, &list))
return NULL;
_rv = GetListClickTime(list);
_res = Py_BuildValue("l",
_rv);
return _res;
}
static PyObject *List_GetListRefCon(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
SInt32 _rv;
ListHandle list;
if (!PyArg_ParseTuple(_args, "O&",
ListObj_Convert, &list))
return NULL;
_rv = GetListRefCon(list);
_res = Py_BuildValue("l",
_rv);
return _res;
}
static PyObject *List_GetListDefinition(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
Handle _rv;
ListHandle list;
if (!PyArg_ParseTuple(_args, "O&",
ListObj_Convert, &list))
return NULL;
_rv = GetListDefinition(list);
_res = Py_BuildValue("O&",
ResObj_New, _rv);
return _res;
}
static PyObject *List_GetListUserHandle(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
Handle _rv;
ListHandle list;
if (!PyArg_ParseTuple(_args, "O&",
ListObj_Convert, &list))
return NULL;
_rv = GetListUserHandle(list);
_res = Py_BuildValue("O&",
ResObj_New, _rv);
return _res;
}
static PyObject *List_GetListDataHandle(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
DataHandle _rv;
ListHandle list;
if (!PyArg_ParseTuple(_args, "O&",
ListObj_Convert, &list))
return NULL;
_rv = GetListDataHandle(list);
_res = Py_BuildValue("O&",
ResObj_New, _rv);
return _res;
}
static PyObject *List_GetListFlags(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
OptionBits _rv;
ListHandle list;
if (!PyArg_ParseTuple(_args, "O&",
ListObj_Convert, &list))
return NULL;
_rv = GetListFlags(list);
_res = Py_BuildValue("l",
_rv);
return _res;
}
static PyObject *List_GetListSelectionFlags(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
OptionBits _rv;
ListHandle list;
if (!PyArg_ParseTuple(_args, "O&",
ListObj_Convert, &list))
return NULL;
_rv = GetListSelectionFlags(list);
_res = Py_BuildValue("l",
_rv);
return _res;
}
static PyObject *List_SetListViewBounds(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
@ -1085,28 +1105,6 @@ static PyMethodDef List_methods[] = {
PyDoc_STR("(Rect rView, Rect dataBounds, Point cellSize, ListDefSpec theSpec, WindowPtr theWindow, Boolean drawIt, Boolean hasGrow, Boolean scrollHoriz, Boolean scrollVert) -> (ListHandle outList)")},
{"LNew", (PyCFunction)List_LNew, 1,
PyDoc_STR("(Rect rView, Rect dataBounds, Point cSize, short theProc, WindowPtr theWindow, Boolean drawIt, Boolean hasGrow, Boolean scrollHoriz, Boolean scrollVert) -> (ListHandle _rv)")},
{"GetListPort", (PyCFunction)List_GetListPort, 1,
PyDoc_STR("(ListHandle list) -> (CGrafPtr _rv)")},
{"GetListVerticalScrollBar", (PyCFunction)List_GetListVerticalScrollBar, 1,
PyDoc_STR("(ListHandle list) -> (ControlHandle _rv)")},
{"GetListHorizontalScrollBar", (PyCFunction)List_GetListHorizontalScrollBar, 1,
PyDoc_STR("(ListHandle list) -> (ControlHandle _rv)")},
{"GetListActive", (PyCFunction)List_GetListActive, 1,
PyDoc_STR("(ListHandle list) -> (Boolean _rv)")},
{"GetListClickTime", (PyCFunction)List_GetListClickTime, 1,
PyDoc_STR("(ListHandle list) -> (SInt32 _rv)")},
{"GetListRefCon", (PyCFunction)List_GetListRefCon, 1,
PyDoc_STR("(ListHandle list) -> (SInt32 _rv)")},
{"GetListDefinition", (PyCFunction)List_GetListDefinition, 1,
PyDoc_STR("(ListHandle list) -> (Handle _rv)")},
{"GetListUserHandle", (PyCFunction)List_GetListUserHandle, 1,
PyDoc_STR("(ListHandle list) -> (Handle _rv)")},
{"GetListDataHandle", (PyCFunction)List_GetListDataHandle, 1,
PyDoc_STR("(ListHandle list) -> (DataHandle _rv)")},
{"GetListFlags", (PyCFunction)List_GetListFlags, 1,
PyDoc_STR("(ListHandle list) -> (OptionBits _rv)")},
{"GetListSelectionFlags", (PyCFunction)List_GetListSelectionFlags, 1,
PyDoc_STR("(ListHandle list) -> (OptionBits _rv)")},
{"SetListViewBounds", (PyCFunction)List_SetListViewBounds, 1,
PyDoc_STR("(ListHandle list, Rect view) -> None")},
{"SetListPort", (PyCFunction)List_SetListPort, 1,

View File

@ -31,7 +31,7 @@ class MyScanner(Scanner):
if arglist:
t, n, m = arglist[-1]
# This is non-functional today
if t == OBJECT and m == "InMode":
if t in ('ListHandle', 'ListRef') and m == "InMode":
classname = "Method"
listname = "methods"
return classname, listname

View File

@ -137,41 +137,23 @@ class ListMethodGenerator(MethodGenerator):
FunctionGenerator.parseArgumentList(self, args)
self.argumentList.append(self.itself)
getattrHookCode = """{
if ( strcmp(name, "listFlags") == 0 )
return Py_BuildValue("l", (long)GetListFlags(self->ob_itself) & 0xff);
if ( strcmp(name, "selFlags") == 0 )
return Py_BuildValue("l", (long)GetListSelectionFlags(self->ob_itself) & 0xff);
if ( strcmp(name, "cellSize") == 0 )
return Py_BuildValue("O&", PyMac_BuildPoint, (*self->ob_itself)->cellSize);
}"""
setattrCode = """
static int
ListObj_setattr(ListObject *self, char *name, PyObject *value)
{
long intval;
int err = 0;
if ( value == NULL ) {
PyErr_SetString(PyExc_AttributeError, "Cannot delete attribute");
return -1;
}
if (strcmp(name, "listFlags") == 0 )
err = PyArg_Parse(value, "B", &(*self->ob_itself)->listFlags);
else if (strcmp(name, "selFlags") == 0 )
err = PyArg_Parse(value, "B", &(*self->ob_itself)->selFlags);
else if (strcmp(name, "cellSize") == 0 )
err = PyArg_Parse(value, "O&", PyMac_GetPoint, &(*self->ob_itself)->cellSize);
else
PyErr_SetString(PyExc_AttributeError, "No such attribute");
if (err) return 0;
else return -1;
}
"""
class MyObjectDefinition(GlobalObjectDefinition):
class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
getsetlist = [(
'listFlags',
'return Py_BuildValue("l", (long)GetListFlags(self->ob_itself) & 0xff);',
'if (!PyArg_Parse(v, "B", &(*self->ob_itself)->listFlags)) return -1;',
None,
), (
'selFlags',
'return Py_BuildValue("l", (long)GetListSelectionFlags(self->ob_itself) & 0xff);',
'if (!PyArg_Parse(v, "B", &(*self->ob_itself)->selFlags)) return -1;',
None,
), (
'cellSize',
'return Py_BuildValue("O&", PyMac_BuildPoint, (*self->ob_itself)->cellSize);',
'if (!PyArg_Parse(v, "O&", PyMac_GetPoint, &(*self->ob_itself)->cellSize)) return -1;',
None
)]
def outputStructMembers(self):
ObjectDefinition.outputStructMembers(self)
@ -201,12 +183,6 @@ class MyObjectDefinition(GlobalObjectDefinition):
Output("SetListRefCon(self->ob_itself, (long)0);")
Output("if (self->ob_must_be_disposed && %s) LDispose(%s);", itselfname, itselfname)
def outputGetattrHook(self):
Output(getattrHookCode)
def outputSetattr(self):
Output(setattrCode)
# From here on it's basically all boiler plate...
finalstuff = finalstuff + """

View File

@ -3000,14 +3000,7 @@ static PyMethodDef MenuObj_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain MenuObj_chain = { MenuObj_methods, NULL };
static PyObject *MenuObj_getattr(MenuObject *self, char *name)
{
return Py_FindMethodInChain(&MenuObj_chain, (PyObject *)self, name);
}
#define MenuObj_setattr NULL
#define MenuObj_getsetlist NULL
#define MenuObj_compare NULL
@ -3024,14 +3017,31 @@ PyTypeObject Menu_Type = {
/* methods */
(destructor) MenuObj_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) MenuObj_getattr, /*tp_getattr*/
(setattrfunc) MenuObj_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) MenuObj_compare, /*tp_compare*/
(reprfunc) MenuObj_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) MenuObj_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
MenuObj_methods, /* tp_methods */
0, /*outputHook_tp_members*/
MenuObj_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* ---------------------- End object type Menu ---------------------- */

View File

@ -98,7 +98,7 @@ initstuff = initstuff + """
PyMac_INIT_TOOLBOX_OBJECT_CONVERT(MenuHandle, MenuObj_Convert);
"""
class MyObjectDefinition(GlobalObjectDefinition):
class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
pass
# Create the generator groups and link them

View File

@ -1295,14 +1295,7 @@ static PyMethodDef TXNObj_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain TXNObj_chain = { TXNObj_methods, NULL };
static PyObject *TXNObj_getattr(TXNObjectObject *self, char *name)
{
return Py_FindMethodInChain(&TXNObj_chain, (PyObject *)self, name);
}
#define TXNObj_setattr NULL
#define TXNObj_getsetlist NULL
#define TXNObj_compare NULL
@ -1319,14 +1312,31 @@ PyTypeObject TXNObject_Type = {
/* methods */
(destructor) TXNObj_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) TXNObj_getattr, /*tp_getattr*/
(setattrfunc) TXNObj_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) TXNObj_compare, /*tp_compare*/
(reprfunc) TXNObj_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) TXNObj_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
TXNObj_methods, /* tp_methods */
0, /*outputHook_tp_members*/
TXNObj_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* ------------------- End object type TXNObject -------------------- */
@ -1411,14 +1421,7 @@ static PyMethodDef TXNFontMenuObj_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain TXNFontMenuObj_chain = { TXNFontMenuObj_methods, NULL };
static PyObject *TXNFontMenuObj_getattr(TXNFontMenuObjectObject *self, char *name)
{
return Py_FindMethodInChain(&TXNFontMenuObj_chain, (PyObject *)self, name);
}
#define TXNFontMenuObj_setattr NULL
#define TXNFontMenuObj_getsetlist NULL
#define TXNFontMenuObj_compare NULL
@ -1435,14 +1438,31 @@ PyTypeObject TXNFontMenuObject_Type = {
/* methods */
(destructor) TXNFontMenuObj_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) TXNFontMenuObj_getattr, /*tp_getattr*/
(setattrfunc) TXNFontMenuObj_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) TXNFontMenuObj_compare, /*tp_compare*/
(reprfunc) TXNFontMenuObj_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) TXNFontMenuObj_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
TXNFontMenuObj_methods, /* tp_methods */
0, /*outputHook_tp_members*/
TXNFontMenuObj_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* --------------- End object type TXNFontMenuObject ---------------- */

View File

@ -136,11 +136,11 @@ execfile("mltetypetest.py")
# Our (opaque) objects
class TXNObjDefinition(GlobalObjectDefinition):
class TXNObjDefinition(PEP252Mixin, GlobalObjectDefinition):
def outputCheckNewArg(self):
Output("if (itself == NULL) return PyMac_Error(resNotFound);")
class TXNFontMenuObjDefinition(GlobalObjectDefinition):
class TXNFontMenuObjDefinition(PEP252Mixin, GlobalObjectDefinition):
def outputCheckNewArg(self):
Output("if (itself == NULL) return PyMac_Error(resNotFound);")

File diff suppressed because it is too large Load Diff

View File

@ -53,6 +53,12 @@ class MyScanner(Scanner):
listname = "functions"
if arglist:
t, n, m = arglist[0]
if t in ('GrafPtr', 'CGrafPtr') and m == 'InMode':
classname = "Method"
listname = "gr_methods"
elif t == 'BitMapPtr' and m == 'InMode':
classname = "Method"
listname = "bm_methods"
## elif t == "PolyHandle" and m == "InMode":
## classname = "Method"
## listname = "p_methods"

View File

@ -211,15 +211,7 @@ PyObject *BMObj_NewCopied(BitMapPtr itself)
"""
variablestuff = """
{
PyObject *o;
o = QDGA_New();
if (o == NULL || PyDict_SetItemString(d, "qd", o) != 0)
return;
}
"""
variablestuff = ""
initstuff = initstuff + """
PyMac_INIT_TOOLBOX_OBJECT_NEW(BitMapPtr, BMObj_New);
@ -244,7 +236,22 @@ initstuff = initstuff + """
## def outputFreeIt(self, itselfname):
## Output("KillPoly(%s);", itselfname)
class MyGRObjectDefinition(GlobalObjectDefinition):
class MyGRObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
getsetlist = [
('visRgn',
"""RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */
return Py_BuildValue("O&", ResObj_New, (Handle)GetPortVisibleRegion(self->ob_itself, h));
""",
None,
"Convenience attribute: return a copy of the visible region"
), (
'clipRgn',
"""RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */
return Py_BuildValue("O&", ResObj_New, (Handle)GetPortClipRegion(self->ob_itself, h));
""",
None,
"Convenience attribute: return a copy of the clipping region"
)]
def outputCheckNewArg(self):
Output("if (itself == NULL) return PyMac_Error(resNotFound);")
def outputCheckConvertArg(self):
@ -269,157 +276,35 @@ class MyGRObjectDefinition(GlobalObjectDefinition):
Output("return 1;")
OutRbrace()
Output("#endif")
def outputGetattrHook(self):
Output("#if !ACCESSOR_CALLS_ARE_FUNCTIONS")
Output("""
{ CGrafPtr itself_color = (CGrafPtr)self->ob_itself;
if ( strcmp(name, "data") == 0 )
return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(GrafPort));
if ( (itself_color->portVersion&0xc000) == 0xc000 ) {
/* Color-only attributes */
if ( strcmp(name, "portBits") == 0 )
/* XXXX Do we need HLock() stuff here?? */
return BMObj_New((BitMapPtr)*itself_color->portPixMap);
if ( strcmp(name, "grafVars") == 0 )
return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->visRgn);
if ( strcmp(name, "chExtra") == 0 )
return Py_BuildValue("h", itself_color->chExtra);
if ( strcmp(name, "pnLocHFrac") == 0 )
return Py_BuildValue("h", itself_color->pnLocHFrac);
if ( strcmp(name, "bkPixPat") == 0 )
return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->bkPixPat);
if ( strcmp(name, "rgbFgColor") == 0 )
return Py_BuildValue("O&", QdRGB_New, &itself_color->rgbFgColor);
if ( strcmp(name, "rgbBkColor") == 0 )
return Py_BuildValue("O&", QdRGB_New, &itself_color->rgbBkColor);
if ( strcmp(name, "pnPixPat") == 0 )
return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->pnPixPat);
if ( strcmp(name, "fillPixPat") == 0 )
return Py_BuildValue("O&", ResObj_New, (Handle)itself_color->fillPixPat);
} else {
/* Mono-only attributes */
if ( strcmp(name, "portBits") == 0 )
return BMObj_New(&self->ob_itself->portBits);
if ( strcmp(name, "bkPat") == 0 )
return Py_BuildValue("s#", (char *)&self->ob_itself->bkPat, sizeof(Pattern));
if ( strcmp(name, "fillPat") == 0 )
return Py_BuildValue("s#", (char *)&self->ob_itself->fillPat, sizeof(Pattern));
if ( strcmp(name, "pnPat") == 0 )
return Py_BuildValue("s#", (char *)&self->ob_itself->pnPat, sizeof(Pattern));
}
/*
** Accessible for both color/mono windows.
** portVersion is really color-only, but we put it here
** for convenience
*/
if ( strcmp(name, "portVersion") == 0 )
return Py_BuildValue("h", itself_color->portVersion);
if ( strcmp(name, "device") == 0 )
return PyInt_FromLong((long)self->ob_itself->device);
if ( strcmp(name, "portRect") == 0 )
return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->portRect);
if ( strcmp(name, "visRgn") == 0 )
return Py_BuildValue("O&", ResObj_New, (Handle)self->ob_itself->visRgn);
if ( strcmp(name, "clipRgn") == 0 )
return Py_BuildValue("O&", ResObj_New, (Handle)self->ob_itself->clipRgn);
if ( strcmp(name, "pnLoc") == 0 )
return Py_BuildValue("O&", PyMac_BuildPoint, self->ob_itself->pnLoc);
if ( strcmp(name, "pnSize") == 0 )
return Py_BuildValue("O&", PyMac_BuildPoint, self->ob_itself->pnSize);
if ( strcmp(name, "pnMode") == 0 )
return Py_BuildValue("h", self->ob_itself->pnMode);
if ( strcmp(name, "pnVis") == 0 )
return Py_BuildValue("h", self->ob_itself->pnVis);
if ( strcmp(name, "txFont") == 0 )
return Py_BuildValue("h", self->ob_itself->txFont);
if ( strcmp(name, "txFace") == 0 )
return Py_BuildValue("h", (short)self->ob_itself->txFace);
if ( strcmp(name, "txMode") == 0 )
return Py_BuildValue("h", self->ob_itself->txMode);
if ( strcmp(name, "txSize") == 0 )
return Py_BuildValue("h", self->ob_itself->txSize);
if ( strcmp(name, "spExtra") == 0 )
return Py_BuildValue("O&", PyMac_BuildFixed, self->ob_itself->spExtra);
/* XXXX Add more, as needed */
/* This one is so we can compare grafports: */
if ( strcmp(name, "_id") == 0 )
return Py_BuildValue("l", (long)self->ob_itself);
}""")
Output("#else")
Output("""
{ CGrafPtr itself_color = (CGrafPtr)self->ob_itself;
if ( strcmp(name, "portBits") == 0 )
return BMObj_New((BitMapPtr)GetPortBitMapForCopyBits(itself_color));
if ( strcmp(name, "chExtra") == 0 )
return Py_BuildValue("h", GetPortChExtra(itself_color));
if ( strcmp(name, "pnLocHFrac") == 0 )
return Py_BuildValue("h", GetPortFracHPenLocation(itself_color));
if ( strcmp(name, "bkPixPat") == 0 ) {
PixPatHandle h=0;
return Py_BuildValue("O&", ResObj_New, (Handle)GetPortBackPixPat(itself_color, h));
}
if ( strcmp(name, "rgbFgColor") == 0 ) {
RGBColor c;
return Py_BuildValue("O&", QdRGB_New, GetPortForeColor(itself_color, &c));
}
if ( strcmp(name, "rgbBkColor") == 0 ) {
RGBColor c;
return Py_BuildValue("O&", QdRGB_New, GetPortBackColor(itself_color, &c));
}
if ( strcmp(name, "pnPixPat") == 0 ) {
PixPatHandle h=NewPixPat(); /* XXXX wrong dispose routine */
return Py_BuildValue("O&", ResObj_New, (Handle)GetPortPenPixPat(itself_color, h));
}
if ( strcmp(name, "fillPixPat") == 0 ) {
PixPatHandle h=NewPixPat(); /* XXXX wrong dispose routine */
return Py_BuildValue("O&", ResObj_New, (Handle)GetPortFillPixPat(itself_color, h));
}
if ( strcmp(name, "portRect") == 0 ) {
Rect r;
return Py_BuildValue("O&", PyMac_BuildRect, GetPortBounds(itself_color, &r));
}
if ( strcmp(name, "visRgn") == 0 ) {
RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */
return Py_BuildValue("O&", ResObj_New, (Handle)GetPortVisibleRegion(itself_color, h));
}
if ( strcmp(name, "clipRgn") == 0 ) {
RgnHandle h=NewRgn(); /* XXXX wrong dispose routine */
return Py_BuildValue("O&", ResObj_New, (Handle)GetPortClipRegion(itself_color, h));
}
if ( strcmp(name, "pnLoc") == 0 ) {
Point p;
return Py_BuildValue("O&", PyMac_BuildPoint, *GetPortPenLocation(itself_color, &p));
}
if ( strcmp(name, "pnSize") == 0 ) {
Point p;
return Py_BuildValue("O&", PyMac_BuildPoint, *GetPortPenSize(itself_color, &p));
}
if ( strcmp(name, "pnMode") == 0 )
return Py_BuildValue("h", GetPortPenMode(itself_color));
if ( strcmp(name, "pnVis") == 0 )
return Py_BuildValue("h", GetPortPenVisibility(itself_color));
if ( strcmp(name, "txFont") == 0 )
return Py_BuildValue("h", GetPortTextFont(itself_color));
if ( strcmp(name, "txFace") == 0 )
return Py_BuildValue("h", (short)GetPortTextFace(itself_color));
if ( strcmp(name, "txMode") == 0 )
return Py_BuildValue("h", GetPortTextMode(itself_color));
if ( strcmp(name, "txSize") == 0 )
return Py_BuildValue("h", GetPortTextSize(itself_color));
if ( strcmp(name, "spExtra") == 0 )
return Py_BuildValue("O&", PyMac_BuildFixed, GetPortSpExtra(itself_color));
/* XXXX Add more, as needed */
/* This one is so we can compare grafports: */
if ( strcmp(name, "_id") == 0 )
return Py_BuildValue("l", (long)self->ob_itself);
}""")
Output("#endif")
class MyBMObjectDefinition(GlobalObjectDefinition):
class MyBMObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
getsetlist = [
(
'baseAddr',
'return PyInt_FromLong((long)self->ob_itself->baseAddr);',
None,
None
), (
'rowBytes',
'return PyInt_FromLong((long)self->ob_itself->rowBytes);',
None,
None
), (
'bounds',
'return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->bounds);',
None,
None
), (
'bitmap_data',
'return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(BitMap));',
None,
None
), (
'pixmap_data',
'return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(PixMap));',
None,
None
)]
def outputCheckNewArg(self):
Output("if (itself == NULL) return PyMac_Error(resNotFound);")
def outputStructMembers(self):
@ -434,104 +319,7 @@ class MyBMObjectDefinition(GlobalObjectDefinition):
Output("it->referred_bitmap = NULL;")
def outputCleanupStructMembers(self):
Output("Py_XDECREF(self->referred_object);")
Output("if (self->referred_bitmap) free(self->referred_bitmap);")
def outputGetattrHook(self):
Output("""if ( strcmp(name, "baseAddr") == 0 )
return PyInt_FromLong((long)self->ob_itself->baseAddr);
if ( strcmp(name, "rowBytes") == 0 )
return PyInt_FromLong((long)self->ob_itself->rowBytes);
if ( strcmp(name, "bounds") == 0 )
return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->bounds);
/* XXXX Add more, as needed */
if ( strcmp(name, "bitmap_data") == 0 )
return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(BitMap));
if ( strcmp(name, "pixmap_data") == 0 )
return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(PixMap));
""")
# This object is instanciated once, and will access qd globals.
class QDGlobalsAccessObjectDefinition(ObjectDefinition):
def outputStructMembers(self):
pass
def outputNew(self):
Output()
Output("%sPyObject *%s_New(void)", self.static, self.prefix)
OutLbrace()
Output("%s *it;", self.objecttype)
Output("it = PyObject_NEW(%s, &%s);", self.objecttype, self.typename)
Output("if (it == NULL) return NULL;")
Output("return (PyObject *)it;")
OutRbrace()
def outputConvert(self):
pass
def outputCleanupStructMembers(self):
pass
def outputGetattrHook(self):
Output("#if !ACCESSOR_CALLS_ARE_FUNCTIONS")
Output("""
if ( strcmp(name, "arrow") == 0 )
return PyString_FromStringAndSize((char *)&qd.arrow, sizeof(qd.arrow));
if ( strcmp(name, "black") == 0 )
return PyString_FromStringAndSize((char *)&qd.black, sizeof(qd.black));
if ( strcmp(name, "white") == 0 )
return PyString_FromStringAndSize((char *)&qd.white, sizeof(qd.white));
if ( strcmp(name, "gray") == 0 )
return PyString_FromStringAndSize((char *)&qd.gray, sizeof(qd.gray));
if ( strcmp(name, "ltGray") == 0 )
return PyString_FromStringAndSize((char *)&qd.ltGray, sizeof(qd.ltGray));
if ( strcmp(name, "dkGray") == 0 )
return PyString_FromStringAndSize((char *)&qd.dkGray, sizeof(qd.dkGray));
if ( strcmp(name, "screenBits") == 0 )
return BMObj_New(&qd.screenBits);
if ( strcmp(name, "thePort") == 0 )
return GrafObj_New(qd.thePort);
if ( strcmp(name, "randSeed") == 0 )
return Py_BuildValue("l", &qd.randSeed);
""")
Output("#else")
Output("""
if ( strcmp(name, "arrow") == 0 ) {
Cursor rv;
GetQDGlobalsArrow(&rv);
return PyString_FromStringAndSize((char *)&rv, sizeof(rv));
}
if ( strcmp(name, "black") == 0 ) {
Pattern rv;
GetQDGlobalsBlack(&rv);
return PyString_FromStringAndSize((char *)&rv, sizeof(rv));
}
if ( strcmp(name, "white") == 0 ) {
Pattern rv;
GetQDGlobalsWhite(&rv);
return PyString_FromStringAndSize((char *)&rv, sizeof(rv));
}
if ( strcmp(name, "gray") == 0 ) {
Pattern rv;
GetQDGlobalsGray(&rv);
return PyString_FromStringAndSize((char *)&rv, sizeof(rv));
}
if ( strcmp(name, "ltGray") == 0 ) {
Pattern rv;
GetQDGlobalsLightGray(&rv);
return PyString_FromStringAndSize((char *)&rv, sizeof(rv));
}
if ( strcmp(name, "dkGray") == 0 ) {
Pattern rv;
GetQDGlobalsDarkGray(&rv);
return PyString_FromStringAndSize((char *)&rv, sizeof(rv));
}
if ( strcmp(name, "screenBits") == 0 ) {
BitMap rv;
GetQDGlobalsScreenBits(&rv);
return BMObj_NewCopied(&rv);
}
if ( strcmp(name, "thePort") == 0 )
return GrafObj_New(GetQDGlobalsThePort());
if ( strcmp(name, "randSeed") == 0 )
return Py_BuildValue("l", GetQDGlobalsRandomSeed());
""")
Output("#endif")
Output("if (self->referred_bitmap) free(self->referred_bitmap);")
# Create the generator groups and link them
module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff, variablestuff)
@ -543,8 +331,6 @@ gr_object = MyGRObjectDefinition("GrafPort", "GrafObj", "GrafPtr")
module.addobject(gr_object)
bm_object = MyBMObjectDefinition("BitMap", "BMObj", "BitMapPtr")
module.addobject(bm_object)
qd_object = QDGlobalsAccessObjectDefinition("QDGlobalsAccess", "QDGA", "XXXX")
module.addobject(qd_object)
# Create the generator classes used to populate the lists
@ -553,15 +339,17 @@ Method = OSErrWeakLinkMethodGenerator
# Create and populate the lists
functions = []
methods = []
gr_methods = []
bm_methods = []
#methods = []
execfile(INPUTFILE)
execfile(EXTRAFILE)
# add the populated lists to the generator groups
# (in a different wordl the scan program would generate this)
for f in functions: module.add(f)
##for f in r_methods: r_object.add(f)
##for f in po_methods: po_object.add(f)
for f in gr_methods: gr_object.add(f)
for f in bm_methods: bm_object.add(f)
# Manual generator: get data out of a bitmap
getdata_body = """

View File

@ -131,14 +131,7 @@ static PyMethodDef GWorldObj_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain GWorldObj_chain = { GWorldObj_methods, NULL };
static PyObject *GWorldObj_getattr(GWorldObject *self, char *name)
{
return Py_FindMethodInChain(&GWorldObj_chain, (PyObject *)self, name);
}
#define GWorldObj_setattr NULL
#define GWorldObj_getsetlist NULL
#define GWorldObj_compare NULL
@ -155,14 +148,31 @@ PyTypeObject GWorld_Type = {
/* methods */
(destructor) GWorldObj_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) GWorldObj_getattr, /*tp_getattr*/
(setattrfunc) GWorldObj_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) GWorldObj_compare, /*tp_compare*/
(reprfunc) GWorldObj_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) GWorldObj_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
GWorldObj_methods, /* tp_methods */
0, /*outputHook_tp_members*/
GWorldObj_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* --------------------- End object type GWorld --------------------- */

View File

@ -57,7 +57,7 @@ initstuff = initstuff + """
PyMac_INIT_TOOLBOX_OBJECT_CONVERT(GWorldPtr, GWorldObj_Convert);
"""
class MyObjectDefinition(GlobalObjectDefinition):
class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
def outputCheckNewArg(self):
Output("if (itself == NULL) return PyMac_Error(resNotFound);")
## def outputInitStructMembers(self):

View File

@ -1090,14 +1090,7 @@ static PyMethodDef MovieCtlObj_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain MovieCtlObj_chain = { MovieCtlObj_methods, NULL };
static PyObject *MovieCtlObj_getattr(MovieControllerObject *self, char *name)
{
return Py_FindMethodInChain(&MovieCtlObj_chain, (PyObject *)self, name);
}
#define MovieCtlObj_setattr NULL
#define MovieCtlObj_getsetlist NULL
#define MovieCtlObj_compare NULL
@ -1114,14 +1107,31 @@ PyTypeObject MovieController_Type = {
/* methods */
(destructor) MovieCtlObj_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) MovieCtlObj_getattr, /*tp_getattr*/
(setattrfunc) MovieCtlObj_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) MovieCtlObj_compare, /*tp_compare*/
(reprfunc) MovieCtlObj_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) MovieCtlObj_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
MovieCtlObj_methods, /* tp_methods */
0, /*outputHook_tp_members*/
MovieCtlObj_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* ---------------- End object type MovieController ----------------- */
@ -1541,14 +1551,7 @@ static PyMethodDef TimeBaseObj_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain TimeBaseObj_chain = { TimeBaseObj_methods, NULL };
static PyObject *TimeBaseObj_getattr(TimeBaseObject *self, char *name)
{
return Py_FindMethodInChain(&TimeBaseObj_chain, (PyObject *)self, name);
}
#define TimeBaseObj_setattr NULL
#define TimeBaseObj_getsetlist NULL
#define TimeBaseObj_compare NULL
@ -1565,14 +1568,31 @@ PyTypeObject TimeBase_Type = {
/* methods */
(destructor) TimeBaseObj_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) TimeBaseObj_getattr, /*tp_getattr*/
(setattrfunc) TimeBaseObj_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) TimeBaseObj_compare, /*tp_compare*/
(reprfunc) TimeBaseObj_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) TimeBaseObj_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
TimeBaseObj_methods, /* tp_methods */
0, /*outputHook_tp_members*/
TimeBaseObj_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* -------------------- End object type TimeBase -------------------- */
@ -1845,14 +1865,7 @@ static PyMethodDef UserDataObj_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain UserDataObj_chain = { UserDataObj_methods, NULL };
static PyObject *UserDataObj_getattr(UserDataObject *self, char *name)
{
return Py_FindMethodInChain(&UserDataObj_chain, (PyObject *)self, name);
}
#define UserDataObj_setattr NULL
#define UserDataObj_getsetlist NULL
#define UserDataObj_compare NULL
@ -1869,14 +1882,31 @@ PyTypeObject UserData_Type = {
/* methods */
(destructor) UserDataObj_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) UserDataObj_getattr, /*tp_getattr*/
(setattrfunc) UserDataObj_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) UserDataObj_compare, /*tp_compare*/
(reprfunc) UserDataObj_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) UserDataObj_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
UserDataObj_methods, /* tp_methods */
0, /*outputHook_tp_members*/
UserDataObj_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* -------------------- End object type UserData -------------------- */
@ -3020,14 +3050,7 @@ static PyMethodDef MediaObj_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain MediaObj_chain = { MediaObj_methods, NULL };
static PyObject *MediaObj_getattr(MediaObject *self, char *name)
{
return Py_FindMethodInChain(&MediaObj_chain, (PyObject *)self, name);
}
#define MediaObj_setattr NULL
#define MediaObj_getsetlist NULL
#define MediaObj_compare NULL
@ -3044,14 +3067,31 @@ PyTypeObject Media_Type = {
/* methods */
(destructor) MediaObj_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) MediaObj_getattr, /*tp_getattr*/
(setattrfunc) MediaObj_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) MediaObj_compare, /*tp_compare*/
(reprfunc) MediaObj_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) MediaObj_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
MediaObj_methods, /* tp_methods */
0, /*outputHook_tp_members*/
MediaObj_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* --------------------- End object type Media ---------------------- */
@ -4301,14 +4341,7 @@ static PyMethodDef TrackObj_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain TrackObj_chain = { TrackObj_methods, NULL };
static PyObject *TrackObj_getattr(TrackObject *self, char *name)
{
return Py_FindMethodInChain(&TrackObj_chain, (PyObject *)self, name);
}
#define TrackObj_setattr NULL
#define TrackObj_getsetlist NULL
#define TrackObj_compare NULL
@ -4325,14 +4358,31 @@ PyTypeObject Track_Type = {
/* methods */
(destructor) TrackObj_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) TrackObj_getattr, /*tp_getattr*/
(setattrfunc) TrackObj_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) TrackObj_compare, /*tp_compare*/
(reprfunc) TrackObj_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) TrackObj_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
TrackObj_methods, /* tp_methods */
0, /*outputHook_tp_members*/
TrackObj_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* --------------------- End object type Track ---------------------- */
@ -6722,14 +6772,7 @@ static PyMethodDef MovieObj_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain MovieObj_chain = { MovieObj_methods, NULL };
static PyObject *MovieObj_getattr(MovieObject *self, char *name)
{
return Py_FindMethodInChain(&MovieObj_chain, (PyObject *)self, name);
}
#define MovieObj_setattr NULL
#define MovieObj_getsetlist NULL
#define MovieObj_compare NULL
@ -6746,14 +6789,31 @@ PyTypeObject Movie_Type = {
/* methods */
(destructor) MovieObj_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) MovieObj_getattr, /*tp_getattr*/
(setattrfunc) MovieObj_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) MovieObj_compare, /*tp_compare*/
(reprfunc) MovieObj_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) MovieObj_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
MovieObj_methods, /* tp_methods */
0, /*outputHook_tp_members*/
MovieObj_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* --------------------- End object type Movie ---------------------- */

View File

@ -181,7 +181,7 @@ QTFloatSingle = Type("QTFloatSingle", "f")
dummyshortptr = FakeType('(short *)0')
dummyStringPtr = FakeType('(StringPtr)0')
class MovieObjectDefinition(GlobalObjectDefinition):
class MovieObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
def outputCheckNewArg(self):
Output("""if (itself == NULL) {
PyErr_SetString(Qt_Error,"Cannot create null Movie");
@ -190,7 +190,7 @@ class MovieObjectDefinition(GlobalObjectDefinition):
def outputFreeIt(self, itselfname):
Output("DisposeMovie(%s);", itselfname)
class TrackObjectDefinition(GlobalObjectDefinition):
class TrackObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
def outputCheckNewArg(self):
Output("""if (itself == NULL) {
PyErr_SetString(Qt_Error,"Cannot create null Track");
@ -199,7 +199,7 @@ class TrackObjectDefinition(GlobalObjectDefinition):
def outputFreeIt(self, itselfname):
Output("DisposeMovieTrack(%s);", itselfname)
class MediaObjectDefinition(GlobalObjectDefinition):
class MediaObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
def outputCheckNewArg(self):
Output("""if (itself == NULL) {
PyErr_SetString(Qt_Error,"Cannot create null Media");
@ -208,7 +208,7 @@ class MediaObjectDefinition(GlobalObjectDefinition):
def outputFreeIt(self, itselfname):
Output("DisposeTrackMedia(%s);", itselfname)
class UserDataObjectDefinition(GlobalObjectDefinition):
class UserDataObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
def outputCheckNewArg(self):
Output("""if (itself == NULL) {
PyErr_SetString(Qt_Error,"Cannot create null UserData");
@ -217,7 +217,7 @@ class UserDataObjectDefinition(GlobalObjectDefinition):
def outputFreeIt(self, itselfname):
Output("DisposeUserData(%s);", itselfname)
class TimeBaseObjectDefinition(GlobalObjectDefinition):
class TimeBaseObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
def outputCheckNewArg(self):
Output("""if (itself == NULL) {
PyErr_SetString(Qt_Error,"Cannot create null TimeBase");
@ -226,7 +226,7 @@ class TimeBaseObjectDefinition(GlobalObjectDefinition):
## def outputFreeIt(self, itselfname):
## Output("DisposeTimeBase(%s);", itselfname)
class MovieCtlObjectDefinition(GlobalObjectDefinition):
class MovieCtlObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
def outputCheckNewArg(self):
Output("""if (itself == NULL) {
PyErr_SetString(Qt_Error,"Cannot create null MovieController");

View File

@ -551,54 +551,61 @@ static PyMethodDef ResObj_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain ResObj_chain = { ResObj_methods, NULL };
static PyObject *ResObj_getattr(ResourceObject *self, char *name)
static PyObject *ResObj_get_data(ResourceObject *self, void *closure)
{
if (strcmp(name, "size") == 0)
return PyInt_FromLong(GetHandleSize(self->ob_itself));
if (strcmp(name, "data") == 0) {
PyObject *res;
char state;
state = HGetState(self->ob_itself);
HLock(self->ob_itself);
res = PyString_FromStringAndSize(
*self->ob_itself,
GetHandleSize(self->ob_itself));
HUnlock(self->ob_itself);
HSetState(self->ob_itself, state);
return res;
}
if (strcmp(name, "__members__") == 0)
return Py_BuildValue("[ss]", "data", "size");
PyObject *res;
char state;
return Py_FindMethodInChain(&ResObj_chain, (PyObject *)self, name);
state = HGetState(self->ob_itself);
HLock(self->ob_itself);
res = PyString_FromStringAndSize(
*self->ob_itself,
GetHandleSize(self->ob_itself));
HUnlock(self->ob_itself);
HSetState(self->ob_itself, state);
return res;
}
static int
ResObj_setattr(ResourceObject *self, char *name, PyObject *value)
static int ResObj_set_data(ResourceObject *self, PyObject *v, void *closure)
{
char *data;
long size;
if (strcmp(name, "data") != 0 || value == NULL )
return -1;
if ( !PyString_Check(value) )
return -1;
size = PyString_Size(value);
data = PyString_AsString(value);
/* XXXX Do I need the GetState/SetState calls? */
SetHandleSize(self->ob_itself, size);
if ( MemError())
return -1;
HLock(self->ob_itself);
memcpy((char *)*self->ob_itself, data, size);
HUnlock(self->ob_itself);
/* XXXX Should I do the Changed call immedeately? */
char *data;
long size;
if ( v == NULL )
return -1;
if ( !PyString_Check(v) )
return -1;
size = PyString_Size(v);
data = PyString_AsString(v);
/* XXXX Do I need the GetState/SetState calls? */
SetHandleSize(self->ob_itself, size);
if ( MemError())
return -1;
HLock(self->ob_itself);
memcpy((char *)*self->ob_itself, data, size);
HUnlock(self->ob_itself);
/* XXXX Should I do the Changed call immedeately? */
return 0;
return 0;
}
static PyObject *ResObj_get_size(ResourceObject *self, void *closure)
{
return PyInt_FromLong(GetHandleSize(self->ob_itself));
}
#define ResObj_set_size NULL
static PyGetSetDef ResObj_getsetlist[] = {
{"data", (getter)ResObj_get_data, (setter)ResObj_set_data, "The resource data"},
{"size", (getter)ResObj_get_size, (setter)ResObj_set_size, "The length of the resource data"},
{NULL, NULL, NULL, NULL},
};
#define ResObj_compare NULL
@ -615,14 +622,31 @@ PyTypeObject Resource_Type = {
/* methods */
(destructor) ResObj_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) ResObj_getattr, /*tp_getattr*/
(setattrfunc) ResObj_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) ResObj_compare, /*tp_compare*/
(reprfunc) ResObj_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) ResObj_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
ResObj_methods, /* tp_methods */
0, /*outputHook_tp_members*/
ResObj_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* -------------------- End object type Resource -------------------- */

View File

@ -100,51 +100,49 @@ initstuff = initstuff + """
module = MacModule('_Res', 'Res', includestuff, finalstuff, initstuff)
getattrHookCode = """
if (strcmp(name, "size") == 0)
return PyInt_FromLong(GetHandleSize(self->ob_itself));
if (strcmp(name, "data") == 0) {
PyObject *res;
char state;
state = HGetState(self->ob_itself);
HLock(self->ob_itself);
res = PyString_FromStringAndSize(
*self->ob_itself,
GetHandleSize(self->ob_itself));
HUnlock(self->ob_itself);
HSetState(self->ob_itself, state);
return res;
}
if (strcmp(name, "__members__") == 0)
return Py_BuildValue("[ss]", "data", "size");
"""
class ResDefinition(PEP252Mixin, GlobalObjectDefinition):
getsetlist = [
('data',
"""
PyObject *res;
char state;
setattrCode = """
static int
ResObj_setattr(ResourceObject *self, char *name, PyObject *value)
{
char *data;
long size;
state = HGetState(self->ob_itself);
HLock(self->ob_itself);
res = PyString_FromStringAndSize(
*self->ob_itself,
GetHandleSize(self->ob_itself));
HUnlock(self->ob_itself);
HSetState(self->ob_itself, state);
return res;
""",
"""
char *data;
long size;
if (strcmp(name, "data") != 0 || value == NULL )
return -1;
if ( !PyString_Check(value) )
return -1;
size = PyString_Size(value);
data = PyString_AsString(value);
/* XXXX Do I need the GetState/SetState calls? */
SetHandleSize(self->ob_itself, size);
if ( MemError())
return -1;
HLock(self->ob_itself);
memcpy((char *)*self->ob_itself, data, size);
HUnlock(self->ob_itself);
/* XXXX Should I do the Changed call immedeately? */
return 0;
}
"""
class ResDefinition(GlobalObjectDefinition):
if ( v == NULL )
return -1;
if ( !PyString_Check(v) )
return -1;
size = PyString_Size(v);
data = PyString_AsString(v);
/* XXXX Do I need the GetState/SetState calls? */
SetHandleSize(self->ob_itself, size);
if ( MemError())
return -1;
HLock(self->ob_itself);
memcpy((char *)*self->ob_itself, data, size);
HUnlock(self->ob_itself);
/* XXXX Should I do the Changed call immedeately? */
return 0;
""",
'The resource data'
), (
'size',
'return PyInt_FromLong(GetHandleSize(self->ob_itself));',
None,
'The length of the resource data'
)]
def outputCheckNewArg(self):
Output("if (itself == NULL) return PyMac_Error(resNotFound);")
@ -163,12 +161,6 @@ class ResDefinition(GlobalObjectDefinition):
Output("PyErr_Clear();")
OutRbrace()
def outputGetattrHook(self):
Output(getattrHookCode)
def outputSetattr(self):
Output(setattrCode)
def outputStructMembers(self):
GlobalObjectDefinition.outputStructMembers(self)
Output("void (*ob_freeit)(%s ptr);", self.itselftype)

View File

@ -55,7 +55,7 @@ ScrapFlavorFlags = Type('ScrapFlavorFlags', 'l')
#ScrapFlavorInfo = OpaqueType('ScrapFlavorInfo', 'ScrapFlavorInfo')
putscrapbuffer = FixedInputBufferType('void *')
class MyObjectDefinition(GlobalObjectDefinition):
class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
pass
# Create the generator groups and link them

View File

@ -300,14 +300,8 @@ static PyMethodDef SndCh_methods[] = {
{NULL, NULL, 0}
};
static PyMethodChain SndCh_chain = { SndCh_methods, NULL };
#define SndCh_getsetlist NULL
static PyObject *SndCh_getattr(SndChannelObject *self, char *name)
{
return Py_FindMethodInChain(&SndCh_chain, (PyObject *)self, name);
}
#define SndCh_setattr NULL
#define SndCh_compare NULL
@ -324,14 +318,31 @@ static PyTypeObject SndChannel_Type = {
/* methods */
(destructor) SndCh_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) SndCh_getattr, /*tp_getattr*/
(setattrfunc) SndCh_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) SndCh_compare, /*tp_compare*/
(reprfunc) SndCh_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) SndCh_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
SndCh_methods, /* tp_methods */
0, /*outputHook_tp_members*/
SndCh_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* ------------------- End object type SndChannel ------------------- */
@ -391,52 +402,66 @@ static PyMethodDef SPBObj_methods[] = {
{NULL, NULL, 0}
};
static PyMethodChain SPBObj_chain = { SPBObj_methods, NULL };
static PyObject *SPBObj_getattr(SPBObject *self, char *name)
static PyObject *SPBObj_get_inRefNum(SPBObject *self, void *closure)
{
if (strcmp(name, "inRefNum") == 0)
return Py_BuildValue("l", self->ob_spb.inRefNum);
else if (strcmp(name, "count") == 0)
return Py_BuildValue("l", self->ob_spb.count);
else if (strcmp(name, "milliseconds") == 0)
return Py_BuildValue("l", self->ob_spb.milliseconds);
else if (strcmp(name, "error") == 0)
return Py_BuildValue("h", self->ob_spb.error);
return Py_FindMethodInChain(&SPBObj_chain, (PyObject *)self, name);
return Py_BuildValue("l", self->ob_spb.inRefNum);
}
static int SPBObj_setattr(SPBObject *self, char *name, PyObject *value)
static int SPBObj_set_inRefNum(SPBObject *self, PyObject *v, void *closure)
{
int rv = 0;
if (strcmp(name, "inRefNum") == 0)
rv = PyArg_Parse(value, "l", &self->ob_spb.inRefNum);
else if (strcmp(name, "count") == 0)
rv = PyArg_Parse(value, "l", &self->ob_spb.count);
else if (strcmp(name, "milliseconds") == 0)
rv = PyArg_Parse(value, "l", &self->ob_spb.milliseconds);
else if (strcmp(name, "buffer") == 0)
rv = PyArg_Parse(value, "w#", &self->ob_spb.bufferPtr, &self->ob_spb.bufferLength);
else if (strcmp(name, "completionRoutine") == 0) {
self->ob_spb.completionRoutine = NewSICompletionUPP(SPB_completion);
self->ob_completion = value;
Py_INCREF(value);
rv = 1;
#if !TARGET_API_MAC_CARBON
} else if (strcmp(name, "interruptRoutine") == 0) {
self->ob_spb.completionRoutine = NewSIInterruptUPP(SPB_interrupt);
self->ob_interrupt = value;
Py_INCREF(value);
rv = 1;
#endif
}
if ( rv ) return 0;
else return -1;
return -1 + PyArg_Parse(v, "l", &self->ob_spb.inRefNum);
return 0;
}
static PyObject *SPBObj_get_count(SPBObject *self, void *closure)
{
return Py_BuildValue("l", self->ob_spb.count);
}
static int SPBObj_set_count(SPBObject *self, PyObject *v, void *closure)
{
return -1 + PyArg_Parse(v, "l", &self->ob_spb.count);
return 0;
}
static PyObject *SPBObj_get_milliseconds(SPBObject *self, void *closure)
{
return Py_BuildValue("l", self->ob_spb.milliseconds);
}
static int SPBObj_set_milliseconds(SPBObject *self, PyObject *v, void *closure)
{
return -1 + PyArg_Parse(v, "l", &self->ob_spb.milliseconds);
return 0;
}
static PyObject *SPBObj_get_error(SPBObject *self, void *closure)
{
return Py_BuildValue("h", self->ob_spb.error);
}
#define SPBObj_set_error NULL
#define SPBObj_get_completionRoutine NULL
static int SPBObj_set_completionRoutine(SPBObject *self, PyObject *v, void *closure)
{
self->ob_spb.completionRoutine = NewSICompletionUPP(SPB_completion);
self->ob_completion = v;
Py_INCREF(v);
return 0;
return 0;
}
static PyGetSetDef SPBObj_getsetlist[] = {
{"inRefNum", (getter)SPBObj_get_inRefNum, (setter)SPBObj_set_inRefNum, NULL},
{"count", (getter)SPBObj_get_count, (setter)SPBObj_set_count, NULL},
{"milliseconds", (getter)SPBObj_get_milliseconds, (setter)SPBObj_set_milliseconds, NULL},
{"error", (getter)SPBObj_get_error, (setter)SPBObj_set_error, NULL},
{"completionRoutine", (getter)SPBObj_get_completionRoutine, (setter)SPBObj_set_completionRoutine, NULL},
};
#define SPBObj_compare NULL
#define SPBObj_repr NULL
@ -452,14 +477,31 @@ static PyTypeObject SPB_Type = {
/* methods */
(destructor) SPBObj_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) SPBObj_getattr, /*tp_getattr*/
(setattrfunc) SPBObj_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) SPBObj_compare, /*tp_compare*/
(reprfunc) SPBObj_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) SPBObj_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
SPBObj_methods, /* tp_methods */
0, /*outputHook_tp_members*/
SPBObj_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* ---------------------- End object type SPB ----------------------- */

View File

@ -211,7 +211,7 @@ SPB_interrupt(SPBPtr my_spb)
# create the module and object definition and link them
class SndObjectDefinition(ObjectDefinition):
class SndObjectDefinition(PEP252Mixin, ObjectDefinition):
def outputStructMembers(self):
ObjectDefinition.outputStructMembers(self)
@ -237,7 +237,37 @@ class SndObjectDefinition(ObjectDefinition):
#
class SpbObjectDefinition(ObjectDefinition):
class SpbObjectDefinition(PEP252Mixin, ObjectDefinition):
getsetlist = [
(
'inRefNum',
'return Py_BuildValue("l", self->ob_spb.inRefNum);',
'return -1 + PyArg_Parse(v, "l", &self->ob_spb.inRefNum);',
None,
), (
'count',
'return Py_BuildValue("l", self->ob_spb.count);',
'return -1 + PyArg_Parse(v, "l", &self->ob_spb.count);',
None
), (
'milliseconds',
'return Py_BuildValue("l", self->ob_spb.milliseconds);',
'return -1 + PyArg_Parse(v, "l", &self->ob_spb.milliseconds);',
None,
), (
'error',
'return Py_BuildValue("h", self->ob_spb.error);',
None,
None
), (
'completionRoutine',
None,
"""self->ob_spb.completionRoutine = NewSICompletionUPP(SPB_completion);
self->ob_completion = v;
Py_INCREF(v);
return 0;""",
None,
)]
def outputStructMembers(self):
Output("/* Members used to implement callbacks: */")
@ -286,54 +316,6 @@ class SpbObjectDefinition(ObjectDefinition):
Output("*p_itself = &((%s *)v)->ob_spb;", self.objecttype)
Output("return 1;")
OutRbrace()
def outputSetattr(self):
Output()
Output("static int %s_setattr(%s *self, char *name, PyObject *value)",
self.prefix, self.objecttype)
OutLbrace()
self.outputSetattrBody()
OutRbrace()
def outputSetattrBody(self):
Output("""
int rv = 0;
if (strcmp(name, "inRefNum") == 0)
rv = PyArg_Parse(value, "l", &self->ob_spb.inRefNum);
else if (strcmp(name, "count") == 0)
rv = PyArg_Parse(value, "l", &self->ob_spb.count);
else if (strcmp(name, "milliseconds") == 0)
rv = PyArg_Parse(value, "l", &self->ob_spb.milliseconds);
else if (strcmp(name, "buffer") == 0)
rv = PyArg_Parse(value, "w#", &self->ob_spb.bufferPtr, &self->ob_spb.bufferLength);
else if (strcmp(name, "completionRoutine") == 0) {
self->ob_spb.completionRoutine = NewSICompletionUPP(SPB_completion);
self->ob_completion = value;
Py_INCREF(value);
rv = 1;
#if !TARGET_API_MAC_CARBON
} else if (strcmp(name, "interruptRoutine") == 0) {
self->ob_spb.completionRoutine = NewSIInterruptUPP(SPB_interrupt);
self->ob_interrupt = value;
Py_INCREF(value);
rv = 1;
#endif
}
if ( rv ) return 0;
else return -1;""")
def outputGetattrHook(self):
Output("""
if (strcmp(name, "inRefNum") == 0)
return Py_BuildValue("l", self->ob_spb.inRefNum);
else if (strcmp(name, "count") == 0)
return Py_BuildValue("l", self->ob_spb.count);
else if (strcmp(name, "milliseconds") == 0)
return Py_BuildValue("l", self->ob_spb.milliseconds);
else if (strcmp(name, "error") == 0)
return Py_BuildValue("h", self->ob_spb.error);""")
sndobject = SndObjectDefinition('SndChannel', 'SndCh', 'SndChannelPtr')

View File

@ -850,52 +850,137 @@ static PyMethodDef TEObj_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain TEObj_chain = { TEObj_methods, NULL };
static PyObject *TEObj_getattr(TEObject *self, char *name)
static PyObject *TEObj_get_destRect(TEObject *self, void *closure)
{
if( strcmp(name, "destRect") == 0 )
return Py_BuildValue("O&", PyMac_BuildRect,
&(*self->ob_itself)->destRect);
if( strcmp(name, "viewRect") == 0 )
return Py_BuildValue("O&", PyMac_BuildRect,
&(*self->ob_itself)->viewRect);
if( strcmp(name, "selRect") == 0 )
return Py_BuildValue("O&", PyMac_BuildRect,
&(*self->ob_itself)->selRect);
if( strcmp(name, "lineHeight") == 0 )
return Py_BuildValue("h", (*self->ob_itself)->lineHeight);
if( strcmp(name, "fontAscent") == 0 )
return Py_BuildValue("h", (*self->ob_itself)->fontAscent);
if( strcmp(name, "selPoint") == 0 )
return Py_BuildValue("O&", PyMac_BuildPoint,
(*self->ob_itself)->selPoint);
if( strcmp(name, "selStart") == 0 )
return Py_BuildValue("h", (*self->ob_itself)->selStart);
if( strcmp(name, "selEnd") == 0 )
return Py_BuildValue("h", (*self->ob_itself)->selEnd);
if( strcmp(name, "active") == 0 )
return Py_BuildValue("h", (*self->ob_itself)->active);
if( strcmp(name, "just") == 0 )
return Py_BuildValue("h", (*self->ob_itself)->just);
if( strcmp(name, "teLength") == 0 )
return Py_BuildValue("h", (*self->ob_itself)->teLength);
if( strcmp(name, "txFont") == 0 )
return Py_BuildValue("h", (*self->ob_itself)->txFont);
if( strcmp(name, "txFace") == 0 )
return Py_BuildValue("h", (*self->ob_itself)->txFace);
if( strcmp(name, "txMode") == 0 )
return Py_BuildValue("h", (*self->ob_itself)->txMode);
if( strcmp(name, "txSize") == 0 )
return Py_BuildValue("h", (*self->ob_itself)->txSize);
if( strcmp(name, "nLines") == 0 )
return Py_BuildValue("h", (*self->ob_itself)->nLines);
return Py_FindMethodInChain(&TEObj_chain, (PyObject *)self, name);
return Py_BuildValue("O&", PyMac_BuildRect, &(*self->ob_itself)->destRect);
}
#define TEObj_setattr NULL
#define TEObj_set_destRect NULL
static PyObject *TEObj_get_viewRect(TEObject *self, void *closure)
{
return Py_BuildValue("O&", PyMac_BuildRect, &(*self->ob_itself)->viewRect);
}
#define TEObj_set_viewRect NULL
static PyObject *TEObj_get_selRect(TEObject *self, void *closure)
{
return Py_BuildValue("O&", PyMac_BuildRect, &(*self->ob_itself)->selRect);
}
#define TEObj_set_selRect NULL
static PyObject *TEObj_get_lineHeight(TEObject *self, void *closure)
{
return Py_BuildValue("h", (*self->ob_itself)->lineHeight);
}
#define TEObj_set_lineHeight NULL
static PyObject *TEObj_get_fontAscent(TEObject *self, void *closure)
{
return Py_BuildValue("h", (*self->ob_itself)->fontAscent);
}
#define TEObj_set_fontAscent NULL
static PyObject *TEObj_get_selPoint(TEObject *self, void *closure)
{
return Py_BuildValue("O&", PyMac_BuildPoint, (*self->ob_itself)->selPoint);
}
#define TEObj_set_selPoint NULL
static PyObject *TEObj_get_selStart(TEObject *self, void *closure)
{
return Py_BuildValue("h", (*self->ob_itself)->selStart);
}
#define TEObj_set_selStart NULL
static PyObject *TEObj_get_selEnd(TEObject *self, void *closure)
{
return Py_BuildValue("h", (*self->ob_itself)->selEnd);
}
#define TEObj_set_selEnd NULL
static PyObject *TEObj_get_active(TEObject *self, void *closure)
{
return Py_BuildValue("h", (*self->ob_itself)->active);
}
#define TEObj_set_active NULL
static PyObject *TEObj_get_just(TEObject *self, void *closure)
{
return Py_BuildValue("h", (*self->ob_itself)->just);
}
#define TEObj_set_just NULL
static PyObject *TEObj_get_teLength(TEObject *self, void *closure)
{
return Py_BuildValue("h", (*self->ob_itself)->teLength);
}
#define TEObj_set_teLength NULL
static PyObject *TEObj_get_txFont(TEObject *self, void *closure)
{
return Py_BuildValue("h", (*self->ob_itself)->txFont);
}
#define TEObj_set_txFont NULL
static PyObject *TEObj_get_txFace(TEObject *self, void *closure)
{
return Py_BuildValue("h", (*self->ob_itself)->txFace);
}
#define TEObj_set_txFace NULL
static PyObject *TEObj_get_txMode(TEObject *self, void *closure)
{
return Py_BuildValue("h", (*self->ob_itself)->txMode);
}
#define TEObj_set_txMode NULL
static PyObject *TEObj_get_txSize(TEObject *self, void *closure)
{
return Py_BuildValue("h", (*self->ob_itself)->txSize);
}
#define TEObj_set_txSize NULL
static PyObject *TEObj_get_nLines(TEObject *self, void *closure)
{
return Py_BuildValue("h", (*self->ob_itself)->nLines);
}
#define TEObj_set_nLines NULL
static PyGetSetDef TEObj_getsetlist[] = {
{"destRect", (getter)TEObj_get_destRect, (setter)TEObj_set_destRect, "Destination rectangle"},
{"viewRect", (getter)TEObj_get_viewRect, (setter)TEObj_set_viewRect, "Viewing rectangle"},
{"selRect", (getter)TEObj_get_selRect, (setter)TEObj_set_selRect, "Selection rectangle"},
{"lineHeight", (getter)TEObj_get_lineHeight, (setter)TEObj_set_lineHeight, "Height of a line"},
{"fontAscent", (getter)TEObj_get_fontAscent, (setter)TEObj_set_fontAscent, "Ascent of a line"},
{"selPoint", (getter)TEObj_get_selPoint, (setter)TEObj_set_selPoint, "Selection Point"},
{"selStart", (getter)TEObj_get_selStart, (setter)TEObj_set_selStart, "Start of selection"},
{"selEnd", (getter)TEObj_get_selEnd, (setter)TEObj_set_selEnd, "End of selection"},
{"active", (getter)TEObj_get_active, (setter)TEObj_set_active, "TBD"},
{"just", (getter)TEObj_get_just, (setter)TEObj_set_just, "Justification"},
{"teLength", (getter)TEObj_get_teLength, (setter)TEObj_set_teLength, "TBD"},
{"txFont", (getter)TEObj_get_txFont, (setter)TEObj_set_txFont, "Current font"},
{"txFace", (getter)TEObj_get_txFace, (setter)TEObj_set_txFace, "Current font variant"},
{"txMode", (getter)TEObj_get_txMode, (setter)TEObj_set_txMode, "Current text-drawing mode"},
{"txSize", (getter)TEObj_get_txSize, (setter)TEObj_set_txSize, "Current font size"},
{"nLines", (getter)TEObj_get_nLines, (setter)TEObj_set_nLines, "TBD"},
};
#define TEObj_compare NULL
@ -912,14 +997,31 @@ PyTypeObject TE_Type = {
/* methods */
(destructor) TEObj_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) TEObj_getattr, /*tp_getattr*/
(setattrfunc) TEObj_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) TEObj_compare, /*tp_compare*/
(reprfunc) TEObj_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) TEObj_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
TEObj_methods, /* tp_methods */
0, /*outputHook_tp_members*/
TEObj_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* ----------------------- End object type TE ----------------------- */

View File

@ -93,7 +93,91 @@ class TEMethodGenerator(OSErrWeakLinkMethodGenerator):
class MyObjectDefinition(GlobalObjectDefinition):
class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
# Attributes that can be set.
getsetlist = [
(
'destRect',
'return Py_BuildValue("O&", PyMac_BuildRect, &(*self->ob_itself)->destRect);',
None,
'Destination rectangle'
), (
'viewRect',
'return Py_BuildValue("O&", PyMac_BuildRect, &(*self->ob_itself)->viewRect);',
None,
'Viewing rectangle'
), (
'selRect',
'return Py_BuildValue("O&", PyMac_BuildRect, &(*self->ob_itself)->selRect);',
None,
'Selection rectangle'
), (
'lineHeight',
'return Py_BuildValue("h", (*self->ob_itself)->lineHeight);',
None,
'Height of a line'
), (
'fontAscent',
'return Py_BuildValue("h", (*self->ob_itself)->fontAscent);',
None,
'Ascent of a line'
), (
"selPoint",
'return Py_BuildValue("O&", PyMac_BuildPoint, (*self->ob_itself)->selPoint);',
None,
'Selection Point'
), (
'selStart',
'return Py_BuildValue("h", (*self->ob_itself)->selStart);',
None,
'Start of selection'
), (
'selEnd',
'return Py_BuildValue("h", (*self->ob_itself)->selEnd);',
None,
'End of selection'
), (
'active',
'return Py_BuildValue("h", (*self->ob_itself)->active);',
None,
'TBD'
), (
'just',
'return Py_BuildValue("h", (*self->ob_itself)->just);',
None,
'Justification'
), (
'teLength',
'return Py_BuildValue("h", (*self->ob_itself)->teLength);',
None,
'TBD'
), (
'txFont',
'return Py_BuildValue("h", (*self->ob_itself)->txFont);',
None,
'Current font'
), (
'txFace',
'return Py_BuildValue("h", (*self->ob_itself)->txFace);',
None,
'Current font variant'
), (
'txMode',
'return Py_BuildValue("h", (*self->ob_itself)->txMode);',
None,
'Current text-drawing mode'
), (
'txSize',
'return Py_BuildValue("h", (*self->ob_itself)->txSize);',
None,
'Current font size'
), (
'nLines',
'return Py_BuildValue("h", (*self->ob_itself)->nLines);',
None,
'TBD'
)]
def outputCheckNewArg(self):
Output("""if (itself == NULL) {
PyErr_SetString(TE_Error,"Cannot create null TE");
@ -102,45 +186,6 @@ class MyObjectDefinition(GlobalObjectDefinition):
def outputFreeIt(self, itselfname):
Output("TEDispose(%s);", itselfname)
def outputGetattrHook(self):
Output("""
if( strcmp(name, "destRect") == 0 )
return Py_BuildValue("O&", PyMac_BuildRect,
&(*self->ob_itself)->destRect);
if( strcmp(name, "viewRect") == 0 )
return Py_BuildValue("O&", PyMac_BuildRect,
&(*self->ob_itself)->viewRect);
if( strcmp(name, "selRect") == 0 )
return Py_BuildValue("O&", PyMac_BuildRect,
&(*self->ob_itself)->selRect);
if( strcmp(name, "lineHeight") == 0 )
return Py_BuildValue("h", (*self->ob_itself)->lineHeight);
if( strcmp(name, "fontAscent") == 0 )
return Py_BuildValue("h", (*self->ob_itself)->fontAscent);
if( strcmp(name, "selPoint") == 0 )
return Py_BuildValue("O&", PyMac_BuildPoint,
(*self->ob_itself)->selPoint);
if( strcmp(name, "selStart") == 0 )
return Py_BuildValue("h", (*self->ob_itself)->selStart);
if( strcmp(name, "selEnd") == 0 )
return Py_BuildValue("h", (*self->ob_itself)->selEnd);
if( strcmp(name, "active") == 0 )
return Py_BuildValue("h", (*self->ob_itself)->active);
if( strcmp(name, "just") == 0 )
return Py_BuildValue("h", (*self->ob_itself)->just);
if( strcmp(name, "teLength") == 0 )
return Py_BuildValue("h", (*self->ob_itself)->teLength);
if( strcmp(name, "txFont") == 0 )
return Py_BuildValue("h", (*self->ob_itself)->txFont);
if( strcmp(name, "txFace") == 0 )
return Py_BuildValue("h", (*self->ob_itself)->txFace);
if( strcmp(name, "txMode") == 0 )
return Py_BuildValue("h", (*self->ob_itself)->txMode);
if( strcmp(name, "txSize") == 0 )
return Py_BuildValue("h", (*self->ob_itself)->txSize);
if( strcmp(name, "nLines") == 0 )
return Py_BuildValue("h", (*self->ob_itself)->nLines);
""")
# From here on it's basically all boiler plate...

View File

@ -384,14 +384,7 @@ static PyMethodDef WEOObj_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain WEOObj_chain = { WEOObj_methods, NULL };
static PyObject *WEOObj_getattr(WEOObject *self, char *name)
{
return Py_FindMethodInChain(&WEOObj_chain, (PyObject *)self, name);
}
#define WEOObj_setattr NULL
#define WEOObj_getsetlist NULL
#define WEOObj_compare NULL
@ -408,14 +401,31 @@ PyTypeObject WEO_Type = {
/* methods */
(destructor) WEOObj_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) WEOObj_getattr, /*tp_getattr*/
(setattrfunc) WEOObj_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) WEOObj_compare, /*tp_compare*/
(reprfunc) WEOObj_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) WEOObj_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
WEOObj_methods, /* tp_methods */
0, /*outputHook_tp_members*/
WEOObj_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* ---------------------- End object type WEO ----------------------- */
@ -2096,14 +2106,7 @@ static PyMethodDef wasteObj_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain wasteObj_chain = { wasteObj_methods, NULL };
static PyObject *wasteObj_getattr(wasteObject *self, char *name)
{
return Py_FindMethodInChain(&wasteObj_chain, (PyObject *)self, name);
}
#define wasteObj_setattr NULL
#define wasteObj_getsetlist NULL
#define wasteObj_compare NULL
@ -2120,14 +2123,31 @@ PyTypeObject waste_Type = {
/* methods */
(destructor) wasteObj_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) wasteObj_getattr, /*tp_getattr*/
(setattrfunc) wasteObj_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) wasteObj_compare, /*tp_compare*/
(reprfunc) wasteObj_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) wasteObj_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
wasteObj_methods, /* tp_methods */
0, /*outputHook_tp_members*/
wasteObj_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* --------------------- End object type waste ---------------------- */

View File

@ -277,7 +277,7 @@ class WEMethodGenerator(OSErrMethodGenerator):
class WEObjectDefinition(GlobalObjectDefinition):
class WEObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
def outputCheckNewArg(self):
Output("""if (itself == NULL) {
PyErr_SetString(waste_Error,"Cannot create null WE");
@ -289,7 +289,7 @@ class WEObjectDefinition(GlobalObjectDefinition):
def outputFreeIt(self, itselfname):
Output("WEDispose(%s);", itselfname)
class WEOObjectDefinition(GlobalObjectDefinition):
class WEOObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
def outputCheckNewArg(self):
Output("""if (itself == NULL) {
Py_INCREF(Py_None);

View File

@ -2926,14 +2926,7 @@ static PyMethodDef WinObj_methods[] = {
{NULL, NULL, 0}
};
PyMethodChain WinObj_chain = { WinObj_methods, NULL };
static PyObject *WinObj_getattr(WindowObject *self, char *name)
{
return Py_FindMethodInChain(&WinObj_chain, (PyObject *)self, name);
}
#define WinObj_setattr NULL
#define WinObj_getsetlist NULL
static int WinObj_compare(WindowObject *self, WindowObject *other)
{
@ -2963,14 +2956,31 @@ PyTypeObject Window_Type = {
/* methods */
(destructor) WinObj_dealloc, /*tp_dealloc*/
0, /*tp_print*/
(getattrfunc) WinObj_getattr, /*tp_getattr*/
(setattrfunc) WinObj_setattr, /*tp_setattr*/
(getattrfunc)0, /*tp_getattr*/
(setattrfunc)0, /*tp_setattr*/
(cmpfunc) WinObj_compare, /*tp_compare*/
(reprfunc) WinObj_repr, /*tp_repr*/
(PyNumberMethods *)0, /* tp_as_number */
(PySequenceMethods *)0, /* tp_as_sequence */
(PyMappingMethods *)0, /* tp_as_mapping */
(hashfunc) WinObj_hash, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
0, /*outputHook_tp_as_buffer*/
0, /*outputHook_tp_flags*/
0, /*outputHook_tp_doc*/
0, /*outputHook_tp_traverse*/
0, /*outputHook_tp_clear*/
0, /*outputHook_tp_richcompare*/
0, /*outputHook_tp_weaklistoffset*/
0, /*outputHook_tp_iter*/
0, /*outputHook_tp_iternext*/
WinObj_methods, /* tp_methods */
0, /*outputHook_tp_members*/
WinObj_getsetlist, /*tp_getset*/
0, /*outputHook_tp_base*/
};
/* --------------------- End object type Window --------------------- */

View File

@ -128,7 +128,7 @@ initstuff = initstuff + """
PyMac_INIT_TOOLBOX_OBJECT_CONVERT(WindowPtr, WinObj_Convert);
"""
class MyObjectDefinition(GlobalObjectDefinition):
class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
def outputCheckNewArg(self):
Output("if (itself == NULL) return PyMac_Error(resNotFound);")
def outputStructMembers(self):