"Fossies" - the Fresh Open Source Software Archive

Member "highlight-3.57-x64/src/include/Diluculum/LuaUtils.hpp" (12 May 2020, 3313 Bytes) of package /windows/www/highlight-3.57-x64.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /******************************************************************************\
    2 * LuaUtils.hpp                                                                 *
    3 * Some utilities related to Lua.                                               *
    4 *                                                                              *
    5 *                                                                              *
    6 * Copyright (C) 2005-2013 by Leandro Motta Barros.                             *
    7 *                                                                              *
    8 * Permission is hereby granted, free of charge, to any person obtaining a copy *
    9 * of this software and associated documentation files (the "Software"), to     *
   10 * deal in the Software without restriction, including without limitation the   *
   11 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or  *
   12 * sell copies of the Software, and to permit persons to whom the Software is   *
   13 * furnished to do so, subject to the following conditions:                     *
   14 *                                                                              *
   15 * The above copyright notice and this permission notice shall be included in   *
   16 * all copies or substantial portions of the Software.                          *
   17 *                                                                              *
   18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR   *
   19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,     *
   20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE *
   21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER       *
   22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING      *
   23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS *
   24 * IN THE SOFTWARE.                                                             *
   25 \******************************************************************************/
   26 
   27 #ifndef _DILUCULUM_LUA_UTILS_HPP_
   28 #define _DILUCULUM_LUA_UTILS_HPP_
   29 
   30 #include <Diluculum/LuaValue.hpp>
   31 
   32 namespace Diluculum
   33 {
   34 
   35    /** Converts and returns the element at index \c index on the stack to a
   36     *  \c LuaValue. This keeps the Lua stack untouched. Oh, yes, and it accepts
   37     *  both positive and negative indices, just like the standard functions on
   38     *  the Lua C API.
   39     *  @throw LuaTypeError If the element at \c index cannot be converted to a
   40     *         \c LuaValue. This can happen if the value at that position is, for
   41     *         example, a "Lua Thread" that is not supported by \c LuaValue.
   42     */
   43    LuaValue ToLuaValue (lua_State* state, int index);
   44 
   45    /** Pushes the value stored at \c value into the Lua stack of \c state. For
   46     *  most types, this is equivalent to simply calling the appropriate
   47     *  <tt>lua_push*()</tt> function. For other types, like tables and Lua
   48     *  functions, the implementation is more complicated.
   49     *  @note If \c value holds a table, then any entry that happens to have
   50     *        \c Nil as key will be ignored. (Since Lua does not support \c nil
   51     *        as a table index.)
   52     */
   53    void PushLuaValue (lua_State* state, const LuaValue& value);
   54 
   55 } // namespace Diluculum
   56 
   57 #endif // _DILUCULUM_LUA_UTILS_HPP_