Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Friends
morkStream Class Reference

#include <morkStream.h>

Inheritance diagram for morkStream:
Inheritance graph
[legend]
Collaboration diagram for morkStream:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual void CloseMorkNode (morkEnv *ev)
virtual ~morkStream ()
 morkStream (morkEnv *ev, const morkUsage &inUsage, nsIMdbHeap *ioHeap, nsIMdbFile *ioContentFile, mork_size inBufSize, mork_bool inFrozen)
void CloseStream (morkEnv *ev)
mork_bool IsStream () const
void NonStreamTypeError (morkEnv *ev)
NS_IMETHOD Steal (nsIMdbEnv *ev, nsIMdbFile *ioThief)
NS_IMETHOD BecomeTrunk (nsIMdbEnv *ev)
NS_IMETHOD AcquireBud (nsIMdbEnv *ev, nsIMdbHeap *ioHeap, nsIMdbFile **acqBud)
virtual mork_pos Length (morkEnv *ev) const
NS_IMETHOD Tell (nsIMdbEnv *ev, mork_pos *aOutPos) const
NS_IMETHOD Read (nsIMdbEnv *ev, void *outBuf, mork_size inSize, mork_size *aOutCount)
NS_IMETHOD Seek (nsIMdbEnv *ev, mork_pos inPos, mork_pos *aOutPos)
NS_IMETHOD Write (nsIMdbEnv *ev, const void *inBuf, mork_size inSize, mork_size *aOutCount)
NS_IMETHOD Flush (nsIMdbEnv *ev)
void NewBadCursorSlotsError (morkEnv *ev) const
void NewBadCursorOrderError (morkEnv *ev) const
void NewNullStreamBufferError (morkEnv *ev) const
void NewCantReadSinkError (morkEnv *ev) const
void NewCantWriteSourceError (morkEnv *ev) const
void NewPosBeyondEofError (morkEnv *ev) const
nsIMdbFileGetStreamContentFile () const
mork_size GetStreamBufferSize () const
mork_size PutIndent (morkEnv *ev, mork_count inDepth)
mork_size PutByteThenIndent (morkEnv *ev, int inByte, mork_count inDepth)
mork_size PutStringThenIndent (morkEnv *ev, const char *inString, mork_count inDepth)
mork_size PutString (morkEnv *ev, const char *inString)
mork_size PutStringThenNewline (morkEnv *ev, const char *inString)
mork_size PutByteThenNewline (morkEnv *ev, int inByte)
void Ungetc (int c)
int Getc (morkEnv *ev)
void Putc (morkEnv *ev, int c)
mork_size PutLineBreak (morkEnv *ev)
void CloseFile (morkEnv *ev)
mork_bool IsFile () const
nsIMdbFileAcquireFileHandle (morkEnv *ev)
mork_bool FileFrozen () const
mork_bool FileDoTrace () const
mork_bool FileIoOpen () const
mork_bool FileActive () const
void SetFileFrozen (mork_bool b)
void SetFileDoTrace (mork_bool b)
void SetFileIoOpen (mork_bool b)
void SetFileActive (mork_bool b)
mork_bool IsOpenActiveAndMutableFile () const
mork_bool IsOpenAndActiveFile () const
nsIMdbFileGetThief () const
void SetThief (morkEnv *ev, nsIMdbFile *ioThief)
const char * GetFileNameString () const
void SetFileName (morkEnv *ev, const char *inName)
void NewMissingIoError (morkEnv *ev) const
void NewFileDownError (morkEnv *ev) const
void NewFileErrnoError (morkEnv *ev) const
mork_size WriteNewlines (morkEnv *ev, mork_count inNewlines)
NS_IMETHOD Eof (nsIMdbEnv *ev, mdb_pos *outPos)
NS_IMETHOD Get (nsIMdbEnv *ev, void *outBuf, mdb_size inSize, mdb_pos inPos, mdb_size *outActualSize)
NS_IMETHOD Put (nsIMdbEnv *ev, const void *inBuf, mdb_size inSize, mdb_pos inPos, mdb_size *outActualSize)
NS_IMETHOD Path (nsIMdbEnv *ev, mdbYarn *outFilePath)
NS_IMETHOD Thief (nsIMdbEnv *ev, nsIMdbFile **acqThief)
NS_DECL_ISUPPORTS NS_IMETHOD IsFrozenMdbObject (nsIMdbEnv *ev, mdb_bool *outIsReadonly)
NS_IMETHOD GetMdbFactory (nsIMdbEnv *ev, nsIMdbFactory **acqFactory)
NS_IMETHOD GetWeakRefCount (nsIMdbEnv *ev, mdb_count *outCount)
NS_IMETHOD GetStrongRefCount (nsIMdbEnv *ev, mdb_count *outCount)
NS_IMETHOD AddWeakRef (nsIMdbEnv *ev)
mork_refs AddWeakRef (morkEnv *ev)
NS_IMETHOD AddStrongRef (nsIMdbEnv *ev)
virtual mork_refs AddStrongRef (morkEnv *ev)
NS_IMETHOD CutWeakRef (nsIMdbEnv *ev)
mork_refs CutWeakRef (morkEnv *ev)
NS_IMETHOD CutStrongRef (nsIMdbEnv *ev)
virtual mork_refs CutStrongRef (morkEnv *ev)
NS_IMETHOD CloseMdbObject (nsIMdbEnv *ev)
mdb_err CloseMdbObject (morkEnv *ev)
NS_IMETHOD IsOpenMdbObject (nsIMdbEnv *ev, mdb_bool *outOpen)
void CloseObject (morkEnv *ev)
mork_bool IsObject () const
mork_u4 BeadHash () const
mork_bool BeadEqual (const morkBead *inBead) const
void CloseBead (morkEnv *ev)
mork_bool IsBead () const
void SetFrozen ()
void SetMutable ()
void SetAsleep ()
mork_bool IsFrozen () const
mork_bool IsMutable () const
mork_bool IsAsleep () const
void SetNodeClean ()
void SetNodeDirty ()
mork_bool IsNodeClean () const
mork_bool IsNodeDirty () const
void ZapOld (morkEnv *ev, nsIMdbHeap *ioHeap)
voidoperator new (size_t inSize, nsIMdbHeap &ioHeap, morkEnv *ev) CPP_THROW_NEW
void CloseNode (morkEnv *ev)
mork_bool IsNode () const
void RefsUnderUsesWarning (morkEnv *ev) const
void NonNodeError (morkEnv *ev) const
void NilHeapError (morkEnv *ev) const
void NonOpenNodeError (morkEnv *ev) const
void NonMutableNodeError (morkEnv *ev) const
void RefsOverflowWarning (morkEnv *ev) const
void UsesOverflowWarning (morkEnv *ev) const
void RefsUnderflowWarning (morkEnv *ev) const
void UsesUnderflowWarning (morkEnv *ev) const
mork_bool GoodRefs () const
mork_bool BadRefs () const
mork_uses StrongRefsOnly () const
mork_refs WeakRefsOnly () const
const char * GetNodeAccessAsString () const
const char * GetNodeUsageAsString () const
mork_usage NodeUsage () const
mork_bool IsHeapNode () const
mork_bool IsOpenNode () const
mork_bool IsShutNode () const
mork_bool IsDeadNode () const
mork_bool IsClosingNode () const
mork_bool IsOpenOrClosingNode () const
mork_bool HasNodeAccess () const
void MarkShut ()
void MarkClosing ()
void MarkDead ()

Static Public Member Functions

static void SlotWeakStream (morkStream *me, morkEnv *ev, morkStream **ioSlot)
static void SlotStrongStream (morkStream *me, morkEnv *ev, morkStream **ioSlot)
static morkFileOpenOldFile (morkEnv *ev, nsIMdbHeap *ioHeap, const char *inFilePath, mork_bool inFrozen)
static morkFileCreateNewFile (morkEnv *ev, nsIMdbHeap *ioHeap, const char *inFilePath)
static void NilSlotHeapError (morkEnv *ev)
static void NilFileNameError (morkEnv *ev)
static void NonFileTypeError (morkEnv *ev)
static void SlotWeakFile (morkFile *me, morkEnv *ev, morkFile **ioSlot)
static void SlotStrongFile (morkFile *me, morkEnv *ev, morkFile **ioSlot)
static void SlotWeakObject (morkObject *me, morkEnv *ev, morkObject **ioSlot)
static void SlotStrongObject (morkObject *me, morkEnv *ev, morkObject **ioSlot)
static void SlotWeakBead (morkBead *me, morkEnv *ev, morkBead **ioSlot)
static void SlotStrongBead (morkBead *me, morkEnv *ev, morkBead **ioSlot)
static voidMakeNew (size_t inSize, nsIMdbHeap &ioHeap, morkEnv *ev)
static void SlotWeakNode (morkNode *me, morkEnv *ev, morkNode **ioSlot)
static void SlotStrongNode (morkNode *me, morkEnv *ev, morkNode **ioSlot)

