Allow "Module" to contain chaiscript snippets to be executed when a module is initialized. Update dynamic_object to use the new feature to clean up some of the _prelude.hpp

This commit is contained in:
Jason Turner
2009-09-21 03:07:01 +00:00
parent 8241e46680
commit 50eace16da
5 changed files with 34 additions and 21 deletions

View File

@@ -693,6 +693,7 @@ namespace chaiscript
m->add(fun(&Dynamic_Object::get_type_name), "get_type_name");
m->add(fun(&Dynamic_Object::get_attrs), "get_attrs");
m->add(fun(&Dynamic_Object::get_attr), "get_attr");
m->eval("def Dynamic_Object::clone() { var new_o := Dynamic_Object(this.get_type_name()); for_each(this.get_attrs(), bind(fun(new_o, x) { new_o.get_attr(x.first) = x.second; }, new_o, _) ); return new_o; }");
basic_constructors<bool>("bool", m);