Loading...
Searching...
No Matches
newstruct.h File Reference

Go to the source code of this file.

## Functions

void | newstruct_setup (const char *name, newstruct_desc d)
int | newstruct_desc_size ()
newstruct_desc | newstructFromString (const char *s)
newstruct_desc | newstructChildFromString (const char *p, const char *s)
BOOLEAN | newstruct_set_proc (const char *name, const char *func, int args, procinfov p)
void | newstructShow (newstruct_desc d)

## Function Documentation

## newstruct_desc_size()

int newstruct_desc_size | ( |  | ) |

Definition at line 42 of file newstruct.cc.

{
return sizeof(newstruct_desc_s);
}
newstruct_desc_s
Definition newstruct.cc:34

## newstruct_set_proc()

BOOLEAN newstruct_set_proc | ( | const char * | name,
|  | const char * | func,
|  | int | args,
|  | procinfov | p )

Definition at line 857 of file newstruct.cc.

{
int id=0;
blackboxIsCmd(bbname,id);
if (id<MAX_TOK)
{
Werror(">>%s<< is not a newstruct type",bbname);
return TRUE;
}
blackbox *bb=getBlackboxStuff(id);
newstruct_desc desc=(newstruct_desc)bb->data;
newstruct_proc p=(newstruct_proc)omAlloc(sizeof(*p));
p->next=desc->procs; desc->procs=p;
idhdl save_ring=currRingHdl;
currRingHdl=(idhdl)1; // fake ring detection
int tt;
if(!(tt=IsCmd(func,p->t)))
{
int t;
if((t=iiOpsTwoChar(func))!=0)
{
p->t=t;
tt=CMD_2; /* ..,::, ==, <=, <>, >= !=i and +,-,*,/,%,.... */
if ((t==PLUSPLUS)
||(t==MINUSMINUS)
||(t=='='))
tt=CMD_1; /* ++,--,= */
else if (t=='(') /* proc call */
tt=CMD_M;
else if (t=='-') /* unary and binary - */
tt=CMD_12;
}
else
{
desc->procs=p->next;
omFreeSize(p,sizeof(*p));
Werror(">>%s<< is not a kernel command",func);
currRingHdl = save_ring;
return TRUE;
}
}
switch(tt)
{
// type conversions:
case BIGINTMAT_CMD:
case MATRIX_CMD:
case INTMAT_CMD:
case RING_CMD:
case RING_DECL:
case ROOT_DECL:
// operations:
case CMD_1:
if(args!=1) { Warn("args must be 1 for %s in %s",func,my_yylinebuf);args=1;}
break;
case CMD_2:
if(args!=2) { Warn("args must be 2 in %s",my_yylinebuf);args=2;}
break;
case CMD_3:
if(args!=3) { Warn("args must be 3 in %s",my_yylinebuf);args=3;}
break;
case CMD_12:
if((args!=1)&&(args!=2)) { Werror("args must in 1 or 2 in %s",my_yylinebuf);}
break;
case CMD_13:
if((args!=1)&&(args!=3)) { Werror("args must in 1 or 3 in %s",my_yylinebuf);}
break;
case CMD_23:
if((args<2)||(args>3)) { Werror("args must in 2..3 in %s",my_yylinebuf);}
break;
case CMD_123:
if((args<1)||(args>3)) { Werror("args must in 1..3 in %s",my_yylinebuf);}
break;
case RING_DECL_LIST:
case ROOT_DECL_LIST:
case CMD_M:
break;
default:
Werror("unknown token type %d in %s",tt,my_yylinebuf);
break;
}
currRingHdl = save_ring;
if (errorreported)
{
desc->procs=p->next;
omFreeSize(p,sizeof(*p));
return TRUE;
}
p->args=args;
p->p=pr; pr->ref++;
pr->is_static=0;
return FALSE;
}
TRUE
#define TRUE
Definition auxiliary.h:101
FALSE
#define FALSE
Definition auxiliary.h:97
getBlackboxStuff
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition blackbox.cc:17
blackboxIsCmd
int blackboxIsCmd(const char *n, int &tok)
used by scanner: returns ROOT_DECL for known types (and the type number in tok)
Definition blackbox.cc:219
p
int p
Definition cfModGcd.cc:4086
Warn
#define Warn
Definition emacs.cc:77
errorreported
VAR short errorreported
Definition feFopen.cc:23
my_yylinebuf
VAR char my_yylinebuf[80]
Definition febase.cc:44
CMD_1
@ CMD_1
Definition grammar.cc:312
PLUSPLUS
@ PLUSPLUS
Definition grammar.cc:274
MINUSMINUS
@ MINUSMINUS
Definition grammar.cc:271
CMD_23
@ CMD_23
Definition grammar.cc:317
CMD_2
@ CMD_2
Definition grammar.cc:313
MATRIX_CMD
@ MATRIX_CMD
Definition grammar.cc:287
RING_DECL
@ RING_DECL
Definition grammar.cc:322
RING_DECL_LIST
@ RING_DECL_LIST
Definition grammar.cc:323
BIGINTMAT_CMD
@ BIGINTMAT_CMD
Definition grammar.cc:278
CMD_3
@ CMD_3
Definition grammar.cc:314
ROOT_DECL
@ ROOT_DECL
Definition grammar.cc:320
INTMAT_CMD
@ INTMAT_CMD
Definition grammar.cc:280
ROOT_DECL_LIST
@ ROOT_DECL_LIST
Definition grammar.cc:321
CMD_123
@ CMD_123
Definition grammar.cc:318
CMD_12
@ CMD_12
Definition grammar.cc:315
CMD_13
@ CMD_13
Definition grammar.cc:316
CMD_M
@ CMD_M
Definition grammar.cc:319
RING_CMD
@ RING_CMD
Definition grammar.cc:282
IsCmd
int IsCmd(const char *n, int &tok)
Definition iparith.cc:9773
currRingHdl
VAR idhdl currRingHdl
Definition ipid.cc:57
iiOpsTwoChar
int iiOpsTwoChar(const char *s)
Definition ipshell.cc:122
omFreeSize
#define omFreeSize(addr, size)
Definition omAllocDecl.h:260
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210
Werror
void Werror(const char *fmt,...)
Definition reporter.cc:189
idhdl
idrec * idhdl
Definition ring.h:22
MAX_TOK
@ MAX_TOK
Definition tok.h:220

