My Project  debian-1:4.1.1-p2+ds-4
Functions
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.

43 {
44  return sizeof(newstruct_desc_s);
45 }

◆ newstruct_set_proc()

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

Definition at line 859 of file newstruct.cc.

860 {
861  int id=0;
862  blackboxIsCmd(bbname,id);
863  if (id<MAX_TOK)
864  {
865  Werror(">>%s<< is not a newstruct type",bbname);
866  return TRUE;
867  }
868  blackbox *bb=getBlackboxStuff(id);
869  newstruct_desc desc=(newstruct_desc)bb->data;
870  newstruct_proc p=(newstruct_proc)omAlloc(sizeof(*p));
871  p->next=desc->procs; desc->procs=p;
872 
873  idhdl save_ring=currRingHdl;
874  currRingHdl=(idhdl)1; // fake ring detection
875 
876  int tt;
877  if(!(tt=IsCmd(func,p->t)))
878  {
879  int t;
880  if((t=iiOpsTwoChar(func))!=0)
881  {
882  p->t=t;
883  tt=CMD_2; /* ..,::, ==, <=, <>, >= !=i and +,-,*,/,%,.... */
884  if ((t==PLUSPLUS)
885  ||(t==MINUSMINUS)
886  ||(t=='='))
887  tt=CMD_1; /* ++,--,= */
888  else if (t=='(') /* proc call */
889  tt=CMD_M;
890  else if (t=='-') /* unary and binary - */
891  tt=CMD_12;
892  }
893  else
894  {
895  desc->procs=p->next;
896  omFreeSize(p,sizeof(*p));
897  Werror(">>%s<< is not a kernel command",func);
898  currRingHdl = save_ring;
899  return TRUE;
900  }
901  }
902  switch(tt)
903  {
904  // type conversions:
905  case BIGINTMAT_CMD:
906  case MATRIX_CMD:
907  case INTMAT_CMD:
908  case RING_CMD:
909  case RING_DECL:
910  case RING_DECL_LIST:
911  case ROOT_DECL:
912  case ROOT_DECL_LIST:
913  // operations:
914  case CMD_1:
915  if(args!=1) { Warn("args must be 1 in %s",my_yylinebuf);args=1;}
916  break;
917  case CMD_2:
918  if(args!=2) { Warn("args must be 2 in %s",my_yylinebuf);args=2;}
919  break;
920  case CMD_3:
921  if(args!=3) { Warn("args must be 3 in %s",my_yylinebuf);args=3;}
922  break;
923  case CMD_12:
924  if((args!=1)&&(args!=2)) { Werror("args must in 1 or 2 in %s",my_yylinebuf);}
925  break;
926  case CMD_13:
927  if((args!=1)&&(args!=3)) { Werror("args must in 1 or 3 in %s",my_yylinebuf);}
928  break;
929  case CMD_23:
930  if((args<2)||(args>3)) { Werror("args must in 2..3 in %s",my_yylinebuf);}
931  break;
932  case CMD_123:
933  if((args<1)||(args>3)) { Werror("args must in 1..3 in %s",my_yylinebuf);}
934  break;
935  case CMD_M:
936  if(args!=4) { Warn("args must be 4 in %s",my_yylinebuf);args=4;}
937  break;
938  default:
939  Werror("unknown token type %d in %s",tt,my_yylinebuf);
940  break;
941  }
942  currRingHdl = save_ring;
943  if (errorreported)
944  {
945  desc->procs=p->next;
946  omFreeSize(p,sizeof(*p));
947  return TRUE;
948  }
949  p->args=args;
950  p->p=pr; pr->ref++;
951  pr->is_static=0;
952  return FALSE;
953 }

◆ newstruct_setup()

void newstruct_setup ( const char *  name,
newstruct_desc  d 
)

Definition at line 701 of file newstruct.cc.

