home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / Programming / Source / winterp-1.13 / src-server / xlisp / xlinit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-04  |  10.6 KB  |  301 lines

  1. /* -*-C-*-
  2. ********************************************************************************
  3. *
  4. * File:         xlinit.c
  5. * RCS:          $Header: xlinit.c,v 1.7 91/03/24 22:24:55 mayer Exp $
  6. * Description:  xlisp initialization module
  7. * Author:       David Michael Betz
  8. * Created:      
  9. * Modified:     Fri Oct  4 04:16:38 1991 (Niels Mayer) mayer@hplnpm
  10. * Language:     C
  11. * Package:      N/A
  12. * Status:       X11r5 contrib tape release
  13. *
  14. * WINTERP Copyright 1989, 1990, 1991 Hewlett-Packard Company (by Niels Mayer).
  15. * XLISP version 2.1, Copyright (c) 1989, by David Betz.
  16. *
  17. * Permission to use, copy, modify, distribute, and sell this software and its
  18. * documentation for any purpose is hereby granted without fee, provided that
  19. * the above copyright notice appear in all copies and that both that
  20. * copyright notice and this permission notice appear in supporting
  21. * documentation, and that the name of Hewlett-Packard and David Betz not be
  22. * used in advertising or publicity pertaining to distribution of the software
  23. * without specific, written prior permission.  Hewlett-Packard and David Betz
  24. * make no representations about the suitability of this software for any
  25. * purpose. It is provided "as is" without express or implied warranty.
  26. *
  27. * HEWLETT-PACKARD AND DAVID BETZ DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
  28. * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
  29. * IN NO EVENT SHALL HEWLETT-PACKARD NOR DAVID BETZ BE LIABLE FOR ANY SPECIAL,
  30. * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  31. * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  32. * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  33. * PERFORMANCE OF THIS SOFTWARE.
  34. *
  35. * See ./winterp/COPYRIGHT for information on contacting the authors.
  36. * Please send modifications, improvements and bugfixes to mayer@hplabs.hp.com
  37. * Post XLISP-specific questions/information to the newsgroup comp.lang.lisp.x
  38. *
  39. ********************************************************************************
  40. */
  41. static char rcs_identity[] = "@(#)$Header: xlinit.c,v 1.7 91/03/24 22:24:55 mayer Exp $";
  42.  
  43. #include "xlisp.h"
  44.  
  45. /* external variables */
  46. extern LVAL true,s_dot,s_unbound;
  47. extern LVAL s_quote,s_function,s_bquote,s_comma,s_comat;
  48. extern LVAL s_lambda,s_macro;
  49. extern LVAL s_stdin,s_stdout,s_stderr,s_debugio,s_traceout;
  50. extern LVAL s_evalhook,s_applyhook,s_tracelist;
  51. extern LVAL s_tracenable,s_tlimit,s_breakenable;
  52. extern LVAL s_setf,s_car,s_cdr,s_nth,s_aref,s_get,s_eql;
  53. extern LVAL s_svalue,s_sfunction,s_splist;
  54. extern LVAL s_rtable,k_wspace,k_const,k_nmacro,k_tmacro;
  55. extern LVAL k_sescape,k_mescape;
  56. extern LVAL s_ifmt,s_ffmt,s_printcase;
  57. extern LVAL s_1plus,s_2plus,s_3plus,s_1star,s_2star,s_3star,s_minus;
  58. extern LVAL k_test,k_tnot;
  59. extern LVAL k_direction,k_input,k_output;
  60. extern LVAL k_start,k_end,k_1start,k_1end,k_2start,k_2end;
  61. extern LVAL k_verbose,k_print,k_count,k_key,k_upcase,k_downcase;
  62. extern LVAL lk_optional,lk_rest,lk_key,lk_aux,lk_allow_other_keys;
  63. extern LVAL a_subr,a_fsubr,a_cons,a_symbol;
  64. extern LVAL a_fixnum,a_flonum,a_string,a_stream,a_object;
  65. extern LVAL a_vector,a_closure,a_char,a_ustream;
  66. extern LVAL s_gcflag,s_gchook;
  67. extern FUNDEF funtab[];
  68.  
  69. #if (defined(UNIX) || defined(WINTERP))
  70. extern LVAL a_PIPE;
  71. #endif /* (defined(UNIX) || defined(WINTERP)) */
  72.  
  73. #ifdef WINTERP
  74. extern LVAL a_XtAccelerators, a_XtTranslations, a_XEvent, a_Window, a_Pixel,
  75.   a_Pixmap, a_XImage, a_XmString, a_XmFontList, a_XT_RESOURCE, a_CALLBACKOBJ,
  76.   a_TIMEOUTOBJ, a_PIXMAP_REFOBJ, a_WIDGETOBJ, a_EVHANDLEROBJ;
  77. #endif
  78.  
  79.  
  80. /* xlinit - xlisp initialization routine */
  81. xlinit()
  82. {
  83.     /* initialize xlisp (must be in this order) */
  84.     xlminit();    /* initialize xldmem.c */
  85.     xldinit();    /* initialize xldbug.c */
  86.  
  87.     /* finish initializing */
  88. #ifdef SAVERESTORE
  89.     if (!xlirestore("xlisp.wks"))
  90. #endif
  91.     initwks();
  92. }
  93.  
  94. /* initwks - build an initial workspace */
  95. LOCAL initwks()
  96. {
  97.     FUNDEF *p;
  98.     int i;
  99.     
  100.     xlsinit();    /* initialize xlsym.c */
  101.     xlsymbols();/* enter all symbols used by the interpreter */
  102.     xlrinit();    /* initialize xlread.c */
  103.     xloinit();    /* initialize xlobj.c */
  104.  
  105.     /* setup defaults */
  106.     setvalue(s_evalhook,NIL);        /* no evalhook function */
  107.     setvalue(s_applyhook,NIL);        /* no applyhook function */
  108.     setvalue(s_tracelist,NIL);        /* no functions being traced */
  109.     setvalue(s_tracenable,NIL);        /* traceback disabled */
  110.     setvalue(s_tlimit,NIL);         /* trace limit infinite */
  111.     setvalue(s_breakenable,NIL);    /* don't enter break loop on errors */
  112.     setvalue(s_gcflag,NIL);        /* don't show gc information */
  113.     setvalue(s_gchook,NIL);        /* no gc hook active */
  114.     setvalue(s_ifmt,cvstring(IFMT));    /* integer print format */
  115.     setvalue(s_ffmt,cvstring("%g"));    /* float print format */
  116.     setvalue(s_printcase,k_upcase);    /* upper case output of symbols */
  117.  
  118.     /* install the built-in functions and special forms */
  119.     for (i = 0, p = funtab; p->fd_subr != NULL; ++i, ++p)
  120.     if (p->fd_name)
  121.         xlsubr(p->fd_name,p->fd_type,p->fd_subr,i);
  122.  
  123.     /* add some synonyms */
  124.     setfunction(xlenter("NOT"),getfunction(xlenter("NULL")));
  125.     setfunction(xlenter("FIRST"),getfunction(xlenter("CAR")));
  126.     setfunction(xlenter("SECOND"),getfunction(xlenter("CADR")));
  127.     setfunction(xlenter("THIRD"),getfunction(xlenter("CADDR")));
  128.     setfunction(xlenter("FOURTH"),getfunction(xlenter("CADDDR")));
  129.     setfunction(xlenter("REST"),getfunction(xlenter("CDR")));
  130. }
  131.  
  132. /* xlsymbols - enter all of the symbols used by the interpreter */
  133. xlsymbols()
  134. {
  135. #ifndef WINTERP
  136.     LVAL sym;
  137. #endif
  138.  
  139.     /* enter the unbound variable indicator (must be first) */
  140.     s_unbound = xlenter("*UNBOUND*");
  141.     setvalue(s_unbound,s_unbound);
  142.  
  143.     /* enter the 't' symbol */
  144.     true = xlenter("T");
  145.     setvalue(true,true);
  146.  
  147.     /* enter some important symbols */
  148.     s_dot    = xlenter(".");
  149.     s_quote    = xlenter("QUOTE");
  150.     s_function    = xlenter("FUNCTION");
  151.     s_bquote    = xlenter("BACKQUOTE");
  152.     s_comma    = xlenter("COMMA");
  153.     s_comat    = xlenter("COMMA-AT");
  154.     s_lambda    = xlenter("LAMBDA");
  155.     s_macro    = xlenter("MACRO");
  156.     s_eql    = xlenter("EQL");
  157.     s_ifmt    = xlenter("*INTEGER-FORMAT*");
  158.     s_ffmt    = xlenter("*FLOAT-FORMAT*");
  159.  
  160.     /* symbols set by the read-eval-print loop */
  161.     s_1plus    = xlenter("+");
  162.     s_2plus    = xlenter("++");
  163.     s_3plus    = xlenter("+++");
  164.     s_1star    = xlenter("*");
  165.     s_2star    = xlenter("**");
  166.     s_3star    = xlenter("***");
  167.     s_minus    = xlenter("-");
  168.  
  169.     /* enter setf place specifiers */
  170.     s_setf    = xlenter("*SETF*");
  171.     s_car    = xlenter("CAR");
  172.     s_cdr    = xlenter("CDR");
  173.     s_nth    = xlenter("NTH");
  174.     s_aref    = xlenter("AREF");
  175.     s_get    = xlenter("GET");
  176.     s_svalue    = xlenter("SYMBOL-VALUE");
  177.     s_sfunction    = xlenter("SYMBOL-FUNCTION");
  178.     s_splist    = xlenter("SYMBOL-PLIST");
  179.  
  180.     /* enter the readtable variable and keywords */
  181.     s_rtable    = xlenter("*READTABLE*");
  182.     k_wspace    = xlenter(":WHITE-SPACE");
  183.     k_const    = xlenter(":CONSTITUENT");
  184.     k_nmacro    = xlenter(":NMACRO");
  185.     k_tmacro    = xlenter(":TMACRO");
  186.     k_sescape    = xlenter(":SESCAPE");
  187.     k_mescape    = xlenter(":MESCAPE");
  188.  
  189.     /* enter parameter list keywords */
  190.     k_test    = xlenter(":TEST");
  191.     k_tnot    = xlenter(":TEST-NOT");
  192.  
  193.     /* "open" keywords */
  194.     k_direction = xlenter(":DIRECTION");
  195.     k_input     = xlenter(":INPUT");
  196.     k_output    = xlenter(":OUTPUT");
  197.  
  198.     /* enter *print-case* symbol and keywords */
  199.     s_printcase = xlenter("*PRINT-CASE*");
  200.     k_upcase    = xlenter(":UPCASE");
  201.     k_downcase  = xlenter(":DOWNCASE");
  202.  
  203.     /* other keywords */
  204.     k_start    = xlenter(":START");
  205.     k_end    = xlenter(":END");
  206.     k_1start    = xlenter(":START1");
  207.     k_1end    = xlenter(":END1");
  208.     k_2start    = xlenter(":START2");
  209.     k_2end    = xlenter(":END2");
  210.     k_verbose    = xlenter(":VERBOSE");
  211.     k_print    = xlenter(":PRINT");
  212.     k_count    = xlenter(":COUNT");
  213.     k_key    = xlenter(":KEY");
  214.  
  215.     /* enter lambda list keywords */
  216.     lk_optional    = xlenter("&OPTIONAL");
  217.     lk_rest    = xlenter("&REST");
  218.     lk_key    = xlenter("&KEY");
  219.     lk_aux    = xlenter("&AUX");
  220.     lk_allow_other_keys = xlenter("&ALLOW-OTHER-KEYS");
  221.  
  222.     /* enter *standard-input*, *standard-output* and *error-output* */
  223.     s_stdin = xlenter("*STANDARD-INPUT*");
  224.     setvalue(s_stdin,cvfile(stdin));
  225.     s_stdout = xlenter("*STANDARD-OUTPUT*");
  226.     setvalue(s_stdout,cvfile(stdout));
  227.     s_stderr = xlenter("*ERROR-OUTPUT*");
  228.     setvalue(s_stderr,cvfile(stderr));
  229.  
  230.     /* enter *debug-io* and *trace-output* */
  231.     s_debugio = xlenter("*DEBUG-IO*");
  232.     setvalue(s_debugio,getvalue(s_stderr));
  233.     s_traceout = xlenter("*TRACE-OUTPUT*");
  234.     setvalue(s_traceout,getvalue(s_stderr));
  235.  
  236.     /* enter the eval and apply hook variables */
  237.     s_evalhook = xlenter("*EVALHOOK*");
  238.     s_applyhook = xlenter("*APPLYHOOK*");
  239.  
  240.     /* enter the symbol pointing to the list of functions being traced */
  241.     s_tracelist = xlenter("*TRACELIST*");
  242.  
  243.     /* enter the error traceback and the error break enable flags */
  244.     s_tracenable = xlenter("*TRACENABLE*");
  245.     s_tlimit = xlenter("*TRACELIMIT*");
  246.     s_breakenable = xlenter("*BREAKENABLE*");
  247.  
  248.     /* enter a symbol to control printing of garbage collection messages */
  249.     s_gcflag = xlenter("*GC-FLAG*");
  250.     s_gchook = xlenter("*GC-HOOK*");
  251.  
  252. #ifndef WINTERP
  253.     /* enter a copyright notice into the oblist */
  254.     sym = xlenter("**Copyright-1989-by-David-Betz**");
  255.     setvalue(sym,true);
  256. #endif
  257.  
  258.     /* enter type names */
  259.     a_subr    = xlenter("SUBR");
  260.     a_fsubr    = xlenter("FSUBR");
  261.     a_cons    = xlenter("CONS");
  262.     a_symbol    = xlenter("SYMBOL");
  263.     a_fixnum    = xlenter("FIXNUM");
  264.     a_flonum    = xlenter("FLONUM");
  265.     a_string    = xlenter("STRING");
  266.     a_object    = xlenter("OBJECT");
  267.     a_stream    = xlenter("FILE-STREAM");
  268.     a_vector    = xlenter("ARRAY");
  269.     a_closure    = xlenter("CLOSURE");
  270.     a_char      = xlenter("CHARACTER");
  271.     a_ustream    = xlenter("UNNAMED-STREAM");
  272.  
  273. #if (defined(UNIX) || defined(WINTERP))
  274.     a_PIPE = xlenter("PIPE");
  275. #endif /* (defined(UNIX) || defined(WINTERP)) */
  276.  
  277. #ifdef WINTERP
  278.     a_XtAccelerators = xlenter("XT_ACCELERATORS");
  279.     a_XtTranslations = xlenter("XT_TRANSLATIONS");
  280.     a_XEvent = xlenter("XEVENT");
  281.     a_Window = xlenter("WINDOW");
  282.     a_Pixel = xlenter("PIXEL");
  283.     a_Pixmap = xlenter("PIXMAP");
  284.     a_XImage = xlenter("XIMAGE");
  285.     a_XmString = xlenter("XM_STRING");
  286.     a_XmFontList = xlenter("XM_FONT_LIST");
  287.     a_XT_RESOURCE = xlenter("XT_RESOURCE");
  288.     a_CALLBACKOBJ = xlenter("CALLBACK_OBJ");
  289.     a_TIMEOUTOBJ = xlenter("TIMEOUT_OBJ");
  290.     a_PIXMAP_REFOBJ = xlenter("PIXMAP_REFOBJ");
  291.     a_WIDGETOBJ = xlenter("WIDGET_OBJ");
  292.     a_EVHANDLEROBJ = xlenter("EVHANDLER_OBJ");
  293. #endif
  294.  
  295.     /* add the object-oriented programming symbols and os specific stuff */
  296.     obsymbols();    /* object-oriented programming symbols */
  297.     ossymbols();    /* os specific symbols */
  298. }
  299.  
  300.