Changeset 67070c in git


Ignore:
Timestamp:
Sep 5, 2011, 7:57:49 PM (13 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
41d16b51dc7a98ea070feec36780afeb1aeba122
Parents:
929fae69163df72f59e8f56cb4e4807d67616e0a
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2011-09-05 19:57:49+02:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 16:12:31+01:00
Message:
ADD: trying to test Singular interpreter according to 'HOWTO-libsingular'
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/test.cc

    r929fae r67070c  
    315315#include "wrapper.cc"
    316316*/
     317void siInit(char *);
    317318
    318319int main( int, char *argv[] )
    319320{
    320   feInitResources(argv[0]);
     321  // init path names etc.
     322  feInitResources(argv[0]); //???
     323  siInit(argv[0]); // ?
     324
    321325
    322326  StringSetS("ressources in use (as reported by feStringAppendResources(0):\n");
     
    360364  rDelete(R);
    361365   
     366
     367   
     368   
     369  currentVoice=feInitStdin(NULL);
     370   
     371   
     372  // hook for error handling:
     373  // WerrorS_callback=......; of type p(const char *)
     374  int err=iiEStart(omStrDup("int ver=system(\"version\");export ver;return();\n"),NULL);
     375  if (err) errorreported = 0; // reset error handling
     376  printf("interpreter returns %d\n",err);
     377  idhdl h=ggetid("ver");
     378  if (h!=NULL)
     379    printf("singular variable ver of type %d contains %d\n",h->typ,(int)(long)IDDATA(h));
     380  else
     381    printf("variable ver does not exist\n");
     382
     383  // calling a singular-library function
     384  idhdl datetime=ggetid("datetime");
     385  if (datetime==NULL)
     386    printf("datetime not found\n");
     387  else
     388  {
     389    leftv res=iiMake_proc(datetime,NULL,NULL);
     390    if (res==NULL) { printf("datetime return an error\n"); errorreported = 0; }
     391    else           printf("datetime returned type %d, >>%s<<\n",res->Typ(),(char *)res->Data());
     392  }
     393
     394  // changing a ring for the interpreter
     395  // re-using n and R from above
     396  R=rDefault(32003,3,n);
     397  idhdl newRingHdl=enterid("R" /* ring name*/,
     398                           0, /*nesting level, 0=global*/
     399                           RING_CMD,
     400                           &IDROOT,
     401                           FALSE);
     402   IDRING(newRingHdl)=R;
     403   // make R the default ring (include rChangeCurrRing):
     404   rSetHdl(newRingHdl);
     405   err=iiEStart(omStrDup("poly p=x;listvar();return();\n"),NULL);
     406
     407  // calling a kernel function via the interpreter interface
     408  sleftv r1; memset(&r1,0,sizeof(r1));
     409  sleftv arg; memset(&arg,0,sizeof(r1));
     410  arg.rtyp=STRING_CMD;
     411  arg.data=omStrDup("huhu");
     412  err=iiExprArith1(&r1,&arg,TYPEOF_CMD);
     413  printf("interpreter returns %d\n",err);
     414  if (err) errorreported = 0; // reset error handling
     415  else printf("typeof returned type %d, >>%s<<\n",r1.Typ(),r1.Data());
     416  // clean up r1:
     417  r1.CleanUp();
    362418   
    363419  return 0;
Note: See TracChangeset for help on using the changeset viewer.