annotate Mac/Python/gusiconfig.cpp @ 12593:eaee924efb19 legacy-trunk

Removed string-exception preference, added tabcheck and NavService preference, upped version number.
author Jack Jansen <jack.jansen@cwi.nl>
date Fri, 05 May 2000 23:11:14 +0000
parents e367ad3ea59a
children 6b143ca4fd7f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
1 /*
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
2 * Generated with the GUSIConfig application and then hand-modified by jack.
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
3 */
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
4
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
5 #define GUSI_SOURCE
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
6 #include <GUSIConfig.h>
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
7 #include <sys/cdefs.h>
12446
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
8 #include <Resources.h>
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
9
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
10 #include "Python.h"
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
11 #include "macglue.h"
12446
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
12 #include "pythonresources.h"
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
13
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
14 static void
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
15 PyMac_GUSISpin(bool wait)
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
16 {
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
17 static Boolean inForeground = true;
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
18 int maxsleep = 6; /* 6 ticks is "normal" sleeptime */
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
19
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
20 if (PyMac_ConsoleIsDead) return;
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
21
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
22 if ( !wait )
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
23 maxsleep = 0;
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
24
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
25 PyMac_DoYield(maxsleep, 0); /* XXXX or is it safe to call python here? */
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
26 }
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
27
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
28
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
29 /* Declarations of Socket Factories */
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
30
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
31 __BEGIN_DECLS
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
32 void GUSIwithInetSockets();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
33 void GUSIwithLocalSockets();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
34 void GUSIwithMTInetSockets();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
35 void GUSIwithMTTcpSockets();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
36 void GUSIwithMTUdpSockets();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
37 void GUSIwithOTInetSockets();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
38 void GUSIwithOTTcpSockets();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
39 void GUSIwithOTUdpSockets();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
40 void GUSIwithPPCSockets();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
41 void GUSISetupFactories();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
42 __END_DECLS
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
43
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
44 /* Configure Socket Factories */
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
45
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
46 void GUSISetupFactories()
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
47 {
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
48 #ifdef GUSISetupFactories_BeginHook
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
49 GUSISetupFactories_BeginHook
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
50 #endif
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
51 GUSIwithInetSockets();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
52 #ifdef GUSISetupFactories_EndHook
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
53 GUSISetupFactories_EndHook
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
54 #endif
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
55 }
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
56
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
57 /* Declarations of File Devices */
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
58
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
59 __BEGIN_DECLS
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
60 void GUSIwithDConSockets();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
61 void GUSIwithNullSockets();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
62 void GUSISetupDevices();
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
63 __END_DECLS
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
64
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
65 /* Configure File Devices */
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
66
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
67 void GUSISetupDevices()
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
68 {
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
69 #ifdef GUSISetupDevices_BeginHook
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
70 GUSISetupDevices_BeginHook
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
71 #endif
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
72 #ifdef GUSISetupDevices_EndHook
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
73 GUSISetupDevices_EndHook
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
74 #endif
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
75 }
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
76
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
77 #ifndef __cplusplus
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
78 #error GUSISetupConfig() needs to be written in C++
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
79 #endif
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
80
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
81 GUSIConfiguration::FileSuffix sSuffices[] = {
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
82 "", '????', '????'
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
83 };
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
84 extern "C" void GUSISetupConfig()
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
85 {
12446
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
86 Handle h;
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
87 short oldrh, prefrh = -1;
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
88 short resource_id = GUSIConfiguration::kNoResource;
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
89
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
90 oldrh = CurResFile();
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
91
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
92 /* Try override from the application resource fork */
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
93 UseResFile(PyMac_AppRefNum);
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
94 h = Get1Resource('GU\267I', GUSIOPTIONSOVERRIDE_ID);
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
95 if ( h ) {
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
96 resource_id = GUSIOPTIONSOVERRIDE_ID;
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
97 } else {
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
98 /* Next try normal resource from preference file */
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
99 prefrh = PyMac_OpenPrefFile();
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
100 h = Get1Resource('GU\267I', GUSIOPTIONS_ID);
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
101 if ( h ) {
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
102 resource_id = GUSIOPTIONS_ID;
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
103 } else {
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
104 /* Finally try normal resource from application */
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
105 if ( prefrh != -1 ) {
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
106 CloseResFile(prefrh);
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
107 prefrh = -1;
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
108 }
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
109 resource_id = GUSIOPTIONS_ID;
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
110 }
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
111 }
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
112
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
113 /* Now we have the right resource file topmost and the id. Init GUSI. */
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
114 GUSIConfiguration * config =
12446
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
115 GUSIConfiguration::CreateInstance(resource_id);
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
116
12446
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
117 /* Finally restore the old resource file */
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
118 if ( prefrh != -1) CloseResFile(prefrh);
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
119 UseResFile(oldrh);
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
120
e367ad3ea59a Made the GUSI options work again with GUSI 2.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
121 config->ConfigureDefaultTypeCreator('ttxt', 'TEXT');
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
122 config->ConfigureSuffices(
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
123 sizeof(sSuffices)/sizeof(GUSIConfiguration::FileSuffix)-1, sSuffices);
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
124 config->ConfigureAutoInitGraf(false);
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
125 config->ConfigureAutoSpin(false);
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
126 config->ConfigureHandleAppleEvents(false);
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
127 config->ConfigureSigInt(false);
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
128 config->ConfigureSigPipe(true);
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
129
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
130 GUSISetHook(GUSI_SpinHook, (GUSIHook)PyMac_GUSISpin);
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
131
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
132 }
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
133
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
134 /**************** END GUSI CONFIGURATION *************************/