// Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp #include #include #include #include namespace Nz { inline unsigned int LuaImplQueryArg(const LuaInstance& instance, int index, SoundBufferParams* params, TypeTag) { instance.CheckType(index, Nz::LuaType_Table); params->forceMono = instance.CheckField("ForceMono", params->forceMono); return 1; } inline unsigned int LuaImplQueryArg(const LuaInstance& lua, int index, Vector3d* vec, TypeTag) { switch (lua.GetType(index)) { case Nz::LuaType_Number: if (index < 0 && index > -3) lua.Error("Vector3 expected, three numbers are required to convert it"); vec->Set(lua.CheckNumber(index), lua.CheckNumber(index + 1), lua.CheckNumber(index + 2)); return 3; case Nz::LuaType_Table: vec->Set(lua.CheckField("x", index), lua.CheckField("y", index), lua.CheckField("z", index)); return 3; default: vec->Set(*(*static_cast(lua.CheckUserdata(index, "Vector3")))); return 1; } } inline unsigned int LuaImplQueryArg(const LuaInstance& lua, int index, Vector3f* vec, TypeTag) { Vector3d vecDouble; unsigned int ret = LuaImplQueryArg(lua, index, &vecDouble, TypeTag()); vec->Set(vecDouble); return ret; } inline unsigned int LuaImplQueryArg(const LuaInstance& lua, int index, Vector3ui* vec, TypeTag) { Vector3d vecDouble; unsigned int ret = LuaImplQueryArg(lua, index, &vecDouble, TypeTag()); vec->Set(vecDouble); return ret; } inline int LuaImplReplyVal(const LuaInstance& instance, const SoundBuffer* val, TypeTag) { instance.PushInstance("SoundBuffer", val); return 1; } inline int LuaImplReplyVal(const LuaInstance& instance, Vector3d val, TypeTag) { instance.PushInstance("Vector3", val); return 1; } inline int LuaImplReplyVal(const LuaInstance& instance, Vector3f val, TypeTag) { instance.PushInstance("Vector3", val); return 1; } inline int LuaImplReplyVal(const LuaInstance& instance, Vector3ui val, TypeTag) { instance.PushInstance("Vector3", val); return 1; } }