Bug 1568095 - Make morkAtom::GetYarn() static.

Tag #1273
This commit is contained in:
Matt A. Tobin 2019-11-11 01:49:50 -05:00 committed by Roy Tam
commit ac612ee4b5
7 changed files with 44 additions and 44 deletions

View file

@ -29,40 +29,35 @@
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789
mork_bool
morkAtom::GetYarn(mdbYarn* outYarn) const
/* static */
mork_bool morkAtom::GetYarn(const morkAtom* atom, mdbYarn* outYarn)
{
const void* source = 0;
mdb_fill fill = 0;
mdb_cscode form = 0;
outYarn->mYarn_More = 0;
if ( this->IsWeeBook() )
{
morkWeeBookAtom* weeBook = (morkWeeBookAtom*) this;
if (atom) {
if (atom->IsWeeBook()) {
morkWeeBookAtom* weeBook = (morkWeeBookAtom*)atom;
source = weeBook->mWeeBookAtom_Body;
fill = weeBook->mAtom_Size;
}
else if ( this->IsBigBook() )
{
morkBigBookAtom* bigBook = (morkBigBookAtom*) this;
} else if (atom->IsBigBook()) {
morkBigBookAtom* bigBook = (morkBigBookAtom*)atom;
source = bigBook->mBigBookAtom_Body;
fill = bigBook->mBigBookAtom_Size;
form = bigBook->mBigBookAtom_Form;
}
else if ( this->IsWeeAnon() )
{
morkWeeAnonAtom* weeAnon = (morkWeeAnonAtom*) this;
} else if (atom->IsWeeAnon()) {
morkWeeAnonAtom* weeAnon = (morkWeeAnonAtom*)atom;
source = weeAnon->mWeeAnonAtom_Body;
fill = weeAnon->mAtom_Size;
}
else if ( this->IsBigAnon() )
{
morkBigAnonAtom* bigAnon = (morkBigAnonAtom*) this;
} else if (atom->IsBigAnon()) {
morkBigAnonAtom* bigAnon = (morkBigAnonAtom*)atom;
source = bigAnon->mBigAnonAtom_Body;
fill = bigAnon->mBigAnonAtom_Size;
form = bigAnon->mBigAnonAtom_Form;
}
}
if ( source && fill ) // have an atom with nonempty content?
{

View file

@ -89,7 +89,7 @@ public: // errors
public: // yarns
static mork_bool AliasYarn(const morkAtom* atom, mdbYarn* outYarn);
mork_bool GetYarn(mdbYarn* outYarn) const;
static mork_bool GetYarn(const morkAtom* atom, mdbYarn* outYarn);
private: // copying is not allowed
morkAtom(const morkAtom& other);

View file

@ -45,7 +45,7 @@ void
morkCell::GetYarn(morkEnv* ev, mdbYarn* outYarn) const
{
MORK_USED_1(ev);
mCell_Atom->GetYarn(outYarn);
morkAtom::GetYarn(mCell_Atom, outYarn);
}
void

View file

@ -332,7 +332,7 @@ NS_IMETHODIMP morkCellObject::GetYarn(nsIMdbEnv* mev,
if ( ev )
{
morkAtom* atom = cell->GetAtom();
atom->GetYarn(outYarn);
morkAtom::GetYarn(atom, outYarn);
outErr = ev->AsErr();
}

View file

@ -447,17 +447,21 @@ void morkRow::SeekColumn(morkEnv* ev, mdb_pos inPos,
if ( cells && inPos < mRow_Length && inPos >= 0 )
{
morkCell* c = cells + inPos;
if ( outColumn )
*outColumn = c->GetColumn();
if ( outYarn )
c->mCell_Atom->GetYarn(outYarn); // nil atom works okay here
if ( outColumn ) {
*outColumn = c->GetColumn();
}
if ( outYarn ) {
morkAtom::GetYarn(c->mCell_Atom, outYarn);
}
}
else
{
if ( outColumn )
*outColumn = 0;
if ( outYarn )
((morkAtom*) 0)->GetYarn(outYarn); // yes this will work
if ( outColumn ) {
*outColumn = 0;
}
if ( outYarn ) {
morkAtom::GetYarn((morkAtom*)0, outYarn);
}
}
}
@ -467,28 +471,30 @@ morkRow::NextColumn(morkEnv* ev, mdb_column* ioColumn, mdbYarn* outYarn)
morkCell* cells = mRow_Cells;
if ( cells )
{
mork_column last = 0;
mork_column inCol = *ioColumn;
mork_column last = 0;
mork_column inCol = *ioColumn;
morkCell* end = cells + mRow_Length;
while ( cells < end )
{
if ( inCol == last ) // found column?
{
if ( outYarn )
cells->mCell_Atom->GetYarn(outYarn); // nil atom works okay here
if ( outYarn ) {
if (outYarn) {
morkAtom::GetYarn(cells->mCell_Atom, outYarn);
}
*ioColumn = cells->GetColumn();
return; // stop, we are done
}
else
{
}
} else {
last = cells->GetColumn();
++cells;
}
}
}
*ioColumn = 0;
if ( outYarn )
((morkAtom*) 0)->GetYarn(outYarn); // yes this will work
*ioColumn = 0;
if ( outYarn ) {
morkAtom::GetYarn((morkAtom*)0, outYarn);
}
}
morkCell*

View file

@ -467,8 +467,7 @@ morkRowObject::GetCellYarn(
if ( mRowObject_Store && mRowObject_Row)
{
morkAtom* atom = mRowObject_Row->GetColumnAtom(ev, inColumn);
atom->GetYarn(outYarn);
// note nil atom works and sets yarn correctly
morkAtom::GetYarn(atom, outYarn);
}
outErr = ev->AsErr();

View file

@ -775,7 +775,7 @@ morkStore::OidToYarn(morkEnv* ev, const mdbOid& inOid, mdbYarn* outYarn)
morkAtomAidMap* map = &atomSpace->mAtomSpace_AtomAids;
atom = map->GetAid(ev, (mork_aid) inOid.mOid_Id);
}
atom->GetYarn(outYarn); // note this is safe even when atom==nil
morkAtom::GetYarn(atom, outYarn);
return ev->Good();
}
@ -823,10 +823,10 @@ morkStore::TokenToString(morkEnv* ev, mdb_token inToken, mdbYarn* outTokenName)
{
morkBookAtom* atom = 0;
morkAtomSpace* space = mStore_GroundColumnSpace;
if ( space )
if ( space ) {
atom = space->mAtomSpace_AtomAids.GetAid(ev, (mork_aid) inToken);
atom->GetYarn(outTokenName); // note this is safe even when atom==nil
}
morkAtom::GetYarn(atom, outTokenName);
}
else // token is an "immediate" single byte string representation?
this->SmallTokenToOneByteYarn(ev, inToken, outTokenName);