Esempio n. 1
0
File: xf.c Progetto: donguinn/core
static F jtixf(J jt,A w){F f;
 ASSERT(2<=AN(w),EVLENGTH);
 switch(AT(w)){
  default:  ASSERT(0,EVDOMAIN);
  case B01: ASSERT(0,EVFNUM);
  case BOX: ASSERT(2==AN(w),EVLENGTH); f=stdf(head(w)); break;
  case INT: f=(F)*AV(w); ASSERT(2<(UI)f,EVFNUM);
 }
 R f?vfn(f):f;
}    /* process index file arg for file number; 0 if a file name */
Esempio n. 2
0
void Package::AddNative(RegisterFunction* fns, size_t count)
{
    GCPAUSE_NORUN(engine);
    for (size_t i = 0; i < count; ++i)
    {
        String* funname = engine->AllocString(fns[i].name);
        
        Def* fn = Def::CreateWith(engine, funname, fns[i].code, fns[i].argc, fns[i].flags, 0, fns[i].__doc);
                                                  
        Value vname(funname);
        Value vfn(fn);
        
        Function* closure = Function::Create(engine, fn, this);
        Value vframe;
        vframe.Set(closure);
        
        SetSlot(vname, vframe);
    }
}