Skip to content

Commit

Permalink
Probe modernizawtion WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
chipbarnaby committed Jan 3, 2025
1 parent edb321a commit fd04d5e
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 125 deletions.
6 changes: 2 additions & 4 deletions src/ancrec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ basAnc::basAnc( int flags, SFIR * _fir, USI _nFlds, const char * _what, USI _eSz
sOff = _sOff; // ..
mn = 1; // min record subscript 1 (overwritten with 0 if static)
// ptr() = 0; // is done in derived class constructor (deriv vf not avail here; ptr is pure!)
an_pCULT = pCULT; // pointer to associated input CULT table, nullptr = unknown
ba_pCULT = pCULT; // pointer to associated input CULT table, nullptr = unknown
if (!dontRegister)
regis(); // conditionally include anchor for nextAnc() iteration
} // basAnc::basAnc
Expand Down Expand Up @@ -1351,7 +1351,6 @@ const char* basAnc::getChoiTx( // return text of given value for a choice data
*pIsHid = pTyX == chtyHIDDEN;
return chtx;
} // basAnc::getChoiTx
//-----------------------------------------------------------------------------
//=============================================================================

//*****************************************************************************
Expand Down Expand Up @@ -1434,7 +1433,6 @@ const char* getFileName( int fileIx) // get text for file name index

return "(bug)"; // (or memory was full at name save)
} // getFileName

//*************************************************** IF-OUTS *************************************************************
//-----------------------------------------------------------------------------

// end of ancrec.cpp
19 changes: 12 additions & 7 deletions src/ancrec.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@ class basAnc // base class for record anchors: basAnc<recordName>
// members setable by application user language (cul.cpp)
BP tyB; // 0 or ptr to user language TYPES anchor in heap (destructor deletes)
BP ownB; // 0 or ptr to anchor whose objects own this anchor's objects (record.ownTi)
const CULT* an_pCULT; // NULL or associated CULT input table for records of this type
const CULT* ba_pCULT; // NULL or associated CULT input table for records of this type
// simplifies back translation of input names
const MODERNIZEPAIR* ba_probeModernizeTable; // table of old / new probe names re handling renamed record members
// nullptr if none; see cuprobe.cpp

basAnc();
basAnc( int flags, SFIR * fir, USI nFlds, const char * what, USI eSz, RCT rt, USI sOff, const CULT* pCult, int dontRegister=0 );
void FC regis();
Expand Down Expand Up @@ -117,15 +120,18 @@ class basAnc // base class for record anchors: basAnc<recordName>
const char* getChoiTx( int fn, int options=0, SI chan=-1, BOOL* bIsHid=NULL) const;
const char* culMbrIdTx(int fn) const;
int culMbrArrayDim(int fn) const;
void an_SetCULTLink( const CULT* pCULT) { an_pCULT = pCULT; }
static void an_SetCULTLinks();
void ba_SetCULTLink( const CULT* pCULT) { ba_pCULT = pCULT; }
int GetCount() const;
int GetCountMax() const
{ return n-mn+1; // max possible # records (includes unused)
// faster than GetCount()
}
int MakeRecordList(char* list, size_t listDim, const char* brk, const char* (*proc)(const record* pR)=nullptr) const;

void ba_SetProbeModernizeTable(const MODERNIZEPAIR* pMP) {
ba_probeModernizeTable = pMP;
}
const char* ba_ModernizeProbeName(const char* inputName) const;

protected:
virtual void conRec( TI i, SI noZ=0) = 0; // execute constructor for record i
virtual void desRec( TI i) = 0; // .. destructor
Expand Down Expand Up @@ -380,8 +386,7 @@ template <class T> class anc : public basAnc
int GetChildCount(const record* pParent) const;
RC CheckChildCount(const record* pParent, std::pair<int, int> countLimits, const char*& msg) const;
RC GetIthChild(const record* pParent, int iSought, T* &pRRet, int erOp=ERR) const;



