您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ ttisfunction函数代码示例

51自学网 2021-06-03 09:00:03
  C++
这篇教程C++ ttisfunction函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中ttisfunction函数的典型用法代码示例。如果您正苦于以下问题:C++ ttisfunction函数的具体用法?C++ ttisfunction怎么用?C++ ttisfunction使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了ttisfunction函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: call_binTM

static int call_binTM (lua_State *L, const TObject *p1, const TObject *p2,                       StkId res, TMS event) {  ptrdiff_t result = savestack(L, res);  const TObject *tm = luaT_gettmbyobj(L, p1, event);  /* try first operand */  if (ttisnil(tm))    tm = luaT_gettmbyobj(L, p2, event);  /* try second operand */  if (!ttisfunction(tm)) return 0;  callTMres(L, tm, p1, p2);  res = restorestack(L, result);  /* previous call may change stack */  setobjs2s(res, L->top);  return 1;}
开发者ID:TheWaWaR,项目名称:my-lua5.0,代码行数:12,


示例2: luaG_errormsg

void luaG_errormsg (lua_State *L){    if (L->errfunc != 0) {  /* is there an error handling function? */        StkId errfunc = restorestack(L, L->errfunc);        if (!ttisfunction(errfunc) && !ttislightfunction(errfunc)) luaD_throw(L, LUA_ERRERR);        setobjs2s(L, L->top, L->top - 1);  /* move argument */        setobjs2s(L, L->top - 1, errfunc);  /* push function */        incr_top(L);        luaD_call(L, L->top - 2, 1);  /* call it */    }    luaD_throw(L, LUA_ERRRUN);}
开发者ID:autosportlabs,项目名称:RaceCapture-Pro-firmware-mk1,代码行数:12,


示例3: lua_getinfo

LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {  int status = 1;  lua_lock(L);  if (*what == '>') {    StkId f = L->top - 1;    if (!ttisfunction(f))      luaG_runerror(L, "value for `lua_getinfo' is not a function");    status = auxgetinfo(L, what + 1, ar, f, NULL);    L->top--;  /* pop function */  }  else if (ar->i_ci != 0) {  /* no tail call? */    CallInfo *ci = L->base_ci + ar->i_ci;    lua_assert(ttisfunction(ci->base - 1));    status = auxgetinfo(L, what, ar, ci->base - 1, ci);  }  else    info_tailcall(L, ar);  if (strchr(what, 'f')) incr_top(L);  lua_unlock(L);  return status;}
开发者ID:gitrider,项目名称:wxsj2,代码行数:21,


示例4: lua_getinfo

LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar){    int status;    Closure *f = NULL;    CallInfo *ci = NULL;    void *plight = NULL;    lua_lock(L);    if (*what == '>') {        StkId func = L->top - 1;        luai_apicheck(L, ttisfunction(func) || ttislightfunction(func));        what++;  /* skip the '>' */        if (ttisfunction(func))            f = clvalue(func);        else            plight = fvalue(func);        L->top--;  /* pop function */    } else if (ar->i_ci != 0) { /* no tail call? */        ci = L->base_ci + ar->i_ci;        lua_assert(ttisfunction(ci->func) || ttislightfunction(ci->func));        if (ttisfunction(ci->func))            f = clvalue(ci->func);        else            plight = fvalue(ci->func);    }    status = auxgetinfo(L, what, ar, f, plight, ci);    if (strchr(what, 'f')) {        if (f != NULL)            setclvalue(L, L->top, f)            else if (plight != NULL)                setfvalue(L->top, plight)                else                    setnilvalue(L->top);        incr_top(L);    }    if (strchr(what, 'L'))        collectvalidlines(L, f);    lua_unlock(L);    return status;}
开发者ID:autosportlabs,项目名称:RaceCapture-Pro-firmware-mk1,代码行数:39,


示例5: luaG_errormsg

