Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions
morkBigBookAtom Class Reference

#include <morkAtom.h>

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

List of all members.

Public Member Functions

 morkBigBookAtom ()
void InitBigBookAtom (morkEnv *ev, const morkBuf &inBuf, mork_cscode inForm, morkAtomSpace *ioSpace, mork_aid inAid)
mork_u4 HashAid () const
mork_bool EqualAid (const morkBookAtom *inAtom) const
mork_u4 HashFormAndBody (morkEnv *ev) const
mork_bool EqualFormAndBody (morkEnv *ev, const morkBookAtom *inAtom) const
void CutBookAtomFromSpace (morkEnv *ev)
mork_bool IsWeeAnon () const
mork_bool IsBigAnon () const
mork_bool IsWeeBook () const
mork_bool IsBigBook () const
mork_bool IsFarBook () const
mork_bool IsRowOid () const
mork_bool IsTableOid () const
mork_bool IsBook () const
void SetAtomClean ()
void SetAtomDirty ()
mork_bool IsAtomClean () const
mork_bool IsAtomDirty () const
mork_scope GetBookAtomSpaceScope (morkEnv *ev) const
mork_aid GetBookAtomAid () const
void MakeCellUseForever (morkEnv *ev)
mork_u1 AddCellUse (morkEnv *ev)
mork_u1 CutCellUse (morkEnv *ev)
mork_bool IsCellUseForever () const
mork_bool AsBuf (morkBuf &outBuf) const
mork_bool AliasYarn (mdbYarn *outYarn) const
mork_bool GetYarn (mdbYarn *outYarn) const

Static Public Member Functions

static mork_size SizeForFill (mork_fill inFill)
static void NonBookAtomTypeError (morkEnv *ev)
static void BadAtomKindError (morkEnv *ev)
static void ZeroAidError (morkEnv *ev)
static void AtomSizeOverflowError (morkEnv *ev)

Public Attributes

mork_cscode mBigBookAtom_Form
mork_size mBigBookAtom_Size
mork_u1 mBigBookAtom_Body [1]
morkAtomSpacemBookAtom_Space
mork_aid mBookAtom_Id
mork_u1 mAtom_Kind
mork_u1 mAtom_CellUses
mork_change mAtom_Change
mork_u1 mAtom_Size

Private Member Functions

 morkBigBookAtom (const morkBigBookAtom &other)
morkBigBookAtomoperator= (const morkBigBookAtom &other)

Detailed Description

Definition at line 336 of file morkAtom.h.


Constructor & Destructor Documentation

Definition at line 352 of file morkAtom.h.

{ }

Here is the caller graph for this function:


Member Function Documentation

mork_u1 morkAtom::AddCellUse ( morkEnv ev) [inherited]

Definition at line 257 of file morkAtom.cpp.

{
  MORK_USED_1(ev); 
  if ( mAtom_CellUses < morkAtom_kMaxCellUses ) // not already maxed out?
    ++mAtom_CellUses;
    
  return mAtom_CellUses;
}

Here is the caller graph for this function:

mork_bool morkAtom::AliasYarn ( mdbYarn outYarn) const [inherited]

Definition at line 174 of file morkAtom.cpp.

{
  outYarn->mYarn_More = 0;
  outYarn->mYarn_Form = 0;
  const morkAtom* atom = this;
  
  if ( atom )
  {
    if ( atom->IsWeeBook() )
    {
      morkWeeBookAtom* weeBook = (morkWeeBookAtom*) atom;
      outYarn->mYarn_Buf = weeBook->mWeeBookAtom_Body;
      outYarn->mYarn_Fill = weeBook->mAtom_Size;
      outYarn->mYarn_Size = weeBook->mAtom_Size;
    }
    else if ( atom->IsBigBook() )
    {
      morkBigBookAtom* bigBook = (morkBigBookAtom*) atom;
      outYarn->mYarn_Buf = bigBook->mBigBookAtom_Body;
      outYarn->mYarn_Fill = bigBook->mBigBookAtom_Size;
      outYarn->mYarn_Size = bigBook->mBigBookAtom_Size;
      outYarn->mYarn_Form = bigBook->mBigBookAtom_Form;
    }
    else if ( atom->IsWeeAnon() )
    {
      morkWeeAnonAtom* weeAnon = (morkWeeAnonAtom*) atom;
      outYarn->mYarn_Buf = weeAnon->mWeeAnonAtom_Body;
      outYarn->mYarn_Fill = weeAnon->mAtom_Size;
      outYarn->mYarn_Size = weeAnon->mAtom_Size;
    }
    else if ( atom->IsBigAnon() )
    {
      morkBigAnonAtom* bigAnon = (morkBigAnonAtom*) atom;
      outYarn->mYarn_Buf = bigAnon->mBigAnonAtom_Body;
      outYarn->mYarn_Fill = bigAnon->mBigAnonAtom_Size;
      outYarn->mYarn_Size = bigAnon->mBigAnonAtom_Size;
      outYarn->mYarn_Form = bigAnon->mBigAnonAtom_Form;
    }
    else
      atom = 0; // show desire to put empty content in yarn
  }
  
  if ( !atom ) // empty content for yarn?
  {
    outYarn->mYarn_Buf = 0;
    outYarn->mYarn_Fill = 0;
    outYarn->mYarn_Size = 0;
    // outYarn->mYarn_Grow = 0; // please don't modify the Grow slot
  }
  return ( atom != 0 );
}

