My Project
Loading...
Searching...
No Matches
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 846 of file newstruct.cc.

847{
848 int id=0;
849 blackboxIsCmd(bbname,id);
850 if (id<MAX_TOK)
851 {
852 Werror(">>%s<< is not a newstruct type",bbname);
853 return TRUE;
854 }
855 blackbox *bb=getBlackboxStuff(id);
856 newstruct_desc desc=(newstruct_desc)bb->data;
857 newstruct_proc p=(newstruct_proc)omAlloc(sizeof(*p));
858 p->next=desc->procs; desc->procs=p;
859
860 idhdl save_ring=currRingHdl;
861 currRingHdl=(idhdl)1; // fake ring detection
862
863 int tt;
864 if(!(tt=IsCmd(func,p->t)))
865 {
866 int t;
867 if((t=iiOpsTwoChar(func))!=0)
868 {
869 p->t=t;
870 tt=CMD_2; /* ..,::, ==, <=, <>, >= !=i and +,-,*,/,%,.... */
871 if ((t==PLUSPLUS)
872 ||(t==MINUSMINUS)
873 ||(t=='='))
874 tt=CMD_1; /* ++,--,= */
875 else if (t=='(') /* proc call */
876 tt=CMD_M;
877 else if (t=='-') /* unary and binary - */
878 tt=CMD_12;
879 }
880 else
881 {
882 desc->procs=p->next;
883 omFreeSize(p,sizeof(*p));
884 Werror(">>%s<< is not a kernel command",func);
885 currRingHdl = save_ring;
886 return TRUE;
887 }
888 }
889 switch(tt)
890 {
891 // type conversions:
892 case BIGINTMAT_CMD:
893 case MATRIX_CMD:
894 case INTMAT_CMD:
895 case RING_CMD:
896 case RING_DECL:
897 case ROOT_DECL:
898 // operations:
899 case CMD_1:
900 if(args!=1) { Warn("args must be 1 for %s in %s",func,my_yylinebuf);args=1;}
901 break;
902 case CMD_2:
903 if(args!=2) { Warn("args must be 2 in %s",my_yylinebuf);args=2;}
904 break;
905 case CMD_3:
906 if(args!=3) { Warn("args must be 3 in %s",my_yylinebuf);args=3;}
907 break;
908 case CMD_12:
909 if((args!=1)&&(args!=2)) { Werror("args must in 1 or 2 in %s",my_yylinebuf);}
910 break;
911 case CMD_13:
912 if((args!=1)&&(args!=3)) { Werror("args must in 1 or 3 in %s",my_yylinebuf);}
913 break;
914 case CMD_23:
915 if((args<2)||(args>3)) { Werror("args must in 2..3 in %s",my_yylinebuf);}
916 break;
917 case CMD_123:
918 if((args<1)||(args>3)) { Werror("args must in 1..3 in %s",my_yylinebuf);}
919 break;
920 case RING_DECL_LIST:
921 case ROOT_DECL_LIST:
922 case CMD_M:
923 break;
924 default:
925 Werror("unknown token type %d in %s",tt,my_yylinebuf);
926 break;
927 }
928 currRingHdl = save_ring;
929 if (errorreported)
930 {
931 desc->procs=p->next;
932 omFreeSize(p,sizeof(*p));
933 return TRUE;
934 }
935 p->args=args;
936 p->p=pr; pr->ref++;
937 pr->is_static=0;
938 return FALSE;
939}
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition: blackbox.cc:17
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:218
int p
Definition: cfModGcd.cc:4078
Definition: idrec.h:35
#define Warn
Definition: emacs.cc:77
VAR short errorreported
Definition: feFopen.cc:23
VAR char my_yylinebuf[80]
Definition: febase.cc:44
@ CMD_1
Definition: grammar.cc:311
@ PLUSPLUS
Definition: grammar.cc:274
@ MINUSMINUS
Definition: grammar.cc:271
@ CMD_23
Definition: grammar.cc:316
@ CMD_2
Definition: grammar.cc:312
@ MATRIX_CMD
Definition: grammar.cc:286
@ RING_DECL
Definition: grammar.cc:321
@ RING_DECL_LIST
Definition: grammar.cc:322
@ BIGINTMAT_CMD
Definition: grammar.cc:278
@ CMD_3
Definition: grammar.cc:313
@ ROOT_DECL
Definition: grammar.cc:319
@ INTMAT_CMD
Definition: grammar.cc:279
@ ROOT_DECL_LIST
Definition: grammar.cc:320
@ CMD_123
Definition: grammar.cc:317
@ CMD_12
Definition: grammar.cc:314
@ CMD_13
Definition: grammar.cc:315
@ CMD_M
Definition: grammar.cc:318
@ RING_CMD
Definition: grammar.cc:281
int IsCmd(const char *n, int &tok)
Definition: iparith.cc:9523
VAR idhdl currRingHdl
Definition: ipid.cc:59
int iiOpsTwoChar(const char *s)
Definition: ipshell.cc:121
#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:218

◆ newstruct_setup()

void newstruct_setup ( const char *  name,
newstruct_desc  d 
)

Definition at line 688 of file newstruct.cc.

