summaryrefslogtreecommitdiffstats
path: root/maccaml/main.c
diff options
context:
space:
mode:
authorDamien Doligez <damien.doligez-inria.fr>1998-10-02 13:02:32 +0000
committerDamien Doligez <damien.doligez-inria.fr>1998-10-02 13:02:32 +0000
commit1785aa4ef9afce6807d5d810687b376620618cf9 (patch)
treee11f59bd40aa82a9cff2f63de8ee9e9e27a619be /maccaml/main.c
parent89074600b8f8425a829f253a27580b5548fd8193 (diff)
portage MacOS standalone: T=0
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2111 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'maccaml/main.c')
-rw-r--r--maccaml/main.c130
1 files changed, 130 insertions, 0 deletions
diff --git a/maccaml/main.c b/maccaml/main.c
new file mode 100644
index 000000000..8f1a2908b
--- /dev/null
+++ b/maccaml/main.c
@@ -0,0 +1,130 @@
+/***********************************************************************/
+/* */
+/* Objective Caml */
+/* */
+/* Damien Doligez, projet Para, INRIA Rocquencourt */
+/* */
+/* Copyright 1997 Institut National de Recherche en Informatique et */
+/* en Automatique. Distributed only by permission. */
+/* */
+/***********************************************************************/
+
+/* $Id$ */
+
+#include "main.h"
+
+QDGlobals qd;
+int gHasDragAndDrop = 0;
+int gHasPowerManager = 0;
+int quit_requested = 0;
+int launch_toplevel_requested = 0;
+
+static OSErr Initialise (void)
+{
+ long gestval;
+ int i;
+ OSErr err;
+
+ SetApplLimit (GetApplLimit () - kExtraStackSpace);
+ MaxApplZone ();
+ for (i = 0; i < kMoreMasters; i++) MoreMasters ();
+ InitGraf (&qd.thePort);
+ InitFonts ();
+ InitWindows ();
+ InitMenus ();
+ TEInit ();
+ InitDialogs (nil);
+ InitCursor ();
+ FlushEvents (everyEvent, 0);
+
+ /* Unload the clipboard to disk if it's too big. */
+ if (InfoScrap ()->scrapSize > kScrapThreshold) UnloadScrap ();
+
+ /* Check for system 7. */
+ if (Gestalt (gestaltSystemVersion, &gestval) != noErr
+ || gestval < kMinSystemVersion){
+ InitCursor ();
+ StopAlert (kAlertNeedSys7, NULL);
+ ExitToShell ();
+ }
+
+ /* Check for 32-bit color QuickDraw. */
+ if (Gestalt (gestaltQuickdrawVersion, &gestval) != noErr
+ || gestval < gestalt32BitQD){
+ InitCursor ();
+ StopAlert (kAlertNeed32BitQD, NULL);
+ ExitToShell ();
+ }
+
+ /* Check for Drag Manager. */
+ if (Gestalt (gestaltDragMgrAttr, &gestval) == noErr
+ && (gestval & (1 << gestaltDragMgrPresent))
+ && (&NewDrag != NULL)){
+ gHasDragAndDrop = 1;
+ }
+
+ /* Check for Power Manager. */
+ if (Gestalt (gestaltPowerMgrAttr, &gestval) == noErr
+ && (gestval & (1 << gestaltPMgrExists))){
+ gHasPowerManager = 1;
+ }
+
+ err = InitialiseErrors ();
+ if (err != noErr) goto problem;
+
+ if (gHasDragAndDrop){
+ err = InstallDragHandlers ();
+ if (err != noErr) goto problem;
+ }
+
+ err = InitialiseEvents ();
+ if (err != noErr) goto problem;
+
+ err = InitialiseMenus ();
+ if (err != noErr) goto problem;
+
+ err = InitialiseScroll ();
+ if (err != noErr) goto problem;
+
+ err = InitialiseWindows ();
+ if (err != noErr) goto problem;
+
+ err = InitialiseModalFilter ();
+ if (err != noErr) goto problem;
+
+ ReadPrefs ();
+
+ return noErr;
+
+ problem: return err;
+}
+
+static void Finalise (void)
+{
+ if (gHasDragAndDrop) RemoveDragHandlers ();
+ WritePrefs ();
+}
+
+void main (void)
+{
+ OSErr err;
+
+ err = Initialise ();
+ if (err != noErr) ExitApplication ();
+
+ while (1){
+ GetAndProcessEvents (waitEvent, 0, 0);
+ if (launch_toplevel_requested){
+ err = launch_caml_main (); /* does not return */
+ if (err != noErr) ErrorAlertGeneric (err);
+ }
+ }
+ ExitApplication ();
+}
+
+void ExitApplication (void)
+{
+ Caml_working (0);
+ Finalise ();
+ ExitToShell ();
+}