Add the ability to specify "load_module" and "use" search paths. The capability is primitive and it is currently used by chaiscript_eval to set a single path from environment variables

This commit is contained in:
Jason Turner
2010-03-18 22:53:52 +00:00
parent 7080f5d681
commit 7ac9ea7249
3 changed files with 94 additions and 25 deletions

View File

@@ -52,7 +52,29 @@ std::string get_next_command() {
int main(int argc, char *argv[]) {
std::string input;
chaiscript::ChaiScript chai;
std::vector<std::string> usepaths;
std::vector<std::string> modulepaths;
const char *usepath = getenv("CHAI_USE_PATH");
const char *modulepath = getenv("CHAI_MODULE_PATH");
usepaths.push_back("");
if (usepath)
{
usepaths.push_back(usepath);
}
modulepaths.push_back("");
if (modulepath)
{
modulepaths.push_back(modulepath);
}
chaiscript::ChaiScript chai(modulepaths,usepaths);
chai.add(chaiscript::fun(&exit), "exit");
chai.add(chaiscript::fun(&throws_exception), "throws_exception");