Skip to content

ToyAuthor/luapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

luapp

It's a useful tool for lua. To help you use lua in C++ style and work better with object-oriented programming.

Features

  • Header file only.
  • To register C++ class into lua.
  • C++ and lua could call each other's function.
  • Read/Write/Add/Remove lua global variable at C++ side.
  • Lua could send any variable to C++, and C++ could send them back.
  • Support to create C extension module.
  • Implement a C++ container to simulate lua table.
  • Implement a class whose instances can hold instances of any type supported by luapp.
  • Let lua script embedded in C++.
  • Be able to search lua script by custom rule.
  • Support to call lua function that has multiple return value.

Requirements

  • CMake 2.8+
  • Lua 5.4+

Information

Item Description
Author Yan-Xin Wu
License MIT
Version 2.5.0 (using Semantic Versioning 2.0.0)

Example

-- ClassIntoLua.lua

object = NewObject()

num = object:count(3,4)

print("3 + 4 = " .. num)
// main.cpp

#include <luapp.hpp>

class MyClass
{
public:

	MyClass(){}

	~MyClass(){}

	lua::Int count( lua::Int num01,
	                lua::Int num02)
	{
		return num01 + num02;
	}
};

int main()
{
	lua::State<>    lua;

	lua.bindMethod("count",&MyClass::count);

	lua.bindClassEx<MyClass>("NewObject");

	lua.run(".","ClassIntoLua.lua");

	return 0;
}