Remove old version of tolua++. Switch to tolua 5.0 as more uptodate version.
1.1 --- a/source/tolua++/INSTALL Wed Nov 04 01:07:17 2009 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,33 +0,0 @@
1.4 -This version of tolua++ uses SCons to compile (http://www.scons.org). SCons uses
1.5 -pythin. If you don't want to install python, check "Installation without scons"
1.6 -below.
1.7 -
1.8 -* Installation
1.9 -
1.10 - 1. Edit the "config" file for your platform to suit your environment,
1.11 - if at all necessary (for cygwin, mingw, BSD and mac OSX use
1.12 - 'config_posix')
1.13 - 2. Then, type "scons".
1.14 -
1.15 - You can use 'scons -h' to see a list of available command line options.
1.16 -
1.17 -* What you get
1.18 -
1.19 - If "scons" succeeds, you get:
1.20 - * an executable to generate binding code in ./bin;
1.21 - * the C library to be linked in your application in ./lib;
1.22 - * the include file needed to compile your application in ./include.
1.23 - These are the only directories you need for development, besides Lua.
1.24 -
1.25 - You can use 'scons install' to install the files, see the 'prefix' option.
1.26 -
1.27 -* Installation without scons
1.28 -
1.29 - The instructions for building tolua++ without scons depend on the particular
1.30 - compiler you are using.
1.31 - The simplest way is to create a folder with all .c and .h files except
1.32 - 'toluabind_default.c', and then create a project for the executable and the
1.33 - library, as follows:
1.34 -
1.35 - tolua.exe: all *.c *.h in src/bin (except toluabind_default.c)
1.36 - tolua.lib: all *.c *.h in src/lib.
2.1 --- a/source/tolua++/Makefile Wed Nov 04 01:07:17 2009 +0000
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,5 +0,0 @@
2.4 -# makefile for tolua hierarchy
2.5 -
2.6 -all:
2.7 - @echo "Makefile is deprecated ;)"
2.8 - @echo "see INSTALL for details on how to build tolua++"
3.1 --- a/source/tolua++/README Wed Nov 04 01:07:17 2009 +0000
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,32 +0,0 @@
3.4 -This is tolua==-1.0
3.5 -
3.6 -* What is tolua==?
3.7 - tolua++ is an extension of toLua</a>, a tool to integrate C/C++ code with
3.8 - Lua. tolua++ includes new features oriented to c++, such as class
3.9 - templates.
3.10 -
3.11 - tolua is a tool that greatly simplifies the integration of C/C++ code
3.12 - with Lua. Based on a "cleaned" header file, tolua automatically generates
3.13 - the binding code to access C/C++ features from Lua. Using Lua-5.0 API and
3.14 - tag method facilities, the current version automatically maps C/C++
3.15 - constants, external variables, functions, namespace, classes, and methods
3.16 - to Lua. It also provides facilities to create Lua modules.
3.17 -
3.18 -* Availability
3.19 - tolua is freely available; you can redistribute it and/or modify it.
3.20 - The software provided hereunder is on an "as is" basis, and
3.21 - the author has no obligation to provide maintenance, support,
3.22 - updates, enhancements, or modifications.
3.23 -
3.24 - tolua can be downloaded from the sites below:
3.25 - http://www.codenix.com/~tolua/
3.26 - http://www.codenix.com/~tolua/tolua++-1.0.tar.bz2
3.27 -
3.28 -* Installation
3.29 - See INSTALL.
3.30 -
3.31 -* Contacting the author
3.32 - tolua has been designed and implemented by Waldemar Celes.
3.33 - tolua++ is maintained by Ariel Manzur.
3.34 - Send your comments, bug reports and anything else to
3.35 - tolua@codenix.com
4.1 --- a/source/tolua++/SConstruct Wed Nov 04 01:07:17 2009 +0000
4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
4.3 @@ -1,152 +0,0 @@
4.4 -import sys;
4.5 -import os
4.6 -env = Environment()
4.7 -
4.8 -options_file = None
4.9 -if sys.platform == 'linux2':
4.10 - options_file = "config_linux.py"
4.11 -
4.12 -elif 'msvc' in env['TOOLS']:
4.13 - options_file = "config_msvc.py"
4.14 -else:
4.15 - options_file = "config_posix.py"
4.16 -
4.17 -## setting up the command line options
4.18 -opts = Options([options_file, 'custom.py'], ARGUMENTS)
4.19 -opts.Add('CC', 'The C compiler.')
4.20 -opts.Add('CCFLAGS', 'Flags for the compiler.', ['-O2', '-Wall'])
4.21 -opts.Add('LINK', 'The linker.')
4.22 -opts.Add('LINKFLAGS', 'Linker flags.', [])
4.23 -opts.Add('no_cygwin', 'Use -mno-cygwin to build using the mingw compiler on cygwin', 0)
4.24 -opts.Add('LIBS', 'libraries', [])
4.25 -
4.26 -opts.Add('prefix', 'The installation prefix')
4.27 -opts.Add('build_dev', 'Build for development (uses tolua to rebuild toluabind.c with the embeded scripts', 0)
4.28 -opts.Add('build_failsafe', "Build using 'factory default' toluabind file (in case build_dev fails)", 0)
4.29 -opts.Add('ENV', 'The environment variables')
4.30 -opts.Update(env)
4.31 -Help(opts.GenerateHelpText(env))
4.32 -
4.33 -def save_config(target, source, env):
4.34 - opts.Save('custom.py', env)
4.35 -
4.36 -cust = env.Command('custom.py', [], save_config)
4.37 -env.Alias('configure', [cust])
4.38 -
4.39 -env['build_dev'] = int(env['build_dev'])
4.40 -
4.41 -## detecting the install directory on win32
4.42 -if 'msvc' in env['TOOLS'] and not (env.has_key('prefix') or env['prefix']):
4.43 -
4.44 - if env['MSVS'].has_key('PLATFORMSDKDIR'):
4.45 - env['prefix'] = env['MSVS']['PLATFORMSDKDIR']
4.46 -
4.47 -
4.48 -SConscriptChdir(0)
4.49 -
4.50 -############ helper builders
4.51 -def pkg_scan_dep(self, target, source):
4.52 -
4.53 - import re
4.54 -
4.55 - ## TODO: detectar si el archivo existe antes de abrirlo asi nomas
4.56 - pkg = open(source, "rt")
4.57 -
4.58 - for linea in pkg.xreadlines():
4.59 - dep = re.search("^[\t\w]*\$[cphl]file\s*\"([^\"]+)\"", linea)
4.60 - if dep:
4.61 - self.Depends(target, '#' + dep.groups()[0]);
4.62 -
4.63 - if dep.groups()[0][-4:] == '.pkg':
4.64 - # recursividad
4.65 - self.pkg_scan_dep(target, dep.groups()[0])
4.66 -
4.67 -
4.68 -def make_tolua_code(self, target, source, pkgname = None, use_own = None):
4.69 -
4.70 - ptarget = Dir('.').path + '/' + target
4.71 - psource = Dir('.').path + '/' + source
4.72 - header = target[:-2] + '.h'
4.73 - pheader = Dir('.').path + '/' + header
4.74 -
4.75 - tolua = ""
4.76 - if use_own:
4.77 - if 'msvc' in self['TOOLS']:
4.78 - tolua = 'bin\\tolua++'
4.79 - else:
4.80 - tolua = 'bin/tolua++'
4.81 - else:
4.82 - tolua = "tolua++"
4.83 -
4.84 - if pkgname:
4.85 - pkgname = ' -n '+pkgname
4.86 - else:
4.87 - pkgname = ''
4.88 -
4.89 - comando = tolua + ' -H ' + pheader + ' -o ' + ptarget + pkgname + ' ' + psource
4.90 - self.Command(target, source, comando)
4.91 -
4.92 - self.SideEffect(header, target)
4.93 - self.Depends(target, source)
4.94 -
4.95 - self.pkg_scan_dep(target, psource)
4.96 -
4.97 - if use_own:
4.98 - self.Depends(target, "#/bin/tolua++"+env['PROGSUFFIX'])
4.99 -
4.100 -
4.101 -env.__class__.LuaBinding = make_tolua_code;
4.102 -env.__class__.pkg_scan_dep = pkg_scan_dep;
4.103 -
4.104 -def print_install_error(target, source, env):
4.105 -
4.106 - msg = """Error: no install prefix was specified, or detected.
4.107 -
4.108 -you can use the 'prefix' option on command line to specify one. Examples:
4.109 -
4.110 - scons prefix=/usr/local install
4.111 -
4.112 -or on Windows:
4.113 -
4.114 - scons "prefix=c:\\program files\\visual basic" install
4.115 -
4.116 -Files will be installed on <prefix>/bin, <prefix>/lib and <prefix>/include
4.117 -"""
4.118 - import SCons.Errors
4.119 - raise SCons.Errors.UserError(msg)
4.120 -
4.121 -########### end of helper builders
4.122 -
4.123 -env['CPPPATH'] = '#/include'
4.124 -env['LIBPATH'] = '#/lib'
4.125 -
4.126 -if env['no_cygwin']:
4.127 -
4.128 - env['CCFLAGS'] += ['-mno-cygwin']
4.129 - env['LINKFLAGS'] += ['-mno-cygwin']
4.130 -
4.131 -import string
4.132 -
4.133 -Export('env')
4.134 -
4.135 -SConscript('src/bin/SCsub')
4.136 -SConscript('src/lib/SCsub')
4.137 -SConscript('src/tests/SCsub')
4.138 -
4.139 -env.Alias('all', [env.bin_target, env.lib_target])
4.140 -env.Alias('test', env.test_targets)
4.141 -
4.142 -Default('all')
4.143 -
4.144 -if env['prefix']:
4.145 - env.Install(env['prefix']+'/bin', env.bin_target)
4.146 - env.Install(env['prefix']+'/lib', env.lib_target)
4.147 - env.Install(env['prefix']+'/include', '#include/tolua++.h')
4.148 -
4.149 - env.Alias('install', [env['prefix']+'/bin', env['prefix']+'/include', env['prefix']+'/lib'])
4.150 -else:
4.151 - env.Command('install', [], print_install_error)
4.152 - env.Depends('install', 'all')
4.153 -
4.154 -env.Command('deb', [], 'dpkg-buildpackage -I.svn -Icustom.py -Itoluabind_dev.c -Itoluabind_dev.h -Itoluabind_default.o -Icustom.lua -I.sconsign', ENV=os.environ)
4.155 -
5.1 --- a/source/tolua++/bin/test Wed Nov 04 01:07:17 2009 +0000
5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
5.3 @@ -1,8 +0,0 @@
5.4 -#define MAX_SOMETHINGS 32
5.5 -
5.6 -typedef struct
5.7 -{
5.8 - int stuff;
5.9 -} SOMETHING;
5.10 -
5.11 -extern SOMETHING somestuff[MAX_SOMETHINGS];
6.1 --- a/source/tolua++/config Wed Nov 04 01:07:17 2009 +0000
6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
6.3 @@ -1,4 +0,0 @@
6.4 -# configuration file for making tolua
6.5 -# $Id$
6.6 -
6.7 -All settings are in the Lua config
6.8 \ No newline at end of file
7.1 --- a/source/tolua++/config_linux.py Wed Nov 04 01:07:17 2009 +0000
7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
7.3 @@ -1,22 +0,0 @@
7.4 -
7.5 -## This is the linux configuration file
7.6 -# use 'scons -h' to see the list of command line options available
7.7 -
7.8 -# Compiler flags (based on Debian's installation of lua)
7.9 -#LINKFLAGS = ['-g']
7.10 -CCFLAGS = ['-I/usr/include/lua50', '-O2', '-ansi', '-Wall']
7.11 -#CCFLAGS = ['-I/usr/include/lua50', '-g']
7.12 -
7.13 -# this is the default directory for installation. Files will be installed on
7.14 -# <prefix>/bin, <prefix>/lib and <prefix>/include when you run 'scons install'
7.15 -#
7.16 -# You can also specify this directory on the command line with the 'prefix'
7.17 -# option
7.18 -#
7.19 -# You can see more 'generic' options for POSIX systems on config_posix.py
7.20 -
7.21 -prefix = '/usr/local'
7.22 -
7.23 -# libraries (based on Debian's installation of lua)
7.24 -LIBS = ['lua50', 'lualib50', 'dl', 'm']
7.25 -
8.1 --- a/source/tolua++/config_msvc.py Wed Nov 04 01:07:17 2009 +0000
8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
8.3 @@ -1,28 +0,0 @@
8.4 -
8.5 -## This is the MSVC configuration file
8.6 -# use 'scons -h' to see the list of command line options available
8.7 -
8.8 -# flags for the compiler
8.9 -CCFLAGS = ['/nologo']
8.10 -
8.11 -# this is the default directory for installation. Files will be installed on
8.12 -# <prefix>/bin, <prefix>/lib and <prefix>/include when you run 'scons install'
8.13 -#
8.14 -# You can also specify this directory on the command line with the 'prefix'
8.15 -# option
8.16 -#
8.17 -# If you leave it as 'None', we'll try to auto-detect it (as 'PLATFORMSDKDIR'
8.18 -# detected by SCons).
8.19 -
8.20 -prefix = None # (it's a string)
8.21 -
8.22 -# the libraries
8.23 -LIBS = ['lua', 'lualib']
8.24 -
8.25 -# linkflags
8.26 -LINKFLAGS = ['/nologo']
8.27 -
8.28 -## We need to specifiy the environment for the PATH and LIB and all those
8.29 -# parameters cl tales from it
8.30 -import os
8.31 -ENV = os.environ
9.1 --- a/source/tolua++/config_posix.py Wed Nov 04 01:07:17 2009 +0000
9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
9.3 @@ -1,23 +0,0 @@
9.4 -
9.5 -## This is the POSIX configuration file (will be included for cygwin, mingw
9.6 -# and possibly mac OSX and BSDs)
9.7 -# use 'scons -h' to see the list of command line options available
9.8 -
9.9 -# flags for the compiler
9.10 -#CCFLAGS = []
9.11 -CCFLAGS = ['-O2', '-ansi', '-Wall']
9.12 -
9.13 -# this is the default directory for installation. Files will be installed on
9.14 -# <prefix>/bin, <prefix>/lib and <prefix>/include when you run 'scons install'
9.15 -#
9.16 -# You can also specify this directory on the command line with the 'prefix'
9.17 -# option
9.18 -
9.19 -prefix = '/usr/local'
9.20 -
9.21 -# libraries
9.22 -LIBS = ['lua', 'lualib', 'm']
9.23 -
9.24 -
9.25 -print "****** posix"
9.26 -import os
10.1 --- a/source/tolua++/custom.py Wed Nov 04 01:07:17 2009 +0000
10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
10.3 @@ -1,5 +0,0 @@
10.4 -#############
10.5 -## This is the custom file to override the options on the config_* files.
10.6 -# Example:
10.7 -#
10.8 -# CCFLAGS = ['-g', '-Wall']
11.1 --- a/source/tolua++/doc/index.html Wed Nov 04 01:07:17 2009 +0000
11.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
11.3 @@ -1,167 +0,0 @@
11.4 -<head>
11.5 -<title>toLua++ - binding c/c++ code to lua</title>
11.6 -</head>
11.7 -
11.8 -<body bgcolor="white">
11.9 -
11.10 -<h1>
11.11 -<img src="toluapp.gif">tolua++ - Home</h1>
11.12 -<p>
11.13 -
11.14 -<a href="#news">news</a> -
11.15 -<a href="#download">download</a> - <a href="#documentation">documentation</a> - <a href="#installing">installing</a> -
11.16 -<a href="mailto:tolua@codenix.com">contact</a> - <a href="lua_qt/">lua_qt</a> - <a href="http://www.codenix.com">Codenix</a>
11.17 -<br>
11.18 -
11.19 -<hr>
11.20 -
11.21 -<b>tolua++</b> is an extended version of <a href="http://www.tecgraf.puc-rio.br/~celes/tolua/">tolua</a>, a tool to integrate
11.22 -C/C++ code with <A HREF="http://www.tecgraf.puc-rio.br/lua">Lua</A>. <b>tolua++</b>
11.23 -includes new features oriented to c++ such as:
11.24 -<p>
11.25 -
11.26 -<ul>
11.27 -<li> Support for <b>std::string</b> as a <a href="#basics">basic type</a> (this can be turned off by a command line option).</li>
11.28 -<li> Support for <a href="#templates">class templates</a></li>
11.29 -</ul>
11.30 -<p>
11.31 -
11.32 -As well as other features and bugfixes.
11.33 -
11.34 -<hr>
11.35 -<a name="news"></a>
11.36 -<h3>News:</h3>
11.37 -<p>
11.38 -
11.39 -<b>01/9/05</b>: Version <b><a href="tolua++_1.0.6-1.tar.gz">1.0.6</a></b> released. Several bugfixes and new features:
11.40 -<p>
11.41 -<ul>
11.42 -<li> Classes can have properties, using the 'tolua_property' keyboard. Property types are customizable.
11.43 -<li> Added a command line flag -D, to disable automatic generation of destructors for all classes with constructors (for compatibility with tolua5)
11.44 -<li> Classes with protected or private destructors can be tagged individually using the "TOLUA_PROTECTED_DESTRUCTOR" macro.
11.45 -<li> Added utility function "tolua.inherit", to allow a lua table "inherit" from an instance of a C/C++ class
11.46 -<li> Fixed class constructor bug (it is now possible to use 'ClassName()' to create a lua-owned instance of the class)
11.47 -<li> Misc bugfixes.
11.48 -</ul>
11.49 -<p>
11.50 -
11.51 -<b>10/4/05</b>: Version <b><a href="tolua++_1.0.5-1.tar.gz">1.0.5</a></b> released. This version contains some minor bugfixes and a new feature,
11.52 -the <b>tolua_outside</b> keyword, used to specify regular functions as methods of classes or structs. This release is also paired with <a href="lua_qt/">lua_qt</a>
11.53 -version 0.0.1a.
11.54 -<p>
11.55 -
11.56 -<b>1/2/05</b>: version <b><a href="tolua++-1.0.4.tar.bz2">1.0.4</a></b> released. This version contains some bugfixes and new features:
11.57 -<p>
11.58 -<ul>
11.59 -<li> Ability to customize tolua++'s behaviour to add functionality.
11.60 -<li> Basic support for multiple inheritance.
11.61 -<li> Several bugfixes on the parser.
11.62 -<li> <a href="tolua++_1.0.4-3_i386.deb">Debian package</a> available for download.
11.63 -</ul>
11.64 -<p>
11.65 -
11.66 -Most of the changes on this version were added for <a href="lua_qt/">lua_qt</a>, a package
11.67 -to bind the <a href="http://www.trolltech.com/products/qt/index.html">Qt</a> toolkit to lua.
11.68 -<p>
11.69 -
11.70 -<b>20/9/04</b>: version <b><a href="tolua++-1.0.3.tar.bz2">1.0.3</a></b> released. This version contains major bugfixes:
11.71 -<p>
11.72 -<ul>
11.73 -<li> Fixed bugs in object tracking (the 'memory address' bug; there's still some work left, but people should be able to use <tt>union</tt>s with no problems)</li>
11.74 -<li> Fixed parser bugs, functions with template parameters should work, also functions with default parameters that call constructos and with commas on them should work.</li>
11.75 -<li> Added a <tt>__call</tt> method for class names, to replace <tt>new_local</tt> to create instances owned by lua.
11.76 -<li> Fixed other minor bugs.</li>
11.77 -<li> Removed the link to win32 binaries, since I aparently don't know what the hell I'm doing with a microsoft compiler ;-)</li>
11.78 -</ul>
11.79 -<p>
11.80 -
11.81 -Everyone should upgrade.
11.82 -<p>
11.83 -
11.84 -<b>23/10/03</b>: version <b><a href="tolua++-1.0.2.tar.bz2">1.0.2</a></b> released. This version contains major bugfixes:
11.85 -<p>
11.86 -<ul>
11.87 -<li> Fixed bugs in gargabe collection (thanks to <b>Christian Vogler</b> for doing all the work :-)</li>
11.88 -<li> <tt>namespace</tt>s and nested types are now fully supported.</li>
11.89 -<li> Fixed other minor bugs.</li>
11.90 -</ul>
11.91 -<p>
11.92 -
11.93 -Everyone should upgrade.
11.94 -
11.95 -<hr>
11.96 -
11.97 -<a name="download"></a>
11.98 -<h3>Downloading</B></H3>
11.99 -The <B>tolua++</B> source is freely available by http.
11.100 -The software provided hereunder is on an "as is" basis, and the author
11.101 -has no obligation to provide maintenance, support, updates, enhancements,
11.102 -or modifications.
11.103 -<p>
11.104 -
11.105 -Current version is <b><a href="tolua++_1.0.6-1.tar.gz">1.0.6</a></b>, older versions:
11.106 -<p>
11.107 -<li> <a href="tolua++_1.0.6-1.tar.gz">tolua++_1.0.6-1.tar.gz</a> [<a href="tolua++_1.0.6-1_i386.deb">deb</a>]
11.108 -<li> <a href="tolua++_1.0.5-1.tar.gz">tolua++_1.0.5-1.tar.gz</a> [<a href="tolua++_1.0.5-1_i386.deb">deb</a>]
11.109 -<li> <a href="tolua++-1.0.4.tar.bz2">tolua++-1.0.4.tar.bz2</a> [<a href="tolua++_1.0.4-3_i386.deb">deb</a>]
11.110 -<li> <a href="tolua++-1.0.3.tar.bz2">tolua++-1.0.3.tar.bz2</a>
11.111 -<li> <a href="tolua++-1.0.2.tar.bz2">tolua++-1.0.2.tar.bz2</a>
11.112 -<li> <a href="tolua++-1.0.tar.bz2">tolua++-1.0.tar.bz2</a>
11.113 -
11.114 -<hr>
11.115 -
11.116 -<a name="documentation"></a>
11.117 -<h3>Documentation</h3>
11.118 -<p>
11.119 -You can find the manual <a href="tolua++.html">here</a> or under the doc/ directory
11.120 -on the distribution.
11.121 -
11.122 -<hr>
11.123 -
11.124 -<a name="installing"></a>
11.125 -<h3>Instalation</h3>
11.126 -<p>
11.127 -
11.128 -tolua++ uses <a href="http://www.scons.org">SCons</a> to build. SCons is based on
11.129 -python, you can get a stand-alone version on <a href="http://www.scons.org">
11.130 -their website</a>. After you have SCons, follow this simple instructions:
11.131 -<p>
11.132 -
11.133 -<li> Type '<b>scons all</b>' to compile.</li>
11.134 -<li> Type '<b>scons install</b>'. The default install prefix is /usr/local, so if you are
11.135 -on a POSIX system, it should work. On other systems, you can change it with the
11.136 -'<b>prefix</b>' option on command line.
11.137 -<p>
11.138 -
11.139 -<b>scons prefix=/usr install</b>
11.140 -<p>
11.141 -<i>or on windows</i>
11.142 -<p>
11.143 -<b>scons "prefix=c:\Program Files\Visual C" install</b>
11.144 -<p>
11.145 -
11.146 -Use <b>scons -h</b> to see a list of available command line options.
11.147 -
11.148 -<p>
11.149 -The files you need (in case you want to do a <b>manual install</b>) are:
11.150 -<ul>
11.151 - <li> bin/tolua++[.exe] - the main binary
11.152 - <li> include/tolua++.h - the header file
11.153 - <li> lib/libtolua++.a <i>or</i> lib/tolua++.lib - the library
11.154 -</ul>
11.155 -
11.156 -<li> See INSTALL for instructions on how to install without SCons. There are also instructions on how
11.157 -to build without scons at the <a href="http://lua-users.org/wiki/CompilingToluappWithoutScons">lua-users wiki</a>
11.158 -(if you know the author of this, <a href="mailto:tolua@codenix.com">contact me</a>)</li>
11.159 -
11.160 -<hr>
11.161 -
11.162 -<b>tolua++</b> and this website are maintained by Ariel Manzur.<br>
11.163 -<a href="http://www.codenix.com/index.php?section=contact">Contact us</a> with any
11.164 -bugs, fixes, suggestions, or questions about this package.
11.165 -
11.166 -<hr>
11.167 -
11.168 -
11.169 -</body>
11.170 -
12.1 --- a/source/tolua++/doc/tolua++.html Wed Nov 04 01:07:17 2009 +0000
12.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
12.3 @@ -1,1713 +0,0 @@
12.4 -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
12.5 -<HTML>
12.6 -<HEAD>
12.7 - <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
12.8 - <META NAME="GENERATOR" CONTENT="Textpad">
12.9 - <META NAME="Author" CONTENT="Waldemar Celes, Ariel Manzur">
12.10 - <TITLE>tolua++ reference manual</TITLE>
12.11 -</HEAD>
12.12 -<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#FF0000">
12.13 -
12.14 -<H1>
12.15 -<IMG SRC="toluapp.gif">tolua++ - Reference Manual</I></H1>
12.16 -by Waldemar Celes, Ariel Manzur.
12.17 -
12.18 -<H1>
12.19 -
12.20 -</h1>
12.21 -
12.22 -<HR ALIGN=LEFT SIZE=5 WIDTH="100%">
12.23 -
12.24 -<b>tolua++</b> is an extended version of <a href="http://www.tecgraf.puc-rio.br/~celes/tolua/">tolua</a>, a tool to integrate
12.25 -C/C++ code with <A HREF="http://www.tecgraf.puc-rio.br/lua">Lua</A>. <b>tolua++</b>
12.26 -includes new features oriented to c++ such as:
12.27 -<p>
12.28 -
12.29 -<ul>
12.30 -<li> Support for <b>std::string</b> as a <a href="#basics">basic type</a> (this can be turned off by a command line option).</li>
12.31 -<li> Support for <a href="#templates">class templates</a></li>
12.32 -</ul>
12.33 -<p>
12.34 -
12.35 -As well as other features and bugfixes.
12.36 -<p>
12.37 -
12.38 -
12.39 -<B>tolua</B> is a tool that greatly simplifies the integration of C/C++
12.40 -code with <A HREF="http://www.tecgraf.puc-rio.br/lua">Lua</A>. Based on
12.41 -a <I>cleaned</I> <I>header file</I> (or extracts from real header files),
12.42 -<B>tolua</B> automatically generates
12.43 -the binding code to access C/C++ features from Lua. Using Lua API and tag
12.44 -method facilities, <B>tolua </B>maps C/C++ constants, external variables,
12.45 -functions, classes, and methods to Lua.
12.46 -<P>This manual is for <B>tolua++</B> version 1.0 and is implemented upon Lua
12.47 -5.0 and based on <b>tolua 5.0</b>. See <A HREF="#changes-v30">Compatibility</A>
12.48 -for details on switching from older versions.
12.49 -<P>The sections below describe how to use <B>tolua</B>. Please <A HREF="mailto:tolua@codenix.com">contact us</A>
12.50 -with bug reports, suggestions, and comments.
12.51 -<UL>
12.52 -<LI>
12.53 -Shortcuts:</LI>
12.54 -
12.55 -<UL>
12.56 -<LI>
12.57 -<A HREF="#introduction">How <B>tolua</B> works</A></LI>
12.58 -
12.59 -<LI>
12.60 -<A HREF="#using">How to use <B>tolua</B></A></LI>
12.61 -
12.62 -<LI>
12.63 -<A HREF="#basics">Basic Concepts</A></LI>
12.64 -
12.65 -<LI>
12.66 -<A HREF="#constants">Binding constants</A></LI>
12.67 -
12.68 -<LI>
12.69 -<A HREF="#variables">Binding external variables</A></LI>
12.70 -
12.71 -<LI>
12.72 -<A HREF="#functions">Binding functions</A></LI>
12.73 -
12.74 -<LI>
12.75 -<A HREF="#structs">Binding struct fields</A></LI>
12.76 -
12.77 -<LI>
12.78 -<A HREF="#classes">Binding classes and methods</A></LI>
12.79 -
12.80 -<li>
12.81 -<a href="#propeties">Binding properties</a></li>
12.82 -
12.83 -<li>
12.84 -<a href="#templates">Class Templates</a></li>
12.85 -
12.86 -<LI>
12.87 -<A HREF="#modules">Module definition</A></LI>
12.88 -
12.89 -<LI>
12.90 -<A HREF="#renaming">Renaming constants, variables and functions</A></LI>
12.91 -
12.92 -<li>
12.93 -<a href="#additional_features">Additional features</a></li>
12.94 -
12.95 -<LI>
12.96 -<A HREF="#additional">Storing additional fields</A></LI>
12.97 -
12.98 -<LI>
12.99 -<A HREF="#utilities">Exported utility functions</A></LI>
12.100 -
12.101 -<LI>
12.102 -<A HREF="#embedded">Embedded Lua code</A></LI>
12.103 -
12.104 -<LI>
12.105 -<a HREF="#customizing">Customizing tolua++</a></li>
12.106 -
12.107 -<li>
12.108 -<a href="#compatibility">Compatibility with older versions</a></li>
12.109 -
12.110 -<li>
12.111 -<A HREF="#changes-v30">Changes since v3 *</A></li>
12.112 -
12.113 -<LI>
12.114 -<A HREF="#changes-v2">Changes since v2.*</A></LI>
12.115 -
12.116 -<LI>
12.117 -<A HREF="#changes-v1">Changes since v1.*</A></LI>
12.118 -
12.119 -<LI>
12.120 -<A HREF="#credits">Credits</A></LI>
12.121 -
12.122 -<LI>
12.123 -<A HREF="#availability">Availability</A></LI>
12.124 -</UL>
12.125 -</UL>
12.126 -
12.127 -<HR WIDTH="100%">
12.128 -<H3>
12.129 -<A NAME="introduction"></A>How tolua works</H3>
12.130 -To use <B>tolua</B>, we create a <I>package file</I>, a C/C++ cleaned header
12.131 -file<I>,</I> listing the constants, variables, functions, classes, and
12.132 -methods we want to export to the Lua environment. Then <B>tolua</B> parses
12.133 -this file and creates a C/C++ file that automatically binds the C/C++ code
12.134 -to Lua. If we link the created file with our application, the specified
12.135 -C/C++ code can be accessed from Lua.<br>
12.136 -A package file can also include regular header files, other package files,
12.137 -or lua files.<br>
12.138 -<P>Let's start with some examples. If we specify as input the following
12.139 -C-like header file to <B>tolua</B>:
12.140 -<PRE>#define FALSE 0
12.141 -#define TRUE 1
12.142 -
12.143 -enum {
12.144 - POINT = 100,
12.145 - LINE,
12.146 - POLYGON
12.147 -}</PRE>
12.148 -
12.149 -<PRE>Object* createObejct (int type);
12.150 -void drawObject (Object* obj, double red, double green, double blue);
12.151 -int isSelected (Object* obj);</PRE>
12.152 -A C file that binds such a code to Lua is automatically generated. Therefore,
12.153 -in Lua code, we can access the C code, writing, for instance:
12.154 -<PRE>...
12.155 -myLine = createObject(LINE)
12.156 -...
12.157 -if isSelected(myLine) == TRUE then
12.158 - drawObject(myLine, 1.0, 0.0, 0.0);
12.159 -else
12.160 - drawObject(myLine, 1.0, 1.0, 1.0);
12.161 -end
12.162 -...</PRE>
12.163 -Also, consider a C++-like header file:
12.164 -<PRE>#define FALSE 0
12.165 -#define TRUE 1</PRE>
12.166 -
12.167 -<PRE>class Shape
12.168 -{
12.169 - void draw (void);
12.170 - void draw (double red, double green, double blue);
12.171 - int isSelected (void);
12.172 -};</PRE>
12.173 -
12.174 -<PRE>class Line : public Shape
12.175 -{
12.176 - Line (double x1, double y1, double x2, double y2);
12.177 - ~Line (void);
12.178 -};</PRE>
12.179 -If this file is used as input to <B>tolua</B>, a C++ file is automatically
12.180 -generated proving access to such a code from Lua. Therefore, it would be
12.181 -valid to write Lua statements like:
12.182 -<PRE>...
12.183 -myLine = Line:new (0,0,1,1)
12.184 -...
12.185 -if myLine:isSelected() == TRUE then
12.186 - myLine:draw(1.0,0.0,0.0)
12.187 -else
12.188 - myLine:draw()
12.189 -end
12.190 -...
12.191 -myLine:delete()
12.192 -...</PRE>
12.193 -The package file (usually with extension <TT>.pkg</TT>) passed to <B>tolua</B>
12.194 -is not the real C/C++ header file, but a <I>cleaned </I>version of it.
12.195 -<B>tolua</B>
12.196 -does not implement a complete parse to interpret C/C++ code, but it understands
12.197 -a few declarations that are used to describe the features that are to be
12.198 -exported to Lua. Regular header files can be included into packages files; <b>tolua</b>
12.199 -will extract the code specified by the user to parse from the header (see <a href="#basics">Basic Concepts</a>).
12.200 -<H3>
12.201 -<A NAME="using"></A>How to use toLua</H3>
12.202 -<B>tolua </B>is composed by two pieces of code: an executable and a library.
12.203 -The executable represents the parser that reads a package file and output
12.204 -a C/C++ code that implements the binding to access the C/C++ features from
12.205 -Lua. If the package file is a C++ like code (i.e., includes class definitions),
12.206 -a C++ code is generated. If the cleaned header file is a C like code (i.e.,
12.207 -without classes), a C code is generated. <B>tolua</B> accepts a set of
12.208 -options. Running <TT>"tolua -h"</TT> displays the current accepted options.
12.209 -For instance, to parse a file called <TT>myfile.pkg
12.210 -</TT>generating the
12.211 -binding code in <TT>myfile.c</TT>, we do:
12.212 -<P><TT>tolua -o myfile.c myfile.pkg</TT>
12.213 -<P>The generated code must be compiled and linked with the application
12.214 -to provide the desired access from Lua. Each parsed file represents a package
12.215 -being exported to Lua. By default, the package name is the input file root
12.216 -name (<TT>myfile </TT>in the example). The user can specify a different
12.217 -name for the package:
12.218 -<P><TT>tolua -n pkgname -o myfile.c myfile.pkg</TT>
12.219 -<P>The package should also be explicitly initialized. To initialize the
12.220 -package from our C/C++ code, we must declare and call the initialization
12.221 -function. The initialization function is defined as
12.222 -<P><TT>int tolua_<I>pkgname</I>_open (void);</TT>
12.223 -<P>where <I><TT>pkgname </TT></I>represents the name of the package being
12.224 -bound. If we are using C++, we can opt for automatic initialization:
12.225 -<P><TT>tolua -a -n pkgname -o myfile.c myfile.pkg</TT>
12.226 -<P>In that case, the initialization function is automatically called. However,
12.227 -if we are planning to use multiple Lua states, automatic initialization
12.228 -does not work, because the order static variables are initialized in C++
12.229 -is not defined.
12.230 -<!--
12.231 -<P>The current <B>tolua</B> version also exports a closing function, which
12.232 -can be called to unbind the package.
12.233 -<P><TT>void tolua_<I>pkgname</I>_close (void);</TT>
12.234 --->
12.235 -<P>Optionally, the prototype of the <TT>open</TT> function
12.236 -can be outputted to a header file, which name is given by the <TT>-H</TT>
12.237 -option.
12.238 -<P>The binding code generated by <B>tolua </B>uses a set of functions defined
12.239 -in the <B>tolua </B>library. Thus, this library also has to be linked with
12.240 -the application. The file <TT>tolua.h</TT> is also necessary to compile
12.241 -the generated code.
12.242 -<P>An application can use tolua object oriented framework (see <A HREF="#utilities">exported
12.243 -utility functions</A>) without binding any package. In that case, the application
12.244 -must call <B>tolua </B>initialization function (this function is called
12.245 -by any package file initialization function):
12.246 -<P><TT>int tolua_open (void);</TT>
12.247 -<!--
12.248 -<P>If multiple Lua states are to be used, after setting a Lua state, we
12.249 -need to call a function to restore <B>tolua </B>internal state:
12.250 -<P><TT>void tolua_restorestate (void);</TT>
12.251 --->
12.252 -<H3>
12.253 -<A NAME="basics"></A>Basic Concepts</H3>
12.254 -The first step in using <B>tolua</B> is to create the package file. Starting
12.255 -with the real header files, we clean them by declaring the features we
12.256 -want to access from Lua in a format that <B>tolua</B> can understand. The
12.257 -format <B>tolua</B> understands is simple C/C++ declarations as described
12.258 -below.
12.259 -
12.260 -<H4>Including files</h4>
12.261 -
12.262 -A package file may include other package file. The general format
12.263 -to do that is:
12.264 -<p>
12.265 -<TT>$pfile "<I>include_file</I>"</TT>
12.266 -<p>
12.267 -A package file may also include regular C/C++ header files, using the <TT>hfile</TT>
12.268 -or <TT>cfile</tt> directive:
12.269 -<p>
12.270 -
12.271 -<tt>$cfile "example.h"</tt>
12.272 -<p>
12.273 -In wich case, <b>tolua</b> will extract the code enclosed between <tt>tolua_begin</tt>
12.274 -and <tt>tolua_end</tt>, or or <tt>tolua_export</tt> for a single line. Consider this C++ header as example:
12.275 -
12.276 -<PRE>
12.277 -
12.278 -#ifndef EXAMPLE_H
12.279 -#define EXAMPLE_H
12.280 -
12.281 -class Example { // tolua_export
12.282 -
12.283 -private:
12.284 -
12.285 - string name;
12.286 - int number;
12.287 -
12.288 -public:
12.289 -
12.290 - void set_number(int number);
12.291 -
12.292 - //tolua_begin
12.293 -
12.294 - string get_name();
12.295 - int get_number();
12.296 -};
12.297 -// tolua_end
12.298 -
12.299 -#endif
12.300 -</pre>
12.301 -
12.302 -<p>
12.303 -In this case, the code that's not supported by <b>tolua</b> (the
12.304 -private part of the class), along with the function <tt>set_number</tt>
12.305 -is left outside of the package that includes this header.
12.306 -<p>
12.307 -
12.308 -Finally, lua files can be included on a package file, using <tt>$lfile</tt>:
12.309 -<p>
12.310 -
12.311 -<tt>$lfile "example.lua"</tt>
12.312 -<p>
12.313 -
12.314 -<b>New on tolua++</b>: an extra way to include source files is available sonce
12.315 -version 1.0.4 of <b>tolua++</b>, using <tt>ifile</tt>:
12.316 -<p>
12.317 -
12.318 -<tt>$ifile "filename"</tt>
12.319 -<p>
12.320 -
12.321 -<tt>ifile</tt> also takes extra optional parameters after the filename, for example:
12.322 -<p>
12.323 -
12.324 -<tt>
12.325 -$ifile "widget.h", GUI<br>
12.326 -$ifile "vector.h", math, 3d
12.327 -</tt>
12.328 -<p>
12.329 -
12.330 -<tt>ifile</tt>'s default behaviour is to include the whole file, untouched. However,
12.331 -the contents of the file and the extra parameters are put through the <tt>include_file_hook</tt>
12.332 -function before being included into the package (see <a href="#customizing">Customizing tolua++</a>
12.333 -for more details).
12.334 -<p>
12.335 -
12.336 -<H4>
12.337 -Basic types</H4>
12.338 -<B>tolua </B>automatically maps C/C++ basic types to Lua basic types. Thus,
12.339 -<TT>char</TT>,
12.340 -<TT>int</TT>,
12.341 -<TT>float</TT>, and <TT>double </TT>are mapped to the Lua type <TT>number</TT>;<TT>
12.342 -char*</TT> is mapped to <TT>string</TT>; and<TT> void*</TT> is mapped to
12.343 -<TT>userdata</TT>. Types may be preceded by modifiers (<TT>unsigned</TT>,
12.344 -<TT>static</TT>, <TT>short</TT>, <TT>const</TT>, etc.); however, be aware
12.345 -that <B>tolua </B>ignores the modifier <TT>const</TT> if applied to basic
12.346 -types. Thus, if we pass a constant basic type to Lua and then pass it back
12.347 -to C/C++ code where a non constant is expected, the constant to non constant
12.348 -conversion will be silently done.
12.349 -<P>Functions in C/C++ can also manipulate Lua objects explicitly. Thus
12.350 -<TT>lua_Object</TT>
12.351 -is also considered a basic type. In this case, any Lua value matches it.
12.352 -<p>
12.353 -
12.354 -<b>New on tolua++</b>: The C++ type <tt>string</tt> is also considered a basic type, and is passed as
12.355 -a value to lua (using the <tt>c_str()</tt> method). This feature can be turned off
12.356 -with the command line option <tt>-S</tt>.
12.357 -
12.358 -<H4>
12.359 -User defined types</H4>
12.360 -All other types that appear in the package file being processed are considered
12.361 -user defined types. These are mapped to tagged userdata type in Lua. Lua
12.362 -can only store pointers to user defined types; although, <B>tolua
12.363 -</B>automatically
12.364 -makes the necessary arrangement to deal with references and values. For
12.365 -instance, if a function or method returns a value of user defined type,
12.366 -<B>tolua
12.367 -</B>allocates
12.368 -a clone object when returning it to Lua and sets the garbage collection
12.369 -tag method to automatically free the allocated object when no longer in
12.370 -use by Lua.
12.371 -<P>For user defined types, <tt>const</tt>ness is preserved. Thus passing a non constant
12.372 -user defined type to a function that expects constant type generates an
12.373 -type mismatching error.
12.374 -<H4>
12.375 -<TT>NULL </TT>and <TT>nil</TT></H4>
12.376 -C/C++ <TT>NULL</TT> or <TT>0 </TT>pointers are mapped to Lua
12.377 -<TT>nil </TT>type;
12.378 -conversely, <TT>nil </TT>may be specified wherever a C/C++ pointer is expected.
12.379 -This is valid for any type: <TT>char*</TT>,
12.380 -<TT>void*</TT>, and pointers
12.381 -to user defined types.
12.382 -<H4>
12.383 -Typedefs</H4>
12.384 -<B>tolua </B>also accepts simple typedef<I>'s </I>inside the package files.
12.385 -Any occurrence of a type after its definition is mapped by <B>tolua
12.386 -</B>to
12.387 -the base type. They are useful because several packages redefine the basic
12.388 -C/C++ types to their own types. For instance, one can define the type <TT>real
12.389 -</TT>to
12.390 -represent a <TT>double</TT>. In that case, <TT>real
12.391 -</TT>can be used to
12.392 -specify the variable types inside the package file interpreted by <B>tolua</B>,
12.393 -but only if we include the following definition before any use of the type
12.394 -<TT>real</TT>.
12.395 -<P><TT>typedef double real;</TT>
12.396 -<P>Otherwise, <TT>real </TT>would be interpreted as a user defined type
12.397 -and would not be mapped to Lua numbers.
12.398 -<H4>
12.399 -Including real header files</H4>
12.400 -In the package file, we must specify which are the real header files that
12.401 -should be included so that the generated code can access the constants,
12.402 -variables, functions, and classes we are binding. Any line in the package
12.403 -file beginning with a <B>$ </B>(except $[hclp]file, $[ , and $] lines) is
12.404 -insert into the generated binding C/C++ code without any change, but the
12.405 -elimination of the <B>$</B> itself. We use this feature to include the
12.406 -real header files. So, our package files will usually start with a set
12.407 -of <B>$</B> beginning lines specifying the files that must be included,
12.408 -that is, the files the package file is based on.
12.409 -<PRE>/* specify the files to be included */</PRE>
12.410 -
12.411 -<PRE>$#include "header1.h" // include first header
12.412 -$#include "header2.h" // include second header</PRE>
12.413 -As illustrated, <B>tolua </B>also accepts comments, using C or C++ convention,
12.414 -inside the package file. Nested C-like comments can also be used.
12.415 -<p>
12.416 -Also note that files included with <tt>$cfile</tt> or <tt>$hfile</tt> don't
12.417 -need to be included using this method, this is done automatically by <b>tolua</b>.
12.418 -
12.419 -<P>In the following sections, we describe how to specify the C/C++ code
12.420 -we want to bind to Lua. The formats are simplified valid C/C++ statements.
12.421 -
12.422 -<H3>
12.423 -<A NAME="constants"></A>Binding constants</H3>
12.424 -To bind constants, <B>tolua </B>accepts both define's and enum's. For define's
12.425 -the general format is:
12.426 -<PRE><B>#define</B> <I>NAME </I>[ <I>VALUE </I>]</PRE>
12.427 -The value, as showed above, is optional. If such a code is inserted inside
12.428 -the file being processed, <B>tolua </B>generates a code that allows the
12.429 -use of <I><TT>NAME </TT></I>as a Lua global variable that has the corresponding
12.430 -C/C++ constant value. Only numeric constants are accepted.
12.431 -<p>
12.432 -<b>New on tolua++</b>: All other preprocessor directives are ignored.
12.433 -<P>For enum's, the general format is:
12.434 -<PRE><B>enum {
12.435 -</B> <I><TT>NAME1 </TT></I>[ <B>=</B> <I>VALUE1 </I>] <B>,
12.436 -</B> <I>NAM</I>E2 [ <B>=</B> <I>VALUE2 </I>] <B>,
12.437 -</B> ...
12.438 - <I>NAMEn </I>[ <B>=</B> <I>VALUEn </I>]
12.439 -<B>};</B></PRE>
12.440 -Similarly, <B>tolua</B> creates a set of global variables, named <I><TT>NAMEi</TT></I>,
12.441 -with their corresponding values.
12.442 -<H3>
12.443 -<A NAME="variables"></A>Binding external variables</H3>
12.444 -Global extern variables can also be exported. In the cleaned header file
12.445 -they are specified as:
12.446 -<PRE><TT>[</TT><B>extern</B><TT>]</TT><B> </B><I>type var</I><B>;</B></PRE>
12.447 -<B>tolua</B> binds such declarations to Lua global variables. Thus, in
12.448 -Lua, we can access the C/C++ variable naturally. If the variable is non
12.449 -constant, we can also assign the variable a new value from Lua. Global
12.450 -variables that represent arrays of value can also be bound to Lua. Arrays
12.451 -can be of any type. The corresponding Lua objects for arrays are Lua tables
12.452 -indexed with numeric values; however, be aware that index 1 in Lua is mapped
12.453 -to index 0 in an C/C++ array. Arrays must be pre dimensioned. For instance:
12.454 -<P><TT>double v[10];</TT>
12.455 -
12.456 -<p>
12.457 -<b>New on tolua++</b>: External variables can use the <tt>tolua_readonly</tt> modifier (see <a href="#additional_features">Additional Features</a>)
12.458 -
12.459 -<H3>
12.460 -<A NAME="functions"></A>Binding functions</H3>
12.461 -Functions are also specified as conventional C/C++ declarations:
12.462 -<PRE><I>type funcname </I><B>(</B><I>type1 par1</I>[<B>,</B> <I>type2 <TT>par2</TT></I>[<B>,.</B>..<I>typeN parN</I>]]<B>);</B></PRE>
12.463 -The returned type can be <TT>void</TT>, meaning no value is returned. A
12.464 -function can also have no parameter. In that case, <TT>void </TT>may be
12.465 -specified in the place of the list of parameters. The parameter types must
12.466 -follow the rules already posted. <B>tolua </B>creates a Lua function binding
12.467 -the C/C++ function. When calling a function from Lua, the parameter types
12.468 -must match the corresponding C/C++ types, otherwise, <B>tolua
12.469 -</B>generates
12.470 -an error and reports which parameter is wrongly specified. If a parameter
12.471 -name is omitted, <B>tolua </B>names it automatically, but its type should
12.472 -be a basic type or user type previously used.
12.473 -<H4>
12.474 -Arrays</H4>
12.475 -<B>tolua </B>also deals with function or method parameters that represent
12.476 -arrays of values. The nice thing about arrays is that the corresponding
12.477 -Lua tables have their values updated if the C/C++ function changes the
12.478 -array contents.
12.479 -<P>The arrays must be pre dimensioned. For instance:
12.480 -<P><TT>void func (double a[3]);</TT>
12.481 -<P>is a valid function declaration for <B>tolua</B> and calling this function
12.482 -from Lua would be done by, for instance:
12.483 -<P><TT>p = {1.0,1.5,8.6}</TT>
12.484 -<BR><TT>func (p)</TT>
12.485 -<P>The array dimension need not be a constant expression; the dimension
12.486 -can also be specified by any expression that can be evaluated in run time.
12.487 -For instance:
12.488 -<P><TT>void func (int n, int m, double image[n*m]);</TT>
12.489 -<P>is also valid since the expression <TT>n*m</TT> is valid in the binding
12.490 -function scope. However, be aware that <B>tolua </B>uses dynamic allocation
12.491 -for binding this function, what can degrade the performance.
12.492 -<P>Despite the dimension specification, it is important to know that all
12.493 -arrays passed to the actual C/C++ function are in the local scope of the
12.494 -binding function. So, if the C/C++ function being called needs to hold
12.495 -the array pointer for later use, the binding code will <I>not </I>work
12.496 -properly.
12.497 -<H4>
12.498 -Overloaded functions</H4>
12.499 -Overloaded functions are accepted. Remember that the distinction between
12.500 -two functions with the same name is made based on the parameter types that
12.501 -are mapped to Lua. So, although
12.502 -<P><TT>void func (int a);</TT>
12.503 -<BR><TT>void func (double a);</TT>
12.504 -<P>represent two different functions in C++, they are the same function
12.505 -for <B>tolua</B>, because both <TT>int </TT>and <TT>double </TT>are mapped
12.506 -to the same Lua type: <TT>number</TT>.
12.507 -<P>Another tricky situation occurs when expecting pointers. Suppose:
12.508 -<PRE>void func (char* s);
12.509 -void func (void* p);
12.510 -void func (Object1* ptr);
12.511 -void func (Object2* prt);</PRE>
12.512 -Although these four functions represent different functions in C++, a Lua
12.513 -statement like:
12.514 -<PRE>func(nil)</PRE>
12.515 -matches all of them.
12.516 -<P>It is important to know that <B>tolua </B>decides which function will
12.517 -be called in run-time, trying to match each provided function. <B>tolua
12.518 -</B>first
12.519 -tries to call the last specified function; if it fails, <B>tolua
12.520 -</B>then
12.521 -tries the previous one. This process is repeated until one function matches
12.522 -the calling code or the first function is reached. For that reason, the
12.523 -mismatching error message, when it occurs, is based on the first function
12.524 -specification. When performance is important, we can specify the most used
12.525 -function as the last one, because it will be tried first.
12.526 -<P><B>tolua</B> allows the use of overloaded functions in C, see <A HREF="#renaming">Renaming
12.527 -</A>for
12.528 -details.
12.529 -<H4>
12.530 -Default parameter values</H4>
12.531 -The last function parameters can have associated default values. In that
12.532 -case, if the function is called with fewer parameters, the default values
12.533 -are assumed. The format to specify the default values is the same as the
12.534 -one used in C++ code:
12.535 -<P><TT><I>type funcname </I><B>(</B><I>...</I><B>,</B><I> typeN-1 parN-1
12.536 -[= valueN-1]<B>,</B> typeN parN [= valueN]</I><B>);</B></TT>
12.537 -<P><B>toLua </B>implements this feature without using any C++ mechanism;
12.538 -so, it can be used also to bind C functions.
12.539 -<P>We can also specify default values for the elements of an array (there
12.540 -is no way to specify a default value for the array itself, though). For
12.541 -instance:
12.542 -<P><TT>void func (int a[5]=0);</TT>
12.543 -<P>sets the default element values to zero, thus the function can be called
12.544 -from Lua with an uninitialized table.
12.545 -<P>For Lua object types (<TT>lua_Object</TT>), <B>tolua </B>defines a constant
12.546 -that can be used to specify <TT>nil </TT>as default value:
12.547 -<P><TT>void func (lua_Object lo = TOLUA_NIL);</TT>
12.548 -<p>
12.549 -
12.550 -<b>New on tolua++</b>: C++ class constructors are valid
12.551 -as default parameters. For example:
12.552 -<p>
12.553 -<tt>void set_color(const Color& color = Color(0,0,0));</tt>
12.554 -<p>
12.555 -
12.556 -<H4>
12.557 -Multiple returned values</H4>
12.558 -In Lua, a function may return any number of values. <B>tolua </B>uses this
12.559 -feature to simulate values passed by reference. If a function parameter
12.560 -is specified as a pointer to or reference of a basic type or a pointer
12.561 -to or reference of a pointer to an user defined type, <B>tolua </B>accepts
12.562 -the corresponding type as input and returns, besides the conventional function
12.563 -returned value, if any, the updated parameter value.
12.564 -<P>For instance, consider a C function that swaps two values:
12.565 -<P><TT>void swap (double* x, double* y);</TT>
12.566 -<P>or
12.567 -<P><TT>void swap (double& x, double& y);</TT>
12.568 -<P>If such a function is declared in the package file, <B>tolua </B>binds
12.569 -it as a function receiving two numbers as input and returning two numbers.
12.570 -So, a valid Lua code would be:
12.571 -<P><TT>x,y = swap(x,y)</TT>
12.572 -<P>If the input values are not used, the use of default parameter value
12.573 -allows calling the function from Lua without specifying them:
12.574 -<P><TT>void getBox (double* xmin=0, double* xmax=0, double* ymin=0, double*
12.575 -ymax=0);</TT>
12.576 -<P>In Lua:
12.577 -<P><TT>xmin, xmax, ymin, ymax = getBox()</TT>
12.578 -<P>With user defined types, we would have for instance:
12.579 -<P><TT>void update (Point** p);</TT>
12.580 -<P>or
12.581 -<P><TT>void update (Point*& p);</TT>
12.582 -<H3>
12.583 -<A NAME="structs"></A>Binding struct fields</H3>
12.584 -User defined types are nicely bound by <B>tolua</B>. For each variable
12.585 -or function type that does not correspond to a basic type, <B>tolua </B>automatically
12.586 -creates a tagged userdata to represent the C/C++ type. If the type corresponds
12.587 -to a struct, the struct fields can be directly accessed from Lua, indexing
12.588 -a variable that holds an object of such a type. In C code, these types
12.589 -are commonly defined using typedef's:
12.590 -<PRE><B>typedef struct [name]</B><I> </I><B>{
12.591 -</B> <I>type1 fieldname1</I><B>;
12.592 -</B> <I>type2 fieldname2</I><B>;
12.593 -</B> ...
12.594 - <I>typeN fieldnameN</I><B>;
12.595 -} </B><I>typename</I><B>;</B></PRE>
12.596 -If such a code is inserted in the package file being processed, <B>tolua
12.597 -</B>allows
12.598 -any variable that holds an object of type <I><TT>typename </TT></I>to access
12.599 -any listed field indexing the variable by the field name. For instance,
12.600 -if <TT>var </TT>holds a such object, <I><TT>var.fieldnamei</TT></I> accesses
12.601 -the field named <I><TT>fieldnamei</TT></I>.
12.602 -<P>Fields that represent arrays of values can also be mapped:
12.603 -<P><TT>typedef struct {</TT>
12.604 -<BR><TT> int x[10];</TT>
12.605 -<BR><TT> int y[10];</TT>
12.606 -<BR><TT>} Example;</TT>
12.607 -<BR>
12.608 -<H3>
12.609 -<A NAME="classes"></A>Binding classes and methods</H3>
12.610 -C++ class definitions are also supported by <B>tolua</B>. Actually, the
12.611 -<B>tolua
12.612 -</B>deals
12.613 -with single inheritance and polymorphism in a natural way. The subsections
12.614 -below describe what can be exported by a class definition.
12.615 -<H4>
12.616 -Specifying inheritance</H4>
12.617 -If <TT>var </TT>is a Lua variable that holds an object of a derived class,
12.618 -<TT>var
12.619 -</TT>can
12.620 -be used wherever its base class type is expected and <TT>var
12.621 -</TT>can access
12.622 -any method of its base class. For this mechanism to take effect, we must
12.623 -indicate that the derived class actually inherits the base class. This
12.624 -is done in the conventional way:
12.625 -<PRE><B>class </B><I>classname </I><B>: public</B> <I>basename
12.626 -</I><B>{</B></PRE>
12.627 -
12.628 -<PRE> /* class definition */</PRE>
12.629 -
12.630 -<PRE><B>};</B></PRE>
12.631 -<p>
12.632 -
12.633 -In this case, the definition of <tt>basename</tt> needs to appear before <tt>classname</tt>
12.634 -if the inheritance properties are to be taken advantage of from lua.
12.635 -
12.636 -<h4>Multiple inheritance</h4>
12.637 -
12.638 -<b>tolua++</b> (starting from version 1.0.4) supports multiple inheritance by allowing you
12.639 -to access the extra parents 'manually'.
12.640 -<p>
12.641 -For example, consider the following class:
12.642 -<p>
12.643 -
12.644 -<PRE>
12.645 -class Slider : public Widget, public Range {
12.646 - ...
12.647 -};
12.648 -</PRE>
12.649 -<p>
12.650 -
12.651 -An object of type 'Slider' will fully retain it's inheritance with Widget,
12.652 -and will contain a 'member' of type Range, which will return the object
12.653 -casted to the correct base type.
12.654 -<p>
12.655 -
12.656 -For example:
12.657 -<p>
12.658 -
12.659 -<PRE>
12.660 -slider = Slider:new()
12.661 -slider:show() -- a Widget method
12.662 -
12.663 -slider:set_range(0, 100) -- this won't work, because
12.664 - -- set_range is a method from Range
12.665 -
12.666 -slider.__Range__:set_range(0, 100) -- this is the correct way
12.667 -</PRE>
12.668 -
12.669 -<p>
12.670 -
12.671 -This is an experimental feature.
12.672 -<p>
12.673 -
12.674 -<H4>
12.675 -Specifying exported members and methods</H4>
12.676 -As for struct fields, class fields, static or not, can be exported. Class
12.677 -methods and class static methods can also be exported. Of course, they
12.678 -must be declared as public in the actual C++ code (the
12.679 -<TT>public:</TT>keyword may appear in the package files, it will be ignored by <b>tolua</b>).
12.680 -<P>For each bound class, <B>tolua </B>creates a Lua table and stores it
12.681 -at a variable which name is the name of the C++ class. This tables may contain other
12.682 -tables that represent other tables, the way C++ classes may contain other classes and structs.
12.683 -Static exported
12.684 -fields are accessed by indexing this table with the field names (similar
12.685 -to struct fields). Static methods are also called using this table, with a colon.
12.686 -Non static exported fields are accessed by indexing
12.687 -the variable that holds the object. Class methods follow the format of
12.688 -the function declaration showed above. They can be accessed from Lua code
12.689 -using the conventional way Lua uses to call methods, applied of course
12.690 -to a variable that holds the appropriate object or to the class table,
12.691 -for static methods.
12.692 -<P>There are a few special methods that are also supported by <B>tolua</B>.
12.693 -Constructors are called as static methods, named <TT>new</TT>, <tt>new_local</tt> (on <b>tolua++</b>),
12.694 -or calling the class name directly (also on <b>tolua++</b>, see below for the difference betwheen these methods). Destructors
12.695 -are called as a conventional method called <TT>delete</TT>.
12.696 -<P>Note that <B>tolua </B>does support overload. This applies even for
12.697 -constructors. Also note that the <TT>virtual </TT>keyword has no effect
12.698 -in the package file.
12.699 -<P>The following code exemplifies class definitions that can be interpreted
12.700 -by <B>tolua</B>.
12.701 -<PRE>class Point {
12.702 - static int n; // represents the total number of created Points
12.703 - static int get_n(); // static method
12.704 -
12.705 - double x; // represents the x coordinate
12.706 - double y; // represents the y coordinate</PRE>
12.707 -
12.708 -<PRE> static char* className (void); // returns the name of the class</PRE>
12.709 -
12.710 -<PRE> Point (void); // constructor 1
12.711 - Point (double px, double py); // constructor 2
12.712 - ~Point (void); // destructor</PRE>
12.713 -
12.714 -<PRE> Point add (Point& other); // add points, returning another one
12.715 -};</PRE>
12.716 -
12.717 -<PRE>class ColorPoint : public Color {
12.718 - int red; // red color component [0 - 255]
12.719 - int green; // green color component [0 - 255]
12.720 - int blue; // blue color component [0 - 255]</PRE>
12.721 -
12.722 -<PRE> ColorPoint (double px, double py, int r, int g, int b);
12.723 -};</PRE>
12.724 -If this segment of code is processed by <B>tolua</B>, we would be able
12.725 -to write the following Lua statements:
12.726 -<PRE>p1 = Point:new(0.0,1.0)
12.727 -p2 = ColorPoint:new(1.5,2.2,0,0,255)
12.728 -print(Point.n) -- would print 2
12.729 -print(Point:get_n()) -- would also print 2
12.730 -p3 = p1:add(p2)
12.731 -local p4 = ColorPoint()
12.732 -print(p3.x,p3.y) -- would print 1.5 and 3.2
12.733 -print(p2.red,p2.green,p2.blue) -- would print 0, 0, and 255
12.734 -p1:delete() -- call destructor
12.735 -p2:delete() -- call destructor</PRE>
12.736 -
12.737 -Note that we can only explicitly delete objects that we explicitly create.
12.738 -In the example above, the point <TT>p3</TT> will be garbage-collected by
12.739 -<B>tolua
12.740 -</B>automatically;
12.741 -we cannot delete it.
12.742 -<p>
12.743 -<b>New on tolua++</b>: Also note that <tt>p4</tt> is created by calling the class name directly (<tt>ColorPoint()</tt>); this has the same effect as calling <tt>new_local</tt>, wich
12.744 -leaves the object to be deleted by the garbaje collector, and it should not be
12.745 -deleted using <tt>delete</tt>. For each constructor on the pkg, one <tt>new</tt>,
12.746 -<tt>new_local</tt> and <tt>.call</tt> callback for the class is created.
12.747 -<P>Of course, we need to specify only the methods and members we want to
12.748 -access from Lua. Sometimes, it will be necessary to declare a class with
12.749 -no member or method just for the sake of not breaking a chain of inheritances.
12.750 -
12.751 -<h4>Using Regular functions as class methods</h4>
12.752 -<p>
12.753 -
12.754 -<b>tolua++</b> (starting from version 1.0.5) uses the keyword <b>tolua_outside</b> to specify regular functions
12.755 -as methods and static methods of a class or struct. For example:
12.756 -
12.757 -<PRE><tt>
12.758 -/////////////// position.h:
12.759 -
12.760 -typedef struct {
12.761 -
12.762 - int x;
12.763 - int y;
12.764 -} Position;
12.765 -
12.766 -Position* position_create();
12.767 -void position_set(Position* pos, int x, int y);
12.768 -
12.769 -/////////////// position.pkg:
12.770 -
12.771 -struct Position {
12.772 -
12.773 - int x;
12.774 - int y;
12.775 -
12.776 - static tolua_outside Position* position_create @ create();
12.777 - tolua_outside void position_set @ set(int x, int y);
12.778 -};
12.779 -
12.780 ---------------- position.lua
12.781 -
12.782 -local pos = Position:create()
12.783 -
12.784 -pos:set(10, 10)
12.785 -
12.786 -</tt></pre>
12.787 -
12.788 -Note that the <b>position_set</b> method takes a pointer to <b>Position</b> as its first parameter,
12.789 -this is ommited on the <b>tolua_outside</b> declaration. Also note that we cannot name our methods
12.790 -<b>new</b> or <b>new_local</b>, or as overloaded operators (see next section), this will result in
12.791 -undefined behaviour.
12.792 -
12.793 -
12.794 -<H4>
12.795 -Overloaded operators</H4>
12.796 -<B>tolua </B>automatically binds the following binary operators:
12.797 -<UL>
12.798 -<PRE>operator+ operator- operator* operator/
12.799 -operator< operator>= operator== operator[]</PRE>
12.800 -</UL>
12.801 -For the relational operators, <B>toLua </B>also automatically converts
12.802 -a returned <TT>0</TT> value into <TT>nil</TT>, so <I>false </I>in C becomes
12.803 -<I>false
12.804 -</I>in
12.805 -Lua.
12.806 -<P>As an example, suppose that in the code above, instead of having:
12.807 -<PRE> Point add (Point& other); // add points, returning another one</PRE>
12.808 -we had:
12.809 -<PRE> Point operator+ (Point& other); // add points, returning another one</PRE>
12.810 -In that case, in Lua, we could simply write:
12.811 -<PRE>p3 = p1 + p2</PRE>
12.812 -The indexing operator (<TT>operator[]</TT>) when receiving a numeric parameter
12.813 -can also be exported to Lua. In this case, <B>tolua </B>accepts reference
12.814 -as returned value, even for basic types. Then if a reference is returned,
12.815 -from Lua, the programmer can either get or set the value. If the returned
12.816 -value is not a reference, the programmer can only get the value. An example
12.817 -may clarify: suppose we have a vector class and bind the following operator:
12.818 -<PRE> double& operator[] (int index);</PRE>
12.819 -In this case, in Lua, we would be able to write: <TT>value = myVector[i]</TT>
12.820 -and also <TT>myVector[i] = value</TT>, wich updates the C++ object. However,
12.821 -if the bound operator was:
12.822 -<PRE> double operator[] (int index);</PRE>
12.823 -we would only be able to write: <TT>value = myVector[i]</TT>.
12.824 -<P>Free functions (i.e., not class members) that overload operators are
12.825 -not supported.
12.826 -
12.827 -<h3><a name="properties"></a>Binding Properties</h3>
12.828 -
12.829 -<b>tolua++</b> (starting from version 1.0.6) supports declaration of class propeties,
12.830 -using the <tt>tolua_property</tt> keyword. A
12.831 -property will look like a 'field' of the class, but it's value will be retrieved
12.832 -using class methods. For example:
12.833 -
12.834 -<pre>
12.835 -/////////////// label.h
12.836 -
12.837 -class Label {
12.838 -
12.839 -public:
12.840 -
12.841 - string get_name();
12.842 - void set_name(string p_name);
12.843 -
12.844 - Widget* get_parent();
12.845 -};
12.846 -
12.847 -/////////////// label.pkg
12.848 -class Label {
12.849 -
12.850 - tolua_property string name;
12.851 -
12.852 - tolua_readonly tolua_property Widget* parent;
12.853 -};
12.854 -
12.855 ---------------- label.lua
12.856 -
12.857 -local label = Label()
12.858 -
12.859 -label.name = "hello"
12.860 -print(label.name)
12.861 -
12.862 -label.parent:show()
12.863 -
12.864 -</pre>
12.865 -
12.866 -<h4>Property types</h4>
12.867 -<p>
12.868 -
12.869 -A property can have differt types, which determine how it's value will be set and retrieved.
12.870 -<b>tolua++</b> comes with 3 different built-in types:
12.871 -<p>
12.872 -
12.873 -<li> <tt>default</tt> will use 'get_name' and 'set_name' methods to access a property called 'name'
12.874 -<li> <tt>qt</tt> will use 'name' and 'setName'
12.875 -<li> <tt>overload</tt> will use 'name' and 'name' (as in 'string name(void);' to get and 'void name(string);' to set)
12.876 -<p>
12.877 -
12.878 -The property type can be appended at the end of the 'tolua_property' keyword on the declaration:
12.879 -
12.880 -<ul><tt>tolua_property__qt string name;</tt></ul>
12.881 -
12.882 -When no type is specified, <tt>default</tt> will be used, but this can be changed (see below).
12.883 -<p>
12.884 -
12.885 -<h4>Changing the default property type</h4>
12.886 -<p>
12.887 -
12.888 -The default property type can be changed using the 'TOLUA_PROPERTY_TYPE' macro. This will change the
12.889 -default type from the point of its invocation, until the end of the block that contains it. For example:
12.890 -<p>
12.891 -
12.892 -<pre>
12.893 -
12.894 -TOLUA_PROPERTY_TYPE(default); // default type for the 'global' scope
12.895 -
12.896 -namespace GUI {
12.897 -
12.898 - class Point {
12.899 -
12.900 - tolua_property int x; // will use get_x/set_x
12.901 - tolua_property int y; // will use get_y/set_y
12.902 - };
12.903 -
12.904 - TOLUA_PROPERTY_TYPE(qt); // changes default type to 'qt' for the rest of the 'GUI' namespace
12.905 -
12.906 - class Label {
12.907 -
12.908 - tolua_property string name; // will use name/setName
12.909 - };
12.910 -};
12.911 -
12.912 -class Sprite {
12.913 -
12.914 - tolua_property GUI::Point position; // will use get_position/set_position
12.915 -
12.916 - tolua_property__overload string name; // will use name/name
12.917 -};
12.918 -
12.919 -</pre>
12.920 -
12.921 -<h4>Adding custom property types</h4>
12.922 -<p>
12.923 -
12.924 -Custom property types can be added by redefining the function "get_property_methods_hook"
12.925 -(see <a href="#customizing">Customizing tolua++</a> for more details). The functions takes
12.926 -the property type and the name, and returns the setter and getter function names. For example:
12.927 -<p>
12.928 -
12.929 -<pre>
12.930 -
12.931 -/////////////// custom.lua
12.932 -
12.933 -function get_property_methods_hook(ptype, name)
12.934 -
12.935 - if ptype == "hungarian_string" then
12.936 -
12.937 - return "sGet"..name, "Set"..name
12.938 - end
12.939 -
12.940 - if ptype == "hungarian_int" then
12.941 -
12.942 - return "iGet"..name, "Set"..name
12.943 - end
12.944 - -- etc
12.945 -end
12.946 -
12.947 -/////////////// label.pkg
12.948 -class Label {
12.949 -
12.950 - tolua_property__hungarian_string string Name; // uses 'sGetName' and 'SetName'
12.951 -
12.952 - tolua_property__hungarian_int string Type; // uses 'iGetType' and 'SetType'
12.953 -};
12.954 -
12.955 -</pre>
12.956 -
12.957 -<h3><a name="templates"></a>Class Templates</h3>
12.958 -
12.959 -One of the additional features of <b>tolua++</b> is the support for class templates,
12.960 -by using the <tt>TEMPLATE_BIND</tt> directive. For example:
12.961 -
12.962 -<pre>
12.963 -class vector {
12.964 -
12.965 - TEMPLATE_BIND(T, int, string, Vector3D, double)
12.966 -
12.967 - void clear();
12.968 - int size() const;
12.969 -
12.970 - const T& operator[](int index) const;
12.971 - T& operator[](int index);
12.972 - void push_back(T val);
12.973 -
12.974 - vector();
12.975 - ~vector();
12.976 -};
12.977 -</pre>
12.978 -
12.979 -This code will create 4 versions of the object <tt>vector</tt>, one for each type
12.980 -specified on the <tt>TEMPLATE_BIND</tt> parameters, each replacing the macro <tt>T</tt>
12.981 -(specified as the first argument of <tt>TEMPLATE_BIND</tt>).
12.982 -Thus, the functions <tt>operator[]</tt>, <tt>&operator[]</tt> and <tt>push_back</tt>
12.983 -will have different signatures on each version of the object. The objects will be
12.984 -recognized as <tt>vector<type></tt> on further declarations, and the name of
12.985 -the table on Lua will be <tt>vector_type_</tt>. Thus, the following Lua code could be used:
12.986 -
12.987 -<pre>
12.988 -string_vector = vector_string_:new_local()
12.989 -string_vector:push_back("hello")
12.990 -string_vector:push_back("world")
12.991 -print(string_vector[0].." "..string_vector[1])
12.992 -</pre>
12.993 -
12.994 -Similarily, a template with more than 1 macro could be bound, and it could also
12.995 -inherit from another template:
12.996 -
12.997 -<pre>
12.998 -class hash_map : public map<K,V> {
12.999 -
12.1000 - TEMPLATE_BIND(K V, int string, string vector<double>)
12.1001 -
12.1002 - V get_element(K key);
12.1003 - void set_element(K key, V value);
12.1004 -
12.1005 - hash_map();
12.1006 - ~hash_map();
12.1007 -};
12.1008 -</tt></pre>
12.1009 -
12.1010 -In this example, one of the objects has another template as one of its types, so
12.1011 -it will be recognized as <tt>hash_map<string,vector<double> ></tt> while
12.1012 -its constructor will be on the Lua table hash_map_string_vector_double___ (see
12.1013 -<a href="#type_renaming">Type Renaming</a> for a better way to access these objects).
12.1014 -<p>
12.1015 -
12.1016 -Note that due to the complexity in the definition of some templates, you should be
12.1017 -careful on how you declare them. For example, if you create an object with type
12.1018 -<tt>hash_map<string,vector<double> ></tt> and then declare a variable
12.1019 -with type <tt>hash_map<string, vector<double> ></tt> (note the space
12.1020 -between string and vector), the type of the variable will not be recognized. The
12.1021 -safest way is to declare a typedef, and use that to use each type (this is also a
12.1022 -common practice on C++ programming). For example, using the previous declaration of
12.1023 -<tt>vector</tt>:
12.1024 -<p>
12.1025 -
12.1026 -<pre>
12.1027 -typedef vector<int> VectorInt;
12.1028 -
12.1029 -VectorInt variable;
12.1030 -</pre>
12.1031 -
12.1032 -<tt>TEMPLATE_BIND</tt> can be used with more than one parenthesis to open and close,
12.1033 -in order to be valid as a macro inside a regular .h file. The <tt>TEMPLATE_BIND</tt>
12.1034 -macro is declared on <tt>tolua.h</tt> as:
12.1035 -<p>
12.1036 -<tt>#define TEMPLATE_BIND(x)</tt>
12.1037 -<p>
12.1038 -
12.1039 -Also, the parameters can have double quotes. Thus, the following uses are valid:
12.1040 -<p>
12.1041 -
12.1042 -<pre>
12.1043 -TEMPLATE_BIND((T, int, float)) // to be used inside a real header file
12.1044 -TEMPLATE_BIND("K V", "string string", int double)
12.1045 -</pre>
12.1046 -
12.1047 -Function templates are not supported on this version.
12.1048 -
12.1049 -<H3>
12.1050 -<A NAME="modules"></A>Module definition</H3>
12.1051 -<B>tolua </B>allows us to group constants, variables, and functions in
12.1052 -a module. The module itself is mapped to a table in Lua, and its constants,
12.1053 -variables, and functions are mapped to fields in that table. The general
12.1054 -format to specify a module is:
12.1055 -<P><TT><B>module</B> name</TT>
12.1056 -<BR><B><TT>{</TT></B>
12.1057 -<BR><TT> ... // constant, variable, and function
12.1058 -declarations</TT>
12.1059 -<BR><B><TT>}</TT></B>
12.1060 -<P>Thus, if we bound the following module declaration:
12.1061 -<P><TT>module mod</TT>
12.1062 -<BR><TT>{</TT>
12.1063 -<BR><TT> #define N</TT>
12.1064 -<BR><TT> extern int var;</TT>
12.1065 -<BR><TT> int func (...):</TT>
12.1066 -<BR><TT>}</TT>
12.1067 -<P>In Lua we would be able to access such features by indexing the module:
12.1068 -<TT>mod.N</TT>,
12.1069 -<TT>mod.var</TT>,
12.1070 -<TT>mod.func</TT>.
12.1071 -<H3>
12.1072 -<A NAME="renaming"></A>Renaming constants, variables and functions</H3>
12.1073 -When exporting constants, variable, and functions (members of a class or
12.1074 -not), we can rename them, such that they will be bound with a different
12.1075 -name from their C/C++ counterparts. To do that, we write the name they
12.1076 -will be referenced in Lua after the character <TT>@</TT>. For instance:
12.1077 -<P><TT>extern int cvar @ lvar;</TT>
12.1078 -<P><TT>#define CNAME @ LNAME</TT>
12.1079 -<P><TT>enum {</TT>
12.1080 -<BR><TT> CITEM1 @ LITEM1,</TT>
12.1081 -<BR><TT> CITEM2 @ LITEM2,</TT>
12.1082 -<BR><TT> ...</TT>
12.1083 -<BR><TT>};</TT>
12.1084 -<P><TT>void cfunc @ lfunc (...);</TT>
12.1085 -<P><TT>class T</TT>
12.1086 -<BR><TT>{</TT>
12.1087 -<BR><TT> double cfield @ lfield;</TT>
12.1088 -<BR><TT> void cmeth @ lmeth (...);</TT>
12.1089 -<BR><TT> ...</TT>
12.1090 -<BR><TT>};</TT>
12.1091 -<P>In such a case, the global variable <TT>cvar </TT>would be identified
12.1092 -in Lua by <TT>lvar</TT>, the constant <TT>CNAME </TT>by <TT>LNAME</TT>,
12.1093 -and so on. Note that class cannot be renamed, because they represent types
12.1094 -in C.
12.1095 -<P>This renaming feature allows function overload in C, because we can
12.1096 -choose to export two different C functions with a same Lua name:
12.1097 -<P><TT>void glVertex3d @ glVertex (double x, double y, double z=0.0);</TT>
12.1098 -<BR><TT>void glVertexdv @ glVertex (double v[3]=0.0);</TT>
12.1099 -
12.1100 -<a name="type_renaming"></a><h3>Renaming Types</h3>
12.1101 -
12.1102 -Types can be renamed using the <tt>$renaming</tt> directive on pkg files, using the
12.1103 -format:
12.1104 -<p>
12.1105 -
12.1106 -<tt>$renaming real_name @ new_name</tt>
12.1107 -<p>
12.1108 -
12.1109 -The parameters to renaming can be Lua <i>patterns</i>. For example:
12.1110 -<p>
12.1111 -
12.1112 -<pre>
12.1113 -$renaming ^_+ @
12.1114 -$renaming hash_map<string,vector<double> > @ StringHash
12.1115 -</pre>
12.1116 -
12.1117 -The first example will remove all underscores at the beginning of all types,
12.1118 -the second will rename the template type hash_map<string,vector<double> >
12.1119 -to StringHash. Once renamed, the Lua table for each type can be accessed only by their
12.1120 -new name, for example: <tt>StringHash:new()</tt>
12.1121 -
12.1122 -<a name="additional_features"></a><h3>Additional features on tolua++</h3>
12.1123 -
12.1124 -<h4>Multiple variable declarations</h4>
12.1125 -
12.1126 -Multiple variables of the same type can be declared at the same time, for example:
12.1127 -<p>
12.1128 -<tt>float x,y,z;</tt>
12.1129 -<p>
12.1130 -will create 3 different variables of type float. Make sure you don't leave any
12.1131 -spaces between the commas, as that will raise a parse error.
12.1132 -<p>
12.1133 -
12.1134 -<h4>tolua_readonly</h4>
12.1135 -
12.1136 -Any variable declaration can use the <tt>tolua_readonly</tt> modifier, to ensure
12.1137 -that the variable is read-only, even when its type is not <tt>const</tt>. Example:
12.1138 -
12.1139 -<pre>
12.1140 -class Widget {
12.1141 -
12.1142 - tolua_readonly string name;
12.1143 -};
12.1144 -</pre>
12.1145 -
12.1146 -This feature could be used to 'hack' the support for other unsuported things like
12.1147 -<tt>operator-></tt>. Consider this example <tt>pkg</tt> file:
12.1148 -
12.1149 -<pre>
12.1150 -$hfile "node.h"
12.1151 -$#define __operator_arrow operator->()
12.1152 -$#define __get_name get_name()
12.1153 -</pre>
12.1154 -
12.1155 -And on the file <tt>node.h</tt>:
12.1156 -
12.1157 -<pre>
12.1158 -template class<T>
12.1159 -class Node { // tolua_export
12.1160 -
12.1161 -private:
12.1162 - string name;
12.1163 - T* value;
12.1164 -
12.1165 -public:
12.1166 -
12.1167 - T* operator->() {return value;};
12.1168 - string get_name() {return name;};
12.1169 -
12.1170 - // tolua_begin
12.1171 -
12.1172 - Node* next;
12.1173 - Node* prev;
12.1174 -
12.1175 - void set_name(string p_name) {name = p_name;};
12.1176 -
12.1177 - #if 0
12.1178 - tolua_readonly __operator_arrow @ p;
12.1179 - tolua_readonly __get_name @ name;
12.1180 -
12.1181 - TEMPLATE_BIND(T, Vector3D)
12.1182 - #endif
12.1183 -
12.1184 - Node();
12.1185 -};
12.1186 -// tolua_end
12.1187 -</pre>
12.1188 -
12.1189 -While not a pretty thing to do to a header file, this acomplishes a number of
12.1190 -things:
12.1191 -<p>
12.1192 -
12.1193 -<li> The method <tt>operator->()</tt> can be used from Lua by calling the variable
12.1194 -<tt>p</tt> on the object.</li>
12.1195 -<li> The method <tt>get_name()</tt> can be using from Lua by calling the variable
12.1196 -<tt>name</tt> on the boject.</li>
12.1197 -
12.1198 -Example lua usage:
12.1199 -
12.1200 -<pre>
12.1201 -node = Node_Vector3D_:new_local()
12.1202 --- do something with the node here --
12.1203 -print("node name is "..node.name)
12.1204 -print("node value is ".. node.p.x ..", ".. node.p.y ..", ".. node.p.z)
12.1205 -</pre>
12.1206 -
12.1207 -Since <b>tolua++</b> ignores all preprocessor directives (except for #define), <tt>node.h</tt>
12.1208 -remains a valid C++ header file, and also a valid source for <b>tolua++</b>,
12.1209 -eliminating the need to maintain 2 different files, even for objects with
12.1210 -unusual features such as these ones.
12.1211 -
12.1212 -<p>
12.1213 -
12.1214 -The ability to rename functions as variables might be expanded on future versions.
12.1215 -
12.1216 -<A NAME="additional"></A><h3>Storing additional fields</H3>
12.1217 -Finally, it is important to know that even though the variables that hold
12.1218 -C/C++ objects are actually tagged userdata for Lua,<B> tolua</B> creates
12.1219 -a mechanism that allows us to store any additional field attached to these
12.1220 -objects. That is, these objects can be seen as conventional Lua tables.
12.1221 -<PRE>obj = <I>ClassName</I>:new()</PRE>
12.1222 -
12.1223 -<PRE>obj.myfield = 1 -- even though "myfield" does not represent a field of ClassName</PRE>
12.1224 -Such a construction is possible because, if needed, <B>tolua </B>automatically
12.1225 -creates a Lua table and associates it with the object. So that, the object
12.1226 -can store additional fields not mapped to C/C++, but actually stored in
12.1227 -the conjugate table. The Lua programmer accesses the C/C++ features and
12.1228 -these additional fields in an uniform way. Note that, in fact, these additional
12.1229 -fields overwrite C/C++ fields or methods when the names are the same.
12.1230 -
12.1231 -
12.1232 -<H3>
12.1233 -<A NAME="utilities"></A>Exported utility functions</H3>
12.1234 -<B>tolua </B>uses itself to export some utility functions to Lua, including
12.1235 -its object-oriented framework. The package file used by <B>tolua </B>is
12.1236 -
12.1237 -shown below:
12.1238 -<P><TT>module tolua</TT>
12.1239 -<BR><TT>{</TT>
12.1240 -<BR><TT> char* tolua_bnd_type @ type (lua_Object lo);</TT>
12.1241 -
12.1242 -<BR><TT> void tolua_bnd_takeownership @ takeownership (lua_Object lo);</TT>
12.1243 -<BR><TT> void tolua_bnd_releaseownership @ releaseownership (lua_Object lo);</TT>
12.1244 -
12.1245 -<BR><TT> lua_Object tolua_bnd_cast @ cast (lua_Object lo, char* type);</TT>
12.1246 -
12.1247 -<BR><TT> void tolua_bnd_inherit @ inherit (lua_Object table, lua_Object instance);</TT>
12.1248 -<BR><TT>}</TT>
12.1249 -
12.1250 -<H4>
12.1251 -tolua.type (<I>var</I>)</H4>
12.1252 -Returns a string representing the object type. For instance, <TT>tolua.type(tolua)</TT>
12.1253 -returns the string <TT>table</TT> and <TT>tolua.type(tolua.type)</TT>
12.1254 -returns <TT>cfunction</TT>. Similarly, if <TT>var </TT>is a variable holding
12.1255 -a user defined type <TT>T</TT>, <TT>tolua.type(var)</TT> would return
12.1256 -<TT>const
12.1257 -T</TT> or <TT>T</TT>, depending whether it is a constant reference.
12.1258 -<p>
12.1259 -
12.1260 -<h4>tolua.takeownership (<I>var</i>)</h4>
12.1261 -
12.1262 -Takes ownership of the object referenced <i>var</i>. This means that when all references
12.1263 -to that object are lost, the objects itself will be deleted by lua.
12.1264 -<p>
12.1265 -
12.1266 -<h4>tolua.releaseownership (<i>var</i>)</h4>
12.1267 -
12.1268 -Releases ownership of the object referenced by <i>var</i>.
12.1269 -<p>
12.1270 -
12.1271 -<h4>tolua.cast (<i>var</i>, <i>type</i>)</h4>
12.1272 -
12.1273 -Changes the metatable of <i>var</i> in order to make it of type <i>type</i>. <i>type</i> needs
12.1274 -to be a string with the complete C type of the object (including namespaces, etc).
12.1275 -
12.1276 -<h4>tolua.inherit (<i>table</i>, <i>var</i>)</h4> (new on <b>tolua++</b>)
12.1277 -
12.1278 -Causes <b>tolua++</b> to recognise <i>table</i> as an object with the same type as <i>var</i>,
12.1279 -and to use <i>var</i> when necesary. For example, consider this method:
12.1280 -<p>
12.1281 -
12.1282 -<ul><tt>void set_parent(Widget* p_parent);</tt></ul>
12.1283 -<p>
12.1284 -
12.1285 -A lua object could be used like this:
12.1286 -<p>
12.1287 -
12.1288 -<pre>
12.1289 -local w = Widget()
12.1290 -local lua_widget = {}
12.1291 -tolua.inherit(lua_widget, w)
12.1292 -
12.1293 -set_parent(lua_widget);
12.1294 -
12.1295 -</pre>
12.1296 -
12.1297 -Remember that this will only cause the table to be recognised as type 'Widget' when
12.1298 -necesary. To be able to access Widget's methods, you'll have to implement your own
12.1299 -object system. A simple example:
12.1300 -<p>
12.1301 -
12.1302 -<pre>
12.1303 -
12.1304 -lua_widget.show = Widget.show
12.1305 -
12.1306 -lua_widget:show() -- this will call the 'show' method from 'Widget', using the lua
12.1307 - -- table as 'self'. Since lua_widget inherits from a widget instance,
12.1308 - -- tolua++ will recognise 'self' as a 'Widget', and call the method
12.1309 -
12.1310 -</pre>
12.1311 -<p>
12.1312 -
12.1313 -Of course a better way would be to add a __index metamethod for the lua object.
12.1314 -<p>
12.1315 -
12.1316 -Similarily, to implement virtual functions, you'll need to create a c++ object that inherits
12.1317 -from the desired type, implement its virtual functions, and use that to inherit from lua. The
12.1318 -object would have a reference to the lua table, and call its methods from the c++ virtual
12.1319 -methods.
12.1320 -<p>
12.1321 -
12.1322 -<b>Note:</b> the current implementation (as of version 1.0.6) stores the C instance
12.1323 -inside the lua table on the field ".c_instance", and looks that up when necesary. This
12.1324 -might change in the future, so it is recommended to use an alternative way to store the
12.1325 -C instance to use with your own object system.
12.1326 -
12.1327 -<!--
12.1328 -<H3>
12.1329 -<A NAME="utilities"></A>Exported utility functions</H3>
12.1330 -<B>tolua </B>uses itself to export some utility functions to Lua, including
12.1331 -its object-oriented framework. The package file used by <B>tolua </B>is
12.1332 -shown below:
12.1333 -<P><TT>module tolua</TT>
12.1334 -<BR><TT>{</TT>
12.1335 -<BR><TT> void tolua_using @ using (lua_Table module);</TT>
12.1336 -<BR><TT> char* tolua_type @ type (lua_Object lo);</TT>
12.1337 -<BR><TT> void tolua_foreach @ foreach (lua_Object lo, lua_Function
12.1338 -f);</TT>
12.1339 -<BR><TT> void tolua_class @ class (lua_Table derived, lua_Table base=TOLUA_NIL);</TT>
12.1340 -<BR><TT> void tolua_instance @ instance (lua_Table instance, lua_Table
12.1341 -classobj);</TT>
12.1342 -<BR><TT> lua_Object tolua_base @ base (lua_Object lo);</TT>
12.1343 -<BR><TT>}</TT>
12.1344 -<H4>
12.1345 -tolua.using (<I>table</I>)</H4>
12.1346 -This functions receives a table and maps all its fields to the global environment.
12.1347 -Thus we can map an entire module and access its features without the module
12.1348 -prefix. For instance, if in our Lua code we do:
12.1349 -<P><TT>tolua.using(tolua)</TT>
12.1350 -<P>all <B>tolua </B>utility functions are mapped to the global environment.
12.1351 -<H4>
12.1352 -tolua.type (<I>var</I>)</H4>
12.1353 -Returns a string representing the object type. For instance, <TT>tolua.type(tolua)</TT>
12.1354 -returns the string <TT>generic module</TT> and <TT>tolua.type(tolua.type)</TT>
12.1355 -returns <TT>cfunction</TT>. Similarly, if <TT>var </TT>is a variable holding
12.1356 -a user defined type <TT>T</TT>, <TT>tolua.type(var)</TT> would return
12.1357 -<TT>const
12.1358 -T</TT> or <TT>T</TT>, depending whether it is a constant reference.
12.1359 -<H4>
12.1360 -tolua.tag (<I>"type"</I>)</H4>
12.1361 -Returns type corresponding tag number.
12.1362 -<H4>
12.1363 -tolua.foreach (<I>object</I>)</H4>
12.1364 -Allows us to traverse the conjugate table of an user defined instance.
12.1365 -If applied to conventional table, it has a similar behavior as the Lua
12.1366 -built-in <TT>foreach </TT>function. The difference is that this function
12.1367 -filters all fields starting with a dot, not passing them to the provided
12.1368 -callback function. This filter is need because <B>tolua </B>adds "hidden"
12.1369 -fields to the tables it manipulates, and all its "hidden" fields start
12.1370 -with a dot.
12.1371 -<H4>
12.1372 -tolua.cast (<I>object, "typename"</I>)</H4>
12.1373 -Returns the object "casted" to the given type. The object must represent
12.1374 -an user type, otherwise the function returns <B><TT>nil</TT></B>.
12.1375 -<H4>
12.1376 -tolua.takeownership (<I>object</I>)</H4>
12.1377 -Asks <B>tolua</B> to take the ownership of the given object. This means
12.1378 -the C/C++ object will be freed/ destructed when garbage-collected by Lua.
12.1379 -The object must represent an user type, otherwise an execution error is
12.1380 -generated.
12.1381 -<H4>
12.1382 -tolua.class (<I>table</I>, <I>base=nil</I>)</H4>
12.1383 -Creates a class by setting the appropriate tag methods to the given table.
12.1384 -The created class can inherit from a base class, previously created.
12.1385 -<H4>
12.1386 -tolua.instance (<I>table</I>, <I>class</I>)</H4>
12.1387 -Sets the given table to be an instance of the given class. This and the
12.1388 -previous utility functions allow object-oriented programming in Lua. As
12.1389 -an example consider:
12.1390 -<P><TT>-- define a Point class</TT>
12.1391 -<BR><TT>classPoint = { x=0, y=0 }</TT>
12.1392 -<BR><TT>tolua.class(classPoint) -- set as a class</TT>
12.1393 -<P><TT>-- define print method</TT>
12.1394 -<BR><TT>function classPoint:print ()</TT>
12.1395 -<BR><TT> print(self.x,self.y)</TT>
12.1396 -<BR><TT>end</TT>
12.1397 -<P><TT>-- define add method</TT>
12.1398 -<BR><TT>function classPoint:add (p2)</TT>
12.1399 -<BR><TT> return Point{x=self.x+p2.x,y=self.y+p2.y}</TT>
12.1400 -<BR><TT>end</TT>
12.1401 -<P><TT>-- define a Point constructor</TT>
12.1402 -<BR><TT>function Point (p)</TT>
12.1403 -<BR><TT> tolua.instance(p,classPoint) -- set as an instance
12.1404 -of classPoint</TT>
12.1405 -<BR><TT>return p end</TT>
12.1406 -<P><TT>-- define a Color Point class</TT>
12.1407 -<BR><TT>classColorPoint = { color = 'black' }</TT>
12.1408 -<BR><TT>tolua.class(classColorPoint,classPoint) -- set as class inheriting
12.1409 -from classPoint</TT>
12.1410 -<P><TT>-- define class methods</TT>
12.1411 -<BR><TT>function classColorPoint:print ()</TT>
12.1412 -<BR><TT> print(self.x,self.y,self.color)</TT>
12.1413 -<BR><TT>end</TT>
12.1414 -<P><TT>-- define Color Point constructor</TT>
12.1415 -<BR><TT>function ColorPoint (p)</TT>
12.1416 -<BR><TT> tolua.instance(p,classColorPoint) -- set as an instance
12.1417 -of classColorPoint</TT>
12.1418 -<BR><TT> return p</TT>
12.1419 -<BR><TT>end</TT>
12.1420 -<P><TT>-- Some valid codes would then be</TT>
12.1421 -<BR><TT>p = Point{x=1}</TT>
12.1422 -<BR><TT>q = ColorPoint{x=2,y=3,color=2}</TT>
12.1423 -<BR><TT>r = p:add(q)</TT>
12.1424 -<BR><TT>r:print() --> would print "3 3"</TT>
12.1425 -<BR>
12.1426 --->
12.1427 -
12.1428 -<H3>
12.1429 -<A NAME="embedded"></A>Embedded Lua code</H3>
12.1430 -<B>tolua</B> allows us to embed Lua code in the C/C++ generated code. To
12.1431 -do that, it compiles the specified Lua code and creates a C constant string,
12.1432 -storing the corresponding bytecodes, in the generated code. When
12.1433 -the package is opened, such a string is executed. The format to embed Lua
12.1434 -code is:
12.1435 -<P><B><TT>$[</TT></B>
12.1436 -<P><I><TT>embedded Lua code</TT></I>
12.1437 -<BR><I><TT>...</TT></I>
12.1438 -<P><B><TT>$]</TT></B>
12.1439 -<P>As an example consider the following .pkg excerpt:
12.1440 -<P><TT>/* Bind a Point class */</TT>
12.1441 -<BR><TT>class Point</TT>
12.1442 -<BR><TT>{</TT>
12.1443 -<BR><TT> Point (int x, int y);</TT>
12.1444 -<BR><TT> ~Point ();</TT>
12.1445 -<BR><TT> void print ();</TT>
12.1446 -<BR><TT> ...</TT>
12.1447 -<BR><TT>} CPoint;</TT>
12.1448 -<P><TT>$[</TT>
12.1449 -<P><TT>-- Create a Point constructor</TT>
12.1450 -<BR><TT>function Point (self)</TT>
12.1451 -<BR><TT> local cobj = CPoint:new(self.x or 0, self.y or 0)</TT>
12.1452 -<BR><TT> tolua.takeownership(cobj)</TT>
12.1453 -<BR><TT> return cobj</TT>
12.1454 -<BR><TT>end</TT>
12.1455 -<P><TT>$]</TT>
12.1456 -<P>Binding such a code would allow us to write the following Lua code:
12.1457 -<P><TT>p = Point{ x=2, y=3 }</TT>
12.1458 -<BR><TT>p:print()</TT>
12.1459 -<BR><TT>...</TT>
12.1460 -<BR>
12.1461 -
12.1462 -<h3><a name="customizing"></a>Customizing tolua++</h3>
12.1463 -<p>
12.1464 -
12.1465 -<b>tolua++</b> calls empty functions at specific points of its execution. This functions
12.1466 -can be redefined on a separate lua file (and included using the -L command line option)
12.1467 -and be used to control the way <b>tolua++</b> behaves. This is the list of functions
12.1468 -(taken from basic.lua on the <b>tolua++</b> source):
12.1469 -<p>
12.1470 -
12.1471 -<PRE>
12.1472 -
12.1473 --- called right after processing the $[ichl]file directives,
12.1474 --- right before processing anything else
12.1475 --- takes the package object as the parameter
12.1476 -function preprocess_hook(p)
12.1477 - -- p.code has all the input code from the pkg
12.1478 -end
12.1479 -
12.1480 -
12.1481 --- called for every $ifile directive
12.1482 --- takes a table with a string called 'code' inside, the filename, and any extra arguments
12.1483 --- passed to $ifile. no return value
12.1484 -function include_file_hook(t, filename, ...)
12.1485 -
12.1486 -end
12.1487 -
12.1488 --- called after processing anything that's not code (like '$renaming', comments, etc)
12.1489 --- and right before parsing the actual code.
12.1490 --- takes the Package object with all the code on the 'code' key. no return value
12.1491 -function preparse_hook(package)
12.1492 -
12.1493 -end
12.1494 -
12.1495 -
12.1496 --- called after writing all the output.
12.1497 --- takes the Package object
12.1498 -function post_output_hook(package)
12.1499 -
12.1500 -end
12.1501 -</PRE>
12.1502 -<p>
12.1503 -
12.1504 -Another 'interesting' function is <tt>extract_code</tt>, defined on basic.lua, which
12.1505 -extracs the code from files included with $cfile and $hfile (by looking for tolua_begin/end and tolua_export).
12.1506 -<p>
12.1507 -
12.1508 -<h3><a name="compatibility"></a>Compatibility with older versions.</h3>
12.1509 -
12.1510 -<h4>toLua 4</h4>
12.1511 -<p>
12.1512 -
12.1513 -<b>Retrieving Objects</b>
12.1514 -<p>
12.1515 -
12.1516 -Users switching from <b>tolua</b> v4 should know that <b>tolua++</b> stores the objects as
12.1517 -<tt>void**</tt> on Lua, so when retrieving an object from the luastate using <tt>lua_touserdata</tt>,
12.1518 -the pointer should be dereferenced. The library function <tt>tolua_tousertype</tt>
12.1519 -should work as expected. Example:
12.1520 -<p>
12.1521 -
12.1522 -<pre>
12.1523 -lua_pushglobal(lua_state, "get_Object");
12.1524 -lua_call(lua_state, 0, 1); // calling a function that returns an Object
12.1525 -
12.1526 -Object *new_object = (Object*)(*lua_touserdata(lua_state, -1));
12.1527 -<i>or</i>
12.1528 -Object *new_object = (Object*)tolua_tousertype(lua_state, -1, NULL);
12.1529 -</pre>
12.1530 -
12.1531 -<b>C++ Strings</b>
12.1532 -<p>
12.1533 -
12.1534 -<b>tolua++</b> binds the c++ type <tt>std::string</tt> as a basic type, passing it
12.1535 -to Lua as a regular string (using the method <tt>c_str()</tt>). This feature can be
12.1536 -turned off with the command line option <tt>-S</tt>.
12.1537 -<p>
12.1538 -
12.1539 -<b>Operators</b>
12.1540 -<p>
12.1541 -
12.1542 -The list of supported operators has changed, see <a href="#classes">Binding classes and methods</a>
12.1543 -for more information.
12.1544 -<p>
12.1545 -
12.1546 -<h4>toLua 5</h4>
12.1547 -<p>
12.1548 -
12.1549 -<b>Class destructors.</b>
12.1550 -<p>
12.1551 -
12.1552 -With every class constructor, <b>tolua++</b> exports a 'local' constructor, to create an instance
12.1553 -of the class that is owned by the lua state. To implement this, <b>tolua++</b> will also export
12.1554 -a function that will <tt>delete</tt> the class. There are 2 options to prevent this:
12.1555 -<p>
12.1556 -
12.1557 -Using the <b>-D</b> command line option will turn this off completely. Destructor functions will
12.1558 -only be exported when a destructor for the class is explicitly declared, or when there is a function
12.1559 -or method that returns an object of the type by value (this is compatible with <b>tolua</b>'s behaviour).
12.1560 -<p>
12.1561 -
12.1562 -Using the <tt>TOLUA_PROTECTED_DESTRUCTOR</tt> directive inside the class declaration, to specify that the
12.1563 -class has a private or protected destructor. In this case, no destructor will be exported for that class.
12.1564 -<p>
12.1565 -
12.1566 -<b><tt>operator[]</tt> index</b>
12.1567 -<p>
12.1568 -
12.1569 -Users switching from <b>tolua</b> v5 should know that <b>tolua</b> 5 substracts 1
12.1570 -from the index on operator[] functions, for compatibility with lua's method for indexing arrays
12.1571 -(1 is the first element). This feature is turned off by default on <b>tolua++</b>
12.1572 -(making it compatible with <b>tolua</b> 4). It can be turned back on with the
12.1573 -command line option <tt>-1</tt>
12.1574 -<p>
12.1575 -
12.1576 -<b>C++ Strings</b>
12.1577 -<p>
12.1578 -
12.1579 -(see c++ strings on <b>tolua</b> 4 below)
12.1580 -
12.1581 -
12.1582 -<H3>
12.1583 -<A NAME="changes-v30"></A>Changes since v. 3.0</H3>
12.1584 -
12.1585 -<ul>
12.1586 -
12.1587 -<LI>
12.1588 -Support for binding arrays as variables and struct/class fields;</LI>
12.1589 -
12.1590 -<LI>
12.1591 -Support for embedding Lua code into the generated binding code;</LI>
12.1592 -
12.1593 -<LI>
12.1594 -New utility functions: <I>cast</I> and <I>takeownership</I>;</LI>
12.1595 -
12.1596 -<LI>
12.1597 -Option to create the corresponding header file of the binding code;</LI>
12.1598 -
12.1599 -<LI>
12.1600 -New "close" package function;</LI>
12.1601 -
12.1602 -<LI>
12.1603 -Fixed bug on cloning objects in C++;</LI>
12.1604 -
12.1605 -<LI>
12.1606 -Fixed bug on enum and struct parsing;</LI>
12.1607 -</ul>
12.1608 -<H3>
12.1609 -<A NAME="changes-v2"></A>Changes since v. 2.0</H3>
12.1610 -<ul>
12.1611 -
12.1612 -<LI>
12.1613 -There is a new executable parser;</LI>
12.1614 -
12.1615 -<LI>
12.1616 -Support for multiple Lua states is provided;</LI>
12.1617 -
12.1618 -<LI>
12.1619 -Support for module definition is provided;</LI>
12.1620 -
12.1621 -<LI>
12.1622 -Global variables is now directly bound to Lua global variables;</LI>
12.1623 -
12.1624 -<LI>
12.1625 -Constness of user defined types is preserved in Lua;</LI>
12.1626 -
12.1627 -<LI>
12.1628 -Support for multiple returned values from C/C++ is provided (simulating
12.1629 -parameters passed by reference);</LI>
12.1630 -
12.1631 -<LI>
12.1632 -Constants, variables, and functions bound to Lua can have different names
12.1633 -from their C/C++ counterparts;</LI>
12.1634 -
12.1635 -<LI>
12.1636 -Object-oriented framework (and other utility functions) used in <B>tolua
12.1637 -</B>is
12.1638 -now exported for Lua programmers;</LI>
12.1639 -
12.1640 -<H4>
12.1641 -Incompatibilities</H4>
12.1642 -Lua code based on <B>tolua</B> v2.* should run with no change on <B>tolua
12.1643 -</B>v3.0.
12.1644 -Although, it may be necessary to change the .pkg file in order to get the
12.1645 -same behavior. The following incompatibilities exist:
12.1646 -<UL>
12.1647 -<LI>
12.1648 -Parameters defined as pointer to basic types are no longer converted to
12.1649 -arrays of dimension one; they are now considered parameters passed by reference.</LI>
12.1650 -
12.1651 -<LI>
12.1652 -Automatic initialization for C++ code must be explicitly requested when
12.1653 -using the new parser;</LI>
12.1654 -
12.1655 -<LI>
12.1656 -Global variables are no longer mapped to a table; the definition of a module
12.1657 -including the global variables may be used to simulate the old behavior;</LI>
12.1658 -
12.1659 -<LI>
12.1660 -The initialization function is no longer toLua_<I>package</I>_open but
12.1661 -tolua_<I>package</I>_open, without the capital letter (sorry!).</LI>
12.1662 -</UL>
12.1663 -</ul>
12.1664 -<H3>
12.1665 -<A NAME="changes-v1"></A>Changes since v. 1.*</H3>
12.1666 -
12.1667 -<ul>
12.1668 -<LI>
12.1669 -The binding code should run much faster;</LI>
12.1670 -
12.1671 -<LI>
12.1672 -The <I>cleaned header file </I>extension should now be <TT>.pkg</TT> instead
12.1673 -of <TT>.L</TT>;</LI>
12.1674 -
12.1675 -<LI>
12.1676 -Type modifiers is now accepted (though the current version ignores
12.1677 -<TT>const</TT>'s);</LI>
12.1678 -
12.1679 -<LI>
12.1680 -Returning object by value is accepted and memory allocation is controlled
12.1681 -by Lua garbage collection;</LI>
12.1682 -
12.1683 -<LI>
12.1684 -Overloaded functions/methods are accepted;</LI>
12.1685 -
12.1686 -<LI>
12.1687 -Parameters with default values are accepted;</LI>
12.1688 -
12.1689 -<LI>
12.1690 -Some overloaded operators are automatically bound.</LI>
12.1691 -</ul>
12.1692 -
12.1693 -<H3>
12.1694 -<A NAME="credits"></A>Credits</H3>
12.1695 -Luiz Henrique de Figueiredo had the idea of creating a tool to automatically
12.1696 -bind C code to Lua. L.H.F. wrote the very first version of such a tool
12.1697 -(that bound C functions, variables, and constants) in <I>awk</I>. At that
12.1698 -time, Waldemar Celes (now the main author) was only responsible for the C code that supported the generated
12.1699 -binding code.
12.1700 -<p>
12.1701 -While working at NGD Studios, Ariel Manzur made some changes to tolua4 for their
12.1702 -game engine. After the release of tolua5, having left NGD, enough changes were
12.1703 -made to tolua to justify a separate release (with Waldemar's blessing :-)
12.1704 -<BR>
12.1705 -<H3>
12.1706 -<A NAME="availability"></A><B>Availability</B></H3>
12.1707 -<B>tolua++ </B>is freely available by <A HREF="http://www.codenix.com/~tolua/tolua++-current.tar.bz2">http</A>.
12.1708 -The software provided hereunder is on an "as is" basis, and the author
12.1709 -has no obligation to provide maintenance, support, updates, enhancements,
12.1710 -or modifications.
12.1711 -<P>
12.1712 -<HR WIDTH="100%">This document was created by <A HREF="http://www.tecgraf.puc-rio.br/~celes/">Waldemar Celes</A>
12.1713 -With modifications by <a href="http://www.codenix.com/index.php?section=contact">Ariel Manzur</a>/
12.1714 -<BR>Last update: Sept 2003<BODT>
12.1715 -</BODY>
12.1716 -</HTML>
13.1 Binary file source/tolua++/doc/toluapp.gif has changed
14.1 Binary file source/tolua++/doc/toluapp.png has changed
15.1 --- a/source/tolua++/include/tolua++.h Wed Nov 04 01:07:17 2009 +0000
15.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
15.3 @@ -1,142 +0,0 @@
15.4 -/* tolua
15.5 -** Support code for Lua bindings.
15.6 -** Written by Waldemar Celes
15.7 -** TeCGraf/PUC-Rio
15.8 -** Apr 2003
15.9 -** $Id$
15.10 -*/
15.11 -
15.12 -/* This code is free software; you can redistribute it and/or modify it.
15.13 -** The software provided hereunder is on an "as is" basis, and
15.14 -** the author has no obligation to provide maintenance, support, updates,
15.15 -** enhancements, or modifications.
15.16 -*/
15.17 -
15.18 -
15.19 -#ifndef TOLUA_H
15.20 -#define TOLUA_H
15.21 -
15.22 -#ifndef TOLUA_API
15.23 -#define TOLUA_API extern
15.24 -#endif
15.25 -
15.26 -#define TOLUA_VERSION "tolua++-1.0.6"
15.27 -
15.28 -#ifdef __cplusplus
15.29 -extern "C" {
15.30 -#endif
15.31 -
15.32 -#define tolua_pushcppstring(x,y) tolua_pushstring(x,y.c_str())
15.33 -#define tolua_iscppstring tolua_isstring
15.34 -
15.35 -// The following causes error: --NDT
15.36 -// src\tolua++\include\tolua++.h(32) : error C2010: '.' : unexpected in macro formal parameter list
15.37 -//#define TEMPLATE_BIND(p...)
15.38 -
15.39 -#define TOLUA_PROTECTED_DESTRUCTOR
15.40 -#define TOLUA_PROPERTY_TYPE(p)
15.41 -
15.42 -typedef int lua_Object;
15.43 -
15.44 -#include "lua.h"
15.45 -#include "lauxlib.h"
15.46 -
15.47 -struct tolua_Error
15.48 -{
15.49 - int index;
15.50 - int array;
15.51 - const char* type;
15.52 -};
15.53 -typedef struct tolua_Error tolua_Error;
15.54 -
15.55 -TOLUA_API const char* tolua_typename (lua_State* L, int lo);
15.56 -TOLUA_API void tolua_error (lua_State* L, char* msg, tolua_Error* err);
15.57 -TOLUA_API int tolua_isnoobj (lua_State* L, int lo, tolua_Error* err);
15.58 -TOLUA_API int tolua_isvalue (lua_State* L, int lo, int def, tolua_Error* err);
15.59 -TOLUA_API int tolua_isboolean (lua_State* L, int lo, int def, tolua_Error* err);
15.60 -TOLUA_API int tolua_isnumber (lua_State* L, int lo, int def, tolua_Error* err);
15.61 -TOLUA_API int tolua_isstring (lua_State* L, int lo, int def, tolua_Error* err);
15.62 -TOLUA_API int tolua_istable (lua_State* L, int lo, int def, tolua_Error* err);
15.63 -TOLUA_API int tolua_isusertable (lua_State* L, int lo, const char* type, int def, tolua_Error* err);
15.64 -TOLUA_API int tolua_isuserdata (lua_State* L, int lo, int def, tolua_Error* err);
15.65 -TOLUA_API int tolua_isusertype (lua_State* L, int lo, const char* type, int def, tolua_Error* err);
15.66 -TOLUA_API int tolua_isvaluearray
15.67 - (lua_State* L, int lo, int dim, int def, tolua_Error* err);
15.68 -TOLUA_API int tolua_isbooleanarray
15.69 - (lua_State* L, int lo, int dim, int def, tolua_Error* err);
15.70 -TOLUA_API int tolua_isnumberarray
15.71 - (lua_State* L, int lo, int dim, int def, tolua_Error* err);
15.72 -TOLUA_API int tolua_isstringarray
15.73 - (lua_State* L, int lo, int dim, int def, tolua_Error* err);
15.74 -TOLUA_API int tolua_istablearray
15.75 - (lua_State* L, int lo, int dim, int def, tolua_Error* err);
15.76 -TOLUA_API int tolua_isuserdataarray
15.77 - (lua_State* L, int lo, int dim, int def, tolua_Error* err);
15.78 -TOLUA_API int tolua_isusertypearray
15.79 - (lua_State* L, int lo, const char* type, int dim, int def, tolua_Error* err);
15.80 -
15.81 -TOLUA_API void tolua_open (lua_State* L);
15.82 -
15.83 -TOLUA_API void* tolua_copy (lua_State* L, void* value, unsigned int size);
15.84 -TOLUA_API int tolua_register_gc (lua_State* L, int lo);
15.85 -TOLUA_API int tolua_default_collect (lua_State* tolua_S);
15.86 -
15.87 -TOLUA_API void tolua_usertype (lua_State* L, char* type);
15.88 -TOLUA_API void tolua_beginmodule (lua_State* L, char* name);
15.89 -TOLUA_API void tolua_endmodule (lua_State* L);
15.90 -TOLUA_API void tolua_module (lua_State* L, char* name, int hasvar);
15.91 -TOLUA_API void tolua_class (lua_State* L, char* name, char* base);
15.92 -TOLUA_API void tolua_cclass (lua_State* L, char* lname, char* name, char* base, lua_CFunction col);
15.93 -TOLUA_API void tolua_function (lua_State* L, char* name, lua_CFunction func);
15.94 -TOLUA_API void tolua_constant (lua_State* L, char* name, double value);
15.95 -TOLUA_API void tolua_variable (lua_State* L, char* name, lua_CFunction get, lua_CFunction set);
15.96 -TOLUA_API void tolua_array (lua_State* L,char* name, lua_CFunction get, lua_CFunction set);
15.97 -
15.98 -/* TOLUA_API void tolua_set_call_event(lua_State* L, lua_CFunction func, char* type); */
15.99 -/* TOLUA_API void tolua_addbase(lua_State* L, char* name, char* base); */
15.100 -
15.101 -TOLUA_API void tolua_pushvalue (lua_State* L, int lo);
15.102 -TOLUA_API void tolua_pushboolean (lua_State* L, int value);
15.103 -TOLUA_API void tolua_pushnumber (lua_State* L, double value);
15.104 -TOLUA_API void tolua_pushstring (lua_State* L, const char* value);
15.105 -TOLUA_API void tolua_pushuserdata (lua_State* L, void* value);
15.106 -TOLUA_API void tolua_pushusertype (lua_State* L, void* value, const char* type);
15.107 -TOLUA_API void tolua_pushusertype_and_takeownership(lua_State* L, void* value, const char* type);
15.108 -TOLUA_API void tolua_pushfieldvalue (lua_State* L, int lo, int index, int v);
15.109 -TOLUA_API void tolua_pushfieldboolean (lua_State* L, int lo, int index, int v);
15.110 -TOLUA_API void tolua_pushfieldnumber (lua_State* L, int lo, int index, double v);
15.111 -TOLUA_API void tolua_pushfieldstring (lua_State* L, int lo, int index, const char* v);
15.112 -TOLUA_API void tolua_pushfielduserdata (lua_State* L, int lo, int index, void* v);
15.113 -TOLUA_API void tolua_pushfieldusertype (lua_State* L, int lo, int index, void* v, const char* type);
15.114 -TOLUA_API void tolua_pushfieldusertype_and_takeownership (lua_State* L, int lo, int index, void* v, const char* type);
15.115 -
15.116 -TOLUA_API double tolua_tonumber (lua_State* L, int narg, double def);
15.117 -TOLUA_API const char* tolua_tostring (lua_State* L, int narg, const char* def);
15.118 -TOLUA_API void* tolua_touserdata (lua_State* L, int narg, void* def);
15.119 -TOLUA_API void* tolua_tousertype (lua_State* L, int narg, void* def);
15.120 -TOLUA_API int tolua_tovalue (lua_State* L, int narg, int def);
15.121 -TOLUA_API int tolua_toboolean (lua_State* L, int narg, int def);
15.122 -TOLUA_API double tolua_tofieldnumber (lua_State* L, int lo, int index, double def);
15.123 -TOLUA_API const char* tolua_tofieldstring (lua_State* L, int lo, int index, const char* def);
15.124 -TOLUA_API void* tolua_tofielduserdata (lua_State* L, int lo, int index, void* def);
15.125 -TOLUA_API void* tolua_tofieldusertype (lua_State* L, int lo, int index, void* def);
15.126 -TOLUA_API int tolua_tofieldvalue (lua_State* L, int lo, int index, int def);
15.127 -TOLUA_API int tolua_getfieldboolean (lua_State* L, int lo, int index, int def);
15.128 -
15.129 -#ifdef __cplusplus
15.130 -static inline const char* tolua_tocppstring (lua_State* L, int narg, const char* def) {
15.131 -
15.132 - const char* s = tolua_tostring(L, narg, def);
15.133 - return s?s:"";
15.134 -};
15.135 -#else
15.136 -#define tolua_tocppstring tolua_tostring
15.137 -#endif
15.138 -
15.139 -TOLUA_API int tolua_fast_isa(lua_State *L, int mt_indexa, int mt_indexb);
15.140 -
15.141 -#ifdef __cplusplus
15.142 -}
15.143 -#endif
15.144 -
15.145 -#endif
16.1 --- a/source/tolua++/src/bin/Makefile Wed Nov 04 01:07:17 2009 +0000
16.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
16.3 @@ -1,25 +0,0 @@
16.4 -# makefile for tolua executable
16.5 -# $Id$
16.6 -
16.7 -TOLUA=../..
16.8 -# Use the Lua config rather than this one to unify everything
16.9 -#include $(TOLUA)/config
16.10 -LUA= ../../../lua
16.11 -include $(LUA)/config
16.12 -
16.13 -OBJS= \
16.14 - tolua.o \
16.15 - toluabind.o
16.16 -
16.17 -T= $(LUA)/bin/tolua
16.18 -
16.19 -all: $T
16.20 -
16.21 -$T: $(OBJS)
16.22 - $(CC) -o $@ $(OBJS) -L$(LIB) -ltolua -llua -llualib -lm
16.23 -
16.24 -clean:
16.25 - rm -f $(OBJS) $T
16.26 -
16.27 -klean:
16.28 - rm -f *.c *.h *.lua
16.29 \ No newline at end of file
17.1 --- a/source/tolua++/src/bin/SCsub Wed Nov 04 01:07:17 2009 +0000
17.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
17.3 @@ -1,17 +0,0 @@
17.4 -Import('env')
17.5 -
17.6 -src = [
17.7 - 'tolua.c',
17.8 - ]
17.9 -
17.10 -
17.11 -if env['build_dev']:
17.12 - env.LuaBinding('toluabind.c', 'tolua_scons.pkg', 'tolua')
17.13 -
17.14 -if env['build_failsafe']:
17.15 - src+= ['toluabind_default.c']
17.16 -else:
17.17 - src += ['toluabind.c']
17.18 -
17.19 -env.bin_target = env.Program('#/bin/tolua++', src, LIBS = ['tolua++'] + env['LIBS'])
17.20 -
18.1 --- a/source/tolua++/src/bin/a.lua Wed Nov 04 01:07:17 2009 +0000
18.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
18.3 @@ -1,128 +0,0 @@
18.4 -
18.5 -rawtype = type
18.6 -function do_ (f, err)
18.7 -if not f then print(err); return end
18.8 -local a,b = pcall(f)
18.9 -if not a then print(b); return nil
18.10 -else return b or true
18.11 -end
18.12 -end
18.13 -function dostring(s) return do_(loadstring(s)) end
18.14 -local tab = table
18.15 -foreach = tab.foreach
18.16 -foreachi = tab.foreachi
18.17 -getn = tab.getn
18.18 -tinsert = tab.insert
18.19 -tremove = tab.remove
18.20 -sort = tab.sort
18.21 -local dbg = debug
18.22 -getinfo = dbg.getinfo
18.23 -getlocal = dbg.getlocal
18.24 -setcallhook = function () error"`setcallhook' is deprecated" end
18.25 -setlinehook = function () error"`setlinehook' is deprecated" end
18.26 -setlocal = dbg.setlocal
18.27 -local math = math
18.28 -abs = math.abs
18.29 -acos = function (x) return math.deg(math.acos(x)) end
18.30 -asin = function (x) return math.deg(math.asin(x)) end
18.31 -atan = function (x) return math.deg(math.atan(x)) end
18.32 -atan2 = function (x,y) return math.deg(math.atan2(x,y)) end
18.33 -ceil = math.ceil
18.34 -cos = function (x) return math.cos(math.rad(x)) end
18.35 -deg = math.deg
18.36 -exp = math.exp
18.37 -floor = math.floor
18.38 -frexp = math.frexp
18.39 -ldexp = math.ldexp
18.40 -log = math.log
18.41 -log10 = math.log10
18.42 -max = math.max
18.43 -min = math.min
18.44 -mod = math.mod
18.45 -PI = math.pi
18.46 -rad = math.rad
18.47 -random = math.random
18.48 -randomseed = math.randomseed
18.49 -sin = function (x) return math.sin(math.rad(x)) end
18.50 -sqrt = math.sqrt
18.51 -tan = function (x) return math.tan(math.rad(x)) end
18.52 -local str = string
18.53 -strbyte = str.byte
18.54 -strchar = str.char
18.55 -strfind = str.find
18.56 -format = str.format
18.57 -gsub = str.gsub
18.58 -strlen = str.len
18.59 -strlower = str.lower
18.60 -strrep = str.rep
18.61 -strsub = str.sub
18.62 -strupper = str.upper
18.63 -clock = os.clock
18.64 -date = os.date
18.65 -difftime = os.difftime
18.66 -execute = os.execute
18.67 -exit = os.exit
18.68 -getenv = os.getenv
18.69 -remove = os.remove
18.70 -rename = os.rename
18.71 -setlocale = os.setlocale
18.72 -time = os.time
18.73 -tmpname = os.tmpname
18.74 -getglobal = function (n) return _G[n] end
18.75 -setglobal = function (n,v) _G[n] = v end
18.76 -local io, tab = io, table
18.77 -_STDIN = io.stdin
18.78 -_STDERR = io.stderr
18.79 -_STDOUT = io.stdout
18.80 -_INPUT = io.stdin
18.81 -_OUTPUT = io.stdout
18.82 -seek = io.stdin.seek
18.83 -tmpfile = io.tmpfile
18.84 -closefile = io.close
18.85 -openfile = io.open
18.86 -function flush (f)
18.87 -if f then f:flush()
18.88 -else _OUTPUT:flush()
18.89 -end
18.90 -end
18.91 -function readfrom (name)
18.92 -if name == nil then
18.93 -local f, err, cod = io.close(_INPUT)
18.94 -_INPUT = io.stdin
18.95 -return f, err, cod
18.96 -else
18.97 -local f, err, cod = io.open(name, "r")
18.98 -_INPUT = f or _INPUT
18.99 -return f, err, cod
18.100 -end
18.101 -end
18.102 -function writeto (name)
18.103 -if name == nil then
18.104 -local f, err, cod = io.close(_OUTPUT)
18.105 -_OUTPUT = io.stdout
18.106 -return f, err, cod
18.107 -else
18.108 -local f, err, cod = io.open(name, "w")
18.109 -_OUTPUT = f or _OUTPUT
18.110 -return f, err, cod
18.111 -end
18.112 -end
18.113 -function appendto (name)
18.114 -local f, err, cod = io.open(name, "a")
18.115 -_OUTPUT = f or _OUTPUT
18.116 -return f, err, cod
18.117 -end
18.118 -function read (...)
18.119 -local f = _INPUT
18.120 -if rawtype(arg[1]) == 'userdata' then
18.121 -f = tab.remove(arg, 1)
18.122 -end
18.123 -return f:read(unpack(arg))
18.124 -end
18.125 -function write (...)
18.126 -local f = _OUTPUT
18.127 -if rawtype(arg[1]) == 'userdata' then
18.128 -f = tab.remove(arg, 1)
18.129 -end
18.130 -return f:write(unpack(arg))
18.131 -end
18.132 \ No newline at end of file
19.1 --- a/source/tolua++/src/bin/lua/all.lua Wed Nov 04 01:07:17 2009 +0000
19.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
19.3 @@ -1,28 +0,0 @@
19.4 -dofile(path.."compat.lua")
19.5 -dofile(path.."basic.lua")
19.6 -dofile(path.."feature.lua")
19.7 -dofile(path.."verbatim.lua")
19.8 -dofile(path.."code.lua")
19.9 -dofile(path.."typedef.lua")
19.10 -dofile(path.."container.lua")
19.11 -dofile(path.."package.lua")
19.12 -dofile(path.."module.lua")
19.13 -dofile(path.."namespace.lua")
19.14 -dofile(path.."define.lua")
19.15 -dofile(path.."enumerate.lua")
19.16 -dofile(path.."declaration.lua")
19.17 -dofile(path.."variable.lua")
19.18 -dofile(path.."array.lua")
19.19 -dofile(path.."function.lua")
19.20 -dofile(path.."operator.lua")
19.21 -dofile(path.."class.lua")
19.22 -dofile(path.."clean.lua")
19.23 ---dofile(path.."custom.lua")
19.24 -dofile(path.."doit.lua")
19.25 -
19.26 -local err,msg = xpcall(doit, debug.traceback)
19.27 -if not err then
19.28 ---print("**** msg is "..tostring(msg))
19.29 - local _,_,label,msg = strfind(msg,"(.-:.-:%s*)(.*)")
19.30 - tolua_error(msg,label)
19.31 -end
20.1 --- a/source/tolua++/src/bin/lua/array.lua Wed Nov 04 01:07:17 2009 +0000
20.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
20.3 @@ -1,214 +0,0 @@
20.4 --- tolua: array class
20.5 --- Written by Waldemar Celes
20.6 --- TeCGraf/PUC-Rio
20.7 --- Jul 1999
20.8 --- $Id$
20.9 -
20.10 --- This code is free software; you can redistribute it and/or modify it.
20.11 --- The software provided hereunder is on an "as is" basis, and
20.12 --- the author has no obligation to provide maintenance, support, updates,
20.13 --- enhancements, or modifications.
20.14 -
20.15 -
20.16 --- Array class
20.17 --- Represents a extern array variable or a public member of a class.
20.18 --- Stores all fields present in a declaration.
20.19 -classArray = {
20.20 -}
20.21 -classArray.__index = classArray
20.22 -setmetatable(classArray,classDeclaration)
20.23 -
20.24 --- Print method
20.25 -function classArray:print (ident,close)
20.26 - print(ident.."Array{")
20.27 - print(ident.." mod = '"..self.mod.."',")
20.28 - print(ident.." type = '"..self.type.."',")
20.29 - print(ident.." ptr = '"..self.ptr.."',")
20.30 - print(ident.." name = '"..self.name.."',")
20.31 - print(ident.." def = '"..self.def.."',")
20.32 - print(ident.." dim = '"..self.dim.."',")
20.33 - print(ident.." ret = '"..self.ret.."',")
20.34 - print(ident.."}"..close)
20.35 -end
20.36 -
20.37 --- check if it is a variable
20.38 -function classArray:isvariable ()
20.39 - return true
20.40 -end
20.41 -
20.42 -
20.43 --- get variable value
20.44 -function classArray:getvalue (class,static)
20.45 - if class and static then
20.46 - return class..'::'..self.name..'[tolua_index]'
20.47 - elseif class then
20.48 - return 'self->'..self.name..'[tolua_index]'
20.49 - else
20.50 - return self.name..'[tolua_index]'
20.51 - end
20.52 -end
20.53 -
20.54 --- Write binding functions
20.55 -function classArray:supcode ()
20.56 - local class = self:inclass()
20.57 -
20.58 - -- get function ------------------------------------------------
20.59 - if class then
20.60 - output("/* get function:",self.name," of class ",class," */")
20.61 - else
20.62 - output("/* get function:",self.name," */")
20.63 - end
20.64 - self.cgetname = self:cfuncname("tolua_get")
20.65 - output("static int",self.cgetname,"(lua_State* tolua_S)")
20.66 - output("{")
20.67 - output(" int tolua_index;")
20.68 -
20.69 - -- declare self, if the case
20.70 - local _,_,static = strfind(self.mod,'^%s*(static)')
20.71 - if class and static==nil then
20.72 - output(' ',self.parent.type,'*','self;')
20.73 - output(' lua_pushstring(tolua_S,".self");')
20.74 - output(' lua_rawget(tolua_S,1);')
20.75 - output(' self = ')
20.76 - output('(',self.parent.type,'*) ')
20.77 - output('lua_touserdata(tolua_S,-1);')
20.78 - elseif static then
20.79 - _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)')
20.80 - end
20.81 -
20.82 - -- check index
20.83 - output('#ifndef TOLUA_RELEASE\n')
20.84 - output(' {')
20.85 - output(' tolua_Error tolua_err;')
20.86 - output(' if (!tolua_isnumber(tolua_S,2,0,&tolua_err))')
20.87 - output(' tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);')
20.88 - output(' }')
20.89 - output('#endif\n')
20.90 - if flags['1'] then -- for compatibility with tolua5 ?
20.91 - output(' tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;')
20.92 - else
20.93 - output(' tolua_index = (int)tolua_tonumber(tolua_S,2,0);')
20.94 - end
20.95 - output('#ifndef TOLUA_RELEASE\n')
20.96 - output(' if (tolua_index<0 || tolua_index>='..self.dim..')')
20.97 - output(' tolua_error(tolua_S,"array indexing out of range.",NULL);')
20.98 - output('#endif\n')
20.99 -
20.100 - -- return value
20.101 - local t,ct = isbasic(self.type)
20.102 - if t then
20.103 - output(' tolua_push'..t..'(tolua_S,(',ct,')'..self:getvalue(class,static)..');')
20.104 - else
20.105 - t = self.type
20.106 - if self.ptr == '&' or self.ptr == '' then
20.107 - output(' tolua_pushusertype(tolua_S,(void*)&'..self:getvalue(class,static)..',"',t,'");')
20.108 - else
20.109 - output(' tolua_pushusertype(tolua_S,(void*)'..self:getvalue(class,static)..',"',t,'");')
20.110 - end
20.111 - end
20.112 - output(' return 1;')
20.113 - output('}')
20.114 - output('\n')
20.115 -
20.116 - -- set function ------------------------------------------------
20.117 - if not strfind(self.type,'const') then
20.118 - if class then
20.119 - output("/* set function:",self.name," of class ",class," */")
20.120 - else
20.121 - output("/* set function:",self.name," */")
20.122 - end
20.123 - self.csetname = self:cfuncname("tolua_set")
20.124 - output("static int",self.csetname,"(lua_State* tolua_S)")
20.125 - output("{")
20.126 -
20.127 - -- declare index
20.128 - output(' int tolua_index;')
20.129 -
20.130 - -- declare self, if the case
20.131 - local _,_,static = strfind(self.mod,'^%s*(static)')
20.132 - if class and static==nil then
20.133 - output(' ',self.parent.type,'*','self;')
20.134 - output(' lua_pushstring(tolua_S,".self");')
20.135 - output(' lua_rawget(tolua_S,1);')
20.136 - output(' self = ')
20.137 - output('(',self.parent.type,'*) ')
20.138 - output('lua_touserdata(tolua_S,-1);')
20.139 - elseif static then
20.140 - _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)')
20.141 - end
20.142 -
20.143 - -- check index
20.144 - output('#ifndef TOLUA_RELEASE\n')
20.145 - output(' {')
20.146 - output(' tolua_Error tolua_err;')
20.147 - output(' if (!tolua_isnumber(tolua_S,2,0,&tolua_err))')
20.148 - output(' tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);')
20.149 - output(' }')
20.150 - output('#endif\n')
20.151 -
20.152 - if flags['1'] then -- for compatibility with tolua5 ?
20.153 - output(' tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;')
20.154 - else
20.155 - output(' tolua_index = (int)tolua_tonumber(tolua_S,2,0);')
20.156 - end
20.157 -
20.158 - output('#ifndef TOLUA_RELEASE\n')
20.159 - output(' if (tolua_index<0 || tolua_index>='..self.dim..')')
20.160 - output(' tolua_error(tolua_S,"array indexing out of range.",NULL);')
20.161 - output('#endif\n')
20.162 -
20.163 - -- assign value
20.164 - local ptr = ''
20.165 - if self.ptr~='' then ptr = '*' end
20.166 - output(' ')
20.167 - if class and static then
20.168 - output(class..'::'..self.name..'[tolua_index]')
20.169 - elseif class then
20.170 - output('self->'..self.name..'[tolua_index]')
20.171 - else
20.172 - output(self.name..'[tolua_index]')
20.173 - end
20.174 - local t = isbasic(self.type)
20.175 - output(' = ')
20.176 - if not t and ptr=='' then output('*') end
20.177 - output('((',self.mod,self.type)
20.178 - if not t then
20.179 - output('*')
20.180 - end
20.181 - output(') ')
20.182 - local def = 0
20.183 - if self.def ~= '' then def = self.def end
20.184 - if t then
20.185 - output('tolua_to'..t,'(tolua_S,3,',def,'));')
20.186 - else
20.187 - output('tolua_tousertype(tolua_S,3,',def,'));')
20.188 - end
20.189 - output(' return 0;')
20.190 - output('}')
20.191 - output('\n')
20.192 - end
20.193 -
20.194 -end
20.195 -
20.196 -function classArray:register ()
20.197 - if self.csetname then
20.198 - output(' tolua_array(tolua_S,"'..self.lname..'",'..self.cgetname..','..self.csetname..');')
20.199 - else
20.200 - output(' tolua_array(tolua_S,"'..self.lname..'",'..self.cgetname..',NULL);')
20.201 - end
20.202 -end
20.203 -
20.204 --- Internal constructor
20.205 -function _Array (t)
20.206 - setmetatable(t,classArray)
20.207 - append(t)
20.208 - return t
20.209 -end
20.210 -
20.211 --- Constructor
20.212 --- Expects a string representing the variable declaration.
20.213 -function Array (s)
20.214 - return _Array (Declaration(s,'var'))
20.215 -end
20.216 -
20.217 -
21.1 --- a/source/tolua++/src/bin/lua/basic.lua Wed Nov 04 01:07:17 2009 +0000
21.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
21.3 @@ -1,342 +0,0 @@
21.4 --- tolua: basic utility functions
21.5 --- Written by Waldemar Celes
21.6 --- TeCGraf/PUC-Rio
21.7 --- Jul 1998
21.8 --- Last update: Apr 2003
21.9 --- $Id$
21.10 -
21.11 --- This code is free software; you can redistribute it and/or modify it.
21.12 --- The software provided hereunder is on an "as is" basis, and
21.13 --- the author has no obligation to provide maintenance, support, updates,
21.14 --- enhancements, or modifications.
21.15 -
21.16 -
21.17 --- Basic C types and their corresponding Lua types
21.18 --- All occurrences of "char*" will be replaced by "_cstring",
21.19 --- and all occurrences of "void*" will be replaced by "_userdata"
21.20 -_basic = {
21.21 - ['void'] = '',
21.22 - ['char'] = 'number',
21.23 - ['int'] = 'number',
21.24 - ['short'] = 'number',
21.25 - ['long'] = 'number',
21.26 - ['unsigned'] = 'number',
21.27 - ['float'] = 'number',
21.28 - ['double'] = 'number',
21.29 - ['_cstring'] = 'string',
21.30 - ['_userdata'] = 'userdata',
21.31 - ['char*'] = 'string',
21.32 - ['void*'] = 'userdata',
21.33 - ['bool'] = 'boolean',
21.34 - ['lua_Object'] = 'value',
21.35 - ['LUA_VALUE'] = 'value', -- for compatibility with tolua 4.0
21.36 - ['lua_State*'] = 'state',
21.37 - ['_lstate'] = 'state',
21.38 - ['lua_Function'] = 'value',
21.39 -}
21.40 -
21.41 -_basic_ctype = {
21.42 - number = "lua_Number",
21.43 - string = "const char*",
21.44 - userdata = "void*",
21.45 - boolean = "bool",
21.46 - value = "int",
21.47 -}
21.48 -
21.49 --- List of user defined types
21.50 --- Each type corresponds to a variable name that stores its tag value.
21.51 -_usertype = {}
21.52 -
21.53 --- List of types that have to be collected
21.54 -_collect = {}
21.55 -
21.56 --- List of types
21.57 -_global_types = {n=0}
21.58 -_global_types_hash = {}
21.59 -
21.60 --- list of classes
21.61 -_global_classes = {}
21.62 -
21.63 --- List of enum constants
21.64 -_global_enums = {}
21.65 -
21.66 --- List of auto renaming
21.67 -_renaming = {}
21.68 -function appendrenaming (s)
21.69 - local b,e,old,new = strfind(s,"%s*(.-)%s*@%s*(.-)%s*$")
21.70 - if not b then
21.71 - error("#Invalid renaming syntax; it should be of the form: pattern@pattern")
21.72 - end
21.73 - tinsert(_renaming,{old=old, new=new})
21.74 -end
21.75 -
21.76 -function applyrenaming (s)
21.77 - for i=1,getn(_renaming) do
21.78 - local m,n = gsub(s,_renaming[i].old,_renaming[i].new)
21.79 - if n ~= 0 then
21.80 - return m
21.81 - end
21.82 - end
21.83 - return nil
21.84 -end
21.85 -
21.86 --- Error handler
21.87 -function tolua_error (s,f)
21.88 -if _curr_code then
21.89 - print("***curr code for error is "..tostring(_curr_code))
21.90 - print(debug.traceback())
21.91 -end
21.92 - local out = _OUTPUT
21.93 - _OUTPUT = _STDERR
21.94 - if strsub(s,1,1) == '#' then
21.95 - write("\n** tolua: "..strsub(s,2)..".\n\n")
21.96 - if _curr_code then
21.97 - local _,_,s = strfind(_curr_code,"^%s*(.-\n)") -- extract first line
21.98 - if s==nil then s = _curr_code end
21.99 - s = gsub(s,"_userdata","void*") -- return with 'void*'
21.100 - s = gsub(s,"_cstring","char*") -- return with 'char*'
21.101 - s = gsub(s,"_lstate","lua_State*") -- return with 'lua_State*'
21.102 - write("Code being processed:\n"..s.."\n")
21.103 - end
21.104 - else
21.105 - if not f then f = "(f is nil)" end
21.106 - print("\n** tolua internal error: "..f..s..".\n\n")
21.107 - return
21.108 - end
21.109 - _OUTPUT = out
21.110 -end
21.111 -
21.112 -function warning (msg)
21.113 - local out = _OUTPUT
21.114 - _OUTPUT = _STDERR
21.115 - write("\n** tolua warning: "..msg..".\n\n")
21.116 - _OUTPUT = out
21.117 -end
21.118 -
21.119 --- register an user defined type: returns full type
21.120 -function regtype (t)
21.121 - if isbasic(t) then
21.122 - return t
21.123 - end
21.124 - local ft = findtype(t)
21.125 -
21.126 - if not _usertype[ft] then
21.127 - return appendusertype(t)
21.128 - end
21.129 - return ft
21.130 -end
21.131 -
21.132 --- return type name: returns full type
21.133 -function typevar(type)
21.134 - if type == '' or type == 'void' then
21.135 - return type
21.136 - else
21.137 - local ft = findtype(type)
21.138 - if ft then
21.139 - return ft
21.140 - end
21.141 - _usertype[type] = type
21.142 - return type
21.143 - end
21.144 -end
21.145 -
21.146 --- check if basic type
21.147 -function isbasic (type)
21.148 - local t = gsub(type,'const ','')
21.149 - local m,t = applytypedef('', t)
21.150 - local b = _basic[t]
21.151 - if b then
21.152 - return b,_basic_ctype[b]
21.153 - end
21.154 - return nil
21.155 -end
21.156 -
21.157 --- split string using a token
21.158 -function split (s,t)
21.159 - local l = {n=0}
21.160 - local f = function (s)
21.161 - l.n = l.n + 1
21.162 - l[l.n] = s
21.163 - end
21.164 - local p = "%s*(.-)%s*"..t.."%s*"
21.165 - s = gsub(s,"^%s+","")
21.166 - s = gsub(s,"%s+$","")
21.167 - s = gsub(s,p,f)
21.168 - l.n = l.n + 1
21.169 - l[l.n] = gsub(s,"(%s%s*)$","")
21.170 - return l
21.171 -end
21.172 -
21.173 --- splits a string using a pattern, considering the spacial cases of C code (templates, function parameters, etc)
21.174 --- pattern can't contain the '^' (as used to identify the begining of the line)
21.175 --- also strips whitespace
21.176 -function split_c_tokens(s, pat)
21.177 -
21.178 - s = string.gsub(s, "^%s*", "")
21.179 - s = string.gsub(s, "%s*$", "")
21.180 -
21.181 - local token_begin = 1
21.182 - local token_end = 1
21.183 - local ofs = 1
21.184 - local ret = {n=0}
21.185 -
21.186 - function add_token(ofs)
21.187 -
21.188 - local t = string.sub(s, token_begin, ofs)
21.189 - t = string.gsub(t, "^%s*", "")
21.190 - t = string.gsub(t, "%s*$", "")
21.191 - ret.n = ret.n + 1
21.192 - ret[ret.n] = t
21.193 - end
21.194 -
21.195 - while ofs <= string.len(s) do
21.196 -
21.197 - local sub = string.sub(s, ofs, -1)
21.198 - local b,e = string.find(sub, "^"..pat)
21.199 - if b then
21.200 - add_token(ofs-1)
21.201 - ofs = ofs+e
21.202 - token_begin = ofs
21.203 - else
21.204 - local char = string.sub(s, ofs, ofs)
21.205 - if char == "(" or char == "<" then
21.206 -
21.207 - local block
21.208 - if char == "(" then block = "^%b()" end
21.209 - if char == "<" then block = "^%b<>" end
21.210 -
21.211 - b,e = string.find(sub, block)
21.212 - if not b then
21.213 - -- unterminated block?
21.214 - ofs = ofs+1
21.215 - else
21.216 - ofs = ofs + e
21.217 - end
21.218 -
21.219 - else
21.220 - ofs = ofs+1
21.221 - end
21.222 - end
21.223 -
21.224 - end
21.225 - add_token(ofs)
21.226 - --if ret.n == 0 then
21.227 -
21.228 - -- ret.n=1
21.229 - -- ret[1] = ""
21.230 - --end
21.231 -
21.232 - return ret
21.233 -
21.234 -end
21.235 -
21.236 --- concatenate strings of a table
21.237 -function concat (t,f,l,jstr)
21.238 - jstr = jstr or " "
21.239 - local s = ''
21.240 - local i=f
21.241 - while i<=l do
21.242 - s = s..t[i]
21.243 - i = i+1
21.244 - if i <= l then s = s..jstr end
21.245 - end
21.246 - return s
21.247 -end
21.248 -
21.249 --- concatenate all parameters, following output rules
21.250 -function concatparam (line, ...)
21.251 - local i=1
21.252 - while i<=arg.n do
21.253 - if _cont and not strfind(_cont,'[%(,"]') and
21.254 - strfind(arg[i],"^[%a_~]") then
21.255 - line = line .. ' '
21.256 - end
21.257 - line = line .. arg[i]
21.258 - if arg[i] ~= '' then
21.259 - _cont = strsub(arg[i],-1,-1)
21.260 - end
21.261 - i = i+1
21.262 - end
21.263 - if strfind(arg[arg.n],"[%/%)%;%{%}]$") then
21.264 - _cont=nil line = line .. '\n'
21.265 - end
21.266 - return line
21.267 -end
21.268 -
21.269 --- output line
21.270 -function output (...)
21.271 - local i=1
21.272 - while i<=arg.n do
21.273 - if _cont and not strfind(_cont,'[%(,"]') and
21.274 - strfind(arg[i],"^[%a_~]") then
21.275 - write(' ')
21.276 - end
21.277 - write(arg[i])
21.278 - if arg[i] ~= '' then
21.279 - _cont = strsub(arg[i],-1,-1)
21.280 - end
21.281 - i = i+1
21.282 - end
21.283 - if strfind(arg[arg.n],"[%/%)%;%{%}]$") then
21.284 - _cont=nil write('\n')
21.285 - end
21.286 -end
21.287 -
21.288 -function get_property_methods(ptype, name)
21.289 -
21.290 - if get_property_methods_hook and get_property_methods_hook(ptype,name) then
21.291 - return get_property_methods_hook(ptype, name)
21.292 - end
21.293 -
21.294 - if ptype == "default" then -- get_name, set_name
21.295 - return "get_"..name, "set_"..name
21.296 - end
21.297 -
21.298 - if ptype == "qt" then -- name, setName
21.299 - return name, "set"..string.upper(string.sub(name, 1, 1))..string.sub(name, 2, -1)
21.300 - end
21.301 -
21.302 - if ptype == "overload" then -- name, name
21.303 - return name,name
21.304 - end
21.305 -
21.306 - return nil
21.307 -end
21.308 -
21.309 --------------- the hooks
21.310 -
21.311 --- called right after processing the $[ichl]file directives,
21.312 --- right before processing anything else
21.313 --- takes the package object as the parameter
21.314 -function preprocess_hook(p)
21.315 - -- p.code has all the input code from the pkg
21.316 -end
21.317 -
21.318 -
21.319 --- called for every $ifile directive
21.320 --- takes a table with a string called 'code' inside, the filename, and any extra arguments
21.321 --- passed to $ifile. no return value
21.322 -function include_file_hook(t, filename, ...)
21.323 -
21.324 -end
21.325 -
21.326 --- called after processing anything that's not code (like '$renaming', comments, etc)
21.327 --- and right before parsing the actual code.
21.328 --- takes the Package object with all the code on the 'code' key. no return value
21.329 -function preparse_hook(package)
21.330 -
21.331 -end
21.332 -
21.333 -
21.334 --- called after writing all the output.
21.335 --- takes the Package object
21.336 -function post_output_hook(package)
21.337 -
21.338 -end
21.339 -
21.340 -
21.341 --- called from 'get_property_methods' to get the methods to retrieve a property
21.342 --- according to its type
21.343 -function get_property_methods_hook(property_type, name)
21.344 -
21.345 -end
22.1 --- a/source/tolua++/src/bin/lua/changelog.txt Wed Nov 04 01:07:17 2009 +0000
22.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
22.3 @@ -1,18 +0,0 @@
22.4 -
22.5 --- templates
22.6 -
22.7 -changes on Class constructor
22.8 -changes on lname and cname (replaced [:<>, ] for '_')
22.9 -
22.10 -added call to applytypedef() on _Declaration(), to allow typedefs of non-basic types to work
22.11 -
22.12 --- misc
22.13 -on Package()
22.14 -moved the code that deals with renamigs to after the included directives are handled
22.15 -
22.16 -on classContainer:findtype()
22.17 -moved check for basic type to the beginning, to avoid enums being considered as objects of type 'int'
22.18 -
22.19 -
22.20 -
22.21 -
23.1 --- a/source/tolua++/src/bin/lua/class.lua Wed Nov 04 01:07:17 2009 +0000
23.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
23.3 @@ -1,203 +0,0 @@
23.4 --- tolua: class class
23.5 --- Written by Waldemar Celes
23.6 --- TeCGraf/PUC-Rio
23.7 --- Jul 1998
23.8 --- $Id$
23.9 -
23.10 --- This code is free software; you can redistribute it and/or modify it.
23.11 --- The software provided hereunder is on an "as is" basis, and
23.12 --- the author has no obligation to provide maintenance, support, updates,
23.13 --- enhancements, or modifications.
23.14 -
23.15 -
23.16 --- Class class
23.17 --- Represents a class definition.
23.18 --- Stores the following fields:
23.19 --- name = class name
23.20 --- base = class base, if any (only single inheritance is supported)
23.21 --- {i} = list of members
23.22 -classClass = {
23.23 - classtype = 'class',
23.24 - name = '',
23.25 - base = '',
23.26 - type = '',
23.27 - btype = '',
23.28 - ctype = '',
23.29 -}
23.30 -classClass.__index = classClass
23.31 -setmetatable(classClass,classContainer)
23.32 -
23.33 -
23.34 --- register class
23.35 -function classClass:register ()
23.36 - push(self)
23.37 - if _collect[self.type] then
23.38 - output('#ifdef __cplusplus\n')
23.39 - output(' tolua_cclass(tolua_S,"'..self.lname..'","'..self.type..'","'..self.btype..'",'.._collect[self.type]..');')
23.40 - output('#else\n')
23.41 - output(' tolua_cclass(tolua_S,"'..self.lname..'","'..self.type..'","'..self.btype..'",NULL);')
23.42 - output('#endif\n')
23.43 - else
23.44 - output(' tolua_cclass(tolua_S,"'..self.lname..'","'..self.type..'","'..self.btype..'",NULL);')
23.45 - end
23.46 - if self.extra_bases then
23.47 - for k,base in ipairs(self.extra_bases) do
23.48 - -- not now
23.49 - --output(' tolua_addbase(tolua_S, "'..self.type..'", "'..base..'");')
23.50 - end
23.51 - end
23.52 - output(' tolua_beginmodule(tolua_S,"'..self.lname..'");')
23.53 - local i=1
23.54 - while self[i] do
23.55 - self[i]:register()
23.56 - i = i+1
23.57 - end
23.58 - output(' tolua_endmodule(tolua_S);')
23.59 - pop()
23.60 -end
23.61 -
23.62 --- return collection requirement
23.63 -function classClass:requirecollection (t)
23.64 - if self.flags.protected_destructor then
23.65 - return false
23.66 - end
23.67 - push(self)
23.68 - local r = false
23.69 - local i=1
23.70 - while self[i] do
23.71 - r = self[i]:requirecollection(t) or r
23.72 - i = i+1
23.73 - end
23.74 - pop()
23.75 - -- only class that exports destructor can be appropriately collected
23.76 - -- classes that export constructors need to have a collector (overrided by -D flag on command line)
23.77 - if self._delete or ((not flags['D']) and self._new) then
23.78 - --t[self.type] = "tolua_collect_" .. gsub(self.type,"::","_")
23.79 - t[self.type] = "tolua_collect_" .. clean_template(self.type)
23.80 - r = true
23.81 - end
23.82 - return r
23.83 -end
23.84 -
23.85 --- output tags
23.86 -function classClass:decltype ()
23.87 - push(self)
23.88 - self.type = regtype(self.original_name or self.name)
23.89 - self.btype = typevar(self.base)
23.90 - self.ctype = 'const '..self.type
23.91 - if self.extra_bases then
23.92 - for i=1,table.getn(self.extra_bases) do
23.93 - self.extra_bases[i] = typevar(self.extra_bases[i])
23.94 - end
23.95 - end
23.96 - local i=1
23.97 - while self[i] do
23.98 - self[i]:decltype()
23.99 - i = i+1
23.100 - end
23.101 - pop()
23.102 -end
23.103 -
23.104 -
23.105 --- Print method
23.106 -function classClass:print (ident,close)
23.107 - print(ident.."Class{")
23.108 - print(ident.." name = '"..self.name.."',")
23.109 - print(ident.." base = '"..self.base.."';")
23.110 - print(ident.." lname = '"..self.lname.."',")
23.111 - print(ident.." type = '"..self.type.."',")
23.112 - print(ident.." btype = '"..self.btype.."',")
23.113 - print(ident.." ctype = '"..self.ctype.."',")
23.114 - local i=1
23.115 - while self[i] do
23.116 - self[i]:print(ident.." ",",")
23.117 - i = i+1
23.118 - end
23.119 - print(ident.."}"..close)
23.120 -end
23.121 -
23.122 -function classClass:set_protected_destructor(p)
23.123 - self.flags.protected_destructor = self.flags.protected_destructor or p
23.124 -end
23.125 -
23.126 --- Internal constructor
23.127 -function _Class (t)
23.128 - setmetatable(t,classClass)
23.129 - t:buildnames()
23.130 - append(t)
23.131 - return t
23.132 -end
23.133 -
23.134 --- Constructor
23.135 --- Expects the name, the base (array) and the body of the class.
23.136 -function Class (n,p,b)
23.137 -
23.138 - if table.getn(p) > 1 then
23.139 - b = string.sub(b, 1, -2)
23.140 - for i=2,table.getn(p),1 do
23.141 - b = b.."\n tolua_inherits "..p[i].." __"..p[i].."__;\n"
23.142 - end
23.143 - b = b.."\n}"
23.144 - end
23.145 -
23.146 - -- check for template
23.147 - local t,_,T,I = string.find(b, "TEMPLATE_BIND%s*%(+%s*\"?([^\",]*)\"?%s*,%s*([^%)]*)%s*%)+")
23.148 - if t then
23.149 -
23.150 - -- remove quotes
23.151 - I = string.gsub(I, "\"", "")
23.152 - T = string.gsub(T, "\"", "")
23.153 - -- get type list
23.154 - local types = split_c_tokens(I, ",")
23.155 - -- remove TEMPLATE_BIND line
23.156 - local bs = string.gsub(b, "\n[^\n]*TEMPLATE_BIND[^\n]*\n", "\n")
23.157 -
23.158 - -- replace
23.159 - for i =1 , types.n do
23.160 -
23.161 - local Tl = split(T, " ")
23.162 - local Il = split_c_tokens(types[i], " ")
23.163 - local bI = bs
23.164 - local pI = {}
23.165 - for j = 1,Tl.n do
23.166 - Tl[j] = findtype(Tl[j]) or Tl[j]
23.167 - bI = string.gsub(bI, "([^_%w])"..Tl[j].."([^_%w])", "%1"..Il[j].."%2")
23.168 - if p then
23.169 - for i=1,table.getn(p) do
23.170 - pI[i] = string.gsub(p[i], "([^_%w]?)"..Tl[j].."([^_%w]?)", "%1"..Il[j].."%2")
23.171 - end
23.172 - end
23.173 - end
23.174 - --local append = "<"..string.gsub(types[i], "%s+", ",")..">"
23.175 - local append = "<"..concat(Il, 1, table.getn(Il), ",")..">"
23.176 - append = string.gsub(append, "%s*,%s*", ",")
23.177 - append = string.gsub(append, ">>", "> >")
23.178 - for i=1,table.getn(pI) do
23.179 - --pI[i] = string.gsub(pI[i], ">>", "> >")
23.180 - pI[i] = resolve_template_types(pI[i])
23.181 - end
23.182 - bI = string.gsub(bI, ">>", "> >")
23.183 - Class(n..append, pI, bI)
23.184 - end
23.185 - return
23.186 - end
23.187 -
23.188 - local mbase
23.189 -
23.190 - if p then
23.191 - mbase = table.remove(p, 1)
23.192 - if not p[1] then p = nil end
23.193 - end
23.194 -
23.195 - mbase = mbase and resolve_template_types(mbase)
23.196 -
23.197 - local c = _Class(_Container{name=n, base=mbase, extra_bases=p})
23.198 -
23.199 - local ft = getnamespace(c.parent)..c.original_name
23.200 - append_global_type(ft, c)
23.201 -
23.202 - push(c)
23.203 - c:parse(strsub(b,2,strlen(b)-1)) -- eliminate braces
23.204 - pop()
23.205 -end
23.206 -
24.1 --- a/source/tolua++/src/bin/lua/clean.lua Wed Nov 04 01:07:17 2009 +0000
24.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
24.3 @@ -1,75 +0,0 @@
24.4 --- mark up comments and strings
24.5 -STR1 = "\001"
24.6 -STR2 = "\002"
24.7 -STR3 = "\003"
24.8 -STR4 = "\004"
24.9 -REM = "\005"
24.10 -ANY = "([\001-\005])"
24.11 -ESC1 = "\006"
24.12 -ESC2 = "\007"
24.13 -
24.14 -MASK = { -- the substitution order is important
24.15 - {ESC1, "\\'"},
24.16 - {ESC2, '\\"'},
24.17 - {STR1, "'"},
24.18 - {STR2, '"'},
24.19 - {STR3, "%[%["},
24.20 - {STR4, "%]%]"},
24.21 - {REM , "%-%-"},
24.22 -}
24.23 -
24.24 -function mask (s)
24.25 - for i = 1,getn(MASK) do
24.26 - s = gsub(s,MASK[i][2],MASK[i][1])
24.27 - end
24.28 - return s
24.29 -end
24.30 -
24.31 -function unmask (s)
24.32 - for i = 1,getn(MASK) do
24.33 - s = gsub(s,MASK[i][1],MASK[i][2])
24.34 - end
24.35 - return s
24.36 -end
24.37 -
24.38 -function clean (s)
24.39 - -- check for compilation error
24.40 - local code = "return function () " .. s .. " end"
24.41 - if not dostring(code) then
24.42 - return nil
24.43 - end
24.44 -
24.45 - local S = "" -- saved string
24.46 -
24.47 - s = mask(s)
24.48 -
24.49 - -- remove blanks and comments
24.50 - while 1 do
24.51 - local b,e,d = strfind(s,ANY)
24.52 - if b then
24.53 - S = S..strsub(s,1,b-1)
24.54 - s = strsub(s,b+1)
24.55 - if d==STR1 or d==STR2 then
24.56 - e = strfind(s,d)
24.57 - S = S ..d..strsub(s,1,e)
24.58 - s = strsub(s,e+1)
24.59 - elseif d==STR3 then
24.60 - e = strfind(s,STR4)
24.61 - S = S..d..strsub(s,1,e)
24.62 - s = strsub(s,e+1)
24.63 - elseif d==REM then
24.64 - s = gsub(s,"[^\n]*(\n?)","%1",1)
24.65 - end
24.66 - else
24.67 - S = S..s
24.68 - break
24.69 - end
24.70 - end
24.71 - -- eliminate unecessary spaces
24.72 - S = gsub(S,"[ \t]+"," ")
24.73 - S = gsub(S,"[ \t]*\n[ \t]*","\n")
24.74 - S = gsub(S,"\n+","\n")
24.75 - S = unmask(S)
24.76 - return S
24.77 -end
24.78 -
25.1 --- a/source/tolua++/src/bin/lua/code.lua Wed Nov 04 01:07:17 2009 +0000
25.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
25.3 @@ -1,78 +0,0 @@
25.4 --- tolua: code class
25.5 --- Written by Waldemar Celes
25.6 --- TeCGraf/PUC-Rio
25.7 --- Jul 1999
25.8 --- $Id$
25.9 -
25.10 --- This code is free software; you can redistribute it and/or modify it.
25.11 --- The software provided hereunder is on an "as is" basis, and
25.12 --- the author has no obligation to provide maintenance, support, updates,
25.13 --- enhancements, or modifications.
25.14 -
25.15 --- global
25.16 -code_n = 1
25.17 -
25.18 --- Code class
25.19 --- Represents Lua code to be compiled and included
25.20 --- in the initialization function.
25.21 --- The following fields are stored:
25.22 --- text = text code
25.23 -classCode = {
25.24 - text = '',
25.25 -}
25.26 -classCode.__index = classCode
25.27 -setmetatable(classCode,classFeature)
25.28 -
25.29 --- register code
25.30 -function classCode:register ()
25.31 - -- clean Lua code
25.32 - local s = clean(self.text)
25.33 - if not s then
25.34 - error("parser error in embedded code")
25.35 - end
25.36 -
25.37 - -- convert to C
25.38 - output('\n { /* begin embedded lua code */\n')
25.39 - output(' int top;')
25.40 - output(' top = lua_gettop(tolua_S);')
25.41 - output(' static unsigned char B[] = {\n ')
25.42 - local t={n=0}
25.43 - local b = gsub(s,'(.)',function (c)
25.44 - local e = ''
25.45 - t.n=t.n+1 if t.n==15 then t.n=0 e='\n ' end
25.46 - return format('%3u,%s',strbyte(c),e)
25.47 - end
25.48 - )
25.49 - output(b..strbyte(" "))
25.50 - output('\n };\n')
25.51 - output(' lua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code '..code_n..'");')
25.52 - output(' lua_settop(tolua_S, top);')
25.53 - output(' } /* end of embedded lua code */\n\n')
25.54 - code_n = code_n +1
25.55 -end
25.56 -
25.57 -
25.58 --- Print method
25.59 -function classCode:print (ident,close)
25.60 - print(ident.."Code{")
25.61 - print(ident.." text = [["..self.text.."]],")
25.62 - print(ident.."}"..close)
25.63 -end
25.64 -
25.65 -
25.66 --- Internal constructor
25.67 -function _Code (t)
25.68 - setmetatable(t,classCode)
25.69 - append(t)
25.70 - return t
25.71 -end
25.72 -
25.73 --- Constructor
25.74 --- Expects a string representing the code text
25.75 -function Code (l)
25.76 - return _Code {
25.77 - text = l
25.78 - }
25.79 -end
25.80 -
25.81 -
26.1 --- a/source/tolua++/src/bin/lua/compat.lua Wed Nov 04 01:07:17 2009 +0000
26.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
26.3 @@ -1,193 +0,0 @@
26.4 --------------------------------------------------------------------
26.5 --- Real globals
26.6 --- _ALERT
26.7 --- _ERRORMESSAGE
26.8 --- _VERSION
26.9 --- _G
26.10 --- assert
26.11 --- error
26.12 --- metatable
26.13 --- next
26.14 --- print
26.15 --- require
26.16 --- tonumber
26.17 --- tostring
26.18 --- type
26.19 --- unpack
26.20 -
26.21 --------------------------------------------------------------------
26.22 --- collectgarbage
26.23 --- gcinfo
26.24 -
26.25 --- globals
26.26 -
26.27 --- call -> protect(f, err)
26.28 --- loadfile
26.29 --- loadstring
26.30 -
26.31 --- rawget
26.32 --- rawset
26.33 -
26.34 --- getargs = Main.getargs ??
26.35 -
26.36 -rawtype = type
26.37 -
26.38 -function do_ (f, err)
26.39 - if not f then print(err); return end
26.40 - local a,b = pcall(f)
26.41 - if not a then print(b); return nil
26.42 - else return b or true
26.43 - end
26.44 -end
26.45 -
26.46 -function dostring(s) return do_(loadstring(s)) end
26.47 --- function dofile(s) return do_(loadfile(s)) end
26.48 -
26.49 --------------------------------------------------------------------
26.50 --- Table library
26.51 -local tab = table
26.52 -foreach = tab.foreach
26.53 -foreachi = tab.foreachi
26.54 -getn = tab.getn
26.55 -tinsert = tab.insert
26.56 -tremove = tab.remove
26.57 -sort = tab.sort
26.58 -
26.59 --------------------------------------------------------------------
26.60 --- Debug library
26.61 -local dbg = debug
26.62 -getinfo = dbg.getinfo
26.63 -getlocal = dbg.getlocal
26.64 -setcallhook = function () error"`setcallhook' is deprecated" end
26.65 -setlinehook = function () error"`setlinehook' is deprecated" end
26.66 -setlocal = dbg.setlocal
26.67 -
26.68 --------------------------------------------------------------------
26.69 --- math library
26.70 -local math = math
26.71 -abs = math.abs
26.72 -acos = function (x) return math.deg(math.acos(x)) end
26.73 -asin = function (x) return math.deg(math.asin(x)) end
26.74 -atan = function (x) return math.deg(math.atan(x)) end
26.75 -atan2 = function (x,y) return math.deg(math.atan2(x,y)) end
26.76 -ceil = math.ceil
26.77 -cos = function (x) return math.cos(math.rad(x)) end
26.78 -deg = math.deg
26.79 -exp = math.exp
26.80 -floor = math.floor
26.81 -frexp = math.frexp
26.82 -ldexp = math.ldexp
26.83 -log = math.log
26.84 -log10 = math.log10
26.85 -max = math.max
26.86 -min = math.min
26.87 -mod = math.mod
26.88 -PI = math.pi
26.89 ---??? pow = math.pow
26.90 -rad = math.rad
26.91 -random = math.random
26.92 -randomseed = math.randomseed
26.93 -sin = function (x) return math.sin(math.rad(x)) end
26.94 -sqrt = math.sqrt
26.95 -tan = function (x) return math.tan(math.rad(x)) end
26.96 -
26.97 --------------------------------------------------------------------
26.98 --- string library
26.99 -local str = string
26.100 -strbyte = str.byte
26.101 -strchar = str.char
26.102 -strfind = str.find
26.103 -format = str.format
26.104 -gsub = str.gsub
26.105 -strlen = str.len
26.106 -strlower = str.lower
26.107 -strrep = str.rep
26.108 -strsub = str.sub
26.109 -strupper = str.upper
26.110 -
26.111 --------------------------------------------------------------------
26.112 --- os library
26.113 -clock = os.clock
26.114 -date = os.date
26.115 -difftime = os.difftime
26.116 -execute = os.execute --?
26.117 -exit = os.exit
26.118 -getenv = os.getenv
26.119 -remove = os.remove
26.120 -rename = os.rename
26.121 -setlocale = os.setlocale
26.122 -time = os.time
26.123 -tmpname = os.tmpname
26.124 -
26.125 --------------------------------------------------------------------
26.126 --- compatibility only
26.127 -getglobal = function (n) return _G[n] end
26.128 -setglobal = function (n,v) _G[n] = v end
26.129 -
26.130 --------------------------------------------------------------------
26.131 -
26.132 -local io, tab = io, table
26.133 -
26.134 --- IO library (files)
26.135 -_STDIN = io.stdin
26.136 -_STDERR = io.stderr
26.137 -_STDOUT = io.stdout
26.138 -_INPUT = io.stdin
26.139 -_OUTPUT = io.stdout
26.140 -seek = io.stdin.seek -- sick ;-)
26.141 -tmpfile = io.tmpfile
26.142 -closefile = io.close
26.143 -openfile = io.open
26.144 -
26.145 -function flush (f)
26.146 - if f then f:flush()
26.147 - else _OUTPUT:flush()
26.148 - end
26.149 -end
26.150 -
26.151 -function readfrom (name)
26.152 - if name == nil then
26.153 - local f, err, cod = io.close(_INPUT)
26.154 - _INPUT = io.stdin
26.155 - return f, err, cod
26.156 - else
26.157 - local f, err, cod = io.open(name, "r")
26.158 - _INPUT = f or _INPUT
26.159 - return f, err, cod
26.160 - end
26.161 -end
26.162 -
26.163 -function writeto (name)
26.164 - if name == nil then
26.165 - local f, err, cod = io.close(_OUTPUT)
26.166 - _OUTPUT = io.stdout
26.167 - return f, err, cod
26.168 - else
26.169 - local f, err, cod = io.open(name, "w")
26.170 - _OUTPUT = f or _OUTPUT
26.171 - return f, err, cod
26.172 - end
26.173 -end
26.174 -
26.175 -function appendto (name)
26.176 - local f, err, cod = io.open(name, "a")
26.177 - _OUTPUT = f or _OUTPUT
26.178 - return f, err, cod
26.179 -end
26.180 -
26.181 -function read (...)
26.182 - local f = _INPUT
26.183 - if rawtype(arg[1]) == 'userdata' then
26.184 - f = tab.remove(arg, 1)
26.185 - end
26.186 - return f:read(unpack(arg))
26.187 -end
26.188 -
26.189 -function write (...)
26.190 - local f = _OUTPUT
26.191 - if rawtype(arg[1]) == 'userdata' then
26.192 - f = tab.remove(arg, 1)
26.193 - end
26.194 - return f:write(unpack(arg))
26.195 -end
26.196 -
27.1 --- a/source/tolua++/src/bin/lua/container.lua Wed Nov 04 01:07:17 2009 +0000
27.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
27.3 @@ -1,699 +0,0 @@
27.4 --- tolua: container abstract class
27.5 --- Written by Waldemar Celes
27.6 --- TeCGraf/PUC-Rio
27.7 --- Jul 1998
27.8 --- $Id$
27.9 -
27.10 --- This code is free software; you can redistribute it and/or modify it.
27.11 --- The software provided hereunder is on an "as is" basis, and
27.12 --- the author has no obligation to provide maintenance, support, updates,
27.13 --- enhancements, or modifications.
27.14 -
27.15 --- table to store namespaced typedefs/enums in global scope
27.16 -global_typedefs = {}
27.17 -global_enums = {}
27.18 -
27.19 --- Container class
27.20 --- Represents a container of features to be bound
27.21 --- to lua.
27.22 -classContainer =
27.23 -{
27.24 - curr = nil,
27.25 -}
27.26 -classContainer.__index = classContainer
27.27 -setmetatable(classContainer,classFeature)
27.28 -
27.29 --- output tags
27.30 -function classContainer:decltype ()
27.31 - push(self)
27.32 - local i=1
27.33 - while self[i] do
27.34 - self[i]:decltype()
27.35 - i = i+1
27.36 - end
27.37 - pop()
27.38 -end
27.39 -
27.40 -
27.41 --- write support code
27.42 -function classContainer:supcode ()
27.43 - push(self)
27.44 - local i=1
27.45 - while self[i] do
27.46 - self[i]:supcode()
27.47 - i = i+1
27.48 - end
27.49 - pop()
27.50 -end
27.51 -
27.52 -function classContainer:hasvar ()
27.53 - local i=1
27.54 - while self[i] do
27.55 - if self[i]:isvariable() then
27.56 - return 1
27.57 - end
27.58 - i = i+1
27.59 - end
27.60 - return 0
27.61 -end
27.62 -
27.63 --- Internal container constructor
27.64 -function _Container (self)
27.65 - setmetatable(self,classContainer)
27.66 - self.n = 0
27.67 - self.typedefs = {tolua_n=0}
27.68 - self.usertypes = {}
27.69 - self.enums = {tolua_n=0}
27.70 - self.lnames = {}
27.71 - return self
27.72 -end
27.73 -
27.74 --- push container
27.75 -function push (t)
27.76 - t.prox = classContainer.curr
27.77 - classContainer.curr = t
27.78 -end
27.79 -
27.80 --- pop container
27.81 -function pop ()
27.82 ---print("name",classContainer.curr.name)
27.83 ---foreach(classContainer.curr.usertypes,print)
27.84 ---print("______________")
27.85 - classContainer.curr = classContainer.curr.prox
27.86 -end
27.87 -
27.88 --- get current namespace
27.89 -function getcurrnamespace ()
27.90 - return getnamespace(classContainer.curr)
27.91 -end
27.92 -
27.93 --- append to current container
27.94 -function append (t)
27.95 - return classContainer.curr:append(t)
27.96 -end
27.97 -
27.98 --- append typedef to current container
27.99 -function appendtypedef (t)
27.100 - return classContainer.curr:appendtypedef(t)
27.101 -end
27.102 -
27.103 --- append usertype to current container
27.104 -function appendusertype (t)
27.105 - return classContainer.curr:appendusertype(t)
27.106 -end
27.107 -
27.108 --- append enum to current container
27.109 -function appendenum (t)
27.110 - return classContainer.curr:appendenum(t)
27.111 -end
27.112 -
27.113 --- substitute typedef
27.114 -function applytypedef (mod,type)
27.115 - return classContainer.curr:applytypedef(mod,type)
27.116 -end
27.117 -
27.118 --- check if is type
27.119 -function findtype (type)
27.120 - local t = classContainer.curr:findtype(type)
27.121 - return t
27.122 -end
27.123 -
27.124 --- check if is typedef
27.125 -function istypedef (type)
27.126 - return classContainer.curr:istypedef(type)
27.127 -end
27.128 -
27.129 --- get fulltype (with namespace)
27.130 -function fulltype (t)
27.131 - local curr = classContainer.curr
27.132 - while curr do
27.133 - if curr then
27.134 - if curr.typedefs and curr.typedefs[t] then
27.135 - return curr.typedefs[t]
27.136 - elseif curr.usertypes and curr.usertypes[t] then
27.137 - return curr.usertypes[t]
27.138 - end
27.139 - end
27.140 - curr = curr.prox
27.141 - end
27.142 - return t
27.143 -end
27.144 -
27.145 --- checks if it requires collection
27.146 -function classContainer:requirecollection (t)
27.147 - push(self)
27.148 - local i=1
27.149 - local r = false
27.150 - while self[i] do
27.151 - r = self[i]:requirecollection(t) or r
27.152 - i = i+1
27.153 - end
27.154 - pop()
27.155 - return r
27.156 -end
27.157 -
27.158 -
27.159 --- get namesapce
27.160 -function getnamespace (curr)
27.161 - local namespace = ''
27.162 - while curr do
27.163 - if curr and
27.164 - ( curr.classtype == 'class' or curr.classtype == 'namespace')
27.165 - then
27.166 - namespace = (curr.original_name or curr.name) .. '::' .. namespace
27.167 - --namespace = curr.name .. '::' .. namespace
27.168 - end
27.169 - curr = curr.prox
27.170 - end
27.171 - return namespace
27.172 -end
27.173 -
27.174 --- get namespace (only namespace)
27.175 -function getonlynamespace ()
27.176 - local curr = classContainer.curr
27.177 - local namespace = ''
27.178 - while curr do
27.179 - if curr.classtype == 'class' then
27.180 - return namespace
27.181 - elseif curr.classtype == 'namespace' then
27.182 - namespace = curr.name .. '::' .. namespace
27.183 - end
27.184 - curr = curr.prox
27.185 - end
27.186 - return namespace
27.187 -end
27.188 -
27.189 --- check if is enum
27.190 -function isenum (type)
27.191 - return classContainer.curr:isenum(type)
27.192 -end
27.193 -
27.194 --- append feature to container
27.195 -function classContainer:append (t)
27.196 - self.n = self.n + 1
27.197 - self[self.n] = t
27.198 - t.parent = self
27.199 -end
27.200 -
27.201 --- append typedef
27.202 -function classContainer:appendtypedef (t)
27.203 - local namespace = getnamespace(classContainer.curr)
27.204 - self.typedefs.tolua_n = self.typedefs.tolua_n + 1
27.205 - self.typedefs[self.typedefs.tolua_n] = t
27.206 - self.typedefs[t.utype] = namespace .. t.utype
27.207 - global_typedefs[namespace..t.utype] = t
27.208 - t.ftype = findtype(t.type) or t.type
27.209 - --print("appending typedef "..t.utype.." as "..namespace..t.utype.." with ftype "..t.ftype)
27.210 - append_global_type(namespace..t.utype)
27.211 - if t.ftype and isenum(t.ftype) then
27.212 -
27.213 - global_enums[namespace..t.utype] = true
27.214 - end
27.215 -end
27.216 -
27.217 --- append usertype: return full type
27.218 -function classContainer:appendusertype (t)
27.219 - local container
27.220 - if t == (self.original_name or self.name) then
27.221 - container = self.prox
27.222 - else
27.223 - container = self
27.224 - end
27.225 - local ft = getnamespace(container) .. t
27.226 - container.usertypes[t] = ft
27.227 - _usertype[ft] = ft
27.228 - return ft
27.229 -end
27.230 -
27.231 --- append enum
27.232 -function classContainer:appendenum (t)
27.233 - local namespace = getnamespace(classContainer.curr)
27.234 - self.enums.tolua_n = self.enums.tolua_n + 1
27.235 - self.enums[self.enums.tolua_n] = t
27.236 - global_enums[namespace..t.name] = t
27.237 -end
27.238 -
27.239 --- determine lua function name overload
27.240 -function classContainer:overload (lname)
27.241 - if not self.lnames[lname] then
27.242 - self.lnames[lname] = 0
27.243 - else
27.244 - self.lnames[lname] = self.lnames[lname] + 1
27.245 - end
27.246 - return format("%02d",self.lnames[lname])
27.247 -end
27.248 -
27.249 --- applies typedef: returns the 'the facto' modifier and type
27.250 -function classContainer:applytypedef (mod,type)
27.251 - if global_typedefs[type] then
27.252 - --print("found typedef "..global_typedefs[type].type)
27.253 - local mod1, type1 = global_typedefs[type].mod, global_typedefs[type].ftype
27.254 - local mod2, type2 = applytypedef(mod.." "..mod1, type1)
27.255 - --return mod2 .. ' ' .. mod1, type2
27.256 - return mod2, type2
27.257 - end
27.258 - do return mod,type end
27.259 -end
27.260 -
27.261 --- check if it is a typedef
27.262 -function classContainer:istypedef (type)
27.263 - local env = self
27.264 - while env do
27.265 - if env.typedefs then
27.266 - local i=1
27.267 - while env.typedefs[i] do
27.268 - if env.typedefs[i].utype == type then
27.269 - return type
27.270 - end
27.271 - i = i+1
27.272 - end
27.273 - end
27.274 - env = env.parent
27.275 - end
27.276 - return nil
27.277 -end
27.278 -
27.279 -function find_enum_var(var)
27.280 -
27.281 - if tonumber(var) then return var end
27.282 -
27.283 - local c = classContainer.curr
27.284 - while c do
27.285 - local ns = getnamespace(c)
27.286 - for k,v in pairs(_global_enums) do
27.287 - if match_type(var, v, ns) then
27.288 - return v
27.289 - end
27.290 - end
27.291 - if c.base and c.base ~= '' then
27.292 - c = _global_classes[c:findtype(c.base)]
27.293 - else
27.294 - c = nil
27.295 - end
27.296 - end
27.297 -
27.298 - return var
27.299 -end
27.300 -
27.301 --- check if is a registered type: return full type or nil
27.302 -function classContainer:findtype (t)
27.303 -
27.304 - t = string.gsub(t, "=.*", "")
27.305 - if _basic[t] then
27.306 - return t
27.307 - end
27.308 -
27.309 - local _,_,em = string.find(t, "([&%*])%s*$")
27.310 - t = string.gsub(t, "%s*([&%*])%s*$", "")
27.311 - p = self
27.312 - while p and type(p)=='table' do
27.313 - local st = getnamespace(p)
27.314 -
27.315 - for i=_global_types.n,1,-1 do -- in reverse order
27.316 -
27.317 - if match_type(t, _global_types[i], st) then
27.318 - return _global_types[i]..(em or "")
27.319 - end
27.320 - end
27.321 - if p.base and p.base ~= '' and p.base ~= t then
27.322 - --print("type is "..t..", p is "..p.base.." self.type is "..self.type.." self.name is "..self.name)
27.323 - p = _global_classes[p:findtype(p.base)]
27.324 - else
27.325 - p = nil
27.326 - end
27.327 - end
27.328 -
27.329 - return nil
27.330 -end
27.331 -
27.332 -function append_global_type(t, class)
27.333 - _global_types.n = _global_types.n +1
27.334 - _global_types[_global_types.n] = t
27.335 - _global_types_hash[t] = 1
27.336 - if class then append_class_type(t, class) end
27.337 -end
27.338 -
27.339 -function append_class_type(t,class)
27.340 - if _global_classes[t] then
27.341 - class.flags = _global_classes[t].flags
27.342 - class.lnames = _global_classes[t].lnames
27.343 - if _global_classes[t].base and (_global_classes[t].base ~= '') then
27.344 - class.base = _global_classes[t].base or class.base
27.345 - end
27.346 - end
27.347 - _global_classes[t] = class
27.348 - class.flags = class.flags or {}
27.349 -end
27.350 -
27.351 -function match_type(childtype, regtype, st)
27.352 ---print("findtype "..childtype..", "..regtype..", "..st)
27.353 - local b,e = string.find(regtype, childtype, -string.len(childtype), true)
27.354 - if b then
27.355 -
27.356 - if e == string.len(regtype) and
27.357 - (b == 1 or (string.sub(regtype, b-1, b-1) == ':' and
27.358 - string.sub(regtype, 1, b-1) == string.sub(st, 1, b-1))) then
27.359 - return true
27.360 - end
27.361 - end
27.362 -
27.363 - return false
27.364 -end
27.365 -
27.366 -function findtype_on_childs(self, t)
27.367 -
27.368 - local tchild
27.369 - if self.classtype == 'class' or self.classtype == 'namespace' then
27.370 - for k,v in ipairs(self) do
27.371 - if v.classtype == 'class' or v.classtype == 'namespace' then
27.372 - if v.typedefs and v.typedefs[t] then
27.373 - return v.typedefs[t]
27.374 - elseif v.usertypes and v.usertypes[t] then
27.375 - return v.usertypes[t]
27.376 - end
27.377 - tchild = findtype_on_childs(v, t)
27.378 - if tchild then return tchild end
27.379 - end
27.380 - end
27.381 - end
27.382 - return nil
27.383 -
27.384 -end
27.385 -
27.386 -function classContainer:isenum (type)
27.387 - if global_enums[type] then
27.388 - return type
27.389 - else
27.390 - return false
27.391 - end
27.392 -
27.393 - local basetype = gsub(type,"^.*::","")
27.394 - local env = self
27.395 - while env do
27.396 - if env.enums then
27.397 - local i=1
27.398 - while env.enums[i] do
27.399 - if env.enums[i].name == basetype then
27.400 - return true
27.401 - end
27.402 - i = i+1
27.403 - end
27.404 - end
27.405 - env = env.parent
27.406 - end
27.407 - return false
27.408 -end
27.409 -
27.410 --- parse chunk
27.411 -function classContainer:doparse (s)
27.412 ---print ("parse "..s)
27.413 -
27.414 - -- try the null statement
27.415 - do
27.416 - local b,e,code = string.find(s, "^%s*;")
27.417 - if b then
27.418 - return strsub(s,e+1)
27.419 - end
27.420 - end
27.421 -
27.422 - -- try empty verbatim line
27.423 - do
27.424 - local b,e,code = string.find(s, "^%s*$\n")
27.425 - if b then
27.426 - return strsub(s,e+1)
27.427 - end
27.428 - end
27.429 -
27.430 - -- try Lua code
27.431 - do
27.432 - local b,e,code = strfind(s,"^%s*(%b\1\2)")
27.433 - if b then
27.434 - Code(strsub(code,2,-2))
27.435 - return strsub(s,e+1)
27.436 - end
27.437 - end
27.438 -
27.439 - -- try C code
27.440 - do
27.441 - local b,e,code = strfind(s,"^%s*(%b\3\4)")
27.442 - if b then
27.443 - code = '{'..strsub(code,2,-2)..'\n}\n'
27.444 - Verbatim(code,'r') -- verbatim code for 'r'egister fragment
27.445 - return strsub(s,e+1)
27.446 - end
27.447 - end
27.448 -
27.449 - -- try default_property directive
27.450 - do
27.451 - local b,e,ptype = strfind(s, "^%s*TOLUA_PROPERTY_TYPE%s*%(+%s*([^%)%s]*)%s*%)+%s*;?")
27.452 - if b then
27.453 - if not ptype or ptype == "" then
27.454 - ptype = "default"
27.455 - end
27.456 - self:set_property_type(ptype)
27.457 - return strsub(s, e+1)
27.458 - end
27.459 - end
27.460 -
27.461 - -- try protected_destructor directive
27.462 - do
27.463 - local b,e = string.find(s, "^%s*TOLUA_PROTECTED_DESTRUCTOR%s*;?")
27.464 - if b then
27.465 - if self.set_protected_destructor then
27.466 - self:set_protected_destructor(true)
27.467 - end
27.468 - return strsub(s, e+1)
27.469 - end
27.470 - end
27.471 -
27.472 - -- try module
27.473 - do
27.474 - local b,e,name,body = strfind(s,"^%s*module%s%s*([_%w][_%w]*)%s*(%b{})%s*")
27.475 - if b then
27.476 - _curr_code = strsub(s,b,e)
27.477 - Module(name,body)
27.478 - return strsub(s,e+1)
27.479 - end
27.480 - end
27.481 -
27.482 - -- try namesapce
27.483 - do
27.484 - local b,e,name,body = strfind(s,"^%s*namespace%s%s*([_%w][_%w]*)%s*(%b{})%s*;?")
27.485 - if b then
27.486 - _curr_code = strsub(s,b,e)
27.487 - Namespace(name,body)
27.488 - return strsub(s,e+1)
27.489 - end
27.490 - end
27.491 -
27.492 - -- try define
27.493 - do
27.494 - local b,e,name = strfind(s,"^%s*#define%s%s*([^%s]*)[^\n]*\n%s*")
27.495 - if b then
27.496 - _curr_code = strsub(s,b,e)
27.497 - Define(name)
27.498 - return strsub(s,e+1)
27.499 - end
27.500 - end
27.501 -
27.502 - -- try enumerates
27.503 -
27.504 - do
27.505 - local b,e,name,body,varname = strfind(s,"^%s*enum%s+(%S*)%s*(%b{})%s*([^%s;]*)%s*;?%s*")
27.506 - if b then
27.507 - --error("#Sorry, declaration of enums and variables on the same statement is not supported.\nDeclare your variable separately (example: '"..name.." "..varname..";')")
27.508 - _curr_code = strsub(s,b,e)
27.509 - Enumerate(name,body,varname)
27.510 - return strsub(s,e+1)
27.511 - end
27.512 - end
27.513 -
27.514 --- do
27.515 --- local b,e,name,body = strfind(s,"^%s*enum%s+(%S*)%s*(%b{})%s*;?%s*")
27.516 --- if b then
27.517 --- _curr_code = strsub(s,b,e)
27.518 --- Enumerate(name,body)
27.519 --- return strsub(s,e+1)
27.520 --- end
27.521 --- end
27.522 -
27.523 - do
27.524 - local b,e,body,name = strfind(s,"^%s*typedef%s+enum[^{]*(%b{})%s*([%w_][^%s]*)%s*;%s*")
27.525 - if b then
27.526 - _curr_code = strsub(s,b,e)
27.527 - Enumerate(name,body)
27.528 - return strsub(s,e+1)
27.529 - end
27.530 - end
27.531 -
27.532 - -- try operator
27.533 - do
27.534 - local b,e,decl,kind,arg,const = strfind(s,"^%s*([_%w][_%w%s%*&:<>,]-%s+operator)%s*([^%s][^%s]*)%s*(%b())%s*(c?o?n?s?t?)%s*;%s*")
27.535 - if not b then
27.536 - -- try inline
27.537 - b,e,decl,kind,arg,const = strfind(s,"^%s*([_%w][_%w%s%*&:<>,]-%s+operator)%s*([^%s][^%s]*)%s*(%b())%s*(c?o?n?s?t?)[%s\n]*%b{}%s*;?%s*")
27.538 - end
27.539 - if b then
27.540 - _curr_code = strsub(s,b,e)
27.541 - Operator(decl,kind,arg,const)
27.542 - return strsub(s,e+1)
27.543 - end
27.544 - end
27.545 -
27.546 - -- try function
27.547 - do
27.548 - --local b,e,decl,arg,const = strfind(s,"^%s*([~_%w][_@%w%s%*&:<>]*[_%w])%s*(%b())%s*(c?o?n?s?t?)%s*=?%s*0?%s*;%s*")
27.549 - local b,e,decl,arg,const = strfind(s,"^%s*([^%(\n]+)%s*(%b())%s*(c?o?n?s?t?)%s*=?%s*0?%s*;%s*")
27.550 - if not b then
27.551 - -- try function with template
27.552 - b,e,decl,arg,const = strfind(s,"^%s*([~_%w][_@%w%s%*&:<>]*[_%w]%b<>)%s*(%b())%s*(c?o?n?s?t?)%s*=?%s*0?%s*;%s*")
27.553 - end
27.554 - if not b then
27.555 - -- try a single letter function name
27.556 - b,e,decl,arg,const = strfind(s,"^%s*([_%w])%s*(%b())%s*(c?o?n?s?t?)%s*;%s*")
27.557 - end
27.558 - if b then
27.559 - _curr_code = strsub(s,b,e)
27.560 - Function(decl,arg,const)
27.561 - return strsub(s,e+1)
27.562 - end
27.563 - end
27.564 -
27.565 - -- try inline function
27.566 - do
27.567 - local b,e,decl,arg,const = strfind(s,"^%s*([^%(\n]+)%s*(%b())%s*(c?o?n?s?t?)[^;{]*%b{}%s*;?%s*")
27.568 - --local b,e,decl,arg,const = strfind(s,"^%s*([~_%w][_@%w%s%*&:<>]*[_%w>])%s*(%b())%s*(c?o?n?s?t?)[^;]*%b{}%s*;?%s*")
27.569 - if not b then
27.570 - -- try a single letter function name
27.571 - b,e,decl,arg,const = strfind(s,"^%s*([_%w])%s*(%b())%s*(c?o?n?s?t?).-%b{}%s*;?%s*")
27.572 - end
27.573 - if b then
27.574 - _curr_code = strsub(s,b,e)
27.575 - Function(decl,arg,const)
27.576 - return strsub(s,e+1)
27.577 - end
27.578 - end
27.579 -
27.580 - -- try class
27.581 - do
27.582 - local b,e,name,base,body
27.583 - base = '' body = ''
27.584 - b,e,name = strfind(s,"^%s*class%s*([_%w][_%w@]*)%s*;") -- dummy class
27.585 - if not b then
27.586 - b,e,name = strfind(s,"^%s*struct%s*([_%w][_%w@]*)%s*;") -- dummy struct
27.587 - if not b then
27.588 - b,e,name,base,body = strfind(s,"^%s*class%s*([_%w][_%w@]*)%s*(.-)%s*(%b{})%s*;%s*")
27.589 - if not b then
27.590 - b,e,name,base,body = strfind(s,"^%s*struct%s*([_%w][_%w@]*)%s*(.-)%s*(%b{})%s*;%s*")
27.591 - if not b then
27.592 - b,e,name,base,body = strfind(s,"^%s*union%s*([_%w][_%w@]*)%s*(.-)%s*(%b{})%s*;%s*")
27.593 - if not b then
27.594 - base = ''
27.595 - b,e,body,name = strfind(s,"^%s*typedef%s%s*struct%s%s*[_%w]*%s*(%b{})%s*([_%w][_%w@]*)%s*;%s*")
27.596 - end
27.597 - end
27.598 - end
27.599 - end
27.600 - end
27.601 - if b then
27.602 - if base ~= '' then
27.603 - base = string.gsub(base, "^%s*:%s*", "")
27.604 - base = string.gsub(base, "%s*public%s*", "")
27.605 - base = split(base, ",")
27.606 - --local b,e
27.607 - --b,e,base = strfind(base,".-([_%w][_%w<>,:]*)$")
27.608 - else
27.609 - base = {}
27.610 - end
27.611 - _curr_code = strsub(s,b,e)
27.612 - Class(name,base,body)
27.613 - return strsub(s,e+1)
27.614 - end
27.615 - end
27.616 -
27.617 - -- try typedef
27.618 - do
27.619 - local b,e,types = strfind(s,"^%s*typedef%s%s*(.-)%s*;%s*")
27.620 - if b then
27.621 - _curr_code = strsub(s,b,e)
27.622 - Typedef(types)
27.623 - return strsub(s,e+1)
27.624 - end
27.625 - end
27.626 -
27.627 - -- try variable
27.628 - do
27.629 - local b,e,decl = strfind(s,"^%s*([_%w][_@%s%w%d%*&:<>,]*[_%w%d])%s*;%s*")
27.630 - if b then
27.631 - _curr_code = strsub(s,b,e)
27.632 -
27.633 - local list = split_c_tokens(decl, ",")
27.634 - Variable(list[1])
27.635 - if list.n > 1 then
27.636 - local _,_,type = strfind(list[1], "(.-)%s+([^%s]*)$");
27.637 -
27.638 - local i =2;
27.639 - while list[i] do
27.640 - Variable(type.." "..list[i])
27.641 - i=i+1
27.642 - end
27.643 - end
27.644 - --Variable(decl)
27.645 - return strsub(s,e+1)
27.646 - end
27.647 - end
27.648 -
27.649 - -- try string
27.650 - do
27.651 - local b,e,decl = strfind(s,"^%s*([_%w]?[_%s%w%d]-char%s+[_@%w%d]*%s*%[%s*%S+%s*%])%s*;%s*")
27.652 - if b then
27.653 - _curr_code = strsub(s,b,e)
27.654 - Variable(decl)
27.655 - return strsub(s,e+1)
27.656 - end
27.657 - end
27.658 -
27.659 - -- try array
27.660 - do
27.661 - local b,e,decl = strfind(s,"^%s*([_%w][][_@%s%w%d%*&:]*[]_%w%d])%s*;%s*")
27.662 - if b then
27.663 - _curr_code = strsub(s,b,e)
27.664 - Array(decl)
27.665 - return strsub(s,e+1)
27.666 - end
27.667 - end
27.668 -
27.669 - -- no matching
27.670 - if gsub(s,"%s%s*","") ~= "" then
27.671 - _curr_code = s
27.672 - error("#parse error")
27.673 - else
27.674 - return ""
27.675 - end
27.676 -
27.677 -end
27.678 -
27.679 -function classContainer:parse (s)
27.680 - while s ~= '' do
27.681 - s = self:doparse(s)
27.682 - end
27.683 -end
27.684 -
27.685 -
27.686 --- property types
27.687 -
27.688 -function get_property_type()
27.689 -
27.690 - return classContainer.curr:get_property_type()
27.691 -end
27.692 -
27.693 -function classContainer:set_property_type(ptype)
27.694 - ptype = string.gsub(ptype, "^%s*", "")
27.695 - ptype = string.gsub(ptype, "%s*$", "")
27.696 -
27.697 - self.property_type = ptype
27.698 -end
27.699 -
27.700 -function classContainer:get_property_type()
27.701 - return self.property_type or (self.parent and self.parent:get_property_type()) or "default"
27.702 -end
28.1 --- a/source/tolua++/src/bin/lua/custom.lua Wed Nov 04 01:07:17 2009 +0000
28.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
28.3 @@ -1,26 +0,0 @@
28.4 -
28.5 -function extract_code(fn,s)
28.6 - local code = ""
28.7 - if fn then
28.8 - code = '\n$#include "'..fn..'"\n'
28.9 - end
28.10 - s= "\n" .. s .. "\n" -- add blank lines as sentinels
28.11 - local _,e,c,t = strfind(s, "\n([^\n]-)SCRIPT_([%w_]*)[^\n]*\n")
28.12 - while e do
28.13 - t = strlower(t)
28.14 - if t == "bind_begin" then
28.15 - _,e,c = strfind(s,"(.-)\n[^\n]*SCRIPT_BIND_END[^\n]*\n",e)
28.16 - if not e then
28.17 - tolua_error("Unbalanced 'SCRIPT_BIND_BEGIN' directive in header file")
28.18 - end
28.19 - end
28.20 - if t == "bind_class" or t == "bind_block" then
28.21 - local b
28.22 - _,e,c,b = string.find(s, "([^{]-)(%b{})", e)
28.23 - c = c..'{'..extract_code(nil, b)..'};\n'
28.24 - end
28.25 - code = code .. c .. "\n"
28.26 - _,e,c,t = strfind(s, "\n([^\n]-)SCRIPT_([%w_]*)[^\n]*\n",e)
28.27 - end
28.28 - return code
28.29 -end
29.1 --- a/source/tolua++/src/bin/lua/custom_hide.lua Wed Nov 04 01:07:17 2009 +0000
29.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
29.3 @@ -1,21 +0,0 @@
29.4 --- extract code with tolua_hide, and also
29.5 -function extract_code(fn,s)
29.6 - local code = '\n$#include "'..fn..'"\n'
29.7 - s= "\n" .. s .. "\n" -- add blank lines as sentinels
29.8 - local _,e,c,t = strfind(s, "\n([^\n]-)[Tt][Oo][Ll][Uu][Aa]_([^%s]*)[^\n]*\n")
29.9 - while e do
29.10 - t = strlower(t)
29.11 - if t == "begin" then
29.12 - _,e,c = strfind(s,"(.-)\n[^\n]*[Tt][Oo][Ll][Uu][Aa]_[Ee][Nn][Dd][^\n]*\n",e)
29.13 - if not e then
29.14 - tolua_error("Unbalanced 'tolua_begin' directive in header file")
29.15 - end
29.16 - end
29.17 - c = c.."\n"
29.18 - c = string.gsub(c, "\n[^\n]*[Tt][Oo][Ll][Uu][Aa]_[hH][iI][Dd][eE][^\n]*\n", "\n");
29.19 - c = string.gsub(c, "#define[^%(\n]*%(.-\n", "\n")
29.20 - code = code .. c
29.21 - _,e,c,t = strfind(s, "\n([^\n]-)[Tt][Oo][Ll][Uu][Aa]_([^%s]*)[^\n]*\n",e)
29.22 - end
29.23 - return code
29.24 -end
30.1 --- a/source/tolua++/src/bin/lua/declaration.lua Wed Nov 04 01:07:17 2009 +0000
30.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
30.3 @@ -1,567 +0,0 @@
30.4 --- tolua: declaration class
30.5 --- Written by Waldemar Celes
30.6 --- TeCGraf/PUC-Rio
30.7 --- Jul 1998
30.8 --- $Id$
30.9 -
30.10 --- This code is free software; you can redistribute it and/or modify it.
30.11 --- The software provided hereunder is on an "as is" basis, and
30.12 --- the author has no obligation to provide maintenance, support, updates,
30.13 --- enhancements, or modifications.
30.14 -
30.15 -
30.16 --- Declaration class
30.17 --- Represents variable, function, or argument declaration.
30.18 --- Stores the following fields:
30.19 --- mod = type modifiers
30.20 --- type = type
30.21 --- ptr = "*" or "&", if representing a pointer or a reference
30.22 --- name = name
30.23 --- dim = dimension, if a vector
30.24 --- def = default value, if any (only for arguments)
30.25 --- ret = "*" or "&", if value is to be returned (only for arguments)
30.26 -classDeclaration = {
30.27 - mod = '',
30.28 - type = '',
30.29 - ptr = '',
30.30 - name = '',
30.31 - dim = '',
30.32 - ret = '',
30.33 - def = ''
30.34 -}
30.35 -classDeclaration.__index = classDeclaration
30.36 -setmetatable(classDeclaration,classFeature)
30.37 -
30.38 --- Create an unique variable name
30.39 -function create_varname ()
30.40 - if not _varnumber then _varnumber = 0 end
30.41 - _varnumber = _varnumber + 1
30.42 - return "tolua_var_".._varnumber
30.43 -end
30.44 -
30.45 --- Check declaration name
30.46 --- It also identifies default values
30.47 -function classDeclaration:checkname ()
30.48 -
30.49 - if strsub(self.name,1,1) == '[' and not findtype(self.type) then
30.50 - self.name = self.type..self.name
30.51 - local m = split(self.mod,'%s%s*')
30.52 - self.type = m[m.n]
30.53 - self.mod = concat(m,1,m.n-1)
30.54 - end
30.55 -
30.56 - local t = split(self.name,'=')
30.57 - if t.n==2 then
30.58 - self.name = t[1]
30.59 - self.def = find_enum_var(t[t.n])
30.60 - end
30.61 -
30.62 - local b,e,d = strfind(self.name,"%[(.-)%]")
30.63 - if b then
30.64 - self.name = strsub(self.name,1,b-1)
30.65 - self.dim = find_enum_var(d)
30.66 - end
30.67 -
30.68 -
30.69 - if self.type ~= '' and self.type ~= 'void' and self.name == '' then
30.70 - self.name = create_varname()
30.71 - elseif self.kind=='var' then
30.72 - if self.type=='' and self.name~='' then
30.73 - self.type = self.type..self.name
30.74 - self.name = create_varname()
30.75 - elseif findtype(self.name) then
30.76 - if self.type=='' then self.type = self.name
30.77 - else self.type = self.type..' '..self.name end
30.78 - self.name = create_varname()
30.79 - end
30.80 - end
30.81 -
30.82 - -- adjust type of string
30.83 - if self.type == 'char' and self.dim ~= '' then
30.84 - self.type = 'char*'
30.85 - end
30.86 -
30.87 - if self.kind and self.kind == 'var' then
30.88 - self.name = string.gsub(self.name, ":.*$", "") -- ???
30.89 - end
30.90 -end
30.91 -
30.92 --- Check declaration type
30.93 --- Substitutes typedef's.
30.94 -function classDeclaration:checktype ()
30.95 -
30.96 - -- check if there is a pointer to basic type
30.97 - local basic = isbasic(self.type)
30.98 - if self.kind == 'func' and basic=='number' and string.find(self.ptr, "%*") then
30.99 - self.type = '_userdata'
30.100 - self.ptr = ""
30.101 - end
30.102 - if basic and self.ptr~='' then
30.103 - self.ret = self.ptr
30.104 - self.ptr = nil
30.105 - if isbasic(self.type) == 'number' then
30.106 - self.return_userdata = true
30.107 - end
30.108 - end
30.109 -
30.110 - -- check if there is array to be returned
30.111 - if self.dim~='' and self.ret~='' then
30.112 - error('#invalid parameter: cannot return an array of values')
30.113 - end
30.114 - -- restore 'void*' and 'string*'
30.115 - if self.type == '_userdata' then self.type = 'void*'
30.116 - elseif self.type == '_cstring' then self.type = 'char*'
30.117 - elseif self.type == '_lstate' then self.type = 'lua_State*'
30.118 - end
30.119 -
30.120 - -- resolve types inside the templates
30.121 - if self.type then
30.122 - self.type = resolve_template_types(self.type)
30.123 - end
30.124 -
30.125 ---
30.126 --- -- if returning value, automatically set default value
30.127 --- if self.ret ~= '' and self.def == '' then
30.128 --- self.def = '0'
30.129 --- end
30.130 ---
30.131 -
30.132 -end
30.133 -
30.134 -function resolve_template_types(type)
30.135 -
30.136 - if isbasic(type) then
30.137 - return type
30.138 - end
30.139 - local b,_,m = string.find(type, "(%b<>)")
30.140 - if b then
30.141 -
30.142 - m = split_c_tokens(string.sub(m, 2, -2), ",")
30.143 - for i=1, table.getn(m) do
30.144 - m[i] = string.gsub(m[i],"%s*([%*&])", "%1")
30.145 - m[i] = findtype(m[i]) or m[i]
30.146 - m[i] = resolve_template_types(m[i])
30.147 - end
30.148 -
30.149 - local b,i
30.150 - type,b,i = break_template(type)
30.151 - local template_part = "<"..string.gsub(concat(m, 1, m.n), " ", ",")..">"
30.152 - type = rebuild_template(type, b, template_part)
30.153 - type = string.gsub(type, ">>", "> >")
30.154 - end
30.155 - return type
30.156 -end
30.157 -
30.158 -function break_template(s)
30.159 - local b,e,timpl = string.find(s, "(%b<>)")
30.160 - if timpl then
30.161 - s = string.gsub(s, "%b<>", "")
30.162 - return s, b, timpl
30.163 - else
30.164 - return s, 0, nil
30.165 - end
30.166 -end
30.167 -
30.168 -function rebuild_template(s, b, timpl)
30.169 -
30.170 - if b == 0 then
30.171 - return s
30.172 - end
30.173 -
30.174 - return string.sub(s, 1, b-1)..timpl..string.sub(s, b, -1)
30.175 -end
30.176 -
30.177 --- Print method
30.178 -function classDeclaration:print (ident,close)
30.179 - print(ident.."Declaration{")
30.180 - print(ident.." mod = '"..self.mod.."',")
30.181 - print(ident.." type = '"..self.type.."',")
30.182 - print(ident.." ptr = '"..self.ptr.."',")
30.183 - print(ident.." name = '"..self.name.."',")
30.184 - print(ident.." dim = '"..self.dim.."',")
30.185 - print(ident.." def = '"..self.def.."',")
30.186 - print(ident.." ret = '"..self.ret.."',")
30.187 - print(ident.."}"..close)
30.188 -end
30.189 -
30.190 --- check if array of values are returned to Lua
30.191 -function classDeclaration:requirecollection (t)
30.192 - if self.mod ~= 'const' and
30.193 - self.dim and self.dim ~= '' and
30.194 - not isbasic(self.type) and
30.195 - self.ptr == '' then
30.196 - local type = gsub(self.type,"%s*const%s+","")
30.197 - t[type] = "tolua_collect_" .. clean_template(type)
30.198 - return true
30.199 - end
30.200 - return false
30.201 -end
30.202 -
30.203 --- declare tag
30.204 -function classDeclaration:decltype ()
30.205 -
30.206 - self.type = typevar(self.type)
30.207 - if strfind(self.mod,'const') then
30.208 - self.type = 'const '..self.type
30.209 - self.mod = gsub(self.mod,'const%s*','')
30.210 - end
30.211 -end
30.212 -
30.213 -
30.214 --- output type checking
30.215 -function classDeclaration:outchecktype (narg)
30.216 - local def
30.217 - local t = isbasic(self.type)
30.218 - if self.def~='' then
30.219 - def = 1
30.220 - else
30.221 - def = 0
30.222 - end
30.223 - if self.dim ~= '' then
30.224 - if t=='string' then
30.225 - return 'tolua_isstring(tolua_S,'..narg..','..def..',&tolua_err)'
30.226 - else
30.227 - return 'tolua_istable(tolua_S,'..narg..',0,&tolua_err)'
30.228 - end
30.229 - elseif t then
30.230 - return 'tolua_is'..t..'(tolua_S,'..narg..','..def..',&tolua_err)'
30.231 - else
30.232 - return 'tolua_isusertype(tolua_S,'..narg..',"'..self.type..'",'..def..',&tolua_err)'
30.233 - end
30.234 -end
30.235 -
30.236 -function classDeclaration:builddeclaration (narg, cplusplus)
30.237 - local array = self.dim ~= '' and tonumber(self.dim)==nil
30.238 - local line = ""
30.239 - local ptr = ''
30.240 - local mod
30.241 - local type = self.type
30.242 - if self.dim ~= '' then
30.243 - type = gsub(self.type,'const%s+','') -- eliminates const modifier for arrays
30.244 - end
30.245 - if self.ptr~='' and not isbasic(type) then ptr = '*' end
30.246 - line = concatparam(line," ",self.mod,type,ptr)
30.247 - if array then
30.248 - line = concatparam(line,'*')
30.249 - end
30.250 - line = concatparam(line,self.name)
30.251 - if self.dim ~= '' then
30.252 - if tonumber(self.dim)~=nil then
30.253 - line = concatparam(line,'[',self.dim,'];')
30.254 - else
30.255 - if cplusplus then
30.256 - line = concatparam(line,' = new',type,ptr,'['..self.dim..'];')
30.257 - else
30.258 - line = concatparam(line,' = (',type,ptr,'*)',
30.259 - 'malloc((',self.dim,')*sizeof(',type,ptr,'));')
30.260 - end
30.261 - end
30.262 - else
30.263 - local t = isbasic(type)
30.264 - line = concatparam(line,' = ')
30.265 - if t == 'state' then
30.266 - line = concatparam(line, 'tolua_S;')
30.267 - else
30.268 - --print("t is "..tostring(t)..", ptr is "..tostring(self.ptr))
30.269 - if t == 'number' and string.find(self.ptr, "%*") then
30.270 - t = 'userdata'
30.271 - end
30.272 - if not t and ptr=='' then line = concatparam(line,'*') end
30.273 - line = concatparam(line,'((',self.mod,type)
30.274 - if not t then
30.275 - line = concatparam(line,'*')
30.276 - end
30.277 - line = concatparam(line,') ')
30.278 - if isenum(type) then
30.279 - line = concatparam(line,'(int) ')
30.280 - end
30.281 - local def = 0
30.282 - if self.def ~= '' then
30.283 - def = self.def
30.284 - if (ptr == '' or self.ptr == '&') and not t then
30.285 - def = "(void*)&(const "..type..")"..def
30.286 - end
30.287 - end
30.288 - if t then
30.289 - line = concatparam(line,'tolua_to'..t,'(tolua_S,',narg,',',def,'));')
30.290 - else
30.291 - line = concatparam(line,'tolua_tousertype(tolua_S,',narg,',',def,'));')
30.292 - end
30.293 - end
30.294 - end
30.295 - return line
30.296 -end
30.297 -
30.298 --- Declare variable
30.299 -function classDeclaration:declare (narg)
30.300 - if self.dim ~= '' and tonumber(self.dim)==nil then
30.301 - output('#ifdef __cplusplus\n')
30.302 - output(self:builddeclaration(narg,true))
30.303 - output('#else\n')
30.304 - output(self:builddeclaration(narg,false))
30.305 - output('#endif\n')
30.306 - else
30.307 - output(self:builddeclaration(narg,false))
30.308 - end
30.309 -end
30.310 -
30.311 --- Get parameter value
30.312 -function classDeclaration:getarray (narg)
30.313 - if self.dim ~= '' then
30.314 - local type = gsub(self.type,'const ','')
30.315 - output(' {')
30.316 - output('#ifndef TOLUA_RELEASE\n')
30.317 - local def; if self.def~='' then def=1 else def=0 end
30.318 - local t = isbasic(type)
30.319 - if (t) then
30.320 - output(' if (!tolua_is'..t..'array(tolua_S,',narg,',',self.dim,',',def,',&tolua_err))')
30.321 - else
30.322 - output(' if (!tolua_isusertypearray(tolua_S,',narg,',"',type,'",',self.dim,',',def,',&tolua_err))')
30.323 - end
30.324 - output(' goto tolua_lerror;')
30.325 - output(' else\n')
30.326 - output('#endif\n')
30.327 - output(' {')
30.328 - output(' int i;')
30.329 - output(' for(i=0; i<'..self.dim..';i++)')
30.330 - local t = isbasic(type)
30.331 - local ptr = ''
30.332 - if self.ptr~='' then ptr = '*' end
30.333 - output(' ',self.name..'[i] = ')
30.334 - if not t and ptr=='' then output('*') end
30.335 - output('((',type)
30.336 - if not t then
30.337 - output('*')
30.338 - end
30.339 - output(') ')
30.340 - local def = 0
30.341 - if self.def ~= '' then def = self.def end
30.342 - if t then
30.343 - output('tolua_tofield'..t..'(tolua_S,',narg,',i+1,',def,'));')
30.344 - else
30.345 - output('tolua_tofieldusertype(tolua_S,',narg,',i+1,',def,'));')
30.346 - end
30.347 - output(' }')
30.348 - output(' }')
30.349 - end
30.350 -end
30.351 -
30.352 --- Get parameter value
30.353 -function classDeclaration:setarray (narg)
30.354 - if not strfind(self.type,'const%s+') and self.dim ~= '' then
30.355 - local type = gsub(self.type,'const ','')
30.356 - output(' {')
30.357 - output(' int i;')
30.358 - output(' for(i=0; i<'..self.dim..';i++)')
30.359 - local t,ct = isbasic(type)
30.360 - if t then
30.361 - output(' tolua_pushfield'..t..'(tolua_S,',narg,',i+1,(',ct,')',self.name,'[i]);')
30.362 - else
30.363 - if self.ptr == '' then
30.364 - output(' {')
30.365 - output('#ifdef __cplusplus\n')
30.366 - output(' void* tolua_obj = new',type,'(',self.name,'[i]);')
30.367 - output(' tolua_pushfieldusertype_and_takeownership(tolua_S,',narg,',i+1,tolua_obj,,"',type,'");')
30.368 - output('#else\n')
30.369 - output(' void* tolua_obj = tolua_copy(tolua_S,(void*)&',self.name,'[i],sizeof(',type,'));')
30.370 - output(' tolua_pushfieldusertype(tolua_S,',narg,',i+1,tolua_obj,,"',type,'");')
30.371 - output('#endif\n')
30.372 - output(' }')
30.373 - else
30.374 - output(' tolua_pushfieldusertype(tolua_S,',narg,',i+1,(void*)',self.name,'[i],"',type,'");')
30.375 - end
30.376 - end
30.377 - output(' }')
30.378 - end
30.379 -end
30.380 -
30.381 --- Free dynamically allocated array
30.382 -function classDeclaration:freearray ()
30.383 - if self.dim ~= '' and tonumber(self.dim)==nil then
30.384 - output('#ifdef __cplusplus\n')
30.385 - output(' delete []',self.name,';')
30.386 - output('#else\n')
30.387 - output(' free(',self.name,');')
30.388 - output('#endif\n')
30.389 - end
30.390 -end
30.391 -
30.392 --- Pass parameter
30.393 -function classDeclaration:passpar ()
30.394 - if self.ptr=='&' and not isbasic(self.type) then
30.395 - output('*'..self.name)
30.396 - elseif self.ret=='*' then
30.397 - output('&'..self.name)
30.398 - else
30.399 - output(self.name)
30.400 - end
30.401 -end
30.402 -
30.403 --- Return parameter value
30.404 -function classDeclaration:retvalue ()
30.405 - if self.ret ~= '' then
30.406 - local t,ct = isbasic(self.type)
30.407 - if t then
30.408 - output(' tolua_push'..t..'(tolua_S,(',ct,')'..self.name..');')
30.409 - else
30.410 - output(' tolua_pushusertype(tolua_S,(void*)'..self.name..',"',self.type,'");')
30.411 - end
30.412 - return 1
30.413 - end
30.414 - return 0
30.415 -end
30.416 -
30.417 --- Internal constructor
30.418 -function _Declaration (t)
30.419 -
30.420 - setmetatable(t,classDeclaration)
30.421 - t:buildnames()
30.422 - t:checkname()
30.423 - t:checktype()
30.424 - local ft = findtype(t.type) or t.type
30.425 - if not isenum(ft) then
30.426 - t.mod, t.type = applytypedef(t.mod, ft)
30.427 - end
30.428 -
30.429 - if t.kind=="var" and (string.find(t.mod, "tolua_property%s") or string.find(t.mod, "tolua_property$")) then
30.430 - t.mod = string.gsub(t.mod, "tolua_property", "tolua_property__"..get_property_type())
30.431 - end
30.432 -
30.433 - return t
30.434 -end
30.435 -
30.436 --- Constructor
30.437 --- Expects the string declaration.
30.438 --- The kind of declaration can be "var" or "func".
30.439 -function Declaration (s,kind,is_parameter)
30.440 -
30.441 - -- eliminate spaces if default value is provided
30.442 - s = gsub(s,"%s*=%s*","=")
30.443 - s = gsub(s, "%s*<", "<")
30.444 -
30.445 - local defb,tmpdef
30.446 - defb,_,tmpdef = string.find(s, "(=.*)$")
30.447 - if defb then
30.448 - s = string.gsub(s, "=.*$", "")
30.449 - else
30.450 - tmpdef = ''
30.451 - end
30.452 - if kind == "var" then
30.453 - -- check the form: void
30.454 - if s == '' or s == 'void' then
30.455 - return _Declaration{type = 'void', kind = kind, is_parameter = is_parameter}
30.456 - end
30.457 - end
30.458 -
30.459 - -- check the form: mod type*& name
30.460 - local t = split_c_tokens(s,'%*%s*&')
30.461 - if t.n == 2 then
30.462 - if kind == 'func' then
30.463 - error("#invalid function return type: "..s)
30.464 - end
30.465 - --local m = split(t[1],'%s%s*')
30.466 - local m = split_c_tokens(t[1],'%s+')
30.467 - return _Declaration{
30.468 - name = t[2]..tmpdef,
30.469 - ptr = '*',
30.470 - ret = '&',
30.471 - --type = rebuild_template(m[m.n], tb, timpl),
30.472 - type = m[m.n],
30.473 - mod = concat(m,1,m.n-1),
30.474 - is_parameter = is_parameter,
30.475 - kind = kind
30.476 - }
30.477 - end
30.478 -
30.479 - -- check the form: mod type** name
30.480 - t = split_c_tokens(s,'%*%s*%*')
30.481 - if t.n == 2 then
30.482 - if kind == 'func' then
30.483 - error("#invalid function return type: "..s)
30.484 - end
30.485 - --local m = split(t[1],'%s%s*')
30.486 - local m = split_c_tokens(t[1],'%s+')
30.487 - return _Declaration{
30.488 - name = t[2]..tmpdef,
30.489 - ptr = '*',
30.490 - ret = '*',
30.491 - --type = rebuild_template(m[m.n], tb, timpl),
30.492 - type = m[m.n],
30.493 - mod = concat(m,1,m.n-1),
30.494 - is_parameter = is_parameter,
30.495 - kind = kind
30.496 - }
30.497 - end
30.498 -
30.499 - -- check the form: mod type& name
30.500 - t = split_c_tokens(s,'&')
30.501 - if t.n == 2 then
30.502 - --local m = split(t[1],'%s%s*')
30.503 - local m = split_c_tokens(t[1],'%s+')
30.504 - return _Declaration{
30.505 - name = t[2]..tmpdef,
30.506 - ptr = '&',
30.507 - --type = rebuild_template(m[m.n], tb, timpl),
30.508 - type = m[m.n],
30.509 - mod = concat(m,1,m.n-1),
30.510 - is_parameter = is_parameter,
30.511 - kind = kind
30.512 - }
30.513 - end
30.514 -
30.515 - -- check the form: mod type* name
30.516 - local s1 = gsub(s,"(%b\[\])",function (n) return gsub(n,'%*','\1') end)
30.517 - t = split_c_tokens(s1,'%*')
30.518 - if t.n == 2 then
30.519 - t[2] = gsub(t[2],'\1','%*') -- restore * in dimension expression
30.520 - --local m = split(t[1],'%s%s*')
30.521 - local m = split_c_tokens(t[1],'%s+')
30.522 - return _Declaration{
30.523 - name = t[2]..tmpdef,
30.524 - ptr = '*',
30.525 - type = m[m.n],
30.526 - --type = rebuild_template(m[m.n], tb, timpl),
30.527 - mod = concat(m,1,m.n-1) ,
30.528 - is_parameter = is_parameter,
30.529 - kind = kind
30.530 - }
30.531 - end
30.532 -
30.533 - if kind == 'var' then
30.534 - -- check the form: mod type name
30.535 - --t = split(s,'%s%s*')
30.536 - t = split_c_tokens(s,'%s+')
30.537 - local v
30.538 - if findtype(t[t.n]) then v = create_varname() else v = t[t.n]; t.n = t.n-1 end
30.539 - return _Declaration{
30.540 - name = v..tmpdef,
30.541 - --type = rebuild_template(t[t.n], tb, timpl),
30.542 - type = t[t.n],
30.543 - mod = concat(t,1,t.n-1),
30.544 - is_parameter = is_parameter,
30.545 - kind = kind
30.546 - }
30.547 -
30.548 - else -- kind == "func"
30.549 -
30.550 - -- check the form: mod type name
30.551 - --t = split(s,'%s%s*')
30.552 - t = split_c_tokens(s,'%s+')
30.553 - local v = t[t.n] -- last word is the function name
30.554 - local tp,md
30.555 - if t.n>1 then
30.556 - tp = t[t.n-1]
30.557 - md = concat(t,1,t.n-2)
30.558 - end
30.559 - --if tp then tp = rebuild_template(tp, tb, timpl) end
30.560 - return _Declaration{
30.561 - name = v,
30.562 - type = tp,
30.563 - mod = md,
30.564 - is_parameter = is_parameter,
30.565 - kind = kind
30.566 - }
30.567 - end
30.568 -
30.569 -end
30.570 -
31.1 --- a/source/tolua++/src/bin/lua/define.lua Wed Nov 04 01:07:17 2009 +0000
31.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
31.3 @@ -1,58 +0,0 @@
31.4 --- tolua: define class
31.5 --- Written by Waldemar Celes
31.6 --- TeCGraf/PUC-Rio
31.7 --- Jul 1998
31.8 --- $Id$
31.9 -
31.10 --- This code is free software; you can redistribute it and/or modify it.
31.11 --- The software provided hereunder is on an "as is" basis, and
31.12 --- the author has no obligation to provide maintenance, support, updates,
31.13 --- enhancements, or modifications.
31.14 -
31.15 -
31.16 --- Define class
31.17 --- Represents a numeric const definition
31.18 --- The following filds are stored:
31.19 --- name = constant name
31.20 -classDefine = {
31.21 - name = '',
31.22 -}
31.23 -classDefine.__index = classDefine
31.24 -setmetatable(classDefine,classFeature)
31.25 -
31.26 --- register define
31.27 -function classDefine:register ()
31.28 - output(' tolua_constant(tolua_S,"'..self.lname..'",'..self.name..');')
31.29 -end
31.30 -
31.31 --- Print method
31.32 -function classDefine:print (ident,close)
31.33 - print(ident.."Define{")
31.34 - print(ident.." name = '"..self.name.."',")
31.35 - print(ident.." lname = '"..self.lname.."',")
31.36 - print(ident.."}"..close)
31.37 -end
31.38 -
31.39 -
31.40 --- Internal constructor
31.41 -function _Define (t)
31.42 - setmetatable(t,classDefine)
31.43 - t:buildnames()
31.44 -
31.45 - if t.name == '' then
31.46 - error("#invalid define")
31.47 - end
31.48 -
31.49 - append(t)
31.50 - return t
31.51 -end
31.52 -
31.53 --- Constructor
31.54 --- Expects a string representing the constant name
31.55 -function Define (n)
31.56 - return _Define{
31.57 - name = n
31.58 - }
31.59 -end
31.60 -
31.61 -
32.1 --- a/source/tolua++/src/bin/lua/doit.lua Wed Nov 04 01:07:17 2009 +0000
32.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
32.3 @@ -1,76 +0,0 @@
32.4 --- Generate binding code
32.5 --- Written by Waldemar Celes
32.6 --- TeCGraf/PUC-Rio
32.7 --- Jul 1998
32.8 --- Last update: Apr 2003
32.9 --- $Id$
32.10 -
32.11 -
32.12 --- This code is free software; you can redistribute it and/or modify it.
32.13 --- The software provided hereunder is on an "as is" basis, and
32.14 --- the author has no obligation to provide maintenance, support, updates,
32.15 --- enhancements, or modifications.
32.16 -
32.17 -function doit ()
32.18 - if flags['L'] then
32.19 - dofile(flags['L'])
32.20 - end
32.21 - -- define package name, if not provided
32.22 - if not flags.n then
32.23 - if flags.f then
32.24 - flags.n = gsub(flags.f,"%..*","")
32.25 - else
32.26 - error("#no package name nor input file provided")
32.27 - end
32.28 - end
32.29 -
32.30 - -- add cppstring
32.31 - if not flags['S'] then
32.32 - _basic['string'] = 'cppstring'
32.33 - _basic['std::string'] = 'cppstring'
32.34 - _basic_ctype.cppstring = 'const char*'
32.35 - end
32.36 -
32.37 - -- proccess package
32.38 - local p = Package(flags.n,flags.f)
32.39 -
32.40 - if flags.p then
32.41 - return -- only parse
32.42 - end
32.43 -
32.44 - if flags.o then
32.45 - local st,msg = writeto(flags.o)
32.46 - if not st then
32.47 - error('#'..msg)
32.48 - end
32.49 - end
32.50 -
32.51 - p:decltype()
32.52 - if flags.P then
32.53 - p:print()
32.54 - else
32.55 - p:preamble()
32.56 - p:supcode()
32.57 - p:register()
32.58 - push(p)
32.59 - post_output_hook(p)
32.60 - pop()
32.61 - end
32.62 -
32.63 - if flags.o then
32.64 - writeto()
32.65 - end
32.66 -
32.67 - -- write header file
32.68 - if not flags.P then
32.69 - if flags.H then
32.70 - local st,msg = writeto(flags.H)
32.71 - if not st then
32.72 - error('#'..msg)
32.73 - end
32.74 - p:header()
32.75 - writeto()
32.76 - end
32.77 - end
32.78 -end
32.79 -
33.1 --- a/source/tolua++/src/bin/lua/enumerate.lua Wed Nov 04 01:07:17 2009 +0000
33.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
33.3 @@ -1,94 +0,0 @@
33.4 --- tolua: enumerate class
33.5 --- Written by Waldemar Celes
33.6 --- TeCGraf/PUC-Rio
33.7 --- Jul 1998
33.8 --- $Id$
33.9 -
33.10 --- This code is free software; you can redistribute it and/or modify it.
33.11 --- The software provided hereunder is on an "as is" basis, and
33.12 --- the author has no obligation to provide maintenance, support, updates,
33.13 --- enhancements, or modifications.
33.14 -
33.15 -
33.16 --- Enumerate class
33.17 --- Represents enumeration
33.18 --- The following fields are stored:
33.19 --- {i} = list of constant names
33.20 -classEnumerate = {
33.21 -}
33.22 -classEnumerate.__index = classEnumerate
33.23 -setmetatable(classEnumerate,classFeature)
33.24 -
33.25 --- register enumeration
33.26 -function classEnumerate:register ()
33.27 - local nspace = getnamespace(classContainer.curr)
33.28 - local i=1
33.29 - while self[i] do
33.30 - output(' tolua_constant(tolua_S,"'..self.lnames[i]..'",'..nspace..self[i]..');')
33.31 - i = i+1
33.32 - end
33.33 -end
33.34 -
33.35 --- Print method
33.36 -function classEnumerate:print (ident,close)
33.37 - print(ident.."Enumerate{")
33.38 - print(ident.." name = "..self.name)
33.39 - local i=1
33.40 - while self[i] do
33.41 - print(ident.." '"..self[i].."'("..self.lnames[i].."),")
33.42 - i = i+1
33.43 - end
33.44 - print(ident.."}"..close)
33.45 -end
33.46 -
33.47 --- Internal constructor
33.48 -function _Enumerate (t,varname)
33.49 - setmetatable(t,classEnumerate)
33.50 - append(t)
33.51 - appendenum(t)
33.52 - if varname and varname ~= "" then
33.53 - if t.name ~= "" then
33.54 - Variable(t.name.." "..varname)
33.55 - else
33.56 - local ns = getcurrnamespace()
33.57 - warning("Variable "..ns..varname.." of type <anonymous enum> is declared as read-only")
33.58 - Variable("tolua_readonly int "..varname)
33.59 - end
33.60 - end
33.61 -return t
33.62 -end
33.63 -
33.64 --- Constructor
33.65 --- Expects a string representing the enumerate body
33.66 -function Enumerate (n,b,varname)
33.67 - b = string.gsub(b, ",[%s\n]*}", "\n}") -- eliminate last ','
33.68 - local t = split(strsub(b,2,-2),',') -- eliminate braces
33.69 - local i = 1
33.70 - local e = {n=0}
33.71 - while t[i] do
33.72 - local tt = split(t[i],'=') -- discard initial value
33.73 - e.n = e.n + 1
33.74 - e[e.n] = tt[1]
33.75 - i = i+1
33.76 - end
33.77 - -- set lua names
33.78 - i = 1
33.79 - e.lnames = {}
33.80 - local ns = getcurrnamespace()
33.81 - while e[i] do
33.82 - local t = split(e[i],'@')
33.83 - e[i] = t[1]
33.84 - if not t[2] then
33.85 - t[2] = applyrenaming(t[1])
33.86 - end
33.87 - e.lnames[i] = t[2] or t[1]
33.88 - _global_enums[ ns..e[i] ] = (ns..e[i])
33.89 - i = i+1
33.90 - end
33.91 - e.name = n
33.92 - if n ~= "" then
33.93 - Typedef("int "..n)
33.94 - end
33.95 - return _Enumerate(e, varname)
33.96 -end
33.97 -
34.1 --- a/source/tolua++/src/bin/lua/feature.lua Wed Nov 04 01:07:17 2009 +0000
34.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
34.3 @@ -1,106 +0,0 @@
34.4 --- tolua: abstract feature class
34.5 --- Written by Waldemar Celes
34.6 --- TeCGraf/PUC-Rio
34.7 --- Jul 1998
34.8 --- $Id$
34.9 -
34.10 --- This code is free software; you can redistribute it and/or modify it.
34.11 --- The software provided hereunder is on an "as is" basis, and
34.12 --- the author has no obligation to provide maintenance, support, updates,
34.13 --- enhancements, or modifications.
34.14 -
34.15 -
34.16 --- Feature class
34.17 --- Represents the base class of all mapped feature.
34.18 -classFeature = {
34.19 -}
34.20 -classFeature.__index = classFeature
34.21 -
34.22 --- write support code
34.23 -function classFeature:supcode ()
34.24 -end
34.25 -
34.26 --- output tag
34.27 -function classFeature:decltype ()
34.28 -end
34.29 -
34.30 --- register feature
34.31 -function classFeature:register ()
34.32 -end
34.33 -
34.34 --- translate verbatim
34.35 -function classFeature:preamble ()
34.36 -end
34.37 -
34.38 --- check if it is a variable
34.39 -function classFeature:isvariable ()
34.40 - return false
34.41 -end
34.42 -
34.43 --- checi if it requires collection
34.44 -function classFeature:requirecollection (t)
34.45 - return false
34.46 -end
34.47 -
34.48 --- build names
34.49 -function classFeature:buildnames ()
34.50 - if self.name and self.name~='' then
34.51 - local n = split(self.name,'@')
34.52 - self.name = n[1]
34.53 - if not n[2] then
34.54 - n[2] = applyrenaming(n[1])
34.55 - end
34.56 - self.lname = n[2] or gsub(n[1],"%[.-%]","")
34.57 - self.original_name = self.name
34.58 - self.lname = clean_template(self.lname)
34.59 - end
34.60 - if not self.is_parameter then
34.61 - self.name = getonlynamespace() .. self.name
34.62 - end
34.63 -end
34.64 -
34.65 -function clean_template(t)
34.66 -
34.67 - return string.gsub(t, "[<>:, %*]", "_")
34.68 -end
34.69 -
34.70 --- check if feature is inside a container definition
34.71 --- it returns the container class name or nil.
34.72 -function classFeature:incontainer (which)
34.73 - if self.parent then
34.74 - local parent = self.parent
34.75 - while parent do
34.76 - if parent.classtype == which then
34.77 - return parent.name
34.78 - end
34.79 - parent = parent.parent
34.80 - end
34.81 - end
34.82 - return nil
34.83 -end
34.84 -
34.85 -function classFeature:inclass ()
34.86 - return self:incontainer('class')
34.87 -end
34.88 -
34.89 -function classFeature:inmodule ()
34.90 - return self:incontainer('module')
34.91 -end
34.92 -
34.93 -function classFeature:innamespace ()
34.94 - return self:incontainer('namespace')
34.95 -end
34.96 -
34.97 --- return C binding function name based on name
34.98 --- the client specifies a prefix
34.99 -function classFeature:cfuncname (n)
34.100 -
34.101 - if self.parent then
34.102 - n = self.parent:cfuncname(n)
34.103 - end
34.104 -
34.105 - n = string.gsub(n..'_'.. (self.lname or self.name), "[<>:, \.%*]", "_")
34.106 -
34.107 - return n
34.108 -end
34.109 -
35.1 --- a/source/tolua++/src/bin/lua/function.lua Wed Nov 04 01:07:17 2009 +0000
35.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
35.3 @@ -1,478 +0,0 @@
35.4 --- tolua: function class
35.5 --- Written by Waldemar Celes
35.6 --- TeCGraf/PUC-Rio
35.7 --- Jul 1998
35.8 --- $Id$
35.9 -
35.10 --- This code is free software; you can redistribute it and/or modify it.
35.11 --- The software provided hereunder is on an "as is" basis, and
35.12 --- the author has no obligation to provide maintenance, support, updates,
35.13 --- enhancements, or modifications.
35.14 -
35.15 -
35.16 -
35.17 --- Function class
35.18 --- Represents a function or a class method.
35.19 --- The following fields are stored:
35.20 --- mod = type modifiers
35.21 --- type = type
35.22 --- ptr = "*" or "&", if representing a pointer or a reference
35.23 --- name = name
35.24 --- lname = lua name
35.25 --- args = list of argument declarations
35.26 --- const = if it is a method receiving a const "this".
35.27 -classFunction = {
35.28 - mod = '',
35.29 - type = '',
35.30 - ptr = '',
35.31 - name = '',
35.32 - args = {n=0},
35.33 - const = '',
35.34 -}
35.35 -classFunction.__index = classFunction
35.36 -setmetatable(classFunction,classFeature)
35.37 -
35.38 --- declare tags
35.39 -function classFunction:decltype ()
35.40 - self.type = typevar(self.type)
35.41 - if strfind(self.mod,'const') then
35.42 - self.type = 'const '..self.type
35.43 - self.mod = gsub(self.mod,'const','')
35.44 - end
35.45 - local i=1
35.46 - while self.args[i] do
35.47 - self.args[i]:decltype()
35.48 - i = i+1
35.49 - end
35.50 -end
35.51 -
35.52 -
35.53 --- Write binding function
35.54 --- Outputs C/C++ binding function.
35.55 -function classFunction:supcode (local_constructor)
35.56 - local overload = strsub(self.cname,-2,-1) - 1 -- indicate overloaded func
35.57 - local nret = 0 -- number of returned values
35.58 - local class = self:inclass()
35.59 - local _,_,static = strfind(self.mod,'^%s*(static)')
35.60 - if class then
35.61 - if local_constructor then
35.62 - output("/* method: new_local of class ",class," */")
35.63 - else
35.64 - output("/* method:",self.name," of class ",class," */")
35.65 - end
35.66 - else
35.67 - output("/* function:",self.name," */")
35.68 - end
35.69 -
35.70 - if local_constructor then
35.71 - output("static int",self.cname.."_local","(lua_State* tolua_S)")
35.72 - else
35.73 - output("static int",self.cname,"(lua_State* tolua_S)")
35.74 - end
35.75 - output("{")
35.76 -
35.77 - -- check types
35.78 - if overload < 0 then
35.79 - output('#ifndef TOLUA_RELEASE\n')
35.80 - end
35.81 - output(' tolua_Error tolua_err;')
35.82 - output(' if (\n')
35.83 - -- check self
35.84 - local narg
35.85 - if class then narg=2 else narg=1 end
35.86 - if class then
35.87 - local func = 'tolua_isusertype'
35.88 - local type = self.parent.type
35.89 - if self.name=='new' or static~=nil then
35.90 - func = 'tolua_isusertable'
35.91 - type = self.parent.type
35.92 - end
35.93 - if self.const ~= '' then
35.94 - type = "const "..type
35.95 - end
35.96 - output(' !'..func..'(tolua_S,1,"'..type..'",0,&tolua_err) ||\n')
35.97 - end
35.98 - -- check args
35.99 - if self.args[1].type ~= 'void' then
35.100 - local i=1
35.101 - while self.args[i] do
35.102 - local btype = isbasic(self.args[i].type)
35.103 - if btype ~= 'value' and btype ~= 'state' then
35.104 - output(' !'..self.args[i]:outchecktype(narg)..' ||\n')
35.105 - end
35.106 - if btype ~= 'state' then
35.107 - narg = narg+1
35.108 - end
35.109 - i = i+1
35.110 - end
35.111 - end
35.112 - -- check end of list
35.113 - output(' !tolua_isnoobj(tolua_S,'..narg..',&tolua_err)\n )')
35.114 - output(' goto tolua_lerror;')
35.115 -
35.116 - output(' else\n')
35.117 - if overload < 0 then
35.118 - output('#endif\n')
35.119 - end
35.120 - output(' {')
35.121 -
35.122 - -- declare self, if the case
35.123 - local narg
35.124 - if class then narg=2 else narg=1 end
35.125 - if class and self.name~='new' and static==nil then
35.126 - output(' ',self.const,self.parent.type,'*','self = ')
35.127 - output('(',self.const,self.parent.type,'*) ')
35.128 - output('tolua_tousertype(tolua_S,1,0);')
35.129 - elseif static then
35.130 - _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)')
35.131 - end
35.132 - -- declare parameters
35.133 - if self.args[1].type ~= 'void' then
35.134 - local i=1
35.135 - while self.args[i] do
35.136 - self.args[i]:declare(narg)
35.137 - if isbasic(self.args[i].type) ~= "state" then
35.138 - narg = narg+1
35.139 - end
35.140 - i = i+1
35.141 - end
35.142 - end
35.143 -
35.144 - -- check self
35.145 - if class and self.name~='new' and static==nil then
35.146 - output('#ifndef TOLUA_RELEASE\n')
35.147 - output(' if (!self) tolua_error(tolua_S,"invalid \'self\' in function \''..self.name..'\'",NULL);');
35.148 - output('#endif\n')
35.149 - end
35.150 -
35.151 - -- get array element values
35.152 - if class then narg=2 else narg=1 end
35.153 - if self.args[1].type ~= 'void' then
35.154 - local i=1
35.155 - while self.args[i] do
35.156 - self.args[i]:getarray(narg)
35.157 - narg = narg+1
35.158 - i = i+1
35.159 - end
35.160 - end
35.161 -
35.162 - local out = string.find(self.mod, "tolua_outside")
35.163 - -- call function
35.164 - if class and self.name=='delete' then
35.165 - output(' delete self;')
35.166 - elseif class and self.name == 'operator&[]' then
35.167 - if flags['1'] then -- for compatibility with tolua5 ?
35.168 - output(' self->operator[](',self.args[1].name,'-1) = ',self.args[2].name,';')
35.169 - else
35.170 - output(' self->operator[](',self.args[1].name,') = ',self.args[2].name,';')
35.171 - end
35.172 - else
35.173 - output(' {')
35.174 - if self.type ~= '' and self.type ~= 'void' then
35.175 - output(' ',self.mod,self.type,self.ptr,'tolua_ret = ')
35.176 - output('(',self.mod,self.type,self.ptr,') ')
35.177 - else
35.178 - output(' ')
35.179 - end
35.180 - if class and self.name=='new' then
35.181 - output('new',self.type,'(')
35.182 - elseif class and static then
35.183 - if out then
35.184 - output(self.name,'(')
35.185 - else
35.186 - output(class..'::'..self.name,'(')
35.187 - end
35.188 - elseif class then
35.189 - if out then
35.190 - output(self.name,'(')
35.191 - else
35.192 - output('self->'..self.name,'(')
35.193 - end
35.194 - else
35.195 - output(self.name,'(')
35.196 - end
35.197 -
35.198 - if out and not static then
35.199 - output('self')
35.200 - if self.args[1] and self.args[1].name ~= '' then
35.201 - output(',')
35.202 - end
35.203 - end
35.204 - -- write parameters
35.205 - local i=1
35.206 - while self.args[i] do
35.207 - self.args[i]:passpar()
35.208 - i = i+1
35.209 - if self.args[i] then
35.210 - output(',')
35.211 - end
35.212 - end
35.213 -
35.214 - if class and self.name == 'operator[]' and flags['1'] then
35.215 - output('-1);')
35.216 - else
35.217 - output(');')
35.218 - end
35.219 -
35.220 - -- return values
35.221 - if self.type ~= '' and self.type ~= 'void' then
35.222 - nret = nret + 1
35.223 - local t,ct = isbasic(self.type)
35.224 - if t then
35.225 - output(' tolua_push'..t..'(tolua_S,(',ct,')tolua_ret);')
35.226 - else
35.227 - t = self.type
35.228 - new_t = string.gsub(t, "const%s+", "")
35.229 - if self.ptr == '' then
35.230 - output(' {')
35.231 - output('#ifdef __cplusplus\n')
35.232 - output(' void* tolua_obj = new',new_t,'(tolua_ret);')
35.233 - output(' tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"',t,'");')
35.234 - output('#else\n')
35.235 - output(' void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(',t,'));')
35.236 - output(' tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"',t,'");')
35.237 - output('#endif\n')
35.238 - output(' }')
35.239 - elseif self.ptr == '&' then
35.240 - output(' tolua_pushusertype(tolua_S,(void*)&tolua_ret,"',t,'");')
35.241 - else
35.242 - if local_constructor then
35.243 - output(' tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"',t,'");')
35.244 - else
35.245 - output(' tolua_pushusertype(tolua_S,(void*)tolua_ret,"',t,'");')
35.246 - end
35.247 - end
35.248 - end
35.249 - end
35.250 - local i=1
35.251 - while self.args[i] do
35.252 - nret = nret + self.args[i]:retvalue()
35.253 - i = i+1
35.254 - end
35.255 - output(' }')
35.256 -
35.257 - -- set array element values
35.258 - if class then narg=2 else narg=1 end
35.259 - if self.args[1].type ~= 'void' then
35.260 - local i=1
35.261 - while self.args[i] do
35.262 - self.args[i]:setarray(narg)
35.263 - narg = narg+1
35.264 - i = i+1
35.265 - end
35.266 - end
35.267 -
35.268 - -- free dynamically allocated array
35.269 - if self.args[1].type ~= 'void' then
35.270 - local i=1
35.271 - while self.args[i] do
35.272 - self.args[i]:freearray()
35.273 - i = i+1
35.274 - end
35.275 - end
35.276 - end
35.277 -
35.278 - output(' }')
35.279 - output(' return '..nret..';')
35.280 -
35.281 - -- call overloaded function or generate error
35.282 - if overload < 0 then
35.283 -
35.284 - output('#ifndef TOLUA_RELEASE\n')
35.285 - output('tolua_lerror:\n')
35.286 - output(' tolua_error(tolua_S,"#ferror in function \''..self.lname..'\'.",&tolua_err);')
35.287 - output(' return 0;')
35.288 - output('#endif\n')
35.289 - else
35.290 - local _local = ""
35.291 - if local_constructor then
35.292 - _local = "_local"
35.293 - end
35.294 - output('tolua_lerror:\n')
35.295 - output(' return '..strsub(self.cname,1,-3)..format("%02d",overload).._local..'(tolua_S);')
35.296 - end
35.297 - output('}')
35.298 - output('\n')
35.299 -
35.300 - -- recursive call to write local constructor
35.301 - if class and self.name=='new' and not local_constructor then
35.302 -
35.303 - self:supcode(1)
35.304 - end
35.305 -
35.306 -end
35.307 -
35.308 -
35.309 --- register function
35.310 -function classFunction:register ()
35.311 - output(' tolua_function(tolua_S,"'..self.lname..'",'..self.cname..');')
35.312 - if self.name == 'new' then
35.313 - output(' tolua_function(tolua_S,"new_local",'..self.cname..'_local);')
35.314 - output(' tolua_function(tolua_S,".call",'..self.cname..'_local);')
35.315 - --output(' tolua_set_call_event(tolua_S,'..self.cname..'_local, "'..self.parent.type..'");')
35.316 - end
35.317 -end
35.318 -
35.319 --- Print method
35.320 -function classFunction:print (ident,close)
35.321 - print(ident.."Function{")
35.322 - print(ident.." mod = '"..self.mod.."',")
35.323 - print(ident.." type = '"..self.type.."',")
35.324 - print(ident.." ptr = '"..self.ptr.."',")
35.325 - print(ident.." name = '"..self.name.."',")
35.326 - print(ident.." lname = '"..self.lname.."',")
35.327 - print(ident.." const = '"..self.const.."',")
35.328 - print(ident.." cname = '"..self.cname.."',")
35.329 - print(ident.." lname = '"..self.lname.."',")
35.330 - print(ident.." args = {")
35.331 - local i=1
35.332 - while self.args[i] do
35.333 - self.args[i]:print(ident.." ",",")
35.334 - i = i+1
35.335 - end
35.336 - print(ident.." }")
35.337 - print(ident.."}"..close)
35.338 -end
35.339 -
35.340 --- check if it returns an object by value
35.341 -function classFunction:requirecollection (t)
35.342 - local r = false
35.343 - if self.type ~= '' and not isbasic(self.type) and self.ptr=='' then
35.344 - local type = gsub(self.type,"%s*const%s+","")
35.345 - t[type] = "tolua_collect_" .. clean_template(type)
35.346 - r = true
35.347 - end
35.348 - local i=1
35.349 - while self.args[i] do
35.350 - r = self.args[i]:requirecollection(t) or r
35.351 - i = i+1
35.352 - end
35.353 - return r
35.354 -end
35.355 -
35.356 --- determine lua function name overload
35.357 -function classFunction:overload ()
35.358 - return self.parent:overload(self.lname)
35.359 -end
35.360 -
35.361 -
35.362 -
35.363 --- Internal constructor
35.364 -function _Function (t)
35.365 - setmetatable(t,classFunction)
35.366 -
35.367 - if t.const ~= 'const' and t.const ~= '' then
35.368 - error("#invalid 'const' specification")
35.369 - end
35.370 -
35.371 - append(t)
35.372 - if t:inclass() then
35.373 - --print ('t.name is '..t.name..', parent.name is '..t.parent.name)
35.374 - if string.gsub(t.name, "%b<>", "") == string.gsub(t.parent.original_name or t.parent.name, "%b<>", "") then
35.375 - t.name = 'new'
35.376 - t.lname = 'new'
35.377 - t.parent._new = true
35.378 - t.type = t.parent.name
35.379 - t.ptr = '*'
35.380 - elseif string.gsub(t.name, "%b<>", "") == '~'..string.gsub(t.parent.original_name or t.parent.name, "%b<>", "") then
35.381 - t.name = 'delete'
35.382 - t.lname = 'delete'
35.383 - t.parent._delete = true
35.384 - end
35.385 - end
35.386 - t.cname = t:cfuncname("tolua")..t:overload(t)
35.387 - return t
35.388 -end
35.389 -
35.390 --- Constructor
35.391 --- Expects three strings: one representing the function declaration,
35.392 --- another representing the argument list, and the third representing
35.393 --- the "const" or empty string.
35.394 -function Function (d,a,c)
35.395 - --local t = split(strsub(a,2,-2),',') -- eliminate braces
35.396 - --local t = split_params(strsub(a,2,-2))
35.397 -
35.398 - if not flags['W'] and string.find(a, "%.%.%.%s*%)") then
35.399 -
35.400 - warning("Functions with variable arguments (`...') are not supported. Ignoring "..d..a..c)
35.401 - return nil
35.402 - end
35.403 -
35.404 -
35.405 - local i=1
35.406 - local l = {n=0}
35.407 -
35.408 - a = string.gsub(a, "%s*([%(%)])%s*", "%1")
35.409 - local t,strip,last = strip_pars(strsub(a,2,-2));
35.410 - if strip then
35.411 - local ns = string.sub(strsub(a,1,-2), 1, -(string.len(last)+1))
35.412 - ns = string.gsub(ns, "%s*,%s*$", "")..')'
35.413 - Function(d, ns, c)
35.414 - end
35.415 -
35.416 - while t[i] do
35.417 - l.n = l.n+1
35.418 - l[l.n] = Declaration(t[i],'var',true)
35.419 - i = i+1
35.420 - end
35.421 - local f = Declaration(d,'func')
35.422 - f.args = l
35.423 - f.const = c
35.424 - return _Function(f)
35.425 -end
35.426 -
35.427 -function strip_pars(s)
35.428 -
35.429 - local t = split_c_tokens(s, ',')
35.430 - local strip = false
35.431 - local last
35.432 -
35.433 - for i=1,t.n do
35.434 -
35.435 - if not strip and param_object(t[i]) then
35.436 - strip = true
35.437 - end
35.438 - if strip then
35.439 - last = t[i]
35.440 - t[i] = string.gsub(t[i], "=.*$", "")
35.441 - end
35.442 - end
35.443 -
35.444 - return t,strip,last
35.445 -
35.446 -end
35.447 -
35.448 -function param_object(par) -- returns true if the parameter has an object as its default value
35.449 -
35.450 - if not string.find(par, '=') then return false end -- it has no default value
35.451 -
35.452 - if string.find(par, "|") then -- a list of flags
35.453 -
35.454 - return true
35.455 - end
35.456 -
35.457 - if string.find(par, "%*") then -- it's a pointer with a default value
35.458 -
35.459 - if string.find(par, '=%s*new') then -- it's a pointer with an instance as default parameter.. is that valid?
35.460 - return true
35.461 - end
35.462 - return false -- default value is 'NULL' or something
35.463 - end
35.464 -
35.465 -
35.466 - if string.find(par, "[%(&]") then
35.467 - return true
35.468 -
35.469 - end -- it's a reference, or default value is a constructor call (most likely both if it's a reference)
35.470 -
35.471 - return false -- ?
35.472 -end
35.473 -
35.474 -function strip_last_arg(all_args, last_arg) -- strips the default value from the last argument
35.475 -
35.476 - local _,_,s_arg = string.find(last_arg, "^([^=]+)")
35.477 - last_arg = string.gsub(last_arg, "([%%%(%)])", "%%%1");
35.478 - all_args = string.gsub(all_args, "%s*,%s*"..last_arg.."%s*%)%s*$", ")")
35.479 - return all_args, s_arg
35.480 -end
35.481 -
36.1 --- a/source/tolua++/src/bin/lua/module.lua Wed Nov 04 01:07:17 2009 +0000
36.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
36.3 @@ -1,67 +0,0 @@
36.4 --- tolua: module class
36.5 --- Written by Waldemar Celes
36.6 --- TeCGraf/PUC-Rio
36.7 --- Jul 1998
36.8 --- $Id$
36.9 -
36.10 --- This code is free software; you can redistribute it and/or modify it.
36.11 --- The software provided hereunder is on an "as is" basis, and
36.12 --- the author has no obligation to provide maintenance, support, updates,
36.13 --- enhancements, or modifications.
36.14 -
36.15 -
36.16 -
36.17 --- Module class
36.18 --- Represents module.
36.19 --- The following fields are stored:
36.20 --- {i} = list of objects in the module.
36.21 -classModule = {
36.22 - classtype = 'module'
36.23 -}
36.24 -classModule.__index = classModule
36.25 -setmetatable(classModule,classContainer)
36.26 -
36.27 --- register module
36.28 -function classModule:register ()
36.29 - push(self)
36.30 - output(' tolua_module(tolua_S,"'..self.name..'",',self:hasvar(),');')
36.31 - output(' tolua_beginmodule(tolua_S,"'..self.name..'");')
36.32 - local i=1
36.33 - while self[i] do
36.34 - self[i]:register()
36.35 - i = i+1
36.36 - end
36.37 - output(' tolua_endmodule(tolua_S);')
36.38 - pop()
36.39 -end
36.40 -
36.41 --- Print method
36.42 -function classModule:print (ident,close)
36.43 - print(ident.."Module{")
36.44 - print(ident.." name = '"..self.name.."';")
36.45 - local i=1
36.46 - while self[i] do
36.47 - self[i]:print(ident.." ",",")
36.48 - i = i+1
36.49 - end
36.50 - print(ident.."}"..close)
36.51 -end
36.52 -
36.53 --- Internal constructor
36.54 -function _Module (t)
36.55 - setmetatable(t,classModule)
36.56 - append(t)
36.57 - return t
36.58 -end
36.59 -
36.60 --- Constructor
36.61 --- Expects two string representing the module name and body.
36.62 -function Module (n,b)
36.63 - local t = _Module(_Container{name=n})
36.64 - push(t)
36.65 - t:parse(strsub(b,2,strlen(b)-1)) -- eliminate braces
36.66 - pop()
36.67 - return t
36.68 -end
36.69 -
36.70 -
37.1 --- a/source/tolua++/src/bin/lua/namespace.lua Wed Nov 04 01:07:17 2009 +0000
37.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
37.3 @@ -1,52 +0,0 @@
37.4 --- tolua: namespace class
37.5 --- Written by Waldemar Celes
37.6 --- TeCGraf/PUC-Rio
37.7 --- Jul 2003
37.8 --- $Id$
37.9 -
37.10 --- This code is free software; you can redistribute it and/or modify it.
37.11 --- The software provided hereunder is on an "as is" basis, and
37.12 --- the author has no obligation to provide maintenance, support, updates,
37.13 --- enhancements, or modifications.
37.14 -
37.15 -
37.16 --- Namespace class
37.17 --- Represents a namesapce definition.
37.18 --- Stores the following fields:
37.19 --- name = class name
37.20 --- {i} = list of members
37.21 -classNamespace = {
37.22 - classtype = 'namespace',
37.23 - name = '',
37.24 -}
37.25 -classNamespace.__index = classNamespace
37.26 -setmetatable(classNamespace,classModule)
37.27 -
37.28 --- Print method
37.29 -function classNamespace:print (ident,close)
37.30 - print(ident.."Namespace{")
37.31 - print(ident.." name = '"..self.name.."',")
37.32 - local i=1
37.33 - while self[i] do
37.34 - self[i]:print(ident.." ",",")
37.35 - i = i+1
37.36 - end
37.37 - print(ident.."}"..close)
37.38 -end
37.39 -
37.40 --- Internal constructor
37.41 -function _Namespace (t)
37.42 - setmetatable(t,classNamespace)
37.43 - append(t)
37.44 - return t
37.45 -end
37.46 -
37.47 --- Constructor
37.48 --- Expects the name and the body of the namespace.
37.49 -function Namespace (n,b)
37.50 - local c = _Namespace(_Container{name=n})
37.51 - push(c)
37.52 - c:parse(strsub(b,2,strlen(b)-1)) -- eliminate braces
37.53 - pop()
37.54 -end
37.55 -
38.1 --- a/source/tolua++/src/bin/lua/operator.lua Wed Nov 04 01:07:17 2009 +0000
38.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
38.3 @@ -1,122 +0,0 @@
38.4 --- tolua: operator class
38.5 --- Written by Waldemar Celes
38.6 --- TeCGraf/PUC-Rio
38.7 --- Jul 1998
38.8 --- $Id$
38.9 -
38.10 --- This code is free software; you can redistribute it and/or modify it.
38.11 --- The software provided hereunder is on an "as is" basis, and
38.12 --- the author has no obligation to provide maintenance, support, updates,
38.13 --- enhancements, or modifications.
38.14 -
38.15 -
38.16 --- Operator class
38.17 --- Represents an operator function or a class operator method.
38.18 --- It stores the same fields as functions do plus:
38.19 --- kind = set of character representing the operator (as it appers in C++ code)
38.20 -classOperator = {
38.21 - kind = '',
38.22 -}
38.23 -classOperator.__index = classOperator
38.24 -setmetatable(classOperator,classFunction)
38.25 -
38.26 --- table to transform operator kind into the appropriate tag method name
38.27 -_TM = {['+'] = 'add',
38.28 - ['-'] = 'sub',
38.29 - ['*'] = 'mul',
38.30 - ['/'] = 'div',
38.31 - ['<'] = 'lt',
38.32 - ['<='] = 'le',
38.33 - ['=='] = 'eq',
38.34 - ['[]'] = 'geti',
38.35 - ['&[]'] = 'seti',
38.36 - --['->'] = 'flechita',
38.37 - }
38.38 -
38.39 -
38.40 --- Print method
38.41 -function classOperator:print (ident,close)
38.42 - print(ident.."Operator{")
38.43 - print(ident.." kind = '"..self.kind.."',")
38.44 - print(ident.." mod = '"..self.mod.."',")
38.45 - print(ident.." type = '"..self.type.."',")
38.46 - print(ident.." ptr = '"..self.ptr.."',")
38.47 - print(ident.." name = '"..self.name.."',")
38.48 - print(ident.." const = '"..self.const.."',")
38.49 - print(ident.." cname = '"..self.cname.."',")
38.50 - print(ident.." lname = '"..self.lname.."',")
38.51 - print(ident.." args = {")
38.52 - local i=1
38.53 - while self.args[i] do
38.54 - self.args[i]:print(ident.." ",",")
38.55 - i = i+1
38.56 - end
38.57 - print(ident.." }")
38.58 - print(ident.."}"..close)
38.59 -end
38.60 -
38.61 --- Internal constructor
38.62 -function _Operator (t)
38.63 - setmetatable(t,classOperator)
38.64 -
38.65 - if t.const ~= 'const' and t.const ~= '' then
38.66 - error("#invalid 'const' specification")
38.67 - end
38.68 -
38.69 - append(t)
38.70 - if not t:inclass() then
38.71 - error("#operator can only be defined as class member")
38.72 - end
38.73 -
38.74 - t.name = t.name .. "_" .. _TM[t.kind]
38.75 - t.cname = t:cfuncname("tolua")..t:overload(t)
38.76 - t.name = "operator" .. t.kind -- set appropriate calling name
38.77 - return t
38.78 -end
38.79 -
38.80 --- Constructor
38.81 -function Operator (d,k,a,c)
38.82 -
38.83 - local op_k = string.gsub(k, "%s", "")
38.84 - if not flags['W'] and not _TM[op_k] then
38.85 -
38.86 - warning("No support for operator "..op_k..", ignoring")
38.87 - return nil
38.88 - end
38.89 -
38.90 - local ref = ''
38.91 - local t = split_c_tokens(strsub(a,2,strlen(a)-1),',') -- eliminate braces
38.92 - local i=1
38.93 - local l = {n=0}
38.94 - while t[i] do
38.95 - l.n = l.n+1
38.96 - l[l.n] = Declaration(t[i],'var')
38.97 - i = i+1
38.98 - end
38.99 - if k == '[]' then
38.100 - local _
38.101 - _, _, ref = strfind(d,'(&)')
38.102 - d = gsub(d,'&','')
38.103 - elseif k=='&[]' then
38.104 - l.n = l.n+1
38.105 - l[l.n] = Declaration(d,'var')
38.106 - l[l.n].name = 'tolua_value'
38.107 - end
38.108 - local f = Declaration(d,'func')
38.109 - if k == '[]' and (l[1]==nil or isbasic(l[1].type)~='number') then
38.110 - error('operator[] can only be defined for numeric index.')
38.111 - end
38.112 - f.args = l
38.113 - f.const = c
38.114 - f.kind = gsub(k,"%s","")
38.115 - if not _TM[f.kind] then
38.116 - error("tolua: no support for operator" .. f.kind)
38.117 - end
38.118 - f.lname = ".".._TM[f.kind]
38.119 - if f.kind == '[]' and ref=='&' and f.const~='const' then
38.120 - Operator(d,'&'..k,a,c) -- create correspoding set operator
38.121 - end
38.122 - return _Operator(f)
38.123 -end
38.124 -
38.125 -
39.1 --- a/source/tolua++/src/bin/lua/package.lua Wed Nov 04 01:07:17 2009 +0000
39.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
39.3 @@ -1,277 +0,0 @@
39.4 --- tolua: package class
39.5 --- Written by Waldemar Celes
39.6 --- TeCGraf/PUC-Rio
39.7 --- Jul 1998
39.8 --- $Id$
39.9 -
39.10 --- This code is free software; you can redistribute it and/or modify it.
39.11 --- The software provided hereunder is on an "as is" basis, and
39.12 --- the author has no obligation to provide maintenance, support, updates,
39.13 --- enhancements, or modifications.
39.14 -
39.15 -
39.16 -
39.17 --- Package class
39.18 --- Represents the whole package being bound.
39.19 --- The following fields are stored:
39.20 --- {i} = list of objects in the package.
39.21 -classPackage = {
39.22 - classtype = 'package'
39.23 -}
39.24 -classPackage.__index = classPackage
39.25 -setmetatable(classPackage,classContainer)
39.26 -
39.27 --- Print method
39.28 -function classPackage:print ()
39.29 - print("Package: "..self.name)
39.30 - local i=1
39.31 - while self[i] do
39.32 - self[i]:print("","")
39.33 - i = i+1
39.34 - end
39.35 -end
39.36 -
39.37 -function classPackage:preprocess ()
39.38 -
39.39 - --self.code = gsub(self.code,"\n%s*#[^d][^\n]*\n", "\n\n") -- eliminate preprocessor directives that don't start with 'd'
39.40 - self.code = gsub(self.code,"\n%s*#[^d]", "\n//") -- eliminate preprocessor directives that don't start with 'd'
39.41 -
39.42 - -- avoid preprocessing embedded Lua code
39.43 - local L = {}
39.44 - self.code = gsub(self.code,"\n%s*%$%[","\1") -- deal with embedded C code
39.45 - self.code = gsub(self.code,"\n%s*%$%]","\2")
39.46 - self.code = gsub(self.code,"(%b\1\2)", function (c)
39.47 - tinsert(L,c)
39.48 - return "\n#["..getn(L).."]#"
39.49 - end)
39.50 - -- avoid preprocessing embedded C code
39.51 - local C = {}
39.52 - self.code = gsub(self.code,"\n%s*%$%<","\3") -- deal with embedded C code
39.53 - self.code = gsub(self.code,"\n%s*%$%>","\4")
39.54 - self.code = gsub(self.code,"(%b\3\4)", function (c)
39.55 - tinsert(C,c)
39.56 - return "\n#<"..getn(C)..">#"
39.57 - end)
39.58 -
39.59 - -- avoid preprocessing verbatim lines
39.60 - local V = {}
39.61 - self.code = gsub(self.code,"\n(%s*%$[^%[%]][^\n]*)",function (v)
39.62 - tinsert(V,v)
39.63 - return "\n#"..getn(V).."#"
39.64 - end)
39.65 - -- perform global substitution
39.66 -
39.67 - self.code = gsub(self.code,"(//[^\n]*)","") -- eliminate C++ comments
39.68 - self.code = gsub(self.code,"/%*","\1")
39.69 - self.code = gsub(self.code,"%*/","\2")
39.70 - self.code = gsub(self.code,"%b\1\2","")
39.71 - self.code = gsub(self.code,"\1","/%*")
39.72 - self.code = gsub(self.code,"\2","%*/")
39.73 - self.code = gsub(self.code,"%s*@%s*","@") -- eliminate spaces beside @
39.74 - self.code = gsub(self.code,"%s?inline(%s)","%1") -- eliminate 'inline' keyword
39.75 - self.code = gsub(self.code,"%s?extern(%s)","%1") -- eliminate 'extern' keyword
39.76 - self.code = gsub(self.code,"%s?virtual(%s)","%1") -- eliminate 'virtual' keyword
39.77 - self.code = gsub(self.code,"public:","") -- eliminate 'public:' keyword
39.78 - self.code = gsub(self.code,"([^%w_])void%s*%*","%1_userdata ") -- substitute 'void*'
39.79 - self.code = gsub(self.code,"([^%w_])void%s*%*","%1_userdata ") -- substitute 'void*'
39.80 - self.code = gsub(self.code,"([^%w_])char%s*%*","%1_cstring ") -- substitute 'char*'
39.81 - self.code = gsub(self.code,"([^%w_])lua_State%s*%*","%1_lstate ") -- substitute 'lua_State*'
39.82 -
39.83 - -- restore embedded code
39.84 - self.code = gsub(self.code,"%#%[(%d+)%]%#",function (n)
39.85 - return L[tonumber(n)]
39.86 - end)
39.87 - -- restore embedded code
39.88 - self.code = gsub(self.code,"%#%<(%d+)%>%#",function (n)
39.89 - return C[tonumber(n)]
39.90 - end)
39.91 - -- restore verbatim lines
39.92 - self.code = gsub(self.code,"%#(%d+)%#",function (n)
39.93 - return V[tonumber(n)]
39.94 - end)
39.95 -
39.96 - self.code = string.gsub(self.code, "\n%s*%$([^\n]+)", function (l)
39.97 - Verbatim(l.."\n")
39.98 - return "\n"
39.99 - end)
39.100 -end
39.101 -
39.102 --- translate verbatim
39.103 -function classPackage:preamble ()
39.104 - output('/*\n')
39.105 - output('** Lua binding: '..self.name..'\n')
39.106 - output('** Generated automatically by '..TOLUA_VERSION..' on '..date()..'.\n')
39.107 - output('*/\n\n')
39.108 -
39.109 - output('#ifndef __cplusplus\n')
39.110 - output('#include "stdlib.h"\n')
39.111 - output('#endif\n')
39.112 - output('#include "string.h"\n\n')
39.113 - output('#include "tolua++.h"\n\n')
39.114 -
39.115 - if not flags.h then
39.116 - output('/* Exported function */')
39.117 - output('TOLUA_API int tolua_'..self.name..'_open (lua_State* tolua_S);')
39.118 - output('\n')
39.119 - end
39.120 -
39.121 - local i=1
39.122 - while self[i] do
39.123 - self[i]:preamble()
39.124 - i = i+1
39.125 - end
39.126 -
39.127 - if self:requirecollection(_collect) then
39.128 - output('\n')
39.129 - output('/* function to release collected object via destructor */')
39.130 - output('#ifdef __cplusplus\n')
39.131 - for i,v in pairs(_collect) do
39.132 - output('\nstatic int '..v..' (lua_State* tolua_S)')
39.133 - output('{')
39.134 - output(' '..i..'* self = ('..i..'*) tolua_tousertype(tolua_S,1,0);')
39.135 - output(' delete self;')
39.136 - output(' return 0;')
39.137 - output('}')
39.138 - end
39.139 - output('#endif\n\n')
39.140 - end
39.141 -
39.142 - output('\n')
39.143 - output('/* function to register type */')
39.144 - output('static void tolua_reg_types (lua_State* tolua_S)')
39.145 - output('{')
39.146 - foreach(_usertype,function(n,v) output(' tolua_usertype(tolua_S,"',v,'");') end)
39.147 - output('}')
39.148 - output('\n')
39.149 -end
39.150 -
39.151 --- register package
39.152 --- write package open function
39.153 -function classPackage:register ()
39.154 - push(self)
39.155 - output("/* Open function */")
39.156 - output("TOLUA_API int tolua_"..self.name.."_open (lua_State* tolua_S)")
39.157 - output("{")
39.158 - output(" tolua_open(tolua_S);")
39.159 - output(" tolua_reg_types(tolua_S);")
39.160 - output(" tolua_module(tolua_S,NULL,",self:hasvar(),");")
39.161 - output(" tolua_beginmodule(tolua_S,NULL);")
39.162 - local i=1
39.163 - while self[i] do
39.164 - self[i]:register()
39.165 - i = i+1
39.166 - end
39.167 - output(" tolua_endmodule(tolua_S);")
39.168 - output(" return 1;")
39.169 - output("}")
39.170 - pop()
39.171 -end
39.172 -
39.173 --- write header file
39.174 -function classPackage:header ()
39.175 - output('/*\n') output('** Lua binding: '..self.name..'\n')
39.176 - output('** Generated automatically by '..TOLUA_VERSION..' on '..date()..'.\n')
39.177 - output('*/\n\n')
39.178 -
39.179 - if not flags.h then
39.180 - output('/* Exported function */')
39.181 - output('TOLUA_API int tolua_'..self.name..'_open (lua_State* tolua_S);')
39.182 - output('\n')
39.183 - end
39.184 -end
39.185 -
39.186 --- Internal constructor
39.187 -function _Package (self)
39.188 - setmetatable(self,classPackage)
39.189 - return self
39.190 -end
39.191 -
39.192 --- Parse C header file with tolua directives
39.193 --- *** Thanks to Ariel Manzur for fixing bugs in nested directives ***
39.194 -function extract_code(fn,s)
39.195 - local code = '\n$#include "'..fn..'"\n'
39.196 - s= "\n" .. s .. "\n" -- add blank lines as sentinels
39.197 - local _,e,c,t = strfind(s, "\n([^\n]-)[Tt][Oo][Ll][Uu][Aa]_([^%s]*)[^\n]*\n")
39.198 - while e do
39.199 - t = strlower(t)
39.200 - if t == "begin" then
39.201 - _,e,c = strfind(s,"(.-)\n[^\n]*[Tt][Oo][Ll][Uu][Aa]_[Ee][Nn][Dd][^\n]*\n",e)
39.202 - if not e then
39.203 - tolua_error("Unbalanced 'tolua_begin' directive in header file")
39.204 - end
39.205 - end
39.206 - code = code .. c .. "\n"
39.207 - _,e,c,t = strfind(s, "\n([^\n]-)[Tt][Oo][Ll][Uu][Aa]_([^%s]*)[^\n]*\n",e)
39.208 - end
39.209 - return code
39.210 -end
39.211 -
39.212 --- Constructor
39.213 --- Expects the package name, the file extension, and the file text.
39.214 -function Package (name,fn)
39.215 - local ext = "pkg"
39.216 -
39.217 - -- open input file, if any
39.218 - if fn then
39.219 - local st, msg = readfrom(flags.f)
39.220 - if not st then
39.221 - error('#'..msg)
39.222 - end
39.223 - local _; _, _, ext = strfind(fn,".*%.(.*)$")
39.224 - end
39.225 - local code = "\n" .. read('*a')
39.226 - if ext == 'h' or ext == 'hpp' then
39.227 - code = extract_code(fn,code)
39.228 - end
39.229 -
39.230 - -- close file
39.231 - if fn then
39.232 - readfrom()
39.233 - end
39.234 -
39.235 - -- deal with include directive
39.236 - local nsubst
39.237 - repeat
39.238 - code,nsubst = gsub(code,'\n%s*%$(.)file%s*"(.-)"([^\n]*)\n',
39.239 - function (kind,fn,extra)
39.240 - local _, _, ext = strfind(fn,".*%.(.*)$")
39.241 - local fp,msg = openfile(fn,'r')
39.242 - if not fp then
39.243 - error('#'..msg..': '..fn)
39.244 - end
39.245 - local s = read(fp,'*a')
39.246 - closefile(fp)
39.247 - if kind == 'c' or kind == 'h' then
39.248 - return extract_code(fn,s)
39.249 - elseif kind == 'p' then
39.250 - return "\n\n" .. s
39.251 - elseif kind == 'l' then
39.252 - return "\n$[\n" .. s .. "\n$]\n"
39.253 - elseif kind == 'i' then
39.254 - local t = {code=s}
39.255 - extra = string.gsub(extra, "^%s*,%s*", "")
39.256 - local pars = split_c_tokens(extra, ",")
39.257 - include_file_hook(t, fn, unpack(pars))
39.258 - return "\n\n" .. t.code
39.259 - else
39.260 - error('#Invalid include directive (use $cfile, $pfile, $lfile or $ifile)')
39.261 - end
39.262 - end)
39.263 - until nsubst==0
39.264 -
39.265 - -- deal with renaming directive
39.266 - repeat -- I don't know why this is necesary
39.267 - code,nsubst = gsub(code,'\n%s*%$renaming%s*(.-)%s*\n', function (r) appendrenaming(r) return "\n" end)
39.268 - until nsubst == 0
39.269 -
39.270 - local t = _Package(_Container{name=name, code=code})
39.271 - push(t)
39.272 - preprocess_hook(t)
39.273 - t:preprocess()
39.274 - preparse_hook(t)
39.275 - t:parse(t.code)
39.276 - pop()
39.277 - return t
39.278 -end
39.279 -
39.280 -
40.1 --- a/source/tolua++/src/bin/lua/typedef.lua Wed Nov 04 01:07:17 2009 +0000
40.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
40.3 @@ -1,70 +0,0 @@
40.4 --- tolua: typedef class
40.5 --- Written by Waldemar Celes
40.6 --- TeCGraf/PUC-Rio
40.7 --- Jul 1998
40.8 --- $Id$
40.9 -
40.10 --- This code is free software; you can redistribute it and/or modify it.
40.11 --- The software provided hereunder is on an "as is" basis, and
40.12 --- the author has no obligation to provide maintenance, support, updates,
40.13 --- enhancements, or modifications.
40.14 -
40.15 -
40.16 -
40.17 --- Typedef class
40.18 --- Represents a type synonym.
40.19 --- The 'de facto' type replaces the typedef before the
40.20 --- remaining code is parsed.
40.21 --- The following fields are stored:
40.22 --- utype = typedef name
40.23 --- type = 'the facto' type
40.24 --- mod = modifiers to the 'de facto' type
40.25 -classTypedef = {
40.26 - utype = '',
40.27 - mod = '',
40.28 - type = ''
40.29 -}
40.30 -classTypedef.__index = classTypedef
40.31 -
40.32 --- Print method
40.33 -function classTypedef:print (ident,close)
40.34 - print(ident.."Typedef{")
40.35 - print(ident.." utype = '"..self.utype.."',")
40.36 - print(ident.." mod = '"..self.mod.."',")
40.37 - print(ident.." type = '"..self.type.."',")
40.38 - print(ident.."}"..close)
40.39 -end
40.40 -
40.41 --- Return it's not a variable
40.42 -function classTypedef:isvariable ()
40.43 - return false
40.44 -end
40.45 -
40.46 --- Internal constructor
40.47 -function _Typedef (t)
40.48 - setmetatable(t,classTypedef)
40.49 - appendtypedef(t)
40.50 - return t
40.51 -end
40.52 -
40.53 --- Constructor
40.54 --- Expects one string representing the type definition.
40.55 -function Typedef (s)
40.56 - if strfind(string.gsub(s, '%b<>', ''),'[%*&]') then
40.57 - tolua_error("#invalid typedef: pointers (and references) are not supported")
40.58 - end
40.59 - local o = {mod = ''}
40.60 - if string.find(s, "[<>]") then
40.61 - _,_,o.type,o.utype = string.find(s, "^%s*([^<>]+%b<>[^%s]*)%s+(.-)$")
40.62 - else
40.63 - local t = split(gsub(s,"%s%s*"," ")," ")
40.64 - o = {
40.65 - utype = t[t.n],
40.66 - type = t[t.n-1],
40.67 - mod = concat(t,1,t.n-2),
40.68 - }
40.69 - end
40.70 - return _Typedef(o)
40.71 -end
40.72 -
40.73 -
41.1 --- a/source/tolua++/src/bin/lua/variable.lua Wed Nov 04 01:07:17 2009 +0000
41.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
41.3 @@ -1,285 +0,0 @@
41.4 --- tolua: variable class
41.5 --- Written by Waldemar Celes
41.6 --- TeCGraf/PUC-Rio
41.7 --- Jul 1998
41.8 --- $Id$
41.9 -
41.10 --- This code is free software; you can redistribute it and/or modify it.
41.11 --- The software provided hereunder is on an "as is" basis, and
41.12 --- the author has no obligation to provide maintenance, support, updates,
41.13 --- enhancements, or modifications.
41.14 -
41.15 -
41.16 --- Variable class
41.17 --- Represents a extern variable or a public member of a class.
41.18 --- Stores all fields present in a declaration.
41.19 -classVariable = {
41.20 - _get = {}, -- mapped get functions
41.21 - _set = {}, -- mapped set functions
41.22 -}
41.23 -classVariable.__index = classVariable
41.24 -setmetatable(classVariable,classDeclaration)
41.25 -
41.26 --- Print method
41.27 -function classVariable:print (ident,close)
41.28 - print(ident.."Variable{")
41.29 - print(ident.." mod = '"..self.mod.."',")
41.30 - print(ident.." type = '"..self.type.."',")
41.31 - print(ident.." ptr = '"..self.ptr.."',")
41.32 - print(ident.." name = '"..self.name.."',")
41.33 - if self.dim then print(ident.." dim = '"..self.dim.."',") end
41.34 - print(ident.." def = '"..self.def.."',")
41.35 - print(ident.." ret = '"..self.ret.."',")
41.36 - print(ident.."}"..close)
41.37 -end
41.38 -
41.39 --- Generates C function name
41.40 -function classVariable:cfuncname (prefix)
41.41 - local parent = ""
41.42 - local unsigned = ""
41.43 - local ptr = ""
41.44 -
41.45 - local p = self:inmodule() or self:innamespace() or self:inclass()
41.46 -
41.47 - if p then
41.48 - if self.parent.classtype == 'class' then
41.49 - parent = "_" .. self.parent.type
41.50 - else
41.51 - parent = "_" .. p
41.52 - end
41.53 - end
41.54 -
41.55 - if strfind(self.mod,"(unsigned)") then
41.56 - unsigned = "_unsigned"
41.57 - end
41.58 -
41.59 - if self.ptr == "*" then ptr = "_ptr"
41.60 - elseif self.ptr == "&" then ptr = "_ref"
41.61 - end
41.62 -
41.63 - local name = prefix .. parent .. unsigned .. "_" .. gsub(self.lname or self.name,".*::","") .. ptr
41.64 -
41.65 - name = clean_template(name)
41.66 - return name
41.67 -
41.68 -end
41.69 -
41.70 --- check if it is a variable
41.71 -function classVariable:isvariable ()
41.72 - return true
41.73 -end
41.74 -
41.75 --- get variable value
41.76 -function classVariable:getvalue (class,static, prop_get)
41.77 -
41.78 - local name
41.79 - if prop_get then
41.80 -
41.81 - name = prop_get.."()"
41.82 - else
41.83 - name = self.name
41.84 - end
41.85 -
41.86 - if class and static then
41.87 - return self.parent.type..'::'..name
41.88 - elseif class then
41.89 - return 'self->'..name
41.90 - else
41.91 - return name
41.92 - end
41.93 -end
41.94 -
41.95 --- get variable pointer value
41.96 -function classVariable:getpointervalue (class,static)
41.97 - if class and static then
41.98 - return class..'::p'
41.99 - elseif class then
41.100 - return 'self->p'
41.101 - else
41.102 - return 'p'
41.103 - end
41.104 -end
41.105 -
41.106 --- Write binding functions
41.107 -function classVariable:supcode ()
41.108 - local class = self:inclass()
41.109 -
41.110 - local prop_get,prop_set
41.111 - if string.find(self.mod, 'tolua_property') then
41.112 -
41.113 - _,_,type = string.find(self.mod, "tolua_property__([^%s]*)")
41.114 - type = type or "default"
41.115 - prop_get,prop_set = get_property_methods(type, self.name)
41.116 - self.mod = string.gsub(self.mod, "tolua_property[^%s]*", "")
41.117 - end
41.118 -
41.119 - -- get function ------------------------------------------------
41.120 - if class then
41.121 - output("/* get function:",self.name," of class ",class," */")
41.122 - else
41.123 - output("/* get function:",self.name," */")
41.124 - end
41.125 - self.cgetname = self:cfuncname("tolua_get")
41.126 - output("static int",self.cgetname,"(lua_State* tolua_S)")
41.127 - output("{")
41.128 -
41.129 - -- declare self, if the case
41.130 - local _,_,static = strfind(self.mod,'^%s*(static)')
41.131 - if class and static==nil then
41.132 - output(' ',self.parent.type,'*','self = ')
41.133 - output('(',self.parent.type,'*) ')
41.134 - output('tolua_tousertype(tolua_S,1,0);')
41.135 - elseif static then
41.136 - _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)')
41.137 - end
41.138 -
41.139 -
41.140 - -- check self value
41.141 - if class and static==nil then
41.142 - output('#ifndef TOLUA_RELEASE\n')
41.143 - output(' if (!self) tolua_error(tolua_S,"invalid \'self\' in accessing variable \''..self.name..'\'",NULL);');
41.144 - output('#endif\n')
41.145 - end
41.146 -
41.147 - -- return value
41.148 - if string.find(self.mod, 'tolua_inherits') then
41.149 - output('#ifdef __cplusplus\n')
41.150 - output(' tolua_pushusertype(tolua_S,(void*)static_cast<'..self.type..'*>(self), "',self.type,'");')
41.151 - output('#else\n')
41.152 - output(' tolua_pushusertype(tolua_S,(void*)(('..self.type..'*)self), "',self.type,'");')
41.153 - output('#endif\n')
41.154 - else
41.155 - local t,ct = isbasic(self.type)
41.156 - if t then
41.157 - output(' tolua_push'..t..'(tolua_S,(',ct,')'..self:getvalue(class,static,prop_get)..');')
41.158 - else
41.159 - t = self.type
41.160 - if self.ptr == '&' or self.ptr == '' then
41.161 - output(' tolua_pushusertype(tolua_S,(void*)&'..self:getvalue(class,static,prop_get)..',"',t,'");')
41.162 - else
41.163 - output(' tolua_pushusertype(tolua_S,(void*)'..self:getvalue(class,static,prop_get)..',"',t,'");')
41.164 - end
41.165 - end
41.166 - end
41.167 - output(' return 1;')
41.168 - output('}')
41.169 - output('\n')
41.170 -
41.171 - -- set function ------------------------------------------------
41.172 - if not (strfind(self.type,'const%s+') or string.find(self.mod, 'tolua_readonly') or string.find(self.mod, 'tolua_inherits')) then
41.173 - if class then
41.174 - output("/* set function:",self.name," of class ",class," */")
41.175 - else
41.176 - output("/* set function:",self.name," */")
41.177 - end
41.178 - self.csetname = self:cfuncname("tolua_set")
41.179 - output("static int",self.csetname,"(lua_State* tolua_S)")
41.180 - output("{")
41.181 -
41.182 - -- declare self, if the case
41.183 - if class and static==nil then
41.184 - output(' ',self.parent.type,'*','self = ')
41.185 - output('(',self.parent.type,'*) ')
41.186 - output('tolua_tousertype(tolua_S,1,0);')
41.187 - -- check self value
41.188 - end
41.189 - -- check types
41.190 - output('#ifndef TOLUA_RELEASE\n')
41.191 - output(' tolua_Error tolua_err;')
41.192 - if class and static==nil then
41.193 - output(' if (!self) tolua_error(tolua_S,"invalid \'self\' in accessing variable \''..self.name..'\'",NULL);');
41.194 - elseif static then
41.195 - _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)')
41.196 - end
41.197 -
41.198 - -- check variable type
41.199 - output(' if (!'..self:outchecktype(2)..')')
41.200 - output(' tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);')
41.201 - output('#endif\n')
41.202 -
41.203 - -- assign value
41.204 - local def = 0
41.205 - if self.def ~= '' then def = self.def end
41.206 - if self.type == 'char*' and self.dim ~= '' then -- is string
41.207 - output(' strncpy(')
41.208 - if class and static then
41.209 - output(self.parent.type..'::'..self.name)
41.210 - elseif class then
41.211 - output('self->'..self.name)
41.212 - else
41.213 - output(self.name)
41.214 - end
41.215 - output(',tolua_tostring(tolua_S,2,',def,'),',self.dim,'-1);')
41.216 - else
41.217 - local ptr = ''
41.218 - if self.ptr~='' then ptr = '*' end
41.219 - output(' ')
41.220 - local name = prop_set or self.name
41.221 - if class and static then
41.222 - output(self.parent.type..'::'..name)
41.223 - elseif class then
41.224 - output('self->'..name)
41.225 - else
41.226 - output(name)
41.227 - end
41.228 - local t = isbasic(self.type)
41.229 - if prop_set then
41.230 - output('(')
41.231 - else
41.232 - output(' = ')
41.233 - end
41.234 - if not t and ptr=='' then output('*') end
41.235 - output('((',self.mod,self.type)
41.236 - if not t then
41.237 - output('*')
41.238 - end
41.239 - output(') ')
41.240 - if t then
41.241 - if isenum(self.type) then
41.242 - output('(int) ')
41.243 - end
41.244 - output('tolua_to'..t,'(tolua_S,2,',def,'))')
41.245 - else
41.246 - output('tolua_tousertype(tolua_S,2,',def,'))')
41.247 - end
41.248 - if prop_set then
41.249 - output(")")
41.250 - end
41.251 - output(";")
41.252 - end
41.253 - output(' return 0;')
41.254 - output('}')
41.255 - output('\n')
41.256 - end
41.257 -
41.258 -end
41.259 -
41.260 -function classVariable:register ()
41.261 - local parent = self:inmodule() or self:innamespace() or self:inclass()
41.262 - if not parent then
41.263 - if classVariable._warning==nil then
41.264 - warning("Mapping variable to global may degrade performance")
41.265 - classVariable._warning = 1
41.266 - end
41.267 - end
41.268 - if self.csetname then
41.269 - output(' tolua_variable(tolua_S,"'..self.lname..'",'..self.cgetname..','..self.csetname..');')
41.270 - else
41.271 - output(' tolua_variable(tolua_S,"'..self.lname..'",'..self.cgetname..',NULL);')
41.272 - end
41.273 -end
41.274 -
41.275 --- Internal constructor
41.276 -function _Variable (t)
41.277 - setmetatable(t,classVariable)
41.278 - append(t)
41.279 - return t
41.280 -end
41.281 -
41.282 --- Constructor
41.283 --- Expects a string representing the variable declaration.
41.284 -function Variable (s)
41.285 - return _Variable (Declaration(s,'var'))
41.286 -end
41.287 -
41.288 -
42.1 --- a/source/tolua++/src/bin/lua/verbatim.lua Wed Nov 04 01:07:17 2009 +0000
42.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
42.3 @@ -1,76 +0,0 @@
42.4 --- tolua: verbatim class
42.5 --- Written by Waldemar Celes
42.6 --- TeCGraf/PUC-Rio
42.7 --- Jul 1998
42.8 --- $Id$
42.9 -
42.10 --- This code is free software; you can redistribute it and/or modify it.
42.11 --- The software provided hereunder is on an "as is" basis, and
42.12 --- the author has no obligation to provide maintenance, support, updates,
42.13 --- enhancements, or modifications.
42.14 -
42.15 -
42.16 -
42.17 --- Verbatim class
42.18 --- Represents a line translated directed to the binding file.
42.19 --- The following filds are stored:
42.20 --- line = line text
42.21 -classVerbatim = {
42.22 - line = '',
42.23 - cond = nil, -- condition: where to generate the code (s=suport, r=register)
42.24 -}
42.25 -classVerbatim.__index = classVerbatim
42.26 -setmetatable(classVerbatim,classFeature)
42.27 -
42.28 --- preamble verbatim
42.29 -function classVerbatim:preamble ()
42.30 - if self.cond == '' then
42.31 - write(self.line)
42.32 - end
42.33 -end
42.34 -
42.35 --- support code
42.36 -function classVerbatim:supcode ()
42.37 - if strfind(self.cond,'s') then
42.38 - write(self.line)
42.39 - write('\n')
42.40 - end
42.41 -end
42.42 -
42.43 --- register code
42.44 -function classVerbatim:register ()
42.45 - if strfind(self.cond,'r') then
42.46 - write(self.line)
42.47 - end
42.48 -end
42.49 -
42.50 -
42.51 --- Print method
42.52 -function classVerbatim:print (ident,close)
42.53 - print(ident.."Verbatim{")
42.54 - print(ident.." line = '"..self.line.."',")
42.55 - print(ident.."}"..close)
42.56 -end
42.57 -
42.58 -
42.59 --- Internal constructor
42.60 -function _Verbatim (t)
42.61 - setmetatable(t,classVerbatim)
42.62 - append(t)
42.63 - return t
42.64 -end
42.65 -
42.66 --- Constructor
42.67 --- Expects a string representing the text line
42.68 -function Verbatim (l,cond)
42.69 - if strsub(l,1,1) == '$' then
42.70 - cond = 'sr' -- generates in both suport and register fragments
42.71 - l = strsub(l,2)
42.72 - end
42.73 - return _Verbatim {
42.74 - line = l,
42.75 - cond = cond or '',
42.76 - }
42.77 -end
42.78 -
42.79 -
43.1 --- a/source/tolua++/src/bin/tolua.c Wed Nov 04 01:07:17 2009 +0000
43.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
43.3 @@ -1,144 +0,0 @@
43.4 -/* tolua
43.5 -** Support code for Lua bindings.
43.6 -** Written by Waldemar Celes
43.7 -** TeCGraf/PUC-Rio
43.8 -** Aug 2003
43.9 -** $Id$
43.10 -*/
43.11 -
43.12 -/* This code is free software; you can redistribute it and/or modify it.
43.13 -** The software provided hereunder is on an "as is" basis, and
43.14 -** the author has no obligation to provide maintenance, support, updates,
43.15 -** enhancements, or modifications.
43.16 -*/
43.17 -
43.18 -#include "tolua++.h"
43.19 -
43.20 -#include "lua.h"
43.21 -#include "lualib.h"
43.22 -#include "lauxlib.h"
43.23 -
43.24 -#include <stdio.h>
43.25 -#include <stdlib.h>
43.26 -#include <string.h>
43.27 -
43.28 -
43.29 -static void help (void)
43.30 -{
43.31 - fprintf(stderr,"\n"
43.32 - "usage: tolua++ [options] input_file\n"
43.33 - "\n"
43.34 - "Command line options are:\n"
43.35 - " -v : print version information.\n"
43.36 - " -o file : set output file; default is stdout.\n"
43.37 - " -H file : create include file.\n"
43.38 - " -n name : set package name; default is input file root name.\n"
43.39 - " -p : parse only.\n"
43.40 - " -P : parse and print structure information (for debug).\n"
43.41 - " -S : disable support for c++ strings.\n"
43.42 - " -1 : substract 1 to operator[] index (for compatibility with tolua5).\n"
43.43 - " -L : run lua file (with dofile()) before doing anything.\n"
43.44 - " -D : disable automatic exporting of destructors for classes that have\n"
43.45 - " constructors (for compatibility with tolua5)\n"
43.46 - " -W : disable warnings for unsupported features (for compatibility\n"
43.47 - " with tolua5)\n"
43.48 - " -h : print this message.\n"
43.49 - "Should the input file be omitted, stdin is assumed;\n"
43.50 - "in that case, the package name must be explicitly set.\n\n"
43.51 - );
43.52 -}
43.53 -
43.54 -static void version (void)
43.55 -{
43.56 - fprintf(stderr, "%s (written by W. Celes, A. Manzur)\n",TOLUA_VERSION);
43.57 -}
43.58 -
43.59 -static void setfield (lua_State* L, int table, char* f, char* v)
43.60 -{
43.61 - lua_pushstring(L,f);
43.62 - lua_pushstring(L,v);
43.63 - lua_settable(L,table);
43.64 -}
43.65 -
43.66 -static void error (char* o)
43.67 -{
43.68 - fprintf(stderr,"tolua: unknown option '%s'\n",o);
43.69 - help();
43.70 - exit(1);
43.71 -}
43.72 -
43.73 -int main (int argc, char* argv[])
43.74 -{
43.75 - lua_State* L = lua_open();
43.76 - luaopen_base(L);
43.77 - luaopen_io(L);
43.78 - luaopen_string(L);
43.79 - luaopen_table(L);
43.80 - luaopen_math(L);
43.81 - luaopen_debug(L);
43.82 -
43.83 - lua_pushstring(L,TOLUA_VERSION); lua_setglobal(L,"TOLUA_VERSION");
43.84 -
43.85 - if (argc==1)
43.86 - {
43.87 - help();
43.88 - return 0;
43.89 - }
43.90 - else
43.91 - {
43.92 - int i, t;
43.93 - lua_newtable(L);
43.94 - lua_pushvalue(L,-1);
43.95 - lua_setglobal(L,"flags");
43.96 - t = lua_gettop(L);
43.97 - for (i=1; i<argc; ++i)
43.98 - {
43.99 - if (*argv[i] == '-')
43.100 - {
43.101 - switch (argv[i][1])
43.102 - {
43.103 - case 'v': version(); return 0;
43.104 - case 'h': help(); return 0;
43.105 - case 'p': setfield(L,t,"p",""); break;
43.106 - case 'P': setfield(L,t,"P",""); break;
43.107 - case 'o': setfield(L,t,"o",argv[++i]); break;
43.108 - case 'n': setfield(L,t,"n",argv[++i]); break;
43.109 - case 'H': setfield(L,t,"H",argv[++i]); break;
43.110 - case 'S': setfield(L,t,"S",""); break;
43.111 - case '1': setfield(L,t,"1",""); break;
43.112 - case 'L': setfield(L,t,"L",argv[++i]); break;
43.113 - case 'D': setfield(L,t,"D",""); break;
43.114 - case 'W': setfield(L,t,"W",""); break;
43.115 - default: error(argv[i]); break;
43.116 - }
43.117 - }
43.118 - else
43.119 - {
43.120 - setfield(L,t,"f",argv[i]);
43.121 - break;
43.122 - }
43.123 - }
43.124 - lua_pop(L,1);
43.125 - }
43.126 -/* #define TOLUA_SCRIPT_RUN */
43.127 -#ifndef TOLUA_SCRIPT_RUN
43.128 - {
43.129 - int tolua_tolua_open (lua_State* L);
43.130 - tolua_tolua_open(L);
43.131 - }
43.132 -#else
43.133 - {
43.134 - char* p;
43.135 - char path[BUFSIZ];
43.136 - strcpy(path,argv[0]);
43.137 - p = strrchr(path,'/');
43.138 - if (p==NULL) p = strrchr(path,'\\');
43.139 - p = (p==NULL) ? path : p+1;
43.140 - sprintf(p,"%s","../src/bin/lua/");
43.141 - lua_pushstring(L,path); lua_setglobal(L,"path");
43.142 - strcat(path,"all.lua");
43.143 - lua_dofile(L,path);
43.144 - }
43.145 -#endif
43.146 - return 0;
43.147 -}
44.1 --- a/source/tolua++/src/bin/tolua.pkg Wed Nov 04 01:07:17 2009 +0000
44.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
44.3 @@ -1,28 +0,0 @@
44.4 -$lfile "lua/compat.lua"
44.5 -$lfile "lua/basic.lua"
44.6 -$lfile "lua/feature.lua"
44.7 -$lfile "lua/verbatim.lua"
44.8 -$lfile "lua/code.lua"
44.9 -$lfile "lua/typedef.lua"
44.10 -$lfile "lua/container.lua"
44.11 -$lfile "lua/package.lua"
44.12 -$lfile "lua/module.lua"
44.13 -$lfile "lua/namespace.lua"
44.14 -$lfile "lua/define.lua"
44.15 -$lfile "lua/enumerate.lua"
44.16 -$lfile "lua/declaration.lua"
44.17 -$lfile "lua/variable.lua"
44.18 -$lfile "lua/array.lua"
44.19 -$lfile "lua/function.lua"
44.20 -$lfile "lua/operator.lua"
44.21 -$lfile "lua/class.lua"
44.22 -$lfile "lua/clean.lua"
44.23 -$lfile "lua/doit.lua"
44.24 -
44.25 -$[
44.26 -local err,msg = pcall(doit)
44.27 -if not err then
44.28 - local _,_,label,msg = strfind(msg,"(.-:.-:%s*)(.*)")
44.29 - tolua_error(msg,label)
44.30 -end
44.31 -$]
45.1 --- a/source/tolua++/src/bin/tolua_scons.pkg Wed Nov 04 01:07:17 2009 +0000
45.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
45.3 @@ -1,29 +0,0 @@
45.4 -$lfile "src/bin/lua/compat.lua"
45.5 -$lfile "src/bin/lua/basic.lua"
45.6 -$lfile "src/bin/lua/feature.lua"
45.7 -$lfile "src/bin/lua/verbatim.lua"
45.8 -$lfile "src/bin/lua/code.lua"
45.9 -$lfile "src/bin/lua/typedef.lua"
45.10 -$lfile "src/bin/lua/container.lua"
45.11 -$lfile "src/bin/lua/package.lua"
45.12 -$lfile "src/bin/lua/module.lua"
45.13 -$lfile "src/bin/lua/namespace.lua"
45.14 -$lfile "src/bin/lua/define.lua"
45.15 -$lfile "src/bin/lua/enumerate.lua"
45.16 -$lfile "src/bin/lua/declaration.lua"
45.17 -$lfile "src/bin/lua/variable.lua"
45.18 -$lfile "src/bin/lua/array.lua"
45.19 -$lfile "src/bin/lua/function.lua"
45.20 -$lfile "src/bin/lua/operator.lua"
45.21 -$lfile "src/bin/lua/class.lua"
45.22 -$lfile "src/bin/lua/clean.lua"
45.23 -$lfile "src/bin/lua/doit.lua"
45.24 -
45.25 -$[
45.26 -local err,msg = pcall(doit)
45.27 -if not err then
45.28 - local _,_,label,msg = strfind(msg,"(.-:.-:%s*)(.*)")
45.29 - tolua_error(msg,label)
45.30 - print(debug.traceback())
45.31 -end
45.32 -$]
46.1 --- a/source/tolua++/src/bin/toluabind.c Wed Nov 04 01:07:17 2009 +0000
46.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
46.3 @@ -1,4891 +0,0 @@
46.4 -/*
46.5 -** Lua binding: tolua
46.6 -** Generated automatically by tolua++-1.0.6 on Thu Aug 25 20:42:02 2005.
46.7 -*/
46.8 -
46.9 -#ifndef __cplusplus
46.10 -#include "stdlib.h"
46.11 -#endif
46.12 -#include "string.h"
46.13 -
46.14 -#include "tolua++.h"
46.15 -
46.16 -/* Exported function */
46.17 -TOLUA_API int tolua_tolua_open (lua_State* tolua_S);
46.18 -
46.19 -
46.20 -/* function to register type */
46.21 -static void tolua_reg_types (lua_State* tolua_S)
46.22 -{
46.23 -}
46.24 -
46.25 -/* Open function */
46.26 -TOLUA_API int tolua_tolua_open (lua_State* tolua_S)
46.27 -{
46.28 - tolua_open(tolua_S);
46.29 - tolua_reg_types(tolua_S);
46.30 - tolua_module(tolua_S,NULL,0);
46.31 - tolua_beginmodule(tolua_S,NULL);
46.32 -
46.33 - { /* begin embedded lua code */
46.34 - static unsigned char B[] = {
46.35 - 10,114, 97,119,116,121,112,101, 32, 61, 32,116,121,112,101,
46.36 - 10,102,117,110, 99,116,105,111,110, 32,100,111, 95, 32, 40,
46.37 - 102, 44, 32,101,114,114, 41, 10,105,102, 32,110,111,116, 32,
46.38 - 102, 32,116,104,101,110, 32,112,114,105,110,116, 40,101,114,
46.39 - 114, 41, 59, 32,114,101,116,117,114,110, 32,101,110,100, 10,
46.40 - 108,111, 99, 97,108, 32, 97, 44, 98, 32, 61, 32,112, 99, 97,
46.41 - 108,108, 40,102, 41, 10,105,102, 32,110,111,116, 32, 97, 32,
46.42 - 116,104,101,110, 32,112,114,105,110,116, 40, 98, 41, 59, 32,
46.43 - 114,101,116,117,114,110, 32,110,105,108, 10,101,108,115,101,
46.44 - 32,114,101,116,117,114,110, 32, 98, 32,111,114, 32,116,114,
46.45 - 117,101, 10,101,110,100, 10,101,110,100, 10,102,117,110, 99,
46.46 - 116,105,111,110, 32,100,111,115,116,114,105,110,103, 40,115,
46.47 - 41, 32,114,101,116,117,114,110, 32,100,111, 95, 40,108,111,
46.48 - 97,100,115,116,114,105,110,103, 40,115, 41, 41, 32,101,110,
46.49 - 100, 10,108,111, 99, 97,108, 32,116, 97, 98, 32, 61, 32,116,
46.50 - 97, 98,108,101, 10,102,111,114,101, 97, 99,104, 32, 61, 32,
46.51 - 116, 97, 98, 46,102,111,114,101, 97, 99,104, 10,102,111,114,
46.52 - 101, 97, 99,104,105, 32, 61, 32,116, 97, 98, 46,102,111,114,
46.53 - 101, 97, 99,104,105, 10,103,101,116,110, 32, 61, 32,116, 97,
46.54 - 98, 46,103,101,116,110, 10,116,105,110,115,101,114,116, 32,
46.55 - 61, 32,116, 97, 98, 46,105,110,115,101,114,116, 10,116,114,
46.56 - 101,109,111,118,101, 32, 61, 32,116, 97, 98, 46,114,101,109,
46.57 - 111,118,101, 10,115,111,114,116, 32, 61, 32,116, 97, 98, 46,
46.58 - 115,111,114,116, 10,108,111, 99, 97,108, 32,100, 98,103, 32,
46.59 - 61, 32,100,101, 98,117,103, 10,103,101,116,105,110,102,111,
46.60 - 32, 61, 32,100, 98,103, 46,103,101,116,105,110,102,111, 10,
46.61 - 103,101,116,108,111, 99, 97,108, 32, 61, 32,100, 98,103, 46,
46.62 - 103,101,116,108,111, 99, 97,108, 10,115,101,116, 99, 97,108,
46.63 - 108,104,111,111,107, 32, 61, 32,102,117,110, 99,116,105,111,
46.64 - 110, 32, 40, 41, 32,101,114,114,111,114, 34, 96,115,101,116,
46.65 - 99, 97,108,108,104,111,111,107, 39, 32,105,115, 32,100,101,
46.66 - 112,114,101, 99, 97,116,101,100, 34, 32,101,110,100, 10,115,
46.67 - 101,116,108,105,110,101,104,111,111,107, 32, 61, 32,102,117,
46.68 - 110, 99,116,105,111,110, 32, 40, 41, 32,101,114,114,111,114,
46.69 - 34, 96,115,101,116,108,105,110,101,104,111,111,107, 39, 32,
46.70 - 105,115, 32,100,101,112,114,101, 99, 97,116,101,100, 34, 32,
46.71 - 101,110,100, 10,115,101,116,108,111, 99, 97,108, 32, 61, 32,
46.72 - 100, 98,103, 46,115,101,116,108,111, 99, 97,108, 10,108,111,
46.73 - 99, 97,108, 32,109, 97,116,104, 32, 61, 32,109, 97,116,104,
46.74 - 10, 97, 98,115, 32, 61, 32,109, 97,116,104, 46, 97, 98,115,
46.75 - 10, 97, 99,111,115, 32, 61, 32,102,117,110, 99,116,105,111,
46.76 - 110, 32, 40,120, 41, 32,114,101,116,117,114,110, 32,109, 97,
46.77 - 116,104, 46,100,101,103, 40,109, 97,116,104, 46, 97, 99,111,
46.78 - 115, 40,120, 41, 41, 32,101,110,100, 10, 97,115,105,110, 32,
46.79 - 61, 32,102,117,110, 99,116,105,111,110, 32, 40,120, 41, 32,
46.80 - 114,101,116,117,114,110, 32,109, 97,116,104, 46,100,101,103,
46.81 - 40,109, 97,116,104, 46, 97,115,105,110, 40,120, 41, 41, 32,
46.82 - 101,110,100, 10, 97,116, 97,110, 32, 61, 32,102,117,110, 99,
46.83 - 116,105,111,110, 32, 40,120, 41, 32,114,101,116,117,114,110,
46.84 - 32,109, 97,116,104, 46,100,101,103, 40,109, 97,116,104, 46,
46.85 - 97,116, 97,110, 40,120, 41, 41, 32,101,110,100, 10, 97,116,
46.86 - 97,110, 50, 32, 61, 32,102,117,110, 99,116,105,111,110, 32,
46.87 - 40,120, 44,121, 41, 32,114,101,116,117,114,110, 32,109, 97,
46.88 - 116,104, 46,100,101,103, 40,109, 97,116,104, 46, 97,116, 97,
46.89 - 110, 50, 40,120, 44,121, 41, 41, 32,101,110,100, 10, 99,101,
46.90 - 105,108, 32, 61, 32,109, 97,116,104, 46, 99,101,105,108, 10,
46.91 - 99,111,115, 32, 61, 32,102,117,110, 99,116,105,111,110, 32,
46.92 - 40,120, 41, 32,114,101,116,117,114,110, 32,109, 97,116,104,
46.93 - 46, 99,111,115, 40,109, 97,116,104, 46,114, 97,100, 40,120,
46.94 - 41, 41, 32,101,110,100, 10,100,101,103, 32, 61, 32,109, 97,
46.95 - 116,104, 46,100,101,103, 10,101,120,112, 32, 61, 32,109, 97,
46.96 - 116,104, 46,101,120,112, 10,102,108,111,111,114, 32, 61, 32,
46.97 - 109, 97,116,104, 46,102,108,111,111,114, 10,102,114,101,120,
46.98 - 112, 32, 61, 32,109, 97,116,104, 46,102,114,101,120,112, 10,
46.99 - 108,100,101,120,112, 32, 61, 32,109, 97,116,104, 46,108,100,
46.100 - 101,120,112, 10,108,111,103, 32, 61, 32,109, 97,116,104, 46,
46.101 - 108,111,103, 10,108,111,103, 49, 48, 32, 61, 32,109, 97,116,
46.102 - 104, 46,108,111,103, 49, 48, 10,109, 97,120, 32, 61, 32,109,
46.103 - 97,116,104, 46,109, 97,120, 10,109,105,110, 32, 61, 32,109,
46.104 - 97,116,104, 46,109,105,110, 10,109,111,100, 32, 61, 32,109,
46.105 - 97,116,104, 46,109,111,100, 10, 80, 73, 32, 61, 32,109, 97,
46.106 - 116,104, 46,112,105, 10,114, 97,100, 32, 61, 32,109, 97,116,
46.107 - 104, 46,114, 97,100, 10,114, 97,110,100,111,109, 32, 61, 32,
46.108 - 109, 97,116,104, 46,114, 97,110,100,111,109, 10,114, 97,110,
46.109 - 100,111,109,115,101,101,100, 32, 61, 32,109, 97,116,104, 46,
46.110 - 114, 97,110,100,111,109,115,101,101,100, 10,115,105,110, 32,
46.111 - 61, 32,102,117,110, 99,116,105,111,110, 32, 40,120, 41, 32,
46.112 - 114,101,116,117,114,110, 32,109, 97,116,104, 46,115,105,110,
46.113 - 40,109, 97,116,104, 46,114, 97,100, 40,120, 41, 41, 32,101,
46.114 - 110,100, 10,115,113,114,116, 32, 61, 32,109, 97,116,104, 46,
46.115 - 115,113,114,116, 10,116, 97,110, 32, 61, 32,102,117,110, 99,
46.116 - 116,105,111,110, 32, 40,120, 41, 32,114,101,116,117,114,110,
46.117 - 32,109, 97,116,104, 46,116, 97,110, 40,109, 97,116,104, 46,
46.118 - 114, 97,100, 40,120, 41, 41, 32,101,110,100, 10,108,111, 99,
46.119 - 97,108, 32,115,116,114, 32, 61, 32,115,116,114,105,110,103,
46.120 - 10,115,116,114, 98,121,116,101, 32, 61, 32,115,116,114, 46,
46.121 - 98,121,116,101, 10,115,116,114, 99,104, 97,114, 32, 61, 32,
46.122 - 115,116,114, 46, 99,104, 97,114, 10,115,116,114,102,105,110,
46.123 - 100, 32, 61, 32,115,116,114, 46,102,105,110,100, 10,102,111,
46.124 - 114,109, 97,116, 32, 61, 32,115,116,114, 46,102,111,114,109,
46.125 - 97,116, 10,103,115,117, 98, 32, 61, 32,115,116,114, 46,103,
46.126 - 115,117, 98, 10,115,116,114,108,101,110, 32, 61, 32,115,116,
46.127 - 114, 46,108,101,110, 10,115,116,114,108,111,119,101,114, 32,
46.128 - 61, 32,115,116,114, 46,108,111,119,101,114, 10,115,116,114,
46.129 - 114,101,112, 32, 61, 32,115,116,114, 46,114,101,112, 10,115,
46.130 - 116,114,115,117, 98, 32, 61, 32,115,116,114, 46,115,117, 98,
46.131 - 10,115,116,114,117,112,112,101,114, 32, 61, 32,115,116,114,
46.132 - 46,117,112,112,101,114, 10, 99,108,111, 99,107, 32, 61, 32,
46.133 - 111,115, 46, 99,108,111, 99,107, 10,100, 97,116,101, 32, 61,
46.134 - 32,111,115, 46,100, 97,116,101, 10,100,105,102,102,116,105,
46.135 - 109,101, 32, 61, 32,111,115, 46,100,105,102,102,116,105,109,
46.136 - 101, 10,101,120,101, 99,117,116,101, 32, 61, 32,111,115, 46,
46.137 - 101,120,101, 99,117,116,101, 10,101,120,105,116, 32, 61, 32,
46.138 - 111,115, 46,101,120,105,116, 10,103,101,116,101,110,118, 32,
46.139 - 61, 32,111,115, 46,103,101,116,101,110,118, 10,114,101,109,
46.140 - 111,118,101, 32, 61, 32,111,115, 46,114,101,109,111,118,101,
46.141 - 10,114,101,110, 97,109,101, 32, 61, 32,111,115, 46,114,101,
46.142 - 110, 97,109,101, 10,115,101,116,108,111, 99, 97,108,101, 32,
46.143 - 61, 32,111,115, 46,115,101,116,108,111, 99, 97,108,101, 10,
46.144 - 116,105,109,101, 32, 61, 32,111,115, 46,116,105,109,101, 10,
46.145 - 116,109,112,110, 97,109,101, 32, 61, 32,111,115, 46,116,109,
46.146 - 112,110, 97,109,101, 10,103,101,116,103,108,111, 98, 97,108,
46.147 - 32, 61, 32,102,117,110, 99,116,105,111,110, 32, 40,110, 41,
46.148 - 32,114,101,116,117,114,110, 32, 95, 71, 91,110, 93, 32,101,
46.149 - 110,100, 10,115,101,116,103,108,111, 98, 97,108, 32, 61, 32,
46.150 - 102,117,110, 99,116,105,111,110, 32, 40,110, 44,118, 41, 32,
46.151 - 95, 71, 91,110, 93, 32, 61, 32,118, 32,101,110,100, 10,108,
46.152 - 111, 99, 97,108, 32,105,111, 44, 32,116, 97, 98, 32, 61, 32,
46.153 - 105,111, 44, 32,116, 97, 98,108,101, 10, 95, 83, 84, 68, 73,
46.154 - 78, 32, 61, 32,105,111, 46,115,116,100,105,110, 10, 95, 83,
46.155 - 84, 68, 69, 82, 82, 32, 61, 32,105,111, 46,115,116,100,101,
46.156 - 114,114, 10, 95, 83, 84, 68, 79, 85, 84, 32, 61, 32,105,111,
46.157 - 46,115,116,100,111,117,116, 10, 95, 73, 78, 80, 85, 84, 32,
46.158 - 61, 32,105,111, 46,115,116,100,105,110, 10, 95, 79, 85, 84,
46.159 - 80, 85, 84, 32, 61, 32,105,111, 46,115,116,100,111,117,116,
46.160 - 10,115,101,101,107, 32, 61, 32,105,111, 46,115,116,100,105,
46.161 - 110, 46,115,101,101,107, 10,116,109,112,102,105,108,101, 32,
46.162 - 61, 32,105,111, 46,116,109,112,102,105,108,101, 10, 99,108,
46.163 - 111,115,101,102,105,108,101, 32, 61, 32,105,111, 46, 99,108,
46.164 - 111,115,101, 10,111,112,101,110,102,105,108,101, 32, 61, 32,
46.165 - 105,111, 46,111,112,101,110, 10,102,117,110, 99,116,105,111,
46.166 - 110, 32,102,108,117,115,104, 32, 40,102, 41, 10,105,102, 32,
46.167 - 102, 32,116,104,101,110, 32,102, 58,102,108,117,115,104, 40,
46.168 - 41, 10,101,108,115,101, 32, 95, 79, 85, 84, 80, 85, 84, 58,
46.169 - 102,108,117,115,104, 40, 41, 10,101,110,100, 10,101,110,100,
46.170 - 10,102,117,110, 99,116,105,111,110, 32,114,101, 97,100,102,
46.171 - 114,111,109, 32, 40,110, 97,109,101, 41, 10,105,102, 32,110,
46.172 - 97,109,101, 32, 61, 61, 32,110,105,108, 32,116,104,101,110,
46.173 - 10,108,111, 99, 97,108, 32,102, 44, 32,101,114,114, 44, 32,
46.174 - 99,111,100, 32, 61, 32,105,111, 46, 99,108,111,115,101, 40,
46.175 - 95, 73, 78, 80, 85, 84, 41, 10, 95, 73, 78, 80, 85, 84, 32,
46.176 - 61, 32,105,111, 46,115,116,100,105,110, 10,114,101,116,117,
46.177 - 114,110, 32,102, 44, 32,101,114,114, 44, 32, 99,111,100, 10,
46.178 - 101,108,115,101, 10,108,111, 99, 97,108, 32,102, 44, 32,101,
46.179 - 114,114, 44, 32, 99,111,100, 32, 61, 32,105,111, 46,111,112,
46.180 - 101,110, 40,110, 97,109,101, 44, 32, 34,114, 34, 41, 10, 95,
46.181 - 73, 78, 80, 85, 84, 32, 61, 32,102, 32,111,114, 32, 95, 73,
46.182 - 78, 80, 85, 84, 10,114,101,116,117,114,110, 32,102, 44, 32,
46.183 - 101,114,114, 44, 32, 99,111,100, 10,101,110,100, 10,101,110,
46.184 - 100, 10,102,117,110, 99,116,105,111,110, 32,119,114,105,116,
46.185 - 101,116,111, 32, 40,110, 97,109,101, 41, 10,105,102, 32,110,
46.186 - 97,109,101, 32, 61, 61, 32,110,105,108, 32,116,104,101,110,
46.187 - 10,108,111, 99, 97,108, 32,102, 44, 32,101,114,114, 44, 32,
46.188 - 99,111,100, 32, 61, 32,105,111, 46, 99,108,111,115,101, 40,
46.189 - 95, 79, 85, 84, 80, 85, 84, 41, 10, 95, 79, 85, 84, 80, 85,
46.190 - 84, 32, 61, 32,105,111, 46,115,116,100,111,117,116, 10,114,
46.191 - 101,116,117,114,110, 32,102, 44, 32,101,114,114, 44, 32, 99,
46.192 - 111,100, 10,101,108,115,101, 10,108,111, 99, 97,108, 32,102,
46.193 - 44, 32,101,114,114, 44, 32, 99,111,100, 32, 61, 32,105,111,
46.194 - 46,111,112,101,110, 40,110, 97,109,101, 44, 32, 34,119, 34,
46.195 - 41, 10, 95, 79, 85, 84, 80, 85, 84, 32, 61, 32,102, 32,111,
46.196 - 114, 32, 95, 79, 85, 84, 80, 85, 84, 10,114,101,116,117,114,
46.197 - 110, 32,102, 44, 32,101,114,114, 44, 32, 99,111,100, 10,101,
46.198 - 110,100, 10,101,110,100, 10,102,117,110, 99,116,105,111,110,
46.199 - 32, 97,112,112,101,110,100,116,111, 32, 40,110, 97,109,101,
46.200 - 41, 10,108,111, 99, 97,108, 32,102, 44, 32,101,114,114, 44,
46.201 - 32, 99,111,100, 32, 61, 32,105,111, 46,111,112,101,110, 40,
46.202 - 110, 97,109,101, 44, 32, 34, 97, 34, 41, 10, 95, 79, 85, 84,
46.203 - 80, 85, 84, 32, 61, 32,102, 32,111,114, 32, 95, 79, 85, 84,
46.204 - 80, 85, 84, 10,114,101,116,117,114,110, 32,102, 44, 32,101,
46.205 - 114,114, 44, 32, 99,111,100, 10,101,110,100, 10,102,117,110,
46.206 - 99,116,105,111,110, 32,114,101, 97,100, 32, 40, 46, 46, 46,
46.207 - 41, 10,108,111, 99, 97,108, 32,102, 32, 61, 32, 95, 73, 78,
46.208 - 80, 85, 84, 10,105,102, 32,114, 97,119,116,121,112,101, 40,
46.209 - 97,114,103, 91, 49, 93, 41, 32, 61, 61, 32, 39,117,115,101,
46.210 - 114,100, 97,116, 97, 39, 32,116,104,101,110, 10,102, 32, 61,
46.211 - 32,116, 97, 98, 46,114,101,109,111,118,101, 40, 97,114,103,
46.212 - 44, 32, 49, 41, 10,101,110,100, 10,114,101,116,117,114,110,
46.213 - 32,102, 58,114,101, 97,100, 40,117,110,112, 97, 99,107, 40,
46.214 - 97,114,103, 41, 41, 10,101,110,100, 10,102,117,110, 99,116,
46.215 - 105,111,110, 32,119,114,105,116,101, 32, 40, 46, 46, 46, 41,
46.216 - 10,108,111, 99, 97,108, 32,102, 32, 61, 32, 95, 79, 85, 84,
46.217 - 80, 85, 84, 10,105,102, 32,114, 97,119,116,121,112,101, 40,
46.218 - 97,114,103, 91, 49, 93, 41, 32, 61, 61, 32, 39,117,115,101,
46.219 - 114,100, 97,116, 97, 39, 32,116,104,101,110, 10,102, 32, 61,
46.220 - 32,116, 97, 98, 46,114,101,109,111,118,101, 40, 97,114,103,
46.221 - 44, 32, 49, 41, 10,101,110,100, 10,114,101,116,117,114,110,
46.222 - 32,102, 58,119,114,105,116,101, 40,117,110,112, 97, 99,107,
46.223 - 40, 97,114,103, 41, 41, 10,101,110,100,32
46.224 - };
46.225 - lua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 1");
46.226 - } /* end of embedded lua code */
46.227 -
46.228 -
46.229 - { /* begin embedded lua code */
46.230 - static unsigned char B[] = {
46.231 - 10, 95, 98, 97,115,105, 99, 32, 61, 32,123, 10, 91, 39,118,
46.232 - 111,105,100, 39, 93, 32, 61, 32, 39, 39, 44, 10, 91, 39, 99,
46.233 - 104, 97,114, 39, 93, 32, 61, 32, 39,110,117,109, 98,101,114,
46.234 - 39, 44, 10, 91, 39,105,110,116, 39, 93, 32, 61, 32, 39,110,
46.235 - 117,109, 98,101,114, 39, 44, 10, 91, 39,115,104,111,114,116,
46.236 - 39, 93, 32, 61, 32, 39,110,117,109, 98,101,114, 39, 44, 10,
46.237 - 91, 39,108,111,110,103, 39, 93, 32, 61, 32, 39,110,117,109,
46.238 - 98,101,114, 39, 44, 10, 91, 39,117,110,115,105,103,110,101,
46.239 - 100, 39, 93, 32, 61, 32, 39,110,117,109, 98,101,114, 39, 44,
46.240 - 10, 91, 39,102,108,111, 97,116, 39, 93, 32, 61, 32, 39,110,
46.241 - 117,109, 98,101,114, 39, 44, 10, 91, 39,100,111,117, 98,108,
46.242 - 101, 39, 93, 32, 61, 32, 39,110,117,109, 98,101,114, 39, 44,
46.243 - 10, 91, 39, 95, 99,115,116,114,105,110,103, 39, 93, 32, 61,
46.244 - 32, 39,115,116,114,105,110,103, 39, 44, 10, 91, 39, 95,117,
46.245 - 115,101,114,100, 97,116, 97, 39, 93, 32, 61, 32, 39,117,115,
46.246 - 101,114,100, 97,116, 97, 39, 44, 10, 91, 39, 99,104, 97,114,
46.247 - 42, 39, 93, 32, 61, 32, 39,115,116,114,105,110,103, 39, 44,
46.248 - 10, 91, 39,118,111,105,100, 42, 39, 93, 32, 61, 32, 39,117,
46.249 - 115,101,114,100, 97,116, 97, 39, 44, 10, 91, 39, 98,111,111,
46.250 - 108, 39, 93, 32, 61, 32, 39, 98,111,111,108,101, 97,110, 39,
46.251 - 44, 10, 91, 39,108,117, 97, 95, 79, 98,106,101, 99,116, 39,
46.252 - 93, 32, 61, 32, 39,118, 97,108,117,101, 39, 44, 10, 91, 39,
46.253 - 76, 85, 65, 95, 86, 65, 76, 85, 69, 39, 93, 32, 61, 32, 39,
46.254 - 118, 97,108,117,101, 39, 44, 10, 91, 39,108,117, 97, 95, 83,
46.255 - 116, 97,116,101, 42, 39, 93, 32, 61, 32, 39,115,116, 97,116,
46.256 - 101, 39, 44, 10, 91, 39, 95,108,115,116, 97,116,101, 39, 93,
46.257 - 32, 61, 32, 39,115,116, 97,116,101, 39, 44, 10, 91, 39,108,
46.258 - 117, 97, 95, 70,117,110, 99,116,105,111,110, 39, 93, 32, 61,
46.259 - 32, 39,118, 97,108,117,101, 39, 44, 10,125, 10, 95, 98, 97,
46.260 - 115,105, 99, 95, 99,116,121,112,101, 32, 61, 32,123, 10,110,
46.261 - 117,109, 98,101,114, 32, 61, 32, 34,108,117, 97, 95, 78,117,
46.262 - 109, 98,101,114, 34, 44, 10,115,116,114,105,110,103, 32, 61,
46.263 - 32, 34, 99,111,110,115,116, 32, 99,104, 97,114, 42, 34, 44,
46.264 - 10,117,115,101,114,100, 97,116, 97, 32, 61, 32, 34,118,111,
46.265 - 105,100, 42, 34, 44, 10, 98,111,111,108,101, 97,110, 32, 61,
46.266 - 32, 34, 98,111,111,108, 34, 44, 10,118, 97,108,117,101, 32,
46.267 - 61, 32, 34,105,110,116, 34, 44, 10,125, 10, 95,117,115,101,
46.268 - 114,116,121,112,101, 32, 61, 32,123,125, 10, 95, 99,111,108,
46.269 - 108,101, 99,116, 32, 61, 32,123,125, 10, 95,103,108,111, 98,
46.270 - 97,108, 95,116,121,112,101,115, 32, 61, 32,123,110, 61, 48,
46.271 - 125, 10, 95,103,108,111, 98, 97,108, 95,116,121,112,101,115,
46.272 - 95,104, 97,115,104, 32, 61, 32,123,125, 10, 95,103,108,111,
46.273 - 98, 97,108, 95, 99,108, 97,115,115,101,115, 32, 61, 32,123,
46.274 - 125, 10, 95,103,108,111, 98, 97,108, 95,101,110,117,109,115,
46.275 - 32, 61, 32,123,125, 10, 95,114,101,110, 97,109,105,110,103,
46.276 - 32, 61, 32,123,125, 10,102,117,110, 99,116,105,111,110, 32,
46.277 - 97,112,112,101,110,100,114,101,110, 97,109,105,110,103, 32,
46.278 - 40,115, 41, 10,108,111, 99, 97,108, 32, 98, 44,101, 44,111,
46.279 - 108,100, 44,110,101,119, 32, 61, 32,115,116,114,102,105,110,
46.280 - 100, 40,115, 44, 34, 37,115, 42, 40, 46, 45, 41, 37,115, 42,
46.281 - 64, 37,115, 42, 40, 46, 45, 41, 37,115, 42, 36, 34, 41, 10,
46.282 - 105,102, 32,110,111,116, 32, 98, 32,116,104,101,110, 10,101,
46.283 - 114,114,111,114, 40, 34, 35, 73,110,118, 97,108,105,100, 32,
46.284 - 114,101,110, 97,109,105,110,103, 32,115,121,110,116, 97,120,
46.285 - 59, 32,105,116, 32,115,104,111,117,108,100, 32, 98,101, 32,
46.286 - 111,102, 32,116,104,101, 32,102,111,114,109, 58, 32,112, 97,
46.287 - 116,116,101,114,110, 64,112, 97,116,116,101,114,110, 34, 41,
46.288 - 10,101,110,100, 10,116,105,110,115,101,114,116, 40, 95,114,
46.289 - 101,110, 97,109,105,110,103, 44,123,111,108,100, 61,111,108,
46.290 - 100, 44, 32,110,101,119, 61,110,101,119,125, 41, 10,101,110,
46.291 - 100, 10,102,117,110, 99,116,105,111,110, 32, 97,112,112,108,
46.292 - 121,114,101,110, 97,109,105,110,103, 32, 40,115, 41, 10,102,
46.293 - 111,114, 32,105, 61, 49, 44,103,101,116,110, 40, 95,114,101,
46.294 - 110, 97,109,105,110,103, 41, 32,100,111, 10,108,111, 99, 97,
46.295 - 108, 32,109, 44,110, 32, 61, 32,103,115,117, 98, 40,115, 44,
46.296 - 95,114,101,110, 97,109,105,110,103, 91,105, 93, 46,111,108,
46.297 - 100, 44, 95,114,101,110, 97,109,105,110,103, 91,105, 93, 46,
46.298 - 110,101,119, 41, 10,105,102, 32,110, 32,126, 61, 32, 48, 32,
46.299 - 116,104,101,110, 10,114,101,116,117,114,110, 32,109, 10,101,
46.300 - 110,100, 10,101,110,100, 10,114,101,116,117,114,110, 32,110,
46.301 - 105,108, 10,101,110,100, 10,102,117,110, 99,116,105,111,110,
46.302 - 32,116,111,108,117, 97, 95,101,114,114,111,114, 32, 40,115,
46.303 - 44,102, 41, 10,105,102, 32, 95, 99,117,114,114, 95, 99,111,
46.304 - 100,101, 32,116,104,101,110, 10,112,114,105,110,116, 40, 34,
46.305 - 42, 42, 42, 99,117,114,114, 32, 99,111,100,101, 32,102,111,
46.306 - 114, 32,101,114,114,111,114, 32,105,115, 32, 34, 46, 46,116,
46.307 - 111,115,116,114,105,110,103, 40, 95, 99,117,114,114, 95, 99,
46.308 - 111,100,101, 41, 41, 10,112,114,105,110,116, 40,100,101, 98,
46.309 - 117,103, 46,116,114, 97, 99,101, 98, 97, 99,107, 40, 41, 41,
46.310 - 10,101,110,100, 10,108,111, 99, 97,108, 32,111,117,116, 32,
46.311 - 61, 32, 95, 79, 85, 84, 80, 85, 84, 10, 95, 79, 85, 84, 80,
46.312 - 85, 84, 32, 61, 32, 95, 83, 84, 68, 69, 82, 82, 10,105,102,
46.313 - 32,115,116,114,115,117, 98, 40,115, 44, 49, 44, 49, 41, 32,
46.314 - 61, 61, 32, 39, 35, 39, 32,116,104,101,110, 10,119,114,105,
46.315 - 116,101, 40, 34, 92,110, 42, 42, 32,116,111,108,117, 97, 58,
46.316 - 32, 34, 46, 46,115,116,114,115,117, 98, 40,115, 44, 50, 41,
46.317 - 46, 46, 34, 46, 92,110, 92,110, 34, 41, 10,105,102, 32, 95,
46.318 - 99,117,114,114, 95, 99,111,100,101, 32,116,104,101,110, 10,
46.319 - 108,111, 99, 97,108, 32, 95, 44, 95, 44,115, 32, 61, 32,115,
46.320 - 116,114,102,105,110,100, 40, 95, 99,117,114,114, 95, 99,111,
46.321 - 100,101, 44, 34, 94, 37,115, 42, 40, 46, 45, 92,110, 41, 34,
46.322 - 41, 10,105,102, 32,115, 61, 61,110,105,108, 32,116,104,101,
46.323 - 110, 32,115, 32, 61, 32, 95, 99,117,114,114, 95, 99,111,100,
46.324 - 101, 32,101,110,100, 10,115, 32, 61, 32,103,115,117, 98, 40,
46.325 - 115, 44, 34, 95,117,115,101,114,100, 97,116, 97, 34, 44, 34,
46.326 - 118,111,105,100, 42, 34, 41, 10,115, 32, 61, 32,103,115,117,
46.327 - 98, 40,115, 44, 34, 95, 99,115,116,114,105,110,103, 34, 44,
46.328 - 34, 99,104, 97,114, 42, 34, 41, 10,115, 32, 61, 32,103,115,
46.329 - 117, 98, 40,115, 44, 34, 95,108,115,116, 97,116,101, 34, 44,
46.330 - 34,108,117, 97, 95, 83,116, 97,116,101, 42, 34, 41, 10,119,
46.331 - 114,105,116,101, 40, 34, 67,111,100,101, 32, 98,101,105,110,
46.332 - 103, 32,112,114,111, 99,101,115,115,101,100, 58, 92,110, 34,
46.333 - 46, 46,115, 46, 46, 34, 92,110, 34, 41, 10,101,110,100, 10,
46.334 - 101,108,115,101, 10,105,102, 32,110,111,116, 32,102, 32,116,
46.335 - 104,101,110, 32,102, 32, 61, 32, 34, 40,102, 32,105,115, 32,
46.336 - 110,105,108, 41, 34, 32,101,110,100, 10,112,114,105,110,116,
46.337 - 40, 34, 92,110, 42, 42, 32,116,111,108,117, 97, 32,105,110,
46.338 - 116,101,114,110, 97,108, 32,101,114,114,111,114, 58, 32, 34,
46.339 - 46, 46,102, 46, 46,115, 46, 46, 34, 46, 92,110, 92,110, 34,
46.340 - 41, 10,114,101,116,117,114,110, 10,101,110,100, 10, 95, 79,
46.341 - 85, 84, 80, 85, 84, 32, 61, 32,111,117,116, 10,101,110,100,
46.342 - 10,102,117,110, 99,116,105,111,110, 32,119, 97,114,110,105,
46.343 - 110,103, 32, 40,109,115,103, 41, 10,108,111, 99, 97,108, 32,
46.344 - 111,117,116, 32, 61, 32, 95, 79, 85, 84, 80, 85, 84, 10, 95,
46.345 - 79, 85, 84, 80, 85, 84, 32, 61, 32, 95, 83, 84, 68, 69, 82,
46.346 - 82, 10,119,114,105,116,101, 40, 34, 92,110, 42, 42, 32,116,
46.347 - 111,108,117, 97, 32,119, 97,114,110,105,110,103, 58, 32, 34,
46.348 - 46, 46,109,115,103, 46, 46, 34, 46, 92,110, 92,110, 34, 41,
46.349 - 10, 95, 79, 85, 84, 80, 85, 84, 32, 61, 32,111,117,116, 10,
46.350 - 101,110,100, 10,102,117,110, 99,116,105,111,110, 32,114,101,
46.351 - 103,116,121,112,101, 32, 40,116, 41, 10,105,102, 32,105,115,
46.352 - 98, 97,115,105, 99, 40,116, 41, 32,116,104,101,110, 10,114,
46.353 - 101,116,117,114,110, 32,116, 10,101,110,100, 10,108,111, 99,
46.354 - 97,108, 32,102,116, 32, 61, 32,102,105,110,100,116,121,112,
46.355 - 101, 40,116, 41, 10,105,102, 32,110,111,116, 32, 95,117,115,
46.356 - 101,114,116,121,112,101, 91,102,116, 93, 32,116,104,101,110,
46.357 - 10,114,101,116,117,114,110, 32, 97,112,112,101,110,100,117,
46.358 - 115,101,114,116,121,112,101, 40,116, 41, 10,101,110,100, 10,
46.359 - 114,101,116,117,114,110, 32,102,116, 10,101,110,100, 10,102,
46.360 - 117,110, 99,116,105,111,110, 32,116,121,112,101,118, 97,114,
46.361 - 40,116,121,112,101, 41, 10,105,102, 32,116,121,112,101, 32,
46.362 - 61, 61, 32, 39, 39, 32,111,114, 32,116,121,112,101, 32, 61,
46.363 - 61, 32, 39,118,111,105,100, 39, 32,116,104,101,110, 10,114,
46.364 - 101,116,117,114,110, 32,116,121,112,101, 10,101,108,115,101,
46.365 - 10,108,111, 99, 97,108, 32,102,116, 32, 61, 32,102,105,110,
46.366 - 100,116,121,112,101, 40,116,121,112,101, 41, 10,105,102, 32,
46.367 - 102,116, 32,116,104,101,110, 10,114,101,116,117,114,110, 32,
46.368 - 102,116, 10,101,110,100, 10, 95,117,115,101,114,116,121,112,
46.369 - 101, 91,116,121,112,101, 93, 32, 61, 32,116,121,112,101, 10,
46.370 - 114,101,116,117,114,110, 32,116,121,112,101, 10,101,110,100,
46.371 - 10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32,105,
46.372 - 115, 98, 97,115,105, 99, 32, 40,116,121,112,101, 41, 10,108,
46.373 - 111, 99, 97,108, 32,116, 32, 61, 32,103,115,117, 98, 40,116,
46.374 - 121,112,101, 44, 39, 99,111,110,115,116, 32, 39, 44, 39, 39,
46.375 - 41, 10,108,111, 99, 97,108, 32,109, 44,116, 32, 61, 32, 97,
46.376 - 112,112,108,121,116,121,112,101,100,101,102, 40, 39, 39, 44,
46.377 - 32,116, 41, 10,108,111, 99, 97,108, 32, 98, 32, 61, 32, 95,
46.378 - 98, 97,115,105, 99, 91,116, 93, 10,105,102, 32, 98, 32,116,
46.379 - 104,101,110, 10,114,101,116,117,114,110, 32, 98, 44, 95, 98,
46.380 - 97,115,105, 99, 95, 99,116,121,112,101, 91, 98, 93, 10,101,
46.381 - 110,100, 10,114,101,116,117,114,110, 32,110,105,108, 10,101,
46.382 - 110,100, 10,102,117,110, 99,116,105,111,110, 32,115,112,108,
46.383 - 105,116, 32, 40,115, 44,116, 41, 10,108,111, 99, 97,108, 32,
46.384 - 108, 32, 61, 32,123,110, 61, 48,125, 10,108,111, 99, 97,108,
46.385 - 32,102, 32, 61, 32,102,117,110, 99,116,105,111,110, 32, 40,
46.386 - 115, 41, 10,108, 46,110, 32, 61, 32,108, 46,110, 32, 43, 32,
46.387 - 49, 10,108, 91,108, 46,110, 93, 32, 61, 32,115, 10,101,110,
46.388 - 100, 10,108,111, 99, 97,108, 32,112, 32, 61, 32, 34, 37,115,
46.389 - 42, 40, 46, 45, 41, 37,115, 42, 34, 46, 46,116, 46, 46, 34,
46.390 - 37,115, 42, 34, 10,115, 32, 61, 32,103,115,117, 98, 40,115,
46.391 - 44, 34, 94, 37,115, 43, 34, 44, 34, 34, 41, 10,115, 32, 61,
46.392 - 32,103,115,117, 98, 40,115, 44, 34, 37,115, 43, 36, 34, 44,
46.393 - 34, 34, 41, 10,115, 32, 61, 32,103,115,117, 98, 40,115, 44,
46.394 - 112, 44,102, 41, 10,108, 46,110, 32, 61, 32,108, 46,110, 32,
46.395 - 43, 32, 49, 10,108, 91,108, 46,110, 93, 32, 61, 32,103,115,
46.396 - 117, 98, 40,115, 44, 34, 40, 37,115, 37,115, 42, 41, 36, 34,
46.397 - 44, 34, 34, 41, 10,114,101,116,117,114,110, 32,108, 10,101,
46.398 - 110,100, 10,102,117,110, 99,116,105,111,110, 32,115,112,108,
46.399 - 105,116, 95, 99, 95,116,111,107,101,110,115, 40,115, 44, 32,
46.400 - 112, 97,116, 41, 10,115, 32, 61, 32,115,116,114,105,110,103,
46.401 - 46,103,115,117, 98, 40,115, 44, 32, 34, 94, 37,115, 42, 34,
46.402 - 44, 32, 34, 34, 41, 10,115, 32, 61, 32,115,116,114,105,110,
46.403 - 103, 46,103,115,117, 98, 40,115, 44, 32, 34, 37,115, 42, 36,
46.404 - 34, 44, 32, 34, 34, 41, 10,108,111, 99, 97,108, 32,116,111,
46.405 - 107,101,110, 95, 98,101,103,105,110, 32, 61, 32, 49, 10,108,
46.406 - 111, 99, 97,108, 32,116,111,107,101,110, 95,101,110,100, 32,
46.407 - 61, 32, 49, 10,108,111, 99, 97,108, 32,111,102,115, 32, 61,
46.408 - 32, 49, 10,108,111, 99, 97,108, 32,114,101,116, 32, 61, 32,
46.409 - 123,110, 61, 48,125, 10,102,117,110, 99,116,105,111,110, 32,
46.410 - 97,100,100, 95,116,111,107,101,110, 40,111,102,115, 41, 10,
46.411 - 108,111, 99, 97,108, 32,116, 32, 61, 32,115,116,114,105,110,
46.412 - 103, 46,115,117, 98, 40,115, 44, 32,116,111,107,101,110, 95,
46.413 - 98,101,103,105,110, 44, 32,111,102,115, 41, 10,116, 32, 61,
46.414 - 32,115,116,114,105,110,103, 46,103,115,117, 98, 40,116, 44,
46.415 - 32, 34, 94, 37,115, 42, 34, 44, 32, 34, 34, 41, 10,116, 32,
46.416 - 61, 32,115,116,114,105,110,103, 46,103,115,117, 98, 40,116,
46.417 - 44, 32, 34, 37,115, 42, 36, 34, 44, 32, 34, 34, 41, 10,114,
46.418 - 101,116, 46,110, 32, 61, 32,114,101,116, 46,110, 32, 43, 32,
46.419 - 49, 10,114,101,116, 91,114,101,116, 46,110, 93, 32, 61, 32,
46.420 - 116, 10,101,110,100, 10,119,104,105,108,101, 32,111,102,115,
46.421 - 32, 60, 61, 32,115,116,114,105,110,103, 46,108,101,110, 40,
46.422 - 115, 41, 32,100,111, 10,108,111, 99, 97,108, 32,115,117, 98,
46.423 - 32, 61, 32,115,116,114,105,110,103, 46,115,117, 98, 40,115,
46.424 - 44, 32,111,102,115, 44, 32, 45, 49, 41, 10,108,111, 99, 97,
46.425 - 108, 32, 98, 44,101, 32, 61, 32,115,116,114,105,110,103, 46,
46.426 - 102,105,110,100, 40,115,117, 98, 44, 32, 34, 94, 34, 46, 46,
46.427 - 112, 97,116, 41, 10,105,102, 32, 98, 32,116,104,101,110, 10,
46.428 - 97,100,100, 95,116,111,107,101,110, 40,111,102,115, 45, 49,
46.429 - 41, 10,111,102,115, 32, 61, 32,111,102,115, 43,101, 10,116,
46.430 - 111,107,101,110, 95, 98,101,103,105,110, 32, 61, 32,111,102,
46.431 - 115, 10,101,108,115,101, 10,108,111, 99, 97,108, 32, 99,104,
46.432 - 97,114, 32, 61, 32,115,116,114,105,110,103, 46,115,117, 98,
46.433 - 40,115, 44, 32,111,102,115, 44, 32,111,102,115, 41, 10,105,
46.434 - 102, 32, 99,104, 97,114, 32, 61, 61, 32, 34, 40, 34, 32,111,
46.435 - 114, 32, 99,104, 97,114, 32, 61, 61, 32, 34, 60, 34, 32,116,
46.436 - 104,101,110, 10,108,111, 99, 97,108, 32, 98,108,111, 99,107,
46.437 - 10,105,102, 32, 99,104, 97,114, 32, 61, 61, 32, 34, 40, 34,
46.438 - 32,116,104,101,110, 32, 98,108,111, 99,107, 32, 61, 32, 34,
46.439 - 94, 37, 98, 40, 41, 34, 32,101,110,100, 10,105,102, 32, 99,
46.440 - 104, 97,114, 32, 61, 61, 32, 34, 60, 34, 32,116,104,101,110,
46.441 - 32, 98,108,111, 99,107, 32, 61, 32, 34, 94, 37, 98, 60, 62,
46.442 - 34, 32,101,110,100, 10, 98, 44,101, 32, 61, 32,115,116,114,
46.443 - 105,110,103, 46,102,105,110,100, 40,115,117, 98, 44, 32, 98,
46.444 - 108,111, 99,107, 41, 10,105,102, 32,110,111,116, 32, 98, 32,
46.445 - 116,104,101,110, 10,111,102,115, 32, 61, 32,111,102,115, 43,
46.446 - 49, 10,101,108,115,101, 10,111,102,115, 32, 61, 32,111,102,
46.447 - 115, 32, 43, 32,101, 10,101,110,100, 10,101,108,115,101, 10,
46.448 - 111,102,115, 32, 61, 32,111,102,115, 43, 49, 10,101,110,100,
46.449 - 10,101,110,100, 10,101,110,100, 10, 97,100,100, 95,116,111,
46.450 - 107,101,110, 40,111,102,115, 41, 10,114,101,116,117,114,110,
46.451 - 32,114,101,116, 10,101,110,100, 10,102,117,110, 99,116,105,
46.452 - 111,110, 32, 99,111,110, 99, 97,116, 32, 40,116, 44,102, 44,
46.453 - 108, 44,106,115,116,114, 41, 10,106,115,116,114, 32, 61, 32,
46.454 - 106,115,116,114, 32,111,114, 32, 34, 32, 34, 10,108,111, 99,
46.455 - 97,108, 32,115, 32, 61, 32, 39, 39, 10,108,111, 99, 97,108,
46.456 - 32,105, 61,102, 10,119,104,105,108,101, 32,105, 60, 61,108,
46.457 - 32,100,111, 10,115, 32, 61, 32,115, 46, 46,116, 91,105, 93,
46.458 - 10,105, 32, 61, 32,105, 43, 49, 10,105,102, 32,105, 32, 60,
46.459 - 61, 32,108, 32,116,104,101,110, 32,115, 32, 61, 32,115, 46,
46.460 - 46,106,115,116,114, 32,101,110,100, 10,101,110,100, 10,114,
46.461 - 101,116,117,114,110, 32,115, 10,101,110,100, 10,102,117,110,
46.462 - 99,116,105,111,110, 32, 99,111,110, 99, 97,116,112, 97,114,
46.463 - 97,109, 32, 40,108,105,110,101, 44, 32, 46, 46, 46, 41, 10,
46.464 - 108,111, 99, 97,108, 32,105, 61, 49, 10,119,104,105,108,101,
46.465 - 32,105, 60, 61, 97,114,103, 46,110, 32,100,111, 10,105,102,
46.466 - 32, 95, 99,111,110,116, 32, 97,110,100, 32,110,111,116, 32,
46.467 - 115,116,114,102,105,110,100, 40, 95, 99,111,110,116, 44, 39,
46.468 - 91, 37, 40, 44, 34, 93, 39, 41, 32, 97,110,100, 10,115,116,
46.469 - 114,102,105,110,100, 40, 97,114,103, 91,105, 93, 44, 34, 94,
46.470 - 91, 37, 97, 95,126, 93, 34, 41, 32,116,104,101,110, 10,108,
46.471 - 105,110,101, 32, 61, 32,108,105,110,101, 32, 46, 46, 32, 39,
46.472 - 32, 39, 10,101,110,100, 10,108,105,110,101, 32, 61, 32,108,
46.473 - 105,110,101, 32, 46, 46, 32, 97,114,103, 91,105, 93, 10,105,
46.474 - 102, 32, 97,114,103, 91,105, 93, 32,126, 61, 32, 39, 39, 32,
46.475 - 116,104,101,110, 10, 95, 99,111,110,116, 32, 61, 32,115,116,
46.476 - 114,115,117, 98, 40, 97,114,103, 91,105, 93, 44, 45, 49, 44,
46.477 - 45, 49, 41, 10,101,110,100, 10,105, 32, 61, 32,105, 43, 49,
46.478 - 10,101,110,100, 10,105,102, 32,115,116,114,102,105,110,100,
46.479 - 40, 97,114,103, 91, 97,114,103, 46,110, 93, 44, 34, 91, 37,
46.480 - 47, 37, 41, 37, 59, 37,123, 37,125, 93, 36, 34, 41, 32,116,
46.481 - 104,101,110, 10, 95, 99,111,110,116, 61,110,105,108, 32,108,
46.482 - 105,110,101, 32, 61, 32,108,105,110,101, 32, 46, 46, 32, 39,
46.483 - 92,110, 39, 10,101,110,100, 10,114,101,116,117,114,110, 32,
46.484 - 108,105,110,101, 10,101,110,100, 10,102,117,110, 99,116,105,
46.485 - 111,110, 32,111,117,116,112,117,116, 32, 40, 46, 46, 46, 41,
46.486 - 10,108,111, 99, 97,108, 32,105, 61, 49, 10,119,104,105,108,
46.487 - 101, 32,105, 60, 61, 97,114,103, 46,110, 32,100,111, 10,105,
46.488 - 102, 32, 95, 99,111,110,116, 32, 97,110,100, 32,110,111,116,
46.489 - 32,115,116,114,102,105,110,100, 40, 95, 99,111,110,116, 44,
46.490 - 39, 91, 37, 40, 44, 34, 93, 39, 41, 32, 97,110,100, 10,115,
46.491 - 116,114,102,105,110,100, 40, 97,114,103, 91,105, 93, 44, 34,
46.492 - 94, 91, 37, 97, 95,126, 93, 34, 41, 32,116,104,101,110, 10,
46.493 - 119,114,105,116,101, 40, 39, 32, 39, 41, 10,101,110,100, 10,
46.494 - 119,114,105,116,101, 40, 97,114,103, 91,105, 93, 41, 10,105,
46.495 - 102, 32, 97,114,103, 91,105, 93, 32,126, 61, 32, 39, 39, 32,
46.496 - 116,104,101,110, 10, 95, 99,111,110,116, 32, 61, 32,115,116,
46.497 - 114,115,117, 98, 40, 97,114,103, 91,105, 93, 44, 45, 49, 44,
46.498 - 45, 49, 41, 10,101,110,100, 10,105, 32, 61, 32,105, 43, 49,
46.499 - 10,101,110,100, 10,105,102, 32,115,116,114,102,105,110,100,
46.500 - 40, 97,114,103, 91, 97,114,103, 46,110, 93, 44, 34, 91, 37,
46.501 - 47, 37, 41, 37, 59, 37,123, 37,125, 93, 36, 34, 41, 32,116,
46.502 - 104,101,110, 10, 95, 99,111,110,116, 61,110,105,108, 32,119,
46.503 - 114,105,116,101, 40, 39, 92,110, 39, 41, 10,101,110,100, 10,
46.504 - 101,110,100, 10,102,117,110, 99,116,105,111,110, 32,103,101,
46.505 - 116, 95,112,114,111,112,101,114,116,121, 95,109,101,116,104,
46.506 - 111,100,115, 40,112,116,121,112,101, 44, 32,110, 97,109,101,
46.507 - 41, 10,105,102, 32,103,101,116, 95,112,114,111,112,101,114,
46.508 - 116,121, 95,109,101,116,104,111,100,115, 95,104,111,111,107,
46.509 - 32, 97,110,100, 32,103,101,116, 95,112,114,111,112,101,114,
46.510 - 116,121, 95,109,101,116,104,111,100,115, 95,104,111,111,107,
46.511 - 40,112,116,121,112,101, 44,110, 97,109,101, 41, 32,116,104,
46.512 - 101,110, 10,114,101,116,117,114,110, 32,103,101,116, 95,112,
46.513 - 114,111,112,101,114,116,121, 95,109,101,116,104,111,100,115,
46.514 - 95,104,111,111,107, 40,112,116,121,112,101, 44, 32,110, 97,
46.515 - 109,101, 41, 10,101,110,100, 10,105,102, 32,112,116,121,112,
46.516 - 101, 32, 61, 61, 32, 34,100,101,102, 97,117,108,116, 34, 32,
46.517 - 116,104,101,110, 10,114,101,116,117,114,110, 32, 34,103,101,
46.518 - 116, 95, 34, 46, 46,110, 97,109,101, 44, 32, 34,115,101,116,
46.519 - 95, 34, 46, 46,110, 97,109,101, 10,101,110,100, 10,105,102,
46.520 - 32,112,116,121,112,101, 32, 61, 61, 32, 34,113,116, 34, 32,
46.521 - 116,104,101,110, 10,114,101,116,117,114,110, 32,110, 97,109,
46.522 - 101, 44, 32, 34,115,101,116, 34, 46, 46,115,116,114,105,110,
46.523 - 103, 46,117,112,112,101,114, 40,115,116,114,105,110,103, 46,
46.524 - 115,117, 98, 40,110, 97,109,101, 44, 32, 49, 44, 32, 49, 41,
46.525 - 41, 46, 46,115,116,114,105,110,103, 46,115,117, 98, 40,110,
46.526 - 97,109,101, 44, 32, 50, 44, 32, 45, 49, 41, 10,101,110,100,
46.527 - 10,105,102, 32,112,116,121,112,101, 32, 61, 61, 32, 34,111,
46.528 - 118,101,114,108,111, 97,100, 34, 32,116,104,101,110, 10,114,
46.529 - 101,116,117,114,110, 32,110, 97,109,101, 44,110, 97,109,101,
46.530 - 10,101,110,100, 10,114,101,116,117,114,110, 32,110,105,108,
46.531 - 10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32,112,
46.532 - 114,101,112,114,111, 99,101,115,115, 95,104,111,111,107, 40,
46.533 - 112, 41, 10,101,110,100, 10,102,117,110, 99,116,105,111,110,
46.534 - 32,105,110, 99,108,117,100,101, 95,102,105,108,101, 95,104,
46.535 - 111,111,107, 40,116, 44, 32,102,105,108,101,110, 97,109,101,
46.536 - 44, 32, 46, 46, 46, 41, 10,101,110,100, 10,102,117,110, 99,
46.537 - 116,105,111,110, 32,112,114,101,112, 97,114,115,101, 95,104,
46.538 - 111,111,107, 40,112, 97, 99,107, 97,103,101, 41, 10,101,110,
46.539 - 100, 10,102,117,110, 99,116,105,111,110, 32,112,111,115,116,
46.540 - 95,111,117,116,112,117,116, 95,104,111,111,107, 40,112, 97,
46.541 - 99,107, 97,103,101, 41, 10,101,110,100, 10,102,117,110, 99,
46.542 - 116,105,111,110, 32,103,101,116, 95,112,114,111,112,101,114,
46.543 - 116,121, 95,109,101,116,104,111,100,115, 95,104,111,111,107,
46.544 - 40,112,114,111,112,101,114,116,121, 95,116,121,112,101, 44,
46.545 - 32,110, 97,109,101, 41, 10,101,110,100,32
46.546 - };
46.547 - lua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 2");
46.548 - } /* end of embedded lua code */
46.549 -
46.550 -
46.551 - { /* begin embedded lua code */
46.552 - static unsigned char B[] = {
46.553 - 10, 99,108, 97,115,115, 70,101, 97,116,117,114,101, 32, 61,
46.554 - 32,123, 10,125, 10, 99,108, 97,115,115, 70,101, 97,116,117,
46.555 - 114,101, 46, 95, 95,105,110,100,101,120, 32, 61, 32, 99,108,
46.556 - 97,115,115, 70,101, 97,116,117,114,101, 10,102,117,110, 99,
46.557 - 116,105,111,110, 32, 99,108, 97,115,115, 70,101, 97,116,117,
46.558 - 114,101, 58,115,117,112, 99,111,100,101, 32, 40, 41, 10,101,
46.559 - 110,100, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,
46.560 - 115,115, 70,101, 97,116,117,114,101, 58,100,101, 99,108,116,
46.561 - 121,112,101, 32, 40, 41, 10,101,110,100, 10,102,117,110, 99,
46.562 - 116,105,111,110, 32, 99,108, 97,115,115, 70,101, 97,116,117,
46.563 - 114,101, 58,114,101,103,105,115,116,101,114, 32, 40, 41, 10,
46.564 - 101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 99,108,
46.565 - 97,115,115, 70,101, 97,116,117,114,101, 58,112,114,101, 97,
46.566 - 109, 98,108,101, 32, 40, 41, 10,101,110,100, 10,102,117,110,
46.567 - 99,116,105,111,110, 32, 99,108, 97,115,115, 70,101, 97,116,
46.568 - 117,114,101, 58,105,115,118, 97,114,105, 97, 98,108,101, 32,
46.569 - 40, 41, 10,114,101,116,117,114,110, 32,102, 97,108,115,101,
46.570 - 10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 99,
46.571 - 108, 97,115,115, 70,101, 97,116,117,114,101, 58,114,101,113,
46.572 - 117,105,114,101, 99,111,108,108,101, 99,116,105,111,110, 32,
46.573 - 40,116, 41, 10,114,101,116,117,114,110, 32,102, 97,108,115,
46.574 - 101, 10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32,
46.575 - 99,108, 97,115,115, 70,101, 97,116,117,114,101, 58, 98,117,
46.576 - 105,108,100,110, 97,109,101,115, 32, 40, 41, 10,105,102, 32,
46.577 - 115,101,108,102, 46,110, 97,109,101, 32, 97,110,100, 32,115,
46.578 - 101,108,102, 46,110, 97,109,101,126, 61, 39, 39, 32,116,104,
46.579 - 101,110, 10,108,111, 99, 97,108, 32,110, 32, 61, 32,115,112,
46.580 - 108,105,116, 40,115,101,108,102, 46,110, 97,109,101, 44, 39,
46.581 - 64, 39, 41, 10,115,101,108,102, 46,110, 97,109,101, 32, 61,
46.582 - 32,110, 91, 49, 93, 10,105,102, 32,110,111,116, 32,110, 91,
46.583 - 50, 93, 32,116,104,101,110, 10,110, 91, 50, 93, 32, 61, 32,
46.584 - 97,112,112,108,121,114,101,110, 97,109,105,110,103, 40,110,
46.585 - 91, 49, 93, 41, 10,101,110,100, 10,115,101,108,102, 46,108,
46.586 - 110, 97,109,101, 32, 61, 32,110, 91, 50, 93, 32,111,114, 32,
46.587 - 103,115,117, 98, 40,110, 91, 49, 93, 44, 34, 37, 91, 46, 45,
46.588 - 37, 93, 34, 44, 34, 34, 41, 10,115,101,108,102, 46,111,114,
46.589 - 105,103,105,110, 97,108, 95,110, 97,109,101, 32, 61, 32,115,
46.590 - 101,108,102, 46,110, 97,109,101, 10,115,101,108,102, 46,108,
46.591 - 110, 97,109,101, 32, 61, 32, 99,108,101, 97,110, 95,116,101,
46.592 - 109,112,108, 97,116,101, 40,115,101,108,102, 46,108,110, 97,
46.593 - 109,101, 41, 10,101,110,100, 10,105,102, 32,110,111,116, 32,
46.594 - 115,101,108,102, 46,105,115, 95,112, 97,114, 97,109,101,116,
46.595 - 101,114, 32,116,104,101,110, 10,115,101,108,102, 46,110, 97,
46.596 - 109,101, 32, 61, 32,103,101,116,111,110,108,121,110, 97,109,
46.597 - 101,115,112, 97, 99,101, 40, 41, 32, 46, 46, 32,115,101,108,
46.598 - 102, 46,110, 97,109,101, 10,101,110,100, 10,101,110,100, 10,
46.599 - 102,117,110, 99,116,105,111,110, 32, 99,108,101, 97,110, 95,
46.600 - 116,101,109,112,108, 97,116,101, 40,116, 41, 10,114,101,116,
46.601 - 117,114,110, 32,115,116,114,105,110,103, 46,103,115,117, 98,
46.602 - 40,116, 44, 32, 34, 91, 60, 62, 58, 44, 32, 37, 42, 93, 34,
46.603 - 44, 32, 34, 95, 34, 41, 10,101,110,100, 10,102,117,110, 99,
46.604 - 116,105,111,110, 32, 99,108, 97,115,115, 70,101, 97,116,117,
46.605 - 114,101, 58,105,110, 99,111,110,116, 97,105,110,101,114, 32,
46.606 - 40,119,104,105, 99,104, 41, 10,105,102, 32,115,101,108,102,
46.607 - 46,112, 97,114,101,110,116, 32,116,104,101,110, 10,108,111,
46.608 - 99, 97,108, 32,112, 97,114,101,110,116, 32, 61, 32,115,101,
46.609 - 108,102, 46,112, 97,114,101,110,116, 10,119,104,105,108,101,
46.610 - 32,112, 97,114,101,110,116, 32,100,111, 10,105,102, 32,112,
46.611 - 97,114,101,110,116, 46, 99,108, 97,115,115,116,121,112,101,
46.612 - 32, 61, 61, 32,119,104,105, 99,104, 32,116,104,101,110, 10,
46.613 - 114,101,116,117,114,110, 32,112, 97,114,101,110,116, 46,110,
46.614 - 97,109,101, 10,101,110,100, 10,112, 97,114,101,110,116, 32,
46.615 - 61, 32,112, 97,114,101,110,116, 46,112, 97,114,101,110,116,
46.616 - 10,101,110,100, 10,101,110,100, 10,114,101,116,117,114,110,
46.617 - 32,110,105,108, 10,101,110,100, 10,102,117,110, 99,116,105,
46.618 - 111,110, 32, 99,108, 97,115,115, 70,101, 97,116,117,114,101,
46.619 - 58,105,110, 99,108, 97,115,115, 32, 40, 41, 10,114,101,116,
46.620 - 117,114,110, 32,115,101,108,102, 58,105,110, 99,111,110,116,
46.621 - 97,105,110,101,114, 40, 39, 99,108, 97,115,115, 39, 41, 10,
46.622 - 101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 99,108,
46.623 - 97,115,115, 70,101, 97,116,117,114,101, 58,105,110,109,111,
46.624 - 100,117,108,101, 32, 40, 41, 10,114,101,116,117,114,110, 32,
46.625 - 115,101,108,102, 58,105,110, 99,111,110,116, 97,105,110,101,
46.626 - 114, 40, 39,109,111,100,117,108,101, 39, 41, 10,101,110,100,
46.627 - 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115,
46.628 - 70,101, 97,116,117,114,101, 58,105,110,110, 97,109,101,115,
46.629 - 112, 97, 99,101, 32, 40, 41, 10,114,101,116,117,114,110, 32,
46.630 - 115,101,108,102, 58,105,110, 99,111,110,116, 97,105,110,101,
46.631 - 114, 40, 39,110, 97,109,101,115,112, 97, 99,101, 39, 41, 10,
46.632 - 101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 99,108,
46.633 - 97,115,115, 70,101, 97,116,117,114,101, 58, 99,102,117,110,
46.634 - 99,110, 97,109,101, 32, 40,110, 41, 10,105,102, 32,115,101,
46.635 - 108,102, 46,112, 97,114,101,110,116, 32,116,104,101,110, 10,
46.636 - 110, 32, 61, 32,115,101,108,102, 46,112, 97,114,101,110,116,
46.637 - 58, 99,102,117,110, 99,110, 97,109,101, 40,110, 41, 10,101,
46.638 - 110,100, 10,110, 32, 61, 32,115,116,114,105,110,103, 46,103,
46.639 - 115,117, 98, 40,110, 46, 46, 39, 95, 39, 46, 46, 32, 40,115,
46.640 - 101,108,102, 46,108,110, 97,109,101, 32,111,114, 32,115,101,
46.641 - 108,102, 46,110, 97,109,101, 41, 44, 32, 34, 91, 60, 62, 58,
46.642 - 44, 32, 92, 46, 37, 42, 93, 34, 44, 32, 34, 95, 34, 41, 10,
46.643 - 114,101,116,117,114,110, 32,110, 10,101,110,100,32
46.644 - };
46.645 - lua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 3");
46.646 - } /* end of embedded lua code */
46.647 -
46.648 -
46.649 - { /* begin embedded lua code */
46.650 - static unsigned char B[] = {
46.651 - 10, 99,108, 97,115,115, 86,101,114, 98, 97,116,105,109, 32,
46.652 - 61, 32,123, 10,108,105,110,101, 32, 61, 32, 39, 39, 44, 10,
46.653 - 99,111,110,100, 32, 61, 32,110,105,108, 44, 10,125, 10, 99,
46.654 - 108, 97,115,115, 86,101,114, 98, 97,116,105,109, 46, 95, 95,
46.655 - 105,110,100,101,120, 32, 61, 32, 99,108, 97,115,115, 86,101,
46.656 - 114, 98, 97,116,105,109, 10,115,101,116,109,101,116, 97,116,
46.657 - 97, 98,108,101, 40, 99,108, 97,115,115, 86,101,114, 98, 97,
46.658 - 116,105,109, 44, 99,108, 97,115,115, 70,101, 97,116,117,114,
46.659 - 101, 41, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,
46.660 - 115,115, 86,101,114, 98, 97,116,105,109, 58,112,114,101, 97,
46.661 - 109, 98,108,101, 32, 40, 41, 10,105,102, 32,115,101,108,102,
46.662 - 46, 99,111,110,100, 32, 61, 61, 32, 39, 39, 32,116,104,101,
46.663 - 110, 10,119,114,105,116,101, 40,115,101,108,102, 46,108,105,
46.664 - 110,101, 41, 10,101,110,100, 10,101,110,100, 10,102,117,110,
46.665 - 99,116,105,111,110, 32, 99,108, 97,115,115, 86,101,114, 98,
46.666 - 97,116,105,109, 58,115,117,112, 99,111,100,101, 32, 40, 41,
46.667 - 10,105,102, 32,115,116,114,102,105,110,100, 40,115,101,108,
46.668 - 102, 46, 99,111,110,100, 44, 39,115, 39, 41, 32,116,104,101,
46.669 - 110, 10,119,114,105,116,101, 40,115,101,108,102, 46,108,105,
46.670 - 110,101, 41, 10,119,114,105,116,101, 40, 39, 92,110, 39, 41,
46.671 - 10,101,110,100, 10,101,110,100, 10,102,117,110, 99,116,105,
46.672 - 111,110, 32, 99,108, 97,115,115, 86,101,114, 98, 97,116,105,
46.673 - 109, 58,114,101,103,105,115,116,101,114, 32, 40, 41, 10,105,
46.674 - 102, 32,115,116,114,102,105,110,100, 40,115,101,108,102, 46,
46.675 - 99,111,110,100, 44, 39,114, 39, 41, 32,116,104,101,110, 10,
46.676 - 119,114,105,116,101, 40,115,101,108,102, 46,108,105,110,101,
46.677 - 41, 10,101,110,100, 10,101,110,100, 10,102,117,110, 99,116,
46.678 - 105,111,110, 32, 99,108, 97,115,115, 86,101,114, 98, 97,116,
46.679 - 105,109, 58,112,114,105,110,116, 32, 40,105,100,101,110,116,
46.680 - 44, 99,108,111,115,101, 41, 10,112,114,105,110,116, 40,105,
46.681 - 100,101,110,116, 46, 46, 34, 86,101,114, 98, 97,116,105,109,
46.682 - 123, 34, 41, 10,112,114,105,110,116, 40,105,100,101,110,116,
46.683 - 46, 46, 34, 32,108,105,110,101, 32, 61, 32, 39, 34, 46, 46,
46.684 - 115,101,108,102, 46,108,105,110,101, 46, 46, 34, 39, 44, 34,
46.685 - 41, 10,112,114,105,110,116, 40,105,100,101,110,116, 46, 46,
46.686 - 34,125, 34, 46, 46, 99,108,111,115,101, 41, 10,101,110,100,
46.687 - 10,102,117,110, 99,116,105,111,110, 32, 95, 86,101,114, 98,
46.688 - 97,116,105,109, 32, 40,116, 41, 10,115,101,116,109,101,116,
46.689 - 97,116, 97, 98,108,101, 40,116, 44, 99,108, 97,115,115, 86,
46.690 - 101,114, 98, 97,116,105,109, 41, 10, 97,112,112,101,110,100,
46.691 - 40,116, 41, 10,114,101,116,117,114,110, 32,116, 10,101,110,
46.692 - 100, 10,102,117,110, 99,116,105,111,110, 32, 86,101,114, 98,
46.693 - 97,116,105,109, 32, 40,108, 44, 99,111,110,100, 41, 10,105,
46.694 - 102, 32,115,116,114,115,117, 98, 40,108, 44, 49, 44, 49, 41,
46.695 - 32, 61, 61, 32, 39, 36, 39, 32,116,104,101,110, 10, 99,111,
46.696 - 110,100, 32, 61, 32, 39,115,114, 39, 10,108, 32, 61, 32,115,
46.697 - 116,114,115,117, 98, 40,108, 44, 50, 41, 10,101,110,100, 10,
46.698 - 114,101,116,117,114,110, 32, 95, 86,101,114, 98, 97,116,105,
46.699 - 109, 32,123, 10,108,105,110,101, 32, 61, 32,108, 44, 10, 99,
46.700 - 111,110,100, 32, 61, 32, 99,111,110,100, 32,111,114, 32, 39,
46.701 - 39, 44, 10,125, 10,101,110,100,32
46.702 - };
46.703 - lua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 4");
46.704 - } /* end of embedded lua code */
46.705 -
46.706 -
46.707 - { /* begin embedded lua code */
46.708 - static unsigned char B[] = {
46.709 - 10, 99,111,100,101, 95,110, 32, 61, 32, 49, 10, 99,108, 97,
46.710 - 115,115, 67,111,100,101, 32, 61, 32,123, 10,116,101,120,116,
46.711 - 32, 61, 32, 39, 39, 44, 10,125, 10, 99,108, 97,115,115, 67,
46.712 - 111,100,101, 46, 95, 95,105,110,100,101,120, 32, 61, 32, 99,
46.713 - 108, 97,115,115, 67,111,100,101, 10,115,101,116,109,101,116,
46.714 - 97,116, 97, 98,108,101, 40, 99,108, 97,115,115, 67,111,100,
46.715 - 101, 44, 99,108, 97,115,115, 70,101, 97,116,117,114,101, 41,