| 264 | } |
| 265 | |
| 266 | int main(int argc, char *argv[]) |
| 267 | { |
| 268 | |
| 269 | // Disable deprecation warning for getenv call. |
| 270 | #ifdef CHAISCRIPT_MSVC |
| 271 | #pragma warning(push) |
| 272 | #pragma warning(disable : 4996) |
| 273 | #endif |
| 274 | |
| 275 | const char *usepath = getenv("CHAI_USE_PATH"); |
| 276 | const char *modulepath = getenv("CHAI_MODULE_PATH"); |
| 277 | |
| 278 | #ifdef CHAISCRIPT_MSVC |
| 279 | #pragma warning(pop) |
| 280 | #endif |
| 281 | |
| 282 | std::vector<std::string> usepaths; |
| 283 | usepaths.push_back(""); |
| 284 | if (usepath) |
| 285 | { |
| 286 | usepaths.push_back(usepath); |
| 287 | } |
| 288 | |
| 289 | std::vector<std::string> modulepaths; |
| 290 | std::vector<std::string> searchpaths = default_search_paths(); |
| 291 | modulepaths.insert(modulepaths.end(), searchpaths.begin(), searchpaths.end()); |
| 292 | modulepaths.push_back(""); |
| 293 | if (modulepath) |
| 294 | { |
| 295 | modulepaths.push_back(modulepath); |
| 296 | } |
| 297 | |
| 298 | //chaiscript::ChaiScript chai(modulepaths, usepaths); |
| 299 | chaiscript::ChaiScript chai(usepaths); |
| 300 | |
| 301 | chai.add(chaiscript::fun(&myexit), "exit"); |
| 302 | chai.add(chaiscript::fun(&myexit), "quit"); |
| 303 | chai.add(chaiscript::fun(&help), "help"); |
| 304 | chai.add(chaiscript::fun(&throws_exception), "throws_exception"); |
| 305 | chai.add(chaiscript::fun(&get_eval_error), "get_eval_error"); |
| 306 | |
| 307 | chai.add(chaiscript::fun(&helloWorld), "helloWorld"); |
| 308 | |
| 309 | clock_t begin = clock(); |
| 310 | |
| 311 | for (int i = 0; i < 1000; i++) |
| 312 | { |
| 313 | std::string str = helloWorld("Bob12345"); |
| 314 | fwrite(str.c_str(), 1, str.size(), stdout); |
| 315 | } |
| 316 | |
| 317 | clock_t end = clock(); |
| 318 | double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC; |
| 319 | |
| 320 | //begin = clock(); |
| 321 | |
| 322 | ////for (int i = 0; i < 1000; i++) |
| 323 | ////{ |
nothing calls this directly
no test coverage detected