OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tcl/] [mac/] [tclMacAppInit.c] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/*
2
 * tclMacAppInit.c --
3
 *
4
 *      Provides a version of the Tcl_AppInit procedure for the example shell.
5
 *
6
 * Copyright (c) 1993-1994 Lockheed Missle & Space Company, AI Center
7
 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
8
 *
9
 * See the file "license.terms" for information on usage and redistribution
10
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11
 *
12
 * RCS: @(#) $Id: tclMacAppInit.c,v 1.1.1.1 2002-01-16 10:25:30 markom Exp $
13
 */
14
 
15
#include "tcl.h"
16
#include "tclInt.h"
17
#include "tclPort.h"
18
#include "tclMac.h"
19
#include "tclMacInt.h"
20
 
21
#if defined(THINK_C)
22
#   include <console.h>
23
#elif defined(__MWERKS__)
24
#   include <SIOUX.h>
25
short InstallConsole _ANSI_ARGS_((short fd));
26
#endif
27
 
28
#ifdef TCL_TEST
29
EXTERN int              Procbodytest_Init _ANSI_ARGS_((Tcl_Interp *interp));
30
EXTERN int              Procbodytest_SafeInit _ANSI_ARGS_((Tcl_Interp *interp));
31
EXTERN int              TclObjTest_Init _ANSI_ARGS_((Tcl_Interp *interp));
32
EXTERN int              Tcltest_Init _ANSI_ARGS_((Tcl_Interp *interp));
33
#endif /* TCL_TEST */
34
 
35
/*
36
 * Forward declarations for procedures defined later in this file:
37
 */
38
 
39
static int              MacintoshInit _ANSI_ARGS_((void));
40
 
41
/*
42
 *----------------------------------------------------------------------
43
 *
44
 * main --
45
 *
46
 *      Main program for tclsh.  This file can be used as a prototype
47
 *      for other applications using the Tcl library.
48
 *
49
 * Results:
50
 *      None. This procedure never returns (it exits the process when
51
 *      it's done.
52
 *
53
 * Side effects:
54
 *      This procedure initializes the Macintosh world and then
55
 *      calls Tcl_Main.  Tcl_Main will never return except to exit.
56
 *
57
 *----------------------------------------------------------------------
58
 */
59
 
60
void
61
main(
62
    int argc,                           /* Number of arguments. */
63
    char **argv)                        /* Array of argument strings. */
64
{
65
    char *newArgv[2];
66
 
67
    if (MacintoshInit()  != TCL_OK) {
68
        Tcl_Exit(1);
69
    }
70
 
71
    argc = 1;
72
    newArgv[0] = "tclsh";
73
    newArgv[1] = NULL;
74
    Tcl_Main(argc, newArgv, Tcl_AppInit);
75
}
76
 
77
/*
78
 *----------------------------------------------------------------------
79
 *
80
 * Tcl_AppInit --
81
 *
82
 *      This procedure performs application-specific initialization.
83
 *      Most applications, especially those that incorporate additional
84
 *      packages, will have their own version of this procedure.
85
 *
86
 * Results:
87
 *      Returns a standard Tcl completion code, and leaves an error
88
 *      message in interp->result if an error occurs.
89
 *
90
 * Side effects:
91
 *      Depends on the startup script.
92
 *
93
 *----------------------------------------------------------------------
94
 */
95
 
96
int
97
Tcl_AppInit(
98
    Tcl_Interp *interp)         /* Interpreter for application. */
99
{
100
    if (Tcl_Init(interp) == TCL_ERROR) {
101
        return TCL_ERROR;
102
    }
103
 
104
#ifdef TCL_TEST
105
    if (Tcltest_Init(interp) == TCL_ERROR) {
106
        return TCL_ERROR;
107
    }
108
    Tcl_StaticPackage(interp, "Tcltest", Tcltest_Init,
109
            (Tcl_PackageInitProc *) NULL);
110
    if (TclObjTest_Init(interp) == TCL_ERROR) {
111
        return TCL_ERROR;
112
    }
113
    if (Procbodytest_Init(interp) == TCL_ERROR) {
114
        return TCL_ERROR;
115
    }
116
    Tcl_StaticPackage(interp, "procbodytest", Procbodytest_Init,
117
            Procbodytest_SafeInit);
118
#endif /* TCL_TEST */
119
 
120
    /*
121
     * Call the init procedures for included packages.  Each call should
122
     * look like this:
123
     *
124
     * if (Mod_Init(interp) == TCL_ERROR) {
125
     *     return TCL_ERROR;
126
     * }
127
     *
128
     * where "Mod" is the name of the module.
129
     */
130
 
131
    /*
132
     * Call Tcl_CreateCommand for application-specific commands, if
133
     * they weren't already created by the init procedures called above.
134
     * Each call would loo like this:
135
     *
136
     * Tcl_CreateCommand(interp, "tclName", CFuncCmd, NULL, NULL);
137
     */
138
 
139
    /*
140
     * Specify a user-specific startup script to invoke if the application
141
     * is run interactively.  On the Mac we can specifiy either a TEXT resource
142
     * which contains the script or the more UNIX like file location
143
     * may also used.  (I highly recommend using the resource method.)
144
     */
145
 
146
    Tcl_SetVar(interp, "tcl_rcRsrcName", "tclshrc", TCL_GLOBAL_ONLY);
147
    /* Tcl_SetVar(interp, "tcl_rcFileName", "~/.tclshrc", TCL_GLOBAL_ONLY); */
148
 
149
    return TCL_OK;
150
}
151
 
152
/*
153
 *----------------------------------------------------------------------
154
 *
155
 * MacintoshInit --
156
 *
157
 *      This procedure calls initalization routines to set up a simple
158
 *      console on a Macintosh.  This is necessary as the Mac doesn't
159
 *      have a stdout & stderr by default.
160
 *
161
 * Results:
162
 *      Returns TCL_OK if everything went fine.  If it didn't the
163
 *      application should probably fail.
164
 *
165
 * Side effects:
166
 *      Inits the appropiate console package.
167
 *
168
 *----------------------------------------------------------------------
169
 */
170
 
171
static int
172
MacintoshInit()
173
{
174
#if GENERATING68K && !GENERATINGCFM
175
    SetApplLimit(GetApplLimit() - (TCL_MAC_68K_STACK_GROWTH));
176
#endif
177
    MaxApplZone();
178
 
179
#if defined(THINK_C)
180
 
181
    /* Set options for Think C console package */
182
    /* The console package calls the Mac init calls */
183
    console_options.pause_atexit = 0;
184
    console_options.title = "\pTcl Interpreter";
185
 
186
#elif defined(__MWERKS__)
187
 
188
    /* Set options for CodeWarrior SIOUX package */
189
    SIOUXSettings.autocloseonquit = true;
190
    SIOUXSettings.showstatusline = true;
191
    SIOUXSettings.asktosaveonclose = false;
192
    InstallConsole(0);
193
    SIOUXSetTitle("\pTcl Interpreter");
194
 
195
#elif defined(applec)
196
 
197
    /* Init packages used by MPW SIOW package */
198
    InitGraf((Ptr)&qd.thePort);
199
    InitFonts();
200
    InitWindows();
201
    InitMenus();
202
    TEInit();
203
    InitDialogs(nil);
204
    InitCursor();
205
 
206
#endif
207
 
208
    Tcl_MacSetEventProc((Tcl_MacConvertEventPtr) SIOUXHandleOneEvent);
209
 
210
    /* No problems with initialization */
211
    return TCL_OK;
212
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.