void CVarDataFile::MarkSlotDeleted(UInt32 inSlotPos, RecIDT inRecID) { RecIDT recID = 0; // use 0 as deleted slot marker #if DB_DEBUG_MODE || DB_INTEGRITY_CHECKING ASSERT(mBytesUsed <= mAllocatedBytes); // can't use more than we've allocated ASSERT((mAllocatedBytes+mFirstItemPos) == GetLength()); // LFileStream needs to be in synch if (GetLength() < (SInt32)inSlotPos) { DB_LOG("ERROR: Delete Rec " << inRecID << " pos: "<<inSlotPos <<" FAILED, overran datafile length "<<GetLength()<<"B"); DB_DEBUG("ERROR: Trying to delete-mark slot at offset "<<inSlotPos<<", but datafile is only "<<GetLength()<<" bytes long.", DEBUG_ERROR); Throw_( dbIndexCorrupt ); } SetMarker(inSlotPos + kVarDBFileRecIDOffset, streamFrom_Start); // debugging, check old ID ReadBlock(&recID, kSizeOfRecID); #if PLATFORM_LITTLE_ENDIAN recID = BigEndian32_ToNative(recID); #endif // PLATFORM_LITTLE_ENDIAN DB_DEBUG("MarkSlotDeleted(); deleted_id: " << recID, DEBUG_TRIVIA); if (recID != inRecID) { DB_LOG("ERROR: Delete Rec " << inRecID << " pos: "<<inSlotPos << " FAILED, slot has Record "<<recID); DB_DEBUG("ERROR: Tried to delete Record ID " << inRecID << " but record " <<recID <<" found in slot at "<<inSlotPos, DEBUG_ERROR); Throw_( dbIndexCorrupt ); } if (recID == 0) { DB_LOG("WARNING: Delete Rec " << inRecID << " pos: "<<inSlotPos << " previously deleted"); DB_DEBUG("NON-CRITICAL ERROR: Deleting a slot with a zero (deleted) ID", DEBUG_ERROR); } recID = 0; #endif // writing zero, don't worry about endian swap SetMarker(inSlotPos + kVarDBFileRecIDOffset, streamFrom_Start); // move to position of recID in slot WriteBlock(&recID, kSizeOfRecID); // write the deletion maker DB_LOG("Deleted Rec " << inRecID << " pos: "<<inSlotPos); DB_DEBUG("MarkSlotDeleted(); pos: " << inSlotPos, DEBUG_TRIVIA); }
void CVarDataFile::UpdateRecord(DatabaseRec *inRecP) { SInt32 recSize = inRecP->recSize; SInt32 recPos = itsMasterIndex->UpdateEntry(inRecP->recID, recSize); // find index entry inRecP->recPos = recPos; #if DB_DEBUG_MODE || DB_INTEGRITY_CHECKING if (inRecP->recID > mLastRecID) { DB_DEBUG("ERROR: Invalid Record ID "<<inRecP->recID<<" updated. Last ID is "<<mLastRecID, DEBUG_ERROR); Throw_( dbInvalidID ); } if (recSize < (SInt32)sizeof(DatabaseRec)) { DB_DEBUG("ERROR: Trying to update Rec "<<inRecP->recID<<" with size of "<<recSize<<" bytes, smaller than the record header alone.", DEBUG_ERROR); Throw_( dbDataCorrupt ); } ASSERT(mBytesUsed <= mAllocatedBytes); // can't use more than we've allocated ASSERT((mAllocatedBytes+mFirstItemPos) == GetLength()); // LFileStream needs to be in synch if (GetLength() < recPos) { DB_DEBUG("ERROR: Index returned offset "<<recPos<<" for Rec "<<inRecP->recID<<", but datafile is only "<<GetLength()<<" bytes long.", DEBUG_ERROR); mFileIsDamaged = true; Throw_( dbIndexCorrupt ); } // DB_DEBUG("in UpdateRecord("<< inRecP->recID <<"); size: "<<recSize<<" pos: "<<recPos, DEBUG_TRIVIA); RecIDT oldID; SInt32 slotSize; SetMarker(recPos + kVarDBFileSlotSizeOffset, streamFrom_Start); // debugging, check old ID ReadBlock(&slotSize, kSizeOfSlotSize); ReadBlock(&oldID, kSizeOfRecID); #if PLATFORM_LITTLE_ENDIAN slotSize = BigEndian32_ToNative(slotSize); oldID = BigEndian32_ToNative(oldID); #endif // PLATFORM_LITTLE_ENDIAN if ( (oldID != 0) && (oldID != inRecP->recID) ) { DB_LOG("ERROR: Update Rec " << inRecP->recID << " " << recSize << "B pos: "<<recPos<<" FAILED, overwriting Rec "<<oldID); DB_DEBUG("ERROR: Updating "<< inRecP->recID << " into wrong place [" << recPos << "] , overwriting Rec "<<oldID, DEBUG_ERROR); mFileIsDamaged = true; Throw_( dbIndexCorrupt ); } if (slotSize < RecSizeToSlotSize(recSize)) { DB_LOG("ERROR: Update Rec " << inRecP->recID << " " << recSize << "B pos: "<<recPos<<" FAILED, slot too small "<<slotSize<<"B"); DB_DEBUG("ERROR: Writing "<< inRecP->recID <<" of "<<RecSizeToSlotSize(recSize)<<" bytes into a "<<slotSize<<" byte slot at "<< recPos, DEBUG_ERROR); mFileIsDamaged = true; Throw_( dbDataCorrupt ); } #endif SetMarker(recPos + kVarDBFileRecIDOffset, streamFrom_Start); // move to start of slot's data, skipping size inRecP->recID = Native_ToBigEndian32(inRecP->recID); WriteBlock(&inRecP->recID, RecSizeToIOSize(recSize)); // write the new record data into the slot inRecP->recID = BigEndian32_ToNative(inRecP->recID); DB_LOG("Updated Rec " << inRecP->recID << " " << recSize << "B pos: "<<recPos); DB_DEBUG("UpdateRecord("<< inRecP->recID <<"); size: "<<recSize<<" pos: "<<recPos, DEBUG_TRIVIA); }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ Link /*e*/ // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // The link stage is used to resolve any forward references in the code, eg a procedure call or a jump statement. // Errors are placed into the error list void CProgram::Link() { AssertThrow_(mProgramState==kAwaitingLinking); TArrayIterator<CLinkableObject*> iter(mLinkableObjects); CLinkableObject *object; while (iter.Next(object)) { Try_ { object->Link(*this); } Catch_(err) { LogError(err); } } mLinkableObjects.RemoveItemsAt(mLinkableObjects.GetCount(),1); PopParsingScope()->EntriesComplete(); // close the root parsing scope - no more identifiers can be intoduced now if (mParsingScope.GetCount()!=0) // no more scopes { SignalString_("This is a temporary message.\rI think you're missing an 'end proc' statement."); Throw_(-1); } // Also for all entries in the root scope set their mIsRoot boolean to true so that they know where to get their values mRootScope.MakeEntriesRoot(); if (mErrors.IsEmpty()) mProgramState=kReady; // don't set the program state to ready unless the link went without a hitch }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ CRawKeyConvertFunction::EvalulateInt // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // converts a raw key into something else TTBInteger CRawKeyConvertFunction::EvaluateInt( CProgram &ioState) { CKeyQueue::STBRawKeycode raw; TTBInteger result=0; raw.rawcode=(UInt32)mRawKey(ioState); switch (mConvertTo) { case RAW2ASCII: result=raw.b.charcode; break; case RAW2SCANCODE: result=raw.b.scancode; break; default: Throw_(kTNTErr_InternalError); break; } return result; }
/* Static e */ CPersistor *UPersistanceMgr::ReanimateObjectFromStream( CPersistor *inParent, LStream &inStream) { TPersistorId id=0; // inStream >> id; inStream.ReadBlock(&id,sizeof(id)); inStream.SetMarker(-sizeof(TPersistorId),streamFrom_Marker); TPersistorCreator creator=LookupCreator(id); if (!creator) { char string[50]; std::strcpy(string,"Reanimation failed for class 'xxxx'"); std::memcpy(&string[30],&id,sizeof(id)); SignalString_(string); Throw_(kTNTErr_UnregisteredPersistorClass); } CPersistor *p=creator(inParent); ThrowIfMemFull_(p); p->AssignFromStream(inStream); return p; }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ CRawKeyFilterFunction::EvaluateInt // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ TTBInteger CRawKeyFilterFunction::EvaluateInt( CProgram &ioState) { UInt32 raw=mRawKey(ioState),data=0; bool res=false; CStringEditBuffer::EKeyClass cls=CStringEditBuffer::ClassifyKey(raw,data); switch (mFilterToken) { case RAWFILTNUMBER: res=(cls==CStringEditBuffer::kKeyClass_Printing && data>='0' && data<='9'); break; case RAWFILTPRINT: res=(cls==CStringEditBuffer::kKeyClass_Printing); break; case RAWFILTNAV: res=(cls==CStringEditBuffer::kKeyClass_Navigation); break; case RAWFILTDEL: res=(cls==CStringEditBuffer::kKeyClass_Delete); break; default: Throw_(-1); break; } return res; }
// sets the list of resources for a type // handle is adopted void CResContainerDirCache::SetResList( ResType inResType, SInt32 inCount, Handle inHandle) { try { CResHash::const_iterator it=mResContentsHash.find(inResType); SResContents cur={0,NULL}; if (it!=mResContentsHash.end()) { cur=(*it).second; } if (cur.contents) { ::DisposeHandle(cur.contents); } cur.contents=inHandle; cur.count=inCount; mResContentsHash.insert(CResHash::value_type(inResType,cur)); it=mResContentsHash.find(inResType); AssertThrow_(it!=mResContentsHash.end()); } catch(...) { Throw_(kTNTErr_STLException); } }
// retrives the list of resources for a given res type, returns true if it was cached, false if not bool CResContainerDirCache::RetrieveResList( ResType inResType, SInt32 *outCount, Handle *outHandle) { bool r=false; try { CResHash::const_iterator it=mResContentsHash.find(inResType); if (it!=mResContentsHash.end()) { *outCount=(*it).second.count; *outHandle=(*it).second.contents; r=true; } else { *outCount=0; *outHandle=NULL; r=false; } } catch(...) { Throw_(kTNTErr_STLException); } return r; }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ Constructor /*e*/ // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // Can either take ownership of the gworld or not. Doens't dispose of the gworld on fail of construction. CBLCanvas::CBLCanvas( GWorldPtr inWorld, bool inAdopt) : mWorld(inWorld), mOwnsWorld(inAdopt), mBuffer(0), mBackColour(TColourPresets::kBlack), mForeColour(TColourPresets::kWhite), mInvalCanvasAsDraw(false), mIsWindow(false) { ThrowIfNil_(inWorld); if (!MakeABCRecFromGWorld(inWorld,&mABCRec)) Throw_(memFullErr); #if TARGET_API_MAC_CARBON ::GetPortBounds(inWorld,&mBoundsRect); #else mBoundsRect=inWorld->portRect; #endif mWidth=FRectWidth(mBoundsRect); mHeight=FRectHeight(mBoundsRect); ZeroRectCorner(mBoundsRect); }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ CFloatArithOp::Evaluate /*e*/ // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ TTBFloat CFloatArithOp::Evaluate( CProgram &inState) { TTBFloat left,right,result; left=mLeft(inState); right=mRight(inState); switch (mOp) { case PLUS: result=left+right; break; case TIMES: result=left*right; break; case MINUS: result=left-right; break; case DIVIDE: result=left/right; break; default: Throw_(-1); break; } return result; }
AMasterIndexable::AMasterIndexable(AMasterIndex *inMasterIndex) { itsMasterIndex = inMasterIndex; if (nil == inMasterIndex) Throw_( dbIndexRequired ); if (itsMasterIndex) itsMasterIndex->SetIndexable(this); }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ Constructor /*e*/ // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // Can either take ownership of the window or not. Doens't dispose of the window on fail of construction. CBLCanvas::CBLCanvas( WindowPtr inWindow, bool inAdopt) : mWorld(GetWindowPort(inWindow)), mOwnsWorld(inAdopt), mBuffer(0), mBackColour(TColourPresets::kBlack), mForeColour(TColourPresets::kWhite), mInvalCanvasAsDraw(false), mIsWindow(true) { ThrowIfNil_(inWindow); MakeBCRecFromWindow(inWindow,&mABCRec.rec,::GetMainDevice()); if (!BCToABCRec(&mABCRec)) Throw_(memFullErr); #if TARGET_API_MAC_CARBON ::GetPortBounds(mWorld,&mBoundsRect); #else mBoundsRect=inWorld->portRect; #endif mWidth=FRectWidth(mBoundsRect); mHeight=FRectHeight(mBoundsRect); ZeroRectCorner(mBoundsRect); }
void AMasterIndexable::SetMasterIndex(AMasterIndex *inMasterIndex) { itsMasterIndex = inMasterIndex; if (nil == inMasterIndex) Throw_( dbIndexRequired ); itsMasterIndex->UseIndexable(this); }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ CurrentStackFrame /*e*/ // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ CStackFrame *CProgram::CurrentStackFrame() { CListElementT<CStackFrame> *ele=mStackFrames.GetFirstElement(); if (!ele) Throw_(kTNTErr_InternalError); return ele->GetData(); }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ InsertElementIntoTable /*e*/ // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // Inserts the passed element into the table. This should be called when the element has been made visible and needs putting // in the table. The element should already be in the hierarchy. void CHierarchicalTable::InsertElementIntoTable( CHierarchicalElement *inElement, CHierarchicalGroup::TVisibilityOperation inOp) { TableIndexT subRowsToAdd; bool addHeaderRow=!inElement->IsInTable(); CHierarchicalGroup *group=dynamic_cast<CHierarchicalGroup*>(inElement); switch (inOp) { case CHierarchicalGroup::kShowHeaderAndSubGroup: subRowsToAdd=group->CountVisibleSubElements(); break; case CHierarchicalGroup::kShowSubGroupOnly: subRowsToAdd=group->CountVisibleSubElements(); addHeaderRow=false; break; case CHierarchicalGroup::kShowHeaderElementOnly: subRowsToAdd=0; break; default: Throw_(paramErr); break; } // Work out where in the table it should go and insert it STableCell cellPos; CalcInsertPosition(inElement,cellPos); if (inElement->IsInTable()) cellPos.row++; // Insert a row(s) and set the cell(s) InsertRows(subRowsToAdd+addHeaderRow,cellPos.row-1,0L,0L,true); if (addHeaderRow) { PutInTable(inElement,cellPos); cellPos.row++; } // group == 0L if the element is not a group leader if (group) { CVisibleElementsIndexer indexer(group->GetSubList()); CHierarchicalElement *element; while ((element=indexer.GetNextData()) && subRowsToAdd--) { PutInTable(element,cellPos); cellPos.row++; } } }
ThingyRef& CThingyList::FetchThingyRefAt(ArrayIndexT inAtIndex) const { ThingyRef* resultP = NULL; if (!ValidIndex(inAtIndex)) { DEBUG_OUT("Throwing: ThingyList index out of range: "<<inAtIndex, DEBUG_ERROR | DEBUG_CONTAINMENT ); Throw_(invalidIndexErr); } else { resultP = (ThingyRef*) GetItemPtr(inAtIndex); } return *resultP; }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ GetDataStatementScope /*e*/ // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ CIdentifierScope *CProgram::GetDataStatementScope() { CIdentifierScope *scope; mParsingScope.PeekItem(scope); if (!scope) Throw_(kTNTErr_InternalError); return scope; }
TActiveScroller::TActiveScroller(ControlHandle scrollBar) { disabled=false; this->scrollBar=scrollBar; wasScrollHilight=kControlInactivePart; // make the tracking proc scrollBarProcUPP=NewControlActionUPP(TrackingProc); if (!scrollBarProcUPP) Throw_(memFullErr); AdjustToControlSize(); }
// deletes the record and the object too and sets the pointer passed in to nil also catches // the exception if the record was not found, since we were going to delete it anyway void //** Thread Safe ** ADataStore::DeleteRecord(CRecord* &inRecP) { ASSERT(inRecP != nil); DB_DEBUG("WriteRecord("<<inRecP->GetRecordID()<<")"); Try_{ DeleteRecord(inRecP->GetRecordID()); } Catch_(err) { if (err != dbItemNotFound) Throw_(err); // pass on the exception if it was something other than notFound } delete inRecP; inRecP = (CRecord*)nil; }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ MakeSelfSpecifier /*e*/ // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // Overridden to allow specification by name or id as an option. void CModelObjectPlus::MakeSelfSpecifier( AEDesc& inSuperSpecifier, AEDesc& outSelfSpecifier) const { Str255 string; GetModelName(string); if ((mFlags&mfSpecifyByName) && string[0]) { if (mSuperModel==nil) Throw_(errAEEventNotHandled); StAEDescriptor nameKeyData; OSErr err=::AECreateDesc(typeChar,&string[1],string[0],nameKeyData); ThrowIfOSErr_(err); err=::CreateObjSpecifier(GetModelKind(),&inSuperSpecifier,formName,&nameKeyData.mDesc,false,&outSelfSpecifier); ThrowIfOSErr_(err); } else if (mFlags&mfSpecifyById) { if (mSuperModel==nil) Throw_(errAEEventNotHandled); StAEDescriptor idKeyData; StAEDescriptor bogusType; GetAEProperty(pID,bogusType,idKeyData); // get the unique id for this object OSErr err=::CreateObjSpecifier(GetModelKind(),&inSuperSpecifier,formUniqueID,&idKeyData.mDesc,false,&outSelfSpecifier); ThrowIfOSErr_(err); } else inheritedModelObject::MakeSelfSpecifier(inSuperSpecifier,outSelfSpecifier); }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ GetLabelTable /*e*/ // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // Return the current table, throw if none (internal error) CLabelTable *CProgram::GetLabelTable() { TArrayIterator<CIdentifierScope*> iter(mParsingScope,LArrayIterator::from_End); CIdentifierScope *scope; while (iter.Previous(scope)) { if (scope->LabelTable()) return scope->LabelTable(); } Throw_(kTNTErr_InternalError); return 0; }
/*e*/ void CoerceInPlaceType(AEDesc &inDesc,DescType toType) { if (toType==typeWildCard || toType==typeNull) return; AEDesc resultDesc={typeNull,0L}; OSErr err=::AECoerceDesc(&inDesc,toType,&resultDesc); if (err && err!=errAECoercionFail) Throw_(err); if (!err) { AEDisposeDesc(&inDesc); inDesc=resultDesc; } }
SInt32 CVarDataFile::GetSlotSize(UInt32 inSlotPos) { #if DB_DEBUG_MODE || DB_INTEGRITY_CHECKING ASSERT(mBytesUsed <= mAllocatedBytes); // can't use more than we've allocated ASSERT((mAllocatedBytes+mFirstItemPos) == GetLength()); // LFileStream needs to be in synch if (GetLength() < (SInt32)inSlotPos) { DB_DEBUG("ERROR: Trying to read from slot at offset "<<inSlotPos<<", but datafile is only "<<GetLength()<<" bytes long.", DEBUG_ERROR); Throw_( dbDataCorrupt ); } #endif SInt32 slotSize; SetMarker(inSlotPos + kVarDBFileSlotSizeOffset, streamFrom_Start); ReadBlock(&slotSize, kSizeOfSlotSize); #if PLATFORM_LITTLE_ENDIAN slotSize = BigEndian32_ToNative(slotSize); #endif // PLATFORM_LITTLE_ENDIAN return slotSize; }
bool UNavServicesDialogs::LCustomFileDesignator::AskDesignateFile(ConstStringPtr inDefaultName, ESaveFormat& ioSaveFormat) { StNavEventUPP eventUPP(NavCustomEventProc); CNavCustomPutFileCallbackData callbackData(kCustomSaveFilePanelSize, kCustomSaveFilePanelDITLResID, ioSaveFormat); LString::CopyPStr(inDefaultName, mNavOptions.savedFileName); mNavReply.SetDefaultValues(); AEDesc* defaultLocationDesc = nil; if (not mDefaultLocation.IsNull()) { defaultLocationDesc = mDefaultLocation; if (mSelectDefault) { mNavOptions.dialogOptionFlags |= kNavSelectDefaultLocation; } else { mNavOptions.dialogOptionFlags &= ~kNavSelectDefaultLocation; } } UDesktop::Deactivate(); OSErr err = ::NavPutFile( defaultLocationDesc, mNavReply, &mNavOptions, eventUPP, mFileType, mFileCreator, &callbackData); UDesktop::Activate(); if ( (err != noErr) && (err != userCanceledErr) ) { Throw_(err); } ioSaveFormat = callbackData.GetSaveFormat(); return mNavReply.IsValid(); }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ GetResIdForName /*e*/ // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // returns the resid of a resource in the current programs res container with the name passed. throws if no such resource exists. TResId CProgram::GetResIdForName( ResType inType, CCString &inString) { TResId resId=kNullResId; if (mResContainer) { Str255 str; CopyCAsPStr((StringPtr)inString.mString,str); resId=mResContainer->GetResIdForName(inType,str); } if (resId==kNullResId) { Throw_(resNotFound); } return resId; }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ SetGWorld /*e*/ // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // Specifies a new gworld for this canvas void CBLCanvas::SetGWorld( GWorldPtr inWorld, bool inAdopt) { if (mWorld && mOwnsWorld) ::DisposeGWorld(mWorld); mWorld=inWorld; mOwnsWorld=inAdopt; mIsWindow=false; ::DestroyABCRec(&mABCRec); if (!MakeABCRecFromGWorld(inWorld,&mABCRec)) Throw_(memFullErr); #if TARGET_API_MAC_CARBON ::GetPortBounds(inWorld,&mBoundsRect); #else mBoundsRect=inWorld->portRect; #endif ZeroRectCorner(mBoundsRect); }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ GetAEDataHandle /*e*/ // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // Returns the AE data handle from the desc. You have to dispose of this handle. Handle GetAEDataHandle( const AEDesc &inDesc) { Size size; size=::AEGetDescDataSize(&inDesc); Handle h=::NewHandle(size); ThrowIfMemFull_(h); HLock(h); OSErr err=::AEGetDescData(&inDesc,*h,size); HUnlock(h); if (err) { DisposeHandle(h); Throw_(err); } return h; }
// handle created is yours to do with as you will handle //** Thread Safe ** ADataStore::ReadRecordHandle(RecIDT inRecID) { handle h; long fullsize = GetRecordSize(inRecID); long size = fullsize - sizeof(DatabaseRec); if (size > 0) { h.resize(fullsize); h.lock(); DatabaseRec* p = (DatabaseRec*) *h; p->recID = inRecID; p->recSize = fullsize; Try_{ ReadRecord(p); } Catch_(err) { h.dispose(); // clean up our mess Throw_(err); } ::BlockMoveData(&p->recData[0], p, size); h.unlock(); h.resize(size); }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ GetVarTable /*e*/ // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // Return the current table, throw if none (internal error) CVariableSymbolTable *CProgram::GetVarTable( bool inRootTable) { if (inRootTable) return mRootScope.VarTable(); else { ArrayIndexT count=mParsingScope.GetCount(); CIdentifierScope *scope; for (ArrayIndexT index=count; index>0; index--) { scope=mParsingScope[index]; if (scope->VarTable()) return scope->VarTable(); } Throw_(kTNTErr_InternalError); } return 0; }
// updates, or adds if doesn't already exist RecIDT //** Thread Safe ** ADataStore::WriteRecord(CRecord* inRecP) { ASSERT(inRecP != nil); // еее pass by reference DB_DEBUG("WriteRecord("<<inRecP->GetRecordID()<<")"); bool addIt = false; RecIDT id = inRecP->GetRecordID(); AutoLockRecord lock(inRecP); // automatically unlock the record as we exit this code block DatabaseRec* p = inRecP->GetRecordDataPtr(); Try_{ UpdateRecord(p); } Catch_(err) { if (err != dbItemNotFound) { Throw_(err); } else { addIt = true; } } if (addIt) { id = AddRecord(p); } return id; }