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

int newstruct_desc_size ( )

Definition at line 41 of file newstruct.cc.

42 {
43  return sizeof(newstruct_desc_s);
44 }
BOOLEAN newstruct_set_proc ( const char *  name,
const char *  func,
int  args,
procinfov  p 
)

Definition at line 840 of file newstruct.cc.

841 {
842  int id=0;
843  blackboxIsCmd(bbname,id);
844  if (id<MAX_TOK)
845  {
846  Werror(">>%s<< is not a newstruct type",bbname);
847  return TRUE;
848  }
849  blackbox *bb=getBlackboxStuff(id);
850  newstruct_desc desc=(newstruct_desc)bb->data;
851  newstruct_proc p=(newstruct_proc)omAlloc(sizeof(*p));
852  p->next=desc->procs; desc->procs=p;
853 
854  idhdl save_ring=currRingHdl;
855  currRingHdl=(idhdl)1; // fake ring detection
856 
857  if(!IsCmd(func,p->t))
858  {
859  int t=0;
860  if (func[1]=='\0') p->t=func[0];
861  else if((t=iiOpsTwoChar(func))!=0)
862  {
863  p->t=t;
864  }
865  else
866  {
867  Werror(">>%s<< is not a kernel command",func);
868  currRingHdl = save_ring;
869  return TRUE;
870  }
871  }
872  p->args=args;
873  p->p=pr; pr->ref++;
874  pr->is_static=0;
875  currRingHdl = save_ring;
876  return FALSE;
877 }
#define FALSE
Definition: auxiliary.h:140
return P p
Definition: myNF.cc:203
Definition: tok.h:167
#define TRUE
Definition: auxiliary.h:144
short ref
Definition: subexpr.h:59
#define omAlloc(size)
Definition: omAllocDecl.h:210
Definition: idrec.h:34
idhdl currRingHdl
Definition: ipid.cc:64
idrec * idhdl
Definition: ring.h:18
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:191
int iiOpsTwoChar(const char *s)
Definition: ipshell.cc:123
void Werror(const char *fmt,...)
Definition: reporter.cc:199
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition: blackbox.cc:20
int IsCmd(const char *n, int &tok)
Definition: iparith.cc:8688
void newstruct_setup ( const char *  name,
newstruct_desc  d 
)

Definition at line 683 of file newstruct.cc.

684 {
685  blackbox *b=(blackbox*)omAlloc0(sizeof(blackbox));
686  // all undefined entries will be set to default in setBlackboxStuff
687  // the default Print is quite useful,
688  // all other are simply error messages
689  b->blackbox_destroy=newstruct_destroy;
690  b->blackbox_String=newstruct_String;
691  b->blackbox_Print=newstruct_Print;//blackbox_default_Print;
692  b->blackbox_Init=newstruct_Init;
693  b->blackbox_Copy=newstruct_Copy;
694  b->blackbox_Assign=newstruct_Assign;
695  b->blackbox_Op1=newstruct_Op1;
696  b->blackbox_Op2=newstruct_Op2;
697  //b->blackbox_Op3=blackboxDefaultOp3;
698  b->blackbox_OpM=newstruct_OpM;
699  b->blackbox_CheckAssign=newstruct_CheckAssign;
700  b->blackbox_serialize=newstruct_serialize;
701  b->blackbox_deserialize=newstruct_deserialize;
702  b->data=d;
703  b->properties=1; // list_like
704  int rt=setBlackboxStuff(b,n);
705  d->id=rt;
706  //Print("create type %d (%s)\n",rt,n);
707 }
BOOLEAN newstruct_deserialize(blackbox **b, void **d, si_link f)
Definition: newstruct.cc:631
BOOLEAN newstruct_Op1(int op, leftv res, leftv arg)
Definition: newstruct.cc:292
void newstruct_destroy(blackbox *, void *d)
Definition: newstruct.cc:519
BOOLEAN newstruct_OpM(int op, leftv res, leftv args)
Definition: newstruct.cc:476
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
BOOLEAN newstruct_Op2(int op, leftv res, leftv a1, leftv a2)
Definition: newstruct.cc:326
void * newstruct_Init(blackbox *b)
Definition: newstruct.cc:528
BOOLEAN newstruct_serialize(blackbox *b, void *d, si_link f)
Definition: newstruct.cc:590
BOOLEAN newstruct_Assign(leftv l, leftv r)
Definition: newstruct.cc:224
char * newstruct_String(blackbox *b, void *d)
Definition: newstruct.cc:46
void * newstruct_Copy(blackbox *, void *d)
Definition: newstruct.cc:161
int setBlackboxStuff(blackbox *bb, const char *n)
define a new type
Definition: blackbox.cc:126
const poly b
Definition: syzextra.cc:213
void newstruct_Print(blackbox *b, void *d)
Definition: newstruct.cc:654
#define omAlloc0(size)
Definition: omAllocDecl.h:211
BOOLEAN newstruct_CheckAssign(blackbox *, leftv L, leftv R)
Definition: newstruct.cc:545
newstruct_desc newstructChildFromString ( const char *  p,
const char *  s 
)

