Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Laubstein committed Nov 4, 2015
0 parents commit 9181fc9
Show file tree
Hide file tree
Showing 61 changed files with 18,574 additions and 0 deletions.
60 changes: 60 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

cmake_minimum_required (VERSION 2.6)
project (tolua++)

include_directories ("${PROJECT_SOURCE_DIR}/../../src/")
include_directories ("${PROJECT_SOURCE_DIR}/include/")
include_directories ("${PROJECT_SOURCE_DIR}/../")
include_directories ("${PROJECT_SOURCE_DIR}")

find_program(XXD_EXECUTABLE xxd)

if(NOT XXD_EXECUTABLE STREQUAL "XXD_EXECUTABLE-NOTFOUND")
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/src/bin/basic_lua.h
COMMAND ${XXD_EXECUTABLE} -i lua/basic.lua | sed 's/unsigned char/static const unsigned char/g' >basic_lua.h
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src/bin/
DEPENDS ${PROJECT_SOURCE_DIR}/src/bin/lua/basic.lua)
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/src/bin/enumerate_lua.h
COMMAND ${XXD_EXECUTABLE} -i lua/enumerate.lua | sed 's/unsigned char/static const unsigned char/g' >enumerate_lua.h
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src/bin/
DEPENDS ${PROJECT_SOURCE_DIR}/src/bin/lua/enumerate.lua)
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/src/bin/function_lua.h
COMMAND ${XXD_EXECUTABLE} -i lua/function.lua | sed 's/unsigned char/static const unsigned char/g' >function_lua.h
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src/bin/
DEPENDS ${PROJECT_SOURCE_DIR}/src/bin/lua/function.lua)
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/src/bin/declaration_lua.h
COMMAND ${XXD_EXECUTABLE} -i lua/declaration.lua | sed 's/unsigned char/static const unsigned char/g' >declaration_lua.h
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src/bin/
DEPENDS ${PROJECT_SOURCE_DIR}/src/bin/lua/declaration.lua)
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/src/bin/container_lua.h
COMMAND ${XXD_EXECUTABLE} -i lua/container.lua | sed 's/unsigned char/static const unsigned char/g' >container_lua.h
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src/bin/
DEPENDS ${PROJECT_SOURCE_DIR}/src/bin/lua/container.lua)
set_property(SOURCE src/bin/toluabind.c APPEND PROPERTY OBJECT_DEPENDS ${PROJECT_SOURCE_DIR}/src/bin/enumerate_lua.h ${PROJECT_SOURCE_DIR}/src/bin/basic_lua.h ${PROJECT_SOURCE_DIR}/src/bin/function_lua.h ${PROJECT_SOURCE_DIR}/src/bin/declaration_lua.h ${PROJECT_SOURCE_DIR}/src/bin/container_lua.h)
else()
message("xxd not found, changes to tolua scripts will be ignored")
endif()


file(GLOB LIB_SOURCE
"src/lib/*.c"
)

file(GLOB BIN_SOURCE
"src/bin/*.c"
)

add_executable(tolua ${BIN_SOURCE})
add_library(tolualib ${LIB_SOURCE})
target_link_libraries(tolualib lua)

#m is the standard math librarys
if(UNIX)
target_link_libraries(tolua m ${DYNAMIC_LOADER})
endif()

if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
add_flags_lnk(-L/usr/local/lib)
endif()

target_link_libraries(tolua tolualib lua)
33 changes: 33 additions & 0 deletions COPYRIGHT
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
tolua++ License
---------------

tolua++ is based on toLua (www.tecgraf.puc-rio.br/~celes/tolua), and
it's licensed under the terms of the MIT license reproduced below.
This means that Lua is free software and can be used for both academic
and commercial purposes at absolutely no cost.

===============================================================================

Copyright (C) 2009 Ariel Manzur.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

===============================================================================