Public Attributes

morkHandlemObject_Handle
morkEnvmMorkEnv
mork_color mBead_Color
nsIMdbHeapmNode_Heap
mork_base mNode_Base
mork_derived mNode_Derived
mork_access mNode_Access
mork_usage mNode_Usage
mork_able mNode_Mutable
mork_load mNode_Load
mork_uses mNode_Uses
mork_refs mNode_Refs

Protected Member Functions

int fill_getc (morkEnv *ev)
void spill_putc (morkEnv *ev, int c)
void spill_buf (morkEnv *ev)

Protected Attributes

mork_u1mStream_At
mork_u1mStream_ReadEnd
mork_u1mStream_WriteEnd
nsIMdbFilemStream_ContentFile
mork_u1mStream_Buf
mork_size mStream_BufSize
mork_pos mStream_BufPos
mork_bool mStream_Dirty
mork_bool mStream_HitEof
mork_u1 mFile_Frozen
mork_u1 mFile_DoTrace
mork_u1 mFile_IoOpen
mork_u1 mFile_Active
nsIMdbHeapmFile_SlotHeap
char * mFile_Name
nsIMdbFilemFile_Thief

Private Member Functions

 morkStream (const morkStream &other)
morkStreamoperator= (const morkStream &other)

Friends

class morkHandleFrame

Detailed Description

Definition at line 97 of file morkStream.h.


Constructor & Destructor Documentation

morkStream::~morkStream ( ) [virtual]

Definition at line 79 of file morkStream.cpp.

morkStream::morkStream ( morkEnv ev,
const morkUsage inUsage,
nsIMdbHeap ioHeap,
nsIMdbFile ioContentFile,
mork_size  inBufSize,
mork_bool  inFrozen 
)

Definition at line 86 of file morkStream.cpp.

: morkFile(ev, inUsage, ioHeap, ioHeap)
, mStream_At( 0 )
, mStream_ReadEnd( 0 )
, mStream_WriteEnd( 0 )

, mStream_ContentFile( 0 )

, mStream_Buf( 0 )
, mStream_BufSize( inBufSize )
, mStream_BufPos( 0 )
, mStream_Dirty( morkBool_kFalse )
, mStream_HitEof( morkBool_kFalse )
{
  if ( ev->Good() )
  {
    if ( inBufSize < morkStream_kMinBufSize )
      mStream_BufSize = inBufSize = morkStream_kMinBufSize;
    else if ( inBufSize > morkStream_kMaxBufSize )
      mStream_BufSize = inBufSize = morkStream_kMaxBufSize;
    
    if ( ioContentFile && ioHeap )
    {
      // if ( ioContentFile->FileFrozen() ) // forced to be readonly?
      //   inFrozen = morkBool_kTrue; // override the input value
        
      nsIMdbFile_SlotStrongFile(ioContentFile, ev, &mStream_ContentFile);
      if ( ev->Good() )
      {
        mork_u1* buf = 0;
        ioHeap->Alloc(ev->AsMdbEnv(), inBufSize, (void**) &buf);
        if ( buf )
        {
          mStream_At = mStream_Buf = buf;
          
          if ( !inFrozen )
          {
            // physical buffer end never moves:
            mStream_WriteEnd = buf + inBufSize;
          }
          else
            mStream_WriteEnd = 0; // no writing is allowed
          
          if ( inFrozen )
          {
            // logical buffer end starts at Buf with no content:
            mStream_ReadEnd = buf;
            this->SetFileFrozen(inFrozen);
          }
          else
            mStream_ReadEnd = 0; // no reading is allowed
          
          this->SetFileActive(morkBool_kTrue);
          this->SetFileIoOpen(morkBool_kTrue);
        }
        if ( ev->Good() )
          mNode_Derived = morkDerived_kStream;
      }
    }
    else ev->NilPointerError();
  }
}

Here is the call graph for this function:

morkStream::morkStream ( const morkStream other) [private]

Member Function Documentation

NS_IMETHODIMP morkStream::AcquireBud ( nsIMdbEnv ev,
nsIMdbHeap ioHeap,
nsIMdbFile **  acqBud 
) [virtual]

Implements morkFile.

Definition at line 373 of file morkStream.cpp.

{
  MORK_USED_1(ioHeap);
  morkFile* outFile = 0;
  nsIMdbFile* file = mStream_ContentFile;
  morkEnv *ev = morkEnv::FromMdbEnv(mev);
  if ( this->IsOpenAndActiveFile() && file )
  {
    // figure out how this interacts with buffering and mStream_WriteEnd:
    ev->StubMethodOnlyError();
  }
  else this->NewFileDownError(ev);
  
  *acqBud = outFile;
  return NS_ERROR_NOT_IMPLEMENTED;
}

Here is the call graph for this function:

Definition at line 155 of file morkFile.cpp.

{
  nsIMdbFile* outFile = 0;

#ifdef MORK_CONFIG_USE_ORKINFILE
  return this;
#endif /*MORK_CONFIG_USE_ORKINFILE*/
  MORK_USED_1(ev);
    
  return outFile;
}

Here is the caller graph for this function:

NS_IMETHODIMP morkObject::AddStrongRef ( nsIMdbEnv ev) [virtual, inherited]

Implements nsIMdbObject.

Reimplemented in morkStore, and morkCursor.

Definition at line 181 of file morkObject.cpp.

{
  return morkNode::AddStrongRef((morkEnv *) mev);
}

Here is the caller graph for this function:

mork_uses morkNode::AddStrongRef ( morkEnv ev) [virtual, inherited]

Reimplemented in morkTable.

Definition at line 510 of file morkNode.cpp.