702 {
703  blackbox *b=(blackbox*)omAlloc0(sizeof(blackbox));
704  // all undefined entries will be set to default in setBlackboxStuff
705  // the default Print is quite useful,
706  // all other are simply error messages
707  b->blackbox_destroy=newstruct_destroy;
708  b->blackbox_String=newstruct_String;
709  b->blackbox_Print=newstruct_Print;//blackbox_default_Print;
710  b->blackbox_Init=newstruct_Init;
711  b->blackbox_Copy=newstruct_Copy;
712  b->blackbox_Assign=newstruct_Assign;
713  b->blackbox_Op1=newstruct_Op1;
714  b->blackbox_Op2=newstruct_Op2;
715  //b->blackbox_Op3=blackboxDefaultOp3;
716  b->blackbox_OpM=newstruct_OpM;
717  b->blackbox_CheckAssign=newstruct_CheckAssign;
718  b->blackbox_serialize=newstruct_serialize;
719  b->blackbox_deserialize=newstruct_deserialize;
720  b->data=d;
721  b->properties=1; // list_like
722  int rt=setBlackboxStuff(b,n);
723  d->id=rt;
724  //Print("create type %d (%s)\n",rt,n);
725 }

◆ newstructChildFromString()

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

Definition at line 812 of file newstruct.cc.

813 {
814  // find parent:
815  int parent_id=0;
816  blackboxIsCmd(parent,parent_id);
817  if (parent_id<MAX_TOK)
818  {
819  Werror(">>%s< not found",parent);
820  return NULL;
821  }
822  blackbox *parent_bb=getBlackboxStuff(parent_id);
823  // check for the correct type:
824  if (parent_bb->blackbox_destroy!=newstruct_destroy)
825  {
826  Werror(">>%s< is not a user defined type",parent);
827  return NULL;
828  }
829  // setup for scanNewstructFromString:
830  newstruct_desc res=(newstruct_desc)omAlloc0(sizeof(*res));
831  newstruct_desc parent_desc=(newstruct_desc)parent_bb->data;
832  res->size=parent_desc->size;
833  res->member=parent_desc->member;
834  res->parent=parent_desc;
835 
836  return scanNewstructFromString(s,res);
837 }

◆ newstructFromString()

newstruct_desc newstructFromString ( const char *  s)

Definition at line 805 of file newstruct.cc.

806 {
807  newstruct_desc res=(newstruct_desc)omAlloc0(sizeof(*res));
808  res->size=0;
809 
810  return scanNewstructFromString(s,res);
811 }

◆ newstructShow()

void newstructShow ( newstruct_desc  d)

Definition at line 839 of file newstruct.cc.

