void morkPool::ZapCells(morkEnv* ev, morkCell* ioVector, mork_size inSize,
                        morkZone* ioZone) {
  MORK_USED_1(inSize);

  if (ioVector) {
#ifdef morkZone_CONFIG_ARENA
    // a zone 'run' knows its size, and can indeed be deallocated:
    ioZone->ZoneZapRun(ev, ioVector);
#else  /*morkZone_CONFIG_ARENA*/
    MORK_USED_1(ioZone);
    mPool_Heap->Free(ev->AsMdbEnv(), ioVector);
#endif /*morkZone_CONFIG_ARENA*/
  }
}
/*virtual*/ void morkBuilder::OnTableEnd(morkEnv* ev, const morkSpan& inSpan)
// mp:Table     ::= OnNewTable mp:TableItem* OnTableEnd
{
  MORK_USED_1(inSpan);
  // mParser_InTable = morkBool_kFalse;
  if (mBuilder_Table) {
    mBuilder_Table->mTable_Priority = mBuilder_TablePriority;

    if (mBuilder_TableIsUnique) mBuilder_Table->SetTableUnique();

    if (mBuilder_TableIsVerbose) mBuilder_Table->SetTableVerbose();

    morkTable::SlotStrongTable((morkTable*)0, ev, &mBuilder_Table);
  } else
    this->NilBuilderTableError(ev);

  mBuilder_Row = 0;
  mBuilder_Cell = 0;

  mBuilder_TablePriority = morkPriority_kLo;
  mBuilder_TableIsUnique = morkBool_kFalse;
  mBuilder_TableIsVerbose = morkBool_kFalse;

  if (mBuilder_TableKind == morkStore_kNoneToken)
    ev->NewError("missing table kind");

  mBuilder_CellAtomScope = mBuilder_RowAtomScope = mBuilder_TableAtomScope =
      mBuilder_PortAtomScope;

  mBuilder_DoCutCell = morkBool_kFalse;
  mBuilder_DoCutRow = morkBool_kFalse;
}
mork_bool morkFactory::CanOpenMorkTextFile(morkEnv* ev,
                                           // const mdbYarn* inFirst512Bytes,
                                           nsIMdbFile* ioFile) {
  MORK_USED_1(ev);
  mork_bool outBool = morkBool_kFalse;
  mork_size headSize = strlen(morkWriter_kFileHeader);

  char localBuf[256 + 4];  // for extra for sloppy safety
  mdbYarn localYarn;
  mdbYarn* y = &localYarn;
  y->mYarn_Buf = localBuf;  // space to hold content
  y->mYarn_Fill = 0;        // no logical content yet
  y->mYarn_Size = 256;      // physical capacity is 256 bytes
  y->mYarn_More = 0;
  y->mYarn_Form = 0;
  y->mYarn_Grow = 0;

  if (ioFile) {
    nsIMdbEnv* menv = ev->AsMdbEnv();
    mdb_size actualSize = 0;
    ioFile->Get(menv, y->mYarn_Buf, y->mYarn_Size, /*pos*/ 0, &actualSize);
    y->mYarn_Fill = actualSize;

    if (y->mYarn_Buf && actualSize >= headSize && ev->Good()) {
      mork_u1* buf = (mork_u1*)y->mYarn_Buf;
      outBool = (MORK_MEMCMP(morkWriter_kFileHeader, buf, headSize) == 0);
    }
  } else
    ev->NilPointerError();

  return outBool;
}
void
morkRow::OnZeroRowGcUse(morkEnv* ev)
// OnZeroRowGcUse() is called when CutRowGcUse() returns zero.
{
  MORK_USED_1(ev);
  // ev->NewWarning("need to implement OnZeroRowGcUse");
}
NS_IMETHODIMP
morkFactory::OpenFilePort(
    nsIMdbEnv* mev, // context
    nsIMdbHeap* ioHeap, // can be nil to cause ev's heap attribute to be used
    // const char* inFilePath, // the file to open for readonly import
    nsIMdbFile* ioFile, // db abstract file interface
    const mdbOpenPolicy* inOpenPolicy, // runtime policies for using db
    nsIMdbThumb** acqThumb)
{
    NS_ASSERTION(false, "this doesn't look implemented");
    MORK_USED_1(ioHeap);
    mdb_err outErr = NS_OK;
    nsIMdbThumb* outThumb = 0;
    morkEnv* ev = morkEnv::FromMdbEnv(mev);
    if ( ev )
    {
        if ( ioFile && inOpenPolicy && acqThumb )
        {
        }
        else
            ev->NilPointerError();

        outErr = ev->AsErr();
    }
    if ( acqThumb )
        *acqThumb = outThumb;
    return outErr;
}
Example #6
0
/*protected non-poly*/ void
morkParser::StartParse(morkEnv* ev)
{
  MORK_USED_1(ev);
  mParser_InCell = morkBool_kFalse;
  mParser_InMeta = morkBool_kFalse;
  mParser_InDict = morkBool_kFalse;
  mParser_InPortRow = morkBool_kFalse;
  
  mParser_RowMid.ClearMid();
  mParser_TableMid.ClearMid();
  mParser_CellMid.ClearMid();
  
  mParser_GroupId = 0;
  mParser_InPort = morkBool_kTrue;

  mParser_GroupSpan.ClearSpan();
  mParser_DictSpan.ClearSpan();
  mParser_AliasSpan.ClearSpan();
  mParser_MetaSpan.ClearSpan();
  mParser_TableSpan.ClearSpan();
  mParser_RowSpan.ClearSpan();
  mParser_CellSpan.ClearSpan();
  mParser_ColumnSpan.ClearSpan();
  mParser_SlotSpan.ClearSpan();

   mParser_PortSpan.ClearSpan();
}
// resize (grow or trim) cell vectors inside a containing row instance
mork_bool morkPool::AddRowCells(morkEnv* ev, morkRow* ioRow,
                                mork_size inNewSize, morkZone* ioZone) {
  // note strong implementation similarity to morkArray::Grow()

  MORK_USED_1(ioZone);
#ifdef morkZone_CONFIG_ARENA
#else  /*morkZone_CONFIG_ARENA*/
#endif /*morkZone_CONFIG_ARENA*/

  mork_fill fill = ioRow->mRow_Length;
  if (ev->Good() && fill < inNewSize)  // need more cells?
  {
    morkCell* newCells = this->NewCells(ev, inNewSize, ioZone);
    if (newCells) {
      morkCell* c = newCells;  // for iterating during copy
      morkCell* oldCells = ioRow->mRow_Cells;
      morkCell* end = oldCells + fill;  // copy all the old cells
      while (oldCells < end) {
        *c++ = *oldCells++;  // bitwise copy each old cell struct
      }
      oldCells = ioRow->mRow_Cells;
      ioRow->mRow_Cells = newCells;
      ioRow->mRow_Length = (mork_u2)inNewSize;
      ++ioRow->mRow_Seed;

      if (oldCells) this->ZapCells(ev, oldCells, fill, ioZone);
    }
  }
  return (ev->Good() && ioRow->mRow_Length >= inNewSize);
}
/*virtual*/ void
morkBuilder::OnPortRowEnd(morkEnv* ev, const morkSpan& inSpan)
{
  MORK_USED_1(inSpan);
  // mParser_InPortRow = morkBool_kFalse;
  ev->StubMethodOnlyError();
}
morkBookAtom* morkPool::NewBookAtom(morkEnv* ev, const morkBuf& inBuf,
                                    mork_cscode inForm, morkAtomSpace* ioSpace,
                                    mork_aid inAid, morkZone* ioZone)