689{
690 blackbox *b=(blackbox*)omAlloc0(sizeof(blackbox));
691 // all undefined entries will be set to default in setBlackboxStuff
692 // the default Print is quite useful,
693 // all other are simply error messages
694 b->blackbox_destroy=newstruct_destroy;
695 b->blackbox_String=newstruct_String;
696 b->blackbox_Print=newstruct_Print;//blackbox_default_Print;
697 b->blackbox_Init=newstruct_Init;
698 b->blackbox_Copy=newstruct_Copy;
699 b->blackbox_Assign=newstruct_Assign;
700 b->blackbox_Op1=newstruct_Op1;
701 b->blackbox_Op2=newstruct_Op2;
702 //b->blackbox_Op3=blackboxDefaultOp3;
703 b->blackbox_OpM=newstruct_OpM;
704 b->blackbox_CheckAssign=newstruct_CheckAssign;
705 b->blackbox_serialize=newstruct_serialize;
706 b->blackbox_deserialize=newstruct_deserialize;
707 b->data=d;
708 b->properties=1; // list_like
709 int rt=setBlackboxStuff(b,n);
710 d->id=rt;
711 //Print("create type %d (%s)\n",rt,n);
712}
int setBlackboxStuff(blackbox *bb, const char *n)
define a new type
Definition: blackbox.cc:142
CanonicalForm b
Definition: cfModGcd.cc:4103
BOOLEAN newstruct_Op2(int op, leftv res, leftv a1, leftv a2)
Definition: newstruct.cc:336
BOOLEAN newstruct_deserialize(blackbox **, void **d, si_link f)
Definition: newstruct.cc:636
void newstruct_destroy(blackbox *, void *d)
Definition: newstruct.cc:519
char * newstruct_String(blackbox *b, void *d)
Definition: newstruct.cc:50
BOOLEAN newstruct_Op1(int op, leftv res, leftv arg)
Definition: newstruct.cc:251
BOOLEAN newstruct_Assign(leftv l, leftv r)
Definition: newstruct.cc:279
BOOLEAN newstruct_serialize(blackbox *b, void *d, si_link f)
Definition: newstruct.cc:594
void * newstruct_Copy(blackbox *, void *d)
Definition: newstruct.cc:167
void * newstruct_Init(blackbox *b)
Definition: newstruct.cc:528
BOOLEAN newstruct_OpM(int op, leftv res, leftv args)
Definition: newstruct.cc:478
BOOLEAN newstruct_CheckAssign(blackbox *, leftv L, leftv R)
Definition: newstruct.cc:549
void newstruct_Print(blackbox *b, void *d)
Definition: newstruct.cc:659
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ newstructChildFromString()

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

Definition at line 799 of file newstruct.cc.

800{
801 // find parent:
802 int parent_id=0;
803 blackboxIsCmd(parent,parent_id);
804 if (parent_id<MAX_TOK)
805 {
806 Werror(">>%s< not found",parent);
807 return NULL;
808 }
809 blackbox *parent_bb=getBlackboxStuff(parent_id);
810 // check for the correct type:
811 if (parent_bb->blackbox_destroy!=newstruct_destroy)
812 {
813 Werror(">>%s< is not a user defined type",parent);
814 return NULL;
815 }
816 // setup for scanNewstructFromString:
817 newstruct_desc res=(newstruct_desc)omAlloc0(sizeof(*res));
818 newstruct_desc parent_desc=(newstruct_desc)parent_bb->data;
819 res->size=parent_desc->size;
820 res->member=parent_desc->member;
821 res->parent=parent_desc;
822
824}
const CanonicalForm int s
Definition: facAbsFact.cc:51
CanonicalForm res
Definition: facAbsFact.cc:60
static newstruct_desc scanNewstructFromString(const char *s, newstruct_desc res)
Definition: newstruct.cc:714
#define NULL
Definition: omList.c:12

◆ newstructFromString()

newstruct_desc newstructFromString ( const char *  s)

Definition at line 792 of file newstruct.cc.

793{
794 newstruct_desc res=(newstruct_desc)omAlloc0(sizeof(*res));
795 res->size=0;
796
798}

◆ newstructShow()

void newstructShow ( newstruct_desc  d)

Definition at line 826 of file newstruct.cc.

827{
828 newstruct_member elem;
829 Print("id: %d\n",d->id);
830 elem=d->member;
831 while (elem!=NULL)
832 {
833 Print(">>%s<< at pos %d, type %d (%s)\n",elem->name,elem->pos,elem->typ,Tok2Cmdname(elem->typ));
834 if (NeedShadowRing(elem->typ))
835 Print(">>r_%s<< at pos %d, shadow ring\n",elem->name,elem->pos-1);
836 elem=elem->next;
837 }
838 newstruct_proc p=d->procs;
839 while (p!=NULL)
840 {
841 Print("op:%d(%s) with %d args -> %s\n",p->t,iiTwoOps(p->t),p->args,p->p->procname);
842 p=p->next;
843 }
844}
#define Print
Definition: emacs.cc:80
const char * iiTwoOps(int t)
Definition: gentable.cc:261
const char * Tok2Cmdname(int tok)
Definition: gentable.cc:140
static int NeedShadowRing(int t)
Definition: newstruct.cc:46