840 {
841  newstruct_member elem;
842  Print("id: %d\n",d->id);
843  elem=d->member;
844  while (elem!=NULL)
845  {
846  Print(">>%s<< at pos %d, type %d (%s)\n",elem->name,elem->pos,elem->typ,Tok2Cmdname(elem->typ));
847  if (RingDependend(elem->typ)|| (elem->typ==DEF_CMD) ||(elem->typ==LIST_CMD))
848  Print(">>r_%s<< at pos %d, shadow ring\n",elem->name,elem->pos-1);
849  elem=elem->next;
850  }
851  newstruct_proc p=d->procs;
852  while (p!=NULL)
853  {
854  Print("op:%d(%s) with %d args -> %s\n",p->t,iiTwoOps(p->t),p->args,p->p->procname);
855  p=p->next;
856  }
857 }
FALSE
#define FALSE
Definition: auxiliary.h:94
newstruct_serialize
BOOLEAN newstruct_serialize(blackbox *b, void *d, si_link f)
Definition: newstruct.cc:607
CMD_M
Definition: grammar.cc:316
errorreported
short errorreported
Definition: feFopen.cc:23
newstruct_deserialize
BOOLEAN newstruct_deserialize(blackbox **, void **d, si_link f)
Definition: newstruct.cc:649
CMD_23
Definition: grammar.cc:314
LIST_CMD
Definition: tok.h:117
CMD_12
Definition: grammar.cc:312
MAX_TOK
Definition: tok.h:214
DEF_CMD
Definition: tok.h:57
BIGINTMAT_CMD
Definition: grammar.cc:278
iiOpsTwoChar
int iiOpsTwoChar(const char *s)
Definition: ipshell.cc:118
idhdl
idrec * idhdl
Definition: ring.h:20
RING_CMD
Definition: grammar.cc:281
b
CanonicalForm b
Definition: cfModGcd.cc:4044
newstruct_Print
void newstruct_Print(blackbox *b, void *d)
Definition: newstruct.cc:672
CMD_3
Definition: grammar.cc:311
currRingHdl
idhdl currRingHdl
Definition: ipid.cc:60
CMD_123
Definition: grammar.cc:315
RingDependend
int RingDependend(int t)
Definition: gentable.cc:28
MATRIX_CMD
Definition: grammar.cc:285
iiTwoOps
const char * iiTwoOps(int t)
Definition: gentable.cc:258
TRUE
#define TRUE
Definition: auxiliary.h:98
res
CanonicalForm res
Definition: facAbsFact.cc:64
omFreeSize
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:258
newstruct_Assign
BOOLEAN newstruct_Assign(leftv l, leftv r)
Definition: newstruct.cc:273
RING_DECL_LIST
Definition: grammar.cc:320
newstruct_Copy
void * newstruct_Copy(blackbox *, void *d)
Definition: newstruct.cc:160
newstruct_Op1
BOOLEAN newstruct_Op1(int op, leftv res, leftv arg)
Definition: newstruct.cc:245
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:192
omAlloc
#define omAlloc(size)
Definition: omAllocDecl.h:208
PLUSPLUS
Definition: grammar.cc:274
my_yylinebuf
char my_yylinebuf[80]
Definition: febase.cc:42
CMD_13
Definition: grammar.cc:313
ROOT_DECL_LIST
Definition: grammar.cc:318
INTMAT_CMD
Definition: grammar.cc:279
idrec
Definition: idrec.h:33
IsCmd
int IsCmd(const char *n, int &tok)
Definition: iparith.cc:8679
newstruct_desc_s
Definition: newstruct.cc:33
CMD_1
Definition: grammar.cc:309
Print
#define Print
Definition: emacs.cc:79
newstruct_CheckAssign
BOOLEAN newstruct_CheckAssign(blackbox *, leftv L, leftv R)
Definition: newstruct.cc:562
Werror
void Werror(const char *fmt,...)
Definition: reporter.cc:188
newstruct_OpM
BOOLEAN newstruct_OpM(int op, leftv res, leftv args)
Definition: newstruct.cc:491
newstruct_Init
void * newstruct_Init(blackbox *b)
Definition: newstruct.cc:541
NULL
#define NULL
Definition: omList.c:9
newstruct_Op2
BOOLEAN newstruct_Op2(int op, leftv res, leftv a1, leftv a2)
Definition: newstruct.cc:330
Warn
#define Warn
Definition: emacs.cc:76
newstruct_destroy
void newstruct_destroy(blackbox *, void *d)
Definition: newstruct.cc:532
p
int p
Definition: cfModGcd.cc:4019
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
newstruct_String
char * newstruct_String(blackbox *b, void *d)
Definition: newstruct.cc:47
Tok2Cmdname
const char * Tok2Cmdname(int tok)
Definition: gentable.cc:137
scanNewstructFromString
static newstruct_desc scanNewstructFromString(const char *s, newstruct_desc res)
Definition: newstruct.cc:727
MINUSMINUS
Definition: grammar.cc:271
getBlackboxStuff
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition: blackbox.cc:16
ROOT_DECL
Definition: grammar.cc:317
omAlloc0
#define omAlloc0(size)
Definition: omAllocDecl.h:209
CMD_2
Definition: grammar.cc:310
RING_DECL
Definition: grammar.cc:319
setBlackboxStuff
int setBlackboxStuff(blackbox *bb, const char *n)
define a new type
Definition: blackbox.cc:126