Refactored 'Constant' to 'NCConstant' in ncgen/ to avoid

reserved word collision on Windows.

Added tst_ncgen4_classic.sh to CMake-based builds.
This commit is contained in:
Ward Fisher 2013-07-16 20:22:48 +00:00
parent 7f9ff06665
commit a90b386e0a
20 changed files with 129 additions and 126 deletions

View File

@ -111,9 +111,10 @@ IF(ENABLE_TESTS)
add_sh_test(ncdump tst_grp_spec)
add_sh_test(ncdump tst_mud)
add_sh_test(ncdump_shell tst_h_scalar)
ENDIF()
#add_sh_test(tst_ncgen4_classic)
add_sh_test(ncdump tst_ncgen4_classic)
IF(USE_NETCDF4)
add_sh_test(ncdump tst_ncgen4)
ENDIF()

View File

@ -25,7 +25,7 @@ bin_charconstant(Generator* generator, Bytebuffer* buf, ...)
}
static int
bin_constant(Generator* generator, Constant* con, Bytebuffer* buf,...)
bin_constant(Generator* generator, NCConstant* con, Bytebuffer* buf,...)
{
if(con->nctype != NC_ECONST) {
alignbuffer(con,buf);

View File

@ -28,7 +28,7 @@ c_charconstant(Generator* generator, Bytebuffer* codebuf, ...)
}
static int
c_constant(Generator* generator, Constant* con, Bytebuffer* buf,...)
c_constant(Generator* generator, NCConstant* con, Bytebuffer* buf,...)
{
Bytebuffer* codetmp = bbNew();
char* special = NULL;

View File

@ -13,7 +13,7 @@
static char stmp[256];
void
convert1(Constant* src, Constant* dst)
convert1(NCConstant* src, NCConstant* dst)
{
Constvalue tmp;
unsigned char* bytes = NULL;
@ -608,7 +608,7 @@ setprimlength(Constant* prim, unsigned long len)
#endif
Datalist*
convertstringtochars(Constant* str)
convertstringtochars(NCConstant* str)
{
int i;
Datalist* dl;
@ -619,7 +619,7 @@ convertstringtochars(Constant* str)
dl = builddatalist(slen);
s = str->value.stringv.stringv;
for(i=0;i<slen;i++) {
Constant con;
NCConstant con;
con.nctype = NC_CHAR;
con.lineno = str->lineno;
con.value.charv = s[i];

View File

@ -15,8 +15,8 @@
extern int lvsnprintf(char*, size_t, const char*, va_list);
*/
Constant nullconstant;
Constant fillconstant;
NCConstant nullconstant;
NCConstant fillconstant;
Datalist nildatalist; // to support NIL keyword
@ -49,7 +49,7 @@ return srcpeek(datasrc) == NULL || istype(datasrc,NC_FILLVALUE);
int
istype(Datasrc* datasrc , nc_type nctype)
{
Constant* ci = srcpeek(datasrc);
NCConstant* ci = srcpeek(datasrc);
if(ci != NULL && ci->nctype == nctype) return 1;
return 0;
}
@ -101,7 +101,7 @@ datalist2src(Datalist* list)
}
Datasrc*
const2src(Constant* con)
const2src(NCConstant* con)
{
Datasrc* src;
ASSERT(con != NULL);
@ -113,10 +113,10 @@ const2src(Constant* con)
return src;
}
Constant
NCConstant
list2const(Datalist* list)
{
Constant con;
NCConstant con;
ASSERT(list != NULL);
con.nctype = NC_COMPOUND;
con.lineno = list->data[0].lineno;
@ -126,7 +126,7 @@ list2const(Datalist* list)
}
Datalist*
const2list(Constant* con)
const2list(NCConstant* con)
{
Datalist* list;
ASSERT(con != NULL);
@ -137,7 +137,7 @@ const2list(Constant* con)
return list;
}
Constant*
NCConstant*
srcpeek(Datasrc* ds)
{
if(ds == NULL) return NULL;
@ -148,7 +148,7 @@ srcpeek(Datasrc* ds)
return NULL;
}
Constant*
NCConstant*
srcnext(Datasrc* ds)
{
DUMPSRC(ds,"!");
@ -185,7 +185,7 @@ srcline(Datasrc* ds)
void
srcpush(Datasrc* src)
{
Constant* con;
NCConstant* con;
ASSERT(src != NULL);
con = srcnext(src);
ASSERT(con->nctype == NC_COMPOUND);
@ -256,10 +256,10 @@ report0(char* lead, Datasrc* src, int index)
/**************************************************/
/* Shallow constant cloning*/
Constant
cloneconstant(Constant* con)
NCConstant
cloneconstant(NCConstant* con)
{
Constant newcon = *con;
NCConstant newcon = *con;
char* s;
switch (newcon.nctype) {
case NC_STRING:
@ -295,23 +295,23 @@ datalistclone(Datalist* dl)
Datalist*
datalistconcat(Datalist* dl1, Datalist* dl2)
{
Constant* vector;
NCConstant* vector;
ASSERT(dl1 != NULL);
if(dl2 == NULL) return dl1;
vector = (Constant*)erealloc(dl1->data,sizeof(Constant)*(dl1->length+dl2->length));
vector = (NCConstant*)erealloc(dl1->data,sizeof(NCConstant)*(dl1->length+dl2->length));
if(vector == NULL) return NULL;
memcpy((void*)(vector+dl1->length),dl2->data,sizeof(Constant)*(dl2->length));
memcpy((void*)(vector+dl1->length),dl2->data,sizeof(NCConstant)*(dl2->length));
dl1->data = vector;
return dl1;
}
Datalist*
datalistappend(Datalist* dl, Constant* con)
datalistappend(Datalist* dl, NCConstant* con)
{
Constant* vector;
NCConstant* vector;
ASSERT(dl != NULL);
if(con == NULL) return dl;
vector = (Constant*)erealloc(dl->data,sizeof(Constant)*(dl->length+1));
vector = (NCConstant*)erealloc(dl->data,sizeof(NCConstant)*(dl->length+1));
if(vector == NULL) return NULL;
vector[dl->length] = *con;
dl->length++;
@ -320,7 +320,7 @@ datalistappend(Datalist* dl, Constant* con)
}
Datalist*
datalistreplace(Datalist* dl, unsigned int index, Constant* con)
datalistreplace(Datalist* dl, unsigned int index, NCConstant* con)
{
ASSERT(dl != NULL);
ASSERT(index < dl->length);
@ -431,7 +431,7 @@ wordstring(char* p, Bytebuffer* buf, int quote)
static const char zeros[] =
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
void
alignbuffer(Constant* prim, Bytebuffer* buf)
alignbuffer(NCConstant* prim, Bytebuffer* buf)
{
int alignment,pad,offset;
@ -633,8 +633,8 @@ codeprintf(const char *fmt, ...)
va_end(argv);
}
Constant*
emptycompoundconst(int lineno, Constant* c)
NCConstant*
emptycompoundconst(int lineno, NCConstant* c)
{
ASSERT(c != NULL);
c->lineno = lineno;
@ -644,8 +644,8 @@ emptycompoundconst(int lineno, Constant* c)
return c;
}
Constant*
emptystringconst(int lineno, Constant* c)
NCConstant*
emptystringconst(int lineno, NCConstant* c)
{
ASSERT(c != NULL);
c->lineno = lineno;

View File

@ -48,19 +48,19 @@ typedef union Constvalue {
struct Symbol* enumv; /* NC_ECONST*/
} Constvalue;
typedef struct Constant {
typedef struct NCConstant {
nc_type nctype;
int lineno;
Constvalue value;
int filled; /* was this originally NC_FILLVALUE? */
} Constant;
} NCConstant;
typedef struct Datalist {
struct Datalist* next; /* chain of all known datalists*/
int readonly; /* data field is shared with another Datalist*/
size_t length; /* |data| */
size_t alloc; /* track total allocated space for data field*/
Constant* data; /* actual list of constants constituting the datalist*/
NCConstant* data; /* actual list of constants constituting the datalist*/
/* Track various values associated with the datalist*/
/* (used to be in Constvalue.compoundv)*/
struct Vlen {
@ -75,7 +75,7 @@ typedef struct Datalist {
In effect, we are parsing the data sequence.
Push and pop of data sources is supported (see srcpush() below).*/
typedef struct Datasrc {
Constant* data; /* duplicate pointer; so do not free.*/
NCConstant* data; /* duplicate pointer; so do not free.*/
int index;
int length;
int spliced; /* Was this list spliced into our parent ? */
@ -97,9 +97,9 @@ int istype(Datasrc* src, nc_type);
int isstringable(nc_type nctype);
Datasrc* datalist2src(Datalist* list);
Datasrc* const2src(Constant*);
Constant list2const(Datalist*);
Datalist* const2list(Constant* con);
Datasrc* const2src(NCConstant*);
NCConstant list2const(Datalist*);
Datalist* const2list(NCConstant* con);
void freedatasrc(Datasrc* src);
void srcpush(Datasrc*);
@ -112,7 +112,7 @@ int datalistline(Datalist*);
#define datalistlen(dl) ((dl)==NULL?0:(dl)->length)
Constant* srcnext(Datasrc*);
NCConstant* srcnext(Datasrc*);
int srcmore(Datasrc*);
int srcline(Datasrc* ds);
@ -122,11 +122,11 @@ int srcline(Datasrc* ds);
#define isnilconst(con) ((con)!=NULL && (con)->nctype == NC_NIL)
Constant* emptystringconst(int,Constant*);
NCConstant* emptystringconst(int,NCConstant*);
Constant cloneconstant(Constant* con); /* shallow clone*/
NCConstant cloneconstant(NCConstant* con); /* shallow clone*/
void alignbuffer(struct Constant* prim, Bytebuffer* buf);
void alignbuffer(struct NCConstant* prim, Bytebuffer* buf);
/* Code dump support procedures */
void bbindent(Bytebuffer*,const int);
@ -150,16 +150,16 @@ extern Bytebuffer* stmt; /* single stmt text generation */
#ifdef FASTDATASRC
#define srcpeek(ds) ((ds)==NULL || (ds)->index >= (ds)->max?NULL:(ds)->data+(ds)->index)
#else
Constant* srcpeek(Datasrc*);
NCConstant* srcpeek(Datasrc*);
#endif
/* Aliases */
#define srcincr(src) srcnext(src)
#define srcget(src) srcpeek(src)
extern Constant nullconstant;
extern Constant fillconstant;
extern Constant nilconstant;
extern NCConstant nullconstant;
extern NCConstant fillconstant;
extern NCConstant nilconstant;
/* From genchar.c */
void gen_charattr(Datalist*, Bytebuffer*);
@ -179,7 +179,7 @@ typedef enum ListClass {
struct Generator {
void* state;
int (*charconstant)(Generator*,Bytebuffer*,...);
int (*constant)(Generator*,Constant*,Bytebuffer*,...);
int (*constant)(Generator*,NCConstant*,Bytebuffer*,...);
int (*listbegin)(Generator*,ListClass,size_t,Bytebuffer*,int*,...);
int (*list)(Generator*,ListClass,int,size_t,Bytebuffer*,...);
int (*listend)(Generator*,ListClass,int,size_t,Bytebuffer*,...);
@ -194,7 +194,7 @@ typedef int (*Writer)(Generator*,struct Symbol*,Bytebuffer*,int,size_t*,size_t*)
extern void generate_attrdata(struct Symbol*, Generator*, Writer writer, Bytebuffer*);
extern void generate_vardata(struct Symbol*, Generator*, Writer writer,Bytebuffer*);
extern void generate_basetype(struct Symbol*,Constant*,Bytebuffer*,Datalist*,Generator*);
extern void generate_basetype(struct Symbol*,NCConstant*,Bytebuffer*,Datalist*,Generator*);
#endif /*DATA_H*/

View File

@ -11,7 +11,7 @@
#define DEBUGSRC
/* Forward */
static void dumpdataprim(Constant*,Bytebuffer*);
static void dumpdataprim(NCConstant*,Bytebuffer*);
char*
indentstr(int n)
@ -24,7 +24,7 @@ indentstr(int n)
void
dumpconstant(Constant* con, char* tag)
dumpconstant(NCConstant* con, char* tag)
{
Bytebuffer* buf = bbNew();
Datalist* dl = builddatalist(1);
@ -47,7 +47,7 @@ void
bufdump(Datalist* list, Bytebuffer* buf)
{
int i;
Constant* dp;
NCConstant* dp;
unsigned int count;
if(list == NULL) {
@ -88,7 +88,7 @@ bufdump(Datalist* list, Bytebuffer* buf)
static void
dumpdataprim(Constant* ci, Bytebuffer* buf)
dumpdataprim(NCConstant* ci, Bytebuffer* buf)
{
char tmp[64];
ASSERT(isprimplus(ci->nctype) || ci->nctype == NC_FILLVALUE);
@ -186,7 +186,7 @@ dumpgroup(Symbol* g)
}
void
dumpconstant1(Constant* con)
dumpconstant1(NCConstant* con)
{
switch (con->nctype) {
case NC_COMPOUND: {

View File

@ -11,7 +11,7 @@
extern void dumptransform(Datalist*);
extern void dumpdatalist(Datalist*,char*);
extern void dumpconstant(Constant*,char*);
extern void dumpconstant(NCConstant*,char*);
extern void bufdump(Datalist*,Bytebuffer*);
extern void dumpgroup(Symbol* g);
extern void dumpsrc(Datasrc*,char*);

View File

@ -28,7 +28,7 @@ f77_charconstant(Generator* generator, Bytebuffer* codebuf, ...)
}
static int
f77_constant(Generator* generator, Constant* ci, Bytebuffer* codebuf,...)
f77_constant(Generator* generator, NCConstant* ci, Bytebuffer* codebuf,...)
{
char tmp[64];
char* special = NULL;

View File

@ -10,7 +10,7 @@
language independent */
/******************************************************/
static size_t gen_charconstant(Constant*, Bytebuffer*, int fillchar);
static size_t gen_charconstant(NCConstant*, Bytebuffer*, int fillchar);
static int getfillchar(Datalist* fillsrc);
static void gen_chararrayr(Dimset*,int,int,Bytebuffer*,Datalist*,int,int,int);
@ -95,14 +95,14 @@ gen_chararrayr(Dimset* dimset, int dimindex, int lastunlimited,
if(dimindex < lastunlimited) {
/* keep recursing */
for(i=0;i<dimsize;i++) {
Constant* c = datalistith(data,i);
NCConstant* c = datalistith(data,i);
ASSERT(islistconst(c));
gen_chararrayr(dimset,dimindex+1,lastunlimited,databuf,
c->value.compoundv,fillchar,unitsize,expectedsize);
}
} else {/* we should be at a list of simple constants */
for(i=0;i<data->length;i++) {
Constant* c = datalistith(data,i);
NCConstant* c = datalistith(data,i);
ASSERT(!islistconst(c));
if(isstringable(c->nctype)) {
int j;
@ -143,7 +143,7 @@ void
gen_charvlen(Datalist* data, Bytebuffer* databuf)
{
int i;
Constant* c;
NCConstant* c;
ASSERT(bbLength(databuf) == 0);
@ -160,7 +160,7 @@ gen_charvlen(Datalist* data, Bytebuffer* databuf)
}
static size_t
gen_charconstant(Constant* con, Bytebuffer* databuf, int fillchar)
gen_charconstant(NCConstant* con, Bytebuffer* databuf, int fillchar)
{
/* Following cases should be consistent with isstringable */
size_t constsize = 1;
@ -194,7 +194,7 @@ getfillchar(Datalist* fillsrc)
/* Determine the fill char */
int fillchar = 0;
if(fillsrc != NULL && fillsrc->length > 0) {
Constant* ccon = fillsrc->data;
NCConstant* ccon = fillsrc->data;
if(ccon->nctype == NC_CHAR) {
fillchar = ccon->value.charv;
} else if(ccon->nctype == NC_STRING) {
@ -246,7 +246,7 @@ gen_leafchararray(Dimset* dimset, int lastunlim, Datalist* data,
}
for(i=0;i<data->length;i++) {
Constant* c = datalistith(data,i);
NCConstant* c = datalistith(data,i);
ASSERT(!islistconst(c));
if(isstringable(c->nctype)) {
int j;

View File

@ -16,8 +16,8 @@
/* Forward*/
static void generate_array(Symbol*,Bytebuffer*,Datalist*,Generator*,Writer);
static void generate_arrayr(Symbol*,Bytebuffer*,Datalist*,Odometer*,int,Datalist*,Generator*);
static void generate_primdata(Symbol*, Constant*, Bytebuffer*, Datalist* fillsrc, Generator*);
static void generate_fieldarray(Symbol*, Constant*, Dimset*, Bytebuffer*, Datalist* fillsrc, Generator*);
static void generate_primdata(Symbol*, NCConstant*, Bytebuffer*, Datalist* fillsrc, Generator*);
static void generate_fieldarray(Symbol*, NCConstant*, Dimset*, Bytebuffer*, Datalist* fillsrc, Generator*);
/* Mnemonics */
#define VLENLIST1
@ -65,7 +65,7 @@ generate_attrdata(Symbol* asym, Generator* generator, Writer writer, Bytebuffer*
size_t count;
generator->listbegin(generator,LISTATTR,asym->data->length,codebuf,&uid);
for(count=0;count<asym->data->length;count++) {
Constant* con = datalistith(asym->data,count);
NCConstant* con = datalistith(asym->data,count);
generator->list(generator,LISTATTR,uid,count,codebuf);
generate_basetype(asym->typ.basetype,con,codebuf,NULL,generator);
}
@ -88,7 +88,7 @@ generate_vardata(Symbol* vsym, Generator* generator, Writer writer, Bytebuffer*
bbSetalloc(code, nciterbuffersize);
if(rank == 0) {/*scalar case*/
Constant* c0 = datalistith(vsym->data,0);
NCConstant* c0 = datalistith(vsym->data,0);
generate_basetype(basetype,c0,code,filler,generator);
writer(generator,vsym,code,0,NULL,NULL);
} else {/*rank > 0*/
@ -152,7 +152,7 @@ generate_array(Symbol* vsym,
#ifdef ITERBUG
Constant* con = datalistith(vsym->data,i);
#else
Constant* con = datalistith(vsym->data,i+offset);
NCConstant* con = datalistith(vsym->data,i+offset);
#endif
generator->list(generator,LISTDATA,uid,i,code);
#ifdef USE_NOFILL
@ -243,7 +243,7 @@ generate_arrayr(Symbol* vsym,
generator->listbegin(generator,LISTDATA,list->length,code,&uid);
for(i=0;odometermore(slabodom);i++) {
size_t offset = odometeroffset(slabodom);
Constant* con = datalistith(list,offset);
NCConstant* con = datalistith(list,offset);
#ifdef USE_NOFILL
if(nofill_flag && con == NULL)
break;
@ -272,7 +272,7 @@ generate_arrayr(Symbol* vsym,
*/
for(i=0;odometermore(slabodom);i++) {
size_t offset = odometeroffset(slabodom);
Constant* con = datalistith(list,offset);
NCConstant* con = datalistith(list,offset);
#ifdef USE_NOFILL
if(nofill_flag && con == NULL)
break;
@ -298,7 +298,7 @@ generate_arrayr(Symbol* vsym,
/* Generate an instance of the basetype */
void
generate_basetype(Symbol* tsym, Constant* con, Bytebuffer* codebuf, Datalist* filler, Generator* generator)
generate_basetype(Symbol* tsym, NCConstant* con, Bytebuffer* codebuf, Datalist* filler, Generator* generator)
{
Datalist* data;
@ -368,8 +368,9 @@ generate_basetype(Symbol* tsym, Constant* con, Bytebuffer* codebuf, Datalist* fi
} else {
generator->listbegin(generator,LISTVLEN,data->length,codebuf,&uid);
for(count=0;count<data->length;count++) {
NCConstant* con;
generator->list(generator,LISTVLEN,uid,count,vlenbuf);
Constant* con = datalistith(data,count);
con = datalistith(data,count);
generate_basetype(tsym->typ.basetype,con,vlenbuf,NULL,generator);
}
generator->listend(generator,LISTVLEN,uid,count,codebuf,(void*)vlenbuf);
@ -395,7 +396,7 @@ generate_basetype(Symbol* tsym, Constant* con, Bytebuffer* codebuf, Datalist* fi
/* Used only for structure field arrays*/
static void
generate_fieldarray(Symbol* basetype, Constant* con, Dimset* dimset,
generate_fieldarray(Symbol* basetype, NCConstant* con, Dimset* dimset,
Bytebuffer* codebuf, Datalist* filler, Generator* generator)
{
int i;
@ -436,7 +437,7 @@ generate_fieldarray(Symbol* basetype, Constant* con, Dimset* dimset,
Note that the string is a sequence of nibbles (4 bits).
*/
static void
normalizeopaquelength(Constant* prim, unsigned long nbytes)
normalizeopaquelength(NCConstant* prim, unsigned long nbytes)
{
int nnibs = 2*nbytes;
ASSERT(prim->nctype==NC_OPAQUE);
@ -458,10 +459,10 @@ normalizeopaquelength(Constant* prim, unsigned long nbytes)
}
static void
generate_primdata(Symbol* basetype, Constant* prim, Bytebuffer* codebuf,
generate_primdata(Symbol* basetype, NCConstant* prim, Bytebuffer* codebuf,
Datalist* filler, Generator* generator)
{
Constant target;
NCConstant target;
if(prim == NULL || isfillconst(prim)) {
Datalist* fill = (filler==NULL?getfiller(basetype):filler);

View File

@ -69,7 +69,7 @@ extern char* jescapifyname(char* s0);
extern char* jdecodify(const char *name);
/* from: getfill.c */
extern void nc_getfill(Constant*);
extern void nc_getfill(NCConstant*);
extern char* nc_dfaltfillname(nc_type);
extern struct Datalist* getfiller(Symbol*); /* symbol isa variable|type */
@ -79,9 +79,9 @@ extern Symbol* basetypefor(nc_type nctype);/* Convert nctype to a Symbol*/
extern Symbol* makearraytype(Symbol*, Dimset*);
/* from: cvt.c */
extern void convert1(Constant*,Constant*); /* Convert an arbitrary value to another */
extern void setprimlength(Constant* prim, unsigned long len);
extern struct Datalist* convertstringtochars(Constant* str);
extern void convert1(NCConstant*,NCConstant*); /* Convert an arbitrary value to another */
extern void setprimlength(NCConstant* prim, unsigned long len);
extern struct Datalist* convertstringtochars(NCConstant* str);
/* from: semantic.c */
@ -100,11 +100,11 @@ extern void semwarnlno,fmt,va_alist) const int lno; const char* fmt; va_dcl;
#endif
extern int nounlimited(Dimset* dimset, int from);
extern int lastunlimited(Dimset* dimset);
extern void padstring(Constant* con, size_t desiredlength, int fillchar);
extern void padstring(NCConstant* con, size_t desiredlength, int fillchar);
extern Datalist* explodestrings(Datalist*,char*);
extern Datalist* implodestrings(Datalist*,char*);
extern int explodestringconst(Constant* con, char* tag, Constant*);
extern int explodestringconst(NCConstant* con, char* tag, NCConstant*);
extern char* indented(int n);

View File

@ -51,7 +51,7 @@ static void
fill(Symbol* tsym, Datalist* filler)
{
int i;
Constant con;
NCConstant con;
Datalist* sublist;
ASSERT(tsym->objectclass == NC_TYPE);
switch (tsym->subclass) {
@ -85,7 +85,7 @@ filllist(Symbol* tsym, Datalist* dl)
{
int i;
Datalist* sublist;
Constant con;
NCConstant con;
ASSERT(tsym->objectclass == NC_TYPE);
switch (tsym->subclass) {
@ -148,7 +148,7 @@ fillarray(Symbol* basetype, Dimset* dimset, int index, Datalist* arraylist)
* that type.
*/
void
nc_getfill(Constant* value)
nc_getfill(NCConstant* value)
{
switch(value->nctype) {
case NC_CHAR: value->value.charv = NC_FILL_CHAR; break;

View File

@ -28,7 +28,7 @@ j_charconstant(Generator* generator, Bytebuffer* codebuf, ...)
}
static int
j_constant(Generator* generator, Constant* con, Bytebuffer* buf,...)
j_constant(Generator* generator, NCConstant* con, Bytebuffer* buf,...)
{
Bytebuffer* codetmp = bbNew();
char* special = NULL;

View File

@ -429,7 +429,7 @@ void
init_netcdf(void) /* initialize global counts, flags */
{
compute_alignments();
memset((void*)&nullconstant,0,sizeof(Constant));
memset((void*)&nullconstant,0,sizeof(NCConstant));
fillconstant = nullconstant;
fillconstant.nctype = NC_FILLVALUE;

View File

@ -139,7 +139,7 @@ typedef struct Typeinfo {
nc_type typecode;
unsigned long offset; /* fields in struct*/
unsigned long alignment;/* fields in struct*/
Constant econst; /* for enum values*/
NCConstant econst; /* for enum values*/
Dimset dimset; /* for NC_VAR/NC_FIELD/NC_ATT*/
size_t size; /* for opaque, compound, etc.*/
size_t nelems; /* size in terms of # of datalist constants

View File

@ -160,9 +160,9 @@ List* condefs; /* non-dimension constants used in type defs*/
List* tmp;
/* Forward */
static Constant makeconstdata(nc_type);
static Constant evaluate(Symbol* fcn, Datalist* arglist);
static Constant makeenumconst(Symbol*);
static NCConstant makeconstdata(nc_type);
static NCConstant evaluate(Symbol* fcn, Datalist* arglist);
static NCConstant makeenumconst(Symbol*);
static void addtogroup(Symbol*);
static Symbol* currentgroup(void);
static Symbol* createrootgroup(void);
@ -173,7 +173,7 @@ static Symbol* makeattribute(Symbol*,Symbol*,Symbol*,Datalist*,Attrkind);
static Symbol* makeprimitivetype(nc_type i);
static Symbol* makespecial(int tag, Symbol* vsym, Symbol* tsym, void* data, int isconst);
static int containsfills(Datalist* list);
static void datalistextend(Datalist* dl, Constant* con);
static void datalistextend(Datalist* dl, NCConstant* con);
static void vercheck(int ncid);
int yylex(void);
@ -288,7 +288,7 @@ unsigned long size; /* allow for zero size to indicate e.g. UNLIMITED*/
long mark; /* track indices into the sequence*/
int nctype; /* for tracking attribute list type*/
Datalist* datalist;
Constant constant;
NCConstant constant;
/* Line 374 of yacc.c */
@ -3210,10 +3210,10 @@ creategroup(Symbol * gsym)
return gsym;
}
static Constant
static NCConstant
makeconstdata(nc_type nctype)
{
Constant con = nullconstant;
NCConstant con = nullconstant;
consttype = nctype;
con.nctype = nctype;
con.lineno = lineno;
@ -3273,10 +3273,10 @@ makeconstdata(nc_type nctype)
return con;
}
static Constant
static NCConstant
makeenumconst(Symbol* econst)
{
Constant con;
NCConstant con;
markcdf4("Enum type");
consttype = NC_ENUM;
con.nctype = NC_ECONST;
@ -3355,7 +3355,7 @@ specialname(int flag)
}
static int
truefalse(Constant* con, int tag)
truefalse(NCConstant* con, int tag)
{
if(con->nctype == NC_STRING) {
char* sdata = con->value.stringv.stringv;
@ -3384,9 +3384,9 @@ makespecial(int tag, Symbol* vsym, Symbol* tsym, void* data, int isconst)
{
Symbol* attr = NULL;
Datalist* list;
Constant* con;
NCConstant* con;
Specialdata* special = (Specialdata*)malloc(sizeof(Specialdata));
Constant iconst;
NCConstant iconst;
int tf = 0;
char* sdata = NULL;
int idata = -1;
@ -3394,12 +3394,12 @@ makespecial(int tag, Symbol* vsym, Symbol* tsym, void* data, int isconst)
specials_flag += (tag == _FILLVALUE_FLAG ? 0 : 1);
if(isconst) {
con = (Constant*)data;
con = (NCConstant*)data;
list = builddatalist(1);
dlappend(list,(Constant*)data);
dlappend(list,(NCConstant*)data);
} else {
list = (Datalist*)data;
con = (Constant*)list->data;
con = (NCConstant*)list->data;
}
if(tag == _FORMAT && vsym != NULL) {
@ -3567,7 +3567,7 @@ containsfills(Datalist* list)
{
if(list != NULL) {
int i;
Constant* con = list->data;
NCConstant* con = list->data;
for(i=0;i<list->length;i++,con++) {
if(con->nctype == NC_COMPOUND) {
if(containsfills(con->value.compoundv)) return 1;
@ -3578,7 +3578,7 @@ containsfills(Datalist* list)
}
static void
datalistextend(Datalist* dl, Constant* con)
datalistextend(Datalist* dl, NCConstant* con)
{
dlappend(dl,con);
}
@ -3611,10 +3611,10 @@ Note that currently, only a single value can
be returned.
*/
static Constant
static NCConstant
evaluate(Symbol* fcn, Datalist* arglist)
{
Constant result;
NCConstant result;
/* prepare the result */
result.lineno = fcn->lineno;

View File

@ -346,7 +346,7 @@ processenums(void)
if(tsym->subclass != NC_ENUM) continue;
for(j=0;j<listlength(tsym->subnodes);j++) {
Symbol* esym = (Symbol*)listget(tsym->subnodes,j);
Constant newec;
NCConstant newec;
ASSERT(esym->subclass == NC_ECONST);
newec.nctype = esym->typ.typecode;
convert1(&esym->typ.econst,&newec);
@ -491,7 +491,7 @@ processspecial1(Symbol* vsym)
{
unsigned long flags = vsym->var.special.flags;
int i,tag;
Constant con;
NCConstant con;
Datalist* dlist = NULL;
if(flags == 0) return; /* no specials defined */
con = nullconstant;
@ -660,7 +660,7 @@ inferattributetype1(Datasrc* src)
result = inferattributetype1(src);
srcpop(src);
} else {
Constant* con = srcnext(src);
NCConstant* con = srcnext(src);
if(isprimplus(con->nctype)) result = con->nctype;
/* else keep looking*/
}
@ -718,7 +718,7 @@ validateNILr(Datalist* src)
{
int i;
for(i=0;i<src->length;i++) {
Constant* con = datalistith(src,i);
NCConstant* con = datalistith(src,i);
if(isnilconst(con))
semerror(con->lineno,"NIL data can only be assigned to variables or attributes of type string");
else if(islistconst(con)) /* recurse */
@ -739,6 +739,7 @@ validateNIL(Symbol* sym)
#endif
}
/* Find name within group structure*/
Symbol*
lookupgroup(List* prefix)
@ -889,7 +890,7 @@ thisunlim->name,
thisunlim->dim.declsize = unlimsize;
/*!lastunlim => data is list of sublists, recurse on each sublist*/
for(i=0;i<data->length;i++) {
Constant* con = data->data+i;
NCConstant* con = data->data+i;
ASSERT(con->nctype == NC_COMPOUND);
computeunlimitedsizes(dimset,nextunlim,con->value.compoundv,ischar);
}
@ -899,7 +900,7 @@ thisunlim->name,
compute total number of characters */
length = 0;
for(i=0;i<data->length;i++) {
Constant* con = &data->data[i];
NCConstant* con = &data->data[i];
switch (con->nctype) {
case NC_CHAR: case NC_BYTE: case NC_UBYTE:
length++;
@ -956,7 +957,7 @@ processunlimiteddims(void)
computeunlimitedsizes(dimset,first,var->data,ischar);
} else {
for(i=0;i<var->data->length;i++) {
Constant* con = var->data->data+i;
NCConstant* con = var->data->data+i;
if(con->nctype != NC_COMPOUND)
semerror(con->lineno,"UNLIMITED dimension (other than first) must be enclosed in {}");
else

View File

@ -479,13 +479,13 @@ dlextend(Datalist* dl)
void
dlsetalloc(Datalist* dl, size_t newalloc)
{
Constant* newdata;
NCConstant* newdata;
if(newalloc <= 0) newalloc = 1;
if(dl->alloc > 0)
newdata = (Constant*)erealloc((void*)dl->data,sizeof(Constant)*newalloc);
newdata = (NCConstant*)erealloc((void*)dl->data,sizeof(NCConstant)*newalloc);
else {
newdata = (Constant*)emalloc(sizeof(Constant)*newalloc);
memset((void*)newdata,0,sizeof(Constant)*newalloc);
newdata = (NCConstant*)emalloc(sizeof(NCConstant)*newalloc);
memset((void*)newdata,0,sizeof(NCConstant)*newalloc);
}
dl->alloc = newalloc;
dl->data = newdata;
@ -500,26 +500,26 @@ builddatalist(int initial)
initial++; /* for header*/
ci = (Datalist*)emalloc(sizeof(Datalist));
memset((void*)ci,0,sizeof(Datalist)); /* only clear the hdr*/
ci->data = (Constant*)emalloc(sizeof(Constant)*initial);
memset((void*)ci->data,0,sizeof(Constant)*initial);
ci->data = (NCConstant*)emalloc(sizeof(NCConstant)*initial);
memset((void*)ci->data,0,sizeof(NCConstant)*initial);
ci->alloc = initial;
ci->length = 0;
return ci;
}
void
dlappend(Datalist* dl, Constant* constant)
dlappend(Datalist* dl, NCConstant* constant)
{
if(dl->length >= dl->alloc) dlextend(dl);
if(constant == NULL) constant = &nullconstant;
dl->data[dl->length++] = *constant;
}
Constant
NCConstant
builddatasublist(Datalist* dl)
{
Constant d;
NCConstant d;
d.nctype = NC_COMPOUND;
d.lineno = (dl->length > 0?dl->data[0].lineno:0);
d.value.compoundv = dl;
@ -529,7 +529,7 @@ builddatasublist(Datalist* dl)
}
static void
constantFree(Constant* con)
constantFree(NCConstant* con)
{
switch(con->nctype) {
case NC_COMPOUND:
@ -552,7 +552,7 @@ static void
reclaimDatalists(void)
{
Datalist* list;
Constant* con;
NCConstant* con;
/* Step 1: free up the constant content of each datalist*/
for(list=alldatalists;list != NULL; list = list->next) {
if(list->data != NULL) { /* avoid multiple free attempts*/

View File

@ -53,8 +53,8 @@ extern unsigned char* makebytestring(char* s, size_t* lenp);
extern int getpadding(int offset, int alignment);
extern Datalist* builddatalist(int initialize);
extern void dlappend(Datalist*, Constant*);
extern Constant builddatasublist(Datalist* dl);
extern void dlappend(Datalist*, NCConstant*);
extern NCConstant builddatasublist(Datalist* dl);
extern void dlextend(Datalist* dl);
extern void dlsetalloc(Datalist* dl, size_t newalloc);
extern void check_err(const int stat, const int line, const char* file);