void luaG_errormsg (lua_State *L) {  if (L->errfunc != 0) {  /* is there an error handling function? */    StkId errfunc = restorestack(L, L->errfunc);    if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR);    setobjs2s(L, L->top, L->top - 1);  /* move argument */    setobjs2s(L, L->top - 1, errfunc);  /* push function */    incr_top(L);    luaD_call(L, L->top - 2, 1);  /* call it */  }else if (L->def_errfunc && lua_checkstack(L, LUA_MINSTACK)) {    L->def_errfunc(L);  // dunno about locks etc.   }  luaD_throw(L, LUA_ERRRUN);}
开发者ID:ArseniyShestakov,项目名称:wog,代码行数:13,


示例6: vm_OP_TAILCALL

int vm_OP_TAILCALL(lua_State *L, int a, int b) {  TValue *func = L->base + a;  Closure *cl;  CallInfo *ci;  StkId st, cur_func;  Proto *p;  int aux;  int tail_recur;  if (b != 0) L->top = func+b;  /* else previous instruction set top */  /* current function index */  ci = L->ci;  cur_func = ci->func;  /* check for tail recursive call */  if(gcvalue(func) == gcvalue(cur_func)) {    cl = clvalue(func);    p = cl->l.p;    /* if is not a vararg function. */    tail_recur = !p->is_vararg;    L->savedpc = p->code;  } else {    tail_recur=0;    ci->savedpc = L->savedpc;    if (!ttisfunction(func)) /* `func' is not a function? */      func = luaD_tryfuncTM(L, func);  /* check the `function' tag method */    cl = clvalue(func);#ifndef NDEBUG    if(cl->l.isC) { /* can't tailcall into C functions.  Causes problems with getfenv() */      luaD_precall(L, func, LUA_MULTRET);      vm_OP_RETURN(L, a, 0);      return PCRC;    }#endif  }  /* clean up current frame to prepare to tailcall into next function. */  if (L->openupval) luaF_close(L, ci->base);  for (aux = 0; func+aux < L->top; aux++)  /* move frame down */    setobjs2s(L, cur_func+aux, func+aux);  L->top = cur_func+aux;  /* JIT function calling it's self. */  if(tail_recur) {    for (st = L->top; st < ci->top; st++)      setnilvalue(st);    return PCRTAILRECUR;  }  L->base = cur_func; /* point base at new function to call.  This is needed by luaD_precall. */  /* unwind stack back to luaD_precall */  return PCRTAILCALL;}
开发者ID:GranPC,项目名称:llvm-lua,代码行数:51,


示例7: luaV_settable

void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {  TValue tmp;  int loop;  for (loop = 0; loop < MAXTAGLOOP; loop++) {    const TValue *tm;    if (ttistable(t)) {  /* `t' is a table? */      Table *h = hvalue(t);      TValue *oldval = luaH_set(L, h, key); /* do a primitive set */      if (!ttisnil(oldval) ||  /* result is no nil? */          (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */        setobj2t(L, oldval, val);        luaC_barriert(L, h, val);#if LUA_REFCOUNT        if (ttisnil(val)) {          Node* keyNode = luaH_getkey(h, key);          if (keyNode) {            luaH_removekey(L, h, keyNode);          }        }#endif /* LUA_REFCOUNT */        return;      }      /* else will try the tag method */    }    else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))      luaG_typeerror(L, t, "index");    if (ttisfunction(tm)) {      callTM(L, tm, t, key, val);#if LUA_REFCOUNT      {        TValue *newval;        if (ttistable(t)) {          newval = luaH_set(L, hvalue(t), key);          if (ttisnil(newval)) {            Node* keyNode = luaH_getkey(hvalue(t), key);            if (keyNode)              luaH_removekey(L, hvalue(t), keyNode);          }        }      }#endif /* LUA_REFCOUNT */      return;    }    setobj(L, &tmp, tm);    t = &tmp;  /* else repeat with copy of `tm' */  }  luaG_runerror(L, "loop in settable");}
开发者ID:zapline,项目名称:zlib,代码行数:48,


示例8: luaV_finishset

/*** Main function for table assignment (invoking metamethods if needed).** Compute 't[key] = val'*/void luaV_finishset (lua_State *L, const TValue *t, TValue *key,                     StkId val, const TValue *oldval) {  int loop;  /* counter to avoid infinite loops */  for (loop = 0; loop < MAXTAGLOOP; loop++) {    const TValue *tm;    if (oldval != NULL) {      Table *h = hvalue(t);  /* save 't' table */      lua_assert(ttisnil(oldval));      /* must check the metamethod */      if ((tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL &&         /* no metamethod; is there a previous entry in the table? */         (oldval != luaO_nilobject ||         /* no previous entry; must create one. (The next test is            always true; we only need the assignment.) */         (oldval = luaH_newkey(L, h, key), 1))) {        /* no metamethod and (now) there is an entry with given key */        setobj2t(L, cast(TValue *, oldval), val);        invalidateTMcache(h);        luaC_barrierback(L, h, val);        return;      }      /* else will try the metamethod */    }    else {  /* not a table; check metamethod */      if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))        luaG_typeerror(L, t, "index");    }    /* try the metamethod */    if (ttisfunction(tm)) {      luaT_callTM(L, tm, t, key, val, 0);      return;    }    t = tm;  /* else repeat assignment over 'tm' */    if (luaV_fastset(L, t, key, oldval, luaH_get, val))      return;  /* done */    /* else loop */  }  luaG_runerror(L, "settable chain too long; possible loop");}
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:43,


示例9: luaV_settable

void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {  int loop;  TValue temp;  setnilvalue(L->top);  L->top++;  fixedstack(L);  for (loop = 0; loop < MAXTAGLOOP; loop++) {    const TValue *tm;    if (ttistable(t) || ttisrotable(t)) {  /* `t' is a table? */      void *h = ttistable(t) ? hvalue(t) : rvalue(t);      TValue *oldval = ttistable(t) ? luaH_set(L, (Table*)h, key) : NULL; /* do a primitive set */      if ((oldval && !ttisnil(oldval)) ||  /* result is no nil? */          (tm = fasttm(L, ttistable(t) ? ((Table*)h)->metatable : (Table*)luaR_getmeta(h), TM_NEWINDEX)) == NULL) { /* or no TM? */        if(oldval) {          L->top--;          unfixedstack(L);          setobj2t(L, oldval, val);          ((Table *)h)->flags = 0;          luaC_barriert(L, (Table*)h, val);        }        return;      }      /* else will try the tag method */    }    else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))      luaG_typeerror(L, t, "index");    if (ttisfunction(tm) || ttislightfunction(tm)) {      L->top--;      unfixedstack(L);      callTM(L, tm, t, key, val);      return;    }    /* else repeat with `tm' */    setobj(L, &temp, tm);  /* avoid pointing inside table (may rehash) */    t = &temp;    setobj2s(L, L->top-1, t);  /* need to protect value from EGC. */  }  luaG_runerror(L, "loop in settable");}
开发者ID:Dxploto,项目名称:nodemcu-firmware,代码行数:39,


示例10: luaV_finishget

/*** Complete a table access: if 't' is a table, 'tm' has its metamethod;** otherwise, 'tm' is NULL.*/void luaV_finishget (lua_State *L, const TValue *t, TValue *key, StkId val,                      const TValue *tm) {  int loop;  /* counter to avoid infinite loops */  lua_assert(tm != NULL || !ttistable(t));  for (loop = 0; loop < MAXTAGLOOP; loop++) {    if (tm == NULL) {  /* no metamethod (from a table)? */      if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))        luaG_typeerror(L, t, "index");  /* no metamethod */    }    if (ttisfunction(tm)) {  /* metamethod is a function */      luaT_callTM(L, tm, t, key, val, 1);  /* call it */      return;    }    t = tm;  /* else repeat access over 'tm' */    if (luaV_fastget(L,t,key,tm,luaH_get)) {  /* try fast track */      setobj2s(L, val, tm);  /* done */      return;    }    /* else repeat */  }  luaG_runerror(L, "gettable chain too long; possible loop");}
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:26,


示例11: luaG_errormsg

void luaG_errormsg (lua_State *L) {  if (L->errfunc != 0) {  /* is there an error handling function? */    StkId errfunc = restorestack(L, L->errfunc);    if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR);    setobjs2s(L, L->top, L->top - 1);  /* move argument */    setobjs2s(L, L->top - 1, errfunc);  /* push function */    incr_top(L);    luaD_call(L, L->top - 2, 1);  /* call it */  }  else  {    lua_getfield(L, LUA_GLOBALSINDEX, "_ErrorHandler");    if (!lua_isfunction(L, -1)) {      lua_pop(L, 1);    }    else {      lua_pushvalue(L, 1);      lua_call(L, 1, 1);      lua_pop(L, 1);    }  }  luaD_throw(L, LUA_ERRRUN);}
开发者ID:nemesisqp,项目名称:premake-dev-rgeary,代码行数:23,


示例12: luaV_settable

/*** Main function for table assignment (invoking metamethods if needed).** Compute 't[key] = val'*/void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {  int loop;  /* counter to avoid infinite loops */  for (loop = 0; loop < MAXTAGLOOP; loop++) {    const TValue *tm;    if (ttistable(t)) {  /* 't' is a table? */      Table *h = hvalue(t);      TValue *oldval = cast(TValue *, luaH_get(h, key));      /* if previous value is not nil, there must be a previous entry         in the table; a metamethod has no relevance */      tm = ttisnil(oldval) ? fasttm(L, h->metatable, TM_NEWINDEX) : fasttm(L, h->metatable, TM_OLDINDEX);      if (tm == NULL &&          (oldval != luaO_nilobject ||           /* no previous entry; must create one. (The next test is              always true; we only need the assignment.) */           (oldval = luaH_newkey(L, h, key), 1))) {        /* no metamethod and (now) there is an entry with given key */        setobj2t(L, oldval, val);  /* assign new value to that entry */        invalidateTMcache(h);        luaC_barrierback(L, h, val);        return;      }      /* else will try the metamethod */    } else { /* not a table; check metamethod */      if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))        luaG_typeerror(L, t, "index");      if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_OLDINDEX)))        luaG_typeerror(L, t, "index");    }    /* try the metamethod */    if (ttisfunction(tm)) {      luaT_callTM(L, tm, t, key, val, 0);      return;    }    t = tm;  /* else repeat assignment over 'tm' */  }
开发者ID:linxiaolong,项目名称:cookies,代码行数:41,