protected:
virtual void desRec( TI i)
{ if (p[i].r_status)
Expand Down Expand Up @@ -563,7 +568,7 @@ template <class T> RC anc<T>::RunDup( // duplicate records for run
// delete old records, alloc to needed size for min fragmentation
RC rc = al(src.n+nxRecs, erOp, _ownB);

an_pCULT = src.an_pCULT; // assume same associated CULT
ba_pCULT = src.ba_pCULT; // assume same associated CULT

const T* pT;
RLUP( src, pT)
Expand Down
99 changes: 3 additions & 96 deletions src/cncult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3208,9 +3208,9 @@ void FC cnPreInit() // preliminary cncult.cpp initialization [needed before sho

// 'showProbeNames' displays member names of all registered rats for CSE -p.
// It is executed before most initialization and can be executed without doing a run.
{
basAnc::an_SetCULTLinks(); // link record anchors to associated input language CULTs

// note rats are now 'registered' in cse.cpp so input and run rats can be intermixed.
{
// clear/Init the "Top input RAT" which holds once-only input parameters, set mainly via cnTopCult[]
TopiR.statSetup(Topi, 1); // init cncult:TopiR as basAnc with 1 static record cncult:Topi.
// and zero record Topi and init its front members.
Expand All @@ -3224,15 +3224,9 @@ void FC cnPreInit() // preliminary cncult.cpp initialization [needed before sho
WthrR.ba_flags |= RFNOEX;
WthrNxHrR.ba_flags |= RFNOEX;

// note rats are now 'registered' in cse.cpp so input and run rats can be intermixed.
SetupProbeModernizeTables();

} // cnPreInit
//-----------------------------------------------------------------------------
/*static*/ void basAnc::an_SetCULTLinks()
{
// an_pCULT links set during anc<T> creation (via makAncXXX())
// nothing further required
} // basAnc::an_SetCULTLinks
//============================================================================================

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -3383,91 +3377,4 @@ int culShowDoc( // public function: display CULT tree
} // culDoc1
//=============================================================================

/************************************************ rest of file is if-outs ***************************************************/

#if 0 //ifdef OLDAT // undefined in cnglob.h, 5-92
o /*------------------------ TERMINAL command (for zone) ----------------------*/
o
o //-------------------------------------------- terminal pre-input fcn: limit #
o // note: pre-input not Itf used so ownTi (=zi) already set in RAT for errmsg.
o LOCAL RC tuxPrf( CULT *c, TUX *p, ZNI *p2, void *p3) /*ARGSUSED*/
o{
o TUX *tu; SI n=0;
o
o // check for too many terminals for zone.
o // NOTE zone terminal tables are in ZNR (not ZNI) -- setup deferred until topTu() below.
o
o // count terminals for same zone. Current one will be included.
o RLUP( TuxiB, tu) // loop TUX records
o if (tu->ownTi==p2->ss) // if terminal belongs to cur zone (reference type, need not check FsVAL 12-91)
o n++; // count it
o
o // error if too many
o if (n > MAX_ZONETUS) // =3, cndefns.h
o return oer( p, "More than %d terminals for zone '%s'", MAX_ZONETUS, p2->Name() );
o
o return RCOK;
o} // tuxPrf
o
o static CULT tuxT[] = //------------------------- TERMINALX subCmd table for ZONE
o // id cs fn f uc evf ty b dfls p2 ckf
{
o //-------- ---- ------------------- -------------- -- ----- ----- ----- --------- ------- ---
o "*", STAR, 0, PRFP, 0, 0, 0, 0, N, 0.f, v tuxPrf, N),
o
o "tuxZone", DAT, TUX_OWNTI, NO_INP|RDFLIN, 0, 0, TYIREF, &ZiB, N, 0.f, N, N),
o "tuxTLH", DAT, TUX_TUXTLH, 0, 0, VHRLY, TYFL, 0, N, 68.f, N, N),
o "tuxMxLH", DAT, TUX_TUXMXLH, 0, 0, VHRLY, TYFL, 0, N, 0.f, N, N),
o "tuxMnLH", DAT, TUX_TUXMNLH, 0, 0, VHRLY, TYFL, 0, N, 0.f, N, N),
o #ifdef OLDAT // undefined in cnglob.h, 5-92
o o "tuxAhu", DAT, TUX_TUXAHI, 0, 0, VEOI, TYREF, &AhuxiB,N, 0, N, N),
o #endif
o "tuxTH", DAT, TUX_TUXTH, 0, 0, VHRLY, TYFL, 0, N, 68.f, N, N),
o "tuxTC", DAT, TUX_TUXTC, 0, 0, VHRLY, TYFL, 0, N, 78.f, N, N),
o "tuxCMn", DAT, TUX_TUXCMN, 0, 0, VHRLY, TYFL, 0, N, 0.f, N, N),
o "tuxCMxH", DAT, TUX_TUXCMXH, 0, 0, VHRLY, TYFL, 0, N, 0.f, N, N),
o "tuxCMxC", DAT, TUX_TUXCMXC, 0, 0, VHRLY, TYFL, 0, N, 0.f, N, N),
o
o "endTerminalx",ENDER,0, 0, 0, 0, 0, 0, N, 0.f, N, N),
oCULT()
o
}; // tuxT
#endif

// znT deletions:
#ifdef OLDNV // 1-92 cndefns.h
o//natVent
o "nvAHi", DAT, ZI(NVAHI), 0, 0, VEOI, TYFL, 0, N, 0.f, N, N),
o "nvALo", DAT, ZI(NVALO), 0, 0, VEOI, TYFL, 0, N, 0.f, N, N),
o "nvHD", DAT, ZI(NVHD), 0, 0, VEOI, TYFL, 0, N, 2.f, N, N),
o "nvAzmI", DAT, ZI(NVAZMI), 0, 0, VEOI, TYFL, 0, N, 0.f, N, N),
o "nvStEM", DAT, ZI(NVSTEM), 0, 0, VEOI, TYFL, 0, N, 1.f, N, N),
o "nvDdEM", DAT, ZI(NVDDEM), 0, 0, VEOI, TYFL, 0, N, 0.f, N, N),
o "nvDiEM", DAT, ZI(NVDIEM), 0, 0, VEOI, TYFL, 0, N, .5f, N, N),
o "nvTD", DAT, ZI(NVTD), 0, 0, VEOI, TYFL, 0, N, 0.f, N, N),
#endif
#ifdef OLDFV
o//fanvent
o "fvCfm", DAT, ZI(FVCFM), 0, 0, VEOI, TYFL, 0, N, 0.f, N, N),
o "fvKW", DAT, ZI(FVKW), 0, 0, VEOI, TYFL, 0, N, 0.f, N, N),
o "fvFz", DAT, ZI(FVFZ), 0, 0, VEOI, TYFL, 0, N, 1.f, N, N),
o "fvDECeff", DAT, ZI(FVDECEFF), 0, 0, VEOI, TYFL, 0, N, 0.f, N, N),
o "fvIEDeff", DAT, ZI(FVIECEFF), 0, 0, VEOI, TYFL, 0, N, 0.f, N, N),
o "fvTD", DAT, ZI(FVTD), 0, 0, VEOI, TYFL, 0, N, 0.f, N, N),
o "fvWbMax", DAT, ZI(FVWBMAX), 0, 0, VEOI, TYFL, 0, N, 999.f, N, N),
#endif
#ifdef OLDCF
o//ceiling fan
o "cfKW", DAT, ZI(CFKW), 0, 0, VEOI, TYFL, 0, N, 0.f, N, N),
o "cfFz", DAT, ZI(CFFZ), 0, 0, VEOI, TYFL, 0, N, 1.f, N, N),
#endif
#ifdef OLDNV // old comments, moved to facilitate edit
o//natVent. want erMsg (at end zone) for only 1 of ahigh, alow > 0.
o /* 1-91: chip to verify traditional dH default: something like 2 for 1 story, 8 for 2 stories. 2-91: his memo shows 0. */
o // 12-90: otta require azmI iff ddEM is non-0. later.
#endif
#if 0 //ifdef OLDAT // undefined in cnglob.h, 5-92
o "terminalx", RATE, 0, 0, 0, 0, 0, &TuxiB, N, 0.f, tuxT, N),
#endif

// end of cncult.cpp
10 changes: 4 additions & 6 deletions src/cul.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3088,8 +3088,6 @@ LOCAL RC CDEC perNxE( MSGORHANDLE ms, ...)
return RCSKIP2END; /* ret special value. eg culRun tests for
this value and calls skip2end() (next) */
} // perNxE

// new 1-19-91. old skip2end is in cul.4 and cul.ifo.
//===========================================================================
LOCAL SI FC skip2end(

Expand Down Expand Up @@ -4687,8 +4685,8 @@ const char* basAnc::culMbrIdTx( // return record field id from cult table
int fn) const // field number
{
// use basAnc's associated CULT
if (an_pCULT) // if basAnc has an associated CULT
{ for (const CULT* c=an_pCULT; c->id; c++)
if (ba_pCULT) // if basAnc has an associated CULT
{ for (const CULT* c=ba_pCULT; c->id; c++)
{ if (c->cs==DAT && c->fn==fn)
return c->id;
}
Expand Down Expand Up @@ -4737,9 +4735,9 @@ int basAnc::culMbrArrayDim( // return field array dimension cult table
int arrayDim = -1;

// use basAnc's associated CULT
if (an_pCULT) // if basAnc has an associated CULT
if (ba_pCULT) // if basAnc has an associated CULT
{
for (const CULT* c = an_pCULT; c->id; c++)
for (const CULT* c = ba_pCULT; c->id; c++)
{
if (c->cs==DAT && c->fn==fn && (c->f & ARRAY))
arrayDim = int(intptr_t( c->p2));
Expand Down
1 change: 1 addition & 0 deletions src/cuparse.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ void FC curLine( int retokPar, int* pFileIx, int* pline, int* pcol, char *s, siz

// cuprobe.cpp
void FC showProbeNames(int showAll);
RC SetupProbeModernizeTables();

// end of cuparse.h
2 changes: 1 addition & 1 deletion src/cuparsex.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file.

// cuparsex.h: parsing-related stuff shared between cuparse.cpp and [obsolete file cumain.cpp] and cuprobe.cpp
// cuparsex.h: parsing-related stuff shared between cuparse.cpp and cuprobe.cpp


/* 12-91: Extending this file to stuff shared with files split off of cuparse.cpp: initially, cuprobe.cpp.
Expand Down
Loading

0 comments on commit fd04d5e

Please sign in to comment.