## newstruct_setup()

void newstruct_setup | ( | const char * | name,
|  | newstruct_desc | d )

Definition at line 699 of file newstruct.cc.

{
blackbox *b=(blackbox*)omAlloc0(sizeof(blackbox));
// all undefined entries will be set to default in setBlackboxStuff
// the default Print is quite useful,
// all other are simply error messages
b->blackbox_destroy=newstruct_destroy;
b->blackbox_String=newstruct_String;
b->blackbox_Print=newstruct_Print;//blackbox_default_Print;
b->blackbox_Init=newstruct_Init;
b->blackbox_Copy=newstruct_Copy;
b->blackbox_Assign=newstruct_Assign;
b->blackbox_Op1=newstruct_Op1;
b->blackbox_Op2=newstruct_Op2;
//b->blackbox_Op3=blackboxDefaultOp3;
b->blackbox_OpM=newstruct_OpM;
b->blackbox_CheckAssign=newstruct_CheckAssign;
b->blackbox_serialize=newstruct_serialize;
b->blackbox_deserialize=newstruct_deserialize;
b->data=d;
b->properties=1; // list_like
int rt=setBlackboxStuff(b,n);
d->id=rt;
//Print("create type %d (%s)\n",rt,n);
}
setBlackboxStuff
int setBlackboxStuff(blackbox *bb, const char *n)
define a new type
Definition blackbox.cc:143
b
CanonicalForm b
Definition cfModGcd.cc:4111
newstruct_Op2
BOOLEAN newstruct_Op2(int op, leftv res, leftv a1, leftv a2)
Definition newstruct.cc:344
newstruct_deserialize
BOOLEAN newstruct_deserialize(blackbox **, void **d, si_link f)
Definition newstruct.cc:644
newstruct_destroy
void newstruct_destroy(blackbox *, void *d)
Definition newstruct.cc:527
newstruct_String
char * newstruct_String(blackbox *b, void *d)
Definition newstruct.cc:50
newstruct_Op1
BOOLEAN newstruct_Op1(int op, leftv res, leftv arg)
Definition newstruct.cc:259
newstruct_Assign
BOOLEAN newstruct_Assign(leftv l, leftv r)
Definition newstruct.cc:287
newstruct_serialize
BOOLEAN newstruct_serialize(blackbox *b, void *d, si_link f)
Definition newstruct.cc:602
newstruct_Copy
void * newstruct_Copy(blackbox *, void *d)
Definition newstruct.cc:175
newstruct_Init
void * newstruct_Init(blackbox *b)
Definition newstruct.cc:536
newstruct_OpM
BOOLEAN newstruct_OpM(int op, leftv res, leftv args)
Definition newstruct.cc:486
newstruct_CheckAssign
BOOLEAN newstruct_CheckAssign(blackbox *, leftv L, leftv R)
Definition newstruct.cc:557
newstruct_Print
void newstruct_Print(blackbox *b, void *d)
Definition newstruct.cc:670
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211