// if inForm is zero, and inBuf.mBuf_Fill is less than 256, then a 'wee'
// book atom will be created, and otherwise a 'big' book atom.
{
  morkBookAtom* newAtom = 0;

  mork_bool needBig = (inForm || inBuf.mBuf_Fill > 255);
  mork_size size = (needBig) ? morkBigBookAtom::SizeForFill(inBuf.mBuf_Fill)
                             : morkWeeBookAtom::SizeForFill(inBuf.mBuf_Fill);

#ifdef morkZone_CONFIG_ARENA
  // a zone 'chip' remembers no size, and so cannot be deallocated:
  newAtom = (morkBookAtom*)ioZone->ZoneNewChip(ev, size);
#else  /*morkZone_CONFIG_ARENA*/
  MORK_USED_1(ioZone);
  mPool_Heap->Alloc(ev->AsMdbEnv(), size, (void**)&newAtom);
#endif /*morkZone_CONFIG_ARENA*/
  if (newAtom) {
    if (needBig)
      ((morkBigBookAtom*)newAtom)
          ->InitBigBookAtom(ev, inBuf, inForm, ioSpace, inAid);
    else
      ((morkWeeBookAtom*)newAtom)->InitWeeBookAtom(ev, inBuf, ioSpace, inAid);
  }
  return newAtom;
}
morkBookAtom* morkPool::NewFarBookAtomCopy(morkEnv* ev,
                                           const morkFarBookAtom& inAtom,
                                           morkZone* ioZone)
