diff --git a/moo/lib/err.c b/moo/lib/err.c index 5299a1b..23b217c 100644 --- a/moo/lib/err.c +++ b/moo/lib/err.c @@ -208,6 +208,7 @@ const moo_ooch_t* moo_synerrnum_to_errstr (moo_synerrnum_t errnum) # include /* (SS$...) */ # include /* (lib$...) */ #elif defined(macintosh) +# include # include # include # include @@ -241,6 +242,24 @@ moo_errnum_t moo_syserr_to_errnum (int e) /*TODO: add more mappings */ default: return MOO_ESYSERR; } +#elif defined(macintosh) + switch (e) + { + case notEnoughMemoryErr: return MOO_ESYSMEM; + case paramErr: return MOO_EINVAL; + + case qErr: /* queue element not found during deletion */ + case fnfErr: /* file not found */ + case dirNFErr: /* direcotry not found */ + case resNotFound: /* resource not found */ + case resFNotFound: /* resource file not found */ + case nbpNotFound: /* name not found on remove */ + return MOO_ENOENT; + + /*TODO: add more mappings */ + default: return MOO_ESYSERR; + } + #else switch (e) { @@ -317,13 +336,13 @@ void moo_seterrwithsyserr (moo_t* moo, int syserr) if (moo->vmprim.syserrstrb) { moo->vmprim.syserrstrb (moo, syserr, moo->errmsg.tmpbuf.bch, MOO_COUNTOF(moo->errmsg.tmpbuf.bch)); - moo_seterrbfmt (moo, moo_syserr_to_errnum(errno), "%hs", moo->errmsg.tmpbuf.bch); + moo_seterrbfmt (moo, moo_syserr_to_errnum(syserr), "%hs", moo->errmsg.tmpbuf.bch); } else { MOO_ASSERT (moo, moo->vmprim.syserrstru != MOO_NULL); moo->vmprim.syserrstru (moo, syserr, moo->errmsg.tmpbuf.uch, MOO_COUNTOF(moo->errmsg.tmpbuf.uch)); - moo_seterrbfmt (moo, moo_syserr_to_errnum(errno), "%ls", moo->errmsg.tmpbuf.uch); + moo_seterrbfmt (moo, moo_syserr_to_errnum(syserr), "%ls", moo->errmsg.tmpbuf.uch); } } diff --git a/moo/lib/main-mac.c b/moo/lib/main-mac.c new file mode 100644 index 0000000..c6023c7 --- /dev/null +++ b/moo/lib/main-mac.c @@ -0,0 +1,38 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +static void InitToolBox () +{ + GrafPtr wmgrPort; + +#if defined(TARGET_API_MAC_CARBON) && (TARGET_API_MAC_CARBON > 0) + /* no init required for the managers below in Carbon */ +#else + InitGraf (&qd.thePort); + InitFonts (); + InitWindows (); + InitMenus (); + TEInit (); + InitDialogs (0L); + MaxApplZone (); +#endif + + InitCursor (); + +#if defined(TARGET_API_MAC_CARBON) && (TARGET_API_MAC_CARBON > 0) + wmgrPort = CreateNewPort(); +#else + GetWMgrPort (&wmgrPort); +#endif + + SetPort (wmgrPort); +} diff --git a/moo/lib/moo-prv.h b/moo/lib/moo-prv.h index 6bb7a3d..725a5eb 100644 --- a/moo/lib/moo-prv.h +++ b/moo/lib/moo-prv.h @@ -465,7 +465,7 @@ struct moo_initv_t enum moo_pragma_flag_t { - MOO_PRAGMA_QC = (1 << 0), + MOO_PRAGMA_QC = (1 << 0) }; struct moo_compiler_t diff --git a/moo/lib/moo.h b/moo/lib/moo.h index 9457d50..3473f7d 100644 --- a/moo/lib/moo.h +++ b/moo/lib/moo.h @@ -123,7 +123,7 @@ enum moo_trait_t MOO_NOGC = (1 << 8), /* wait for running process when exiting from the main method */ - MOO_AWAIT_PROCS = (1 << 9), + MOO_AWAIT_PROCS = (1 << 9) }; typedef enum moo_trait_t moo_trait_t; @@ -1428,7 +1428,7 @@ enum moo_log_mask_t MOO_LOG_STDOUT = (1 << 14), /* write log messages to stdout without timestamp. MOO_LOG_STDOUT wins over MOO_LOG_STDERR. */ - MOO_LOG_STDERR = (1 << 15), /* write log messages to stderr without timestamp. */ + MOO_LOG_STDERR = (1 << 15) /* write log messages to stderr without timestamp. */ }; typedef enum moo_log_mask_t moo_log_mask_t;