diff --git a/Makefile.Mac.depend b/Makefile.Mac.depend index 5dc98297..674ae24b 100644 --- a/Makefile.Mac.depend +++ b/Makefile.Mac.depend @@ -100,12 +100,12 @@ :parsing:longident.cmi :parsing:parsetree.cmi :typing:types.cmi :typing:btype.cmoÄ :typing:path.cmi :typing:types.cmi :typing:btype.cmi :typing:btype.cmxÄ :typing:path.cmx :typing:types.cmx :typing:btype.cmi -:typing:ctype.cmoÄ :parsing:asttypes.cmi :typing:btype.cmi :typing:env.cmi ¶ - :typing:ident.cmi :utils:misc.cmi :typing:path.cmi :typing:subst.cmi ¶ - :typing:types.cmi :typing:ctype.cmi -:typing:ctype.cmxÄ :parsing:asttypes.cmi :typing:btype.cmx :typing:env.cmx ¶ - :typing:ident.cmx :utils:misc.cmx :typing:path.cmx :typing:subst.cmx ¶ - :typing:types.cmx :typing:ctype.cmi +:typing:ctype.cmoÄ :parsing:asttypes.cmi :typing:btype.cmi :utils:clflags.cmo ¶ + :typing:env.cmi :typing:ident.cmi :utils:misc.cmi :typing:path.cmi ¶ + :typing:subst.cmi :typing:types.cmi :typing:ctype.cmi +:typing:ctype.cmxÄ :parsing:asttypes.cmi :typing:btype.cmx :utils:clflags.cmx ¶ + :typing:env.cmx :typing:ident.cmx :utils:misc.cmx :typing:path.cmx ¶ + :typing:subst.cmx :typing:types.cmx :typing:ctype.cmi :typing:datarepr.cmoÄ :parsing:asttypes.cmi :utils:misc.cmi :typing:path.cmi ¶ :typing:predef.cmi :typing:types.cmi :typing:datarepr.cmi :typing:datarepr.cmxÄ :parsing:asttypes.cmi :utils:misc.cmx :typing:path.cmx ¶ diff --git a/byterun/macintosh.c b/byterun/macintosh.c index 0b775c60..5ac65cc1 100644 --- a/byterun/macintosh.c +++ b/byterun/macintosh.c @@ -11,17 +11,17 @@ /* $Id$ */ -/* Macintosh-specific stuff */ +/* MacOS-specific stuff */ + +#include +#include -#include #include #include #include -#include -#include -#include #include -#include + +#include "rotatecursor.h" /* The user interface defaults to MPW tool. The standalone application overrides the ui_* functions, as well as [main], [InitCursorCtl], @@ -35,16 +35,19 @@ void ui_exit (int return_code) int ui_read (int file_desc, char *buf, unsigned int length) { + ROTATECURSOR_MAGIC (); return read (file_desc, buf, length); } int ui_write (int file_desc, char *buf, unsigned int length) { + ROTATECURSOR_MAGIC (); return write (file_desc, buf, length); } void ui_print_stderr (char *format, void *arg) { + ROTATECURSOR_MAGIC (); fprintf (stderr, format, arg); fflush (stderr); } diff --git a/byterun/rotatecursor.c b/byterun/rotatecursor.c index 46f7d07f..d1e0042f 100644 --- a/byterun/rotatecursor.c +++ b/byterun/rotatecursor.c @@ -11,13 +11,6 @@ /* $Id$ */ -/* Rotatecursor library, written by Damien Doligez - This file is in the public domain. - version 1.7 - - See rotatecursor.h for documentation. -*/ - #include #include #include diff --git a/byterun/rotatecursor.h b/byterun/rotatecursor.h index 53414e11..cb850cd3 100644 --- a/byterun/rotatecursor.h +++ b/byterun/rotatecursor.h @@ -11,26 +11,6 @@ /* $Id$ */ -/* Rotatecursor library, written by Damien Doligez - This file is in the public domain. - version 1.7 - - The goal of this library is to help implement cooperative multitasking - for MPW tools: to make sure that your program calls RotateCursor often - enough (about 20 times per second) but not too often (to avoid a big - slowdown). It can also be used in applications as soon as you have - an implementation of InitCursorCtl and RotateCursor (which is not hard - to do). - - Simplified usage: - - 1. #include this file where appropriate - 2. Insert the following line in the inner loop(s) of your program: - ROTATECURSOR_MAGIC (); - The overhead of this macro is only a few CPU cycles, so it can be - used without problem even in a tight loop. -*/ - #ifndef _rotatecursor_ #define _rotatecursor_ diff --git a/maccaml/drag.c b/maccaml/drag.c index 7d7b4630..474f0a79 100644 --- a/maccaml/drag.c +++ b/maccaml/drag.c @@ -110,7 +110,7 @@ static pascal OSErr MyTrackingHandler (DragTrackingMessage message, WindowPtr w, static OSErr ToplevelReceiveDrag (DragReference drag, WEReference we) { - GrafPtr (saveport); + GrafPtr saveport; short readonly = 0; Boolean canaccept; OSErr err; @@ -124,8 +124,7 @@ static OSErr ToplevelReceiveDrag (DragReference drag, WEReference we) Size sz, curlen; long dest, selstart, selend = -1; - GetPort (&saveport); - SetPortWindowPort (winToplevel); + PushWindowPort (winToplevel); readonly = WEFeatureFlag (weFReadOnly, weBitTest, we); if (readonly) WEFeatureFlag (weFReadOnly, weBitClear, we); @@ -174,14 +173,14 @@ static OSErr ToplevelReceiveDrag (DragReference drag, WEReference we) WESetSelection (dest + curlen, dest + curlen, we); DisposeHandle (h); - SetPort (saveport); + PopPort; return noErr; failed: if (h != NULL) DisposeHandle (h); if (selend != -1) WESetSelection (selstart, selend, we); if (readonly) WEFeatureFlag (weFReadOnly, weBitSet, we); - SetPort (saveport); + PopPort; return err; } diff --git a/maccaml/events.c b/maccaml/events.c index 4ff54c14..2f0837f7 100644 --- a/maccaml/events.c +++ b/maccaml/events.c @@ -154,13 +154,12 @@ static void DoMouseUp (EventRecord *e) if (FrontWindow () != winGraphics) return; partCode = FindWindow (e->where, &w); if (partCode != inContent) return; - GetPort (&saveport); - SetPort (winGraphics); + PushWindowPort (winGraphics); hitpt = e->where; GlobalToLocal (&hitpt); ScrollCalcGraph (winGraphics, &r); if (PtInRect (hitpt, &r)) GraphGotEvent (e); - SetPort (saveport); + PopPort; return; } diff --git a/maccaml/graph.c b/maccaml/graph.c index 73f11964..ed2ecf69 100644 --- a/maccaml/graph.c +++ b/maccaml/graph.c @@ -184,11 +184,9 @@ void GraphGotEvent (EventRecord *evt) Point pt = evt->where; GraphEvent grevt; - GetPort (&saveport); - SetPort (winGraphics); + PushWindowPort (winGraphics); GlobalToLocal (&pt); - SetPort (saveport); - + PopPort; switch (evt->what){ case mouseDown: @@ -314,7 +312,7 @@ static void gr_check_open (void) in one major GC cycle. The GC will speed up to match this allocation speed. */ -#define Max_image_mem 1000000 /* XXX Should use 20% of total memory */ +#define Max_image_mem 1000000 /* XXX Should use user pref. */ #define Transparent (-1) @@ -974,8 +972,7 @@ value gr_wait_event (value veventlist) Point pt; gr_check_open(); - GetPort (&saveport); - SetPort (winGraphics); + PushWindowPort (winGraphics); while (veventlist != Val_int (0)) { switch (Int_val(Field (veventlist, 0))) { @@ -1017,7 +1014,7 @@ value gr_wait_event (value veventlist) /* Restore the grafport now because GetAndProcessEvents may longjmp directly out of here. */ - SetPort (saveport); + PopPort; while (1){ latestevent.valid = 0; enter_blocking_section (); diff --git a/maccaml/main.h b/maccaml/main.h index e0f3b660..e0569cac 100644 --- a/maccaml/main.h +++ b/maccaml/main.h @@ -29,9 +29,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -44,7 +46,6 @@ #include #include #include -#include #include ":WASTE-1.2:WASTE C/C++ Headers:WASTE.h" @@ -240,3 +241,11 @@ void WinGraphicsStdState (Rect *r); void WinToplevelStdState (Rect *r); void WinUpdate (WindowPtr w); void WinUpdateStatus (WindowPtr w); + +/* useful macros */ + +/* PushPort and PopPort assume that there is a local variable [saveport] */ +#define PushPort(p) do{ GetPort (&saveport); SetPort (p); }while(0) +#define PushWindowPort(w) \ + do{ GetPort (&saveport); SetPortWindowPort (w); }while(0) +#define PopPort do{ SetPort (saveport); }while(0) diff --git a/maccaml/print.c b/maccaml/print.c index 469ddc02..d7dbf5fa 100644 --- a/maccaml/print.c +++ b/maccaml/print.c @@ -13,6 +13,111 @@ #include "main.h" +static short (*get_npages) (THPrint printrec); +static short (*draw_page) (THPrint printrec, TPPrPort port, int pagenum); + +static THPrint curjobprintrec = NULL; + +/* + dojobdialog = 0 -> no job dialog (use default settings) + dojobdialog = 1 -> use job dialog + dojobdialog = 2 -> no job dialog (use previous dialog settings) +*/ +static short print_loop (int dojobdialog, THPrint docprintrec) +{ + short ncopies, fstpage, lstpage, npages; + OSErr err; + GrafPtr saveport; + TPPrPort printerport; + TPrStatus prstatus; + int copy, page, pgrun; + + GetPort (&saveport); + + PrOpen (); + err = PrError (); if (err != noErr) goto failed_PrOpen; + + PrValidate (docprintrec); + err = PrError (); if (err != noErr) goto failed_PrValidate; + + npages = (*get_npages) (docprintrec); + switch (dojobdialog){ + case 0: + if (curjobprintrec != NULL) DisposeHandle ((Handle) curjobprintrec); + curjobprintrec = (THPrint) NewHandle (sizeof (TPrint)); + if (curjobprintrec == NULL) goto failed_alloc_curjobprintrec; + PrintDefault (curjobprintrec); + PrJobMerge (curjobprintrec, docprintrec); + break; + case 1: + err = PrJobDialog (docprintrec); + if (err) goto failed_PrJobDialog; + if (curjobprintrec != NULL) DisposeHandle ((Handle) curjobprintrec); + curjobprintrec = docprintrec; + HandToHand ((Handle *) &curjobprintrec); + if (curjobprintrec == NULL) goto failed_alloc_curjobprintrec; + break; + case 2: + PrJobMerge (curjobprintrec, docprintrec); + break; + } + ncopies = (*docprintrec)->prJob.iCopies; + fstpage = (*docprintrec)->prJob.iFstPage; + lstpage = (*docprintrec)->prJob.iLstPage; + if (lstpage > npages) lstpage = npages; + + /* XXX Should display a status dialog box and use a IdleProc function */ + + for (copy = 0; copy < ncopies; copy++){ + printerport = PrOpenDoc (docprintrec, NULL, NULL); + err = PrError (); if (err != noErr) goto failed_PrOpenDoc; + pgrun = 0; + for (page = fstpage; page <= lstpage; page++){ + if (pgrun >= iPFMaxPgs){ + PrCloseDoc (printerport); + err = PrError (); if (err != noErr) goto failed_PrCloseDoc; + if ((*docprintrec)->prJob.bJDocLoop == bSpoolLoop){ + PrPicFile (docprintrec, NULL, NULL, NULL, &prstatus); + } + printerport = PrOpenDoc (docprintrec, NULL, NULL); + err = PrError (); if (err != noErr) goto failed_PrOpenDoc; + pgrun = 0; + } + PrOpenPage (printerport, NULL); + err = PrError (); if (err != noErr) goto failed_PrOpenPage; + err = (*draw_page) (docprintrec, printerport, page); + if (err != noErr) goto failed_draw_page; + PrClosePage (printerport); + ++ pgrun; + } + PrCloseDoc (printerport); + err = PrError (); if (err != noErr) goto failed_PrCloseDoc; + if ((*docprintrec)->prJob.bJDocLoop == bSpoolLoop){ + PrPicFile (docprintrec, NULL, NULL, NULL, &prstatus); + } + } + PrClose (); + /*XXX close status dialog box here */ + SetPort (saveport); + return noErr; + + failed_draw_page: + PrClosePage (printerport); + /* fall through */ + failed_PrOpenPage: + PrCloseDoc (printerport); + /* fall through */ + failed_PrOpenDoc: + failed_PrCloseDoc: + failed_alloc_curjobprintrec: + failed_PrJobDialog: + failed_PrValidate: + PrClose (); + /* fall through */ + failed_PrOpen: + return err; +} + void FilePageSetup (void) { XXX (); diff --git a/maccaml/scroll.c b/maccaml/scroll.c index 65a717d4..03919588 100644 --- a/maccaml/scroll.c +++ b/maccaml/scroll.c @@ -51,8 +51,7 @@ void AdjustScrollBars (WindowPtr w) long xmax, xval, ymax, yval; long h; - GetPort (&saveport); - SetPort (w); + PushWindowPort (w); st = WinGetStatus (w); Assert (st != NULL); @@ -83,7 +82,7 @@ void AdjustScrollBars (WindowPtr w) if (xval > xmax || yval > ymax) AdjustView (st); - SetPort (saveport); + PopPort; } /* Callback procedure for auto-scrolling the text. (called by WASTE) */ @@ -258,8 +257,7 @@ void ScrollNewSize (WindowPtr w) Assert (st != NULL); - GetPort (&saveport); - SetPort (w); + PushWindowPort (w); bar = (*st)->scrollbars[H]; r.left = port.left - 1; @@ -297,7 +295,7 @@ void ScrollNewSize (WindowPtr w) AdjustScrollBars (w); - SetPort (saveport); + PopPort; } /* Return 1 if the vertical scroll bar is at its max setting, 0 otherwise. diff --git a/maccaml/windows.c b/maccaml/windows.c index dc6f0704..8afa114b 100644 --- a/maccaml/windows.c +++ b/maccaml/windows.c @@ -91,12 +91,11 @@ void WinActivateDeactivate (int activate, WindowPtr w) WStatusH st = WinGetStatus (w); WEHandle we = WinGetWE (w); VHSelect axis; - GrafPtr savePort; + GrafPtr saveport; if (st == NULL) return; - GetPort (&savePort); - SetPort (w); + PushWindowPort (w); if (we != NULL){ if (activate) WEActivate (we); else WEDeactivate (we); @@ -118,7 +117,7 @@ void WinActivateDeactivate (int activate, WindowPtr w) */ if (GetWVariant (w) != noGrowDocProc) DrawGrowIcon (w); - SetPort (savePort); + PopPort; } void WinAdvanceTopFrontier (long length) @@ -160,12 +159,11 @@ void WinCloseGraphics (void) Assert (winGraphics != NULL); - GetPort (&saveport); - SetPort (winGraphics); + PushWindowPort (winGraphics); r = winGraphics->portRect; LocalToGlobalRect (&r); prefs.graphpos = r; - SetPort (saveport); + PopPort; DisposeWindow (winGraphics); winGraphics = NULL; @@ -177,8 +175,7 @@ void WinCloseToplevel (void) GrafPtr saveport; if (winToplevel != NULL){ - GetPort (&saveport); - SetPort (winToplevel); + PushWindowPort (winToplevel); r = winToplevel->portRect; LocalToGlobalRect (&r); @@ -186,7 +183,7 @@ void WinCloseToplevel (void) if (prefs.asksavetop){ XXX (); } - SetPort (saveport); + PopPort; } DisposeWindow (winToplevel); winToplevel = NULL; @@ -209,8 +206,7 @@ void WinDoContentClick (EventRecord *event, WindowPtr w) Point hitPt = event->where; GrafPtr saveport; - GetPort (&saveport); - SetPort (w); + PushWindowPort (w); GlobalToLocal (&hitPt); if (inback){ SelectWindow (w); @@ -223,7 +219,7 @@ void WinDoContentClick (EventRecord *event, WindowPtr w) ScrollDoClick (w, hitPt, event->modifiers); } } - SetPort (saveport); + PopPort; break; } @@ -235,8 +231,7 @@ void WinDoContentClick (EventRecord *event, WindowPtr w) WEReference we = WinGetWE (w); Assert (we != NULL); - GetPort (&saveport); - SetPort (w); + PushWindowPort (w); GlobalToLocal (&hitPt); if (inback && gHasDragAndDrop){ @@ -261,7 +256,7 @@ void WinDoContentClick (EventRecord *event, WindowPtr w) ScrollDoClick (w, hitPt, event->modifiers); } } - SetPort (saveport); + PopPort; break; } @@ -373,8 +368,7 @@ static void WinResize (WindowPtr w, short x, short y) WEReference we = WinGetWE (w); Rect r; - GetPort (&saveport); - SetPort (w); + PushWindowPort (w); /* Invalidate the old grow icon and the text margin. */ r = w->portRect; @@ -392,7 +386,7 @@ static void WinResize (WindowPtr w, short x, short y) } if (w == winGraphics) WinGraphNewSize (w); ScrollNewSize (w); - SetPort (saveport); + PopPort; } void WinDoGrow (Point where, WindowPtr w) @@ -789,8 +783,7 @@ void WinUpdate (WindowPtr w) Assert (k != kWinUnknown); - GetPort (&saveport); - SetPort (w); + PushWindowPort (w); BeginUpdate (w); updateRgn = w->visRgn; if (!EmptyRgn (updateRgn)){ @@ -801,7 +794,7 @@ void WinUpdate (WindowPtr w) if (we != NULL) WEUpdate (updateRgn, we); } EndUpdate (w); - SetPort (saveport); + PopPort; } void WinUpdateStatus (WindowPtr w) diff --git a/man/ocaml.help b/man/ocaml.help index fc20b345..466896dc 100644 --- a/man/ocaml.help +++ b/man/ocaml.help @@ -1,39 +1,116 @@ - OCaml # Objective Caml toplevel -OCaml [-I directory] [-unsafe] - -I directory # search for interface files in directory - -unsafe # suppress bound checking for arrays and strings +Usage: ocaml +options are: + -I Add to the list of include directories + -unsafe No bound checking on array and string access + -drawlambda (undocumented) + -dlambda (undocumented) + -dinstr (undocumented) + -rectypes (undocumented) - OCamlc # Objective Caml compiler -OCamlc [optionsÉ] nameÉ - -a # build a library file - -c # compile only, do not link - -cclib option # pass option to the C linker - -ccopt option # pass option to the C compiler - -i # print types - -I directory # look in directory for .cm[io] files - -o file # output to file (default a.out) - -v # print compiler version number - -unsafe # suppress bound checking for arrays and strings +Usage: ocamlc +Options are: + -a Build a library + -c Compile only (do not link) + -cc Use as the C compiler and linker + -cclib Pass option to the C linker + -ccopt Pass option to the C compiler and linker + -g Save debugging information + -i Print the types + -I Add to the list of include directories + -impl Compile as a .ml file + -intf Compile as a .mli file + -intf-suffix Suffix for interface file (default: .mli) + -intf_suffix (deprecated) same as -intf-suffix + -linkall Link all modules, even unused ones + -make-runtime Build a runtime system with given C objects and libraries + -make_runtime (deprecated) same as -make-runtime + -noassert Do not compile assertion checks + -o Set output file name to + -output-obj Output a C object file instead of an executable + -pp Pipe sources through preprocessor + -thread Use thread-safe standard library + -unsafe No bounds checking on array and string access + -use-runtime Generate bytecode for the given runtime system + -use_runtime (deprecated) same as -use-runtime + -v Print compiler version number + -verbose Print calls to external commands + -w Enable or disable warnings according to : + A/a enable/disable all warnings + C/c enable/disable suspicious comment + F/f enable/disable partially applied function + M/m enable/disable overriden method + P/p enable/disable partial match + S/s enable/disable non-unit statement + U/u enable/disable unused match case + V/v enable/disable hidden instance variable + X/x enable/disable all other warnings + default setting is A (all warnings enabled) + -nopervasives (undocumented) + -dparsetree (undocumented) + -drawlambda (undocumented) + -dlambda (undocumented) + -dinstr (undocumented) + -use-prims (undocumented) + -rectypes (undocumented) + - Treat as a file name (even if it starts with `-') - OCamlc-custom # Objective Caml compiler for custom runtime mode -OCamlc-custom [optionsÉ] nameÉ - -a # build a library file - -c # compile only, do not link - -cclib option # pass option to the C linker - -ccopt option # pass option to the C compiler - -i # print types - -I directory # look in directory for .cm[io] files - -o file # output to file (default a.out) - -v # print compiler version number - -unsafe # suppress bound checking for arrays and strings +Usage: ocamlc-custom +Options are: + -a Build a library + -c Compile only (do not link) + -cc Use as the C compiler and linker + -cclib Pass option to the C linker + -ccopt Pass option to the C compiler and linker + -g Save debugging information + -i Print the types + -I Add to the list of include directories + -impl Compile as a .ml file + -intf Compile as a .mli file + -intf-suffix Suffix for interface file (default: .mli) + -intf_suffix (deprecated) same as -intf-suffix + -linkall Link all modules, even unused ones + -make-runtime Build a runtime system with given C objects and libraries + -make_runtime (deprecated) same as -make-runtime + -noassert Do not compile assertion checks + -o Set output file name to + -output-obj Output a C object file instead of an executable + -pp Pipe sources through preprocessor + -thread Use thread-safe standard library + -unsafe No bounds checking on array and string access + -use-runtime Generate bytecode for the given runtime system + -use_runtime (deprecated) same as -use-runtime + -v Print compiler version number + -verbose Print calls to external commands + -w Enable or disable warnings according to : + A/a enable/disable all warnings + C/c enable/disable suspicious comment + F/f enable/disable partially applied function + M/m enable/disable overriden method + P/p enable/disable partial match + S/s enable/disable non-unit statement + U/u enable/disable unused match case + V/v enable/disable hidden instance variable + X/x enable/disable all other warnings + default setting is A (all warnings enabled) + -nopervasives (undocumented) + -dparsetree (undocumented) + -drawlambda (undocumented) + -dlambda (undocumented) + -dinstr (undocumented) + -use-prims (undocumented) + -rectypes (undocumented) + - Treat as a file name (even if it starts with `-') - OCamlDep # Objective Caml dependency generator -OcamlDep [-I directory] nameÉ - -I # look in directory for .cmi files +Usage: ocamldep [-I ] + -I Add to the list of include directories - OCamlLex # Objective Caml lexer generator @@ -44,6 +121,16 @@ OCamlRun # Objective Caml bytecode interpreter OCamlRun [-v] file [argumentsÉ] -v # print GC messages +Environment variable: +Set -e OCamlRunParam "