Changeset 165


Ignore:
Timestamp:
07/16/13 23:40:03 (12 years ago)
Author:
epyon
Message:
  • lua bindings - version choice made explicit, lua jit a toggle, not a version
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/lib/lua.hh

    r164 r165  
    3939
    4040#define NV_LUA_51     0
    41 #define NV_LUA_51_JIT 1
    42 #define NV_LUA_52     2
    43 
    44 #ifndef NV_LUA_VERSION
     41#define NV_LUA_52     1
     42
     43#if !defined(NV_LUA_VERSION)
    4544#       define NV_LUA_VERSION NV_LUA_52
     45#endif
     46#if defined(NV_LUA_JIT)
     47#       define NV_LUA_VERSION NV_LUA_51
    4648#endif
    4749
     
    6264#               define NV_LUA_PATH "lua5.1.so"
    6365#       endif
    64 #elif NV_LUA_VERSION == NV_LUA_51_JIT
     66#else
     67#       error "Unrecognized NV_LUA_VERSION!"
     68#endif
     69
     70#if defined(NV_LUA_JIT)
    6571#       if NV_PLATFORM == NV_WINDOWS
    6672#               define NV_LUA_PATH "luajit.dll"
     
    7076#               define NV_LUA_PATH "luajit.so"
    7177#       endif
    72 #else
    73 #       error "Unrecognized NV_LUA_VERSION!"
    7478#endif
    7579
     
    122126#       define LUA_REGISTRYINDEX        LUAI_FIRSTPSEUDOIDX
    123127#       define lua_upvalueindex(i)      (LUA_REGISTRYINDEX - (i))
    124 #else
     128#elif NV_LUA_VERSION == NV_LUA_51
    125129#       define LUA_REGISTRYINDEX      (-10000)
    126130#       define LUA_ENVIRONINDEX       (-10001)
    127131#       define LUA_GLOBALSINDEX       (-10002)
    128132#       define lua_upvalueindex(i)    (LUA_GLOBALSINDEX-(i))
     133#else
    129134#endif
    130135
    131136#define LUAL_BUFFERSIZE         BUFSIZ
    132 
    133137
    134138/* Types */
     
    157161  char short_src[LUA_IDSIZE]; /* (S) */
    158162  struct CallInfo *i_ci;  /* active function */
    159 #else
     163#elif NV_LUA_VERSION == NV_LUA_51
    160164  int nups;
    161165  int linedefined;      /* (S) */
     
    163167  char short_src[LUA_IDSIZE]; /* (S) */
    164168  int i_ci;  /* active function */
     169#else
    165170#endif
    166171};
     
    180185        char initb[LUAL_BUFFERSIZE];  /* initial buffer */
    181186} luaL_Buffer;
    182 #else
     187#elif NV_LUA_VERSION == NV_LUA_51
    183188typedef struct luaL_Buffer {
    184189        char *p;
     
    187192        char initb[LUAL_BUFFERSIZE];
    188193} luaL_Buffer;
     194#else
    189195#endif
    190196
     
    210216#       define LUA_ERRERR       6
    211217#       define LUA_ERRFILE  7
    212 #else
     218#elif NV_LUA_VERSION == NV_LUA_51
    213219#       define LUA_ERRERR       5
    214220#       define LUA_ERRFILE  6
     221#else
    215222#endif
    216223
     
    280287#if NV_LUA_VERSION == NV_LUA_52
    281288#       define LUA_HOOKTAILCALL 4
    282 #else
     289#elif NV_LUA_VERSION == NV_LUA_51
    283290#       define LUA_HOOKTAILRET 4
     291#else
    284292#endif
    285293
     
    291299
    292300/* lualib.h defines */
    293 #define LUA_COLIBNAME   "coroutine"
    294301#define LUA_TABLIBNAME  "table"
    295302#define LUA_IOLIBNAME   "io"
     
    300307#define LUA_LOADLIBNAME "package"
    301308#if NV_LUA_VERSION == NV_LUA_52
     309#       define LUA_COLIBNAME    "coroutine"
    302310#       define LUA_BITLIBNAME   "bit32"
    303311#endif
     
    312320#       define NV_LUA_FUN_51( rtype, fname, fparams )
    313321#       define NV_LUA_FUN_52 NV_LUA_FUN
    314 #else
     322#elif NV_LUA_VERSION == NV_LUA_51
    315323#       define NV_LUA_FUN_51 NV_LUA_FUN
     324#       define NV_LUA_FUN_52( rtype, fname, fparams )
     325#else
     326#       define NV_LUA_FUN_51( rtype, fname, fparams )
    316327#       define NV_LUA_FUN_52( rtype, fname, fparams )
    317328#endif
     
    347358#if NV_LUA_VERSION == NV_LUA_52
    348359#       define lua_pushglobaltable(L)  lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS)
    349 #else
     360#elif NV_LUA_VERSION == NV_LUA_51
    350361#       define lua_setglobal(L,s)     lua_setfield(L, LUA_GLOBALSINDEX, (s))
    351362#       define lua_getglobal(L,s)     lua_getfield(L, LUA_GLOBALSINDEX, (s))
     363#else
    352364#endif
    353365
     
    378390#       define luaL_addchar(B,c) ((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), ((B)->b[(B)->n++] = (c)))
    379391#       define luaL_addsize(B,s)        ((B)->n += (s))
    380 #else
     392#elif NV_LUA_VERSION == NV_LUA_51
    381393#       define luaL_addchar(B,c) ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), (*(B)->p++ = (char)(c)))
    382394#       define luaL_addsize(B,n)  ((B)->p += (n))
     395#else
    383396#endif
    384397
  • trunk/src/lib/lua.cc

    r164 r165  
    2727#       define NV_LUA_FUN_51( rtype, fname, fparams )
    2828#       define NV_LUA_FUN_52 NV_LUA_FUN
     29#elif NV_LUA_VERSION == NV_LUA_51
     30#       define NV_LUA_FUN_51 NV_LUA_FUN
     31#       define NV_LUA_FUN_52( rtype, fname, fparams )
    2932#else
    30 #       define NV_LUA_FUN_51 NV_LUA_FUN
    31 #       define NV_LUA_FUN_52( rtype, fname, fparams )
     33#       define NV_LUA_FUN_51( rtype, fname, fparams )
     34#       define NV_LUA_FUN_52( rtype, fname, fparams ) 
    3235#endif
    3336
     
    4851#               define NV_LUA_FUN_51( rtype, fname, fparams )
    4952#               define NV_LUA_FUN_52 NV_LUA_FUN
     53#       elif NV_LUA_VERSION == NV_LUA_51
     54#               define NV_LUA_FUN_51 NV_LUA_FUN
     55#               define NV_LUA_FUN_52( rtype, fname, fparams )
    5056#       else
    51 #               define NV_LUA_FUN_51 NV_LUA_FUN
     57#               define NV_LUA_FUN_51( rtype, fname, fparams )
    5258#               define NV_LUA_FUN_52( rtype, fname, fparams )
    5359#       endif
    5460
    55 #include <nv/lib/detail/lua_functions.inc>
     61#       include <nv/lib/detail/lua_functions.inc>
    5662
    57 #undef NV_LUA_FUN
    58 #undef NV_LUA_FUN_51
    59 #undef NV_LUA_FUN_52
     63#       undef NV_LUA_FUN
     64#       undef NV_LUA_FUN_51
     65#       undef NV_LUA_FUN_52
    6066        return true;
    6167}
Note: See TracChangeset for help on using the changeset viewer.