// make the smallest kind of book atom that can hold content in inAtom.
// The inAtom parameter is often expected to be a staged book atom in
// the store, which was used to search an atom space for existing atoms.
{
  morkBookAtom* newAtom = 0;

  mork_cscode form = inAtom.mFarBookAtom_Form;
  mork_fill fill = inAtom.mFarBookAtom_Size;
  mork_bool needBig = (form || fill > 255);
  mork_size size = (needBig) ? morkBigBookAtom::SizeForFill(fill)
                             : morkWeeBookAtom::SizeForFill(fill);

#ifdef morkZone_CONFIG_ARENA
  // a zone 'chip' remembers no size, and so cannot be deallocated:
  newAtom = (morkBookAtom*)ioZone->ZoneNewChip(ev, size);
#else  /*morkZone_CONFIG_ARENA*/
  MORK_USED_1(ioZone);
  mPool_Heap->Alloc(ev->AsMdbEnv(), size, (void**)&newAtom);
#endif /*morkZone_CONFIG_ARENA*/
  if (newAtom) {
    morkBuf buf(inAtom.mFarBookAtom_Body, fill);
    if (needBig)
      ((morkBigBookAtom*)newAtom)
          ->InitBigBookAtom(ev, buf, form, inAtom.mBookAtom_Space,
                            inAtom.mBookAtom_Id);
    else
      ((morkWeeBookAtom*)newAtom)
          ->InitWeeBookAtom(ev, buf, inAtom.mBookAtom_Space,
                            inAtom.mBookAtom_Id);
  }
  return newAtom;
}
Example #11
0
// { ===== begin morkMap poly interface =====
/*virtual*/ mork_bool // 
morkRowMap::Equal(morkEnv* ev, const void* inKeyA,
  const void* inKeyB) const
{
  MORK_USED_1(ev);
  return (*(const morkRow**) inKeyA)->EqualRow(*(const morkRow**) inKeyB);
}
/*virtual*/ void
morkBuilder::OnNewTable(morkEnv* ev, const morkPlace& inPlace,
  const morkMid& inMid, mork_bool inCutAllRows)
// mp:Table     ::= OnNewTable mp:TableItem* OnTableEnd
// mp:TableItem ::= mp:Row | mp:MetaTable | OnTableGlitch
// mp:MetaTable ::= OnNewMeta mp:MetaItem* mp:Row OnMetaEnd
// mp:Meta      ::= OnNewMeta mp:MetaItem* OnMetaEnd
// mp:MetaItem  ::= mp:Cell | OnMetaGlitch
{
  MORK_USED_1(inPlace);
  // mParser_InTable = morkBool_kTrue;
  mBuilder_TableForm = mBuilder_PortForm;
  mBuilder_TableRowScope = mBuilder_PortRowScope;
  mBuilder_TableAtomScope = mBuilder_PortAtomScope;
  mBuilder_TableKind = morkStore_kNoneToken;
  
  mBuilder_TablePriority = morkPriority_kLo;
  mBuilder_TableIsUnique = morkBool_kFalse;
  mBuilder_TableIsVerbose = morkBool_kFalse;

  morkTable* table = mBuilder_Store->MidToTable(ev, inMid);
  morkTable::SlotStrongTable(table, ev, &mBuilder_Table);
  if ( table )
  {
    if ( table->mTable_RowSpace )
      mBuilder_TableRowScope = table->mTable_RowSpace->SpaceScope();
      
    if ( inCutAllRows )
      table->CutAllRows(ev);
  }
}
/*virtual*/ void morkBuilder::OnTableMid(morkEnv* ev, const morkSpan& inSpan,
                                         const morkMid& inMid)