Here is the call graph for this function:

Here is the caller graph for this function:

mork_bool morkAtom::AsBuf ( morkBuf outBuf) const [inherited]

Definition at line 132 of file morkAtom.cpp.

{
  const morkAtom* atom = this;
  if ( atom )
  {
    if ( atom->IsWeeBook() )
    {
      morkWeeBookAtom* weeBook = (morkWeeBookAtom*) atom;
      outBuf.mBuf_Body = weeBook->mWeeBookAtom_Body;
      outBuf.mBuf_Fill = weeBook->mAtom_Size;
    }
    else if ( atom->IsBigBook() )
    {
      morkBigBookAtom* bigBook = (morkBigBookAtom*) atom;
      outBuf.mBuf_Body = bigBook->mBigBookAtom_Body;
      outBuf.mBuf_Fill = bigBook->mBigBookAtom_Size;
    }
    else if ( atom->IsWeeAnon() )
    {
      morkWeeAnonAtom* weeAnon = (morkWeeAnonAtom*) atom;
      outBuf.mBuf_Body = weeAnon->mWeeAnonAtom_Body;
      outBuf.mBuf_Fill = weeAnon->mAtom_Size;
    }
    else if ( atom->IsBigAnon() )
    {
      morkBigAnonAtom* bigAnon = (morkBigAnonAtom*) atom;
      outBuf.mBuf_Body = bigAnon->mBigAnonAtom_Body;
      outBuf.mBuf_Fill = bigAnon->mBigAnonAtom_Size;
    }
    else
      atom = 0; // show desire to put empty content in yarn
  }
  
  if ( !atom ) // empty content for yarn?
  {
    outBuf.mBuf_Body = 0;
    outBuf.mBuf_Fill = 0;
  }
  return ( atom != 0 );
}

Here is the call graph for this function:

void morkAtom::AtomSizeOverflowError ( morkEnv ev) [static, inherited]

Definition at line 299 of file morkAtom.cpp.

