FFI: Add ffi.load() and ffi.C default namespace.

This commit is contained in:
Mike Pall
2011-01-10 03:43:18 +01:00
parent d215747fd5
commit ddf6596333
11 changed files with 435 additions and 15 deletions

26
src/lj_clib.h Normal file
View File

@@ -0,0 +1,26 @@
/*
** FFI C library loader.
** Copyright (C) 2005-2011 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_CLIB_H
#define _LJ_CLIB_H
#include "lj_obj.h"
#if LJ_HASFFI
/* C library namespace. */
typedef struct CLibrary {
void *handle; /* Opaque handle for dynamic library loader. */
GCtab *cache; /* Cache for resolved symbols. Anchored in ud->env. */
} CLibrary;
LJ_FUNC TValue *lj_clib_index(lua_State *L, CLibrary *cl, GCstr *name);
LJ_FUNC void lj_clib_load(lua_State *L, GCtab *mt, GCstr *name, int global);
LJ_FUNC void lj_clib_unload(CLibrary *cl);
LJ_FUNC void lj_clib_default(lua_State *L, GCtab *mt);
#endif
#endif