Pioneer
Loading...
Searching...
No Matches
LuaVector2.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 _LUAVECTOR2_H
5#define _LUAVECTOR2_H
6
7#include "vector2.h"
8
9struct lua_State;
10
11namespace LuaVector2 {
12 extern const char LibName[];
13 extern const char TypeName[];
14
15 void Register(lua_State *L);
16 vector2d *PushNewToLua(lua_State *L);
17 inline void PushToLua(lua_State *L, const vector2d &v) { *PushNewToLua(L) = v; }
18 const vector2d *GetFromLua(lua_State *L, int idx);
19 vector2d *CheckFromLua(lua_State *L, int idx);
20
21 inline void PushToLuaF(lua_State *L, const vector2f &v) { PushToLua(L, vector2d(v)); }
22 inline vector2f CheckFromLuaF(lua_State *L, int idx) { return vector2f(*CheckFromLua(L, idx)); }
23} // namespace LuaVector2
24
25inline void pi_lua_generic_push(lua_State *l, const vector2d &value) { LuaVector2::PushToLua(l, value); }
26
27inline void pi_lua_generic_pull(lua_State *l, int index, vector2d &out)
28{
29 out = *LuaVector2::CheckFromLua(l, index);
30}
31
32inline bool pi_lua_strict_pull(lua_State *l, int index, vector2d &out)
33{
34 const vector2d *tmp = LuaVector2::GetFromLua(l, index);
35 if (tmp) {
36 out = *tmp;
37 return true;
38 }
39 return false;
40}
41
42#endif
void pi_lua_generic_push(lua_State *l, const vector2d &value)
Definition LuaVector2.h:25
void pi_lua_generic_pull(lua_State *l, int index, vector2d &out)
Definition LuaVector2.h:27
bool pi_lua_strict_pull(lua_State *l, int index, vector2d &out)
Definition LuaVector2.h:32
Definition LuaVector2.h:11
vector2d * CheckFromLua(lua_State *L, int idx)
Definition LuaVector2.cpp:269
vector2d * PushNewToLua(lua_State *L)
Definition LuaVector2.cpp:256
void Register(lua_State *L)
Definition LuaVector2.cpp:212
const char LibName[]
Definition LuaVector2.cpp:209
vector2f CheckFromLuaF(lua_State *L, int idx)
Definition LuaVector2.h:22
const vector2d * GetFromLua(lua_State *L, int idx)
Definition LuaVector2.cpp:264
void PushToLua(lua_State *L, const vector2d &v)
Definition LuaVector2.h:17
const char TypeName[]
Definition LuaVector2.cpp:210
void PushToLuaF(lua_State *L, const vector2f &v)
Definition LuaVector2.h:21
vector2< float > vector2f
Definition vector2.h:133
vector2< double > vector2d
Definition vector2.h:134