home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1993, 1994 Marc Parmet.
- * This file is part of the Macintosh port of GNU Emacs.
- *
- * GNU Emacs is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
- #if defined(THINK_C)
- #include <MacHeaders>
- #else
- #include <Types.h>
- #include <Memory.h>
- #include <Quickdraw.h>
- #include <Windows.h>
- #include <Dialogs.h>
- #include <Errors.h>
- #include <ToolUtils.h>
- #endif
-
- #include <AppleEvents.h>
- #include <AEPackObject.h>
- #include "signal.h"
- #include "config.h"
- #include "lisp.h"
- #include "buffer.h"
- #include "window.h"
- #include "termchar.h"
- #include "68k-traps.h"
-
- // This is so that we can document functions without having to remake the DOC file.
- #undef DEFUN
- #define DEFUN(lname, fnname, sname, minargs, maxargs, prompt, doc) \
- Lisp_Object fnname (); \
- struct Lisp_Subr sname = {fnname, minargs, maxargs, lname, prompt, doc }; \
- Lisp_Object fnname
-
- WindowPtr console_window(),tty_window();
- WCTabHandle console_WCTabHandle();
-
- Lisp_Object Vmodifier_vector = 0;
- Lisp_Object Vaccept_high_level_events;
- Lisp_Object Vquit_in_main_event_loop;
- Lisp_Object Vmin_stack_size;
- Lisp_Object Vpowerc;
-
- Lisp_Object Vmac_trap_code,Vmac_trap_code_end,Vmac_trap_code_max;
-
- static Lisp_Object Qchar,Qshort,Qlong,Qunsigned_char,Qunsigned_short,Qunsigned_long,
- Qverbatim_long,Qstring,Qpascal_string;
-
- static int min(a,b) { return a<b ? a : b; }
-
- int
- string_to_restype(struct Lisp_String *s)
- {
- int i,len,type;
-
- len = s->size;
- type = 0;
- for (i = 0; i<min(len,4); ++i)
- type |= s->data[i] << ((3-i) * 8);
-
- return type;
- }
-
- static Lisp_Object internal_cmd;
-
- static Lisp_Object
- pass_up_lisp_command1(void)
- {
- return Feval(internal_cmd);
- }
-
- Lisp_Object
- pass_up_lisp_command(Lisp_Object cmd)
- {
- struct gcpro gcpro1;
- extern Lisp_Object cmd_error();
- extern int waiting_for_input; // Fsignal checks this -- I don't know why
- int old_waiting_for_input;
- Lisp_Object result;
-
- internal_cmd = cmd;
- GCPRO1(internal_cmd);
- old_waiting_for_input = waiting_for_input;
- waiting_for_input = 0;
- result = internal_condition_case(pass_up_lisp_command1,Qerror,cmd_error);
- waiting_for_input = old_waiting_for_input;
- UNGCPRO;
- return result;
- }
-
- pascal short
- ae_receive_func2(AppleEvent *e_ci,AppleEvent *reply_ci,long refCon)
- {
- Lisp_Object func,err,e_li,reply_li,refCon_li;
-
- // Be careful not to evaluate the refCon twice. It was already evaluated once.
- func = Fcons(intern("ae-receive"),
- Fcons(XSET(e_li,Lisp_Int,e_ci),
- Fcons(XSET(reply_li,Lisp_Int,reply_ci),
- Fcons(Fcons(Qquote,Fcons(refCon,Qnil)),
- Qnil))));
- err = pass_up_lisp_command(func);
- return XINT(err);
- }
-
- DEFUN("string-data",Fstring_data,Sstring_data,
- 1,1,0,"Return as an integer the address of the data of STRING.")
- (s)
- {
- Lisp_Object result;
- CHECK_STRING(s,0);
- return XSET(result,Lisp_Int,(unsigned long)XSTRING(s)->data);
- }
-
- DEFUN("extract-internal",Fextract_internal,Sextract_internal,
- 3,4,0,
- "Extract from STRING, starting at byte INDEX, an integer according\012"
- "to TYPE. If TYPE is 'char, the byte at the given address is sign\012"
- "extended to a lisp integer, which is returned. If TYPE is\012"
- "'unsigned-char, the byte is zero extended. If TYPE is 'short or\012"
- "'unsigned-short, the word, either sign or zero extended, is returned.\012"
- "If TYPE is 'long or 'unsigned-long, the long word at the given address\012"
- "is returned, with a loss of some high bits. If TYPE is 'verbatim-long,\012"
- "the long word is returned verbatim, high bits included. If TYPE is 'string,\012"
- "then a string of a fourth parameter LENGTH bytes is extracted. If\012"
- "TYPE is 'pascal-string, then a pascal style string is extracted.\012"
- "STRING can also be an integer, which is interpreted as an address.")
- (string_lo,index_li,type_ls,length_li)
- {
- int index_ci;
- unsigned char *base;
- Lisp_Object t;
-
- CHECK_NUMBER(index_li,1);
- CHECK_SYMBOL(type_ls,2);
- index_ci = XINT(index_li);
-
- if (XTYPE(string_lo) == Lisp_String) {
- struct Lisp_String *string_ls = XSTRING(string_lo);
- if (index_ci < 0 || index_ci >= string_ls->size) return Qnil;
- base = string_ls->data;
- }
- else if (XTYPE(string_lo) == Lisp_Int)
- base = (unsigned char *)XPNTR(string_lo);
- else
- wrong_type_argument(Qstringp,string_lo);
-
- base += index_ci;
-
- if (type_ls == Qchar)
- return XSET(t,Lisp_Int,(long)*(char *)base);
- else if (type_ls == Qunsigned_char)
- return XSET(t,Lisp_Int,(long)(unsigned long)*(unsigned char *)base);
- else if (type_ls == Qshort)
- return XSET(t,Lisp_Int,(long)*(short *)base);
- else if (type_ls == Qunsigned_short)
- return XSET(t,Lisp_Int,(long)(unsigned long)*(unsigned short *)base);
- else if (type_ls == Qlong)
- return XSET(t,Lisp_Int,*(long *)base);
- else if (type_ls == Qunsigned_long)
- return XSET(t,Lisp_Int,*(long *)base);
- else if (type_ls == Qverbatim_long)
- return *(long *)base;
- else if (type_ls == Qstring) {
- CHECK_NUMBER(length_li,3);
- return make_string((char *)base,length_li);
- }
- else if (type_ls == Qpascal_string) {
- int length = (long)(unsigned long)*(unsigned char *)base;
- return make_string((char *)base+1,length);
- }
- else
- error("Illegal type '%s' passed to extract-internal",XSYMBOL(type_ls)->name->data);
- }
-
- DEFUN("encode-internal",Fencode_internal,Sencode_internal,
- 4,4,0,
- "Set STRING, starting at byte INDEX, using TYPE, to DATA, a lisp integer.\012"
- "If TYPE is 'char, then the low byte of DATA is written. If TYPE is\012"
- "'short, then the low word of DATA is written. If TYPE is 'long, then\012"
- "the sign bit of DATA is extended to replace the type tag before a long\012"
- "word is written. If TYPE is 'unsigned-long, the data is zero-extended.\012"
- "If TYPE is 'verbatim-long, then the data is written\012"
- "verbatim. If TYPE is 'string, then DATA must be a lisp string, and\012"
- "the contents of the string, without a terminator or length record,\012"
- "is written. STRING can also be an integer, interpreted as an address.\012\012"
- "Use of this function can easily crash Emacs or the entire machine.")
- (string_lo,index_li,type_ls,data_lo)
- {
- int i,index_ci,base_li;
- unsigned char *base;
-
- CHECK_NUMBER(index_li,1);
- CHECK_SYMBOL(type_ls,2);
- index_ci = XINT(index_li);
-
- if (XTYPE(string_lo) == Lisp_String) {
- struct Lisp_String *string_ls = XSTRING(string_lo);
- if (index_ci < 0 || index_ci >= string_ls->size) return Qnil;
- base = string_ls->data;
- }
- else if (XTYPE(string_lo) == Lisp_Int)
- base = (unsigned char *)XPNTR(string_lo);
- else
- wrong_type_argument(Qstringp,string_lo);
-
- base += index_ci;
-
- if (type_ls == Qlong)
- *(long *)base = (long)XINT(data_lo);
- else if (type_ls == Qunsigned_long)
- *(unsigned long *)base = (unsigned long)XUINT(data_lo);
- else if (type_ls == Qshort || type_ls == Qunsigned_short)
- *(short *)base = (short)XINT(data_lo);
- else if (type_ls == Qchar || type_ls == Qunsigned_char)
- *(char *)base = (char)XINT(data_lo);
- else if (type_ls == Qverbatim_long)
- *(long *)base = data_lo;
- else if (type_ls == Qstring)
- for (i = 0; i<XSTRING(data_lo)->size; ++i)
- base[i] = XSTRING(data_lo)->data[i];
- else
- error("Illegal type '%s' passed to encode-internal",XSYMBOL(type_ls)->name->data);
-
- return XSET(base_li,Lisp_Int,(int)base);
- }
-
- DEFUN("FSSpec-to-unix-filename",FFSSpec_to_unix_filename,SFSSpec_to_unix_filename,
- 1,1,0,"Given an FSSpec record encoded in a Lisp string, return\012"
- "the Unix-style filename for that FSSpec.")
- (spec_ls)
- {
- Handle filename_cs;
- FSSpec spec_c;
- int err_ci;
- Lisp_Object err_li,filename_ls;
-
- CHECK_STRING(spec_ls,0);
- if (XSTRING(spec_ls)->size != sizeof(FSSpec)) return fnfErr;
- memcpy((char *)&spec_c,(char *)XSTRING(spec_ls)->data,sizeof(FSSpec));
- err_ci = FSSpec2unixfn(&spec_c,&filename_cs);
- if (err_ci) return XSET(err_li,Lisp_Int,err_ci);
- HLock(filename_cs);
- filename_ls = make_string(*filename_cs,strlen(*filename_cs));
- DisposHandle(filename_cs);
- return filename_ls;
- }
-
- DEFUN("unix-filename-to-FSSpec-internal",Funix_filename_to_FSSpec_internal,Sunix_filename_to_FSSpec_internal,
- 1,1,0,"Given a Unix-style filename, return a FSSpec record for it,\012"
- "encoded in a Lisp string.")
- (filename)
- {
- int err1;
- FSSpec fs1;
- Lisp_Object err,fs;
-
- CHECK_STRING(filename,0);
- err1 = unixfn2FSSpec(XSTRING(filename)->data,&fs1,0);
- fs = make_string((char *)&fs1,sizeof(FSSpec));
- return Fcons(fs,XSET(err,Lisp_Int,err1));
- }
-
- /* These declarations are here especially for Think C, for which Apple events
- just weren't good enough. */
-
- #if !defined(powerc)
- static long our_a5;
- #endif
-
- enum {
- uppGetNumLinesProcInfo = kPascalStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(long)))
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(void *))),
- uppGetCharPosProcInfo = kPascalStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(long)))
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(void *)))
- | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long))),
- uppGetLineNumProcInfo = kPascalStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(short)))
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(void *)))
- | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
- | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long *)))
- };
-
- static UniversalProcPtr tc_GetNumLines_funcptr;
- static UniversalProcPtr tc_GetCharPos_funcptr;
- static UniversalProcPtr tc_GetLineNum_funcptr;
-
- static int
- tc_handler(struct buffer *b,int task,int data)
- {
- /* task == 1, return number of lines in buffer
- task == 2, given a line number, return the position of the first character of that line
- task == 3, given a character position, return the number of line it's on
- */
-
- register int i,j,nlines,s1,s2;
- register unsigned char *p1,*p2;
-
- #if !defined(powerc)
- /* We're in a weird state here. Emacs is not the current application,
- TPM is. We should be careful not to do many things, like call
- WaitNextEvent. */
- asm { move.l a5,-(a7) }
- asm { move.l our_a5,a5 }
- #endif
-
- /* Get pointers and sizes of the two strings
- that make up the visible portion of the buffer. */
-
- #define BUF_FETCH_CHAR(buf,n) *(((n)>= BUF_GPT(buf) ? BUF_GAP_SIZE(buf) : 0) + \
- (n) + BUF_BEG_ADDR(buf) - 1)
- #define BUF_BEGV_ADDR(buf) (&BUF_FETCH_CHAR(buf,(buf)->text.begv))
- #define BUF_GAP_END_ADDR(buf) ((buf)->text.beg + (buf)->text.gpt + (buf)->text.gap_size - 1)
-
- p1 = BUF_BEGV_ADDR(b);
- s1 = BUF_GPT(b) - BUF_BEGV(b);
- p2 = BUF_GAP_END_ADDR(b);
- s2 = BUF_ZV(b) - BUF_GPT(b);
- if (s1 < 0) {
- p1 = p2;
- s1 = BUF_ZV(b) - BUF_BEGV(b);
- s2 = 0;
- }
- if (s2 < 0) {
- s1 = BUF_ZV(b) - BUF_BEGV(b);
- s2 = 0;
- }
-
- i = j = 0;
- nlines = 0;
- while (i<s1) {
- if (task == 1 && nlines == data) goto finished;
- if (task == 2 && i == data) goto finished;
- if (p1[i] == '\012') ++nlines;
- ++i;
- }
- while (j<s2) {
- if (task == 1 && nlines == data) goto finished;
- if (task == 2 && i == data) goto finished;
- if (p2[j] == '\012') ++nlines;
- ++j;
- }
- if (s2 == 0 && s1 != 0) {
- if (p1[s1-1] != '\012') ++nlines;
- }
- else if (s2 != 0) {
- if (p2[s2-1] != '\012') ++nlines;
- }
-
- finished:
- #if !defined(powerc)
- asm { move.l (a7)+,a5 }
- #endif
- return (task == 1 ? i+j : nlines);
- }
-
- static pascal long
- tc_GetNumLines_func(struct buffer *b)
- {
- return tc_handler(b,0,0);
- }
-
- static pascal long
- tc_GetCharPos_func(struct buffer *b,long lineNum)
- {
- return tc_handler(b,1,lineNum);
- }
-
- static pascal short
- tc_GetLineNum_func(struct buffer *b,long charPos,long *line)
- {
- *line = tc_handler(b,2,charPos);
- return 0;
- }
-
- DEFUN("special-menu-show-stdout",Fspecial_menu_show_stdout,Sspecial_menu_show_stdout,
- 2,2,0,0)
- (menu,item)
- {
- tty_expose();
- return Qnil;
- }
-
- DEFUN("special-menu-font-change",Fspecial_menu_font_change,Sspecial_menu_font_change,
- 2,2,0,0)
- (font,size)
- {
- CHECK_NUMBER(font,0);
- CHECK_NUMBER(size,1);
- console_change_fontsize(XINT(font),XINT(size));
- return Qnil;
- }
-
- DEFUN("get-preference",Fget_preference,Sget_preference,2,2,0,
- "Return a handle to preference of type TYPE, index N in the Emacs preferences\012"
- "file. The handle returned is detached from the resource map of that file,\012"
- "and should eventually be disposed by the caller. A negative result indicates\012"
- "an error, and is an OS error code.")
- (Lisp_Object type,Lisp_Object n)
- {
- int err;
- Handle h;
- Lisp_Object result;
-
- CHECK_STRING(type,0);
- CHECK_NUMBER(n,1);
- err = get_preference(*(int *)XSTRING(type)->data,XINT(n),&h);
- return XSET(result,Lisp_Int,err ? err : (int)h);
- }
-
- DEFUN("set-preference",Fset_preference,Sset_preference,3,3,0,
- "Set preference type TYPE, index N in the Emacs preferences file to\012"
- "the data in HANDLE, replacing any such preference if it already exists.\012"
- "The handle given becomes part of the resource map of the file, and\012"
- "should not be disposed by the caller. Return OS error code.")
- (Lisp_Object type_ls,Lisp_Object n_li,Lisp_Object h_li)
- {
- Handle h_ci;
- int n_ci,type_ci;
- Lisp_Object result;
-
- CHECK_STRING(type_ls,0);
- CHECK_NUMBER(n_li,1);
- CHECK_NUMBER(h_li,2);
-
- h_ci = (Handle)XPNTR(h_li);
- n_ci = XINT(n_li);
- type_ci = *(int *)XSTRING(type_ls)->data;
- return XSET(result,Lisp_Int,set_preference(type_ci,n_ci,h_ci));
- }
-
- DEFUN("console-WindowPtr",Fconsole_WindowPtr,Sconsole_WindowPtr,0,0,0,
- "Returns a pointer to the Emacs window.")
- (void)
- {
- Lisp_Object result;
- return XSET(result,Lisp_Int,console_window());
- }
-
- DEFUN("console-WCTabHandle",Fconsole_WCTabHandle,Sconsole_WCTabHandle,0,0,0,
- "Returns a handle to a copy of the WinCTab of the Emacs\012"
- "window. Do not dispose of it.")
- (void)
- {
- Lisp_Object result;
- return XSET(result,Lisp_Int,console_WCTabHandle());
- }
-
- DEFUN("execute-68k-trap",Fexecute_68k_trap,Sexecute_68k_trap,5,5,0,"Don't ask.")
- (stack,code_base,code_offset,inregs,out)
- {
- int value,(*p)();
- unsigned char *size;
- Lisp_Object result,reglist;
- struct regs_for_68k_traps regs;
-
- /* Set up registers going into call */
- for (reglist = inregs; !NULL(reglist); reglist = Fcdr(reglist)) {
- Lisp_Object regspec = Fcar(reglist);
- unsigned char *regname = XSYMBOL(Fcar(regspec))->name->data;
- int regval = XINT(Fcar(Fcdr(regspec)));
- if (!strcmp(regname,"d0")) regs.d0 = regval;
- else if (!strcmp(regname,"d1")) regs.d1 = regval;
- else if (!strcmp(regname,"d2")) regs.d2 = regval;
- else if (!strcmp(regname,"a0")) regs.a0 = regval;
- else if (!strcmp(regname,"a1")) regs.a1 = regval;
- }
-
- p = (int (*)())((XTYPE(code_base) == Lisp_String ?
- (char *)XSTRING(code_base)->data :
- (char *)XPNTR(code_base))
- + code_offset);
-
- execute_68k_trap(p,(char *)XSTRING(stack)->data,XSTRING(stack)->size,®s);
-
- /* Extract output value */
- if (XTYPE(out) == Lisp_Symbol && !NULL(out)) {
- size = XSYMBOL(out)->name->data;
- value = regs.d0;
- }
- else if (XTYPE(out) == Lisp_Cons) {
- unsigned char *regname = XSYMBOL(Fcar(Fcdr(out)))->name->data;
- size = XSYMBOL(Fcar(out))->name->data;
- if (!strcmp(regname,"d0")) value = regs.d0;
- else if (!strcmp(regname,"d1")) value = regs.d1;
- else if (!strcmp(regname,"d2")) value = regs.d2;
- else if (!strcmp(regname,"a0")) value = regs.a0;
- else if (!strcmp(regname,"a1")) value = regs.a1;
- else return Qnil;
- }
- else
- return Qnil;
-
- if (!strcmp(size,"long"))
- return XSET(result,Lisp_Int,value);
- else if (!strcmp(size,"short"))
- return XSET(result,Lisp_Int,(long)(short)value);
- else if (!strcmp(size,"char"))
- return XSET(result,Lisp_Int,(long)(char)value);
- else
- return Qnil;
- }
-
- static pascal void
- dialog_user_item_callback(DialogPtr d,short item)
- {
- pass_up_lisp_command(Fcons(intern("dialog-user-item-callback"),
- Fcons((Lisp_Object)d,Fcons(item,Qnil))));
- }
-
- static pascal Boolean
- modal_dialog_filter_callback(DialogPtr d,EventRecord *e,short *i)
- {
- return pass_up_lisp_command(Fcons(intern("modal-dialog-filter-callback"),
- Fcons((Lisp_Object)d,Fcons((Lisp_Object)e,Fcons((Lisp_Object)i,Qnil)))));
- }
-
- void
- do_MenuSelect_before_hooks(void)
- {
- Lisp_Object result,funcname;
-
- if (!NULL(funcname = Fintern_soft(build_string("do-MenuSelect-before-hooks"),Qnil)))
- result = pass_up_lisp_command(Fcons(funcname,Qnil));
- }
-
- void
- do_menu_internal(long choice)
- {
- long now;
- short menu,item;
- Lisp_Object result,funcname;
-
- menu = HiWord(choice);
- item = LoWord(choice);
- now = TickCount();
-
- if (!NULL(funcname = Fintern_soft(build_string("do-menu"),Qnil)))
- result = pass_up_lisp_command(Fcons(funcname,
- Fcons(menu,
- Fcons(item,
- Qnil))));
- else
- result = Qnil;
-
- // Let the menu item remain highlighted for a short time
- while (now + 10 >= TickCount())
- ;
- HiliteMenu(0);
- }
-
- #if 0
-
- static void
- enable_item(long mh,int item,int enable)
- {
- if (enable)
- EnableItem((MenuHandle)mh,item);
- else
- DisableItem((MenuHandle)mh,item);
- }
-
- void
- fixup_menus()
- {
- WindowPtr fw;
- int cw,mw,lrnk,i,j,n,max,enable;
- MenuHandle mh;
- short c;
- static int last_enable = -1;
-
- fw = FrontWindow();
- cw = fw == console_window();
- mw = fw == tty_window();
- lrnk = 1;
- enable = lrnk && cw;
- if (enable == last_enable) return;
-
- // See IM pg I-346
- max = *(short *)*MenuList / 6;
- for (i = 1; i<max-2; ++i) {
- mh = *(MenuHandle *)&(*MenuList)[6 + 6*i];
- if (!pstrcmp((**mh).menuData,"\pFile")) {
- n = CountMItems(mh);
- for (j = 1; j<=n; ++j) {
- GetItemCmd(mh,j,&c);
- if (c == 'Q')
- enable_item((long)mh,j,1);
- else
- enable_item((long)mh,j,enable);
- }
- }
- else
- enable_item((long)mh,0,enable);
- }
-
- DrawMenuBar();
- last_enable = enable;
- }
-
- #endif
-
- static UserItemUPP dialog_user_item_callback_UPP;
- static ModalFilterUPP modal_dialog_filter_callback_UPP;
- static AEIdleUPP ae_send_idle_function_UPP;
- static AEEventHandlerUPP ae_receive_func_UPP;
- static UniversalProcPtr CreateObjSpecifier_UPP;
-
- enum {
- uppCreateObjSpecifierProcInfo = kPascalStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DescType)))
- | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(AEDesc *)))
- | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(DescType)))
- | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(AEDesc *)))
- | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(Boolean)))
- | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(AEDesc *)))
- };
-
- void
- init_apple(void)
- {
- long **h;
- extern pascal short ae_receive_func();
- extern pascal short ae_send_idle_function();
-
- #if !defined(powerc)
- asm { move.l a5,our_a5 }
- #endif
- tc_GetNumLines_funcptr = NewRoutineDescriptor(tc_GetNumLines_func,uppGetNumLinesProcInfo,GetCurrentISA());
- tc_GetCharPos_funcptr = NewRoutineDescriptor(tc_GetCharPos_func,uppGetCharPosProcInfo,GetCurrentISA());
- tc_GetLineNum_funcptr = NewRoutineDescriptor((long (*)())tc_GetLineNum_func,uppGetLineNumProcInfo,GetCurrentISA());
- ae_receive_func_UPP = NewAEEventHandlerProc(ae_receive_func);
- ae_send_idle_function_UPP = NewAEIdleProc(ae_send_idle_function);
- dialog_user_item_callback_UPP = NewUserItemProc(dialog_user_item_callback);
- modal_dialog_filter_callback_UPP = NewModalFilterProc(modal_dialog_filter_callback);
- CreateObjSpecifier_UPP = NewRoutineDescriptor((long (*)())CreateObjSpecifier,
- uppCreateObjSpecifierProcInfo,
- GetCurrentISA());
-
- if (initialized) {
- char *new_trap_code = NewPtr(XINT(Vmac_trap_code_max));
- if (MemError()) ExitToShell();
- memcpy((char *)new_trap_code,(char *)XSTRING(Vmac_trap_code)->data,XSTRING(Vmac_trap_code)->size);
- XSET(Vmac_trap_code,Lisp_Int,(int)new_trap_code);
- }
- else {
- Vmac_trap_code_max = 5000;
- Vmac_trap_code = make_string((char *)0,Vmac_trap_code_max);
- }
- }
-
- void
- syms_of_apple(void)
- {
- // Reloading the dump will restore this variables to the wrong values.
- // But init_apple above will fix them.
-
- DEFVAR_INT("tc:GetNumLines",(int *)&tc_GetNumLines_funcptr,0L);
- DEFVAR_INT("tc:GetCharPos",(int *)&tc_GetCharPos_funcptr,0L);
- DEFVAR_INT("tc:GetLineNum",(int *)&tc_GetLineNum_funcptr,0L);
-
- DEFVAR_INT("AESend-idle-function",(int *)&ae_send_idle_function_UPP,0L);
- DEFVAR_INT("ae-receive",(int *)&ae_receive_func_UPP,0L);
- DEFVAR_INT("dialog-user-item-callback",(int *)&dialog_user_item_callback_UPP,0L);
- DEFVAR_INT("modal-dialog-filter-callback",(int *)&modal_dialog_filter_callback_UPP,0L);
- DEFVAR_INT("CreateObjSpecifier",(int *)&CreateObjSpecifier_UPP,0L);
-
- DEFVAR_BOOL("powerc",&Vpowerc,"True if we're running on PPC architecture");
- #if defined(powerc)
- Vpowerc = 1;
- #else
- Vpowerc = 0;
- #endif
- DEFVAR_BOOL("accept-high-level-events",&Vaccept_high_level_events,0L);
- Vaccept_high_level_events = 0;
- DEFVAR_BOOL("quit-in-main-event-loop",&Vquit_in_main_event_loop,0L);
- Vquit_in_main_event_loop = 0;
- DEFVAR_INT("min-stack-size",&Vmin_stack_size,0L);
- Vmin_stack_size = MIN_STACK_SIZE;
- DEFVAR_LISP("modifier-vector",&Vmodifier_vector,0L);
-
- DEFVAR_LISP("mac-trap-code",&Vmac_trap_code,0L);
- DEFVAR_INT("mac-trap-code-max",&Vmac_trap_code_max,0L);
- DEFVAR_INT("mac-trap-code-end",&Vmac_trap_code_end,0L);
- Vmac_trap_code_end = 0;
-
- Qchar = intern("char"); staticpro(&Qchar);
- Qshort = intern("short"); staticpro(&Qshort);
- Qlong = intern("long"); staticpro(&Qlong);
- Qunsigned_char = intern("unsigned-char"); staticpro(&Qunsigned_char);
- Qunsigned_short = intern("unsigned-short"); staticpro(&Qunsigned_short);
- Qunsigned_long = intern("unsigned-long"); staticpro(&Qunsigned_long);
- Qverbatim_long = intern("verbatim-long"); staticpro(&Qverbatim_long);
- Qstring = intern("string"); staticpro(&Qstring);
- Qpascal_string = intern("pascal-string"); staticpro(&Qpascal_string);
-
- defsubr(&Sstring_data);
- defsubr(&Sextract_internal);
- defsubr(&Sencode_internal);
-
- defsubr(&Sunix_filename_to_FSSpec_internal);
- defsubr(&SFSSpec_to_unix_filename);
-
- defsubr(&Sspecial_menu_show_stdout);
- defsubr(&Sspecial_menu_font_change);
-
- defsubr(&Sget_preference);
- defsubr(&Sset_preference);
- defsubr(&Sconsole_WindowPtr);
- defsubr(&Sconsole_WCTabHandle);
- defsubr(&Sexecute_68k_trap);
- }
-