| 29 | |
| 30 | namespace sol { |
| 31 | struct stack_proxy_base : public proxy_base<stack_proxy_base> { |
| 32 | private: |
| 33 | lua_State* m_L; |
| 34 | int m_index; |
| 35 | |
| 36 | public: |
| 37 | stack_proxy_base() : m_L(nullptr), m_index(0) { |
| 38 | } |
| 39 | stack_proxy_base(lua_State* L_, int index_) : m_L(L_), m_index(index_) { |
| 40 | } |
| 41 | |
| 42 | template <typename T> |
| 43 | decltype(auto) get() const { |
| 44 | return stack::get<T>(m_L, stack_index()); |
| 45 | } |
| 46 | |
| 47 | template <typename T> |
| 48 | bool is() const { |
| 49 | return stack::check<T>(m_L, stack_index()); |
| 50 | } |
| 51 | |
| 52 | template <typename T> |
| 53 | decltype(auto) as() const { |
| 54 | return get<T>(); |
| 55 | } |
| 56 | |
| 57 | type get_type() const noexcept { |
| 58 | return type_of(lua_state(), stack_index()); |
| 59 | } |
| 60 | |
| 61 | int push() const { |
| 62 | return push(m_L); |
| 63 | } |
| 64 | |
| 65 | int push(lua_State* L_) const { |
| 66 | lua_pushvalue(L_, m_index); |
| 67 | return 1; |
| 68 | } |
| 69 | |
| 70 | lua_State* lua_state() const { |
| 71 | return m_L; |
| 72 | } |
| 73 | int stack_index() const { |
| 74 | return m_index; |
| 75 | } |
| 76 | }; |
| 77 | |
| 78 | namespace stack { |
| 79 | template <> |