Changeset 57dcd6 in git


Ignore:
Timestamp:
Dec 13, 2012, 12:07:24 AM (11 years ago)
Author:
Alexander Dreyer <adreyer@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
c1e7a64cbf29c8f08287152a94545e06e8608a9a
Parents:
801d2b82d26cf116224a17169c6379c454c018e7
git-author:
Alexander Dreyer <adreyer@gmx.de>2012-12-13 00:07:24+01:00
git-committer:
Alexander Dreyer <adreyer@gmx.de>2012-12-14 11:40:21+01:00
Message:
using LIB("pyobject.so"); instead of system("pyobject");
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • Singular/extra.cc

    r801d2b r57dcd6  
    29482948         res->rtyp = NONE;
    29492949         return FALSE;
    2950        }
    2951        else
    2952 
    2953   /*==== pyobject (or pyobject*, like pyobject.so) force loading python ===*/
    2954        if (strncmp(sys_cmd, "pyobject", 8) == 0)
    2955        {
    2956          res->rtyp = NONE;
    2957          return pyobject_ensure();
    29582950       }
    29592951       else
  • Singular/iparith.cc

    r801d2b r57dcd6  
    51555155  char libnamebuf[256];
    51565156  lib_types LT = type_of_LIB(s, libnamebuf);
     5157
    51575158#ifdef HAVE_DYNAMIC_LOADING
    51585159  extern BOOLEAN load_modules(char *newlib, char *fullpath, BOOLEAN autoexport);
     
    51955196      }
    51965197      case LT_BUILTIN:
    5197         return FALSE;
     5198        SModulFunc_t iiGetBuiltinModInit(char*);
     5199        return load_builtin(s,autoexport, iiGetBuiltinModInit(s));
    51985200      case LT_MACH_O:
    51995201      case LT_ELF:
  • Singular/iplib.cc

    r801d2b r57dcd6  
    672672}
    673673
     674int huhu_mod_init(SModulFunctions*){ return 0; }
     675
     676#define SI_GET_BUILTIN_MOD_INIT(name) \
     677  int name##_mod_init(SModulFunctions*); \
     678  if (strcmp(libname, #name ".so") == 0) {  return name##_mod_init; }
     679
     680
     681SModulFunc_t
     682iiGetBuiltinModInit(char* libname)
     683{
     684  SI_FOREACH_BUILTIN(SI_GET_BUILTIN_MOD_INIT)
     685
     686  return NULL;
     687}
     688
     689
     690#undef SI_GET_BUILTIN_MOD_INIT
     691
     692
    674693/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
    675694BOOLEAN iiTryLoadLib(leftv v, const char *id)
     
    684703  idhdl packhdl;
    685704  lib_types LT;
    686 
    687705  for(i=0; suffix[i] != NULL; i++)
    688706  {
     
    702720      else if (LT==LT_BUILTIN)
    703721      {
    704         LoadResult=load_builtin(s,FALSE,(SModulFunc_t)NULL);
     722        LoadResult=load_builtin(s,FALSE, iiGetBuiltinModInit(s));
    705723      }
    706724      if(!LoadResult )
     
    11261144    (*init)(&sModulFunctions);
    11271145  }
    1128   if (BVERBOSE(V_LOAD_LIB)) Print( "// ** loaded %s \n", newlib);
     1146  if (BVERBOSE(V_LOAD_LIB)) Print( "// ** loaded (builtin) %s \n", newlib);
    11291147  currPack->loaded=1;
    11301148  currPack=s;
  • Singular/pyobject.cc

    r801d2b r57dcd6  
    413413  size_t size(leftv iter, size_t distance = 0) const
    414414  {
    415     if (iter) { do { ++distance; } while(iter = iter->next); };
     415    if (iter) { do { ++distance; } while((iter = iter->next)); };
    416416    return distance;
    417417  }
     
    463463  sync_contexts();
    464464
    465   Py_XINCREF(Py_None);
     465  Py_INCREF(Py_None);
    466466  return PythonCastStatic<>(Py_None).assign_to(result);
    467467}
     
    496496  sync_contexts();
    497497
    498   Py_XINCREF(Py_None);
     498  Py_INCREF(Py_None);
    499499  return PythonCastStatic<>(Py_None).assign_to(result);
    500500}
     
    503503void* pyobject_Init(blackbox*)
    504504{
    505   Py_XINCREF(Py_None);
     505  Py_INCREF(Py_None);
    506506  return Py_None;
    507507}
     
    715715
    716716#define PYOBJECT_ADD_C_PROC(name) \
    717   add_C_proc((currPack->libname? currPack->libname: ""), (char*)#name, FALSE, name);
    718 
    719 typedef  BOOLEAN (*func_type)(leftv, leftv);
    720 void pyobject_init(int (*add_C_proc)(const char*, const char*, BOOLEAN,
    721                                      func_type) )
     717  psModulFunctions->iiAddCproc((currPack->libname? currPack->libname: ""),\
     718     (char*)#name, FALSE, name);
     719
     720int pyobject_mod_init(SModulFunctions* psModulFunctions)
    722721{
    723722  int tok = -1;
     
    734733    bbx->blackbox_Op3     = pyobject_Op3;
    735734    bbx->blackbox_OpM     = pyobject_OpM;
    736     bbx->data             = omAlloc0(newstruct_desc_size());
     735    bbx->data             = (void*)omAlloc0(newstruct_desc_size());
    737736   
    738737    PythonInterpreter::init(tok);
     
    742741    PYOBJECT_ADD_C_PROC(python_run);
    743742  }
     743  return 0;
    744744}
    745745#undef PYOBJECT_ADD_C_PROC
     
    747747#ifndef EMBED_PYTHON
    748748extern "C" {
    749   void mod_init(SModulFunctions* psModulFunctions)
     749  int mod_init(SModulFunctions* psModulFunctions)
    750750  {
    751     pyobject_init(psModulFunctions->iiAddCproc);
     751    return pyobject_mod_init(psModulFunctions);
    752752  }
    753753}
  • Singular/pyobject_setup.cc

    r801d2b r57dcd6  
    1919#include <Singular/ipshell.h>
    2020
    21 /* whether pyobject module is linked statically or dynamically */
    22 
    23 #ifdef EMBED_PYTHON // Case: we include the pyobject interface in the binary
    24 
    25 #ifdef HAVE_PYTHON
     21#ifdef EMBED_PYTHON
    2622#include "pyobject.cc"
    27 static BOOLEAN pyobject_load()
    28 {
    29    pyobject_init(iiAddCproc);
    30    return FALSE;
    31 }
    32 
    33 #else // Forced embedding, but no (development version of) python available!
    34 static BOOLEAN pyobject_load() { return TRUE; }
    3523#endif
    3624
    37 
    38 # else // Case: pyobject may be loaded from a dynamic module (prefered variant)
    39 // Note: we do not need python at compile time.
    4025static BOOLEAN pyobject_load()
    4126{
    4227  return jjLOAD("pyobject.so", TRUE);
    4328}
    44 #endif
    45 
    46 
    4729
    4830/// blackbox support - initialization via autoloading
  • libpolys/polys/mod_raw.cc

    r801d2b r57dcd6  
    3434#define BYTES_TO_CHECK 7
    3535
    36 char* si_bultin_libs[]={ "huhu.so", NULL };
     36#define SI_BUILTIN_LIBSTR(name) (char*) #name ".so",
     37
     38char* si_bultin_libs[]={ SI_FOREACH_BUILTIN(SI_BUILTIN_LIBSTR)  NULL };
     39
     40#undef SI_BUILTIN_LIBSTR
    3741
    3842lib_types type_of_LIB(char *newlib, char *libnamebuf)
  • libpolys/polys/mod_raw.h

    r801d2b r57dcd6  
    3939
    4040#endif /* HAVE_DL */
     41
     42
     43#ifdef EMBED_PYTHON
     44#define SI_BUILTIN_PYOBJECT(add) add(pyobject)
     45#else
     46#define SI_BUILTIN_PYOBJECT(add)
     47#endif
     48
     49/// Use @c add(name) to add built-in library to macro
     50#define SI_FOREACH_BUILTIN(add)\
     51  add(huhu)\
     52  SI_BUILTIN_PYOBJECT(add)
     53
     54
    4155#endif /* MOD_RAW_H */
Note: See TracChangeset for help on using the changeset viewer.