Pioneer
Loading...
Searching...
No Matches
LuaVector.h
Go to the documentation of this file.
1// Copyright © 2008-2023 Pioneer Developers. See AUTHORS.txt for details
2// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
3
4#ifndef _LUAVECTOR_H
5#define _LUAVECTOR_H
6
7#include "vector3.h"
8
9struct lua_State;
10
11namespace LuaVector {
12 extern const char LibName[];
13 extern const char TypeName[];
14
15 void Register(lua_State *L);
16 vector3d *PushNewToLua(lua_State *L);
17 inline void PushToLua(lua_State *L, const vector3d &v) { *PushNewToLua(L) = v; }
18 const vector3d *GetFromLua(lua_State *L, int idx);
19 vector3d *CheckFromLua(lua_State *L, int idx);
20
21 inline void PushToLuaF(lua_State *L, const vector3f &v) { PushToLua(L, vector3d(v)); }
22 inline vector3f CheckFromLuaF(lua_State *L, int idx) { return vector3f(*CheckFromLua(L, idx)); }
23} // namespace LuaVector
24
25inline void pi_lua_generic_push(lua_State *l, const vector3d &value) { LuaVector::PushToLua(l, value); }
26
27inline void pi_lua_generic_pull(lua_State *l, int index, vector3d &out)
28{
29 out = *LuaVector::CheckFromLua(l, index);
30}
31
32inline bool pi_lua_strict_pull(lua_State *l, int index, vector3d &out)
33{
34 const vector3d *tmp = LuaVector::GetFromLua(l, index);
35 if (tmp) {
36 out = *tmp;
37 return true;
38 }
39 return false;
40}
41
42#endif
void pi_lua_generic_pull(lua_State *l, int index, vector3d &out)
Definition LuaVector.h:27
bool pi_lua_strict_pull(lua_State *l, int index, vector3d &out)
Definition LuaVector.h:32
void pi_lua_generic_push(lua_State *l, const vector3d &value)
Definition LuaVector.h:25
Definition LuaVector.h:11
vector3d * CheckFromLua(lua_State *L, int idx)
Definition LuaVector.cpp:257
void Register(lua_State *L)
Definition LuaVector.cpp:210
void PushToLua(lua_State *L, const vector3d &v)
Definition LuaVector.h:17
void PushToLuaF(lua_State *L, const vector3f &v)
Definition LuaVector.h:21
const vector3d * GetFromLua(lua_State *L, int idx)
Definition LuaVector.cpp:252
vector3f CheckFromLuaF(lua_State *L, int idx)
Definition LuaVector.h:22
vector3d * PushNewToLua(lua_State *L)
Definition LuaVector.cpp:244
const char LibName[]
Definition LuaVector.cpp:207
const char TypeName[]
Definition LuaVector.cpp:208
vector3< float > vector3f
Definition vector3.h:289
vector3< double > vector3d
Definition vector3.h:290