{
  mork_uses outUses = 0;
  if ( this )
  {
    if ( this->IsNode() )
    {
      mork_uses uses = mNode_Uses;
      mork_refs refs = mNode_Refs;
      if ( refs < uses ) // need to fix broken refs/uses relation?
      { 
        this->RefsUnderUsesWarning(ev);
        mNode_Refs = mNode_Uses = refs = uses;
      }
      if ( refs < morkNode_kMaxRefCount ) // not too great?
      {
        mNode_Refs = ++refs;
        mNode_Uses = ++uses;
      }
      else
        this->RefsOverflowWarning(ev);

      outUses = uses;
    }
    else
      this->NonNodeError(ev);
  }
  else
    ev->NilPointerError();
  return outUses;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP morkObject::AddWeakRef ( nsIMdbEnv ev) [virtual, inherited]

Implements nsIMdbObject.

Reimplemented in morkStore, and morkCursor.

Definition at line 176 of file morkObject.cpp.

{
  return morkNode::AddWeakRef((morkEnv *) mev);
}
mork_refs morkNode::AddWeakRef ( morkEnv ev) [inherited]

Definition at line 599 of file morkNode.cpp.

{
  mork_refs outRefs = 0;
  if ( this )
  {
    if ( this->IsNode() )
    {
      mork_refs refs = mNode_Refs;
      if ( refs < morkNode_kMaxRefCount ) // not too great?
        mNode_Refs = ++refs;
      else
        this->RefsOverflowWarning(ev);
        
      outRefs = refs;
    }
    else
      this->NonNodeError(ev);
  }
  else
    ev->NilPointerError();
  return outRefs;
}

Here is the call graph for this function:

Here is the caller graph for this function:

mork_bool morkNode::BadRefs ( ) const [inline, inherited]

Definition at line 217 of file morkNode.h.

{ return mNode_Refs < mNode_Uses; }
mork_bool morkBead::BeadEqual ( const morkBead inBead) const [inline, inherited]

Definition at line 88 of file morkBead.h.

  { return ( mBead_Color == inBead->mBead_Color); }

Here is the caller graph for this function:

mork_u4 morkBead::BeadHash ( ) const [inline, inherited]

Definition at line 87 of file morkBead.h.

{ return (mork_u4) mBead_Color; }

Here is the caller graph for this function:

Implements morkFile.

Definition at line 362 of file morkStream.cpp.

Here is the call graph for this function:

void morkBead::CloseBead ( morkEnv ev) [inherited]

Definition at line 109 of file morkBead.cpp.

{
  if ( this )
  {
    if ( this->IsNode() )
    {
      if ( !this->IsShutNode() )
      {
        mBead_Color = 0;
        this->MarkShut();
      }
    }
    else
      this->NonNodeError(ev);
  }
  else
    ev->NilPointerError();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void morkFile::CloseFile ( morkEnv ev) [inherited]

Definition at line 125 of file morkFile.cpp.

{
  if ( this )
  {
    if ( this->IsNode() )
    {
      mFile_Frozen = 0;
      mFile_DoTrace = 0;
      mFile_IoOpen = 0;
      mFile_Active = 0;
      
      if ( mFile_Name )
        this->SetFileName(ev, (const char*) 0);

      nsIMdbHeap_SlotStrongHeap((nsIMdbHeap*) 0, ev, &mFile_SlotHeap);
      nsIMdbFile_SlotStrongFile((nsIMdbFile*) 0, ev, &mFile_Thief);

      this->MarkShut();
    }
    else
      this->NonNodeError(ev);
  }
  else
    ev->NilPointerError();
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP morkObject::CloseMdbObject ( nsIMdbEnv ev) [virtual, inherited]

Implements nsIMdbObject.

Reimplemented in morkStore, and morkCursor.

Definition at line 199 of file morkObject.cpp.

{
  return morkNode::CloseMdbObject((morkEnv *) mev);
}
mdb_err morkNode::CloseMdbObject ( morkEnv ev) [inherited]

Definition at line 243 of file morkNode.cpp.

{
  // if only one ref, Handle_CutStrongRef will clean up better.
  if (mNode_Uses == 1)
    return CutStrongRef(ev);

  mdb_err outErr = 0;
  
  if ( IsNode() && IsOpenNode() )
  {
    if ( ev )
    {
      CloseMorkNode(ev);
      outErr = ev->AsErr();
    }
  }
  return outErr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void morkStream::CloseMorkNode ( morkEnv ev) [virtual]

Reimplemented from morkFile.

Definition at line 68 of file morkStream.cpp.

{
  if ( this->IsOpenNode() )
  {
    this->MarkClosing();
    this->CloseStream(ev);
    this->MarkShut();
  }
}

Here is the call graph for this function:

void morkNode::CloseNode ( morkEnv ev) [inherited]

Definition at line 384 of file morkNode.cpp.

{
  if ( this )
  {
    if ( this->IsNode() )
      this->MarkShut();
    else
      this->NonNodeError(ev);
  }
  else
    ev->NilPointerError();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void morkObject::CloseObject ( morkEnv ev) [inherited]

Definition at line 119 of file morkObject.cpp.

{
  if ( this )
  {
    if ( this->IsNode() )
    {
      if ( !this->IsShutNode() )
      {
        if ( mObject_Handle )
          morkHandle::SlotWeakHandle((morkHandle*) 0L, ev, &mObject_Handle);
          
        mBead_Color = 0; // this->CloseBead(ev);
        this->MarkShut();
      }
    }
    else
      this->NonNodeError(ev);
  }
  else
    ev->NilPointerError();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 152 of file morkStream.cpp.

{
  if ( this )
  {
    if ( this->IsNode() )
    {
      nsIMdbFile_SlotStrongFile((nsIMdbFile*) 0, ev, &mStream_ContentFile);
      nsIMdbHeap* heap = mFile_SlotHeap;
      mork_u1* buf = mStream_Buf;
      mStream_Buf = 0;
      
      if ( heap && buf )
        heap->Free(ev->AsMdbEnv(), buf);

      this->CloseFile(ev);
      this->MarkShut();
    }
    else
      this->NonNodeError(ev);
  }
  else
    ev->NilPointerError();
}

Here is the call graph for this function:

Here is the caller graph for this function:

morkFile * morkFile::CreateNewFile ( morkEnv ev,
nsIMdbHeap ioHeap,
const char *  inFilePath 
) [static, inherited]

Definition at line 181 of file morkFile.cpp.

{
  return morkStdioFile::CreateNewStdioFile(ev, ioHeap, inFilePath);
}

Here is the call graph for this function:

NS_IMETHODIMP morkObject::CutStrongRef ( nsIMdbEnv ev) [virtual, inherited]

Implements nsIMdbObject.

Reimplemented in morkStore, and morkCursor.

Definition at line 192 of file morkObject.cpp.

{
  return morkNode::CutStrongRef((morkEnv *) mev);
}

Here is the caller graph for this function:

mork_uses morkNode::CutStrongRef ( morkEnv ev) [virtual, inherited]

Reimplemented in morkTable.

Definition at line 580 of file morkNode.cpp.

{
  mork_refs outRefs = 0;
  if ( this )
  {
    if ( this->IsNode() )
    {
      if ( this->cut_use_count(ev) )
        outRefs = this->CutWeakRef(ev);
    }
    else
      this->NonNodeError(ev);
  }
  else
    ev->NilPointerError();
  return outRefs;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP morkObject::CutWeakRef ( nsIMdbEnv ev) [virtual, inherited]

Implements nsIMdbObject.

Reimplemented in morkStore, and morkCursor.

Definition at line 187 of file morkObject.cpp.

{
  return morkNode::CutWeakRef((morkEnv *) mev);
}

Here is the caller graph for this function:

mork_refs morkNode::CutWeakRef ( morkEnv ev) [inherited]

Definition at line 623 of file morkNode.cpp.

{
  mork_refs outRefs = 0;
  if ( this )
  {
    if ( this->IsNode() )
    {
      mork_uses uses = mNode_Uses;
      mork_refs refs = mNode_Refs;
      if ( refs ) // not yet zero?
        mNode_Refs = --refs;
      else
        this->RefsUnderflowWarning(ev);

      if ( refs < uses ) // need to fix broken refs/uses relation?
      { 
        this->RefsUnderUsesWarning(ev);
        mNode_Refs = mNode_Uses = refs = uses;
      }
        
      outRefs = refs;
      if ( !refs ) // last reference gone? time to destroy node?
        this->ZapOld(ev, mNode_Heap); // self destroy, use this no longer
    }
    else
      this->NonNodeError(ev);
  }
  else
    ev->NilPointerError();
  return outRefs;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP morkFile::Eof ( nsIMdbEnv ev,
mdb_pos outPos 
) [virtual, inherited]

Implements nsIMdbFile.

Definition at line 314 of file morkFile.cpp.

{
  mdb_err outErr = 0;
  mdb_pos pos = -1;
  morkEnv *ev = morkEnv::FromMdbEnv(mev);
  pos = Length(ev);
  outErr = ev->AsErr();
  if ( outPos )
    *outPos = pos;
  return outErr;
}

Here is the call graph for this function:

mork_bool morkFile::FileActive ( ) const [inline, inherited]

Definition at line 144 of file morkFile.h.

{ return mFile_Active == 'A'; }

Here is the caller graph for this function:

mork_bool morkFile::FileDoTrace ( ) const [inline, inherited]

Definition at line 142 of file morkFile.h.

{ return mFile_DoTrace == 'T'; }
mork_bool morkFile::FileFrozen ( ) const [inline, inherited]

Definition at line 141 of file morkFile.h.

{ return mFile_Frozen == 'F'; }

Here is the caller graph for this function:

mork_bool morkFile::FileIoOpen ( ) const [inline, inherited]

Definition at line 143 of file morkFile.h.

{ return mFile_IoOpen == 'O'; }

Here is the caller graph for this function:

int morkStream::fill_getc ( morkEnv ev) [protected]

Definition at line 788 of file morkStream.cpp.

{
  int c = EOF;
  
  nsIMdbFile* file = mStream_ContentFile;
  if ( this->IsOpenAndActiveFile() && file )
  {
    mork_u1* buf = mStream_Buf;
    mork_u1* end = mStream_ReadEnd; // beyond buf after earlier read
    if ( end > buf ) // any earlier read bytes buffered?
    {
      mStream_BufPos += ( end - buf ); // advance past old read
    }
      
    if ( ev->Good() ) // no errors yet?
    {
      // file->Seek(ev, mStream_BufPos); // set file pos
      // if ( ev->Good() ) // no seek error?
      // {
      // }

      nsIMdbEnv* menv = ev->AsMdbEnv();
      mork_num actual = 0;
      file->Get(menv, buf, mStream_BufSize, mStream_BufPos, &actual);
      if ( ev->Good() ) // no read errors?
      {
        if ( actual > mStream_BufSize ) // more than asked for??
          actual = mStream_BufSize;
        
        mStream_At = buf;
        mStream_ReadEnd = buf + actual;
        if ( actual ) // any bytes actually read?
        {
          c = *mStream_At++; // return first byte from buffer
          mStream_HitEof = morkBool_kFalse;
        }
        else
          mStream_HitEof = morkBool_kTrue;
      }
    }
  }
  else this->NewFileDownError(ev);
  
  return c;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Implements morkFile.

Definition at line 768 of file morkStream.cpp.

{
  morkEnv *mev = morkEnv::FromMdbEnv(ev);
  nsresult rv = NS_ERROR_FAILURE;
  nsIMdbFile* file = mStream_ContentFile;
  if ( this->IsOpenOrClosingNode() && this->FileActive() && file )
  {
    if ( mStream_Dirty )
      this->spill_buf(mev);

    rv = file->Flush(ev);
  }
  else this->NewFileDownError(mev);
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP morkFile::Get ( nsIMdbEnv ev,
void outBuf,
mdb_size  inSize,
mdb_pos  inPos,
mdb_size outActualSize 
) [virtual, inherited]

Implements nsIMdbFile.

Definition at line 327 of file morkFile.cpp.

{
  nsresult rv = NS_OK;
  morkEnv *ev = morkEnv::FromMdbEnv(mev);
  if ( ev )
  {
    mdb_pos outPos;
    Seek(mev, inPos, &outPos);
    if ( ev->Good() )
      rv = Read(mev, outBuf, inSize, outActualSize);
  }
  return rv;
}

Here is the call graph for this function:

int morkStream::Getc ( morkEnv ev) [inline]

Definition at line 224 of file morkStream.h.

  { return ( mStream_At < mStream_ReadEnd )? *mStream_At++ : fill_getc(ev); }

Here is the call graph for this function:

Here is the caller graph for this function:

const char* morkFile::GetFileNameString ( ) const [inline, inherited]

Definition at line 164 of file morkFile.h.

{ return mFile_Name; }

Here is the caller graph for this function:

NS_IMETHODIMP morkObject::GetMdbFactory ( nsIMdbEnv ev,
nsIMdbFactory **  acqFactory 
) [virtual, inherited]

Implements nsIMdbObject.

Definition at line 146 of file morkObject.cpp.

{
  nsresult rv;
  nsCOMPtr <nsIMdbObject> obj = do_QueryInterface(mev);
  if (obj)
    rv = obj->GetMdbFactory(mev, acqFactory);
  else
    return NS_ERROR_NO_INTERFACE;

  return rv;
} 

Here is the call graph for this function:

const char * morkNode::GetNodeAccessAsString ( ) const [inherited]

Definition at line 658 of file morkNode.cpp.

{
  const char* outString = morkNode_kBroken;
  switch( mNode_Access )
  {
    case morkAccess_kOpen: outString = "open"; break;
    case morkAccess_kClosing: outString = "closing"; break;
    case morkAccess_kShut: outString = "shut"; break;
    case morkAccess_kDead: outString = "dead"; break;
  }
  return outString;
}
const char * morkNode::GetNodeUsageAsString ( ) const [inherited]

Definition at line 672 of file morkNode.cpp.

{
  const char* outString = morkNode_kBroken;
  switch( mNode_Usage )
  {
    case morkUsage_kHeap: outString = "heap"; break;
    case morkUsage_kStack: outString = "stack"; break;
    case morkUsage_kMember: outString = "member"; break;
    case morkUsage_kGlobal: outString = "global"; break;
    case morkUsage_kPool: outString = "pool"; break;
    case morkUsage_kNone: outString = "none"; break;
  }
  return outString;
}

Definition at line 195 of file morkStream.h.

{ return mStream_BufSize; }

Definition at line 194 of file morkStream.h.

{ return mStream_ContentFile; }
NS_IMETHODIMP morkObject::GetStrongRefCount ( nsIMdbEnv ev,
mdb_count outCount 
) [virtual, inherited]

Implements nsIMdbObject.

Reimplemented in morkStore, and morkCursor.

Definition at line 168 of file morkObject.cpp.

{
  *outCount = StrongRefsOnly();
  return NS_OK;
}

Here is the call graph for this function:

nsIMdbFile* morkFile::GetThief ( ) const [inline, inherited]

Definition at line 161 of file morkFile.h.

{ return mFile_Thief; }

Here is the caller graph for this function:

NS_IMETHODIMP morkObject::GetWeakRefCount ( nsIMdbEnv ev,
mdb_count outCount 
) [virtual, inherited]

Implements nsIMdbObject.

Reimplemented in morkStore, and morkCursor.

Definition at line 161 of file morkObject.cpp.

{
  *outCount = WeakRefsOnly();
  return NS_OK;
}  

Here is the call graph for this function:

mork_bool morkNode::GoodRefs ( ) const [inline, inherited]

Definition at line 216 of file morkNode.h.

{ return mNode_Refs >= mNode_Uses; }
mork_bool morkNode::HasNodeAccess ( ) const [inline, inherited]

Definition at line 251 of file morkNode.h.

  { return ( IsOpenNode() || IsShutNode() || IsClosingNode() ); }

Here is the call graph for this function:

mork_bool morkNode::IsAsleep ( ) const [inline, inherited]

Definition at line 142 of file morkNode.h.

mork_bool morkBead::IsBead ( ) const [inline, inherited]

Definition at line 113 of file morkBead.h.

  { return IsNode() && mNode_Derived == morkDerived_kBead; }

Here is the call graph for this function:

mork_bool morkNode::IsClosingNode ( ) const [inline, inherited]

Definition at line 245 of file morkNode.h.

Here is the caller graph for this function:

mork_bool morkNode::IsDeadNode ( ) const [inline, inherited]

Definition at line 242 of file morkNode.h.

Here is the caller graph for this function:

mork_bool morkFile::IsFile ( ) const [inline, inherited]

Definition at line 112 of file morkFile.h.

  { return IsNode() && mNode_Derived == morkDerived_kFile; }

Here is the call graph for this function:

mork_bool morkNode::IsFrozen ( ) const [inline, inherited]

Definition at line 140 of file morkNode.h.

Here is the caller graph for this function:

NS_IMETHODIMP morkObject::IsFrozenMdbObject ( nsIMdbEnv ev,
mdb_bool outIsReadonly 
) [virtual, inherited]

Implements nsIMdbObject.

Reimplemented in morkCursor.

Definition at line 211 of file morkObject.cpp.

{
  *outIsReadonly = IsFrozen();
  return NS_OK;
}

Here is the call graph for this function:

mork_bool morkNode::IsHeapNode ( ) const [inline, inherited]

Definition at line 233 of file morkNode.h.

  { return mNode_Usage == morkUsage_kHeap; }
mork_bool morkNode::IsMutable ( ) const [inline, inherited]

Definition at line 141 of file morkNode.h.

Here is the caller graph for this function:

mork_bool morkNode::IsNode ( ) const [inline, inherited]

Definition at line 193 of file morkNode.h.

  { return mNode_Base == morkBase_kNode; }
mork_bool morkNode::IsNodeClean ( ) const [inline, inherited]

Definition at line 147 of file morkNode.h.

{ return mNode_Load == morkLoad_kClean; }

Here is the caller graph for this function:

mork_bool morkNode::IsNodeDirty ( ) const [inline, inherited]

Definition at line 148 of file morkNode.h.

{ return mNode_Load == morkLoad_kDirty; }

Here is the caller graph for this function:

mork_bool morkObject::IsObject ( ) const [inline, inherited]

Definition at line 149 of file morkObject.h.

Here is the call graph for this function:

mork_bool morkFile::IsOpenActiveAndMutableFile ( ) const [inline, inherited]

Definition at line 152 of file morkFile.h.

  { return ( IsOpenNode() && FileActive() && !FileFrozen() ); }

Here is the call graph for this function:

Here is the caller graph for this function:

mork_bool morkFile::IsOpenAndActiveFile ( ) const [inline, inherited]

Definition at line 156 of file morkFile.h.

  { return ( this->IsOpenNode() && this->FileActive() ); }

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP morkObject::IsOpenMdbObject ( nsIMdbEnv ev,
mdb_bool outOpen 
) [virtual, inherited]

Implements nsIMdbObject.

Reimplemented in morkStore, and morkCursor.

Definition at line 205 of file morkObject.cpp.

{
  *outOpen = IsOpenNode();
  return NS_OK;
}

Here is the call graph for this function:

mork_bool morkNode::IsOpenNode ( ) const [inline, inherited]

Definition at line 236 of file morkNode.h.

mork_bool morkNode::IsOpenOrClosingNode ( ) const [inline, inherited]

Definition at line 248 of file morkNode.h.

  { return IsOpenNode() || IsClosingNode(); }

Here is the call graph for this function:

Here is the caller graph for this function:

mork_bool morkNode::IsShutNode ( ) const [inline, inherited]

Definition at line 239 of file morkNode.h.

Here is the caller graph for this function:

mork_bool morkStream::IsStream ( ) const [inline]

Definition at line 128 of file morkStream.h.

Here is the call graph for this function:

mork_pos morkStream::Length ( morkEnv ev) const [virtual]

Implements morkFile.

Definition at line 405 of file morkStream.cpp.

{
  mork_pos outPos = 0;

  nsIMdbFile* file = mStream_ContentFile;
  if ( this->IsOpenAndActiveFile() && file )
  {
    mork_pos contentEof = 0;
    file->Eof(ev->AsMdbEnv(), &contentEof);
    if ( ev->Good() )
    {
      if ( mStream_WriteEnd ) // this stream supports writing?
      {
        // the local buffer might have buffered content past content eof
        if ( ev->Good() ) // no error happened during Length() above?
        {
          mork_u1* at = mStream_At;
          mork_u1* buf = mStream_Buf;
          if ( at >= buf ) // expected cursor order?
          {
            mork_pos localContent = mStream_BufPos + (at - buf);
            if ( localContent > contentEof ) // buffered past eof?
              contentEof = localContent; // return new logical eof

            outPos = contentEof;
          }
          else this->NewBadCursorOrderError(ev);
        }
      }
      else
        outPos = contentEof; // frozen files get length from content file
    }
  }
  else this->NewFileDownError(ev);

  return outPos;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void * morkNode::MakeNew ( size_t  inSize,
nsIMdbHeap ioHeap,
morkEnv ev 
) [static, inherited]

Definition at line 177 of file morkNode.cpp.

{
  void* node = 0;
  if ( &ioHeap )
  {
    ioHeap.Alloc(ev->AsMdbEnv(), inSize, (void **) &node);
    if ( !node )
      ev->OutOfMemoryError();
  }
  else
    ev->NilPointerError();
  
  return node;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void morkNode::MarkClosing ( ) [inline, inherited]

Definition at line 255 of file morkNode.h.

void morkNode::MarkDead ( ) [inline, inherited]

Definition at line 256 of file morkNode.h.

void morkNode::MarkShut ( ) [inline, inherited]

Definition at line 254 of file morkNode.h.

Definition at line 458 of file morkStream.cpp.

{ ev->NewError("bad stream cursor order"); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 443 of file morkStream.cpp.

{ ev->NewError("bad stream cursor slots"); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 449 of file morkStream.cpp.

{ ev->NewError("cant read stream sink"); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 452 of file morkStream.cpp.

{ ev->NewError("cant write stream source"); }

Here is the call graph for this function:

Here is the caller graph for this function:

void morkFile::NewFileDownError ( morkEnv ev) const [inherited]

Definition at line 243 of file morkFile.cpp.

{
  if ( this->IsOpenNode() )
  {
    if ( this->FileActive() )
    {
      if ( this->FileFrozen() )
      {
        ev->NewError("file frozen");
      }
      else
        ev->NewError("unknown file problem");
    }
    else
      ev->NewError("file not active");
  }
  else
    ev->NewError("file not open");
}

Here is the caller graph for this function:

void morkFile::NewFileErrnoError ( morkEnv ev) const [inherited]

Definition at line 266 of file morkFile.cpp.

{
  const char* errnoString = strerror(errno);
  ev->NewError(errnoString); // maybe pass value of strerror() instead
}

Here is the call graph for this function:

Here is the caller graph for this function:

void morkFile::NewMissingIoError ( morkEnv ev) const [inherited]

Definition at line 194 of file morkFile.cpp.

{
  ev->NewError("file missing io");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 446 of file morkStream.cpp.

{ ev->NewError("null stream buffer"); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 455 of file morkStream.cpp.

{ ev->NewError("stream pos beyond eof"); }

Here is the call graph for this function:

Here is the caller graph for this function:

void morkFile::NilFileNameError ( morkEnv ev) [static, inherited]

Definition at line 212 of file morkFile.cpp.

{
  ev->NewError("nil mFile_Name");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void morkNode::NilHeapError ( morkEnv ev) const [inherited]

Definition at line 354 of file morkNode.cpp.

{
  ev->NewError("nil mNode_Heap");
}

Here is the caller graph for this function:

void morkFile::NilSlotHeapError ( morkEnv ev) [static, inherited]

Definition at line 206 of file morkFile.cpp.

{
  ev->NewError("nil mFile_SlotHeap");
}

Here is the call graph for this function:

Here is the caller graph for this function:

mork_usage morkNode::NodeUsage ( ) const [inline, inherited]

Definition at line 231 of file morkNode.h.

{ return mNode_Usage; }
void morkFile::NonFileTypeError ( morkEnv ev) [static, inherited]

Definition at line 200 of file morkFile.cpp.

{
  ev->NewError("non morkFile");
}

Here is the call graph for this function:

void morkNode::NonMutableNodeError ( morkEnv ev) const [inherited]

Definition at line 348 of file morkNode.cpp.

{
  ev->NewError("non-mutable-morkNode");
}

Here is the caller graph for this function:

void morkNode::NonNodeError ( morkEnv ev) const [inherited]

Definition at line 336 of file morkNode.cpp.

{
  ev->NewError("non-morkNode");
}
void morkNode::NonOpenNodeError ( morkEnv ev) const [inherited]

Definition at line 342 of file morkNode.cpp.

{
  ev->NewError("non-open-morkNode");
}

Here is the caller graph for this function:

morkFile * morkFile::OpenOldFile ( morkEnv ev,
nsIMdbHeap ioHeap,
const char *  inFilePath,
mork_bool  inFrozen 
) [static, inherited]

Definition at line 168 of file morkFile.cpp.

{
  return morkStdioFile::OpenOldStdioFile(ev, ioHeap, inFilePath, inFrozen);
}

Here is the call graph for this function:

void* morkNode::operator new ( size_t  inSize,
nsIMdbHeap ioHeap,
morkEnv ev 
) [inline, inherited]

Reimplemented in morkTable, morkFactory, morkPool, and morkSorting.

Definition at line 159 of file morkNode.h.

  { return morkNode::MakeNew(inSize, ioHeap, ev); }

Here is the call graph for this function:

morkStream& morkStream::operator= ( const morkStream other) [private]
NS_IMETHODIMP morkFile::Path ( nsIMdbEnv ev,
mdbYarn outFilePath 
) [virtual, inherited]

Implements nsIMdbFile.

Definition at line 363 of file morkFile.cpp.

{
  mdb_err outErr = 0;
  if ( outFilePath )
    outFilePath->mYarn_Fill = 0;
  morkEnv *ev = morkEnv::FromMdbEnv(mev);
  if ( ev )
  {
    ev->StringToYarn(GetFileNameString(), outFilePath);
    outErr = ev->AsErr();
  }
  return outErr;
}

Here is the call graph for this function:

NS_IMETHODIMP morkFile::Put ( nsIMdbEnv ev,
const void inBuf,
mdb_size  inSize,
mdb_pos  inPos,
mdb_size outActualSize 
) [virtual, inherited]

Implements nsIMdbFile.

Definition at line 343 of file morkFile.cpp.

{
  mdb_err outErr = 0;
  *outActualSize = 0;
  morkEnv *ev = morkEnv::FromMdbEnv(mev);
  if ( ev )
  {
    mdb_pos outPos;

    Seek(mev, inPos, &outPos);
    if ( ev->Good() )
      Write(mev, inBuf, inSize, outActualSize);
    outErr = ev->AsErr();
  }
  return outErr;
}

Here is the call graph for this function:

mork_size morkStream::PutByteThenIndent ( morkEnv ev,
int  inByte,
mork_count  inDepth 
)

Definition at line 208 of file morkStream.cpp.

{
  mork_size outLength = 0;
  nsIMdbEnv *mev = ev->AsMdbEnv();
  
  if ( inDepth > morkStream_kMaxIndentDepth )
    inDepth = morkStream_kMaxIndentDepth;
  
  this->Putc(ev, inByte);
  if ( ev->Good() )
  {
    this->PutLineBreak(ev);
    if ( ev->Good() )
    {
      outLength = inDepth;
      mdb_size bytesWritten;
      if ( inDepth )
        this->Write(mev, morkStream_kSpaces, inDepth, &bytesWritten);
    }
  }
  return outLength;
}

Here is the call graph for this function:

Definition at line 304 of file morkStream.cpp.

{
  mork_size outSize = 1; // one for the following byte
  this->Putc(ev, inByte);
  if ( ev->Good() )
    outSize += this->PutLineBreak(ev);
  return outSize;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void morkStream::Putc ( morkEnv ev,
int  c 
) [inline]

Definition at line 227 of file morkStream.h.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 187 of file morkStream.cpp.

{
  mork_size outLength = 0;
  nsIMdbEnv *mev = ev->AsMdbEnv();
  if ( ev->Good() )
  {
    this->PutLineBreak(ev);
    if ( ev->Good() )
    {
      outLength = inDepth;
      mdb_size bytesWritten;
      if ( inDepth )
        this->Write(mev, morkStream_kSpaces, inDepth, &bytesWritten);
    }
  }
  return outLength;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 315 of file morkStream.cpp.

{
#if defined(MORK_MAC)

  this->Putc(ev, mork_kCR);
  return 1;
  
#else
#  if defined(MORK_WIN) || defined(MORK_OS2)
  
  this->Putc(ev, mork_kCR);
  this->Putc(ev, mork_kLF);
  return 2;
  
#  else
#    if defined(MORK_UNIX) || defined(MORK_BEOS)
  
  this->Putc(ev, mork_kLF);
  return 1;
  
#    endif /* MORK_UNIX || MORK_BEOS */
#  endif /* MORK_WIN */
#endif /* MORK_MAC */
}

Here is the call graph for this function:

Here is the caller graph for this function:

mork_size morkStream::PutString ( morkEnv ev,
const char *  inString 
)

Definition at line 267 of file morkStream.cpp.

{
  nsIMdbEnv *mev = ev->AsMdbEnv();
  mork_size outSize = 0;
  mdb_size bytesWritten;
  if ( inString )
  {
    outSize = MORK_STRLEN(inString);
    if ( outSize && ev->Good() ) // any bytes to write?
    {
      this->Write(mev, inString, outSize, &bytesWritten);
    }
  }
  return outSize;
}

Here is the call graph for this function:

Here is the caller graph for this function:

mork_size morkStream::PutStringThenIndent ( morkEnv ev,
const char *  inString,
mork_count  inDepth 
)

Definition at line 234 of file morkStream.cpp.

{
  mork_size outLength = 0;
  mdb_size bytesWritten;
  nsIMdbEnv *mev = ev->AsMdbEnv();
  
  if ( inDepth > morkStream_kMaxIndentDepth )
    inDepth = morkStream_kMaxIndentDepth;
  
  if ( inString )
  {
    mork_size length = MORK_STRLEN(inString);
    if ( length && ev->Good() ) // any bytes to write?
      this->Write(mev, inString, length, &bytesWritten);
  }
  
  if ( ev->Good() )
  {
    this->PutLineBreak(ev);
    if ( ev->Good() )
    {
      outLength = inDepth;
      if ( inDepth )
        this->Write(mev, morkStream_kSpaces, inDepth, &bytesWritten);
    }
  }
  return outLength;
}

Here is the call graph for this function:

mork_size morkStream::PutStringThenNewline ( morkEnv ev,
const char *  inString 
)

Definition at line 284 of file morkStream.cpp.

{
  nsIMdbEnv *mev = ev->AsMdbEnv();
  mork_size outSize = 0;
  mdb_size bytesWritten;
  if ( inString )
  {
    outSize = MORK_STRLEN(inString);
    if ( outSize && ev->Good() ) // any bytes to write?
    {
      this->Write(mev, inString, outSize, &bytesWritten);
      if ( ev->Good() )
        outSize += this->PutLineBreak(ev);
    }
  }
  return outSize;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP morkStream::Read ( nsIMdbEnv ev,
void outBuf,
mork_size  inSize,
mork_size aOutCount 
) [virtual]

Implements morkFile.

Definition at line 501 of file morkStream.cpp.

{
  NS_ENSURE_ARG_POINTER(aOutSize);
  // First we satisfy the request from buffered bytes, if any.  Then
  // if additional bytes are needed, we satisfy these by direct reads
  // from the content file without any local buffering (but we still need
  // to adjust the buffer position to reflect the current i/o point).

  morkEnv *ev = morkEnv::FromMdbEnv(mdbev);
  nsresult rv = NS_OK;

  nsIMdbFile* file = mStream_ContentFile;
  if ( this->IsOpenAndActiveFile() && file )
  {
    mork_u1* end = mStream_ReadEnd; // byte after last buffered byte
    if ( end ) // file is open for read access?
    {
      if ( inSize ) // caller wants any output?
      {
        mork_u1* sink = (mork_u1*) outBuf; // where we plan to write bytes
        if ( sink ) // caller passed good buffer address?
        {
          mork_u1* at = mStream_At;
          mork_u1* buf = mStream_Buf;
          if ( at >= buf && at <= end ) // expected cursor order?
          {
            mork_num remaining = (mork_num) (end - at); // bytes left in buffer
            
            mork_num quantum = inSize; // number of bytes to copy
            if ( quantum > remaining ) // more than buffer content?
              quantum = remaining; // restrict to buffered bytes
              
            if ( quantum ) // any bytes left in the buffer?
            {
              MORK_MEMCPY(sink, at, quantum); // from buffer bytes
              
              at += quantum; // advance past read bytes
              mStream_At = at;
              *aOutSize += quantum;  // this much copied so far

              sink += quantum;   // in case we need to copy more
              inSize -= quantum; // filled this much of request
              mStream_HitEof = morkBool_kFalse;
            }
            
            if ( inSize ) // we still need to read more content?
            {
              // We need to read more bytes directly from the
              // content file, without local buffering.  We have
              // exhausted the local buffer, so we need to show
              // it is now empty, and adjust the current buf pos.
              
              mork_num posDelta = (mork_num) (at - buf); // old buf content
              mStream_BufPos += posDelta;   // past now empty buf
              
              mStream_At = mStream_ReadEnd = buf; // empty buffer
              
              // file->Seek(ev, mStream_BufPos); // set file pos
              // if ( ev->Good() ) // no seek error?
              // {
              // }
              
              mork_num actual = 0;
              nsIMdbEnv* menv = ev->AsMdbEnv();
              file->Get(menv, sink, inSize, mStream_BufPos, &actual);
              if ( ev->Good() ) // no read error?
              {
                if ( actual )
                {
                  *aOutSize += actual;
                  mStream_BufPos += actual;
                  mStream_HitEof = morkBool_kFalse;
                }
                else if ( !*aOutSize )
                  mStream_HitEof = morkBool_kTrue;
              }
            }
          }
          else this->NewBadCursorOrderError(ev);
        }
        else this->NewNullStreamBufferError(ev);
      }
    }
    else this->NewCantReadSinkError(ev);
  }
  else this->NewFileDownError(ev);
  
  if ( ev->Bad() )
    *aOutSize = 0;

  return rv;
}

Here is the call graph for this function:

void morkNode::RefsOverflowWarning ( morkEnv ev) const [inherited]

Definition at line 360 of file morkNode.cpp.

{
  ev->NewWarning("mNode_Refs overflow");
}

Here is the caller graph for this function:

void morkNode::RefsUnderflowWarning ( morkEnv ev) const [inherited]

Definition at line 372 of file morkNode.cpp.

{
  ev->NewWarning("mNode_Refs underflow");
}

Here is the caller graph for this function:

void morkNode::RefsUnderUsesWarning ( morkEnv ev) const [inherited]

Definition at line 330 of file morkNode.cpp.

{
  ev->NewError("mNode_Refs < mNode_Uses");
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP morkStream::Seek ( nsIMdbEnv ev,
mork_pos  inPos,
mork_pos aOutPos 
) [virtual]

Implements morkFile.

Definition at line 595 of file morkStream.cpp.

{
  NS_ENSURE_ARG_POINTER(aOutPos);
  morkEnv *ev = morkEnv::FromMdbEnv(mdbev);
  *aOutPos = 0;
  nsresult rv = NS_OK;
  nsIMdbFile* file = mStream_ContentFile;
  if ( this->IsOpenOrClosingNode() && this->FileActive() && file )
  {
    mork_u1* at = mStream_At;             // current position in buffer
    mork_u1* buf = mStream_Buf;           // beginning of buffer 
    mork_u1* readEnd = mStream_ReadEnd;   // nonzero only if readonly
    mork_u1* writeEnd = mStream_WriteEnd; // nonzero only if writeonly
    
    if ( writeEnd ) // file is mutable/writeonly?
    {
      if ( mStream_Dirty ) // need to commit buffer changes?
        this->Flush(mdbev);

      if ( ev->Good() ) // no errors during flush or earlier?
      {
        if ( at == buf ) // expected post flush cursor value?
        {
          if ( mStream_BufPos != inPos ) // need to change pos?
          {
            mork_pos eof = 0;
            nsIMdbEnv* menv = ev->AsMdbEnv();
            file->Eof(menv, &eof);
            if ( ev->Good() ) // no errors getting length?
            {
              if ( inPos <= eof ) // acceptable new position?
              {
                mStream_BufPos = inPos; // new stream position
                *aOutPos = inPos;
              }
              else this->NewPosBeyondEofError(ev);
            }
          }
        }
        else this->NewBadCursorOrderError(ev);
      }
    }
    else if ( readEnd ) // file is frozen/readonly?
    {
      if ( at >= buf && at <= readEnd ) // expected cursor order?
      {
        mork_pos eof = 0;
        nsIMdbEnv* menv = ev->AsMdbEnv();
        file->Eof(menv, &eof);
        if ( ev->Good() ) // no errors getting length?
        {
          if ( inPos <= eof ) // acceptable new position?
          {
            *aOutPos = inPos;
            mStream_BufPos = inPos; // new stream position
            mStream_At = mStream_ReadEnd = buf; // empty buffer
            if ( inPos == eof ) // notice eof reached?
              mStream_HitEof = morkBool_kTrue;
          }
          else this->NewPosBeyondEofError(ev);
        }
      }
      else this->NewBadCursorOrderError(ev);
    }
      
  }
  else this->NewFileDownError(ev);

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void morkNode::SetAsleep ( ) [inline, inherited]

Definition at line 138 of file morkNode.h.

void morkFile::SetFileActive ( mork_bool  b) [inline, inherited]

Definition at line 149 of file morkFile.h.

{ mFile_Active = (mork_u1) ((b)? 'A' : 0); }

Here is the caller graph for this function:

void morkFile::SetFileDoTrace ( mork_bool  b) [inline, inherited]

Definition at line 147 of file morkFile.h.

{ mFile_DoTrace = (mork_u1) ((b)? 'T' : 0); }
void morkFile::SetFileFrozen ( mork_bool  b) [inline, inherited]

Definition at line 146 of file morkFile.h.

{ mFile_Frozen = (mork_u1) ((b)? 'F' : 0); }

Here is the caller graph for this function:

void morkFile::SetFileIoOpen ( mork_bool  b) [inline, inherited]

Definition at line 148 of file morkFile.h.

{ mFile_IoOpen = (mork_u1) ((b)? 'O' : 0); }

Here is the caller graph for this function:

void morkFile::SetFileName ( morkEnv ev,
const char *  inName 
) [inherited]

Definition at line 224 of file morkFile.cpp.

{
  nsIMdbHeap* heap = mFile_SlotHeap;
  if ( heap )
  {
    char* name = mFile_Name;
    if ( name )
    {
      mFile_Name = 0;
      ev->FreeString(heap, name);
    }
    if ( ev->Good() && inName )
      mFile_Name = ev->CopyString(heap, inName);
  }
  else
    this->NilSlotHeapError(ev);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void morkNode::SetFrozen ( ) [inline, inherited]

Definition at line 136 of file morkNode.h.

void morkNode::SetMutable ( ) [inline, inherited]

Definition at line 137 of file morkNode.h.

void morkNode::SetNodeClean ( ) [inline, inherited]

Definition at line 144 of file morkNode.h.

Here is the caller graph for this function:

void morkNode::SetNodeDirty ( ) [inline, inherited]

Definition at line 145 of file morkNode.h.

Here is the caller graph for this function:

void morkFile::SetThief ( morkEnv ev,
nsIMdbFile ioThief 
) [inherited]

Definition at line 218 of file morkFile.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static void morkBead::SlotStrongBead ( morkBead me,
morkEnv ev,
morkBead **  ioSlot 
) [inline, static, inherited]

Definition at line 124 of file morkBead.h.

  { morkNode::SlotStrongNode((morkNode*) me, ev, (morkNode**) ioSlot); }

Here is the call graph for this function:

static void morkFile::SlotStrongFile ( morkFile me,
morkEnv ev,
morkFile **  ioSlot 
) [inline, static, inherited]

Definition at line 187 of file morkFile.h.

  { morkNode::SlotStrongNode((morkNode*) me, ev, (morkNode**) ioSlot); }

Here is the call graph for this function:

void morkNode::SlotStrongNode ( morkNode me,
morkEnv ev,
morkNode **  ioSlot 
) [static, inherited]

Definition at line 466 of file morkNode.cpp.

{
  morkNode* node = *ioSlot;
  if ( me != node )
  {
    if ( node )
    {
      // what if this nulls out the ev and causes asserts?
      // can we move this after the CutStrongRef()?
      *ioSlot = 0;
      node->CutStrongRef(ev);
    }
    if ( me && me->AddStrongRef(ev) )
      *ioSlot = me;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void morkObject::SlotStrongObject ( morkObject me,
morkEnv ev,
morkObject **  ioSlot 
) [inline, static, inherited]

Definition at line 160 of file morkObject.h.

  { morkNode::SlotStrongNode((morkNode*) me, ev, (morkNode**) ioSlot); }

Here is the call graph for this function:

Here is the caller graph for this function:

static void morkStream::SlotStrongStream ( morkStream me,
morkEnv ev,
morkStream **  ioSlot 
) [inline, static]

Definition at line 243 of file morkStream.h.

  { morkNode::SlotStrongNode((morkNode*) me, ev, (morkNode**) ioSlot); }

Here is the call graph for this function:

Here is the caller graph for this function:

static void morkBead::SlotWeakBead ( morkBead me,
morkEnv ev,
morkBead **  ioSlot 
) [inline, static, inherited]

Definition at line 120 of file morkBead.h.

  { morkNode::SlotWeakNode((morkNode*) me, ev, (morkNode**) ioSlot); }

Here is the call graph for this function:

static void morkFile::SlotWeakFile ( morkFile me,
morkEnv ev,
morkFile **  ioSlot 
) [inline, static, inherited]

Definition at line 183 of file morkFile.h.

  { morkNode::SlotWeakNode((morkNode*) me, ev, (morkNode**) ioSlot); }

Here is the call graph for this function:

void morkNode::SlotWeakNode ( morkNode me,
morkEnv ev,
morkNode **  ioSlot 
) [static, inherited]

Definition at line 489 of file morkNode.cpp.

{
  morkNode* node = *ioSlot;
  if ( me != node )
  {
    if ( node )
    {
      *ioSlot = 0;
      node->CutWeakRef(ev);
    }
    if ( me && me->AddWeakRef(ev) )
      *ioSlot = me;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void morkObject::SlotWeakObject ( morkObject me,
morkEnv ev,
morkObject **  ioSlot 
) [inline, static, inherited]

Definition at line 156 of file morkObject.h.

  { morkNode::SlotWeakNode((morkNode*) me, ev, (morkNode**) ioSlot); }

Here is the call graph for this function:

static void morkStream::SlotWeakStream ( morkStream me,
morkEnv ev,
morkStream **  ioSlot 
) [inline, static]

Definition at line 239 of file morkStream.h.

  { morkNode::SlotWeakNode((morkNode*) me, ev, (morkNode**) ioSlot); }

Here is the call graph for this function:

void morkStream::spill_buf ( morkEnv ev) [protected]

Definition at line 843 of file morkStream.cpp.

{
  nsIMdbFile* file = mStream_ContentFile;
  if ( this->IsOpenOrClosingNode() && this->FileActive() && file )
  {
    mork_u1* buf = mStream_Buf;
    if ( mStream_Dirty )
    {
      mork_u1* at = mStream_At;
      if ( at >= buf && at <= mStream_WriteEnd ) // order?
      {
        mork_num count = (mork_num) (at - buf); // bytes buffered
        if ( count ) // anything to write to the string?
        {
          if ( count > mStream_BufSize ) // no more than max?
          {
            count = mStream_BufSize;
            mStream_WriteEnd = buf + mStream_BufSize;
            this->NewBadCursorSlotsError(ev);
          }
          if ( ev->Good() )
          {
            // file->Seek(ev, mStream_BufPos);
            // if ( ev->Good() )
            // {
            // }
            nsIMdbEnv* menv = ev->AsMdbEnv();
            mork_num actual = 0;
            
            file->Put(menv, buf, count, mStream_BufPos, &actual);
            if ( ev->Good() )
            {
              mStream_BufPos += actual; // past bytes written
              mStream_At = buf; // reset buffer cursor
              mStream_Dirty = morkBool_kFalse;
            }
          }
        }
      }
      else this->NewBadCursorOrderError(ev);
    }
    else
    {
#ifdef MORK_DEBUG
      ev->NewWarning("stream:spill:not:dirty");
#endif /*MORK_DEBUG*/
    }
  }
  else this->NewFileDownError(ev);

}

Here is the call graph for this function:

Here is the caller graph for this function:

void morkStream::spill_putc ( morkEnv ev,
int  c 
) [protected]

Definition at line 835 of file morkStream.cpp.

{
  this->spill_buf(ev);
  if ( ev->Good() && mStream_At < mStream_WriteEnd )
    this->Putc(ev, c);
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP morkStream::Steal ( nsIMdbEnv ev,
nsIMdbFile ioThief 
) [virtual]

Implements morkFile.

Definition at line 344 of file morkStream.cpp.

Here is the call graph for this function:

mork_uses morkNode::StrongRefsOnly ( ) const [inline, inherited]

Definition at line 219 of file morkNode.h.

{ return mNode_Uses; }

Here is the caller graph for this function:

NS_IMETHODIMP morkStream::Tell ( nsIMdbEnv ev,
mork_pos aOutPos 
) const [virtual]

Implements morkFile.

Definition at line 462 of file morkStream.cpp.

{
  nsresult rv = NS_OK;
  morkEnv *ev = morkEnv::FromMdbEnv(mdbev);

  NS_ENSURE_ARG_POINTER(aOutPos);
  
  nsIMdbFile* file = mStream_ContentFile;
  if ( this->IsOpenAndActiveFile() && file )
  {
    mork_u1* buf = mStream_Buf;
    mork_u1* at = mStream_At;
    
    mork_u1* readEnd = mStream_ReadEnd;   // nonzero only if readonly
    mork_u1* writeEnd = mStream_WriteEnd; // nonzero only if writeonly
    
    if ( writeEnd )
    {
      if ( buf && at >= buf && at <= writeEnd ) 
      {
        *aOutPos = mStream_BufPos + (at - buf);
      }
      else this->NewBadCursorOrderError(ev);
    }
    else if ( readEnd )
    {
      if ( buf && at >= buf && at <= readEnd ) 
      {
        *aOutPos = mStream_BufPos + (at - buf);
      }
      else this->NewBadCursorOrderError(ev);
    }
  }
  else this->NewFileDownError(ev);

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP morkFile::Thief ( nsIMdbEnv ev,
nsIMdbFile **  acqThief 
) [virtual, inherited]

Implements nsIMdbFile.

Definition at line 383 of file morkFile.cpp.

{
  mdb_err outErr = 0;
  nsIMdbFile* outThief = 0;
  morkEnv *ev = morkEnv::FromMdbEnv(mev);
  if ( ev )
  {
    outThief = GetThief();
    NS_IF_ADDREF(outThief);
    outErr = ev->AsErr();
  }
  if ( acqThief )
    *acqThief = outThief;
  return outErr;
}

Here is the call graph for this function:

void morkStream::Ungetc ( int  c) [inline]

Definition at line 220 of file morkStream.h.

  { if ( mStream_At > mStream_Buf && c > 0 ) *--mStream_At = (mork_u1) c; }

Here is the caller graph for this function:

void morkNode::UsesOverflowWarning ( morkEnv ev) const [inherited]

Definition at line 366 of file morkNode.cpp.

{
  ev->NewWarning("mNode_Uses overflow");
}
void morkNode::UsesUnderflowWarning ( morkEnv ev) const [inherited]

Definition at line 378 of file morkNode.cpp.

{
  ev->NewWarning("mNode_Uses underflow");
}

Here is the caller graph for this function:

mork_refs morkNode::WeakRefsOnly ( ) const [inline, inherited]

Definition at line 220 of file morkNode.h.

{ return (mork_refs) ( mNode_Refs - mNode_Uses ); }

Here is the caller graph for this function:

NS_IMETHODIMP morkStream::Write ( nsIMdbEnv ev,
const void inBuf,
mork_size  inSize,
mork_size aOutCount 
) [virtual]

Implements morkFile.

Definition at line 667 of file morkStream.cpp.

{
  mork_num outActual = 0;
  morkEnv *ev = morkEnv::FromMdbEnv(menv);

  nsIMdbFile* file = mStream_ContentFile;
  if ( this->IsOpenActiveAndMutableFile() && file )
  {
    mork_u1* end = mStream_WriteEnd; // byte after last buffered byte
    if ( end ) // file is open for write access?
    {
      if ( inSize ) // caller provided any input?
      {
        const mork_u1* source = (const mork_u1*) inBuf; // from where
        if ( source ) // caller passed good buffer address?
        {
          mork_u1* at = mStream_At;
          mork_u1* buf = mStream_Buf;
          if ( at >= buf && at <= end ) // expected cursor order?
          {
            mork_num space = (mork_num) (end - at); // space left in buffer
            
            mork_num quantum = inSize; // number of bytes to write
            if ( quantum > space ) // more than buffer size?
              quantum = space; // restrict to avail space
              
            if ( quantum ) // any space left in the buffer?
            {
              mStream_Dirty = morkBool_kTrue; // to ensure later flush
              MORK_MEMCPY(at, source, quantum); // into buffer
              
              mStream_At += quantum; // advance past written bytes
              outActual += quantum;  // this much written so far

              source += quantum; // in case we need to write more
              inSize -= quantum; // filled this much of request
            }
            
            if ( inSize ) // we still need to write more content?
            {
              // We need to write more bytes directly to the
              // content file, without local buffering.  We have
              // exhausted the local buffer, so we need to flush
              // it and empty it, and adjust the current buf pos.
              // After flushing, if the rest of the write fits
              // inside the buffer, we will put bytes into the
              // buffer rather than write them to content file.
              
              if ( mStream_Dirty )
                this->Flush(menv); // will update mStream_BufPos

              at = mStream_At;
              if ( at < buf || at > end ) // bad cursor?
                this->NewBadCursorOrderError(ev);
                
              if ( ev->Good() ) // no errors?
              {
                space = (mork_num) (end - at); // space left in buffer
                if ( space > inSize ) // write to buffer?
                {
                  mStream_Dirty = morkBool_kTrue; // ensure flush
                  MORK_MEMCPY(at, source, inSize); // copy
                  
                  mStream_At += inSize; // past written bytes
                  outActual += inSize;  // this much written
                }
                else // directly to content file instead
                {
                  // file->Seek(ev, mStream_BufPos); // set pos
                  // if ( ev->Good() ) // no seek error?
                  // {
                  // }

                  mork_num actual = 0;
                  file->Put(menv, source, inSize, mStream_BufPos, &actual);
                  if ( ev->Good() ) // no write error?
                  {
                    outActual += actual;
                    mStream_BufPos += actual;
                  }
                }
              }
            }
          }
          else this->NewBadCursorOrderError(ev);
        }
        else this->NewNullStreamBufferError(ev);
      }
    }
    else this->NewCantWriteSourceError(ev);
  }
  else this->NewFileDownError(ev);
  
  if ( ev->Bad() )
    outActual = 0;

  *aOutSize = outActual;
  return ev->AsErr();
}

Here is the call graph for this function:

Here is the caller graph for this function:

mork_size morkFile::WriteNewlines ( morkEnv ev,
mork_count  inNewlines 
) [inherited]

Definition at line 294 of file morkFile.cpp.

{
  mork_size outSize = 0;
  while ( inNewlines && ev->Good() ) // more newlines to write?
  {
    mork_u4 quantum = inNewlines;
    if ( quantum > morkFile_kNewlinesCount )
      quantum = morkFile_kNewlinesCount;

    mork_size quantumSize = quantum * mork_kNewlineSize;
    mdb_size bytesWritten;
    this->Write(ev->AsMdbEnv(), morkFile_kNewlines, quantumSize, &bytesWritten);
    outSize += quantumSize;
    inNewlines -= quantum;
  }
  return outSize;
}

Here is the call graph for this function:

void morkNode::ZapOld ( morkEnv ev,
nsIMdbHeap ioHeap 
) [inherited]

Definition at line 193 of file morkNode.cpp.

{
  if ( this )
  {
    if ( this->IsNode() )
    {
      mork_usage usage = mNode_Usage; // mNode_Usage before ~morkNode
      this->morkNode::~morkNode(); // first call polymorphic destructor
      if ( ioHeap ) // was this node heap allocated?
        ioHeap->Free(ev->AsMdbEnv(), this);
      else if ( usage == morkUsage_kPool ) // mNode_Usage before ~morkNode
      {
        morkHandle* h = (morkHandle*) this;
        if ( h->IsHandle() && h->GoodHandleTag() )
        {
          if ( h->mHandle_Face )
          {
            if (ev->mEnv_HandlePool)
              ev->mEnv_HandlePool->ZapHandle(ev, h->mHandle_Face);
            else if (h->mHandle_Env && h->mHandle_Env->mEnv_HandlePool)
              h->mHandle_Env->mEnv_HandlePool->ZapHandle(ev, h->mHandle_Face);
          }
          else
            ev->NilPointerError();
        }
      }
    }
    else
      this->NonNodeError(ev);
  }
  else
    ev->NilPointerError();
}

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class morkHandleFrame [friend, inherited]

Reimplemented in morkHandle.

Definition at line 131 of file morkNode.h.


Member Data Documentation

Definition at line 83 of file morkBead.h.

mork_u1 morkFile::mFile_Active [protected, inherited]

Definition at line 88 of file morkFile.h.

mork_u1 morkFile::mFile_DoTrace [protected, inherited]

Definition at line 86 of file morkFile.h.

mork_u1 morkFile::mFile_Frozen [protected, inherited]

Definition at line 85 of file morkFile.h.

mork_u1 morkFile::mFile_IoOpen [protected, inherited]

Definition at line 87 of file morkFile.h.

char* morkFile::mFile_Name [protected, inherited]

Definition at line 91 of file morkFile.h.

nsIMdbHeap* morkFile::mFile_SlotHeap [protected, inherited]

Definition at line 90 of file morkFile.h.

nsIMdbFile* morkFile::mFile_Thief [protected, inherited]

Definition at line 94 of file morkFile.h.

Definition at line 91 of file morkObject.h.

Definition at line 122 of file morkNode.h.

Definition at line 119 of file morkNode.h.

Definition at line 120 of file morkNode.h.

Definition at line 117 of file morkNode.h.

Definition at line 125 of file morkNode.h.

Definition at line 124 of file morkNode.h.

Definition at line 128 of file morkNode.h.

Definition at line 123 of file morkNode.h.

Definition at line 127 of file morkNode.h.

Definition at line 89 of file morkObject.h.

Definition at line 101 of file morkStream.h.

Definition at line 107 of file morkStream.h.

Definition at line 109 of file morkStream.h.

Definition at line 108 of file morkStream.h.

Definition at line 105 of file morkStream.h.

Definition at line 110 of file morkStream.h.

Definition at line 111 of file morkStream.h.

Definition at line 102 of file morkStream.h.

Definition at line 103 of file morkStream.h.


The documentation for this class was generated from the following files: