| 266 | } |
| 267 | |
| 268 | int main(int argc, char *argv[]) |
| 269 | { |
| 270 | |
| 271 | // Disable deprecation warning for getenv call. |
| 272 | #ifdef CHAISCRIPT_MSVC |
| 273 | #pragma warning(push) |
| 274 | #pragma warning(disable : 4996) |
| 275 | #endif |
| 276 | |
| 277 | const char *usepath = getenv("CHAI_USE_PATH"); |
| 278 | const char *modulepath = getenv("CHAI_MODULE_PATH"); |
| 279 | |
| 280 | #ifdef CHAISCRIPT_MSVC |
| 281 | #pragma warning(pop) |
| 282 | #endif |
| 283 | |
| 284 | std::vector<std::string> usepaths; |
| 285 | usepaths.push_back(""); |
| 286 | if (usepath != nullptr) |
| 287 | { |
| 288 | usepaths.push_back(usepath); |
| 289 | } |
| 290 | |
| 291 | std::vector<std::string> modulepaths; |
| 292 | std::vector<std::string> searchpaths = default_search_paths(); |
| 293 | modulepaths.insert(modulepaths.end(), searchpaths.begin(), searchpaths.end()); |
| 294 | modulepaths.push_back(""); |
| 295 | if (modulepath != nullptr) |
| 296 | { |
| 297 | modulepaths.push_back(modulepath); |
| 298 | } |
| 299 | |
| 300 | chaiscript::ChaiScript_Basic chai(create_chaiscript_stdlib(),create_chaiscript_parser(),modulepaths,usepaths); |
| 301 | |
| 302 | chai.add(chaiscript::fun(&myexit), "exit"); |
| 303 | chai.add(chaiscript::fun(&myexit), "quit"); |
| 304 | chai.add(chaiscript::fun(&help), "help"); |
| 305 | chai.add(chaiscript::fun(&throws_exception), "throws_exception"); |
| 306 | chai.add(chaiscript::fun(&get_eval_error), "get_eval_error"); |
| 307 | chai.add(chaiscript::fun(&now), "now"); |
| 308 | |
| 309 | bool eval_error_ok = false; |
| 310 | bool boxed_exception_ok = false; |
| 311 | bool any_exception_ok = false; |
| 312 | |
| 313 | for (int i = 0; i < argc; ++i) { |
| 314 | if ( i == 0 && argc > 1 ) { |
| 315 | ++i; |
| 316 | } |
| 317 | |
| 318 | std::string arg( i != 0 ? argv[i] : "--interactive" ); |
| 319 | |
| 320 | enum { eInteractive |
| 321 | , eCommand |
| 322 | , eFile |
| 323 | } mode = eCommand ; |
| 324 | |
| 325 | if ( arg == "-c" || arg == "--command" ) { |
nothing calls this directly
no test coverage detected