(end of COPYRIGHT)
42 changes: 42 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
This version of tolua++ uses SCons to compile (http://www.scons.org). SCons uses
pythin. If you don't want to install python, check "Installation without scons"
below.

* Installation

1. Edit the "config" file for your platform to suit your environment,
if at all necessary (for cygwin, mingw, BSD and mac OSX use
'config_posix')
2. Then, type "scons".

You can use 'scons -h' to see a list of available command line options.

* What you get

If "scons" succeeds, you get:
* an executable to generate binding code in ./bin;
* the C library to be linked in your application in ./lib;
* the include file needed to compile your application in ./include.
These are the only directories you need for development, besides Lua.

You can use 'scons install' to install the files, see the 'prefix' option.

* Installation without scons

The instructions for building tolua++ without scons depend on the particular
compiler you are using.
The simplest way is to create a folder with all .c and .h files except
'toluabind_default.c', and then create a project for the executable and the
library, as follows:

tolua.exe: all *.c *.h in src/bin (except toluabind_default.c)
tolua.lib: all *.c *.h in src/lib.

* Installation with Microsoft Visual Studio

The directory 'win32' contains project files for Microsoft Visual Studio 7
(contributed by Makoto Hamanaka). The project has 4 different build options:
withLua50_Release, withLua51_Release, withLua50_Debug and withLua51_Debug.
They all expect the lua library names used by the LuaBinaries packages
(http://luabinaries.luaforge.net/). The resulting files are built on /lib and
/bin (for the library and tolua++.exe).
30 changes: 30 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
This is tolua++-1.0

* What is tolua++?
tolua++ is an extension of toLua, a tool to integrate C/C++ code with
Lua. tolua++ includes new features oriented to c++, such as class
templates.

tolua is a tool that greatly simplifies the integration of C/C++ code
with Lua. Based on a "cleaned" header file, tolua automatically generates
the binding code to access C/C++ features from Lua. Using Lua-5.0 API and
metamethod facilities, the current version automatically maps C/C++
constants, external variables, functions, namespace, classes, and methods
to Lua. It also provides facilities to create Lua modules.

* Availability

tolua++ is freely available for both academic and commercial purposes.
See COPYRIGHT for details.

tolua++ can be downloaded from the sites below:
http://www.codenix.com/~tolua/

* Installation
See INSTALL.

* Contacting the author
tolua has been designed and implemented by Waldemar Celes.
tolua++ is maintained by Ariel Manzur.
Send your comments, bug reports and anything else to
tolua@codenix.com
50 changes: 50 additions & 0 deletions README-5.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Compiling for lua 5.1
---------------------

Starting from version 1.0.8pre1, tolua++ can be compiled with both lua 5.0 and
5.1. Both versions will output the same code, and the C API (tolua++.h) is the
same.

The build system is not yet ready to detect/decide when to compile for 5.1,
the easiest way right now is to add a file called 'custom.py' on the root of
the package, with the following:

## BEGIN custom.py

CCFLAGS = ['-I/usr/local/include/lua5.1', '-O2', '-ansi']
LIBPATH = ['/usr/local/lib']
LIBS = ['lua5.1', 'dl', 'm']
tolua_bin = 'tolua++5.1'
tolua_lib = 'tolua++5.1'
TOLUAPP = 'tolua++5.1'

## END custom.py

This will build the binary as 'tolua++5.1' and the library as 'libtolua++5.1.a'
(taken from tolua_bin and tolua_lib), and take the lua headers and libraries
from /usr/local/include/lua5.1 and /usr/local/lib. It will also link with
'-llua5.1'. Modify the parameters acording to your system.

Compatibility
-------------

There are a couple of things to keep in mind when running code inside tolua
using the -L option:

* `...' and arg: you can still use 'arg' on 5.1, this is done automatically by
adding the 'arg' declaration to functions on files loaded with dofile.

For example, the line:

function foo( ... )

becomes

function foo( ... ) local arg = {n=select('#', ...), ...};

This lets you use the same code on both versions without having to make any
modifications.

* keep in mind that there are slight differences on the way string.gsub works,
and the original version of the function is always kept, so it will behave
diffently depending on which version of lua you're using.

0 comments on commit 9181fc9

Please sign in to comment.