Thanks to visit codestin.com
Credit goes to github.com

Skip to content
/ laf Public

Automatic lua_cfunction/lua callback generator

Notifications You must be signed in to change notification settings

tomstitt/laf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Automatic Lua callbacks

#include <iostream>
#include <lua.hpp>
#include "laf.hpp"

using namespace std;

int main() {
  lua_State * L = luaL_newstate();
  luaL_openlibs(L);

  int a = 5;
  laf::push_function(L, [a](int b) { cout << "adding " << a << " to " << b; return a + b; });
  lua_setglobal(L, "add_5");
  assert(luaL_dostring(L, "return add_5(3)") == 0);

  cout << ", the result is " << lua_tonumber(L, -1) << endl;

  return 0;
}

About

Automatic lua_cfunction/lua callback generator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published