Changeset 801d2b in git


Ignore:
Timestamp:
Mar 13, 2012, 2:58:47 PM (12 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '648d28f488f6ff08f5607ff229b9ad9e4a5b93c2')
Children:
57dcd6dcce5b13d67c7a17d1b1dc57c9b4de98c9
Parents:
f51a5bd5a84a0bdc21e8b4b7357a3d1f43bae4e6
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2012-03-13 14:58:47+01:00
git-committer:
Alexander Dreyer <adreyer@gmx.de>2012-12-14 11:40:21+01:00
Message:
add: help for modules, "static" modules - part 1
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • Singular/iparith.cc

    rf51a5b r801d2b  
    51945194        return bo;
    51955195      }
     5196      case LT_BUILTIN:
     5197        return FALSE;
    51965198      case LT_MACH_O:
    51975199      case LT_ELF:
  • Singular/ipid.h

    rf51a5b r801d2b  
    7979
    8080extern idhdl      currRingHdl;
     81/* ================================================================== */
     82/* module support */
     83typedef int (*SModulFunc_t)(SModulFunctions*);
     84BOOLEAN load_builtin(char *newlib, BOOLEAN autoexport, SModulFunc_t init);
     85void module_help_main(char *newlib,const char *help);
     86void module_help_proc(char *newlib,const char *p, const char *help);
     87
     88/* ================================================================== */
     89
    8190/*extern ring     currRing;  in ring.h */
    8291/*extern ideal      currQuotient; in structs.h */
  • Singular/iplib.cc

    rf51a5b r801d2b  
    700700        LoadResult = load_modules(s,libnamebuf,FALSE);
    701701      #endif
     702      else if (LT==LT_BUILTIN)
     703      {
     704        LoadResult=load_builtin(s,FALSE,(SModulFunc_t)NULL);
     705      }
    702706      if(!LoadResult )
    703707      {
     
    10221026                               BOOLEAN pstatic,
    10231027                               BOOLEAN(*func)(leftv res, leftv v)));
    1024   typedef int (*fktn2_t)(SModulFunctions*);
    1025   fktn2_t fktn;
     1028  SModulFunc_t fktn;
    10261029  idhdl pl;
    10271030  char *plib = iiConvName(newlib);
     
    10701073    package s=currPack;
    10711074    currPack=IDPACKAGE(pl);
    1072     fktn = (fktn2_t)dynl_sym(IDPACKAGE(pl)->handle, "mod_init");
     1075    fktn = (SModulFunc_t)dynl_sym(IDPACKAGE(pl)->handle, "mod_init");
    10731076    if( fktn!= NULL)
    10741077    {
     
    10891092#endif /*STATIC */
    10901093}
     1094/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
     1095BOOLEAN load_builtin(char *newlib, BOOLEAN autoexport, SModulFunc_t init)
     1096{
     1097  int iiAddCproc(const char *libname, const char *procname, BOOLEAN pstatic,
     1098                 BOOLEAN(*func)(leftv res, leftv v));
     1099  typedef int (*fktn_t)(int(*iiAddCproc)(const char *libname, const char *procname,
     1100                               BOOLEAN pstatic,
     1101                               BOOLEAN(*func)(leftv res, leftv v)));
     1102  SModulFunc_t fktn;
     1103  idhdl pl;
     1104  char *plib = iiConvName(newlib);
     1105  BOOLEAN RET=TRUE;
     1106  int token;
     1107
     1108  pl = IDROOT->get(plib,0);
     1109  if (pl==NULL)
     1110  {
     1111    pl = enterid( plib,0, PACKAGE_CMD, &IDROOT,
     1112                  TRUE );
     1113    IDPACKAGE(pl)->language = LANG_C;
     1114    IDPACKAGE(pl)->libname=omStrDup(newlib);
     1115  }
     1116  IDPACKAGE(pl)->handle=(void *)NULL;
     1117  SModulFunctions sModulFunctions;
     1118
     1119  package s=currPack;
     1120  currPack=IDPACKAGE(pl);
     1121  if( init!= NULL)
     1122  {
     1123    sModulFunctions.iiArithAddCmd = iiArithAddCmd;
     1124    if (autoexport) sModulFunctions.iiAddCproc = iiAddCprocTop;
     1125    else            sModulFunctions.iiAddCproc = iiAddCproc;
     1126    (*init)(&sModulFunctions);
     1127  }
     1128  if (BVERBOSE(V_LOAD_LIB)) Print( "// ** loaded %s \n", newlib);
     1129  currPack->loaded=1;
     1130  currPack=s;
     1131
     1132  return FALSE;
     1133}
     1134/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
     1135void module_help_main(char *newlib,const char *help)
     1136{
     1137  char *plib = iiConvName(newlib);
     1138  idhdl pl = IDROOT->get(plib,0);
     1139  if ((pl==NULL)||(IDTYP(pl)!=PACKAGE_CMD))
     1140    Werror(">>%s<< is not a package",plib);
     1141  else
     1142  {
     1143    package s=currPack;
     1144    currPack=IDPACKAGE(pl);
     1145    idhdl h=enterid(omStrDup("info"),0,STRING_CMD,&IDROOT,FALSE);
     1146    IDSTRING(h)=omStrDup(help);
     1147    currPack=s;
     1148  }
     1149}
     1150void module_help_proc(char *newlib,const char *p, const char *help)
     1151{
     1152  char *plib = iiConvName(newlib);
     1153  idhdl pl = IDROOT->get(plib,0);
     1154  if ((pl==NULL)||(IDTYP(pl)!=PACKAGE_CMD))
     1155    Werror(">>%s<< is not a package",plib);
     1156  else
     1157  {
     1158    package s=currPack;
     1159    currPack=IDPACKAGE(pl);
     1160    char buff[256];
     1161    buff[255]='\0';
     1162    strncpy(buff,p,255);
     1163    strncat(buff,"_help",255-strlen(p));
     1164    idhdl h=enterid(omStrDup(buff),0,STRING_CMD,&IDROOT,FALSE);
     1165    IDSTRING(h)=omStrDup(help);
     1166    currPack=s;
     1167  }
     1168}
     1169/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
    10911170
    10921171// loads a dynamic module from the binary path and returns a named function
  • Singular/tesths.cc

    rf51a5b r801d2b  
    181181  errorreported = 0;
    182182
     183  // -- example for "static" modules ------
     184  //load_builtin("huhu.so",FALSE,(SModulFunc_t)huhu_mod_init);
     185  //module_help_main("huhu.so","Help for huhu\nhaha\n");
     186  //module_help_proc("huhu.so","p","Help for huhu::p\nhaha\n");
    183187  setjmp(si_start_jmpbuf);
    184188
  • libpolys/polys/mod_raw.cc

    rf51a5b r801d2b  
    3434#define BYTES_TO_CHECK 7
    3535
     36char* si_bultin_libs[]={ "huhu.so", NULL };
     37
    3638lib_types type_of_LIB(char *newlib, char *libnamebuf)
    3739{
     
    4244  const unsigned char mach_O64[]={0xcf,0xfa,0xed,0xfe,0};
    4345   
     46  int i=0;
     47  while(si_bultin_libs[i]!=NULL)
     48  {
     49    if (strcmp(newlib,si_bultin_libs[i])==0)
     50    {
     51      if(libnamebuf!=NULL) strcpy(libnamebuf,newlib);
     52      return LT_BUILTIN;
     53    }
     54    i++;
     55  }
    4456  char        buf[BYTES_TO_CHECK+1];        /* one extra for terminating '\0' */
    4557  struct stat sb;
     
    93105    goto lib_type_end;
    94106  }
    95    
     107
     108
    96109  if( (strncmp(buf, "\02\020\01\016\05\022@", 7)==0))
    97110  {
     
    207220#endif
    208221
    209 #if defined(__APPLE__) && defined(__MACH__)
     222#if defined(ix86Mac_darwin)
     223#define HAVE_ELF_SYSTEM
     224#endif
     225
     226#if defined(x86_64Mac_darwin)
    210227#define HAVE_ELF_SYSTEM
    211228#endif
  • libpolys/polys/mod_raw.h

    rf51a5b r801d2b  
    1313*/
    1414
    15 typedef enum { LT_NONE, LT_NOTFOUND, LT_SINGULAR, LT_ELF, LT_HPUX, LT_MACH_O} lib_types;
     15typedef enum { LT_NONE, LT_NOTFOUND, LT_SINGULAR, LT_ELF, LT_HPUX, LT_MACH_O, LT_BUILTIN} lib_types;
    1616
    1717lib_types type_of_LIB(char *newlib, char *fullname);
Note: See TracChangeset for help on using the changeset viewer.