Added the pager API placeholder files
This commit is contained in:
+43
-32
@@ -1,34 +1,47 @@
|
|||||||
/*
|
/* $Id: linit.c,v 1.32, modified
|
||||||
** $Id: linit.c,v 1.32 2011/04/08 19:17:36 roberto Exp $
|
* Initialization of libraries for lua.c and other clients
|
||||||
** Initialization of libraries for lua.c and other clients
|
* See Copyright Notice in lua.h
|
||||||
** See Copyright Notice in lua.h
|
*
|
||||||
|
* If you embed Lua in your program and need to open the standard
|
||||||
|
* libraries, call luaL_openlibs in your program. If you need a
|
||||||
|
* different set of libraries, copy this file to your project and edit
|
||||||
|
* it to suit your needs.
|
||||||
|
*
|
||||||
|
* Modified for use in Tortuga, renamed to linit.cpp
|
||||||
|
* Modifications are released under the zlib license:
|
||||||
|
*
|
||||||
|
* Copyright: (c) Kayne Ruse 2014
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Modified for use in Tortuga, renamed to linit.cpp
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
** If you embed Lua in your program and need to open the standard
|
|
||||||
** libraries, call luaL_openlibs in your program. If you need a
|
|
||||||
** different set of libraries, copy this file to your project and edit
|
|
||||||
** it to suit your needs.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#define linit_c
|
#define linit_c
|
||||||
#define LUA_LIB
|
#define LUA_LIB
|
||||||
|
|
||||||
#include "lua/lua.hpp"
|
#include "lua/lua.hpp"
|
||||||
|
|
||||||
#include "region_api.hpp"
|
#include "region_api.hpp"
|
||||||
|
#include "pager_api.hpp"
|
||||||
|
|
||||||
|
//these libs are loaded by lua.c and are readily available to any Lua program
|
||||||
/*
|
|
||||||
** these libs are loaded by lua.c and are readily available to any Lua
|
|
||||||
** program
|
|
||||||
*/
|
|
||||||
static const luaL_Reg loadedlibs[] = {
|
static const luaL_Reg loadedlibs[] = {
|
||||||
/* Standard libs */
|
//Standard libs
|
||||||
{"_G", luaopen_base},
|
{"_G", luaopen_base},
|
||||||
{LUA_LOADLIBNAME, luaopen_package},
|
{LUA_LOADLIBNAME, luaopen_package},
|
||||||
{LUA_COLIBNAME, luaopen_coroutine},
|
{LUA_COLIBNAME, luaopen_coroutine},
|
||||||
@@ -40,33 +53,31 @@ static const luaL_Reg loadedlibs[] = {
|
|||||||
{LUA_MATHLIBNAME, luaopen_math},
|
{LUA_MATHLIBNAME, luaopen_math},
|
||||||
{LUA_DBLIBNAME, luaopen_debug},
|
{LUA_DBLIBNAME, luaopen_debug},
|
||||||
|
|
||||||
/* custom libs */
|
//custom libs
|
||||||
{LUA_REGIONLIBNAME, luaopen_regionapi},
|
{LUA_REGIONLIBNAME, luaopen_regionapi},
|
||||||
|
{LUA_PAGERLIBNAME, luaopen_pagerapi},
|
||||||
|
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
//these libs are preloaded and must be required before used
|
||||||
** these libs are preloaded and must be required before used
|
|
||||||
*/
|
|
||||||
static const luaL_Reg preloadedlibs[] = {
|
static const luaL_Reg preloadedlibs[] = {
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API void luaL_openlibs (lua_State *L) {
|
LUALIB_API void luaL_openlibs (lua_State *L) {
|
||||||
const luaL_Reg *lib;
|
const luaL_Reg *lib;
|
||||||
/* call open functions from 'loadedlibs' and set results to global table */
|
//call open functions from 'loadedlibs' and set results to global table
|
||||||
for (lib = loadedlibs; lib->func; lib++) {
|
for (lib = loadedlibs; lib->func; lib++) {
|
||||||
luaL_requiref(L, lib->name, lib->func, 1);
|
luaL_requiref(L, lib->name, lib->func, 1);
|
||||||
lua_pop(L, 1); /* remove lib */
|
lua_pop(L, 1); //remove lib
|
||||||
}
|
}
|
||||||
/* add open functions from 'preloadedlibs' into 'package.preload' table */
|
//add open functions from 'preloadedlibs' into 'package.preload' table
|
||||||
luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD");
|
luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD");
|
||||||
for (lib = preloadedlibs; lib->func; lib++) {
|
for (lib = preloadedlibs; lib->func; lib++) {
|
||||||
lua_pushcfunction(L, lib->func);
|
lua_pushcfunction(L, lib->func);
|
||||||
lua_setfield(L, -2, lib->name);
|
lua_setfield(L, -2, lib->name);
|
||||||
}
|
}
|
||||||
lua_pop(L, 1); /* remove _PRELOAD table */
|
lua_pop(L, 1); //remove _PRELOAD table
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2014
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#include "pager_api.hpp"
|
||||||
|
|
||||||
|
static int func(lua_State* L) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const luaL_Reg pagerlib[] = {
|
||||||
|
{"name", func},
|
||||||
|
{nullptr, nullptr}
|
||||||
|
};
|
||||||
|
|
||||||
|
LUAMOD_API int luaopen_pagerapi(lua_State* L) {
|
||||||
|
luaL_newlib(L, pagerlib);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2014
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#ifndef PAGERAPI_HPP_
|
||||||
|
#define PAGERAPI_HPP_
|
||||||
|
|
||||||
|
#include "lua/lua.hpp"
|
||||||
|
|
||||||
|
#define LUA_PAGERLIBNAME "pager"
|
||||||
|
LUAMOD_API int luaopen_pagerapi(lua_State* L);
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user