// mp:CellItem  ::= mp:Slot | OnCellForm | OnCellGlitch
// mp:Slot      ::= OnValue | OnValueMid | OnRowMid | OnTableMid
{
  MORK_USED_1(inSpan);
  morkStore* store = mBuilder_Store;
  morkCell* cell = mBuilder_Cell;
  if (cell) {
    mdbOid tableOid = inMid.mMid_Oid;
    if (inMid.mMid_Buf) {
      if (!tableOid.mOid_Scope) store->MidToOid(ev, inMid, &tableOid);
    } else if (!tableOid.mOid_Scope)
      tableOid.mOid_Scope = mBuilder_RowRowScope;

    if (ev->Good()) {
      morkPool* pool = store->StorePool();
      morkAtom* atom = pool->NewTableOidAtom(ev, tableOid, &store->mStore_Zone);
      if (atom) {
        cell->SetAtom(ev, atom, pool);
        morkTable* table = store->OidToTable(ev, &tableOid,
                                             /*optionalMetaRowOid*/ (mdbOid*)0);
        if (table)  // found or created such a table?
          table->AddTableGcUse(ev);
      }
    }
  } else
    this->NilBuilderCellError(ev);
}
/*virtual*/ void morkBuilder::OnRowMid(morkEnv* ev, const morkSpan& inSpan,
                                       const morkMid& inMid)
// mp:CellItem  ::= mp:Slot | OnCellForm | OnCellGlitch
// mp:Slot      ::= OnValue | OnValueMid | OnRowMid | OnTableMid
{
  MORK_USED_1(inSpan);
  morkStore* store = mBuilder_Store;
  morkCell* cell = mBuilder_Cell;
  if (cell) {
    mdbOid rowOid = inMid.mMid_Oid;
    if (inMid.mMid_Buf) {
      if (!rowOid.mOid_Scope) store->MidToOid(ev, inMid, &rowOid);
    } else if (!rowOid.mOid_Scope)
      rowOid.mOid_Scope = mBuilder_RowRowScope;

    if (ev->Good()) {
      morkPool* pool = store->StorePool();
      morkAtom* atom = pool->NewRowOidAtom(ev, rowOid, &store->mStore_Zone);
      if (atom) {
        cell->SetAtom(ev, atom, pool);
        morkRow* row = store->OidToRow(ev, &rowOid);
        if (row)  // found or created such a row?
          row->AddRowGcUse(ev);
      }
    }
  } else
    this->NilBuilderCellError(ev);
}
// alloc and free individual instances of handles (inside hand frames):
morkHandleFace* morkPool::NewHandle(morkEnv* ev, mork_size inSize,
                                    morkZone* ioZone) {
  void* newBlock = 0;
  if (inSize <= sizeof(morkHandleFrame)) {
    morkLink* firstLink = mPool_FreeHandleFrames.RemoveFirst();
    if (firstLink) {
      newBlock = firstLink;
      if (mPool_FreeFramesCount)
        --mPool_FreeFramesCount;
      else
        ev->NewWarning("mPool_FreeFramesCount underflow");
    } else
      mPool_Heap->Alloc(ev->AsMdbEnv(), sizeof(morkHandleFrame),
                        (void**)&newBlock);
  } else {
    ev->NewWarning("inSize > sizeof(morkHandleFrame)");
    mPool_Heap->Alloc(ev->AsMdbEnv(), inSize, (void**)&newBlock);
  }
#ifdef morkZone_CONFIG_ARENA
#else  /*morkZone_CONFIG_ARENA*/
  MORK_USED_1(ioZone);
#endif /*morkZone_CONFIG_ARENA*/

  return (morkHandleFace*)newBlock;
}
Example #16
0
morkRow*
morkRowProbeMap::CutRow(morkEnv* ev, const morkRow* ioRow)
{
  MORK_USED_1(ioRow);
  morkProbeMap::ProbeMapCutError(ev);
    
  return 0;
}
Example #17
0
morkRow*
morkRowProbeMap::CutOid(morkEnv* ev, const mdbOid* inOid)
{
  MORK_USED_1(inOid);
  morkProbeMap::ProbeMapCutError(ev);
    
  return 0;
}
Example #18
0
mork_u2
morkTable::AddTableGcUse(morkEnv* ev)
{
  MORK_USED_1(ev); 
  if ( mTable_GcUses < morkTable_kMaxTableGcUses ) // not already maxed out?
    ++mTable_GcUses;
    
  return mTable_GcUses;
}
/*virtual*/ void morkBuilder::OnNewRow(morkEnv* ev, const morkPlace& inPlace,
                                       const morkMid& inMid,
                                       mork_bool inCutAllCols)
