Пример #1
0
/** 
Function called by GAP after a workspace restore. This is also called by us in
InitLibrary();
**/ 
static Int PostRestore(StructInitInfo* module)
{
  Int i;
  Int gvar;
  Obj tmp;
  
  gvar = GVarName("LinBox");
  tmp = (Obj)VAL_GVAR(gvar);
  if(!tmp) 
  {
    tmp = (Obj)NEW_PREC(0);
  }

  /* Write the names of my functions into th LinBox record */
  for(i = 0; GVarFuncs[i].name != 0; i++) 
  {
    AssPRec(
      tmp, 
      RNamName((Char*)GVarFuncs[i].name), 
      NewFunctionC(
        GVarFuncs[i].name, 
        GVarFuncs[i].nargs, 
        GVarFuncs[i].args, 
        GVarFuncs[i].handler) );
  }
  
  MakeReadWriteGVar(gvar);
  AssGVar(gvar, tmp);
  MakeReadOnlyGVar(gvar);
  return 0;
}
Пример #2
0
  Obj get(const char* c)
  {
    UInt n = RNamName(c);
    if(!has(c))
      throw GAPException("field not in record");

    return ELM_REC(record, n);
  }
Пример #3
0
/****************************************************************************
**
*F  RNamObj(<obj>)  . . . . . . . . . . .  convert an object to a record name
**
**  'RNamObj' returns the record name  corresponding  to  the  object  <obj>,
**  which currently must be a string or an integer.
*/
UInt            RNamObj (
    Obj                 obj )
{
    /* convert integer object                                              */
    if ( IS_INTOBJ(obj) ) {
        return RNamIntg( INT_INTOBJ(obj) );
    }

    /* convert string object (empty string may have type T_PLIST)          */
    else if ( IsStringConv(obj) && IS_STRING_REP(obj) ) {
        return RNamName( CSTR_STRING(obj) );
    }

    /* otherwise fail                                                      */
    else {
        obj = ErrorReturnObj(
            "Record: '<rec>.(<obj>)' <obj> must be a string or an integer",
            0L, 0L,
            "you can replace <obj> via 'return <obj>;'" );
        return RNamObj( obj );
    }
}
Пример #4
0
/****************************************************************************
**
*F  RNamIntg(<intg>)  . . . . . . . . . . convert an integer to a record name
**
**  'RNamIntg' returns the record name corresponding to the integer <intg>.
*/
UInt            RNamIntg (
    Int                 intg )
{
    Char                name [32];      /* integer converted to a string   */
    Char *              p;              /* loop variable                   */
    UInt negative;

    /* convert the integer to a string                                     */
    p = name + sizeof(name);  *--p = '\0';
    negative = (intg < 0);
    if ( negative ) {
        intg = -intg;
    }
   
    do {
        *--p = '0' + intg % 10;
    } while ( (intg /= 10) != 0 );
    if( negative ) {
        *--p = '-';
    }

    /* return the name                                                     */
    return RNamName( p );
}
Пример #5
0
 void set(const char* c, const T& t)
 {
   UInt n = RNamName(c);
   AssPRec(record, n, GAP_make(t));
 }
Пример #6
0
 bool has(const char* c)
 {
   UInt n = RNamName(c);
   return ISB_REC(record, n);
 }