annotate Mac/Modules/gestaltmodule.c @ 4566:6403c94de50d legacy-trunk

Added safeguard against failure in __del__.
author Guido van Rossum <guido@python.org>
date Wed, 27 Nov 1996 19:39:58 +0000
parents 9dc875ad050c
children 44bdf0b56c0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2392
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
1 /***********************************************************
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
3 The Netherlands.
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
4
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
5 All Rights Reserved
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
6
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
7 Permission to use, copy, modify, and distribute this software and its
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
8 documentation for any purpose and without fee is hereby granted,
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
9 provided that the above copyright notice appear in all copies and that
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
10 both that copyright notice and this permission notice appear in
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
11 supporting documentation, and that the names of Stichting Mathematisch
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
12 Centrum or CWI not be used in advertising or publicity pertaining to
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
13 distribution of the software without specific, written prior permission.
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
14
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
22
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
23 ******************************************************************/
9dc875ad050c added copyright header
Guido van Rossum <guido@python.org>
parents: 1892
diff changeset
24
1892
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
25 /* Macintosh Gestalt interface */
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
26
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 #include "allobjects.h"
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 #include "modsupport.h"
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
29
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 #include <Types.h>
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
31 #include <GestaltEqu.h>
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
32
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 static object *
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 gestalt_gestalt(self, args)
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
35 object *self;
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 object *args;
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
37 {
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
38 OSErr iErr;
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
39 char *str;
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
40 int size;
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
41 OSType selector;
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
42 long response;
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
43 if (!getargs(args, "s#", &str, &size))
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
44 return NULL;
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
45 if (size != 4) {
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
46 err_setstr(TypeError, "gestalt arg must be 4-char string");
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
47 return NULL;
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
48 }
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
49 selector = *(OSType*)str;
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 iErr = Gestalt ( selector, &response );
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
51 if (iErr != 0) {
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
52 char buf[100];
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
53 sprintf(buf, "Gestalt error code %d", iErr);
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
54 err_setstr(RuntimeError, buf);
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
55 return NULL;
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
56 }
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
57 return newintobject(response);
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
58 }
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
59
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
60 static struct methodlist gestalt_methods[] = {
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
61 {"gestalt", gestalt_gestalt},
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
62 {NULL, NULL} /* Sentinel */
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
63 };
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
64
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
65 void
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
66 initgestalt()
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
67 {
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
68 initmodule("gestalt", gestalt_methods);
eec0dc5aba60 gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff changeset
69 }