示例13: luaV_gettable

void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) {  int loop;  for (loop = 0; loop < MAXTAGLOOP; loop++) {    const TValue *tm;    if (ttistable(t)) {  /* `t' is a table? */      Table *h = hvalue(t);      const TValue *res = luaH_get(h, key); /* do a primitive get */      if (!ttisnil(res) ||  /* result is no nil? */          (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */        setobj2s(L, val, res);        return;      }      /* else will try the tag method */    }    else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))      luaG_typeerror(L, t, "index");    if (ttisfunction(tm)) {      callTMres(L, val, tm, t, key);      return;    }    t = tm;  /* else repeat with `tm' */   }  luaG_runerror(L, "loop in gettable");}
开发者ID:angryzor,项目名称:luajit-tilepro64,代码行数:24,


示例14: luaV_gettable

/*** Main function for table access (invoking metamethods if needed).** Compute 'val = t[key]'*/void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) {    int loop;    /* counter to avoid infinite loops */    for (loop = 0; loop < MAXTAGLOOP; loop++) {        const TValue *tm;        if (ttistable(t)) {    /* 't' is a table? */            Table *h = hvalue(t);            const TValue *res = luaH_get(h, key); /* do a primitive get */            if (!ttisnil(res) ||    /* result is not nil? */                    (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */                setobj2s(L, val, res);    /* result is the raw get */                return;            }            /* else will try metamethod */        }        else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))            luaG_typeerror(L, t, "index");    /* no metamethod */        if (ttisfunction(tm)) {    /* metamethod is a function */            luaT_callTM(L, tm, t, key, val, 1);            return;        }        t = tm;    /* else repeat access over 'tm' */    }    luaG_runerror(L, "gettable chain too long; possible loop");}
开发者ID:SwadicalRag,项目名称:lau,代码行数:28,


