
- ChaiScript no longer includes or automatically instantiates std lib - ChaiScript constructor now requires an std lib instance in the form of a ModulePtr object - This new layout facilitates better usage of compilation firewalls and factories for reducing the overall impact of ChaiScript on a project
29 lines
606 B
C++
29 lines
606 B
C++
#include <chaiscript/utility/utility.hpp>
|
|
|
|
#include <chaiscript/chaiscript_stdlib.hpp>
|
|
|
|
int main()
|
|
{
|
|
|
|
chaiscript::ChaiScript chai(chaiscript::Std_Lib::library());
|
|
|
|
chai.eval("def func() { print(\"Hello World\"); } ");
|
|
|
|
std::function<void ()> f = chai.eval<std::function<void ()> >("func");
|
|
f();
|
|
|
|
if (chai.eval<std::function<std::string (int)> >("to_string")(6) != "6")
|
|
{
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
if (chai.eval<std::function<std::string (const chaiscript::Boxed_Value &)> >("to_string")(chaiscript::var(6)) == "6")
|
|
{
|
|
return EXIT_SUCCESS;
|
|
} else {
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
|
|
}
|