| 686 | |
| 687 | |
| 688 | int main(int argc, char **argv) { |
| 689 | /* |
| 690 | argc = 2; |
| 691 | argv = (char**)malloc(sizeof(char*) * 2); |
| 692 | argv[0] = "lua"; |
| 693 | argv[1] = "sample.bytes"; |
| 694 | */ |
| 695 | int status, result; |
| 696 | thinkyoung::lua::lib::GluaStateScope scope; |
| 697 | scope.add_system_extra_libs(); |
| 698 | lua_State *L = scope.L(); |
| 699 | if (!L) { |
| 700 | l_message(argv[0], "cannot create state: not enough memory"); |
| 701 | return EXIT_FAILURE; |
| 702 | } |
| 703 | lua_pushcfunction(L, &pmain); /* to call 'pmain' in protected mode */ |
| 704 | lua_pushinteger(L, argc); /* 1st argument */ |
| 705 | lua_pushlightuserdata(L, argv); /* 2nd argument */ |
| 706 | status = lua_pcall(L, 2, 1, 0); /* do the call */ |
| 707 | result = lua_toboolean(L, -1); /* get result */ |
| 708 | report(L, status); |
| 709 | return (result && status == LUA_OK) ? EXIT_SUCCESS : EXIT_FAILURE; |
| 710 | } |
nothing calls this directly
no test coverage detected