"Fossies" - the Fresh Open Source Software Archive

Member "highlight-3.57-x64/src/core/Diluculum/InternalUtils.hpp" (12 May 2020, 4633 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 * InternalUtils.hpp                                                            *
    3 * Miscellaneous utilities used internally by Diluculum.                        *
    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_INTERNAL_UTILS_HPP_
   28 #define _DILUCULUM_INTERNAL_UTILS_HPP_
   29 
   30 #include <Diluculum/LuaState.hpp>
   31 
   32 
   33 namespace Diluculum
   34 {
   35    namespace Impl
   36    {
   37       /** Calls the function on the top of the stack, passing the given
   38        *  parameters. Returns the values returned by the called function.
   39        *  @param ls The Lua state from where the Lua function will be taken, and
   40        *         where the function will be executed.
   41        *  @param params The parameters to be passed to the function.
   42        */
   43       LuaValueList CallFunctionOnTop (lua_State* ls, const LuaValueList& params);
   44 
   45       /** Throws an exception if the status code passed as parameter corresponds
   46        *  to an error code from a function from the Lua API.  The exception
   47        *  thrown is of the proper type, that is, of the subclass of \c LuaError
   48        *  that best describes the error. Furthermore, the string associated with
   49        *  the exception (the \c what parameter) is set to whatever Lua returned
   50        *  as the error message.
   51        *  <p>If the number passed as parameter is 0 (which is the code for "no
   52        *  error"), the function does nothing.
   53        *  @param statusCode The return code for some Lua API function; that's
   54        *         the value we want to check for "errorness".
   55        *  @param ls The Lua state on which the function that generated the
   56        *         status code being tested was called. This is used just to get a
   57        *         nice error message, if an error did actually happen.
   58        *  @throw LuaRunTimeError If <tt>retCode == LUA_ERRRUN</tt>.
   59        *  @throw LuaFileError If <tt>retCode == LUA_ERRFILE</tt>.
   60        *  @throw LuaRunTimeError If <tt>retCode == LUA_ERRRUN</tt>.
   61        *  @throw LuaSyntaxError If <tt>retCode == LUA_ERRSYNTAX</tt>.
   62        *  @throw LuaMemoryError If <tt>retCode == LUA_ERRMEM</tt>.
   63        *  @throw LuaError If \c retCode is not a recognized Lua error code.
   64        */
   65       void ThrowOnLuaError (lua_State* ls, int statusCode);
   66 
   67       /** The \c lua_Writer used in the calls to \c lua_dump() when converting a
   68        * function implemented in Lua to a \c LuaFunction.
   69        */
   70       int LuaFunctionWriter(lua_State* luaState, const void* data, size_t size,
   71                             void* func);
   72 
   73       /** The \c lua_Reader used to get Lua bytecode from a \c LuaFunction. This
   74        *  is used by \c LuaState::call();
   75        */
   76       const char* LuaFunctionReader(lua_State* luaState, void* func,
   77                                     size_t* size);
   78    }
   79 
   80 } // namespace Diluculum
   81 
   82 
   83 #endif // _DILUCULUM_INTERNAL_UTILS_HPP_