Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 75 additions & 54 deletions src/RCDEF/rcdef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@
#include "srd.h"

#include "xiopak.h" // xffilcomp
// #include "envpak.h" // hello byebye
#include "cuevf.h" // EVFHR EVFMH
#include "cvpak.h"
#include "lookup.h"
Expand Down Expand Up @@ -2049,7 +2048,13 @@ x { printf( "\nRecord trap!");}

// standard type-specific members: Copy() and operator=()
fprintf( frc, " %s& Copy( const %s& _d) { Copy( static_cast< const record*>(&_d)); return *this; }\n", rcNam, rcNam);
#if 0
0 experiment re elimination of duplicate Copy / CopyFrom
0 retain pending finalization of Copy / CopyFrom merge 6-2023
0 fprintf(frc, " %s& operator=( const %s& _d) = delete;\n", rcNam, rcNam);
#else
fprintf( frc, " %s& operator=( const %s& _d) { Copy( static_cast< const record*>(&_d)); return *this; }\n", rcNam, rcNam);
#endif

// virtual Copy(): override or not
fprintf( frc, " virtual void Copy( const record* pSrc, int options=0)%s;\n",
Expand Down Expand Up @@ -2230,7 +2235,7 @@ x { printf( "\nRecord trap!");}

if (fSrfd) // if doing it and opened ok
{
wSrfd4( fSrfd); // write part after per-record stuff, below
// wSrfd4( fSrfd); write part after per-record stuff, below DROPPED 6-2023
fprintf( fSrfd, "\n\n/* end of srfd.cpp */\n" );
fclose(fSrfd);
printf(" \n");
Expand Down Expand Up @@ -2932,7 +2937,7 @@ LOCAL void wRcTd( FILE *f) // write record and anchor class declara
//======================================================================
LOCAL void wSrfd1( FILE *f)

// write "Small record and field descriptor" C source file for compilation and linking into applications
// write "Small record and field descriptor" C++ file for compilation and linking into applications

// PART 1 of 4 parts: field types table, and stuff above portion repeated for each record type.

Expand All @@ -2945,15 +2950,15 @@ LOCAL void wSrfd1( FILE *f)
"// srfd.cpp\n"
"\n"
"/* This is a Record and Field Descriptor Tables source file generated generated by rcdef.exe.\n"
" This file is compiled and linked into an application, such as CN. */\n" );
" This file is compiled and linked into CSE.*/\n" );
fprintf( f, "\n"
"/* DO NOT EDIT: This file is overwritten when rcdef is run.\n"
" To change, change rcdef.exe input as desired and re-run rcdef.exe via the appropropriate batch file. */\n\n"
"\n"
"#include \"cnglob.h\" // includes <dtypes.h> for DTxxxx symbols\n"
"#include \"srd.h\" // defines structures and declares variables. Plus comments. Manually generated file.\n"
"#include <ancrec.h> // defines base class for record classes in rc____.h files. Manually generated file.\n"
"// also <rc___.h> file(s) are included below.\n"
"#include \"ancrec.h\" // defines base class for record classes. Manually generated file.\n"
"// also rccn.h is included below.\n"
"\n"
"#undef o // in case an .h file defines o\n"// 1-95
);
Expand All @@ -2973,9 +2978,8 @@ LOCAL void wSrfd1( FILE *f)
for (int i = 0; i < nfdtypes; i++)
{
// write data type 0 as "0", not "DTSI" or whatever is first, for clearer entry 0 (FDNONE)
char* dtTx = (Fdtab[i].dtype==0 ? const_cast<char*>("0")
: strtcat( "DT", dtnames[ dtnmi[ DTBMASK&(Fdtab[i].dtype) ] ],
NULL ) );
const char* dtTx = (Fdtab[i].dtype==0 ? "0"
: strtcat( "DT", dtnames[ dtnmi[ DTBMASK&(Fdtab[i].dtype) ] ], NULL ) );
/* write line: DTXXXX, LMXXXX, UNXXXX, // number NAME */
fprintf( f, " {%15s, %10s, %13s },\t//%3d %s\n",
dtTx,
Expand All @@ -2990,23 +2994,24 @@ LOCAL void wSrfd1( FILE *f)

// Write stuff above "fir" tables for record types

fprintf( f,
fprintf(f,
"\n\n/*========== small FIELDS-IN-RECORDS tables for each record type */\n"
"\n"
" /* COLUMNS ARE\n"
" .fdTy .evf .ff .off .mName \n"
" (sFdtab (vari- (fld \n"
" index) ation) flgs) (member offset) (member name) field type name\n"
" ------- ------ ----- ----------------- ------------------ --------------- */\n"
"\n"
"/*lint -e619 suppress msg for putting \"text\" in pointer */\n\n");
"// COLUMNS ARE\n"
"// ff field flags\n"
"// fdTy field type (sFdtab idx)\n"
"// evf variability (evaluation interval)\n"
"// nxsc fn of next field requiring special case copy\n"
"// off member offset\n"
"// mName member name\n"
"// data type (as comment)\n\n");

// wSrfd3, called for each record type, continues the file
} // wSrfd1
//======================================================================
LOCAL void wSrfd2( FILE *f)

// write "Small record and field descriptor" C source file for compilation and linking into applications
// write "Small record and field descriptor" c++ source file for compilation and linking into applications

// PART 2 of 4 parts: portion repeated at each *file statement

Expand All @@ -3019,7 +3024,7 @@ LOCAL void wSrfd2( FILE *f)
//======================================================================
LOCAL void wSrfd3( FILE *f)

// write "Small record and field descriptor" C source file for compilation and linking into applications
// write "Small record and field descriptor" C++ source file for compilation and linking into applications

// PART 3 of 4 parts: portion repeated for each record type: fields-in-record table for current record.

Expand All @@ -3032,61 +3037,77 @@ LOCAL void wSrfd3( FILE *f)

// for file format see comments in srd.h, or in srfd.cpp as output.
{
// identify fields that cannot be copied bit-wise
// chain them together for use in e.g. record::Copy
std::vector< int> nxsc(rcdesc->rcdnfds, -1);
int iNxscPrior = 0;
for (int j = 0; j < rcdesc->rcdnfds; j++)
{
int fdi = rcdesc->rcdfdd[j].rcfdnm; // field type
if (strcmp( rcfdnms[fdi], "CHP")==0)
{ nxsc[iNxscPrior] = j;
iNxscPrior = j;
}
}

fprintf( f, "struct SFIR sfir%s[] =\t// fields info for RT%s\n"
"{\n #define o(m) offsetof(%s,m)\n"
// {dddd, dddd, dddd,ssssssssssssssssssss,sssssssssssssssssss },
" // .ff .fdTy .evf .off .mName\n",
"// ff fdTy evf nxsc off mName\n",
rcNam, rcNam, rcNam );
for (int j = 0; j < rcdesc->rcdnfds; j++) // fields loop
{
int fdi = rcdesc->rcdfdd[j].rcfdnm; // get field type
fprintf( f, " {%4d, %4d, %4d,%20s,%19s },\t// %s\n",
fprintf( f, " {%4d, %4d, %4d, %4d,%20s,%19s },\t// %s\n",
rcdesc->rcdfdd[j].ff, // field flags (attributes)
fdi, // field type
rcdesc->rcdfdd[j].evf, // field variation
nxsc[ j], // next special copy field
strtprintf("o(%s)", fldFullNm2[rcseq][j].c_str()), // full member name, in macro call to make compiler supply offset
enquote( fldNm2[ rcseq][j].c_str()), // user member name in quotes (for probes, error messages)
rcfdnms[fdi] ); // name of field type, in comment
#define WARNAT (30-1) // extra -1 got lots of messages
if (strlen(fldNm2[ rcseq][j].c_str()) > WARNAT) // report overlong ones
rcderr( "Warning: member name over %d long: %s", WARNAT, fldNm2[ rcseq][j].c_str());
}
fprintf( f, " { 0, 0, 0, 0, 0 }\t// terminator\n"
fprintf( f, " { 0, 0, 0, 0, 0, 0 }\t// terminator\n"
" #undef o\n"
"}; // sfir%s\n\n", rcNam );
} // wSrfd3
//======================================================================
LOCAL void wSrfd4( FILE *f)

// write "Small record and field descriptor" C source file for compilation and linking into applications

// PART 4 of 4 parts: stuff after portion repeated for each record type; small record descriptor table.
{

// Write small record descriptor table

fprintf( f, "\n\n/*========== small RECORD DESCRIPTOR table */\n"
"\n"
" // find desired entry by searching for .rt \n"
"\n"
"SRD sRd[] =\n"
"{ // recTy, #fds, fields-in-record pointer\n"
" // .rt .nFlds .fir\n" );
for (int i = 1; i < nrcnms; i++) // loop records types
// note start at 1 to skip RTNONE
{
RCD* rd = (RCD *)( (char *)Rcdtab + (ULI)Rcdtab[ rctypes[i] & RCTMASK]);
// use offset stored in pointer array
// write line " RTXXXX, nFields, sfirXXXX,"
fprintf( f, " {%15s, %3d, sfir%s },\n",
strtcat( "RT", rcnms[i], NULL),
rd->rcdnfds, rcnms[i] );
}
fprintf( f, " { 0, 0, 0 }\t// terminate table for searching\n"
"}; // sRd[]\n");

// caller recs() finishes file and closes.
} // wSrfd4
#if 0
0 DROPPED 6-2023 (unused)
0 LOCAL void wSrfd4( FILE *f)
0
0 // write "Small record and field descriptor" C++ file for compilation and linking into applications
0
0 // PART 4 of 4 parts: stuff after portion repeated for each record type; small record descriptor table.
0 {
0
0 // Write small record descriptor table
0
0 fprintf( f, "\n\n/*========== small RECORD DESCRIPTOR table */\n"
0 "\n"
0 " // find desired entry by searching for .rt \n"
0 "\n"
0 "SRD sRd[] =\n"
0 "{ // recTy, #fds, fields-in-record pointer\n"
0 " // .rt .nFlds .fir\n" );
0 for (int i = 1; i < nrcnms; i++) // loop records types
0 // note start at 1 to skip RTNONE
0 {
0 RCD* rd = (RCD *)( (char *)Rcdtab + (ULI)Rcdtab[ rctypes[i] & RCTMASK]);
0 // use offset stored in pointer array
0 // write line " RTXXXX, nFields, sfirXXXX,"
0 fprintf( f, " {%15s, %3d, sfir%s },\n",
0 strtcat( "RT", rcnms[i], NULL),
0 rd->rcdnfds, rcnms[i] );
0 }
0 fprintf( f, " { 0, 0, 0 }\t// terminate table for searching\n"
0 "}; // sRd[]\n");
0
0 // caller recs() finishes file and closes.
0 } // wSrfd4
#endif

//======================================================================
LOCAL void sumry() // write rcdef summary to screen and file
Expand Down
12 changes: 6 additions & 6 deletions src/ancrec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ record::record(BP _b, TI i, SI noZ/*=0*/) // construct record i of basAnc b, z
} // record::record
//---------------------------------------------------------------------------------------------------------------------------
void* record::field( int fn) // point to member in record by FIELD #
{ return (void *)((char *)this + b->fir[fn].off); }
{ return (void *)((char *)this + b->fir[fn].fi_off); }
//-----------------------------------------------------------------------------
const void* record::field( int fn) const
{ return (const void *)((const char *)this + b->fir[fn].off); }
{ return (const void *)((const char *)this + b->fir[fn].fi_off); }
//-----------------------------------------------------------------------------
void record::RRFldCopy( // record-to-record field copy
const record* r, // source record (same type as this)
Expand Down Expand Up @@ -100,7 +100,7 @@ void record::FldCopy( // field-to-field copy (within record)
} // record::FldCopy
//-----------------------------------------------------------------------------
int record::DType( int fn) const
{ int fdTy = b->fir[ fn].fdTy; // get field type (sFdtab subscript) from rat's "Fields In Record" table
{ int fdTy = b->fir[ fn].fi_fdTy; // get field type (sFdtab subscript) from rat's "Fields In Record" table
int dt = sFdtab[ fdTy].dtype; // get data type from small Fields info Table
return dt;
} // record::DType
Expand Down Expand Up @@ -638,7 +638,7 @@ void CDEC record::chafSelf( // say increment change flag IN SAME RECORD on cha
{
va_list ap;
va_start(ap, chafFn);
chafNV(this->b, ss, b->fir[chafFn].off, ap);
chafNV(this->b, ss, b->fir[chafFn].fi_off, ap);
} // record::chafSelf
//============================================================================================================================
void CDEC record::chafN( // say increment specified flag during run on change in list of fields in curr record
Expand Down Expand Up @@ -884,7 +884,7 @@ void * FC basAnc::recFld( TI i, SI fn) // point record i member by FIELD #
/* note: this is not in ancrec.h to avoid needing to include srd.h first for sFIRstr;
it is not virtual to avoid multiple copies. delete later (3-92) if not used. */
{
return (void *)((char *)&rec(i) + fir[fn].off); // get field offset from basAnc's fields-in-record table
return (void *)((char *)&rec(i) + fir[fn].fi_off); // get field offset from basAnc's fields-in-record table
}
//---------------------------------------------------------------------------------------------------------------------------
RC FC basAnc::al( // destroy any existing records and allocate space for n (0=default) records
Expand Down Expand Up @@ -1251,7 +1251,7 @@ const char* basAnc::getChoiTx( // return text of given value for a choice data

// add more checks to this code if errors tend to happen...

USI fdTy = fir[fn].fdTy; // get field type (sFdtab subscript) from rat's "Fields In Record" table
USI fdTy = fir[fn].fi_fdTy; // get field type (sFdtab subscript) from rat's "Fields In Record" table
USI dt = sFdtab[fdTy].dtype; // get data type from small Fields info Table

chan &= ~NCNAN; // clear special bits in nchoice value to make checks work
Expand Down
Loading