summaryrefslogtreecommitdiffstats
path: root/Mac/Modules/menu
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1999-12-23 14:32:06 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1999-12-23 14:32:06 (GMT)
commita1a0fef2ea9ece5b16f9e6c37800778c64844e69 (patch)
tree6af31ec1186b5ebe0aed89f5c4159445fff61381 /Mac/Modules/menu
parent7b912120caa517ef4fa65eefc26e63f3dea8009a (diff)
downloadcpython-a1a0fef2ea9ece5b16f9e6c37800778c64844e69.zip
cpython-a1a0fef2ea9ece5b16f9e6c37800778c64844e69.tar.gz
cpython-a1a0fef2ea9ece5b16f9e6c37800778c64844e69.tar.bz2
Unified handle-conversion scheme to
handle = Ctl.as_Resource(ctl) ctl = Ctl.as_Control(handle) and similarly for List, Menu, TE. The old handle.as_Control() methods are still there for backward compatability.
Diffstat (limited to 'Mac/Modules/menu')
-rw-r--r--Mac/Modules/menu/Menumodule.c13
-rw-r--r--Mac/Modules/menu/menuedit.py11
-rw-r--r--Mac/Modules/menu/menusupport.py2
3 files changed, 13 insertions, 13 deletions
diff --git a/Mac/Modules/menu/Menumodule.c b/Mac/Modules/menu/Menumodule.c
index 52308b7..e40ace7 100644
--- a/Mac/Modules/menu/Menumodule.c
+++ b/Mac/Modules/menu/Menumodule.c
@@ -48,6 +48,7 @@ extern PyObject *WinObj_WhichWindow(WindowPtr);
#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
#define as_Menu(h) ((MenuHandle)h)
+#define as_Resource(h) ((Handle)h)
static PyObject *Menu_Error;
@@ -1123,9 +1124,13 @@ static PyObject *MenuObj_as_Resource(_self, _args)
PyObject *_args;
{
PyObject *_res = NULL;
-
- return ResObj_New((Handle)_self->ob_itself);
-
+ Handle _rv;
+ if (!PyArg_ParseTuple(_args, ""))
+ return NULL;
+ _rv = as_Resource(_self->ob_itself);
+ _res = Py_BuildValue("O&",
+ ResObj_New, _rv);
+ return _res;
}
static PyObject *MenuObj_AppendMenu(_self, _args)
@@ -1291,7 +1296,7 @@ static PyMethodDef MenuObj_methods[] = {
{"IsMenuItemIconEnabled", (PyCFunction)MenuObj_IsMenuItemIconEnabled, 1,
"(UInt16 item) -> (Boolean _rv)"},
{"as_Resource", (PyCFunction)MenuObj_as_Resource, 1,
- "Return this Menu as a Resource"},
+ "() -> (Handle _rv)"},
{"AppendMenu", (PyCFunction)MenuObj_AppendMenu, 1,
"(Str255 data) -> None"},
{"InsertMenu", (PyCFunction)MenuObj_InsertMenu, 1,
diff --git a/Mac/Modules/menu/menuedit.py b/Mac/Modules/menu/menuedit.py
index 8e7d12b..5409663 100644
--- a/Mac/Modules/menu/menuedit.py
+++ b/Mac/Modules/menu/menuedit.py
@@ -3,17 +3,10 @@ f = Function(void, 'OpenDeskAcc',
)
functions.append(f)
-f = Function(MenuHandle, 'as_Menu',
- (Handle, 'h', InMode))
+f = Function(MenuHandle, 'as_Menu', (Handle, 'h', InMode))
functions.append(f)
-as_resource_body = """
-return ResObj_New((Handle)_self->ob_itself);
-"""
-
-f = ManualGenerator("as_Resource", as_resource_body)
-f.docstring = lambda : "Return this Menu as a Resource"
-
+f = Method(Handle, 'as_Resource', (MenuHandle, 'h', InMode))
methods.append(f)
# The following have "Mac" prepended to their names in the include file
diff --git a/Mac/Modules/menu/menusupport.py b/Mac/Modules/menu/menusupport.py
index 6424ed9..b706a36 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
+Handle = OpaqueByValueType("Handle", "ResObj")
unsigned_char = Type('unsigned char', 'b')
@@ -34,6 +35,7 @@ includestuff = includestuff + """
#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
#define as_Menu(h) ((MenuHandle)h)
+#define as_Resource(h) ((Handle)h)
"""
class MyObjectDefinition(GlobalObjectDefinition):