home *** CD-ROM | disk | FTP | other *** search
- /************************************************************
- *
- * Created: Thursday, December 3, 1992 11:57:00 AM
- * NeoMacintosh.h
- * Macintosh-specific definitions for NeoLogic products
- *
- * Copyright © Neologic Systems 1992-1994. All Rights Reserved.
- * All rights reserved
- *
- ***********************************************************/
- #pragma once
- #ifndef __NeoMacintosh__
- #define __NeoMacintosh__ 1
-
- #if defined(__powerc) || defined(powerc)
- #define qNeoPowerPC 1
- #else
- #undef qNeoPowerPC
- #endif
-
- #define CNeoAppH "CNeoApp.h"
- #define CNeoArrayH "CNeoArray.h"
- #define CNeoBlobH "CNeoBlob.h"
- #define CNeoClassH "CNeoClass.h"
- #define CNeoDatabaseH "CNeoDatabase.h"
- #define CNeoDocH "CNeoDoc.h"
- #define CNeoFileStreamH "CNeoFileStream.h"
- #define CNeoIndexIteratorH "CNeoIndexIterator.h"
- #define CNeoFreeListH "CNeoFreeList.h"
- #define CNeoIDIndexH "CNeoIDIndex.h"
- #define CNeoIDListH "CNeoIDList.h"
- #define CNeoIOBlockH "CNeoIOBlock.h"
- #define CNeoIteratorH "CNeoIterator.h"
- #define CNeoInodeH "CNeoInode.h"
- #define CNeoMetaClassH "CNeoMetaClass.h"
- #define CNeoNamedOffspringH "CNeoNamedOffspring.h"
- #define CNeoNodeH "CNeoNode.h"
- #define CNeoObjectH "CNeoObject.h"
- #define CNeoOffspringH "CNeoOffspring.h"
- #define CNeoParentIndexH "CNeoParentIndex.h"
- #define CNeoParentNNameIndexH "CNeoParentNNameIndex.h"
- #define CNeoPartListIteratorH "CNeoPartListIterator.h"
- #define CNeoPartMgrH "CNeoPartMgr.h"
- #define CNeoPersistH "CNeoPersist.h"
- #define CNeoSelectH "CNeoSelect.h"
- #define CNeoContainerStreamH "CNeoContainerStream.h"
- #define CNeoStreamH "CNeoStream.h"
- #define CNeoSubclassH "CNeoSubclass.h"
- #define CNeoSwizzlerH "CNeoSwizzler.h"
- #define CNeoTransactionH "CNeoTransaction.h"
- #define NeoFailureH "NeoFailure.h"
-
- #define NeoTime time_t
-
- #ifdef CallGrowZoneProc
- #define qNeoUniversalHeaders 1
- #else
- #undef qNeoUniversalHeaders
- #endif
-
- // !@#$ Apple! Make a change but don't tell anybody until it's on our doorstep!
- //
- // So, Apple has decided that they want to change the DisposHandle (and friends)
- // to DisposeHandle in Memory.h. All these jirations below is our attempt to use
- // the right symbol given all possible header file combinations.
- //
- // The logic here is: If qNeoUniversalHeaders is defined, then these are the new
- // headers with the changed names. We undef first just in case.
- #ifdef qNeoUniversalHeaders
- #undef DisposPtr
- #undef DisposHandle
- #undef ReallocHandle
-
- #define DisposPtr(p) DisposePtr(p)
- #define DisposHandle(h) DisposeHandle(h)
- #define ReallocHandle(h, byteCount) ReallocateHandle(h, byteCount)
- #endif
-
- #define qNeoMacintosh 1
-
- #define NeoIOParams ParamBlockRec
-
- enum {kNeoCacheSize = 0x80000};
-
- const unsigned char kNeoLeafMask = 0x80; // Mask for determining if node is a leaf
-
- #define Neo4CharConst(p1, p2) ((((unsigned long)(p1))<<16) | ((unsigned short)(p2)))
-
- #define NeoSize Size
-
- typedef SignedByte NeoPerms;
-
- #define NeoStreamRefNum short
- #define NeoFileSpec FSSpec
- #define NeoReadPerm fsRdPerm
- #define NeoWritePerm fsWrPerm
- #define NeoReadWritePerm fsRdWrPerm
- #define NeoReadWriteSharedPerm fsRdPerm
-
- // Macros for dealing with files
- #define NeoGetFileName(n) (n) = (unsigned char *)fFileSpec.name
- #define NeoGetFilePath(n) (n) = (unsigned char *)fFileSpec.name
- #define NeoCreateFile(c, t) FailOSErr(FSpCreate(&fFileSpec, (c), (t), smCurrentScript))
- #define NeoDeleteFile() FSpDelete(&fFileSpec)
- #define NeoOpenFile(p) FailOSErr(FSpOpenDF(&fFileSpec, (p), &fRefNum))
- #define NeoCloseFile() FailOSErr(FSClose(fRefNum)); fRefNum = 0
- #define NeoGetFileLength(l) FailOSErr(GetEOF(fRefNum, &(l)))
- #define NeoSetFileLength(l) FailOSErr(SetEOF(fRefNum, (l)))
- #define NeoGetFileMark(m) FailOSErr(GetFPos(fRefNum, &(m)))
- #define NeoSetFileMark(m) FailOSErr(SetFPos(fRefNum, fsFromStart, (m)))
- #define NeoReadFile(b, l) FailOSErr(FSRead(fRefNum, &(l), (b)))
- #define NeoWriteFile(b, l) FailOSErr(FSWrite(fRefNum, &(l), (b)))
- #define NeoGetFileSpecName(n) NeoStringCopy(fFileSpec.name, (unsigned char *)(n))
- #define NeoGetFileSpecPath(p) NeoStringCopy(fFileSpec.name, (unsigned char *)(p))
- #define NeoSetFileSpecPath(p) NeoStringCopy((unsigned char *)(p), fFileSpec.name)
- #define NeoFileExists(b) { \
- FInfo fileInfo; \
- b = (::HGetFInfo(fFileSpec.vRefNum, fFileSpec.parID, fFileSpec.name, &fileInfo) == kNeoNoErr); \
- }
- #define NeoFlushFile() if (fRefNum) { \
- IOParam pb; \
- pb.ioCompletion = nil; \
- pb.ioRefNum = fRefNum; \
- FailOSErr(PBFlushFile((ParmBlkPtr)&pb, FALSE)); \
- }
- #define NeoCompareFileSpec(s1, s2) \
- ((s1).vRefNum == (s2).vRefNum && \
- (s1).parID == (s2).parID && \
- IUEqualPString((s1).name, (s2).name, nil) == 0) \
-
- #define NeoSwapShort(x)
- #define NeoSwapShortInto(s, d) ((* (short *) (&(d)) = (* (short *) (&(s)))))
- #define NeoSwapLong(x)
- #define NeoSwapLongInto(s, d) ((* (long *) (&(d)) = (* (long *) (&(s)))))
-
- #define kNeoNullName "\p"
-
- #define NeoBlob void **
- #define NeoBlobGetPtr(b) ((Ptr)*(b))
- #define NeoBlobMalloc(n) ((NeoBlob)NewHandle(n))
- #define NeoBlobFree(p) DisposHandle((Handle)(p))
- #define NeoBlobGetSize(x) GetHandleSize((Handle)(x))
-
- #ifdef qNeoUniversalHeaders
- // #include <TextUtils.h>
- #endif
-
- #include "NeoMacMetro.h"
-
- #include <AppleEvents.h>
- #include <AERegistry.h>
-
- const NeoTag kNeoBooleanType = typeBoolean;
- const NeoTag kNeoDoubleType = 'dbl '; // really should be typeLongFloat
- const NeoTag kNeoFloatType = typeFloat;
- const NeoTag kNeoLongType = typeLongInteger;
- const NeoTag kNeoLongDoubleType = typeExtended;
- const NeoTag kNeoNativeStringType = typeChar;
- const NeoTag kNeoShortType = typeShortInteger;
- const NeoTag kNeoStringType = 'text'; // really should be type Char
-
- #define pNeoID pID
- #define pNeoClassID Neo4CharConst('pc', 'ID')
- #define pNeoName pName
- #define pNeoParentID Neo4CharConst('pp', 'ar')
- #define pNeoMark Neo4CharConst('ma', 'rk')
- #define pNeoLength Neo4CharConst('pl', 'en')
-
- #ifdef qNeoPowerPC
- #define BreakStrToSourceDebugger_(s) DebugStr(s)
- #else
- #define BreakStrToSourceDebugger_(s) SysBreakStr(s)
- #endif
-
- // Macros for making debugging assertions
- #ifdef qNeoDebug
- #if defined(qNeoPowerPC) || defined(__SC__) // PowerPC and THINK Debugger both like DebugStr
- #define NeoDebugStr(s) DebugStr((ConstStr255Param)(s))
- #else
- #define NeoDebugStr(s) SysBreakStr((ConstStr255Param)(s))
- #endif
- #define NeoAssert(condition) (condition) ? 0 : (NeoDebugStr("\pAssertion Failed!"), 0)
- #else
- #define NeoDebugStr(s)
- #define NeoAssert(condition)
- #endif
-
- // Macro for getting the # of seconds since 1/1/1970 00:00:00
- #define NeoGetCurrentTime() (time(nil) - 0x7C321500)
-
- // Macros for dealing with pointer-based blocks
- #define NeoNewPtr(n) NewPtr((Size)(n))
- #define NeoFreePtr(x) DisposePtr((Ptr)(x))
- #define NeoBlockMove(s, d, l) BlockMove((s), (d), (l))
- #define NeoStringCopy(s, d) NeoBlockMove((s), (d), (s)[0] +1)
-
- // Macros for dealing with handle-based blocks
- #define NeoNewHandle(x) NewHandle((Size)(x))
- #define NeoFreeHandle(x) DisposHandle((Handle)(x))
- #define NeoResizeHandle(x, l) SetHandleSize((Handle)(x), (l))
-
- // Routines that deal with blocks of the default type
- #define kNeoNoErr noErr
- #define kNeoMemFull memFullErr
- #define kNeoNotFound resNotFound
- #define kNeoUnknownType invalidTranslationPathErr
-
- #define NeoFree(p) DisposePtr((Ptr)(p))
- #define NeoMalloc(n) ((void *)NewPtr((Size)(n)))
- #define NeoRealloc(p, l) SetPtrSize((Ptr)(p), (Size)(l))
- #define NeoGetSize(x) GetPtrSize((Ptr)(x))
-
- #if USES68KINLINES
- #pragma parameter __D0 NeoGetA0
- extern pascal long NeoGetA0(void) ONEWORDINLINE(0x2008);
-
- #pragma parameter __D0 NeoGetA1
- extern pascal long NeoGetA1(void) ONEWORDINLINE(0x2009);
-
- #pragma parameter NeoSetD0(__D1)
- extern pascal void NeoSetD0(long aD0) ONEWORDINLINE(0x2049);
- #endif
-
- #define NeoNewInherit
- #define NeoDeleteInherit
-
- class CNeoString {
- public:
- CNeoString(void);
- CNeoString(const unsigned char *aSrc);
- operator char *(void) const;
- operator unsigned char *(void) const;
- unsigned char operator[](const int aIndex) const;
- unsigned char & operator[](const int aIndex);
- CNeoString & operator=(const CNeoString &aSrc);
- int operator>(const CNeoString &aOther) const;
- int operator>=(const CNeoString &aOther) const;
- int operator<(const CNeoString &aOther) const;
- int operator<=(const CNeoString &aOther) const;
- int operator==(const CNeoString &aOther) const;
- short getLength(void) const;
-
- protected:
- unsigned char fString[128];
- };
-
- #ifndef qNeoDebug
- inline CNeoString::CNeoString(void)
- {
- fString[0] = 0;
- }
-
- inline CNeoString::CNeoString(const unsigned char *aSrc)
- {
- unsigned char length = (aSrc)[0] +1;
-
- NeoBlockMove((aSrc), fString, length);
- fString[length] = 0;
- }
-
- inline CNeoString::operator char *(void) const
- {
- return (char *)&fString[1];
- }
-
- inline CNeoString::operator unsigned char *(void) const
- {
- return (unsigned char *)&fString[0];
- }
-
- inline unsigned char CNeoString::operator[](const int aIndex) const
- {
- return fString[aIndex];
- }
-
- inline unsigned char & CNeoString::operator[](const int aIndex)
- {
- return fString[aIndex];
- }
-
- inline CNeoString & CNeoString::operator=(const CNeoString &aSrc)
- {
- unsigned char length = (aSrc)[0] +1;
-
- NeoBlockMove((unsigned char *)(aSrc), fString, length);
- fString[length] = 0;
-
- return *this;
- }
-
- inline int CNeoString::operator>(const CNeoString &aOther) const
- {
- return (IUCompString(fString, aOther.fString) == 1);
- }
-
- inline int CNeoString::operator>=(const CNeoString &aOther) const
- {
- return (IUCompString(fString, aOther.fString) != -1);
- }
-
- inline int CNeoString::operator<(const CNeoString &aOther) const
- {
- return (IUCompString(fString, aOther.fString) == -1);
- }
-
- inline int CNeoString::operator<=(const CNeoString &aOther) const
- {
- return (IUCompString(fString, aOther.fString) != 1);
- }
-
- inline int CNeoString::operator==(const CNeoString &aOther) const
- {
- return (IUCompString(fString, aOther.fString) == 0);
- }
-
- inline short CNeoString::getLength(void) const
- {
- return (short)(fString)[0];
- }
-
- #endif
-
- extern Boolean NeoAsk(Str255 aComplaint, Str255 aQuestion);
- #define NeoAskID 501
- #define NeoCancelID 2
-
- // NeoAccess class names
- #define kNeoPersistName "\pCNeoPersist"
- #define kNeoClassName "\pCNeoClass"
- #define kNeoSubclassName "\pCNeoSubclass"
- #define kNeoFreeListName "\pCNeoFreeList"
- #define kNeoInodeName "\pCNeoInode"
- #define kNeoIDIndexName "\pCNeoIDIndex"
- #define kNeoIDListName "\pCNeoIDList"
- #define kNeoParentIndexName "\pCNeoParentIndex"
- #define kNeoPartMgrName "\pCNeoPartMgr"
-
- #endif
-