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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [itcl/] [itk/] [unix/] [tkAppInit.c] - Blame information for rev 578

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

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

powered by: WebSVN 2.1.0

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