LCOV - code coverage report
Current view: top level - src/script/lua_api - l_base.h (source / functions) Hit Total Coverage
Test: report Lines: 0 7 0.0 %
Date: 2015-07-11 18:23:49 Functions: 0 3 0.0 %

          Line data    Source code
       1             : /*
       2             : Minetest
       3             : Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
       4             : 
       5             : This program is free software; you can redistribute it and/or modify
       6             : it under the terms of the GNU Lesser General Public License as published by
       7             : the Free Software Foundation; either version 2.1 of the License, or
       8             : (at your option) any later version.
       9             : 
      10             : This program is distributed in the hope that it will be useful,
      11             : but WITHOUT ANY WARRANTY; without even the implied warranty of
      12             : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      13             : GNU Lesser General Public License for more details.
      14             : 
      15             : You should have received a copy of the GNU Lesser General Public License along
      16             : with this program; if not, write to the Free Software Foundation, Inc.,
      17             : 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      18             : */
      19             : 
      20             : #ifndef L_BASE_H_
      21             : #define L_BASE_H_
      22             : 
      23             : #include "common/c_types.h"
      24             : #include "common/c_internal.h"
      25             : 
      26             : extern "C" {
      27             : #include <lua.h>
      28             : #include <lauxlib.h>
      29             : }
      30             : 
      31             : class ScriptApiBase;
      32             : class Server;
      33             : class Environment;
      34             : class GUIEngine;
      35             : 
      36           0 : class ModApiBase {
      37             : 
      38             : public:
      39             :         static ScriptApiBase*   getScriptApiBase(lua_State *L);
      40             :         static Server*          getServer(lua_State *L);
      41             :         static Environment*     getEnv(lua_State *L);
      42             :         static GUIEngine*       getGuiEngine(lua_State *L);
      43             :         // When we are not loading the mod, this function returns "."
      44             :         static std::string      getCurrentModPath(lua_State *L);
      45             : 
      46             :         // Get an arbitrary subclass of ScriptApiBase
      47             :         // by using dynamic_cast<> on getScriptApiBase()
      48             :         template<typename T>
      49           0 :         static T* getScriptApi(lua_State *L) {
      50           0 :                 ScriptApiBase *scriptIface = getScriptApiBase(L);
      51           0 :                 T *scriptIfaceDowncast = dynamic_cast<T*>(scriptIface);
      52           0 :                 if (!scriptIfaceDowncast) {
      53           0 :                         throw LuaError("Requested unavailable ScriptApi - core engine bug!");
      54             :                 }
      55           0 :                 return scriptIfaceDowncast;
      56             :         }
      57             : 
      58             :         static bool registerFunction(lua_State *L,
      59             :                         const char* name,
      60             :                         lua_CFunction fct,
      61             :                         int top
      62             :                         );
      63             : };
      64             : 
      65             : #endif /* L_BASE_H_ */

Generated by: LCOV version 1.11