示例15: luaV_finishset

/*** Finish a table assignment 't[key] = val'.** If 'slot' is NULL, 't' is not a table.  Otherwise, 'slot' points** to the entry 't[key]', or to 'luaO_nilobject' if there is no such** entry.  (The value at 'slot' must be nil, otherwise 'luaV_fastset'** would have done the job.)*/void luaV_finishset (lua_State *L, const TValue *t, TValue *key,                     StkId val, const TValue *slot) {  int loop;  /* counter to avoid infinite loops */  for (loop = 0; loop < MAXTAGLOOP; loop++) {    const TValue *tm;  /* '__newindex' metamethod */    if (slot != NULL) {  /* is 't' a table? */      Table *h = hvalue(t);  /* save 't' table */      lua_assert(ttisnil(slot));  /* old value must be nil */      tm = fasttm(L, h->metatable, TM_NEWINDEX);  /* get metamethod */      if (tm == NULL) {  /* no metamethod? */        if (slot == luaO_nilobject)  /* no previous entry? */          slot = luaH_newkey(L, h, key);  /* create one */        /* no metamethod and (now) there is an entry with given key */        setobj2t(L, cast(TValue *, slot), val);  /* set its new value */        invalidateTMcache(h);        luaC_barrierback(L, h, val);        return;      }      /* else will try the metamethod */    }    else {  /* not a table; check metamethod */      if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))        luaG_typeerror(L, t, "index");    }    /* try the metamethod */    if (ttisfunction(tm)) {      luaT_callTM(L, tm, t, key, val, 0);      return;    }    t = tm;  /* else repeat assignment over 'tm' */    if (luaV_fastset(L, t, key, slot, luaH_get, val))      return;  /* done */    /* else loop */  }  luaG_runerror(L, "'__newindex' chain too long; possible loop");}
开发者ID:IamAnson,项目名称:skynet,代码行数:43,


