My Project  debian-1:4.1.1-p2+ds-4build4
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 }
#define TRUE
Definition: auxiliary.h:98
#define FALSE
Definition: auxiliary.h:94
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition: blackbox.cc:16
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
int p
Definition: cfModGcd.cc:4019
Definition: idrec.h:35
#define Warn
Definition: emacs.cc:77
short errorreported
Definition: feFopen.cc:23
char my_yylinebuf[80]
Definition: febase.cc:43
@ CMD_1
Definition: grammar.cc:309
@ PLUSPLUS
Definition: grammar.cc:274
@ MINUSMINUS
Definition: grammar.cc:271
@ CMD_23
Definition: grammar.cc:314
@ CMD_2
Definition: grammar.cc:310
@ MATRIX_CMD
Definition: grammar.cc:285
@ RING_DECL
Definition: grammar.cc:319
@ RING_DECL_LIST
Definition: grammar.cc:320
@ BIGINTMAT_CMD
Definition: grammar.cc:278
@ CMD_3
Definition: grammar.cc:311
@ ROOT_DECL
Definition: grammar.cc:317
@ INTMAT_CMD
Definition: grammar.cc:279
@ ROOT_DECL_LIST
Definition: grammar.cc:318
@ CMD_123
Definition: grammar.cc:315
@ CMD_12
Definition: grammar.cc:312
@ CMD_13
Definition: grammar.cc:313
@ CMD_M
Definition: grammar.cc:316
@ RING_CMD
Definition: grammar.cc:281
int IsCmd(const char *n, int &tok)
Definition: iparith.cc:8679
idhdl currRingHdl
Definition: ipid.cc:61
int iiOpsTwoChar(const char *s)
Definition: ipshell.cc:119
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc(size)
Definition: omAllocDecl.h:210
void Werror(const char *fmt,...)
Definition: reporter.cc:189
idrec * idhdl
Definition: ring.h:21
@ MAX_TOK
Definition: tok.h:215

◆ 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 }
int setBlackboxStuff(blackbox *bb, const char *n)
define a new type
Definition: blackbox.cc:126
CanonicalForm b
Definition: cfModGcd.cc:4044
void * newstruct_Copy(blackbox *, void *d)
Definition: newstruct.cc:160
BOOLEAN newstruct_Op2(int op, leftv res, leftv a1, leftv a2)
Definition: newstruct.cc:330
char * newstruct_String(blackbox *b, void *d)
Definition: newstruct.cc:47
BOOLEAN newstruct_deserialize(blackbox **, void **d, si_link f)
Definition: newstruct.cc:649
void newstruct_destroy(blackbox *, void *d)
Definition: newstruct.cc:532
BOOLEAN newstruct_Op1(int op, leftv res, leftv arg)
Definition: newstruct.cc:245
BOOLEAN newstruct_Assign(leftv l, leftv r)
Definition: newstruct.cc:273
BOOLEAN newstruct_serialize(blackbox *b, void *d, si_link f)
Definition: newstruct.cc:607
BOOLEAN newstruct_OpM(int op, leftv res, leftv args)
Definition: newstruct.cc:491
BOOLEAN newstruct_CheckAssign(blackbox *, leftv L, leftv R)
Definition: newstruct.cc:562
void newstruct_Print(blackbox *b, void *d)
Definition: newstruct.cc:672
void * newstruct_Init(blackbox *b)
Definition: newstruct.cc:541
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ 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 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
CanonicalForm res
Definition: facAbsFact.cc:64
static newstruct_desc scanNewstructFromString(const char *s, newstruct_desc res)
Definition: newstruct.cc:727
#define NULL
Definition: omList.c:10

◆ 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 }
#define Print
Definition: emacs.cc:80
const char * Tok2Cmdname(int tok)
Definition: gentable.cc:138
int RingDependend(int t)
Definition: gentable.cc:29
const char * iiTwoOps(int t)
Definition: gentable.cc:259
@ LIST_CMD
Definition: tok.h:118
@ DEF_CMD
Definition: tok.h:58