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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [itcl/] [itcl/] [unix/] [tclAppInit.c] - Blame information for rev 1773

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

Line No. Rev Author Line
1 578 markom
/*
2
 * tclAppInit.c --
3
 *
4
 *      Provides a default version of the main program and Tcl_AppInit
5
 *      procedure for Tcl applications (without Tk).
6
 *
7
 * Copyright (c) 1993 The Regents of the University of California.
8
 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
9
 *
10
 * See the file "license.terms" for information on usage and redistribution
11
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12
 *
13
 * SCCS: @(#) tclAppInit.c 1.20 97/03/24 14:29:43
14
 */
15
 
16
#ifdef TCL_XT_TEST
17
#include <X11/Intrinsic.h>
18
#endif
19
 
20
/* include tclInt.h for access to namespace API */
21
#include "tclInt.h"
22
 
23
#include "itcl.h"
24
 
25
/*
26
 * The following variable is a special hack that is needed in order for
27
 * Sun shared libraries to be used for Tcl.
28
 */
29
 
30
extern int matherr();
31
int *tclDummyMathPtr = (int *) matherr;
32
 
33
 
34
#ifdef TCL_TEST
35
EXTERN int              TclObjTest_Init _ANSI_ARGS_((Tcl_Interp *interp));
36
EXTERN int              Tcltest_Init _ANSI_ARGS_((Tcl_Interp *interp));
37
#endif /* TCL_TEST */
38
#ifdef TCL_XT_TEST
39
EXTERN int              Tclxttest_Init _ANSI_ARGS_((Tcl_Interp *interp));
40
#endif
41
 
42
/*
43
 *----------------------------------------------------------------------
44
 *
45
 * main --
46
 *
47
 *      This is the main program for the application.
48
 *
49
 * Results:
50
 *      None: Tcl_Main never returns here, so this procedure never
51
 *      returns either.
52
 *
53
 * Side effects:
54
 *      Whatever the application does.
55
 *
56
 *----------------------------------------------------------------------
57
 */
58
 
59
int
60
main(argc, argv)
61
    int argc;                   /* Number of command-line arguments. */
62
    char **argv;                /* Values of command-line arguments. */
63
{
64
#ifdef TCL_XT_TEST
65
    XtToolkitInitialize();
66
#endif
67
    Tcl_Main(argc, argv, Tcl_AppInit);
68
    return 0;                    /* Needed only to prevent compiler warning. */
69
}
70
 
71
/*
72
 *----------------------------------------------------------------------
73
 *
74
 * Tcl_AppInit --
75
 *
76
 *      This procedure performs application-specific initialization.
77
 *      Most applications, especially those that incorporate additional
78
 *      packages, will have their own version of this procedure.
79
 *
80
 * Results:
81
 *      Returns a standard Tcl completion code, and leaves an error
82
 *      message in interp->result if an error occurs.
83
 *
84
 * Side effects:
85
 *      Depends on the startup script.
86
 *
87
 *----------------------------------------------------------------------
88
 */
89
 
90
int
91
Tcl_AppInit(interp)
92
    Tcl_Interp *interp;         /* Interpreter for application. */
93
{
94
    if (Tcl_Init(interp) == TCL_ERROR) {
95
        return TCL_ERROR;
96
    }
97
 
98
#ifdef TCL_TEST
99
#ifdef TCL_XT_TEST
100
     if (Tclxttest_Init(interp) == TCL_ERROR) {
101
         return TCL_ERROR;
102
     }
103
#endif
104
    if (Tcltest_Init(interp) == TCL_ERROR) {
105
        return TCL_ERROR;
106
    }
107
    Tcl_StaticPackage(interp, "Tcltest", Tcltest_Init,
108
            (Tcl_PackageInitProc *) NULL);
109
    if (TclObjTest_Init(interp) == TCL_ERROR) {
110
        return TCL_ERROR;
111
    }
112
#endif /* TCL_TEST */
113
 
114
    /*
115
     * Call the init procedures for included packages.  Each call should
116
     * look like this:
117
     *
118
     * if (Mod_Init(interp) == TCL_ERROR) {
119
     *     return TCL_ERROR;
120
     * }
121
     *
122
     * where "Mod" is the name of the module.
123
     */
124
    if (Itcl_Init(interp) == TCL_ERROR) {
125
        return TCL_ERROR;
126
    }
127
    Tcl_StaticPackage(interp, "Itcl", Itcl_Init, Itcl_SafeInit);
128
 
129
    /*
130
     *  This is itclsh, so import all [incr Tcl] commands by
131
     *  default into the global namespace.  Fix up the autoloader
132
     *  to do the same.
133
     */
134
    if (Tcl_Import(interp, Tcl_GetGlobalNamespace(interp),
135
            "::itcl::*", /* allowOverwrite */ 1) != TCL_OK) {
136
        return TCL_ERROR;
137
    }
138
 
139
    if (Tcl_Eval(interp, "auto_mkindex_parser::slavehook { _%@namespace import -force ::itcl::* }") != TCL_OK) {
140
        return TCL_ERROR;
141
    }
142
 
143
    /*
144
     * Call Tcl_CreateCommand for application-specific commands, if
145
     * they weren't already created by the init procedures called above.
146
     */
147
 
148
    /*
149
     * Specify a user-specific startup file to invoke if the application
150
     * is run interactively.  Typically the startup file is "~/.apprc"
151
     * where "app" is the name of the application.  If this line is deleted
152
     * then no user-specific startup file will be run under any conditions.
153
     */
154
 
155
    Tcl_SetVar(interp, "tcl_rcFileName", "~/.itclshrc", TCL_GLOBAL_ONLY);
156
    return TCL_OK;
157
}

powered by: WebSVN 2.1.0

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