os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/mac/tclMacAppInit.c
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/mac/tclMacAppInit.c	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,213 @@
     1.4 +/* 
     1.5 + * tclMacAppInit.c --
     1.6 + *
     1.7 + *	Provides a version of the Tcl_AppInit procedure for the example shell.
     1.8 + *
     1.9 + * Copyright (c) 1993-1994 Lockheed Missle & Space Company, AI Center
    1.10 + * Copyright (c) 1995-1997 Sun Microsystems, Inc.
    1.11 + *
    1.12 + * See the file "license.terms" for information on usage and redistribution
    1.13 + * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    1.14 + *
    1.15 + * RCS: @(#) $Id: tclMacAppInit.c,v 1.9 2001/11/23 01:27:13 das Exp $
    1.16 + */
    1.17 +
    1.18 +#include "tcl.h"
    1.19 +#include "tclInt.h"
    1.20 +#include "tclPort.h"
    1.21 +#include "tclMac.h"
    1.22 +#include "tclMacInt.h"
    1.23 +
    1.24 +#if defined(THINK_C)
    1.25 +#   include <console.h>
    1.26 +#elif defined(__MWERKS__)
    1.27 +#   include <SIOUX.h>
    1.28 +EXTERN short InstallConsole _ANSI_ARGS_((short fd));
    1.29 +#endif
    1.30 +
    1.31 +#ifdef TCL_TEST
    1.32 +extern int		Procbodytest_Init _ANSI_ARGS_((Tcl_Interp *interp));
    1.33 +extern int		Procbodytest_SafeInit _ANSI_ARGS_((Tcl_Interp *interp));
    1.34 +extern int		TclObjTest_Init _ANSI_ARGS_((Tcl_Interp *interp));
    1.35 +extern int		Tcltest_Init _ANSI_ARGS_((Tcl_Interp *interp));
    1.36 +#endif /* TCL_TEST */
    1.37 +
    1.38 +/*
    1.39 + * Forward declarations for procedures defined later in this file:
    1.40 + */
    1.41 +
    1.42 +static int		MacintoshInit _ANSI_ARGS_((void));
    1.43 +
    1.44 +/*
    1.45 + *----------------------------------------------------------------------
    1.46 + *
    1.47 + * main --
    1.48 + *
    1.49 + *	Main program for tclsh.  This file can be used as a prototype
    1.50 + *	for other applications using the Tcl library.
    1.51 + *
    1.52 + * Results:
    1.53 + *	None. This procedure never returns (it exits the process when
    1.54 + *	it's done.
    1.55 + *
    1.56 + * Side effects:
    1.57 + *	This procedure initializes the Macintosh world and then 
    1.58 + *	calls Tcl_Main.  Tcl_Main will never return except to exit.
    1.59 + *
    1.60 + *----------------------------------------------------------------------
    1.61 + */
    1.62 +
    1.63 +void
    1.64 +main(
    1.65 +    int argc,				/* Number of arguments. */
    1.66 +    char **argv)			/* Array of argument strings. */
    1.67 +{
    1.68 +    char *newArgv[2];
    1.69 +    
    1.70 +    if (MacintoshInit()  != TCL_OK) {
    1.71 +	Tcl_Exit(1);
    1.72 +    }
    1.73 +
    1.74 +    argc = 1;
    1.75 +    newArgv[0] = "tclsh";
    1.76 +    newArgv[1] = NULL;
    1.77 +    Tcl_Main(argc, newArgv, Tcl_AppInit);
    1.78 +}
    1.79 +
    1.80 +/*
    1.81 + *----------------------------------------------------------------------
    1.82 + *
    1.83 + * Tcl_AppInit --
    1.84 + *
    1.85 + *	This procedure performs application-specific initialization.
    1.86 + *	Most applications, especially those that incorporate additional
    1.87 + *	packages, will have their own version of this procedure.
    1.88 + *
    1.89 + * Results:
    1.90 + *	Returns a standard Tcl completion code, and leaves an error
    1.91 + *	message in the interp's result if an error occurs.
    1.92 + *
    1.93 + * Side effects:
    1.94 + *	Depends on the startup script.
    1.95 + *
    1.96 + *----------------------------------------------------------------------
    1.97 + */
    1.98 +
    1.99 +int
   1.100 +Tcl_AppInit(
   1.101 +    Tcl_Interp *interp)		/* Interpreter for application. */
   1.102 +{
   1.103 +    if (Tcl_Init(interp) == TCL_ERROR) {
   1.104 +	return TCL_ERROR;
   1.105 +    }
   1.106 +
   1.107 +#ifdef TCL_TEST
   1.108 +    if (Tcltest_Init(interp) == TCL_ERROR) {
   1.109 +	return TCL_ERROR;
   1.110 +    }
   1.111 +    Tcl_StaticPackage(interp, "Tcltest", Tcltest_Init,
   1.112 +            (Tcl_PackageInitProc *) NULL);
   1.113 +    if (TclObjTest_Init(interp) == TCL_ERROR) {
   1.114 +	return TCL_ERROR;
   1.115 +    }
   1.116 +    if (Procbodytest_Init(interp) == TCL_ERROR) {
   1.117 +	return TCL_ERROR;
   1.118 +    }
   1.119 +    Tcl_StaticPackage(interp, "procbodytest", Procbodytest_Init,
   1.120 +            Procbodytest_SafeInit);
   1.121 +#endif /* TCL_TEST */
   1.122 +
   1.123 +    /*
   1.124 +     * Call the init procedures for included packages.  Each call should
   1.125 +     * look like this:
   1.126 +     *
   1.127 +     * if (Mod_Init(interp) == TCL_ERROR) {
   1.128 +     *     return TCL_ERROR;
   1.129 +     * }
   1.130 +     *
   1.131 +     * where "Mod" is the name of the module.
   1.132 +     */
   1.133 +
   1.134 +    /*
   1.135 +     * Call Tcl_CreateCommand for application-specific commands, if
   1.136 +     * they weren't already created by the init procedures called above.
   1.137 +     * Each call would loo like this:
   1.138 +     *
   1.139 +     * Tcl_CreateCommand(interp, "tclName", CFuncCmd, NULL, NULL);
   1.140 +     */
   1.141 +
   1.142 +    /*
   1.143 +     * Specify a user-specific startup script to invoke if the application
   1.144 +     * is run interactively.  On the Mac we can specifiy either a TEXT resource
   1.145 +     * which contains the script or the more UNIX like file location
   1.146 +     * may also used.  (I highly recommend using the resource method.)
   1.147 +     */
   1.148 +
   1.149 +    Tcl_SetVar(interp, "tcl_rcRsrcName", "tclshrc", TCL_GLOBAL_ONLY);
   1.150 +    /* Tcl_SetVar(interp, "tcl_rcFileName", "~/.tclshrc", TCL_GLOBAL_ONLY); */
   1.151 +
   1.152 +    return TCL_OK;
   1.153 +}
   1.154 +
   1.155 +/*
   1.156 + *----------------------------------------------------------------------
   1.157 + *
   1.158 + * MacintoshInit --
   1.159 + *
   1.160 + *	This procedure calls initalization routines to set up a simple
   1.161 + *	console on a Macintosh.  This is necessary as the Mac doesn't
   1.162 + *	have a stdout & stderr by default.
   1.163 + *
   1.164 + * Results:
   1.165 + *	Returns TCL_OK if everything went fine.  If it didn't the 
   1.166 + *	application should probably fail.
   1.167 + *
   1.168 + * Side effects:
   1.169 + *	Inits the appropiate console package.
   1.170 + *
   1.171 + *----------------------------------------------------------------------
   1.172 + */
   1.173 +
   1.174 +static int
   1.175 +MacintoshInit()
   1.176 +{
   1.177 +#if GENERATING68K && !GENERATINGCFM
   1.178 +    SetApplLimit(GetApplLimit() - (TCL_MAC_68K_STACK_GROWTH));
   1.179 +#endif
   1.180 +    MaxApplZone();
   1.181 +
   1.182 +#if defined(THINK_C)
   1.183 +
   1.184 +    /* Set options for Think C console package */
   1.185 +    /* The console package calls the Mac init calls */
   1.186 +    console_options.pause_atexit = 0;
   1.187 +    console_options.title = "\pTcl Interpreter";
   1.188 +		
   1.189 +#elif defined(__MWERKS__)
   1.190 +
   1.191 +    /* Set options for CodeWarrior SIOUX package */
   1.192 +    SIOUXSettings.autocloseonquit = true;
   1.193 +    SIOUXSettings.showstatusline = true;
   1.194 +    SIOUXSettings.asktosaveonclose = false;
   1.195 +    SIOUXSettings.wasteusetempmemory = true;    
   1.196 +    InstallConsole(0);
   1.197 +    SIOUXSetTitle("\pTcl Interpreter");
   1.198 +		
   1.199 +#elif defined(applec)
   1.200 +
   1.201 +    /* Init packages used by MPW SIOW package */
   1.202 +    InitGraf((Ptr)&qd.thePort);
   1.203 +    InitFonts();
   1.204 +    InitWindows();
   1.205 +    InitMenus();
   1.206 +    TEInit();
   1.207 +    InitDialogs(nil);
   1.208 +    InitCursor();
   1.209 +		
   1.210 +#endif
   1.211 +
   1.212 +    Tcl_MacSetEventProc((Tcl_MacConvertEventPtr) SIOUXHandleOneEvent);
   1.213 +    
   1.214 +    /* No problems with initialization */
   1.215 +    return TCL_OK;
   1.216 +}