-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.c
35 lines (29 loc) · 879 Bytes
/
test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma path "src"
#include <stdio.h>
#include <stdlib.h>
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
#include "testiface.h"
int main(int argc, char *argv[]) {
// Initialize the LUA state
printf("Initialize the LUA state\n");
lua_State *L = luaL_newstate();
printf("Opening libs\n");
luaL_openlibs(L);
// Load the test_iface library
printf("Loading test_iface library\n");
luaL_requiref(L, "test_iface", luaopen_test_iface, 1);
lua_pop(L, 1);
// Load and execute the LUA script
printf("Executing bridge.lua\n");
if (luaL_loadfile(L, "bridge.lua") || lua_pcall(L, 0, 0, 0)) {
fprintf(stderr, "Error running script: %s\n", lua_tostring(L, -1));
lua_close(L);
return 1;
}
// Close the LUA state
printf("Closing LUA state... Byeeeeeeeeeee!\n");
lua_close(L);
return 0;
}