24 #include "../Util/Log.h" 43 template<
class Ins
ide,
class Outs
ide>
48 scripting(&scripting), ref(scripting) { }
61 void Set(
const luabind::object &obj)
74 throw ScriptExn(
"Expected a constructor or function.");
85 std::shared_ptr<Outside>
operator()(std::shared_ptr<Inside> inside)
const 91 return std::make_shared<Outside>(inside);
94 lua_State *L = scripting->GetState();
96 object obj(L, inside);
97 std::shared_ptr<Outside> retv;
101 scripting->Invoke(1,
nullptr, [&](lua_State *L,
int num) {
103 HR_LOG(error) <<
"Expected a return value.";
106 object retObj(from_stack(L, -num));
108 retv = object_cast<std::shared_ptr<Outside>>(retObj);
110 catch (cast_failed &ex)
112 HR_LOG(error) <<
"Unexpected return value: " << ex.what();
119 return retv ? retv : std::make_shared<Outside>(inside);
WrapperFactory & operator=(const luabind::object &obj)
Definition: WrapperFactory.h:55
Generic script engine exception.
Definition: ScriptExn.h:41
WrapperFactory(Script::Core &scripting)
Definition: WrapperFactory.h:47
Encapsulates a ref to the registry.
Definition: RegistryRef.h:50
RegistryRef ref
Definition: WrapperFactory.h:124
Script::Core * scripting
Definition: WrapperFactory.h:123
Definition: StyleEnv.cpp:32
A reference to a Lua function or userdata that wraps a native object.
Definition: WrapperFactory.h:44
#define HR_LOG(lvl)
Alias for BOOST_LOG_TRIVIAL.
Definition: Log.h:45
void Set(const luabind::object &obj)
Definition: WrapperFactory.h:61
std::shared_ptr< Outside > operator()(std::shared_ptr< Inside > inside) const
Wrap a native object in the wrapper.
Definition: WrapperFactory.h:85
Definition: Announcement.h:24
A script environment.
Definition: Core.h:66