mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-07 09:56:59 +00:00
lua: Fix access to sprites in Sprites collection
This commit is contained in:
parent
0203b65908
commit
afa59e8aa4
@ -15,6 +15,8 @@ extern "C" {
|
||||
#include "lauxlib.h"
|
||||
}
|
||||
|
||||
#include "base/debug.h"
|
||||
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
|
||||
@ -61,14 +63,18 @@ template <typename T> T* get_ptr(lua_State* L, int index) {
|
||||
}
|
||||
|
||||
template <typename T> T* get_obj(lua_State* L, int index) {
|
||||
return (T*)luaL_checkudata(L, index, get_mtname<T>());
|
||||
T* ptr = (T*)luaL_checkudata(L, index, get_mtname<T>());
|
||||
ASSERT(typeid(*ptr) == typeid(T));
|
||||
return ptr;
|
||||
}
|
||||
|
||||
// Returns nil if the index doesn't have the given metatable
|
||||
template <typename T> T* may_get_ptr(lua_State* L, int index) {
|
||||
T** ptr = (T**)luaL_testudata(L, index, get_mtname<T>());
|
||||
if (ptr)
|
||||
if (ptr) {
|
||||
ASSERT(typeid(**ptr) == typeid(T));
|
||||
return *ptr;
|
||||
}
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ struct SpritesObj {
|
||||
|
||||
SpritesObj(const Docs& docs) {
|
||||
for (const Doc* doc : docs)
|
||||
this->docs.push_back(doc->id());
|
||||
this->docs.push_back(doc->sprite()->id());
|
||||
}
|
||||
|
||||
SpritesObj(const SpritesObj&) = delete;
|
||||
|
Loading…
Reference in New Issue
Block a user