Adding handling of simple generics in genlib
This commit is contained in:
parent
373a87ee1c
commit
8533d03c59
|
@ -96,10 +96,7 @@ int bus_decod();
|
|||
* physical user functions *
|
||||
*******************************************************************************/
|
||||
|
||||
static chain_list *g_addphvia(p, type, x, y, dx, dy, name)
|
||||
phfig_list *p;
|
||||
char type, *name;
|
||||
long x, y, dx, dy;
|
||||
static chain_list *g_addphvia( phfig_list *p, char type, long x, long y, long dx, long dy, char *name)
|
||||
{
|
||||
chain_list *c = NULL;
|
||||
|
||||
|
@ -2716,7 +2713,7 @@ va_list arg;
|
|||
char *figname, *signame;
|
||||
lofig_list *ptfig;
|
||||
|
||||
va_start(arg, instance);
|
||||
va_start(arg, insname);
|
||||
figname = namealloc(va_arg(arg, char *));
|
||||
if (WORK_LOFIG == NULL) {
|
||||
(void)fflush(stdout);
|
||||
|
@ -3454,9 +3451,17 @@ void genLOGEN(char *name, int type)
|
|||
ptype_list *p = getptype(WORK_LOFIG->USER, LOGEN);
|
||||
|
||||
if (!p)
|
||||
p = addptype(WORK_LOFIG->USER, LOGEN, NULL);
|
||||
p = WORK_LOFIG->USER = addptype(WORK_LOFIG->USER, LOGEN, NULL);
|
||||
|
||||
p->DATA = addlogen(name, type);
|
||||
p->DATA = addlogen(p->DATA, name);
|
||||
|
||||
if (type != INTEGER_GEN && type != STRING_GEN) {
|
||||
(void)fflush(stdout);
|
||||
(void)fputs("*** genlib error ***\n", stderr);
|
||||
(void)fprintf(stderr, "Illegal SETLOGEN: unsupported generic type\n");
|
||||
EXIT(1);
|
||||
}
|
||||
((logen_list *)p->DATA)->TYPE = type;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -3465,16 +3470,63 @@ ptype_list *p = getptype(WORK_LOFIG->USER, LOGEN);
|
|||
void genSETLOGEN(char *instance, char *name, ...)
|
||||
{
|
||||
va_list ap; /* We have a single argument, but of unknown type yet! */
|
||||
lofig_list *f = getlofig();
|
||||
loins_list *i = getloins(WORK_LOFIG, instance);
|
||||
lofig_list *f;
|
||||
ptype_list *p;
|
||||
logen_list *g;
|
||||
char *s, *t;
|
||||
|
||||
if (!i) {
|
||||
(void)fflush(stdout);
|
||||
(void)fputs("*** genlib error ***\n", stderr);
|
||||
(void)fprintf(stderr, "Illegal SETLOGEN : no instance called '%s' \n",
|
||||
instance);
|
||||
EXIT(1);
|
||||
}
|
||||
|
||||
f = getlofig(i->FIGNAME, 'P');
|
||||
p = getptype(f->USER, LOGEN);
|
||||
if (!p) {
|
||||
(void)fflush(stdout);
|
||||
(void)fputs("*** genlib error ***\n", stderr);
|
||||
(void)fprintf(stderr, "Illegal SETLOGEN : no logen in model '%s' \n",
|
||||
i->FIGNAME);
|
||||
EXIT(1);
|
||||
}
|
||||
g = getlogen(p->DATA, name);
|
||||
if (!g) {
|
||||
(void)fflush(stdout);
|
||||
(void)fputs("*** genlib error ***\n", stderr);
|
||||
(void)fprintf(stderr, "Illegal SETLOGEN : no generic called '%s' \n",
|
||||
name);
|
||||
EXIT(1);
|
||||
}
|
||||
|
||||
va_start(ap, name);
|
||||
|
||||
ptype_list *p = getptype(WORK_LOFIG->USER, LOGEN);
|
||||
p = getptype(i->USER, LOGEN);
|
||||
if (!p)
|
||||
p = addptype(WORK_LOFIG->USER, LOGEN, NULL);
|
||||
|
||||
p->DATA = addlogen(name, type);
|
||||
p = i->USER = addptype(i->USER, LOGEN, NULL);
|
||||
p->DATA = addlogen(p->DATA, name);
|
||||
switch (g->TYPE) {
|
||||
case INTEGER_GEN:
|
||||
((logen_list *)p->DATA)->TYPE = INTEGER_GEN;
|
||||
((logen_list *)p->DATA)->VALUE.VAL = va_arg(ap, long);
|
||||
break;
|
||||
case STRING_GEN:
|
||||
((logen_list *)p->DATA)->TYPE = STRING_GEN;
|
||||
s = va_arg(ap, char *);
|
||||
t = malloc((strlen(s) + 3) * sizeof(char));
|
||||
sprintf(t, "\"%s\"", s);
|
||||
((logen_list *)p->DATA)->VALUE.TEXT = namealloc(t);
|
||||
free(t);
|
||||
break;
|
||||
default:
|
||||
(void)fflush(stdout);
|
||||
(void)fputs("*** genlib error ***\n", stderr);
|
||||
(void)fprintf(stderr, "Illegal SETLOGEN: unsupported generic type\n");
|
||||
EXIT(1);
|
||||
}
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -3539,11 +3591,10 @@ losig_list *s;
|
|||
/*******************************************************************************
|
||||
* function UNFLATTEN_LOFIG *
|
||||
*******************************************************************************/
|
||||
void genUNFLATTEN_LOFIG(va_alist)
|
||||
va_dcl
|
||||
void genUNFLATTEN_LOFIG(char *modelname, ...)
|
||||
{
|
||||
va_list instancelist;
|
||||
char *modelname, *instancename, *iname;
|
||||
char *instancename, *iname;
|
||||
chain_list *ilist = NULL;
|
||||
|
||||
if (WORK_LOFIG == NULL) {
|
||||
|
@ -3552,8 +3603,8 @@ chain_list *ilist = NULL;
|
|||
(void)fputs("Illegal UNFLATTEN_LOFIG : missing DEF_LOFIG\n", stderr);
|
||||
EXIT(1);
|
||||
}
|
||||
va_start(instancelist);
|
||||
if ((modelname = va_arg(instancelist, char *)) == NULL) {
|
||||
va_start(instancelist, modelname);
|
||||
if (modelname == NULL) {
|
||||
(void)fflush(stdout);
|
||||
(void)fputs("*** genlib error ***\n", stderr);
|
||||
(void)fputs("Illegal UNFLATTEN_LOFIG : missing arguments\n", stderr);
|
||||
|
@ -3913,17 +3964,15 @@ chain_list *c, *loname = NULL, *phname = NULL;
|
|||
/*******************************************************************************
|
||||
* function NAME *
|
||||
*******************************************************************************/
|
||||
char *genNAME(va_alist)
|
||||
va_dcl
|
||||
char *genNAME(char *p, ...)
|
||||
{
|
||||
va_list stack;
|
||||
char *ret, *res, *p;
|
||||
char *ret, *res;
|
||||
long strsize = 0;
|
||||
char piece[BUFSIZ], *s;
|
||||
long d;
|
||||
|
||||
va_start(stack);
|
||||
p = va_arg(stack, char *);
|
||||
va_start(stack, p);
|
||||
ret = res = (char *)mbkalloc(BUFSIZ);
|
||||
while (*p != '\0') {
|
||||
if (*p != '%') {
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
# with the GNU C Library; see the file COPYING. If not, write to the Free
|
||||
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#
|
||||
# $Id: genlib.sh,v 1.1 2002/03/08 14:08:11 fred Exp $
|
||||
# $Id: genlib.sh,v 1.2 2002/04/16 07:18:31 fred Exp $
|
||||
|
||||
help() {
|
||||
echo "Syntax: `basename $0` [-vk] source-file (without extension)"
|
||||
|
@ -65,7 +65,13 @@ help() {
|
|||
done
|
||||
trap "rm -f ./*.$$; exit 1" 1 2 3 6
|
||||
|
||||
alcbanner "GenLib" "3.3" "Procedural Generation Language" "1991"
|
||||
ALLIANCE_LIB=${ALLIANCE_TOP}/lib
|
||||
ALLIANCE_INCLUDE=${ALLIANCE_TOP}/include
|
||||
ALLIANCE_BIN=${ALLIANCE_TOP}/bin
|
||||
|
||||
export ALLIANCE_LIB ALLIANCE_INCLUDE ALLIANCE_BIN
|
||||
|
||||
${ALLIANCE_BIN}/alcbanner "GenLib" "3.3" "Procedural Generation Language" "1991"
|
||||
|
||||
if [ -z "$name" ] ; then
|
||||
help
|
||||
|
@ -74,6 +80,8 @@ help() {
|
|||
echo "There seems no to be a file called $name.c"
|
||||
help
|
||||
fi
|
||||
|
||||
rm -f $name > /dev/null 2>&1
|
||||
|
||||
if [ $talk -eq 1 ]; then
|
||||
echo "Generating the Makefile";
|
||||
|
@ -84,21 +92,17 @@ help() {
|
|||
# --------------------------------------------------------------------
|
||||
# Development hacks.
|
||||
|
||||
if [ $devel -eq 1 ]; then
|
||||
ALLIANCE_INSTALL_DIR="__ALLIANCE_INSTALL_DIR__"
|
||||
ALLIANCE_DEVEL_INCLUDE="-I${ALLIANCE_INSTALL_DIR}/include"
|
||||
ALLIANCE_DEVEL_LIB="-L${ALLIANCE_INSTALL_DIR}/lib"
|
||||
ALLIANCE_LIB=${ALLIANCE_TOP}/lib
|
||||
ALLIANCE_INCLUDE=${ALLIANCE_TOP}/include
|
||||
fi
|
||||
|
||||
if [ $devel -eq 1 ]; then
|
||||
ALLIANCE_INSTALL_DIR="__ALLIANCE_INSTALL_DIR__"
|
||||
ALLIANCE_DEVEL_INCLUDE="-I${ALLIANCE_INSTALL_DIR}/include"
|
||||
ALLIANCE_DEVEL_LIB="-L${ALLIANCE_INSTALL_DIR}/lib"
|
||||
export ALLIANCE_INSTALL_DIR ALLIANCE_DEVEL_INCLUDE ALLIANCE_DEVEL_LIB
|
||||
fi
|
||||
|
||||
makefile="Makefile.$$"
|
||||
echo 'include $(ALLIANCE_TOP)/etc/libraries.mk' > $makefile
|
||||
echo 'include $(ALLIANCE_TOP)/etc/$(ALLIANCE_OS).mk' >> $makefile
|
||||
echo 'ALLIANCE_LIBRARY = '${ALLIANCE_DEVEL_LIB}' -L$(ALLIANCE_LIB) \
|
||||
-lMgn -lMlu -lMpu -lMcp -lMap -lMmg -lMcl -lMgl \
|
||||
-lMal -lMvl -lMel -lMsl -lMhl -lMlo -lMph -lMut -lRcn' >> $makefile
|
||||
-lMal -lMvg -lMel -lMsl -lMhl -lMlo -lMph -lMut -lRcn' >> $makefile
|
||||
|
||||
echo "ALLIANCE_INC = ${ALLIANCE_DEVEL_INCLUDE} -I\$(ALLIANCE_INCLUDE)" >> $makefile
|
||||
echo "$name : $name.c" >> $makefile
|
||||
|
@ -115,7 +119,8 @@ help() {
|
|||
if [ ! $? -eq 0 ]; then
|
||||
echo "Compilation failed!"
|
||||
cat $name.grr
|
||||
exit 1
|
||||
rm $makefile
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $talk -eq 1 ] ; then
|
||||
|
|
|
@ -91,8 +91,8 @@ extern void genOUTLINE();
|
|||
extern void genDEF_LOFIG();
|
||||
extern void genLOAD_LOFIG();
|
||||
extern void genSAVE_LOFIG();
|
||||
extern void genLOINS();
|
||||
extern void genLOINSE();
|
||||
extern void genLOINS(char *, ...);
|
||||
extern void genLOINSE(char *, ...);
|
||||
extern void genLOINSA();
|
||||
extern void genLOTRS();
|
||||
extern void genLOCON();
|
||||
|
@ -109,13 +109,13 @@ extern void genSC_BOTTOM();
|
|||
extern void genSC_CHANNEL();
|
||||
extern void genSC_CON_CHANNEL();
|
||||
extern void genLOGEN();
|
||||
extern void genSETLOGEN();
|
||||
extern void genSETLOGEN(char *, char *, ...);
|
||||
/*******************************************************************************
|
||||
* name forming functions, for both views *
|
||||
*******************************************************************************/
|
||||
extern char *genBUS();
|
||||
extern char *genELM();
|
||||
extern char *genNAME();
|
||||
extern char *genNAME(char *, ...);
|
||||
|
||||
/*******************************************************************************
|
||||
* macro definitions for allowed stdlib functions *
|
||||
|
|
Loading…
Reference in New Issue