Definition at line 793 of file newstruct.cc.

794 {
795  // find parent:
796  int parent_id=0;
797  blackboxIsCmd(parent,parent_id);
798  if (parent_id<MAX_TOK)
799  {
800  Werror(">>%s< not found",parent);
801  return NULL;
802  }
803  blackbox *parent_bb=getBlackboxStuff(parent_id);
804  // check for the correct type:
805  if (parent_bb->blackbox_destroy!=newstruct_destroy)
806  {
807  Werror(">>%s< is not a user defined type",parent);
808  return NULL;
809  }
810  // setup for scanNewstructFromString:
811  newstruct_desc res=(newstruct_desc)omAlloc0(sizeof(*res));
812  newstruct_desc parent_desc=(newstruct_desc)parent_bb->data;
813  res->size=parent_desc->size;
814  res->member=parent_desc->member;
815  res->parent=parent_desc;
816 
817  return scanNewstructFromString(s,res);
818 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
void newstruct_destroy(blackbox *, void *d)
Definition: newstruct.cc:519
Definition: tok.h:167
poly res
Definition: myNF.cc:322
#define NULL
Definition: omList.c:10
static newstruct_desc scanNewstructFromString(const char *s, newstruct_desc res)
Definition: newstruct.cc:709
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:191
void Werror(const char *fmt,...)
Definition: reporter.cc:199
#define omAlloc0(size)
Definition: omAllocDecl.h:211
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition: blackbox.cc:20
newstruct_desc newstructFromString ( const char *  s)

Definition at line 786 of file newstruct.cc.

787 {
788  newstruct_desc res=(newstruct_desc)omAlloc0(sizeof(*res));
789  res->size=0;
790 
791  return scanNewstructFromString(s,res);
792 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
poly res
Definition: myNF.cc:322
static newstruct_desc scanNewstructFromString(const char *s, newstruct_desc res)
Definition: newstruct.cc:709
#define omAlloc0(size)
Definition: omAllocDecl.h:211
void newstructShow ( newstruct_desc  d)

Definition at line 820 of file newstruct.cc.

821 {
822  newstruct_member elem;
823  Print("id: %d\n",d->id);
824  elem=d->member;
825  while (elem!=NULL)
826  {
827  Print(">>%s<< at pos %d, type %d (%s)\n",elem->name,elem->pos,elem->typ,Tok2Cmdname(elem->typ));
828  if (RingDependend(elem->typ)|| (elem->typ==DEF_CMD) ||(elem->typ==LIST_CMD))
829  Print(">>r_%s<< at pos %d, shadow ring\n",elem->name,elem->pos-1);
830  elem=elem->next;
831  }
832  newstruct_proc p=d->procs;
833  while (p!=NULL)
834  {
835  Print("op:%d(%s) with %d args -> %s\n",p->t,iiTwoOps(p->t),p->args,p->p->procname);
836  p=p->next;
837  }
838 }
#define Print
Definition: emacs.cc:83
return P p
Definition: myNF.cc:203
int RingDependend(int t)
Definition: gentable.cc:23
const char * iiTwoOps(int t)
Definition: gentable.cc:250
Definition: tok.h:58
#define NULL
Definition: omList.c:10
const char * Tok2Cmdname(int tok)
Definition: gentable.cc:128
Definition: tok.h:96