From 6c2236d6764c2a7fec36de74dc70e62043927616 Mon Sep 17 00:00:00 2001 From: Daniel Wallin Date: Mon, 1 Sep 2003 20:29:23 +0000 Subject: [PATCH] fixed bug with holders and properties --- luabind/detail/property.hpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/luabind/detail/property.hpp b/luabind/detail/property.hpp index 9a38f5e..8ed5fdd 100644 --- a/luabind/detail/property.hpp +++ b/luabind/detail/property.hpp @@ -59,7 +59,16 @@ namespace luabind { namespace detail // 2. key (property name) object_rep* obj = static_cast(lua_touserdata(L, 1)); - return get(f, reinterpret_cast(static_cast(obj->ptr()) + pointer_offset), L, static_cast(this)); + class_rep* crep = obj->crep(); + + void* ptr; + + if (crep->has_holder()) + ptr = crep->extractor()(obj->ptr()); + else + ptr = obj->ptr(); + + return get(f, reinterpret_cast(static_cast(ptr) + pointer_offset), L, static_cast(this)); } }; @@ -90,8 +99,17 @@ namespace luabind { namespace detail // parameter on index 2 we need to // remove the key-parameter (parameter 2). object_rep* obj = reinterpret_cast(lua_touserdata(L, 1)); + class_rep* crep = obj->crep(); + + void* ptr; + + if (crep->has_holder()) + ptr = crep->extractor()(obj->ptr()); + else + ptr = obj->ptr(); + lua_remove(L, 2); - return set(f, reinterpret_cast(static_cast(obj->ptr()) + pointer_offset), L, static_cast(this)); + return set(f, reinterpret_cast(static_cast(ptr) + pointer_offset), L, static_cast(this)); } }; -- 2.11.4.GIT