2017-02-08 00:15:55 +01:00
|
|
|
/*
|
|
|
|
Minetest
|
|
|
|
Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
|
|
|
|
Copyright (C) 2017 nerzhul, Loic Blot <loic.blot@unix-experience.fr>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2.1 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License along
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2017-08-17 22:19:39 +02:00
|
|
|
#pragma once
|
2017-02-08 00:15:55 +01:00
|
|
|
|
|
|
|
#include "l_metadata.h"
|
2017-04-07 08:50:17 +02:00
|
|
|
#include "lua_api/l_base.h"
|
2017-02-08 00:15:55 +01:00
|
|
|
|
|
|
|
class ModMetadata;
|
|
|
|
|
2017-04-07 08:50:17 +02:00
|
|
|
class ModApiStorage : public ModApiBase
|
2017-02-08 00:15:55 +01:00
|
|
|
{
|
|
|
|
protected:
|
|
|
|
static int l_get_mod_storage(lua_State *L);
|
2017-04-07 08:50:17 +02:00
|
|
|
|
2017-02-08 00:15:55 +01:00
|
|
|
public:
|
|
|
|
static void Initialize(lua_State *L, int top);
|
|
|
|
};
|
|
|
|
|
2017-04-07 08:50:17 +02:00
|
|
|
class StorageRef : public MetaDataRef
|
2017-02-08 00:15:55 +01:00
|
|
|
{
|
|
|
|
private:
|
2017-06-19 23:54:58 +02:00
|
|
|
ModMetadata *m_object = nullptr;
|
2017-02-08 00:15:55 +01:00
|
|
|
|
|
|
|
static const char className[];
|
2017-04-08 09:28:37 +02:00
|
|
|
static const luaL_Reg methods[];
|
2017-02-08 00:15:55 +01:00
|
|
|
|
2017-04-07 08:50:17 +02:00
|
|
|
virtual Metadata *getmeta(bool auto_create);
|
2017-02-08 00:15:55 +01:00
|
|
|
virtual void clearMeta();
|
|
|
|
|
|
|
|
// garbage collector
|
|
|
|
static int gc_object(lua_State *L);
|
2017-04-07 08:50:17 +02:00
|
|
|
|
2017-02-08 00:15:55 +01:00
|
|
|
public:
|
|
|
|
StorageRef(ModMetadata *object);
|
2017-08-19 22:23:47 +02:00
|
|
|
~StorageRef() = default;
|
2017-02-08 00:15:55 +01:00
|
|
|
|
|
|
|
static void Register(lua_State *L);
|
|
|
|
static void create(lua_State *L, ModMetadata *object);
|
|
|
|
|
|
|
|
static StorageRef *checkobject(lua_State *L, int narg);
|
2017-04-07 08:50:17 +02:00
|
|
|
static ModMetadata *getobject(StorageRef *ref);
|
2017-02-08 00:15:55 +01:00
|
|
|
};
|