示例16: luaV_settable

/*** Receives table at `t', key at `key' and value at `val'.*/void luaV_settable (lua_State *L, const TObject *t, TObject *key, StkId val) {  const TObject *tm;  int loop = 0;  do {    if (ttistable(t)) {  /* `t' is a table? */      Table *h = hvalue(t);      TObject *oldval = luaH_set(L, h, key); /* do a primitive set */      if (!ttisnil(oldval) ||  /* result is no nil? */          (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */        setobj2t(oldval, val);  /* write barrier */        return;      }      /* else will try the tag method */    }    else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))      luaG_typeerror(L, t, "index");    if (ttisfunction(tm)) {      callTM(L, tm, t, key, val);      return;    }    t = tm;  /* else repeat with `tm' */   } while (++loop <= MAXTAGLOOP);  luaG_runerror(L, "loop in settable");}
开发者ID:TheWaWaR,项目名称:my-lua5.0,代码行数:27,


示例17: luaV_execute

//.........这里部分代码省略.........            base = (L->ci - 1)->base;  /* `luaD_precall' may change the stack */            ra = RA(i);            if (L->openupval) luaF_close(L, base);            for (aux = 0; ra+aux < L->top; aux++)  /* move frame down */              setobjs2s(base+aux-1, ra+aux);            (L->ci - 1)->top = L->top = base+aux;  /* correct top */            lua_assert(L->ci->state & CI_SAVEDPC);            (L->ci - 1)->u.l.savedpc = L->ci->u.l.savedpc;            (L->ci - 1)->u.l.tailcalls++;  /* one more call lost */            (L->ci - 1)->state = CI_SAVEDPC;            L->ci--;  /* remove new frame */            L->base = L->ci->base;          }          goto callentry;        }        break;      }      case OP_RETURN: {        CallInfo *ci = L->ci - 1;  /* previous function frame */        int b = GETARG_B(i);        if (b != 0) L->top = ra+b-1;        lua_assert(L->ci->state & CI_HASFRAME);        if (L->openupval) luaF_close(L, base);        L->ci->state = CI_SAVEDPC;  /* deactivate current function */        L->ci->u.l.savedpc = pc;        /* previous function was running `here'? */        if (!(ci->state & CI_CALLING)) {          lua_assert((ci->state & CI_C) || ci->u.l.pc != &pc);          return ra;  /* no: return */        }        else {  /* yes: continue its execution */          int nresults;          lua_assert(ci->u.l.pc == &pc &&                     ttisfunction(ci->base - 1) &&                     (ci->state & CI_SAVEDPC));          lua_assert(GET_OPCODE(*(ci->u.l.savedpc - 1)) == OP_CALL);          nresults = GETARG_C(*(ci->u.l.savedpc - 1)) - 1;          luaD_poscall(L, nresults, ra);          if (nresults >= 0) L->top = L->ci->top;          goto retentry;        }      }      case OP_FORLOOP: {        lua_Number step, idx, limit;        const TObject *plimit = ra+1;        const TObject *pstep = ra+2;        if (!ttisnumber(ra))          luaG_runerror(L, "`for' initial value must be a number");        if (!tonumber(plimit, ra+1))          luaG_runerror(L, "`for' limit must be a number");        if (!tonumber(pstep, ra+2))          luaG_runerror(L, "`for' step must be a number");        step = nvalue(pstep);        idx = nvalue(ra) + step;  /* increment index */        limit = nvalue(plimit);        if (step > 0 ? idx <= limit : idx >= limit) {          dojump(pc, GETARG_sBx(i));  /* jump back */          chgnvalue(ra, idx);  /* update index */        }        break;      }      case OP_TFORLOOP: {        int nvar = GETARG_C(i) + 1;        StkId cb = ra + nvar + 2;  /* call base */        setobjs2s(cb, ra);        setobjs2s(cb+1, ra+1);
开发者ID:TheWaWaR,项目名称:my-lua5.0,代码行数:67,


