예제 #1
0
파일: flow.c 프로젝트: evanrmurphy/PicoLisp
// (new ['flg|num] ['typ ['any ..]]) -> obj
any doNew(any ex) {
   any x, y, *h;
   cell c1, c2;

   x = cdr(ex);
   if (isCell(y = EVAL(car(x))))
      Push(c1, consSym(y,Nil));
   else {
      if (isNil(y))
         data(c1) = consSym(Nil,Nil);
      else {
         y = newId(ex, isNum(y)? (int)unDig(y)/2 : 1);
         if (data(c1) = findHash(y, h = Extern + ehash(y)))
            tail(data(c1)) = y;
         else
            *h = cons(data(c1) = consSym(Nil,y), *h);
         mkExt(data(c1));
      }
      Save(c1);
      x = cdr(x),  val(data(c1)) = EVAL(car(x));
   }
   TheKey = T,  TheCls = NULL;
   if (y = method(data(c1)))
      evMethod(data(c1), y, cdr(x));
   else {
      Push(c2, Nil);
      while (isCell(x = cdr(x))) {
         data(c2) = EVAL(car(x)),  x = cdr(x);
         put(data(c1), data(c2), EVAL(car(x)));
      }
   }
   return Pop(c1);
}
예제 #2
0
파일: test.c 프로젝트: jacereda/glcv
intptr_t event(const ev * e) {
        intptr_t ret = 1;
        cveventtype t = evType(e);
        if (t != CVE_UPDATE)
                cvReport("got event %s, %p %p", 
                         evName(e), evArg0(e), evArg1(e));
        switch (t) {
#if !defined NPAPI
        case CVQ_LOGGER: ret = (intptr_t)report; break;
#endif
        case CVQ_NAME: ret = (intptr_t)"test"; break;
        case CVQ_XPOS: ret = 50; break;
        case CVQ_YPOS: ret = 50; break;
        case CVQ_WIDTH: ret = 640; break;
        case CVQ_HEIGHT: ret = 480; break;
        case CVE_INIT: init(); break;
        case CVE_TERM: term(); break;
        case CVE_GLINIT: glinit(); break;
        case CVE_DOWN: ret = down(evWhich(e)); break;
        case CVE_UP: ret = up(evWhich(e)); break;
        case CVE_UNICODE: unicode(evUnicode(e)); break;
        case CVE_MOTION: motion(evX(e), evY(e)); break;
        case CVE_CLOSE: close(); break;
        case CVE_INVOKE: invoke(evMethod(e)); break;
        case CVE_RESIZE: resize(evWidth(e), evHeight(e)); break;
        case CVE_UPDATE: update(); break;
        default: ret = 0; break;
        }
        return ret;
}
예제 #3
0
파일: flow.c 프로젝트: evanrmurphy/PicoLisp
// (send 'msg 'obj ['any ..]) -> any
any doSend(any ex) {
   any x, y;
   cell c1, c2;

   x = cdr(ex),  Push(c1,  EVAL(car(x)));
   NeedSym(ex,data(c1));
   x = cdr(x),  Push(c2,  EVAL(car(x)));
   NeedSym(ex,data(c2));
   Fetch(ex,data(c2));
   TheKey = data(c1),  TheCls = NULL;
   if (y = method(data(c2))) {
      x = evMethod(data(c2), y, cdr(x));
      drop(c1);
      return x;
   }
   err(ex, TheKey, "Bad message");
}
예제 #4
0
파일: flow.c 프로젝트: evanrmurphy/PicoLisp
// (meth 'obj ['any ..]) -> any
any doMeth(any ex) {
   any x, y;
   cell c1;

   x = cdr(ex),  Push(c1, EVAL(car(x)));
   NeedSym(ex,data(c1));
   Fetch(ex,data(c1));
   for (TheKey = car(ex); ; TheKey = val(TheKey)) {
      if (!isSym(TheKey))
         err(ex, TheKey, "Bad message");
      if (isNum(val(TheKey))) {
         TheCls = NULL;
         if (y = method(data(c1))) {
            x = evMethod(data(c1), y, cdr(x));
            drop(c1);
            return x;
         }
         err(ex, TheKey, "Bad message");
      }
   }
}
예제 #5
0
파일: flow.c 프로젝트: evanrmurphy/PicoLisp
// (try 'msg 'obj ['any ..]) -> any
any doTry(any ex) {
   any x, y;
   cell c1, c2;

   x = cdr(ex),  Push(c1,  EVAL(car(x)));
   NeedSym(ex,data(c1));
   x = cdr(x),  Push(c2,  EVAL(car(x)));
   if (isSym(data(c2))) {
      if (isExt(data(c2))) {
         if (!isLife(data(c2)))
            return Nil;
         db(ex,data(c2),1);
      }
      TheKey = data(c1),  TheCls = NULL;
      if (y = method(data(c2))) {
         x = evMethod(data(c2), y, cdr(x));
         drop(c1);
         return x;
      }
   }
   drop(c1);
   return Nil;
}