diff --git a/src/test_module.cpp b/src/test_module.cpp index c5da4c9..ebccf73 100644 --- a/src/test_module.cpp +++ b/src/test_module.cpp @@ -34,6 +34,11 @@ class TestBaseType int mdarray[2][3][5]; std::function func_member; + void set_string_val(std::string &t_str) + { + t_str = "42"; + } + private: TestBaseType &operator=(const TestBaseType &) = delete; }; @@ -52,6 +57,7 @@ class Type2 return m_bt.val; } + const char *get_str() const { return m_str.c_str(); @@ -171,6 +177,7 @@ CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_test_mo m->add(chaiscript::fun(&TestBaseType::val), "val"); m->add(chaiscript::fun(&TestBaseType::const_val), "const_val"); m->add(chaiscript::fun(&TestBaseType::base_only_func), "base_only_func"); + m->add(chaiscript::fun(&TestBaseType::set_string_val), "set_string_val"); #ifndef CHAISCRIPT_MSVC_12 // we cannot support these in MSVC_12 because of a bug in the implementation of diff --git a/unittests/non_const_param.chai b/unittests/non_const_param.chai new file mode 100644 index 0000000..fa385db --- /dev/null +++ b/unittests/non_const_param.chai @@ -0,0 +1,8 @@ +load_module("test_module") + +var t2 = TestBaseType(); + +var s = "5"; +t2.set_string_val(s); +assert_equal(s, "42") +