示例18: luaV_gettable

void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) {  int loop;  for (loop = 0; loop < MAXTAGLOOP; loop++) {    const TValue *tm = 0; /* LUA-VEC -- compiler gives a warning of uninitialized value on this so we set it to 0 */    if (ttistable(t)) {  /* `t' is a table? */      Table *h = hvalue(t);      const TValue *res = luaH_get(h, key); /* do a primitive get */      if (!ttisnil(res) ||  /* result is no nil? */          (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */        setobj2s(L, val, res);        return;      }      /* else will try the tag method */    }    else if (ttisvec(t)) { /* LUA-VEC -- vec[idx] operator */      /* issue: "index" may not be the correct arg for luaG_typeerror in here */      if (ttisnumber(key) &&   /* acessing vec by a number? */          (nvalue(key) >= 1 && nvalue(key) <= 4)) {  /* index is between 1-4? */        TValue res;        setnvalue(&res, vecvalue(t)[(int)nvalue(key)-1]);        setobj2s(L, val, &res);        return;      }      else if (ttisstring(key)) {  /* acessing vec by a string? */        if (tsvalue(key)->len == 1) {          /* accessing by a single component, such as vec.x */          TValue res;          switch (*getstr(tsvalue(key))) {            case 'x':  setnvalue(&res, vecvalue(t)[0]); break;            case 'y':  setnvalue(&res, vecvalue(t)[1]); break;            case 'z':  setnvalue(&res, vecvalue(t)[2]); break;            case 'w':  setnvalue(&res, vecvalue(t)[3]); break;            default:   luaG_typeerror(L, t, "index");          }          setobj2s(L, val, &res);          return;        }        else if (tsvalue(key)->len <= 4) {          /* accessing by swizzling, such as vec.xy, vec.xxyz etc. */          TValue res;          float v[4] = {0.0f,0.0f,0.0f,0.0f};          int i;          for (i = 0; i < (int)tsvalue(key)->len; ++i) {            switch (getstr(tsvalue(key))[i]) {              case 'x':  v[i] = vecvalue(t)[0]; break;              case 'y':  v[i] = vecvalue(t)[1]; break;              case 'z':  v[i] = vecvalue(t)[2]; break;              case 'w':  v[i] = vecvalue(t)[3]; break;              default:   luaG_typeerror(L, t, "index");            }          }          setvecvalue(&res, v[0], v[1], v[2], v[3]);          setobj2s(L, val, &res);          return;        }      }      luaG_typeerror(L, t, "index");    }    else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))      luaG_typeerror(L, t, "index");    if (ttisfunction(tm)) {      callTMres(L, val, tm, t, key);      return;    }    t = tm;  /* else repeat with `tm' */   }  luaG_runerror(L, "loop in gettable");}
开发者ID:MickW8s,项目名称:AppEasyCoreSDK,代码行数:68,



注:本文中的ttisfunction函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ ttisinteger函数代码示例
C++ tt_str_op函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。