2014-03-10 14:04:58 +08:00
|
|
|
/****************************************************************************
|
2018-01-29 16:25:32 +08:00
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-09 22:23:34 +08:00
|
|
|
https://axis-project.github.io/
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef __COCOS2DX_SCRIPTING_LUA_COCOS2DXSUPPORT_LUABAISCCONVERSIONS_H__
|
|
|
|
#define __COCOS2DX_SCRIPTING_LUA_COCOS2DXSUPPORT_LUABAISCCONVERSIONS_H__
|
|
|
|
|
2016-04-18 15:09:21 +08:00
|
|
|
#include <unordered_map>
|
|
|
|
#include <string>
|
|
|
|
|
2021-06-18 12:23:10 +08:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2016-03-20 21:53:44 +08:00
|
|
|
#include "scripting/lua-bindings/manual/tolua_fix.h"
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2016-03-20 21:53:44 +08:00
|
|
|
#include "scripting/lua-bindings/manual/Lua-BindingsExport.h"
|
2016-04-18 15:09:21 +08:00
|
|
|
#include "2d/CCLabel.h"
|
|
|
|
#include "2d/CCSprite.h"
|
|
|
|
#include "3d/CCBundle3D.h"
|
|
|
|
#include "base/CCValue.h"
|
|
|
|
#include "base/ccTypes.h"
|
|
|
|
#include "physics/CCPhysicsContact.h"
|
|
|
|
#include "physics/CCPhysicsJoint.h"
|
|
|
|
#include "physics/CCPhysicsShape.h"
|
|
|
|
#include "physics/CCPhysicsWorld.h"
|
2019-05-05 15:26:34 +08:00
|
|
|
#include "renderer/backend/Types.h"
|
|
|
|
#include "renderer/backend/VertexLayout.h"
|
2014-03-10 14:04:58 +08:00
|
|
|
|
2020-12-16 17:52:17 +08:00
|
|
|
#include "yasio/cxx17/string_view.hpp"
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
USING_NS_AX;
|
2014-03-10 14:04:58 +08:00
|
|
|
|
2021-06-18 12:23:10 +08:00
|
|
|
extern std::unordered_map<uintptr_t, const char*> g_luaType;
|
2021-12-25 10:04:45 +08:00
|
|
|
extern std::unordered_map<cxx17::string_view, const char*> g_typeCast;
|
2014-03-10 14:04:58 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
void luaval_to_native_err(lua_State* L, const char* msg, tolua_Error* err, const char* funcName = "");
|
2014-03-10 14:04:58 +08:00
|
|
|
#endif
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
#define LUA_PRECONDITION(condition, ...) \
|
|
|
|
if (!(condition)) \
|
|
|
|
{ \
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::log("lua: ERROR: File %s: Line: %d, Function: %s", __FILE__, __LINE__, __FUNCTION__); \
|
|
|
|
axis::log(__VA_ARGS__); \
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
2014-03-10 14:04:58 +08:00
|
|
|
|
2015-03-26 22:07:44 +08:00
|
|
|
/**
|
|
|
|
* @addtogroup lua
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2015-03-24 21:46:18 +08:00
|
|
|
/**
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the typename of userdata at the given acceptable index of stack is equal to type it return true, otherwise return
|
|
|
|
* false. If def != 0, lo could greater than the top index of stack, return value is true. If the value of the given
|
|
|
|
* index is nil, return value also is true.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param type the typename used to judge.
|
2015-03-27 11:13:28 +08:00
|
|
|
* @param def whether has default value.
|
2021-12-25 10:04:45 +08:00
|
|
|
* @return Return true if the typename of userdata at the given acceptable index of stack is equal to type, otherwise
|
|
|
|
* return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
extern bool luaval_is_usertype(lua_State* L, int lo, const char* type, int def);
|
2014-03-10 14:04:58 +08:00
|
|
|
// to native
|
2015-03-27 15:27:08 +08:00
|
|
|
|
2015-03-24 21:46:18 +08:00
|
|
|
/**
|
|
|
|
* @name luaval_to_native
|
2021-12-25 10:04:45 +08:00
|
|
|
* The following function are all used to convert the Lua values at the given acceptable index to the corresponding c++
|
|
|
|
*values. If the Lua values can be converted the return value is true, otherwise return false. If it happens error
|
|
|
|
*during the conversion process, it outputs the error msg in the console to provide information about the name of
|
|
|
|
*calling function, the typename of value at the given acceptable index, and so on.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @{
|
|
|
|
**/
|
|
|
|
|
|
|
|
/**
|
2016-10-05 13:08:56 +08:00
|
|
|
* Get a unsigned short value from the given acceptable index of stack.
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the value at the given acceptable index of stack is a number or a string convertible to a number it returns true,
|
|
|
|
* otherwise returns false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param outValue the pointer to store the unsigned short value converted from the Lua value.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2021-12-25 10:04:45 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a number or a string convertible to a
|
|
|
|
* number, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2014-07-21 09:39:41 +08:00
|
|
|
extern bool luaval_to_ushort(lua_State* L, int lo, unsigned short* outValue, const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
2019-05-05 15:26:34 +08:00
|
|
|
/**
|
2021-12-25 10:04:45 +08:00
|
|
|
* Get a float value from the given acceptable index of stack.
|
|
|
|
* If the value at the given acceptable index of stack is a number or a string convertible to a number it returns true,
|
|
|
|
* otherwise returns false.
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
|
|
|
* @param lo the given acceptable index of stack.
|
|
|
|
* @param outValue the pointer to store the float value converted from the Lua value.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
|
|
|
* @return Return true if the value at the given acceptable index of stack is a number or a string convertible to a
|
|
|
|
* number, otherwise return false.
|
|
|
|
*/
|
2019-05-05 15:26:34 +08:00
|
|
|
extern bool luaval_to_float(lua_State* L, int lo, float* outValue, const char* funcName = "");
|
|
|
|
|
2015-03-24 21:46:18 +08:00
|
|
|
/**
|
2016-10-05 13:08:56 +08:00
|
|
|
* Get a int value from the given acceptable index of stack.
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the value at the given acceptable index of stack is a number or a string convertible to a number it returns true,
|
|
|
|
* otherwise returns false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param outValue the pointer to store the int value converted from the Lua value.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2021-12-25 10:04:45 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a number or a string convertible to a
|
|
|
|
* number, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
extern bool luaval_to_int32(lua_State* L, int lo, int* outValue, const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2016-10-05 13:08:56 +08:00
|
|
|
* Get a unsigned int value from the given acceptable index of stack.
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the value at the given acceptable index of stack is a number or a string convertible to a number it returns true,
|
|
|
|
* otherwise returns false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param outValue the pointer to store the unsigned int value converted from the Lua value.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2021-12-25 10:04:45 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a number or a string convertible to a
|
|
|
|
* number, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2014-07-21 09:39:41 +08:00
|
|
|
extern bool luaval_to_uint32(lua_State* L, int lo, unsigned int* outValue, const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2016-10-05 13:08:56 +08:00
|
|
|
* Get a uint16_t value from the given acceptable index of stack.
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the value at the given acceptable index of stack is a number or a string convertible to a number it returns true,
|
|
|
|
* otherwise returns false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param outValue the pointer to store the uint16_t value converted from the Lua value.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2021-12-25 10:04:45 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a number or a string convertible to a
|
|
|
|
* number, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
extern bool luaval_to_uint16(lua_State* L, int lo, uint16_t* outValue, const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2016-10-05 13:08:56 +08:00
|
|
|
* Get a boolean value from the given acceptable index of stack.
|
|
|
|
* If the value at the given acceptable index of stack has type boolean it returns true, otherwise returns false.
|
2015-03-24 21:46:18 +08:00
|
|
|
* Any Lua value is different from false and nil, the value of conversion is true, otherwise the value is false.
|
2016-10-05 13:08:56 +08:00
|
|
|
* If the lo is non-valid index, the value of conversion also is false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param outValue the pointer to store the boolean value converted from the Lua value.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2021-12-25 10:04:45 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a number or a string convertible to a
|
|
|
|
* number, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2022-07-15 19:17:01 +08:00
|
|
|
extern AX_LUA_DLL bool luaval_to_boolean(lua_State* L, int lo, bool* outValue, const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2016-10-05 13:08:56 +08:00
|
|
|
* Get a double value from the given acceptable index of stack.
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the value at the given acceptable index of stack is a number or a string convertible to a number it returns true,
|
|
|
|
* otherwise returns false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param outValue the pointer to store the double value converted from the Lua value.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2021-12-25 10:04:45 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a number or a string convertible to a
|
|
|
|
* number, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
extern bool luaval_to_number(lua_State* L, int lo, double* outValue, const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2016-10-05 13:08:56 +08:00
|
|
|
* Get a long long value from the given acceptable index of stack.
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the value at the given acceptable index of stack is a number or a string convertible to a number it returns true,
|
|
|
|
* otherwise returns false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param outValue the pointer to store the long long value converted from the Lua value.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2021-12-25 10:04:45 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a number or a string convertible to a
|
|
|
|
* number, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
extern bool luaval_to_long_long(lua_State* L, int lo, long long* outValue, const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2016-10-05 13:08:56 +08:00
|
|
|
* Get a std::string value from the given acceptable index of stack.
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the value at the given acceptable index of stack is a string or a number convertible to a string it returns true,
|
|
|
|
* otherwise returns false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param outValue the pointer to store std::string value converted from the Lua value.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2021-12-25 10:04:45 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a string or a number convertible to a
|
|
|
|
* string, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2022-07-15 19:17:01 +08:00
|
|
|
extern AX_LUA_DLL bool luaval_to_std_string(lua_State* L, int lo, std::string* outValue, const char* funcName = "");
|
|
|
|
extern AX_LUA_DLL bool luaval_to_std_string_view(lua_State* L,
|
2021-12-25 10:04:45 +08:00
|
|
|
int lo,
|
|
|
|
cxx17::string_view* outValue,
|
|
|
|
const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2016-10-05 13:08:56 +08:00
|
|
|
* Get a ssize_t value from the given acceptable index of stack.
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the value at the given acceptable index of stack is a number or a string convertible to a number it returns true,
|
|
|
|
* otherwise returns false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param outValue the pointer to store the ssize_t value converted from the Lua value.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2021-12-25 10:04:45 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a number or a string convertible to a
|
|
|
|
* number, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
extern bool luaval_to_ssize_t(lua_State* L, int lo, ssize_t* outValue, const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2016-10-05 13:08:56 +08:00
|
|
|
* Get a Size object value from the given acceptable index of stack.
|
|
|
|
* If the value at the given acceptable index of stack is a table it returns true, otherwise returns false.
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the table has the `width` and `height` key and the corresponding values are not nil, this function would assign
|
|
|
|
* the values to the corresponding members of outValue. Otherwise, the value of members of outValue would be 0.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param outValue the pointer to a Size object which stores the values from the Lua table.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
extern bool luaval_to_size(lua_State* L, int lo, Size* outValue, const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2016-10-05 13:08:56 +08:00
|
|
|
* Get a Rect object value from the given acceptable index of stack.
|
|
|
|
* If the value at the given acceptable index of stack is a table it returns true, otherwise returns false.
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the table has the `x`,`y`,`width` and `height` keys and the corresponding values are not nil, this function would
|
|
|
|
* assign the values to the corresponding members of outValue. Otherwise, the value of members of outValue would be 0.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param outValue the pointer to a Rect object which stores the values from the Lua table.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
extern bool luaval_to_rect(lua_State* L, int lo, Rect* outValue, const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2016-10-05 13:08:56 +08:00
|
|
|
* Get a Color3B object value from the given acceptable index of stack.
|
|
|
|
* If the value at the given acceptable index of stack is a table it returns true, otherwise returns false.
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the table has the `r`,`g` and `b` keys and the corresponding values are not nil, this function would assign the
|
|
|
|
* values to the corresponding members of outValue. Otherwise, the value of members of outValue would be 0.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param outValue the pointer to a Color3B object which stores the values from the Lua table.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2022-07-15 19:17:01 +08:00
|
|
|
extern AX_LUA_DLL bool luaval_to_color3b(lua_State* L, int lo, Color3B* outValue, const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2016-10-05 13:08:56 +08:00
|
|
|
* Get a Color4B object value from the given acceptable index of stack.
|
|
|
|
* If the value at the given acceptable index of stack is a table it returns true, otherwise returns false.
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the table has the `r`,`g`, `b` and 'a' keys and the corresponding values are not nil, this function would assign
|
|
|
|
* the values to the corresponding members of outValue. Otherwise, the value of members of outValue would be 0.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param outValue the pointer to a Color4B object which stores the values from the Lua table.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
extern bool luaval_to_color4b(lua_State* L, int lo, Color4B* outValue, const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2016-10-05 13:08:56 +08:00
|
|
|
* Get a Color4F object value from the given acceptable index of stack.
|
|
|
|
* If the value at the given acceptable index of stack is a table it returns true, otherwise returns false.
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the table has the `r`,`g`, `b` and 'a' keys and the corresponding values are not nil, this function would assign
|
|
|
|
* the values to the corresponding members of outValue. Otherwise, the value of members of outValue would be 0.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param outValue the pointer to a Color4F object which stores the values from the Lua table.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
extern bool luaval_to_color4f(lua_State* L, int lo, Color4F* outValue, const char* funcName = "");
|
2022-07-15 19:17:01 +08:00
|
|
|
#if AX_USE_PHYSICS
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2016-10-05 13:08:56 +08:00
|
|
|
* Get a PhysicsMaterial object value from the given acceptable index of stack.
|
|
|
|
* If the value at the given acceptable index of stack is a table it returns true, otherwise returns false.
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the table has the `density`,`restitution` and 'friction' keys and the corresponding values are not nil, this
|
|
|
|
* function would assign the values to the corresponding members of outValue. Otherwise, the value of members of
|
|
|
|
* outValue would be 0.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param outValue the pointer to a axis::PhysicsMaterial object which stores the values from the Lua table.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
extern bool luaval_to_physics_material(lua_State* L,
|
|
|
|
int lo,
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PhysicsMaterial* outValue,
|
2021-12-25 10:04:45 +08:00
|
|
|
const char* funcName = "");
|
2022-07-15 19:17:01 +08:00
|
|
|
#endif //#if AX_USE_PHYSICS
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2016-10-05 13:08:56 +08:00
|
|
|
* If the value at the given acceptable index of stack is a table it returns true, otherwise returns false.
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the table has the `a`, `b`, `c`, `d` , `tx` and `ty` keys and the corresponding values are not nil, this function
|
|
|
|
* would assign the values to the corresponding members of outValue. Otherwise, the value of members of outValue would
|
|
|
|
* be 0.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param outValue the pointer to a AffineTransform object which stores the values from the Lua table.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
extern bool luaval_to_affinetransform(lua_State* L, int lo, AffineTransform* outValue, const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2016-10-05 13:08:56 +08:00
|
|
|
* Get a FontDefinition object value from the given acceptable index of stack.
|
|
|
|
* If the value at the given acceptable index of stack is a table it returns true, otherwise returns false.
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the table has the `fontName`, `fontSize`, `fontAlignmentH`, `fontAlignmentV` , `fontFillColor` ,`fontDimensions`,
|
|
|
|
* `shadowEnabled` and `strokeEnabled` keys and the corresponding values are not nil, this function would assign the
|
|
|
|
* values to the corresponding members of outValue. Otherwise, the value of members of outValue would be 0. If the
|
|
|
|
* values about `shadowEnabled` and `strokeEnabled` are true, there would be more keys such as `shadowOffset`,
|
|
|
|
* `shadowBlur` ,`shadowOpacity`, `strokeColor`, and `strokeSize`.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param outValue the pointer to a FontDefinition object which stores the values from the Lua table.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
extern bool luaval_to_fontdefinition(lua_State* L, int lo, FontDefinition* outValue, const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2016-10-05 13:08:56 +08:00
|
|
|
* Get a Mat object value from the given acceptable index of stack.
|
|
|
|
* If the value at the given acceptable index of stack is a table it returns true, otherwise returns false.
|
2015-03-24 21:46:18 +08:00
|
|
|
* The table is array-table which begin the index starts at 1.
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param outValue the pointer to a Mat object which stores the values from the Lua table.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
extern bool luaval_to_mat4(lua_State* L, int lo, axis::Mat4* outValue, const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2016-10-05 13:08:56 +08:00
|
|
|
* Get a array of Vec2 object from the given acceptable index of stack.
|
|
|
|
* If the value at the given acceptable index of stack is a table it returns true, otherwise returns false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param points the pointer to a array of Vec2 object which stores the values from the Lua table.
|
|
|
|
* @param numPoints a int pointer to store the size of a Vec2 object array.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
extern bool luaval_to_array_of_vec2(lua_State* L,
|
|
|
|
int lo,
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2** points,
|
2021-12-25 10:04:45 +08:00
|
|
|
int* numPoints,
|
|
|
|
const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Get a axis::ValueVector object value by the argc numbers of Lua values in the stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
|
|
|
* @param argc the numbers of Lua values in the stack.
|
|
|
|
* @param ret the pointer to a ValueVector object which stores the values from the Lua table.
|
|
|
|
* @return Return false if argc equal to 0 or L equal to nullptr, otherwise return true.
|
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
extern bool luavals_variadic_to_ccvaluevector(lua_State* L, int argc, axis::ValueVector* ret);
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2016-10-05 13:08:56 +08:00
|
|
|
* Get a Vec2 object value from the given acceptable index of stack.
|
|
|
|
* If the value at the given acceptable index of stack is a table it returns true, otherwise returns false.
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the table has the `x`,and 'y' keys and the corresponding values are not nil, this function would assign the values
|
|
|
|
* to the corresponding members of outValue. Otherwise, the value of members of outValue would be 0.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param outValue the pointer to a Vec2 object which stores the values from the Lua table.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
extern bool luaval_to_vec2(lua_State* L, int lo, axis::Vec2* outValue, const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2016-10-05 13:08:56 +08:00
|
|
|
* Get a Vec3 object value from the given acceptable index of stack.
|
|
|
|
* If the value at the given acceptable index of stack is a table it returns true, otherwise returns false.
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the table has the `x`, 'y' and `z` keys and the corresponding values are not nil, this function would assign the
|
|
|
|
* values to the corresponding members of outValue. Otherwise, the value of members of outValue would be 0.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param outValue the pointer to a Vec3 object which stores the values from the Lua table.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
extern bool luaval_to_vec3(lua_State* L, int lo, axis::Vec3* outValue, const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2016-10-05 13:08:56 +08:00
|
|
|
* Get a Vec4 object value from the given acceptable index of stack.
|
|
|
|
* If the value at the given acceptable index of stack is a table it returns true, otherwise returns false.
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the table has the `x`, 'y', `z` and `w` keys and the corresponding values are not nil, this function would assign
|
|
|
|
* the values to the corresponding members of outValue. Otherwise, the value of members of outValue would be 0.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param outValue the pointer to a Vec4 object which stores the values from the Lua table.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
extern bool luaval_to_vec4(lua_State* L, int lo, axis::Vec4* outValue, const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2016-10-05 13:08:56 +08:00
|
|
|
* Get a BlendFunc object value from the given acceptable index of stack.
|
|
|
|
* If the value at the given acceptable index of stack is a table it returns true, otherwise returns false.
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the table has the `src` and 'dst' keys and the corresponding values are not nil, this function would assign the
|
|
|
|
* values to the corresponding members of outValue. Otherwise, the value of members of outValue would be 0.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param outValue the pointer to a BlendFunc object which stores the values from the Lua table.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
extern bool luaval_to_blendfunc(lua_State* L, int lo, axis::BlendFunc* outValue, const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2016-10-05 13:08:56 +08:00
|
|
|
* Get a TTFConfig object value from the given acceptable index of stack.
|
|
|
|
* If the value at the given acceptable index of stack is a table it returns true, otherwise returns false.
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the table has the `fontFilePath`, `fontSize`, `glyphs`, `customGlyphs`, `distanceFieldEnabled` and 'outlineSize'
|
|
|
|
* keys and the corresponding values are not nil, this function would assign the values to the corresponding members of
|
|
|
|
* outValue. Otherwise, the value of members of outValue would be given the default value.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param outValue the pointer to a TTFConfig object which stores the values from the Lua table.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
extern bool luaval_to_ttfconfig(lua_State* L, int lo, axis::TTFConfig* outValue, const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2016-10-05 13:08:56 +08:00
|
|
|
* Get a Vec2 object value from the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* At current, the Point is typedef of Vec2.
|
|
|
|
* @see luaval_to_vec2
|
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
static inline bool luaval_to_point(lua_State* L, int lo, axis::Vec2* outValue, const char* funcName = "")
|
2014-04-28 16:28:15 +08:00
|
|
|
{
|
2014-05-15 15:39:15 +08:00
|
|
|
return luaval_to_vec2(L, lo, outValue);
|
2014-04-28 16:28:15 +08:00
|
|
|
}
|
|
|
|
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_DEPRECATED_ATTRIBUTE static inline bool luaval_to_kmMat4(lua_State* L,
|
2021-12-25 10:04:45 +08:00
|
|
|
int lo,
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Mat4* outValue,
|
2021-12-25 10:04:45 +08:00
|
|
|
const char* funcName = "")
|
2014-04-28 16:28:15 +08:00
|
|
|
{
|
2014-05-15 15:39:15 +08:00
|
|
|
return luaval_to_mat4(L, lo, outValue);
|
2014-04-28 16:28:15 +08:00
|
|
|
}
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_DEPRECATED_ATTRIBUTE static inline bool luaval_to_array_of_Point(lua_State* L,
|
2021-12-25 10:04:45 +08:00
|
|
|
int lo,
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2** points,
|
2021-12-25 10:04:45 +08:00
|
|
|
int* numPoints,
|
|
|
|
const char* funcName = "")
|
2014-04-28 16:28:15 +08:00
|
|
|
{
|
2014-05-15 15:39:15 +08:00
|
|
|
return luaval_to_array_of_vec2(L, lo, points, numPoints);
|
2014-04-28 16:28:15 +08:00
|
|
|
}
|
|
|
|
|
2015-03-24 21:46:18 +08:00
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Get a axis::Vector of type T objects by the argc numbers of Lua values in the stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
|
|
|
* @param argc the numbers of Lua values in the stack.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param ret a axis::Vector of type T objects.
|
2022-07-12 21:31:54 +08:00
|
|
|
* @return Return false if argc equal to 0 , L equal to nullptr or the Lua userdata at the index isn't `ax.Ref` type,
|
2021-12-25 10:04:45 +08:00
|
|
|
* otherwise return true.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2014-03-10 14:04:58 +08:00
|
|
|
template <class T>
|
2022-07-11 17:50:21 +08:00
|
|
|
bool luavals_variadic_to_ccvector(lua_State* L, int argc, axis::Vector<T>* ret)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == L || argc == 0)
|
2014-03-10 14:04:58 +08:00
|
|
|
return false;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
for (int i = 0; i < argc; i++)
|
|
|
|
{
|
|
|
|
if (lua_isuserdata(L, i + 2))
|
|
|
|
{
|
|
|
|
tolua_Error err;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, i + 2, "ax.Ref", 0, &err))
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
|
|
|
ok = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
T obj = static_cast<T>(tolua_tousertype(L, i + 2, nullptr));
|
|
|
|
ret->pushBack(obj);
|
|
|
|
}
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
2015-03-24 21:46:18 +08:00
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Get a axis::Vector of type T objects from a Lua table in the stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param ret a axis::Vector of type T objects.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2014-03-10 14:04:58 +08:00
|
|
|
template <class T>
|
2022-07-11 17:50:21 +08:00
|
|
|
bool luaval_to_ccvector(lua_State* L, int lo, axis::Vector<T>* ret, const char* funcName = "")
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L || nullptr == ret)
|
|
|
|
return false;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_istable(L, lo, 0, &tolua_err))
|
2014-03-10 14:04:58 +08:00
|
|
|
ok = false;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
size_t len = lua_objlen(L, lo);
|
2014-10-19 17:00:05 +08:00
|
|
|
for (size_t i = 0; i < len; i++)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
|
|
|
lua_pushnumber(L, i + 1);
|
|
|
|
lua_gettable(L, lo);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
if (lua_isnil(L, -1) || !lua_isuserdata(L, -1))
|
|
|
|
{
|
|
|
|
lua_pop(L, 1);
|
|
|
|
continue;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
T cobj = static_cast<T>(tolua_tousertype(L, -1, NULL));
|
2014-03-10 14:04:58 +08:00
|
|
|
if (NULL != cobj)
|
|
|
|
ret->pushBack(cobj);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
2015-03-24 21:46:18 +08:00
|
|
|
/**
|
|
|
|
* Get a pointer points to a std::vector<std::string> from a Lua array table in the stack.
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param ret a pointer points to a std::vector<std::string>.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_LUA_DLL bool luaval_to_std_vector_string(lua_State* L,
|
2021-12-25 10:04:45 +08:00
|
|
|
int lo,
|
|
|
|
std::vector<std::string>* ret,
|
|
|
|
const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_LUA_DLL bool luaval_to_std_vector_string_view(lua_State* L,
|
2021-12-28 16:06:23 +08:00
|
|
|
int lo,
|
|
|
|
std::vector<std::string_view>* ret,
|
|
|
|
const char* funcName = "");
|
2021-12-28 15:46:32 +08:00
|
|
|
|
2015-03-24 21:46:18 +08:00
|
|
|
/**
|
|
|
|
* Get a pointer points to a std::vector<std::int> from a Lua array table in the stack.
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param ret a pointer points to a std::vector<int>.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2014-07-21 09:39:41 +08:00
|
|
|
bool luaval_to_std_vector_int(lua_State* L, int lo, std::vector<int>* ret, const char* funcName = "");
|
2014-03-10 14:04:58 +08:00
|
|
|
|
2015-03-24 21:46:18 +08:00
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Get a pointer points to a axis::Map whose key/value pair is string value and T object from a Lua hash-map table in
|
2021-12-25 10:04:45 +08:00
|
|
|
* the stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param ret a pointer points to a axis::Map whose key/value pair is string value and T object.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2014-03-10 14:04:58 +08:00
|
|
|
template <class T>
|
2022-07-11 17:50:21 +08:00
|
|
|
bool luaval_to_ccmap_string_key(lua_State* L, int lo, axis::Map<std::string, T>* ret, const char* funcName = "")
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == L || nullptr == ret || lua_gettop(L) < lo)
|
2014-03-10 14:04:58 +08:00
|
|
|
return false;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
bool ok = true;
|
|
|
|
if (!tolua_istable(L, lo, 0, &tolua_err))
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
luaval_to_native_err(L, "#ferror:", &tolua_err);
|
2014-03-10 14:04:58 +08:00
|
|
|
#endif
|
|
|
|
ok = false;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
std::string stringKey = "";
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushnil(L); /* first key L: lotable ..... nil */
|
|
|
|
while (0 != lua_next(L, lo)) /* L: lotable ..... key value */
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
|
|
|
if (!lua_isstring(L, -2))
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pop(L, 1); /* removes 'value'; keep 'key' for next iteration*/
|
2014-03-10 14:04:58 +08:00
|
|
|
continue;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
if (lua_isnil(L, -1) || !lua_isuserdata(L, -1))
|
|
|
|
{
|
|
|
|
lua_pop(L, 1);
|
|
|
|
continue;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
luaval_to_std_string(L, -2, &stringKey);
|
2021-12-25 10:04:45 +08:00
|
|
|
T obj = static_cast<T>(tolua_tousertype(L, -1, NULL));
|
2014-03-10 14:04:58 +08:00
|
|
|
if (nullptr != obj)
|
|
|
|
ret->insert(stringKey, obj);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pop(L, 1); /* L: lotable ..... key */
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
2015-03-24 21:46:18 +08:00
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Get a axis::Value object from the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* The type of Lua value at the index could be a Lua table, LUA_TSTRING, LUA_TBOOLEAN and LUA_TNUMBER.
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param ret a pointer points to a axis::Value object.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
|
|
|
* @return Return true if the L and ret is not nullptr,otherwise return false.
|
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
extern bool luaval_to_ccvalue(lua_State* L, int lo, axis::Value* ret, const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Get a axis::ValueMap object from the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* The type of Lua value at the index should be a Lua table.
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param ret a pointer points to a axis::ValueMap object.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
|
|
|
* @return Return true if the type of Lua value at the index is a Lua table, otherwise return false.
|
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
extern bool luaval_to_ccvaluemap(lua_State* L, int lo, axis::ValueMap* ret, const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Get a axis::ValueMapIntKey object from the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* The type of Lua value at the index should be a Lua table.
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param ret a pointer points to a axis::ValueMapIntKey object.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
|
|
|
* @return Return true if the type of Lua value at the index is a Lua table, otherwise return false.
|
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
extern bool luaval_to_ccvaluemapintkey(lua_State* L, int lo, axis::ValueMapIntKey* ret, const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Get a axis::ValueVector object from the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* The type of Lua value at the index should be a Lua array table.
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param ret a pointer points to a axis::ValueVector object.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
|
|
|
* @return Return true if the type of Lua value at the index is a Lua table, otherwise return false.
|
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
extern bool luaval_to_ccvaluevector(lua_State* L, int lo, axis::ValueVector* ret, const char* funcName = "");
|
2014-03-10 14:04:58 +08:00
|
|
|
|
2015-03-24 21:46:18 +08:00
|
|
|
/**
|
2016-10-05 13:08:56 +08:00
|
|
|
* Get a Type T object from the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param type a string pointer points to the type name.
|
|
|
|
* @param ret the pointer points to a Type T object.
|
|
|
|
* @return Return true if the type of Lua value at the index is a Lua userdata, otherwise return false.
|
|
|
|
*/
|
2014-03-10 14:04:58 +08:00
|
|
|
template <class T>
|
2015-05-20 10:26:54 +08:00
|
|
|
bool luaval_to_object(lua_State* L, int lo, const char* type, T** ret, const char* funcName = "")
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == L || lua_gettop(L) < lo)
|
2014-03-10 14:04:58 +08:00
|
|
|
return false;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
if (!luaval_is_usertype(L, lo, type, 0))
|
|
|
|
return false;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
*ret = static_cast<T*>(tolua_tousertype(L, lo, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-05-20 10:26:54 +08:00
|
|
|
if (nullptr == *ret)
|
2022-07-16 10:43:05 +08:00
|
|
|
AXLOG("Warning: %s argument %d is invalid native object(nullptr)", funcName, lo);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-03-24 21:46:18 +08:00
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Get a axis::MeshVertexAttrib object value from the given acceptable index of stack.
|
2016-10-05 13:08:56 +08:00
|
|
|
* If the value at the given acceptable index of stack is a table it returns true, otherwise returns false.
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the table has the `size`, `type`, `vertexAttrib`, `vertexAttrib` and `attribSizeBytes` keys and the corresponding
|
|
|
|
* values are not nil, this function would assign the values to the corresponding members of outValue.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param ret the pointer to a axis::MeshVertexAttrib object which stores the values from the Lua table.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
extern bool luaval_to_mesh_vertex_attrib(lua_State* L,
|
|
|
|
int lo,
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::MeshVertexAttrib* ret,
|
2021-12-25 10:04:45 +08:00
|
|
|
const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a pointer points to a std::vector<float> from a Lua array table in the stack.
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param ret a pointer points to a std::vector<float>.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2014-07-21 09:39:41 +08:00
|
|
|
extern bool luaval_to_std_vector_float(lua_State* L, int lo, std::vector<float>* ret, const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a pointer points to a std::vector<unsigned shortt> from a Lua array table in the stack.
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param ret a pointer points to a std::vector<unsigned short>.
|
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
extern bool luaval_to_std_vector_ushort(lua_State* L,
|
|
|
|
int lo,
|
|
|
|
std::vector<unsigned short>* ret,
|
|
|
|
const char* funcName = "");
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Get a axis::Quaternion object value from the given acceptable index of stack.
|
2016-10-05 13:08:56 +08:00
|
|
|
* If the value at the given acceptable index of stack is a table it returns true, otherwise returns false.
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the table has the `x`, `y`, `z` and `w` keys and the corresponding values are not nil, this function would assign
|
|
|
|
* the values to the corresponding members of outValue.Otherwise, the value of members of outValue would be 0.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param outValue the pointer to a axis::Quaternion object which stores the values from the Lua table.
|
2015-03-24 21:46:18 +08:00
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
extern bool luaval_to_quaternion(lua_State* L, int lo, axis::Quaternion* outValue, const char* funcName = "");
|
2014-03-10 14:04:58 +08:00
|
|
|
|
2015-03-28 14:59:47 +08:00
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Get a axis::Texture2D::TexParams object value from the given acceptable index of stack.
|
2016-10-05 13:08:56 +08:00
|
|
|
* If the value at the given acceptable index of stack is a table it returns true, otherwise returns false.
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the table has the `minFilter`, `magFilter`, `wrapS` and `wrapT` keys and the corresponding values are not nil,
|
|
|
|
* this function would assign the values to the corresponding members of outValue.Otherwise, the value of members of
|
|
|
|
* outValue would be 0.
|
2015-03-28 14:59:47 +08:00
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param outValue the pointer to a axis::Quaternion object which stores the values from the Lua table.
|
2015-03-28 14:59:47 +08:00
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-03-28 14:59:47 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
extern bool luaval_to_texparams(lua_State* L,
|
|
|
|
int lo,
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Texture2D::TexParams* outValue,
|
2021-12-25 10:04:45 +08:00
|
|
|
const char* funcName = "");
|
2015-04-28 18:19:57 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Get a axis::V3F_C4B_T2F object value from the given acceptable index of stack.
|
2016-10-05 13:08:56 +08:00
|
|
|
* If the value at the given acceptable index of stack is a table it returns true, otherwise returns false.
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the table has the `vertices`, `colors`, and `texCoords` keys and the corresponding values are not nil, this
|
|
|
|
* function would assign the values to the corresponding members of outValue.
|
2015-04-28 18:19:57 +08:00
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param outValue the pointer to a axis::V3F_C4B_T2F object which stores the values from the Lua table.
|
2015-04-28 18:19:57 +08:00
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-04-28 18:19:57 +08:00
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
extern bool luaval_to_v3f_c4b_t2f(lua_State* L, int lo, axis::V3F_C4B_T2F* outValue, const char* funcName = "");
|
2015-04-28 18:19:57 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Get a axis::Tex2F object value from the given acceptable index of stack.
|
2016-10-05 13:08:56 +08:00
|
|
|
* If the value at the given acceptable index of stack is a table it returns true, otherwise returns false.
|
2021-12-25 10:04:45 +08:00
|
|
|
* If the table has the `u`, and `v` keys and the corresponding values are not nil, this function would assign the
|
|
|
|
* values to the corresponding members of outValue.Otherwise, the value of members of outValue would be 0.
|
2015-04-28 18:19:57 +08:00
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param outValue the pointer to a axis::Tex2F object which stores the values from the Lua table.
|
2015-04-28 18:19:57 +08:00
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-04-28 18:19:57 +08:00
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
extern bool luaval_to_tex2f(lua_State* L, int lo, axis::Tex2F* outValue, const char* funcName = "");
|
2015-04-28 18:19:57 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Get a pointer points to a std::vector<axis::V3F_C4B_T2F> from a Lua array table in the stack.
|
2015-04-28 18:19:57 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param ret a pointer points to a std::vector<axis::V3F_C4B_T2F>.
|
2015-04-28 18:19:57 +08:00
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-04-28 18:19:57 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
extern bool luaval_to_std_vector_v3f_c4b_t2f(lua_State* L,
|
|
|
|
int lo,
|
2022-07-11 17:50:21 +08:00
|
|
|
std::vector<axis::V3F_C4B_T2F>* ret,
|
2021-12-25 10:04:45 +08:00
|
|
|
const char* funcName = "");
|
2015-04-28 18:19:57 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Get a pointer points to a std::vector<axis::Vec2> from a Lua array table in the stack.
|
2015-04-28 18:19:57 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param ret a pointer points to a std::vector<axis::Vec2>.
|
2015-04-28 18:19:57 +08:00
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-04-28 18:19:57 +08:00
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
extern bool luaval_to_std_vector_vec2(lua_State* L, int lo, std::vector<axis::Vec2>* ret, const char* funcName = "");
|
2015-05-15 09:28:03 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Get a pointer points to a std::vector<axis::Vec3> from a Lua array table in the stack.
|
2015-05-15 09:28:03 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @param lo the given acceptable index of stack.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param ret a pointer points to a std::vector<axis::Vec3>.
|
2015-05-15 09:28:03 +08:00
|
|
|
* @param funcName the name of calling function, it is used for error output in the debug model.
|
2016-10-05 13:08:56 +08:00
|
|
|
* @return Return true if the value at the given acceptable index of stack is a table, otherwise return false.
|
2015-05-15 09:28:03 +08:00
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
extern bool luaval_to_std_vector_vec3(lua_State* L, int lo, std::vector<axis::Vec3>* ret, const char* funcName = "");
|
2015-03-28 14:59:47 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
extern bool luaval_to_std_map_string_string(lua_State* L,
|
|
|
|
int lo,
|
2021-12-28 15:46:32 +08:00
|
|
|
hlookup::string_map<std::string>* ret,
|
2021-12-25 10:04:45 +08:00
|
|
|
const char* funcName);
|
2015-07-26 07:40:34 +08:00
|
|
|
|
2015-03-24 21:46:18 +08:00
|
|
|
/**@}**/
|
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
// from native
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @name native_to_luaval
|
2021-12-25 10:04:45 +08:00
|
|
|
* The following function are all used to convert native c++ values to the corresponding Lua values, then push it into
|
|
|
|
*the Lua stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @{
|
|
|
|
**/
|
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a table converted from a axis::Vec2 object into the Lua stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* The format of table as follows: {x=numberValue1, y=numberValue2}
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param vec2 a axis::Vec2 object.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
extern int vec2_to_luaval(lua_State* L, const axis::Vec2& vec2);
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a table converted from a axis::Vec3 object into the Lua stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* The format of table as follows: {x=numberValue1, y=numberValue2, z=numberValue3}
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param vec3 a axis::Vec3 object.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
extern int vec3_to_luaval(lua_State* L, const axis::Vec3& vec3);
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a table converted from a axis::Vec4 object into the Lua stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* The format of table as follows: {x=numberValue1, y=numberValue2, z=numberValue3, w=numberValue4}
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param vec4 a axis::Vec4 object.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
extern int vec4_to_luaval(lua_State* L, const axis::Vec4& vec4);
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a table converted from a axis::Vec2 array into the Lua stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* The table size is count.
|
|
|
|
* The format of table as follows: {vec2_table1,vec2_table2,...,vec2_tableCount}.
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param points a pointer points to a axis::Vec2 array.
|
|
|
|
* @param count the number of axis::Vec2 object should be converted to a Lua table and push into the Lua stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
extern void vec2_array_to_luaval(lua_State* L, const axis::Vec2* points, int count);
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a table converted from a axis::Size object into the Lua stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* The format of table as follows: {width=numberValue1, height=numberValue2}
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param sz a axis::Size object.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
extern void size_to_luaval(lua_State* L, const Size& sz);
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a table converted from a axis::Rect object into the Lua stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* The format of table as follows: {x=numberValue1, y=numberValue2, width=numberValue3, height=numberValue4}
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param rt a axis::Rect object.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
extern void rect_to_luaval(lua_State* L, const Rect& rt);
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a table converted from a axis::Color3B object into the Lua stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* The format of table as follows: {r=numberValue1, g=numberValue2, b=numberValue3}
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param cc a axis::Color3B object.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2022-07-15 19:17:01 +08:00
|
|
|
extern AX_LUA_DLL void color3b_to_luaval(lua_State* L, const Color3B& cc);
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a table converted from a axis::Color4B object into the Lua stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* The format of table as follows: {r=numberValue1, g=numberValue2, b=numberValue3, a=numberValue4}
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param cc a axis::Color4B object.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
extern void color4b_to_luaval(lua_State* L, const Color4B& cc);
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a table converted from a axis::Color4F object into the Lua stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* The format of table as follows: {r=numberValue1, g=numberValue2, b=numberValue3, a=numberValue4}
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param cc a axis::Color4F object.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
extern void color4f_to_luaval(lua_State* L, const Color4F& cc);
|
2022-07-15 19:17:01 +08:00
|
|
|
#if AX_USE_PHYSICS
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a table converted from a axis::PhysicsMaterial object into the Lua stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* The format of table as follows: {density=numberValue1, restitution=numberValue2, friction=numberValue3}
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param pm a axis::PhysicsMaterial object.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
extern void physics_material_to_luaval(lua_State* L, const PhysicsMaterial& pm);
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a table converted from a axis::PhysicsRayCastInfo object into the Lua stack.
|
2021-12-25 10:04:45 +08:00
|
|
|
* The format of table as follows: {shape=userdata, start=vec2_table1, ended=vec2_table2, contact=vec2_table3,
|
|
|
|
* normal=vec2_table4, fraction=numberValue}
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param info a axis::PhysicsRayCastInfo object.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2014-03-10 14:04:58 +08:00
|
|
|
extern void physics_raycastinfo_to_luaval(lua_State* L, const PhysicsRayCastInfo& info);
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a table converted from a axis::PhysicsContactData object into the Lua stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* The format of table as follows: {points=vec2_array_table, normal=vec2_table, POINT_MAX=numberValue}
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param data a axis::PhysicsContactData object.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2014-03-10 14:04:58 +08:00
|
|
|
extern void physics_contactdata_to_luaval(lua_State* L, const PhysicsContactData* data);
|
2022-07-15 19:17:01 +08:00
|
|
|
#endif //#if AX_USE_PHYSICS
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a table converted from a axis::AffineTransform object into the Lua stack.
|
2021-12-25 10:04:45 +08:00
|
|
|
* The format of table as follows: {a=numberValue1, b=numberValue2, c=numberValue3, d=numberValue4,tx=numberValue5,
|
|
|
|
* ty=numberValue6}
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param inValue a axis::AffineTransform object.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
extern void affinetransform_to_luaval(lua_State* L, const AffineTransform& inValue);
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a table converted from a axis::FontDefinition object into the Lua stack.
|
2021-12-25 10:04:45 +08:00
|
|
|
* The format of table as follows: {fontName=stringValue1, fontSize=numberValue1, fontAlignmentH=numberValue2,
|
|
|
|
* fontAlignmentV=numberValue3,fontFillColor=color3b_table1, fontDimensions=size_table1, shadowEnabled=booleanValue1,
|
|
|
|
* shadowOffset=size_table2, shadowBlur=numberValue4, shadowOpacity=numberValue5, shadowEnabled=booleanValue2,
|
|
|
|
* strokeColor=color3b_table2, strokeSize=size_table3}
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param inValue a axis::FontDefinition object.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
extern void fontdefinition_to_luaval(lua_State* L, const FontDefinition& inValue);
|
2015-03-27 15:27:08 +08:00
|
|
|
|
2015-03-24 21:46:18 +08:00
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a table converted from a axis::Mat4 object into the Lua stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* The format of table as follows: {numberValue1, numberValue2, ..., numberValue16}
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param mat a axis::Mat4 object.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
extern void mat4_to_luaval(lua_State* L, const axis::Mat4& mat);
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a table converted from a axis::BlendFunc object into the Lua stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* The format of table as follows: {src=numberValue1, dst=numberValue2}
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param func a axis::BlendFunc object.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
extern void blendfunc_to_luaval(lua_State* L, const axis::BlendFunc& func);
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a table converted from a axis::TTFConfig object into the Lua stack.
|
2021-12-25 10:04:45 +08:00
|
|
|
* The format of table as follows: {fontFilePath=stringValue1, fontSize=numberValue1, glyphs=numberValue2,
|
|
|
|
* customGlyphs=stringValue2,distanceFieldEnabled=booleanValue1, outlineSize=numberValue3}
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param config a axis::TTFConfig object.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
extern void ttfconfig_to_luaval(lua_State* L, const axis::TTFConfig& config);
|
2015-03-24 21:46:18 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
static inline void point_to_luaval(lua_State* L, const axis::Vec2& pt)
|
2014-04-28 16:28:15 +08:00
|
|
|
{
|
2014-05-15 15:39:15 +08:00
|
|
|
vec2_to_luaval(L, pt);
|
2014-04-28 16:28:15 +08:00
|
|
|
}
|
|
|
|
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_DEPRECATED_ATTRIBUTE static inline void points_to_luaval(lua_State* L, const axis::Vec2* points, int count)
|
2014-04-28 16:28:15 +08:00
|
|
|
{
|
2014-05-15 15:39:15 +08:00
|
|
|
vec2_array_to_luaval(L, points, count);
|
2014-04-28 16:28:15 +08:00
|
|
|
}
|
|
|
|
|
2021-09-20 18:18:52 +08:00
|
|
|
/**
|
|
|
|
* Get the real typename for the specified typename.
|
|
|
|
* Because all override functions wouldn't be bound,so we must use `typeid` to get the real class name.
|
|
|
|
*
|
|
|
|
* @param ret the pointer points to a type T object.
|
|
|
|
* @param type the string pointer points to specified typename.
|
|
|
|
* @return return the pointer points to the real typename, or nullptr.
|
|
|
|
*/
|
|
|
|
template <class T>
|
2021-12-25 10:04:45 +08:00
|
|
|
const char* getLuaTypeName(T* ret, const char* defaultTypeName)
|
2021-09-20 18:18:52 +08:00
|
|
|
{
|
|
|
|
if (nullptr != ret)
|
|
|
|
{
|
|
|
|
auto typeName = typeid(*ret).name();
|
|
|
|
auto iter = g_luaType.find(reinterpret_cast<uintptr_t>(typeName));
|
2021-12-25 10:04:45 +08:00
|
|
|
if (g_luaType.end() != iter)
|
2021-09-20 18:18:52 +08:00
|
|
|
{
|
|
|
|
return iter->second;
|
|
|
|
}
|
|
|
|
else
|
2021-12-25 10:04:45 +08:00
|
|
|
{ // unlike logic, for windows dll only
|
2021-09-20 18:18:52 +08:00
|
|
|
cxx17::string_view strkey(typeName);
|
|
|
|
auto iter2 = g_typeCast.find(strkey);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (iter2 != g_typeCast.end())
|
|
|
|
{
|
2021-09-20 18:18:52 +08:00
|
|
|
g_luaType.emplace(reinterpret_cast<uintptr_t>(typeName), iter2->second);
|
|
|
|
return iter2->second;
|
|
|
|
}
|
|
|
|
return defaultTypeName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-03-24 21:46:18 +08:00
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a table converted from a axis::Vector object into the Lua stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* The format of table as follows: {userdata1, userdata2, ..., userdataVectorSize}
|
2022-07-11 17:50:21 +08:00
|
|
|
* The object in the axis::Vector which would be pushed into the table should be Ref type.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param inValue a axis::Vector object.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2014-03-10 14:04:58 +08:00
|
|
|
template <class T>
|
2022-07-11 17:50:21 +08:00
|
|
|
void ccvector_to_luaval(lua_State* L, const axis::Vector<T>& inValue)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
|
|
|
lua_newtable(L);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
if (nullptr == L)
|
|
|
|
return;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
int indexTable = 1;
|
|
|
|
for (const auto& obj : inValue)
|
|
|
|
{
|
|
|
|
if (nullptr == obj)
|
|
|
|
continue;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
if (nullptr != dynamic_cast<axis::Ref*>(obj))
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2021-06-18 12:23:10 +08:00
|
|
|
auto luaTypeName = getLuaTypeName(obj, nullptr);
|
|
|
|
if (luaTypeName)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
|
|
|
lua_pushnumber(L, (lua_Number)indexTable);
|
2021-12-25 10:04:45 +08:00
|
|
|
int ID = (obj) ? (int)obj->_ID : -1;
|
2014-03-10 14:04:58 +08:00
|
|
|
int* luaID = (obj) ? &obj->_luaID : NULL;
|
2021-12-25 10:04:45 +08:00
|
|
|
toluafix_pushusertype_ccobject(L, ID, luaID, (void*)obj, luaTypeName);
|
2014-03-10 14:04:58 +08:00
|
|
|
lua_rawset(L, -3);
|
|
|
|
++indexTable;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-24 21:46:18 +08:00
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a table converted from a axis::Map object into the Lua stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* The format of table as follows: {name1=userdata1, name2=userdata2, ..., nameMapSize=userdataMapSize}
|
2022-07-11 17:50:21 +08:00
|
|
|
* The object in the axis::Map which would be pushed into the table should be Ref type.
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param v a axis::Map object.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2014-03-10 14:04:58 +08:00
|
|
|
template <class T>
|
2022-07-11 17:50:21 +08:00
|
|
|
void ccmap_string_key_to_luaval(lua_State* L, const axis::StringMap<T>& v)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
|
|
|
lua_newtable(L);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == L)
|
2014-03-10 14:04:58 +08:00
|
|
|
return;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
for (auto iter = v.begin(); iter != v.end(); ++iter)
|
|
|
|
{
|
2021-12-28 15:46:32 +08:00
|
|
|
auto& key = iter->first;
|
2021-12-28 16:06:23 +08:00
|
|
|
T obj = iter->second;
|
2022-07-11 17:50:21 +08:00
|
|
|
if (nullptr != dynamic_cast<axis::Ref*>(obj))
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
auto name = reinterpret_cast<uintptr_t>(typeid(*obj).name());
|
2014-03-10 14:04:58 +08:00
|
|
|
auto typeIter = g_luaType.find(name);
|
2021-06-18 12:23:10 +08:00
|
|
|
|
|
|
|
auto luaTypeName = getLuaTypeName(obj, nullptr);
|
|
|
|
if (luaTypeName)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2014-07-25 09:44:17 +08:00
|
|
|
lua_pushstring(L, key.c_str());
|
2021-12-25 10:04:45 +08:00
|
|
|
int ID = (obj) ? (int)obj->_ID : -1;
|
2014-03-10 14:04:58 +08:00
|
|
|
int* luaID = (obj) ? &obj->_luaID : NULL;
|
2021-12-25 10:04:45 +08:00
|
|
|
toluafix_pushusertype_ccobject(L, ID, luaID, (void*)obj, luaTypeName);
|
2014-03-10 14:04:58 +08:00
|
|
|
lua_rawset(L, -3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-24 21:46:18 +08:00
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a Lua value converted from a axis::Value object into the Lua stack.
|
|
|
|
* Different axis::Value type, different Lua value pushed into the Lua stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* Value::Type::BOOLEAN -> push a boolean value into the Lua stack.
|
|
|
|
* Value::Type::FLOAT,Value::Type::DOUBLE -> push a number value into the Lua stack.
|
|
|
|
* Value::Type::INTEGER -> push a integer value into the Lua stack.
|
|
|
|
* Value::Type::STRING -> push a string value into the Lua stack.
|
|
|
|
* Value::Type::VECTOR -> push a array table into the Lua stack.
|
|
|
|
* Value::Type::MAP -> push a hash table into the Lua stack.
|
|
|
|
* Value::Type::INT_KEY_MAP -> push a hash table into the Lua stack.
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param inValue a axis::Value object.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
void ccvalue_to_luaval(lua_State* L, const axis::Value& inValue);
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a Lua hash table converted from a axis::ValueMap object into the Lua stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* The type of value of the key/value pair would be boolean,number, integer, string, array table, hash table.
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param inValue a axis::ValueMap object.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
void ccvaluemap_to_luaval(lua_State* L, const axis::ValueMap& inValue);
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a Lua hash table converted from a axis::ValueMapIntKey object into the Lua stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* The type of value of the key/value pair would be boolean,number, integer, string, array table, hash table.
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param inValue a axis::ValueMapIntKey object.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
void ccvaluemapintkey_to_luaval(lua_State* L, const axis::ValueMapIntKey& inValue);
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a Lua array table converted from a axis::ValueVector object into the Lua stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* The type of value of the key/value pair would be boolean,number, integer, string, array table, hash table.
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param inValue a axis::ValueVector object.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
void ccvaluevector_to_luaval(lua_State* L, const axis::ValueVector& inValue);
|
2014-03-10 14:04:58 +08:00
|
|
|
|
2015-03-24 21:46:18 +08:00
|
|
|
/**@}**/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Push the native object by userdata format into the Lua stack by typename.
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
|
|
|
* @param type the string pointer points to the typename.
|
|
|
|
* @param ret the native object pointer.
|
|
|
|
*/
|
2014-03-10 14:04:58 +08:00
|
|
|
template <class T>
|
2021-12-25 10:04:45 +08:00
|
|
|
void object_to_luaval(lua_State* L, const char* type, T* ret)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr != ret)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
if (std::is_base_of<axis::Ref, T>::value)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2014-07-21 14:37:46 +08:00
|
|
|
// use c style cast, T may not polymorphic
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Ref* dynObject = (axis::Ref*)(ret);
|
2021-12-25 10:04:45 +08:00
|
|
|
int ID = (int)(dynObject->_ID);
|
|
|
|
int* luaID = &(dynObject->_luaID);
|
|
|
|
toluafix_pushusertype_ccobject(L, ID, luaID, (void*)ret, type);
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_pushusertype(L, (void*)ret, getLuaTypeName(ret, type));
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lua_pushnil(L);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-24 21:46:18 +08:00
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a table converted from a axis::MeshVertexAttrib object into the Lua stack.
|
2021-12-25 10:04:45 +08:00
|
|
|
* The format of table as follows: {size=numberValue1, type=numberValue2, vertexAttrib=numberValue3,
|
|
|
|
* attribSizeBytes=numberValue4}
|
2015-03-24 21:46:18 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param inValue a axis::MeshVertexAttrib object.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
void mesh_vertex_attrib_to_luaval(lua_State* L, const axis::MeshVertexAttrib& inValue);
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Push a Lua array table converted from a std::vector<std::string> into the Lua stack.
|
|
|
|
* The format of table as follows: {stringValue1, stringValue2, ..., stringVectorSize}
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
|
|
|
* @param inValue a std::vector<std::string> value.
|
|
|
|
*/
|
2014-05-20 18:09:04 +08:00
|
|
|
void ccvector_std_string_to_luaval(lua_State* L, const std::vector<std::string>& inValue);
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Push a Lua array table converted from a std::vector<int> into the Lua stack.
|
|
|
|
* The format of table as follows: {numberValue1, numberValue2, ..., numberVectorSize}
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-01-11 18:15:34 +08:00
|
|
|
* @param inValue a std::vector<int> value.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2014-05-20 18:09:04 +08:00
|
|
|
void ccvector_int_to_luaval(lua_State* L, const std::vector<int>& inValue);
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Push a Lua array table converted from a std::vector<float> into the Lua stack.
|
|
|
|
* The format of table as follows: {numberValue1, numberValue2, ..., numberVectorSize}
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-01-11 18:15:34 +08:00
|
|
|
* @param inValue a std::vector<float> value.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2014-05-20 18:09:04 +08:00
|
|
|
void ccvector_float_to_luaval(lua_State* L, const std::vector<float>& inValue);
|
2015-03-24 21:46:18 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Push a Lua array table converted from a std::vector<unsigned short> into the Lua stack.
|
|
|
|
* The format of table as follows: {numberValue1, numberValue2, ..., numberVectorSize}
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-01-11 18:15:34 +08:00
|
|
|
* @param inValue a std::vector<float> value.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2014-05-20 18:09:04 +08:00
|
|
|
void ccvector_ushort_to_luaval(lua_State* L, const std::vector<unsigned short>& inValue);
|
|
|
|
|
2015-03-24 21:46:18 +08:00
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a table converted from a axis::Quaternion object into the Lua stack.
|
2015-03-24 21:46:18 +08:00
|
|
|
* The format of table as follows: {x=numberValue1, y=numberValue2, z=numberValue3, w=numberValue4}
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param inValue a axis::Quaternion object.
|
2015-03-24 21:46:18 +08:00
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
void quaternion_to_luaval(lua_State* L, const axis::Quaternion& inValue);
|
2015-03-26 22:07:44 +08:00
|
|
|
|
2015-03-28 14:59:47 +08:00
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a table converted from a axis::Texture2D::TexParams object into the Lua stack.
|
2021-12-25 10:04:45 +08:00
|
|
|
* The format of table as follows: {minFilter=numberValue1, magFilter=numberValue2, wrapS=numberValue3,
|
|
|
|
* wrapT=numberValue4}
|
2015-03-28 14:59:47 +08:00
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param inValue a axis::Texture2D::TexParams object.
|
2015-03-28 14:59:47 +08:00
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
void texParams_to_luaval(lua_State* L, const axis::Texture2D::TexParams& inValue);
|
2015-03-28 14:59:47 +08:00
|
|
|
|
2015-05-15 16:25:07 +08:00
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* Push a Lua array table converted from a std::vector<axis::Vec3> into the Lua stack.
|
2015-05-15 16:25:07 +08:00
|
|
|
* The format of table as follows: {vec3Value1, vec3Value2, ..., vec3ValueSize}
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2022-07-11 17:50:21 +08:00
|
|
|
* @param inValue a std::vector<axis::Vec3> value.
|
2015-05-15 16:25:07 +08:00
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
void std_vector_vec3_to_luaval(lua_State* L, const std::vector<axis::Vec3>& inValue);
|
2015-07-26 07:40:34 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Push a Lua dict table converted from a std::map<std::string, std::string> into the Lua stack.
|
|
|
|
*
|
|
|
|
* @param L the current lua_State.
|
2016-01-11 18:15:34 +08:00
|
|
|
* @param inValue a std::map<std::string, std::string> value.
|
2015-07-26 07:40:34 +08:00
|
|
|
*/
|
|
|
|
void std_map_string_string_to_luaval(lua_State* L, const std::map<std::string, std::string>& inValue);
|
|
|
|
|
2015-11-25 23:03:25 +08:00
|
|
|
// Follow 2 function is added for Cocos Studio to make lua lib can be compile as dynamic library
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_LUA_DLL extern bool luaval_to_node(lua_State* L, int lo, const char* type, axis::Node** node);
|
|
|
|
AX_LUA_DLL extern void node_to_luaval(lua_State* L, const char* type, axis::Node* node);
|
2015-11-25 23:03:25 +08:00
|
|
|
|
2019-05-05 15:26:34 +08:00
|
|
|
/**
|
2021-12-25 10:04:45 +08:00
|
|
|
* convert lua object VertexLayout to native object
|
|
|
|
*/
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_LUA_DLL bool luaval_to_vertexLayout(lua_State* L,
|
2021-12-25 10:04:45 +08:00
|
|
|
int pos,
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::backend::VertexLayout& outLayout,
|
2021-12-25 10:04:45 +08:00
|
|
|
const char* message);
|
2019-05-05 15:26:34 +08:00
|
|
|
|
|
|
|
/**
|
2021-12-25 10:04:45 +08:00
|
|
|
* convert lua object SamplerDescriptor to native object
|
|
|
|
*/
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_LUA_DLL bool luaval_to_samplerDescriptor(lua_State* L,
|
2021-12-25 10:04:45 +08:00
|
|
|
int pos,
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::backend::SamplerDescriptor& desc,
|
2021-12-25 10:04:45 +08:00
|
|
|
const char* message);
|
2019-05-05 15:26:34 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* convert lua object to axis::backend::UniformLocation
|
2021-12-25 10:04:45 +08:00
|
|
|
*/
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_LUA_DLL bool luaval_to_uniformLocation(lua_State* L,
|
2021-12-25 10:04:45 +08:00
|
|
|
int pos,
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::backend::UniformLocation& desc,
|
2021-12-25 10:04:45 +08:00
|
|
|
const char* message);
|
2019-05-05 15:26:34 +08:00
|
|
|
|
|
|
|
/**
|
2022-07-11 17:50:21 +08:00
|
|
|
* convert axis::backend::UniformLocation to lua object
|
2021-12-25 10:04:45 +08:00
|
|
|
*/
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_LUA_DLL void uniformLocation_to_luaval(lua_State* L, const axis::backend::UniformLocation& desc);
|
2019-05-05 15:26:34 +08:00
|
|
|
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_LUA_DLL void program_activeattrs_to_luaval(lua_State* L,
|
2022-07-11 17:50:21 +08:00
|
|
|
const hlookup::string_map<axis::backend::AttributeBindInfo>& map);
|
2019-05-05 15:26:34 +08:00
|
|
|
|
2015-03-26 22:07:44 +08:00
|
|
|
// end group
|
|
|
|
/// @}
|
2021-12-25 10:04:45 +08:00
|
|
|
#endif //__COCOS2DX_SCRIPTING_LUA_COCOS2DXSUPPORT_LUABAISCCONVERSIONS_H__
|