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:
@@ -13,7 +13,6 @@
|
||||
|
||||
#define chaiscript_prelude CODE_STRING(\
|
||||
def new(x) { eval(type_name(x))(); } \n\
|
||||
def clone(o) : is_type(o, "Dynamic_Object") { var new_o := Dynamic_Object(o.get_type_name()); for_each(o.get_attrs(), bind(fun(new_o, x) { new_o.get_attr(x.first) = x.second; }, new_o, _) ); return new_o; } \n\
|
||||
def clone(x) : function_exists(type_name(x)) && call_exists(eval(type_name(x)), x) { eval(type_name(x))(x); } \n\
|
||||
# to_string for Pair()\n\
|
||||
def to_string(x) : call_exists(first, x) && call_exists(second, x) { \n\
|
||||
|
Reference in New Issue
Block a user