{
  ev->NewError("atom mAtom_Size overflow");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void morkAtom::BadAtomKindError ( morkEnv ev) [static, inherited]

Definition at line 287 of file morkAtom.cpp.

{
  ev->NewError("bad mAtom_Kind");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 489 of file morkAtom.cpp.

{
  morkAtomSpace* space = mBookAtom_Space;
  if ( space )
  {
    mBookAtom_Space = 0;
    space->mAtomSpace_AtomBodies.CutAtom(ev, this);
    space->mAtomSpace_AtomAids.CutAtom(ev, this);
  }
  else
    ev->NilPointerError();
}

Here is the call graph for this function:

mork_u1 morkAtom::CutCellUse ( morkEnv ev) [inherited]

Definition at line 267 of file morkAtom.cpp.

{
  if ( mAtom_CellUses ) // any outstanding uses to cut?
  {
    if ( mAtom_CellUses < morkAtom_kMaxCellUses ) // not frozen at max?
      --mAtom_CellUses;
  }
  else
    this->CellUsesUnderflowWarning(ev);
    
  return mAtom_CellUses;
}

Here is the call graph for this function:

Here is the caller graph for this function:

mork_bool morkBookAtom::EqualAid ( const morkBookAtom inAtom) const [inline, inherited]

Definition at line 248 of file morkAtom.h.

  { return ( mBookAtom_Id == inAtom->mBookAtom_Id); }
mork_bool morkBookAtom::EqualFormAndBody ( morkEnv ev,
const morkBookAtom inAtom 
) const [inherited]

Definition at line 420 of file morkAtom.cpp.

{
  mork_bool outEqual = morkBool_kFalse;
  
  const mork_u1* body = 0; // body of inAtom bytes to compare
  mork_size size; // the number of inAtom bytes to compare
  mork_cscode form; // nominal charset for ioAtom

  if ( inAtom->IsWeeBook() )
  {
    size = inAtom->mAtom_Size;
    body = ((const morkWeeBookAtom*) inAtom)->mWeeBookAtom_Body;
    form = 0;
  }
  else if ( inAtom->IsBigBook() )
  {
    size = ((const morkBigBookAtom*) inAtom)->mBigBookAtom_Size;
    body = ((const morkBigBookAtom*) inAtom)->mBigBookAtom_Body;
    form = ((const morkBigBookAtom*) inAtom)->mBigBookAtom_Form;
  }
  else if ( inAtom->IsFarBook() )
  {
    size = ((const morkFarBookAtom*) inAtom)->mFarBookAtom_Size;
    body = ((const morkFarBookAtom*) inAtom)->mFarBookAtom_Body;
    form = ((const morkFarBookAtom*) inAtom)->mFarBookAtom_Form;
  }
  else
  {
    inAtom->NonBookAtomTypeError(ev);
    return morkBool_kFalse;
  }

  const mork_u1* thisBody = 0; // body of bytes in this to compare
  mork_size thisSize; // the number of bytes in this to compare
  mork_cscode thisForm; // nominal charset for this atom
  
  if ( this->IsWeeBook() )
  {
    thisSize = mAtom_Size;
    thisBody = ((const morkWeeBookAtom*) this)->mWeeBookAtom_Body;
    thisForm = 0;
  }
  else if ( this->IsBigBook() )
  {
    thisSize = ((const morkBigBookAtom*) this)->mBigBookAtom_Size;
    thisBody = ((const morkBigBookAtom*) this)->mBigBookAtom_Body;
    thisForm = ((const morkBigBookAtom*) this)->mBigBookAtom_Form;
  }
  else if ( this->IsFarBook() )
  {
    thisSize = ((const morkFarBookAtom*) this)->mFarBookAtom_Size;
    thisBody = ((const morkFarBookAtom*) this)->mFarBookAtom_Body;
    thisForm = ((const morkFarBookAtom*) this)->mFarBookAtom_Form;
  }
  else
  {
    this->NonBookAtomTypeError(ev);
    return morkBool_kFalse;
  }
  
  // if atoms are empty, form is irrelevant
  if ( body && thisBody && size == thisSize && (!size || form == thisForm ))
    outEqual = (MORK_MEMCMP(body, thisBody, size) == 0);
  
  return outEqual;
}

Here is the call graph for this function:

Here is the caller graph for this function:

mork_aid morkAtom::GetBookAtomAid ( ) const [inherited]

Definition at line 227 of file morkAtom.cpp.

{
  return ( this->IsBook() )? ((morkBookAtom*) this)->mBookAtom_Id : 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

mork_scope morkAtom::GetBookAtomSpaceScope ( morkEnv ev) const [inherited]

Definition at line 233 of file morkAtom.cpp.

{
  mork_scope outScope = 0;
  if ( this->IsBook() )
  {
    const morkBookAtom* bookAtom = (const morkBookAtom*) this;
    morkAtomSpace* space = bookAtom->mBookAtom_Space;
    if ( space->IsAtomSpace() )
      outScope = space->SpaceScope();
    else
      space->NonAtomSpaceTypeError(ev);
  }
  
  return outScope;
}

Here is the call graph for this function:

Here is the caller graph for this function:

mork_bool morkAtom::GetYarn ( mdbYarn outYarn) const [inherited]

Definition at line 65 of file morkAtom.cpp.

{
  const void* source = 0;  
  mdb_fill fill = 0; 
  mdb_cscode form = 0;
  outYarn->mYarn_More = 0;

  if ( this )
  {
    if ( this->IsWeeBook() )
    {
      morkWeeBookAtom* weeBook = (morkWeeBookAtom*) this;
      source = weeBook->mWeeBookAtom_Body;
      fill = weeBook->mAtom_Size;
    }
    else if ( this->IsBigBook() )
    {
      morkBigBookAtom* bigBook = (morkBigBookAtom*) this;
      source = bigBook->mBigBookAtom_Body;
      fill = bigBook->mBigBookAtom_Size;
      form = bigBook->mBigBookAtom_Form;
    }
    else if ( this->IsWeeAnon() )
    {
      morkWeeAnonAtom* weeAnon = (morkWeeAnonAtom*) this;
      source = weeAnon->mWeeAnonAtom_Body;
      fill = weeAnon->mAtom_Size;
    }
    else if ( this->IsBigAnon() )
    {
      morkBigAnonAtom* bigAnon = (morkBigAnonAtom*) this;
      source = bigAnon->mBigAnonAtom_Body;
      fill = bigAnon->mBigAnonAtom_Size;
      form = bigAnon->mBigAnonAtom_Form;
    }
  }
  if ( source && fill ) // have an atom with nonempty content?
  {
    // if we have too many bytes, and yarn seems growable:
    if ( fill > outYarn->mYarn_Size && outYarn->mYarn_Grow ) // try grow?
      (*outYarn->mYarn_Grow)(outYarn, (mdb_size) fill); // request bigger
      
    mdb_size size = outYarn->mYarn_Size; // max dest size
    if ( fill > size ) // too much atom content?
    {
      outYarn->mYarn_More = fill - size; // extra atom bytes omitted
      fill = size; // copy no more bytes than size of yarn buffer
    }
    void* dest = outYarn->mYarn_Buf; // where bytes are going
    if ( !dest ) // nil destination address buffer?
      fill = 0; // we can't write any content at all
      
    if ( fill ) // anything to copy?
      MORK_MEMCPY(dest, source, fill); // copy fill bytes to yarn
      
    outYarn->mYarn_Fill = fill; // tell yarn size of copied content
  }
  else // no content to put into the yarn
  {
    outYarn->mYarn_Fill = 0; // tell yarn that atom has no bytes
  }
  outYarn->mYarn_Form = form; // always update the form slot
  
  return ( source != 0 );
}

Here is the call graph for this function:

Here is the caller graph for this function:

mork_u4 morkBookAtom::HashAid ( ) const [inline, inherited]

Definition at line 247 of file morkAtom.h.

{ return mBookAtom_Id; }
mork_u4 morkBookAtom::HashFormAndBody ( morkEnv ev) const [inherited]

Definition at line 371 of file morkAtom.cpp.

{
  // This hash is obviously a variation of the dragon book string hash.
  // (I won't bother to explain or rationalize this usage for you.)
  
  register mork_u4 outHash = 0; // hash value returned
  register unsigned char c; // next character
  register const mork_u1* body; // body of bytes to hash
  mork_size size = 0; // the number of bytes to hash

  if ( this->IsWeeBook() )
  {
    size = mAtom_Size;
    body = ((const morkWeeBookAtom*) this)->mWeeBookAtom_Body;
  }
  else if ( this->IsBigBook() )
  {
    size = ((const morkBigBookAtom*) this)->mBigBookAtom_Size;
    body = ((const morkBigBookAtom*) this)->mBigBookAtom_Body;
  }
  else if ( this->IsFarBook() )
  {
    size = ((const morkFarBookAtom*) this)->mFarBookAtom_Size;
    body = ((const morkFarBookAtom*) this)->mFarBookAtom_Body;
  }
  else
  {
    this->NonBookAtomTypeError(ev);
    return 0;
  }
  
  const mork_u1* end = body + size;
  while ( body < end )
  {
    c = *body++;
    outHash <<= 4;
    outHash += c;
    mork_u4 top = outHash & 0xF0000000L; // top four bits
    if ( top ) // any of high four bits equal to one? 
    {
      outHash ^= (top >> 24); // fold down high bits
      outHash ^= top; // zero top four bits
    }
  }
    
  return outHash;
}

Here is the call graph for this function:

void morkBigBookAtom::InitBigBookAtom ( morkEnv ev,
const morkBuf inBuf,
mork_cscode  inForm,
morkAtomSpace ioSpace,
mork_aid  inAid 
)

Definition at line 549 of file morkAtom.cpp.

{
  mAtom_Kind = 0;
  mAtom_Change = morkChange_kNil;
  if ( ioSpace )
  {
    if ( inAid )
    {
      mAtom_CellUses = 0;
      mAtom_Kind = morkAtom_kKindBigBook;
      mAtom_Size = 0;
      mBookAtom_Space = ioSpace;
      mBookAtom_Id = inAid;
      mBigBookAtom_Form = inForm;
      mork_size size = inBuf.mBuf_Fill;
      mBigBookAtom_Size = size;
      if ( size && inBuf.mBuf_Body )
        MORK_MEMCPY(mBigBookAtom_Body, inBuf.mBuf_Body, size);
        
      mBigBookAtom_Body[ size ] = 0;
    }
    else
      this->ZeroAidError(ev);
  }
  else
    ev->NilPointerError();
}

Here is the call graph for this function:

Here is the caller graph for this function:

mork_bool morkAtom::IsAtomClean ( ) const [inline, inherited]

Definition at line 89 of file morkAtom.h.

mork_bool morkAtom::IsAtomDirty ( ) const [inline, inherited]

Definition at line 90 of file morkAtom.h.

Here is the caller graph for this function:

mork_bool morkAtom::IsBigAnon ( ) const [inline, inherited]

Definition at line 75 of file morkAtom.h.

Here is the caller graph for this function:

mork_bool morkAtom::IsBigBook ( ) const [inline, inherited]

Definition at line 77 of file morkAtom.h.

Here is the caller graph for this function:

mork_bool morkAtom::IsBook ( ) const [inline, inherited]

Definition at line 82 of file morkAtom.h.

{ return this->IsWeeBook() || this->IsBigBook(); }

Here is the call graph for this function:

Here is the caller graph for this function:

mork_bool morkAtom::IsCellUseForever ( ) const [inline, inherited]

Definition at line 108 of file morkAtom.h.

mork_bool morkAtom::IsFarBook ( ) const [inline, inherited]

Definition at line 78 of file morkAtom.h.

Here is the caller graph for this function:

mork_bool morkAtom::IsRowOid ( ) const [inline, inherited]

Definition at line 79 of file morkAtom.h.

Here is the caller graph for this function:

mork_bool morkAtom::IsTableOid ( ) const [inline, inherited]

Definition at line 80 of file morkAtom.h.

Here is the caller graph for this function:

mork_bool morkAtom::IsWeeAnon ( ) const [inline, inherited]

Definition at line 74 of file morkAtom.h.

Here is the caller graph for this function:

mork_bool morkAtom::IsWeeBook ( ) const [inline, inherited]

Definition at line 76 of file morkAtom.h.

Here is the caller graph for this function:

void morkAtom::MakeCellUseForever ( morkEnv ev) [inherited]

Definition at line 250 of file morkAtom.cpp.

Here is the caller graph for this function:

void morkBookAtom::NonBookAtomTypeError ( morkEnv ev) [static, inherited]

Definition at line 365 of file morkAtom.cpp.

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

Here is the call graph for this function:

Here is the caller graph for this function:

morkBigBookAtom& morkBigBookAtom::operator= ( const morkBigBookAtom other) [private]
void morkAtom::SetAtomClean ( ) [inline, inherited]

Definition at line 86 of file morkAtom.h.

Here is the caller graph for this function:

void morkAtom::SetAtomDirty ( ) [inline, inherited]

Definition at line 87 of file morkAtom.h.

Here is the caller graph for this function:

static mork_size morkBigBookAtom::SizeForFill ( mork_fill  inFill) [inline, static]

Definition at line 357 of file morkAtom.h.

  { return sizeof(morkBigBookAtom) + inFill; }

Here is the call graph for this function:

Here is the caller graph for this function:

void morkAtom::ZeroAidError ( morkEnv ev) [static, inherited]

Definition at line 293 of file morkAtom.cpp.

{
  ev->NewError("zero atom ID");
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 67 of file morkAtom.h.

Definition at line 68 of file morkAtom.h.

Definition at line 66 of file morkAtom.h.

Definition at line 69 of file morkAtom.h.

Definition at line 349 of file morkAtom.h.

Definition at line 347 of file morkAtom.h.

Definition at line 348 of file morkAtom.h.

Definition at line 238 of file morkAtom.h.

Definition at line 237 of file morkAtom.h.


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