summaryrefslogtreecommitdiff
path: root/plugins/MirLua
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2016-05-17 12:24:12 +0000
committerAlexander Lantsev <aunsane@gmail.com>2016-05-17 12:24:12 +0000
commit8d525f2f68c3c079f2888fdc911f0b5d7cfc8557 (patch)
tree2b94ae97bbda914fcdeab1082f625706c453f279 /plugins/MirLua
parentaba74f5d4859b0c97533a69fbfc5acacbbb51ae5 (diff)
MirLua: attempt to fix MT field reading
git-svn-id: http://svn.miranda-ng.org/main/trunk@16838 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua')
-rw-r--r--plugins/MirLua/src/m_database.cpp2
-rw-r--r--plugins/MirLua/src/mlua_metatable.h21
2 files changed, 13 insertions, 10 deletions
diff --git a/plugins/MirLua/src/m_database.cpp b/plugins/MirLua/src/m_database.cpp
index f81baf06b6..4accb8cff9 100644
--- a/plugins/MirLua/src/m_database.cpp
+++ b/plugins/MirLua/src/m_database.cpp
@@ -675,7 +675,7 @@ int MT<CONTACTINFO>::Index(lua_State *L, CONTACTINFO *ci)
return 1;
}
-void MT<CONTACTINFO>::Free(lua_State *L, CONTACTINFO **ci)
+void MT<CONTACTINFO>::Free(lua_State* /*L*/, CONTACTINFO **ci)
{
mir_free((*ci));
}
diff --git a/plugins/MirLua/src/mlua_metatable.h b/plugins/MirLua/src/mlua_metatable.h
index 13c2d614e3..6e8ddc3cf5 100644
--- a/plugins/MirLua/src/mlua_metatable.h
+++ b/plugins/MirLua/src/mlua_metatable.h
@@ -20,27 +20,28 @@ private:
};
size_t offset;
+ size_t size;
int type;
- int getType;
+
+ int getterType;
std::function<void*(T*)> lambda;
public:
- MTField(size_t offset, int type)
- : offset(offset), type(type), getType(MTFG_OFFSET) { }
+ MTField(size_t offset, size_t size, int type)
+ : offset(offset), size(size), type(type), getterType(MTFG_OFFSET) { }
MTField(std::function<void*(T*)> f, int type)
- : lambda(f), type(type), getType(MTFG_LAMBDA) { }
+ : lambda(f), type(type), getterType(MTFG_LAMBDA) { }
int GetType() const { return type; }
template<typename R>
R GetValue(T *obj) const
{
- if (getType == MTFG_LAMBDA) return (R)lambda(obj);
+ if (getterType == MTFG_LAMBDA) return (R)lambda(obj);
else
{
R res = NULL;
- size_t size = sizeof(R);
memcpy(&res, ((char*)obj) + offset, size);
return res;
}
@@ -114,7 +115,7 @@ private:
switch (field->GetType())
{
case LUA_TBOOLEAN:
- lua_pushboolean(L, field->GetValue<BOOL>(obj));
+ lua_pushboolean(L, field->GetValue<int>(obj));
break;
case LUA_TINTEGER:
lua_pushinteger(L, field->GetValue<long long>(obj));
@@ -166,11 +167,13 @@ public:
}
template<typename R>
- MT& Field(R T::*M, const char *name, int type)
+ MT& Field(R T::*M, const char *name, int type, size_t size = 0)
{
+ if (size == 0)
+ size = sizeof(M);
size_t offset = offsetof(T, *M);
if (type != LUA_TNONE)
- fields[name] = new MTField<T>(offset, type);
+ fields[name] = new MTField<T>(offset, size, type);
return *this;
}