ref counting with std::shared_ptr seems to work and also is handed through with sol
This commit is contained in:
parent
dd23fa811a
commit
ae37273021
4 changed files with 41 additions and 24 deletions
|
@ -92,7 +92,7 @@ void lua_state::load_modules() {
|
|||
|
||||
_namespace.new_usertype<window>("window",
|
||||
"update",&window::update,
|
||||
"set_title",&window::set_title,
|
||||
"title",sol::writeonly_property(&window::set_title),
|
||||
"set_size",&window::set_size
|
||||
);
|
||||
|
||||
|
@ -100,26 +100,15 @@ void lua_state::load_modules() {
|
|||
_namespace.new_usertype<node>("node",
|
||||
sol::constructors<node(), node(std::string)>(),
|
||||
"add_child",&node::add_child,
|
||||
"shared",&node::shared,
|
||||
"children",&node::children,
|
||||
"child_count",&node::child_count,
|
||||
"create", []() -> std::shared_ptr<node> {
|
||||
auto ptr = std::make_shared<node>();
|
||||
return ptr;
|
||||
},
|
||||
"children",sol::readonly_property(&node::children),
|
||||
"child_count",sol::readonly_property(&node::child_count),
|
||||
"create", []() -> std::shared_ptr<node> { return std::make_shared<node>(); },
|
||||
"is_leaf", sol::readonly_property(&node::is_leaf),
|
||||
"is_root", sol::readonly_property(&node::is_root),
|
||||
// "share",scripting::property(scripting::resolve<std::shared_ptr<node>(std::make_shared<node>))
|
||||
"name",scripting::property(&node::name,&node::set_name)
|
||||
);
|
||||
|
||||
|
||||
|
||||
// _namespace.set("something", std::shared_ptr<node>(new node()));
|
||||
|
||||
_namespace["my_func"] = []() -> std::shared_ptr<node> {
|
||||
return std::make_shared<node>();
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue