Files
ReScript/main.cpp

43 lines
1.0 KiB
C++

#include "ReScript/luaengine.hpp"
#include <cmath>
#include <errno.h>
#include <jlog/jlog.hpp>
static int l_sin (lua_State *L) {
//lua_Number d = luaL_checknumber(L, 1);
//DEBUG(std::to_string(d))
//lua_pushnumber(L, sin(d));
LuaNumber LN = LuaNumber();
LN.Pull(L, 1);
LuaNumber LN2 = sin(LN.Value());
//LN2.Push(L);
DEBUG(std::to_string(LN.Value()));
DEBUG(std::to_string(LN2.Value()));
DEBUG(std::to_string(sin(LN.Value())));
lua_pushnumber(L, LN2.Value());
return 1;
}
int main() {
char buff[256];
int error;
//lua_State *L = luaL_newstate();
//luaL_openlibs(L);
LuaEngine LE = LuaEngine();
lua_pushcfunction(LE.L, l_sin);
lua_setglobal(LE.L, "mysin");
while(fgets(buff, sizeof(buff), stdin) != NULL) {
error = LE.LoadString(buff) || lua_pcall(LE.L, 0, 0, 0);
if (error) {
fprintf(stderr, "%s\n", lua_tostring(LE.L, -1));
lua_pop(LE.L, 1);
}
}
lua_close(LE.L);
return 0;
}