[SCM] an open source computer algebra system branch, cleanedupstream, updated. 6125e540ca6d66c307958938a9d53b245507c323
Bernhard R. Link
brlink at debian.org
Tue Apr 24 15:54:03 UTC 2012
The following commit has been merged in the cleanedupstream branch:
commit 6dba8e911b000d9fde1b879f6d70118daf19bb77
Author: Hans Schoenemann <hannes at mathematik.uni-kl.de>
Date: Thu Mar 8 15:42:54 2012 +0100
add: overload print and others for newstruct
diff --git a/Singular/blackbox.h b/Singular/blackbox.h
index 408858c..97e13b6 100644
--- a/Singular/blackbox.h
+++ b/Singular/blackbox.h
@@ -54,6 +54,9 @@ BOOLEAN blackboxDefaultOp2(int op,leftv l, leftv r1, leftv r2);
/// default procedure blackboxDefaultOpM, to be called as "default:" branch
BOOLEAN blackbox_default_OpM(int op,leftv l, leftv r);
+/// default procedure blackbox_default_Print: print the string
+void blackbox_default_Print(blackbox *b,void *d);
+
/// return the structure to the type given by t
blackbox* getBlackboxStuff(const int t);
/// return the name to the type given by t (r/o)
diff --git a/Singular/extra.cc b/Singular/extra.cc
index f08e5e2..477f4e6 100644
--- a/Singular/extra.cc
+++ b/Singular/extra.cc
@@ -14,6 +14,7 @@
#include <signal.h>
#include <kernel/mod2.h>
#include <misc_ip.h>
+#include <newstruct.h>
#ifdef TIME_WITH_SYS_TIME
# include <time.h>
@@ -3749,6 +3750,21 @@ static BOOLEAN jjEXTENDED_SYSTEM(leftv res, leftv h)
return FALSE;
}
else
+/*==================== install newstruct =================*/
+ if (strcmp(sys_cmd,"install")==0)
+ {
+ if ((h!=NULL) && (h->Typ()==STRING_CMD)
+ && (h->next!=NULL) && (h->next->Typ()==STRING_CMD)
+ && (h->next->next!=NULL) && (h->next->next->Typ()==PROC_CMD)
+ && (h->next->next->next!=NULL) && (h->next->next->next->Typ()==INT_CMD))
+ {
+ return newstruct_set_proc((char*)h->Data(),(char*)h->next->Data(),
+ (int)(long)h->next->next->next->Data(),
+ (procinfov)h->next->next->Data());
+ }
+ return TRUE;
+ }
+ else
/*==================== Error =================*/
Werror( "(extended) system(\"%s\",...) %s", sys_cmd, feNotImplemented );
}
diff --git a/Singular/ipassign.cc b/Singular/ipassign.cc
index 4f926f6..8de3904 100644
--- a/Singular/ipassign.cc
+++ b/Singular/ipassign.cc
@@ -453,7 +453,7 @@ static BOOLEAN jiA_PROC(leftv res, leftv a, Subexpr e)
((procinfo *)res->data)->data.s.body=(char *)a->CopyD(STRING_CMD);
}
else
- res->data=(void *)a->CopyD(PROC_CMD);
+ res->data=(void *)a->CopyD();
jiAssignAttr(res,a);
return FALSE;
}
diff --git a/Singular/newstruct.cc b/Singular/newstruct.cc
index 2197cfd..8b24a3d 100644
--- a/Singular/newstruct.cc
+++ b/Singular/newstruct.cc
@@ -18,10 +18,21 @@ struct newstruct_member_s
int pos;
};
+struct newstruct_proc_s;
+typedef struct newstruct_proc_a *newstruct_proc;
+struct newstruct_proc_a
+{
+ newstruct_proc next;
+ int t; /*tok id */
+ int args; /* number of args */
+ procinfov p;
+};
+
struct newstruct_desc_s
{
newstruct_member member;
newstruct_desc parent;
+ newstruct_proc procs;
int size; // number of mebers +1
int id; // the type id assigned to this bb
};
@@ -257,6 +268,29 @@ BOOLEAN newstruct_Op2(int op, leftv res, leftv a1, leftv a2)
}
}
}
+ newstruct_proc p=nt->procs;
+ while((p!=NULL) &&(p->t=op)&&(p->args!=2)) p=p->next;
+ if (p!=NULL)
+ {
+ leftv sl;
+ sleftv tmp;
+ memset(&tmp,0,sizeof(sleftv));
+ tmp.Copy(a1);
+ tmp.next=(leftv)omAlloc0(sizeof(sleftv));
+ tmp.next->Copy(a2);
+ idrec hh;
+ memset(&hh,0,sizeof(hh));
+ hh.id=Tok2Cmdname(p->t);
+ hh.typ=PROC_CMD;
+ hh.data.pinf=p->p;
+ sl=iiMake_proc(&hh,NULL,&tmp);
+ if (sl==NULL) return TRUE;
+ else
+ {
+ res->Copy(sl);
+ return FALSE;
+ }
+ }
return blackboxDefaultOp2(op,res,a1,a2);
}
@@ -353,15 +387,38 @@ BOOLEAN newstruct_deserialize(blackbox **b, void **d, si_link f)
return FALSE;
}
+void newstruct_Print(blackbox *b,void *d)
+{
+ newstruct_desc dd=(newstruct_desc)b->data;
+ newstruct_proc p=dd->procs;
+ while((p!=NULL)&&(p->t!=PRINT_CMD))
+ p=p->next;
+ if (p!=NULL)
+ {
+ leftv sl;
+ sleftv tmp;
+ memset(&tmp,0,sizeof(tmp));
+ tmp.rtyp=dd->id;
+ tmp.data=(void*)newstruct_Copy(b,d);
+ idrec hh;
+ memset(&hh,0,sizeof(hh));
+ hh.id=Tok2Cmdname(p->t);
+ hh.typ=PROC_CMD;
+ hh.data.pinf=p->p;
+ sl=iiMake_proc(&hh,NULL,&tmp);
+ }
+ else
+ blackbox_default_Print(b,d);
+}
void newstruct_setup(const char *n, newstruct_desc d )
{
blackbox *b=(blackbox*)omAlloc0(sizeof(blackbox));
// all undefined entries will be set to default in setBlackboxStuff
- // the default Print is quite usefule,
+ // 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=blackbox_default_Print;
+ b->blackbox_Print=newstruct_Print;//blackbox_default_Print;
b->blackbox_Init=newstruct_Init;
b->blackbox_Copy=newstruct_Copy;
b->blackbox_Assign=newstruct_Assign;
@@ -488,3 +545,25 @@ newstruct_desc newstructChildFromString(const char *parent, const char *s)
return scanNewstructFromString(s,res);
}
+
+BOOLEAN newstruct_set_proc(const char *bbname,const char *func, int args,procinfov pr)
+{
+ int id=0;
+ blackboxIsCmd(bbname,id);
+ 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;
+ if(!IsCmd(func,p->t))
+ {
+ if (func[1]=='\0') p->t=func[0];
+ else
+ {
+ Werror(">>%s<< is not e kernel command",func);
+ return TRUE;
+ }
+ }
+ p->args=args;
+ p->p=pr; pr->ref++;
+ return FALSE;
+}
diff --git a/Singular/newstruct.h b/Singular/newstruct.h
index 64575b6..9e56778 100644
--- a/Singular/newstruct.h
+++ b/Singular/newstruct.h
@@ -6,5 +6,6 @@ typedef struct newstruct_desc_s *newstruct_desc;
void newstruct_setup(const char * name, newstruct_desc d);
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);
#endif
--
an open source computer algebra system
More information about the debian-science-commits
mailing list