diff options
author | Just van Rossum <just@letterror.com> | 2002-01-02 14:48:36 (GMT) |
---|---|---|
committer | Just van Rossum <just@letterror.com> | 2002-01-02 14:48:36 (GMT) |
commit | ca3cff30ec98754e2be3887cdd3b478ceb87c0ba (patch) | |
tree | ec405cabd96156d62da844981a086dcb4d45b452 /Mac/Modules/menu/menusupport.py | |
parent | 69ac361cb54c2134a13bd27b685ba8d01e3c9aa9 (diff) | |
download | cpython-ca3cff30ec98754e2be3887cdd3b478ceb87c0ba.zip cpython-ca3cff30ec98754e2be3887cdd3b478ceb87c0ba.tar.gz cpython-ca3cff30ec98754e2be3887cdd3b478ceb87c0ba.tar.bz2 |
- 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?
Diffstat (limited to 'Mac/Modules/menu/menusupport.py')
-rw-r--r-- | Mac/Modules/menu/menusupport.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Mac/Modules/menu/menusupport.py b/Mac/Modules/menu/menusupport.py index 210a6b3..05a4412 100644 --- a/Mac/Modules/menu/menusupport.py +++ b/Mac/Modules/menu/menusupport.py @@ -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 + """ |