## newstructChildFromString()

newstruct_desc newstructChildFromString | ( | const char * | p,
|  | const char * | s )

Definition at line 810 of file newstruct.cc.

{
// find parent:
int parent_id=0;
blackboxIsCmd(parent,parent_id);
if (parent_id<MAX_TOK)
{
Werror(">>%s< not found",parent);
return NULL;
}
blackbox *parent_bb=getBlackboxStuff(parent_id);
// check for the correct type:
if (parent_bb->blackbox_destroy!=newstruct_destroy)
{
Werror(">>%s< is not a user defined type",parent);
return NULL;
}
// setup for scanNewstructFromString:
newstruct_desc res=(newstruct_desc)omAlloc0(sizeof(*res));
newstruct_desc parent_desc=(newstruct_desc)parent_bb->data;
res->size=parent_desc->size;
res->member=parent_desc->member;
res->parent=parent_desc;
return scanNewstructFromString(s,res);
}
s
const CanonicalForm int s
Definition facAbsFact.cc:51
res
CanonicalForm res
Definition facAbsFact.cc:60
scanNewstructFromString
static newstruct_desc scanNewstructFromString(const char *s, newstruct_desc res)
Definition newstruct.cc:725
NULL
#define NULL
Definition omList.c:12

## newstructFromString()

newstruct_desc newstructFromString | ( | const char * | s | ) |

Definition at line 803 of file newstruct.cc.

{
newstruct_desc res=(newstruct_desc)omAlloc0(sizeof(*res));
res->size=0;
return scanNewstructFromString(s,res);
}

## newstructShow()

void newstructShow | ( | newstruct_desc | d | ) |

Definition at line 837 of file newstruct.cc.

{
newstruct_member elem;
Print("id: %d\n",d->id);
elem=d->member;
while (elem!=NULL)
{
Print(">>%s<< at pos %d, type %d (%s)\n",elem->name,elem->pos,elem->typ,Tok2Cmdname(elem->typ));
if (NeedShadowRing(elem->typ))
Print(">>r_%s<< at pos %d, shadow ring\n",elem->name,elem->pos-1);
elem=elem->next;
}
newstruct_proc p=d->procs;
while (p!=NULL)
{
Print("op:%d(%s) with %d args -> %s\n",p->t,iiTwoOps(p->t),p->args,p->p->procname);
p=p->next;
}
}
Print
#define Print
Definition emacs.cc:80
iiTwoOps
const char * iiTwoOps(int t)
Definition gentable.cc:258
Tok2Cmdname
const char * Tok2Cmdname(int tok)
Definition gentable.cc:137
NeedShadowRing
static int NeedShadowRing(int t)
Definition newstruct.cc:46