// mp:Table     ::= OnNewTable mp:TableItem* OnTableEnd
// mp:TableItem ::= mp:Row | mp:MetaTable | OnTableGlitch
// mp:MetaTable ::= OnNewMeta mp:MetaItem* mp:Row OnMetaEnd
// mp:Row       ::= OnMinusRow? OnNewRow mp:RowItem* OnRowEnd
// mp:RowItem   ::= mp:Cell | mp:Meta | OnRowGlitch
// mp:Cell      ::= OnMinusCell? OnNewCell mp:CellItem? OnCellEnd
// mp:CellItem  ::= mp:Slot | OnCellForm | OnCellGlitch
// mp:Slot      ::= OnValue | OnValueMid | OnRowMid | OnTableMid
{
  MORK_USED_1(inPlace);
  // mParser_InRow = morkBool_kTrue;

  mBuilder_CellForm = mBuilder_RowForm = mBuilder_TableForm;
  mBuilder_CellAtomScope = mBuilder_RowAtomScope = mBuilder_TableAtomScope;
  mBuilder_RowRowScope = mBuilder_TableRowScope;
  morkStore* store = mBuilder_Store;

  if (!inMid.mMid_Buf && !inMid.mMid_Oid.mOid_Scope) {
    morkMid mid(inMid);
    mid.mMid_Oid.mOid_Scope = mBuilder_RowRowScope;
    mBuilder_Row = store->MidToRow(ev, mid);
  } else {
    mBuilder_Row = store->MidToRow(ev, inMid);
  }
  morkRow* row = mBuilder_Row;
  if (row && inCutAllCols) {
    row->CutAllColumns(ev);
  }

  morkTable* table = mBuilder_Table;
  if (table) {
    if (row) {
      if (mParser_InMeta) {
        morkRow* metaRow = table->mTable_MetaRow;
        if (!metaRow) {
          table->mTable_MetaRow = row;
          table->mTable_MetaRowOid = row->mRow_Oid;
          row->AddRowGcUse(ev);
        } else if (metaRow != row)  // not identical?
          ev->NewError("duplicate table meta row");
      } else {
        if (mBuilder_DoCutRow)
          table->CutRow(ev, row);
        else
          table->AddRow(ev, row);
      }
    }
  }
  // else // it is now okay to have rows outside a table:
  //  this->NilBuilderTableError(ev);

  mBuilder_DoCutRow = morkBool_kFalse;
}
void morkPool::ZapRow(morkEnv* ev, morkRow* ioRow,
                      morkZone* ioZone)  // free old row instance
{
#ifdef morkZone_CONFIG_ARENA
  if (!ioRow) ev->NilPointerWarning();  // a zone 'chip' cannot be freed
#else                                   /*morkZone_CONFIG_ARENA*/
  MORK_USED_1(ioZone);
  if (ioRow) mPool_Heap->Free(ev->AsMdbEnv(), ioRow);
#endif                                  /*morkZone_CONFIG_ARENA*/
}
/*virtual*/ nsresult morkHandle::Handle_IsOpenMdbObject(nsIMdbEnv* mev,
                                                        mdb_bool* outOpen) {
  MORK_USED_1(mev);
  nsresult outErr = NS_OK;

  MORK_ASSERT(outOpen);
  if (outOpen) *outOpen = this->IsOpenNode();

  return outErr;
}
// alloc & free individual instances of atoms (lots of atom subclasses):
void morkPool::ZapAtom(morkEnv* ev, morkAtom* ioAtom,
                       morkZone* ioZone)  // any subclass (by kind)
{
#ifdef morkZone_CONFIG_ARENA
  if (!ioAtom) ev->NilPointerWarning();  // a zone 'chip' cannot be freed
#else                                    /*morkZone_CONFIG_ARENA*/
  MORK_USED_1(ioZone);
  if (ioAtom) mPool_Heap->Free(ev->AsMdbEnv(), ioAtom);
#endif                                   /*morkZone_CONFIG_ARENA*/
}
/*virtual*/ void morkBuilder::OnAlias(morkEnv* ev, const morkSpan& inSpan,
                                      const morkMid& inMid) {
  MORK_USED_1(inSpan);
  if (mParser_InDict) {
    morkMid mid = inMid;  // local copy for modification
    mid.mMid_Oid.mOid_Scope = mBuilder_DictAtomScope;
    mBuilder_Store->AddAlias(ev, mid, mBuilder_DictForm);
  } else
    ev->NewError("alias not in dict");
}
Example #24
0
mork_bool
morkPool::CutRowCells(morkEnv* ev, morkRow* ioRow,
  mork_size inNewSize,
  morkZone* ioZone)
{
  MORK_USED_1(ioZone);
#ifdef morkZone_CONFIG_ARENA
#else /*morkZone_CONFIG_ARENA*/
#endif /*morkZone_CONFIG_ARENA*/

  mork_fill fill = ioRow->mRow_Length;
  if ( ev->Good() && fill > inNewSize ) // need fewer cells?
  {
    if ( inNewSize ) // want any row cells at all?
    {
      morkCell* newCells = this->NewCells(ev, inNewSize, ioZone);
      if ( newCells )
      {
        morkCell* saveNewCells = newCells; // Keep newcell pos
        morkCell* oldCells = ioRow->mRow_Cells;
        morkCell* oldEnd = oldCells + fill; // one past all old cells
        morkCell* newEnd = oldCells + inNewSize; // copy only kept old cells
        while ( oldCells < newEnd )
        {
          *newCells++ = *oldCells++; // bitwise copy each old cell struct
        }
        while ( oldCells < oldEnd )
        {
          if ( oldCells->mCell_Atom ) // need to unref old cell atom?
            oldCells->SetAtom(ev, (morkAtom*) 0, this); // unref cell atom
          ++oldCells;
        }
        oldCells = ioRow->mRow_Cells;
        ioRow->mRow_Cells = saveNewCells;
        ioRow->mRow_Length = (mork_u2) inNewSize;
        ++ioRow->mRow_Seed;
        
        if ( oldCells )
          this->ZapCells(ev, oldCells, fill, ioZone);
      }
    }
    else // get rid of all row cells
    {
      morkCell* oldCells = ioRow->mRow_Cells;
      ioRow->mRow_Cells = 0;
      ioRow->mRow_Length = 0;
      ++ioRow->mRow_Seed;
      
      if ( oldCells )
        this->ZapCells(ev, oldCells, fill, ioZone);
    }
  }
  return ( ev->Good() && ioRow->mRow_Length <= inNewSize );
}
/*virtual*/ mork_test  // hit(a,b) implies hash(a) == hash(b)
morkRowProbeMap::MapTest(morkEnv* ev, const void* inMapKey,
                         const void* inAppKey) const {
  MORK_USED_1(ev);
  const morkRow* key = *(const morkRow**)inMapKey;
  if (key) {
    mork_bool hit = key->EqualRow(*(const morkRow**)inAppKey);
    return (hit) ? morkTest_kHit : morkTest_kMiss;
  } else
    return morkTest_kVoid;
}
morkCell*
morkRow::CellAt(morkEnv* ev, mork_pos inPos) const
{
  MORK_USED_1(ev);
  morkCell* cells = mRow_Cells;
  if ( cells && inPos < mRow_Length && inPos >= 0 )
  {
    return cells + inPos;
  }
  return (morkCell*) 0;
}
Example #27
0
void
morkMapIter::CloseMapIter(morkEnv* ev)
{
  MORK_USED_1(ev);
  mMapIter_Map = 0;
  mMapIter_Seed = 0;
  
  mMapIter_Bucket = 0;
  mMapIter_AssocRef = 0;
  mMapIter_Assoc = 0;
  mMapIter_Next = 0;
}
nsIMdbFile*
morkFile::AcquireFileHandle(morkEnv* ev)
{
  nsIMdbFile* outFile = 0;

#ifdef MORK_CONFIG_USE_ORKINFILE
  return this;
#endif /*MORK_CONFIG_USE_ORKINFILE*/
  MORK_USED_1(ev);
    
  return outFile;
}
/*virtual*/ void morkBuilder::OnValueMid(morkEnv* ev, const morkSpan& inSpan,
                                         const morkMid& inMid)
