- Added support for optional MenuObj arguments

- Added a bunch of calls as functions with an optional
  MenuObj first argument. The same calls already
  exist as methods, but then the first arg isn't
  optional... The method versions could go as far as I'm
  concerned. Jack?
This commit is contained in:
Just van Rossum 2002-01-02 14:48:36 +00:00
parent 69ac361cb5
commit ca3cff30ec
3 changed files with 405 additions and 0 deletions

View file

@ -24,6 +24,7 @@ from macsupport import *
MenuHandle = OpaqueByValueType(OBJECTTYPE, OBJECTPREFIX)
MenuRef = MenuHandle
OptMenuRef = OpaqueByValueType(OBJECTTYPE, "Opt" + OBJECTPREFIX)
Handle = OpaqueByValueType("Handle", "ResObj")
MenuBarHandle = OpaqueByValueType("MenuBarHandle", "ResObj")
MenuID = Type("MenuID", "h")
@ -68,6 +69,28 @@ extern int _MenuObj_Convert(PyObject *, MenuHandle *);
#define as_Menu(h) ((MenuHandle)h)
#define as_Resource(h) ((Handle)h)
/* Alternative version of ResObj_New, which returns None for null argument */
PyObject *OptMenuObj_New(MenuRef itself)
{
if (itself == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
return MenuObj_New(itself);
}
int OptMenuObj_Convert(PyObject *v, MenuRef *p_itself)
{
PyObject *tmp;
if ( v == Py_None ) {
*p_itself = NULL;
return 1;
}
return MenuObj_Convert(v, p_itself);
}
"""
initstuff = initstuff + """