From d73d935c82bd805267fd66e462bfa15d5cca7832 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 13 Sep 2015 00:56:53 +0200 Subject: [PATCH] Lua/LuaInstance: Fix warning + optimizations Former-commit-id: 4191d942ed50058fba0d2a5ed533c41e993fd0eb --- include/Nazara/Lua/LuaInstance.inl | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/include/Nazara/Lua/LuaInstance.inl b/include/Nazara/Lua/LuaInstance.inl index f9c9d823e..6a1a35e24 100644 --- a/include/Nazara/Lua/LuaInstance.inl +++ b/include/Nazara/Lua/LuaInstance.inl @@ -18,22 +18,28 @@ double NzLuaImplQueryArg(NzLuaInstance& instance, unsigned int index, NzTypeTag< float NzLuaImplQueryArg(NzLuaInstance& instance, unsigned int index, NzTypeTag) { - return instance.CheckNumber(index); + return static_cast(instance.CheckNumber(index)); } int NzLuaImplQueryArg(NzLuaInstance& instance, unsigned int index, NzTypeTag) { - return instance.CheckInteger(index); + return static_cast(instance.CheckInteger(index)); } std::string NzLuaImplQueryArg(NzLuaInstance& instance, unsigned int index, NzTypeTag) { - return instance.CheckString(index); + std::size_t strLength = 0; + const char* str = instance.CheckString(index, &strLength); + + return std::string(str, strLength); } NzString NzLuaImplQueryArg(NzLuaInstance& instance, unsigned int index, NzTypeTag) { - return instance.CheckString(index); + std::size_t strLength = 0; + const char* str = instance.CheckString(index, &strLength); + + return NzString(str, strLength); } template