// mp:CellItem  ::= mp:Slot | OnCellForm | OnCellGlitch
// mp:Slot      ::= OnValue | OnValueMid | OnRowMid | OnTableMid
{
  MORK_USED_1(inSpan);
  morkStore* store = mBuilder_Store;
  morkCell* cell = mBuilder_Cell;

  morkMid valMid;                     // local mid for modifications
  mdbOid* valOid = &valMid.mMid_Oid;  // ref to oid inside mid
  *valOid = inMid.mMid_Oid;           // bitwise copy inMid's oid

  if (inMid.mMid_Buf) {
    if (!valOid->mOid_Scope) store->MidToOid(ev, inMid, valOid);
  } else if (!valOid->mOid_Scope)
    valOid->mOid_Scope = mBuilder_CellAtomScope;

  if (cell) {
    morkBookAtom* atom = store->MidToAtom(ev, valMid);
    if (atom)
      cell->SetAtom(ev, atom, store->StorePool());
    else
      ev->NewError("undefined cell value alias");
  } else if (mParser_InMeta) {
    mork_token* metaSlot = mBuilder_MetaTokenSlot;
    if (metaSlot) {
      mork_scope valScope = valOid->mOid_Scope;
      if (!valScope || valScope == morkStore_kColumnSpaceScope) {
        if (ev->Good() && valMid.HasSomeId()) {
          *metaSlot = valOid->mOid_Id;
          if (metaSlot == &mBuilder_TableKind)  // table kind?
          {
            if (mParser_InTable && mBuilder_Table) {
              mBuilder_Table->mTable_Kind = valOid->mOid_Id;
            } else
              ev->NewWarning("mBuilder_TableKind not in table");
          } else if (metaSlot == &mBuilder_TableStatus)  // table status?
          {
            if (mParser_InTable && mBuilder_Table) {
              // $$ what here??
            } else
              ev->NewWarning("mBuilder_TableStatus not in table");
          }
        }
      } else
        this->NonColumnSpaceScopeError(ev);
    }
  } else
    this->NilBuilderCellError(ev);
}
morkOidAtom* morkPool::NewTableOidAtom(morkEnv* ev, const mdbOid& inOid,
                                       morkZone* ioZone) {
  morkOidAtom* newAtom = 0;

#ifdef morkZone_CONFIG_ARENA
  // a zone 'chip' remembers no size, and so cannot be deallocated:
  newAtom = (morkOidAtom*)ioZone->ZoneNewChip(ev, sizeof(morkOidAtom));
#else  /*morkZone_CONFIG_ARENA*/
  MORK_USED_1(ioZone);
  mPool_Heap->Alloc(ev->AsMdbEnv(), sizeof(morkOidAtom), (void**)&newAtom);
#endif /*morkZone_CONFIG_ARENA*/
  if (newAtom) newAtom->InitTableOidAtom(ev, inOid);
  return newAtom;
}