]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/include/rocksdb/utilities/lua/rocks_lua_custom_library.h
1 // Copyright (c) 2016, Facebook, Inc. All rights reserved.
2 // This source code is licensed under both the GPLv2 (found in the
3 // COPYING file in the root directory) and Apache 2.0 License
4 // (found in the LICENSE.Apache file in the root directory).
16 namespace ROCKSDB_NAMESPACE
{
18 // A class that used to define custom C Library that is callable
20 class RocksLuaCustomLibrary
{
22 virtual ~RocksLuaCustomLibrary() {}
23 // The name of the C library. This name will also be used as the table
24 // (namespace) in Lua that contains the C library.
25 virtual const char* Name() const = 0;
27 // Returns a "static const struct luaL_Reg[]", which includes a list of
28 // C functions. Note that the last entry of this static array must be
29 // {nullptr, nullptr} as required by Lua.
31 // More details about how to implement Lua C libraries can be found
32 // in the official Lua document http://www.lua.org/pil/26.2.html
33 virtual const struct luaL_Reg
* Lib() const = 0;
35 // A function that will be called right after the library has been created
36 // and pushed on the top of the lua_State. This custom setup function
37 // allows developers to put additional table or constant values inside
38 // the same table / namespace.
39 virtual void CustomSetup(lua_State
* /*L*/) const {}
42 } // namespace ROCKSDB_NAMESPACE