├── Demo ├── Builds │ ├── Linux │ │ └── Makefile │ ├── MacOSX │ │ ├── Info.plist │ │ └── LuaBridgeDemo.xcodeproj │ │ │ └── project.pbxproj │ ├── VisualStudio2008 │ │ ├── LuaBridgeDemo.sln │ │ ├── LuaBridgeDemo.vcproj │ │ └── resources.rc │ └── VisualStudio2010 │ │ ├── LuaBridgeDemo.sln │ │ ├── LuaBridgeDemo.vcxproj │ │ ├── LuaBridgeDemo.vcxproj.filters │ │ └── resources.rc ├── JUCEAmalgam │ ├── BRANCHES │ ├── COMMITLOG │ ├── README.md │ └── include │ │ ├── juce_audio_basics_amalgam.cpp │ │ ├── juce_audio_basics_amalgam.h │ │ ├── juce_audio_basics_amalgam.mm │ │ ├── juce_audio_devices_amalgam.cpp │ │ ├── juce_audio_devices_amalgam.h │ │ ├── juce_audio_devices_amalgam.mm │ │ ├── juce_audio_formats_amalgam.cpp │ │ ├── juce_audio_formats_amalgam.h │ │ ├── juce_audio_formats_amalgam.mm │ │ ├── juce_audio_processors_amalgam.cpp │ │ ├── juce_audio_processors_amalgam.h │ │ ├── juce_audio_processors_amalgam.mm │ │ ├── juce_audio_utils_amalgam.cpp │ │ ├── juce_audio_utils_amalgam.h │ │ ├── juce_audio_utils_amalgam.mm │ │ ├── juce_core_amalgam.cpp │ │ ├── juce_core_amalgam.h │ │ ├── juce_core_amalgam.mm │ │ ├── juce_cryptography_amalgam.cpp │ │ ├── juce_cryptography_amalgam.h │ │ ├── juce_cryptography_amalgam.mm │ │ ├── juce_data_structures_amalgam.cpp │ │ ├── juce_data_structures_amalgam.h │ │ ├── juce_data_structures_amalgam.mm │ │ ├── juce_events_amalgam.cpp │ │ ├── juce_events_amalgam.h │ │ ├── juce_events_amalgam.mm │ │ ├── juce_graphics_amalgam.cpp │ │ ├── juce_graphics_amalgam.h │ │ ├── juce_graphics_amalgam.mm │ │ ├── juce_gui_basics_amalgam.cpp │ │ ├── juce_gui_basics_amalgam.h │ │ ├── juce_gui_basics_amalgam.mm │ │ ├── juce_gui_extra_amalgam.cpp │ │ ├── juce_gui_extra_amalgam.h │ │ ├── juce_gui_extra_amalgam.mm │ │ ├── juce_opengl_amalgam.cpp │ │ ├── juce_opengl_amalgam.h │ │ ├── juce_opengl_amalgam.mm │ │ ├── juce_video_amalgam.cpp │ │ ├── juce_video_amalgam.h │ │ └── juce_video_amalgam.mm ├── JuceLibraryCode │ ├── AppConfig.h │ ├── BinaryData.cpp │ ├── BinaryData.h │ ├── JuceHeader.h │ └── ReadMe.txt ├── LuaBridgeDemo.jucer └── Source │ ├── App.cpp │ ├── CConsole.cpp │ ├── CConsole.h │ ├── CConsoleEdit.cpp │ ├── CConsoleEdit.h │ ├── CConsoleText.cpp │ ├── CConsoleText.h │ ├── CConsoleWindow.cpp │ ├── CConsoleWindow.h │ ├── LuaState.cpp │ ├── LuaState.h │ ├── Main.cpp │ ├── NewTests.cpp │ ├── NewTests.h │ └── TestHost.h ├── Lua ├── Lua.5.1.5 │ ├── COPYRIGHT │ ├── HISTORY │ ├── INSTALL │ ├── Makefile │ ├── README │ ├── doc │ │ ├── contents.html │ │ ├── cover.png │ │ ├── logo.gif │ │ ├── lua.1 │ │ ├── lua.css │ │ ├── lua.html │ │ ├── luac.1 │ │ ├── luac.html │ │ ├── manual.css │ │ ├── manual.html │ │ └── readme.html │ ├── etc │ │ ├── Makefile │ │ ├── README │ │ ├── all.c │ │ ├── lua.hpp │ │ ├── lua.ico │ │ ├── lua.pc │ │ ├── luavs.bat │ │ ├── min.c │ │ ├── noparser.c │ │ └── strict.lua │ ├── src │ │ ├── Makefile │ │ ├── lapi.c │ │ ├── lapi.h │ │ ├── lauxlib.c │ │ ├── lauxlib.h │ │ ├── lbaselib.c │ │ ├── lcode.c │ │ ├── lcode.h │ │ ├── ldblib.c │ │ ├── ldebug.c │ │ ├── ldebug.h │ │ ├── ldo.c │ │ ├── ldo.h │ │ ├── ldump.c │ │ ├── lfunc.c │ │ ├── lfunc.h │ │ ├── lgc.c │ │ ├── lgc.h │ │ ├── linit.c │ │ ├── liolib.c │ │ ├── llex.c │ │ ├── llex.h │ │ ├── llimits.h │ │ ├── lmathlib.c │ │ ├── lmem.c │ │ ├── lmem.h │ │ ├── loadlib.c │ │ ├── lobject.c │ │ ├── lobject.h │ │ ├── lopcodes.c │ │ ├── lopcodes.h │ │ ├── loslib.c │ │ ├── lparser.c │ │ ├── lparser.h │ │ ├── lstate.c │ │ ├── lstate.h │ │ ├── lstring.c │ │ ├── lstring.h │ │ ├── lstrlib.c │ │ ├── ltable.c │ │ ├── ltable.h │ │ ├── ltablib.c │ │ ├── ltm.c │ │ ├── ltm.h │ │ ├── lua.c │ │ ├── lua.h │ │ ├── luac.c │ │ ├── luaconf.h │ │ ├── lualib.h │ │ ├── lundump.c │ │ ├── lundump.h │ │ ├── lvm.c │ │ ├── lvm.h │ │ ├── lzio.c │ │ ├── lzio.h │ │ └── print.c │ └── test │ │ ├── README │ │ ├── bisect.lua │ │ ├── cf.lua │ │ ├── echo.lua │ │ ├── env.lua │ │ ├── factorial.lua │ │ ├── fib.lua │ │ ├── fibfor.lua │ │ ├── globals.lua │ │ ├── hello.lua │ │ ├── life.lua │ │ ├── luac.lua │ │ ├── printf.lua │ │ ├── readonly.lua │ │ ├── sieve.lua │ │ ├── sort.lua │ │ ├── table.lua │ │ ├── trace-calls.lua │ │ ├── trace-globals.lua │ │ └── xd.lua ├── Lua.5.2.0 │ ├── Makefile │ ├── README │ ├── doc │ │ ├── contents.html │ │ ├── logo.gif │ │ ├── lua.1 │ │ ├── lua.css │ │ ├── luac.1 │ │ ├── manual.css │ │ ├── manual.html │ │ ├── osi-certified-72x60.png │ │ └── readme.html │ └── src │ │ ├── Makefile │ │ ├── lapi.c │ │ ├── lapi.h │ │ ├── lauxlib.c │ │ ├── lauxlib.h │ │ ├── lbaselib.c │ │ ├── lbitlib.c │ │ ├── lcode.c │ │ ├── lcode.h │ │ ├── lcorolib.c │ │ ├── lctype.c │ │ ├── lctype.h │ │ ├── ldblib.c │ │ ├── ldebug.c │ │ ├── ldebug.h │ │ ├── ldo.c │ │ ├── ldo.h │ │ ├── ldump.c │ │ ├── lfunc.c │ │ ├── lfunc.h │ │ ├── lgc.c │ │ ├── lgc.h │ │ ├── linit.c │ │ ├── liolib.c │ │ ├── llex.c │ │ ├── llex.h │ │ ├── llimits.h │ │ ├── lmathlib.c │ │ ├── lmem.c │ │ ├── lmem.h │ │ ├── loadlib.c │ │ ├── lobject.c │ │ ├── lobject.h │ │ ├── lopcodes.c │ │ ├── lopcodes.h │ │ ├── loslib.c │ │ ├── lparser.c │ │ ├── lparser.h │ │ ├── lstate.c │ │ ├── lstate.h │ │ ├── lstring.c │ │ ├── lstring.h │ │ ├── lstrlib.c │ │ ├── ltable.c │ │ ├── ltable.h │ │ ├── ltablib.c │ │ ├── ltm.c │ │ ├── ltm.h │ │ ├── lua.c │ │ ├── lua.h │ │ ├── lua.hpp │ │ ├── luac.c │ │ ├── luaconf.h │ │ ├── lualib.h │ │ ├── lundump.c │ │ ├── lundump.h │ │ ├── lvm.c │ │ ├── lvm.h │ │ ├── lzio.c │ │ └── lzio.h ├── LuaLibrary.h ├── LuaLibrary5.1.5.cpp └── LuaLibrary5.2.0.cpp ├── LuaBridge ├── .gitignore ├── CHANGES ├── Doxyfile ├── LuaBridge.h ├── LuaBridgeExtras.h ├── README.md ├── RefCountedObject.h └── RefCountedPtr.h ├── README.md ├── Solutions └── VisualStudio2010 │ └── LuaBridge.sln └── Tests ├── Builds ├── Linux │ └── Makefile ├── MacOSX │ └── LuaBridgeTests.xcodeproj │ │ └── project.pbxproj ├── VisualStudio2008 │ ├── LuaBridgeTests.sln │ ├── LuaBridgeTests.vcproj │ └── resources.rc ├── VisualStudio2010 │ ├── LuaBridgeTests.sln │ ├── LuaBridgeTests.vcxproj │ ├── LuaBridgeTests.vcxproj.filters │ └── resources.rc └── iOS │ └── LuaBridgeTests.xcodeproj │ └── project.pbxproj ├── JuceLibraryCode ├── AppConfig.h ├── BinaryData.cpp ├── BinaryData.h ├── JuceHeader.h └── ReadMe.txt ├── LuaBridgeTests.jucer └── Source ├── Performance.cpp ├── Performance.h ├── Tests.cpp ├── Tests.h ├── Tests.lua └── TestsMain.cpp /Demo/Builds/MacOSX/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | CFBundleExecutable 7 | ${EXECUTABLE_NAME} 8 | CFBundleIconFile 9 | 10 | CFBundleIdentifier 11 | com.yourcompany.LuaBridgeDemo 12 | CFBundleName 13 | LuaBridgeDemo 14 | CFBundlePackageType 15 | APPL 16 | CFBundleSignature 17 | ???? 18 | CFBundleShortVersionString 19 | 1.0.0 20 | CFBundleVersion 21 | 1.0.0 22 | NSHumanReadableCopyright 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Demo/Builds/VisualStudio2008/LuaBridgeDemo.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 10.00 2 | # Visual C++ Express 2008 3 | Project("{8EC338BF-BCDD-F3E3-C66F-F7F361BB1A8A}") = "LuaBridgeDemo", "LuaBridgeDemo.vcproj", "{340ACBA7-0099-FD85-2AB7-7948DD2F983D}" 4 | EndProject 5 | Global 6 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 7 | Debug|Win32 = Debug|Win32 8 | Release|Win32 = Release|Win32 9 | EndGlobalSection 10 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 11 | {340ACBA7-0099-FD85-2AB7-7948DD2F983D}.Debug|Win32.ActiveCfg = Debug|Win32 12 | {340ACBA7-0099-FD85-2AB7-7948DD2F983D}.Debug|Win32.Build.0 = Debug|Win32 13 | {340ACBA7-0099-FD85-2AB7-7948DD2F983D}.Release|Win32.ActiveCfg = Release|Win32 14 | {340ACBA7-0099-FD85-2AB7-7948DD2F983D}.Release|Win32.Build.0 = Release|Win32 15 | EndGlobalSection 16 | GlobalSection(SolutionProperties) = preSolution 17 | HideSolutionNode = FALSE 18 | EndGlobalSection 19 | EndGlobal 20 | -------------------------------------------------------------------------------- /Demo/Builds/VisualStudio2008/resources.rc: -------------------------------------------------------------------------------- 1 | #undef WIN32_LEAN_AND_MEAN 2 | #define WIN32_LEAN_AND_MEAN 3 | #include 4 | 5 | VS_VERSION_INFO VERSIONINFO 6 | FILEVERSION 1,0,0,0 7 | BEGIN 8 | BLOCK "StringFileInfo" 9 | BEGIN 10 | BLOCK "040904E4" 11 | BEGIN 12 | VALUE "FileDescription", "LuaBridgeDemo\0" 13 | VALUE "FileVersion", "1.0.0\0" 14 | VALUE "ProductName", "LuaBridgeDemo\0" 15 | VALUE "ProductVersion", "1.0.0\0" 16 | END 17 | END 18 | 19 | BLOCK "VarFileInfo" 20 | BEGIN 21 | VALUE "Translation", 0x409, 65001 22 | END 23 | END 24 | -------------------------------------------------------------------------------- /Demo/Builds/VisualStudio2010/LuaBridgeDemo.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 11.00 2 | # Visual Studio 2010 3 | Project("{8EC338BF-BCDD-F3E3-C66F-F7F361BB1A8A}") = "LuaBridgeDemo", "LuaBridgeDemo.vcxproj", "{340ACBA7-0099-FD85-2AB7-7948DD2F983D}" 4 | EndProject 5 | Global 6 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 7 | Debug|Win32 = Debug|Win32 8 | Release|Win32 = Release|Win32 9 | EndGlobalSection 10 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 11 | {340ACBA7-0099-FD85-2AB7-7948DD2F983D}.Debug|Win32.ActiveCfg = Debug|Win32 12 | {340ACBA7-0099-FD85-2AB7-7948DD2F983D}.Debug|Win32.Build.0 = Debug|Win32 13 | {340ACBA7-0099-FD85-2AB7-7948DD2F983D}.Release|Win32.ActiveCfg = Release|Win32 14 | {340ACBA7-0099-FD85-2AB7-7948DD2F983D}.Release|Win32.Build.0 = Release|Win32 15 | EndGlobalSection 16 | GlobalSection(SolutionProperties) = preSolution 17 | HideSolutionNode = FALSE 18 | EndGlobalSection 19 | EndGlobal 20 | -------------------------------------------------------------------------------- /Demo/Builds/VisualStudio2010/resources.rc: -------------------------------------------------------------------------------- 1 | #undef WIN32_LEAN_AND_MEAN 2 | #define WIN32_LEAN_AND_MEAN 3 | #include 4 | 5 | VS_VERSION_INFO VERSIONINFO 6 | FILEVERSION 1,0,0,0 7 | BEGIN 8 | BLOCK "StringFileInfo" 9 | BEGIN 10 | BLOCK "040904E4" 11 | BEGIN 12 | VALUE "FileDescription", "LuaBridgeDemo\0" 13 | VALUE "FileVersion", "1.0.0\0" 14 | VALUE "ProductName", "LuaBridgeDemo\0" 15 | VALUE "ProductVersion", "1.0.0\0" 16 | END 17 | END 18 | 19 | BLOCK "VarFileInfo" 20 | BEGIN 21 | VALUE "Translation", 0x409, 65001 22 | END 23 | END 24 | -------------------------------------------------------------------------------- /Demo/JUCEAmalgam/BRANCHES: -------------------------------------------------------------------------------- 1 | Branches: 2 | 3 | master : Tracks the master branch of the official repository 4 | 5 | Use tags to obtain specific releases 6 | -------------------------------------------------------------------------------- /Demo/JUCEAmalgam/README.md: -------------------------------------------------------------------------------- 1 | # JUCE Amalgamation 2 | 3 | A distribution of the [JUCE][1] library in amalgamated source code form. 4 | 5 | ## What's an amalgamation? 6 | 7 | An amalgamation is simply a collection of header and source files that have been 8 | concatenated together to form one or more very large files. In this form, they 9 | are easy to add to your existing project as source files (rather than linking 10 | as a library). They are also easier to redistribute if you are making an open 11 | source application and don't want to have any external dependencies. 12 | 13 | ## What is JUCE? 14 | 15 | JUCE (Jules' Utility Class Extensions) is an all-encompassing C++ class library 16 | for developing cross-platform software. It contains pretty much everything 17 | you're likely to need to create most applications, and is particularly 18 | well-suited for building highly-customised GUIs, and for handling graphics 19 | and sound. JUCE can target the following platforms: 20 | 21 | **Mac OSX**: Applications and VST/AudioUnit/RTAS/NPAPI plugins can be compiled 22 | Xcode for OSX 10.4 or later. 23 | 24 | **iOS**: Native iPhone and iPad apps can be built with Xcode. 25 | 26 | **Windows**: Applications and VST/RTAS/NPAPI/ActiveX plugins can be built using 27 | MS Visual Studio. The results are all fully compatible with 28 | Windows XP, or Win7. 29 | 30 | **Linux**: Applications and plugins can be built for any kernel 2.6 or later. 31 | 32 | **Android**: Android apps can now be built using Ant and Eclipse, with the 33 | Android NDK v5 or later. 34 | 35 | For all the platforms above, the code that you write is the same, and you don't 36 | need to worry about any platform-specific details. If your C++ is portable, then 37 | you should be able to simply re-compile your app to run it on other OSes. 38 | 39 | ## How do I use this? 40 | 41 | JUCE is broken up into modules, with each module coming with its own pair of 42 | amalgamated source and header files. Add the desired amalgamated module sources 43 | to your existing project. For Macintosh and iOS targets you will use the ".mm" 44 | files. For all others, add the ".cpp" files. Include the corresponding header 45 | in your source code. You will need to create a file called "AppConfig.h" and 46 | configure your include paths so that it is visible to the JUCE amalgamated 47 | sources. 48 | 49 | The [JUCE Amalgmation][7] was built using the [Amalgamate Templates][3]. 50 | 51 | ## License 52 | 53 | Copyright 2004-11 by [Raw Material Software Ltd.][5]
54 | JUCE is released under the [GNU Public Licence][6], which means it can be freely 55 | copied and distributed, and costs nothing to use in open-source applications. If 56 | you'd like to release a closed-source application that uses JUCE, [paid 57 | commercial licences][2] are available. 58 | 59 | [1]: http://rawmaterialsoftware.com/juce.php "The JUCE Library" 60 | [2]: http://rawmaterialsoftware.com/jucelicense.php "JUCE Commercial Licensing" 61 | [3]: https://github.com/vinniefalco/Amalgams/ "Amalgamate Templates" 62 | [4]: https://github.com/vinniefalco/Amalgamate/ "Amalgamate Tool" 63 | [5]: http://rawmaterialsoftware.com "Raw Material Software, Ltd." 64 | [6]: http://www.gnu.org/licenses/gpl-2.0.html "GNU GPL Version 2" 65 | [7]: https://github.com/vinniefalco/JUCEAmalgam "JUCE Amalgamation" 66 | -------------------------------------------------------------------------------- /Demo/JUCEAmalgam/include/juce_audio_basics_amalgam.mm: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the JUCE library - "Jules' Utility Class Extensions" 5 | Copyright 2004-11 by Raw Material Software Ltd. 6 | 7 | ------------------------------------------------------------------------------ 8 | 9 | JUCE can be redistributed and/or modified under the terms of the GNU General 10 | Public License (Version 2), as published by the Free Software Foundation. 11 | A copy of the license is included in the JUCE distribution, or can be found 12 | online at www.gnu.org/licenses. 13 | 14 | JUCE is distributed in the hope that it will be useful, but WITHOUT ANY 15 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 16 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 17 | 18 | ------------------------------------------------------------------------------ 19 | 20 | To release a closed-source product which uses JUCE, commercial licenses are 21 | available: visit www.rawmaterialsoftware.com/juce for more information. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #if defined(__APPLE__) && defined(__OBJC__) 27 | #include "juce_audio_basics_amalgam.cpp" 28 | #endif 29 | -------------------------------------------------------------------------------- /Demo/JUCEAmalgam/include/juce_audio_devices_amalgam.mm: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the JUCE library - "Jules' Utility Class Extensions" 5 | Copyright 2004-11 by Raw Material Software Ltd. 6 | 7 | ------------------------------------------------------------------------------ 8 | 9 | JUCE can be redistributed and/or modified under the terms of the GNU General 10 | Public License (Version 2), as published by the Free Software Foundation. 11 | A copy of the license is included in the JUCE distribution, or can be found 12 | online at www.gnu.org/licenses. 13 | 14 | JUCE is distributed in the hope that it will be useful, but WITHOUT ANY 15 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 16 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 17 | 18 | ------------------------------------------------------------------------------ 19 | 20 | To release a closed-source product which uses JUCE, commercial licenses are 21 | available: visit www.rawmaterialsoftware.com/juce for more information. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #if defined(__APPLE__) && defined(__OBJC__) 27 | #include "juce_audio_devices_amalgam.cpp" 28 | #endif 29 | -------------------------------------------------------------------------------- /Demo/JUCEAmalgam/include/juce_audio_formats_amalgam.mm: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the JUCE library - "Jules' Utility Class Extensions" 5 | Copyright 2004-11 by Raw Material Software Ltd. 6 | 7 | ------------------------------------------------------------------------------ 8 | 9 | JUCE can be redistributed and/or modified under the terms of the GNU General 10 | Public License (Version 2), as published by the Free Software Foundation. 11 | A copy of the license is included in the JUCE distribution, or can be found 12 | online at www.gnu.org/licenses. 13 | 14 | JUCE is distributed in the hope that it will be useful, but WITHOUT ANY 15 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 16 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 17 | 18 | ------------------------------------------------------------------------------ 19 | 20 | To release a closed-source product which uses JUCE, commercial licenses are 21 | available: visit www.rawmaterialsoftware.com/juce for more information. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #if defined(__APPLE__) && defined(__OBJC__) 27 | #include "juce_audio_formats_amalgam.cpp" 28 | #endif 29 | -------------------------------------------------------------------------------- /Demo/JUCEAmalgam/include/juce_audio_processors_amalgam.mm: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the JUCE library - "Jules' Utility Class Extensions" 5 | Copyright 2004-11 by Raw Material Software Ltd. 6 | 7 | ------------------------------------------------------------------------------ 8 | 9 | JUCE can be redistributed and/or modified under the terms of the GNU General 10 | Public License (Version 2), as published by the Free Software Foundation. 11 | A copy of the license is included in the JUCE distribution, or can be found 12 | online at www.gnu.org/licenses. 13 | 14 | JUCE is distributed in the hope that it will be useful, but WITHOUT ANY 15 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 16 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 17 | 18 | ------------------------------------------------------------------------------ 19 | 20 | To release a closed-source product which uses JUCE, commercial licenses are 21 | available: visit www.rawmaterialsoftware.com/juce for more information. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #if defined(__APPLE__) && defined(__OBJC__) 27 | #include "juce_audio_processors_amalgam.cpp" 28 | #endif 29 | -------------------------------------------------------------------------------- /Demo/JUCEAmalgam/include/juce_audio_utils_amalgam.mm: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the JUCE library - "Jules' Utility Class Extensions" 5 | Copyright 2004-11 by Raw Material Software Ltd. 6 | 7 | ------------------------------------------------------------------------------ 8 | 9 | JUCE can be redistributed and/or modified under the terms of the GNU General 10 | Public License (Version 2), as published by the Free Software Foundation. 11 | A copy of the license is included in the JUCE distribution, or can be found 12 | online at www.gnu.org/licenses. 13 | 14 | JUCE is distributed in the hope that it will be useful, but WITHOUT ANY 15 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 16 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 17 | 18 | ------------------------------------------------------------------------------ 19 | 20 | To release a closed-source product which uses JUCE, commercial licenses are 21 | available: visit www.rawmaterialsoftware.com/juce for more information. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #if defined(__APPLE__) && defined(__OBJC__) 27 | #include "juce_audio_utils_amalgam.cpp" 28 | #endif 29 | -------------------------------------------------------------------------------- /Demo/JUCEAmalgam/include/juce_core_amalgam.mm: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the JUCE library - "Jules' Utility Class Extensions" 5 | Copyright 2004-11 by Raw Material Software Ltd. 6 | 7 | ------------------------------------------------------------------------------ 8 | 9 | JUCE can be redistributed and/or modified under the terms of the GNU General 10 | Public License (Version 2), as published by the Free Software Foundation. 11 | A copy of the license is included in the JUCE distribution, or can be found 12 | online at www.gnu.org/licenses. 13 | 14 | JUCE is distributed in the hope that it will be useful, but WITHOUT ANY 15 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 16 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 17 | 18 | ------------------------------------------------------------------------------ 19 | 20 | To release a closed-source product which uses JUCE, commercial licenses are 21 | available: visit www.rawmaterialsoftware.com/juce for more information. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #if defined(__APPLE__) && defined(__OBJC__) 27 | #include "juce_core_amalgam.cpp" 28 | #endif 29 | -------------------------------------------------------------------------------- /Demo/JUCEAmalgam/include/juce_cryptography_amalgam.mm: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the JUCE library - "Jules' Utility Class Extensions" 5 | Copyright 2004-11 by Raw Material Software Ltd. 6 | 7 | ------------------------------------------------------------------------------ 8 | 9 | JUCE can be redistributed and/or modified under the terms of the GNU General 10 | Public License (Version 2), as published by the Free Software Foundation. 11 | A copy of the license is included in the JUCE distribution, or can be found 12 | online at www.gnu.org/licenses. 13 | 14 | JUCE is distributed in the hope that it will be useful, but WITHOUT ANY 15 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 16 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 17 | 18 | ------------------------------------------------------------------------------ 19 | 20 | To release a closed-source product which uses JUCE, commercial licenses are 21 | available: visit www.rawmaterialsoftware.com/juce for more information. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #if defined(__APPLE__) && defined(__OBJC__) 27 | #include "juce_cryptography_amalgam.cpp" 28 | #endif 29 | -------------------------------------------------------------------------------- /Demo/JUCEAmalgam/include/juce_data_structures_amalgam.mm: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the JUCE library - "Jules' Utility Class Extensions" 5 | Copyright 2004-11 by Raw Material Software Ltd. 6 | 7 | ------------------------------------------------------------------------------ 8 | 9 | JUCE can be redistributed and/or modified under the terms of the GNU General 10 | Public License (Version 2), as published by the Free Software Foundation. 11 | A copy of the license is included in the JUCE distribution, or can be found 12 | online at www.gnu.org/licenses. 13 | 14 | JUCE is distributed in the hope that it will be useful, but WITHOUT ANY 15 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 16 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 17 | 18 | ------------------------------------------------------------------------------ 19 | 20 | To release a closed-source product which uses JUCE, commercial licenses are 21 | available: visit www.rawmaterialsoftware.com/juce for more information. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #if defined(__APPLE__) && defined(__OBJC__) 27 | #include "juce_data_structures_amalgam.cpp" 28 | #endif 29 | -------------------------------------------------------------------------------- /Demo/JUCEAmalgam/include/juce_events_amalgam.mm: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the JUCE library - "Jules' Utility Class Extensions" 5 | Copyright 2004-11 by Raw Material Software Ltd. 6 | 7 | ------------------------------------------------------------------------------ 8 | 9 | JUCE can be redistributed and/or modified under the terms of the GNU General 10 | Public License (Version 2), as published by the Free Software Foundation. 11 | A copy of the license is included in the JUCE distribution, or can be found 12 | online at www.gnu.org/licenses. 13 | 14 | JUCE is distributed in the hope that it will be useful, but WITHOUT ANY 15 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 16 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 17 | 18 | ------------------------------------------------------------------------------ 19 | 20 | To release a closed-source product which uses JUCE, commercial licenses are 21 | available: visit www.rawmaterialsoftware.com/juce for more information. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #if defined(__APPLE__) && defined(__OBJC__) 27 | #include "juce_events_amalgam.cpp" 28 | #endif 29 | -------------------------------------------------------------------------------- /Demo/JUCEAmalgam/include/juce_graphics_amalgam.mm: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the JUCE library - "Jules' Utility Class Extensions" 5 | Copyright 2004-11 by Raw Material Software Ltd. 6 | 7 | ------------------------------------------------------------------------------ 8 | 9 | JUCE can be redistributed and/or modified under the terms of the GNU General 10 | Public License (Version 2), as published by the Free Software Foundation. 11 | A copy of the license is included in the JUCE distribution, or can be found 12 | online at www.gnu.org/licenses. 13 | 14 | JUCE is distributed in the hope that it will be useful, but WITHOUT ANY 15 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 16 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 17 | 18 | ------------------------------------------------------------------------------ 19 | 20 | To release a closed-source product which uses JUCE, commercial licenses are 21 | available: visit www.rawmaterialsoftware.com/juce for more information. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #if defined(__APPLE__) && defined(__OBJC__) 27 | #include "juce_graphics_amalgam.cpp" 28 | #endif 29 | -------------------------------------------------------------------------------- /Demo/JUCEAmalgam/include/juce_gui_basics_amalgam.mm: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the JUCE library - "Jules' Utility Class Extensions" 5 | Copyright 2004-11 by Raw Material Software Ltd. 6 | 7 | ------------------------------------------------------------------------------ 8 | 9 | JUCE can be redistributed and/or modified under the terms of the GNU General 10 | Public License (Version 2), as published by the Free Software Foundation. 11 | A copy of the license is included in the JUCE distribution, or can be found 12 | online at www.gnu.org/licenses. 13 | 14 | JUCE is distributed in the hope that it will be useful, but WITHOUT ANY 15 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 16 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 17 | 18 | ------------------------------------------------------------------------------ 19 | 20 | To release a closed-source product which uses JUCE, commercial licenses are 21 | available: visit www.rawmaterialsoftware.com/juce for more information. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #if defined(__APPLE__) && defined(__OBJC__) 27 | #include "juce_gui_basics_amalgam.cpp" 28 | #endif 29 | -------------------------------------------------------------------------------- /Demo/JUCEAmalgam/include/juce_gui_extra_amalgam.mm: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the JUCE library - "Jules' Utility Class Extensions" 5 | Copyright 2004-11 by Raw Material Software Ltd. 6 | 7 | ------------------------------------------------------------------------------ 8 | 9 | JUCE can be redistributed and/or modified under the terms of the GNU General 10 | Public License (Version 2), as published by the Free Software Foundation. 11 | A copy of the license is included in the JUCE distribution, or can be found 12 | online at www.gnu.org/licenses. 13 | 14 | JUCE is distributed in the hope that it will be useful, but WITHOUT ANY 15 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 16 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 17 | 18 | ------------------------------------------------------------------------------ 19 | 20 | To release a closed-source product which uses JUCE, commercial licenses are 21 | available: visit www.rawmaterialsoftware.com/juce for more information. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #if defined(__APPLE__) && defined(__OBJC__) 27 | #include "juce_gui_extra_amalgam.cpp" 28 | #endif 29 | -------------------------------------------------------------------------------- /Demo/JUCEAmalgam/include/juce_opengl_amalgam.mm: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the JUCE library - "Jules' Utility Class Extensions" 5 | Copyright 2004-11 by Raw Material Software Ltd. 6 | 7 | ------------------------------------------------------------------------------ 8 | 9 | JUCE can be redistributed and/or modified under the terms of the GNU General 10 | Public License (Version 2), as published by the Free Software Foundation. 11 | A copy of the license is included in the JUCE distribution, or can be found 12 | online at www.gnu.org/licenses. 13 | 14 | JUCE is distributed in the hope that it will be useful, but WITHOUT ANY 15 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 16 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 17 | 18 | ------------------------------------------------------------------------------ 19 | 20 | To release a closed-source product which uses JUCE, commercial licenses are 21 | available: visit www.rawmaterialsoftware.com/juce for more information. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #if defined(__APPLE__) && defined(__OBJC__) 27 | #include "juce_opengl_amalgam.cpp" 28 | #endif 29 | -------------------------------------------------------------------------------- /Demo/JUCEAmalgam/include/juce_video_amalgam.mm: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the JUCE library - "Jules' Utility Class Extensions" 5 | Copyright 2004-11 by Raw Material Software Ltd. 6 | 7 | ------------------------------------------------------------------------------ 8 | 9 | JUCE can be redistributed and/or modified under the terms of the GNU General 10 | Public License (Version 2), as published by the Free Software Foundation. 11 | A copy of the license is included in the JUCE distribution, or can be found 12 | online at www.gnu.org/licenses. 13 | 14 | JUCE is distributed in the hope that it will be useful, but WITHOUT ANY 15 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 16 | A PARTICULAR PURPOSE. See the GNU General Public License for more details. 17 | 18 | ------------------------------------------------------------------------------ 19 | 20 | To release a closed-source product which uses JUCE, commercial licenses are 21 | available: visit www.rawmaterialsoftware.com/juce for more information. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #if defined(__APPLE__) && defined(__OBJC__) 27 | #include "juce_video_amalgam.cpp" 28 | #endif 29 | -------------------------------------------------------------------------------- /Demo/JuceLibraryCode/AppConfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | IMPORTANT! This file is auto-generated each time you save your 4 | project - if you alter its contents, your changes may be overwritten! 5 | 6 | There's a section below where you can add your own custom code safely, and the 7 | Introjucer will preserve the contents of that block, but the best way to change 8 | any of these definitions is by using the Introjucer's project settings. 9 | 10 | Any commented-out settings will assume their default values. 11 | 12 | */ 13 | 14 | #ifndef __JUCE_APPCONFIG_Z8YIUR__ 15 | #define __JUCE_APPCONFIG_Z8YIUR__ 16 | 17 | //============================================================================== 18 | // [BEGIN_USER_CODE_SECTION] 19 | 20 | // (You can add your own code in this section, and the Introjucer will not overwrite it) 21 | 22 | // [END_USER_CODE_SECTION] 23 | 24 | //============================================================================== 25 | 26 | 27 | #endif // __JUCE_APPCONFIG_Z8YIUR__ 28 | -------------------------------------------------------------------------------- /Demo/JuceLibraryCode/BinaryData.h: -------------------------------------------------------------------------------- 1 | /* ========================================================================================= 2 | 3 | This is an auto-generated file, created by The Introjucer 3.0.0 4 | Do not edit anything in this file! 5 | 6 | */ 7 | 8 | namespace BinaryData 9 | { 10 | extern const char* README_md; 11 | const int README_mdSize = 2500; 12 | 13 | extern const char* Tests_lua; 14 | const int Tests_luaSize = 3877; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Demo/JuceLibraryCode/JuceHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | IMPORTANT! This file is auto-generated each time you save your 4 | project - if you alter its contents, your changes may be overwritten! 5 | 6 | This is the header file that your files should include in order to get all the 7 | JUCE library headers. You should avoid including the JUCE headers directly in 8 | your own source files, because that wouldn't pick up the correct configuration 9 | options for your app. 10 | 11 | */ 12 | 13 | #ifndef __APPHEADERFILE_Z8YIUR__ 14 | #define __APPHEADERFILE_Z8YIUR__ 15 | 16 | #include "AppConfig.h" 17 | #include "BinaryData.h" 18 | 19 | #if ! DONT_SET_USING_JUCE_NAMESPACE 20 | // If your code uses a lot of JUCE classes, then this will obviously save you 21 | // a lot of typing, but can be disabled by setting DONT_SET_USING_JUCE_NAMESPACE. 22 | using namespace juce; 23 | #endif 24 | 25 | namespace ProjectInfo 26 | { 27 | const char* const projectName = "LuaBridgeDemo"; 28 | const char* const versionString = "1.0.0"; 29 | const int versionNumber = 0x10000; 30 | } 31 | 32 | #endif // __APPHEADERFILE_Z8YIUR__ 33 | -------------------------------------------------------------------------------- /Demo/JuceLibraryCode/ReadMe.txt: -------------------------------------------------------------------------------- 1 | 2 | Important Note!! 3 | ================ 4 | 5 | The purpose of this folder is to contain files that are auto-generated by the Introjucer, 6 | and ALL files in this folder will be mercilessly DELETED and completely re-written whenever 7 | the Introjucer saves your project. 8 | 9 | Therefore, it's a bad idea to make any manual changes to the files in here, or to 10 | put any of your own files in here if you don't want to lose them. (Of course you may choose 11 | to add the folder's contents to your version-control system so that you can re-merge your own 12 | modifications after the Introjucer has saved its changes). 13 | -------------------------------------------------------------------------------- /Demo/Source/App.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | /* 3 | https://github.com/vinniefalco/LuaBridge 4 | https://github.com/vinniefalco/LuaBridgeDemo 5 | 6 | Copyright (C) 2012, Vinnie Falco 7 | 8 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | */ 28 | //============================================================================== 29 | 30 | class App : public JUCEApplication 31 | { 32 | private: 33 | ScopedPointer m_luaState; 34 | ScopedPointer m_window; 35 | 36 | public: 37 | App() 38 | : m_luaState (LuaState::New ()) 39 | { 40 | } 41 | 42 | ~App() 43 | { 44 | } 45 | 46 | void runTests () 47 | { 48 | lua_State* L = m_luaState->createTestEnvironment (); 49 | 50 | LuaBridgeTests::addToState (L); 51 | 52 | if (luaL_loadstring (L, BinaryData::Tests_lua) != 0) 53 | { 54 | // compile-time error 55 | m_luaState->print (lua_tostring (L, -1)); 56 | } 57 | else if (LuaState::pcall (L, 0, 0) != 0) 58 | { 59 | m_luaState->print (lua_tostring (L, -1)); 60 | } 61 | 62 | m_luaState->destroyTestEnvironment (L); 63 | 64 | runNewTests (*m_luaState); 65 | } 66 | 67 | void initialise (const String&) 68 | { 69 | // Do your application's initialisation code here.. 70 | 71 | m_window = new CConsoleWindow (*m_luaState); 72 | 73 | m_window->setVisible (true); 74 | 75 | runTests (); 76 | } 77 | 78 | void shutdown() 79 | { 80 | // Do your application's shutdown code here.. 81 | 82 | m_window = nullptr; 83 | } 84 | 85 | void systemRequestedQuit() 86 | { 87 | quit(); 88 | } 89 | 90 | const String getApplicationName() 91 | { 92 | return "LuaBridge Demo"; 93 | } 94 | 95 | const String getApplicationVersion() 96 | { 97 | return "1.0"; 98 | } 99 | 100 | bool moreThanOneInstanceAllowed() 101 | { 102 | return true; 103 | } 104 | 105 | void anotherInstanceStarted (const String&) 106 | { 107 | 108 | } 109 | }; 110 | 111 | START_JUCE_APPLICATION (App) 112 | -------------------------------------------------------------------------------- /Demo/Source/CConsole.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | /* 3 | https://github.com/vinniefalco/LuaBridge 4 | https://github.com/vinniefalco/LuaBridgeDemo 5 | 6 | Copyright (C) 2012, Vinnie Falco 7 | 8 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | */ 28 | //============================================================================== 29 | 30 | CConsole::CConsole (LuaState& luaState) 31 | { 32 | { 33 | Component* c = new CConsoleText (luaState); 34 | addAndMakeVisible (c); 35 | m_text = c; 36 | } 37 | 38 | { 39 | Component* c = new CConsoleEdit (luaState); 40 | addAndMakeVisible (c); 41 | m_edit = c; 42 | } 43 | } 44 | 45 | CConsole::~CConsole () 46 | { 47 | } 48 | 49 | void CConsole::resized () 50 | { 51 | m_text->setBounds (0, 0, getWidth (), getHeight() - 32); 52 | m_edit->setBounds (0, getHeight () - 32, getWidth (), 32); 53 | } 54 | -------------------------------------------------------------------------------- /Demo/Source/CConsole.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | /* 3 | https://github.com/vinniefalco/LuaBridge 4 | https://github.com/vinniefalco/LuaBridgeDemo 5 | 6 | Copyright (C) 2012, Vinnie Falco 7 | 8 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | */ 28 | //============================================================================== 29 | 30 | #ifndef LUABRIDGEDEMO_CCONSOLE_HEADER 31 | #define LUABRIDGEDEMO_CCONSOLE_HEADER 32 | 33 | #include "CConsoleEdit.h" 34 | 35 | class CConsole : public Component 36 | { 37 | public: 38 | explicit CConsole (LuaState& luaState); 39 | ~CConsole (); 40 | 41 | void resized (); 42 | 43 | private: 44 | ScopedPointer m_edit; 45 | ScopedPointer m_text; 46 | }; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /Demo/Source/CConsoleEdit.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | /* 3 | https://github.com/vinniefalco/LuaBridge 4 | https://github.com/vinniefalco/LuaBridgeDemo 5 | 6 | Copyright (C) 2012, Vinnie Falco 7 | 8 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | */ 28 | //============================================================================== 29 | 30 | CConsoleEdit::CConsoleEdit (LuaState& luaState) 31 | : m_luaState (luaState) 32 | { 33 | { 34 | TextEditor* c = new TextEditor; 35 | c->setMultiLine (false); 36 | c->setFont (18); 37 | c->setBounds (0, 0, 100, 34); 38 | addAndMakeVisible (c); 39 | c->addListener (this); 40 | m_edit = c; 41 | } 42 | 43 | triggerAsyncUpdate (); 44 | } 45 | 46 | CConsoleEdit::~CConsoleEdit () 47 | { 48 | } 49 | 50 | void CConsoleEdit::resized () 51 | { 52 | m_edit->setBounds (0, 0, getWidth (), getHeight ()); 53 | } 54 | 55 | void CConsoleEdit::handleAsyncUpdate () 56 | { 57 | grabKeyboardFocus (); 58 | } 59 | 60 | void CConsoleEdit::textEditorReturnKeyPressed (TextEditor& editor) 61 | { 62 | String text = editor.getText (); 63 | 64 | editor.selectAll (); 65 | 66 | m_luaState.doString (text); 67 | } 68 | 69 | -------------------------------------------------------------------------------- /Demo/Source/CConsoleEdit.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | /* 3 | https://github.com/vinniefalco/LuaBridge 4 | https://github.com/vinniefalco/LuaBridgeDemo 5 | 6 | Copyright (C) 2012, Vinnie Falco 7 | 8 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | */ 28 | //============================================================================== 29 | 30 | #ifndef LUABRIDGEDEMO_CCONSOLEEDIT_HEADER 31 | #define LUABRIDGEDEMO_CCONSOLEEDIT_HEADER 32 | 33 | #include "LuaState.h" 34 | 35 | class CConsoleEdit 36 | : public Component 37 | , private TextEditor::Listener 38 | , private AsyncUpdater 39 | { 40 | public: 41 | explicit CConsoleEdit (LuaState& luaState); 42 | ~CConsoleEdit (); 43 | 44 | void resized (); 45 | 46 | private: 47 | void handleAsyncUpdate (); 48 | 49 | void textEditorReturnKeyPressed (TextEditor& editor); 50 | 51 | private: 52 | LuaState& m_luaState; 53 | ScopedPointer m_edit; 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /Demo/Source/CConsoleText.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | /* 3 | https://github.com/vinniefalco/LuaBridge 4 | https://github.com/vinniefalco/LuaBridgeDemo 5 | 6 | Copyright (C) 2012, Vinnie Falco 7 | 8 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | */ 28 | //============================================================================== 29 | 30 | 31 | CConsoleText::CConsoleText (LuaState& luaState) 32 | : m_luaState (luaState) 33 | , m_text (new TextEditor) 34 | { 35 | setSize (400, 100); 36 | 37 | { 38 | TextEditor* c = m_text; 39 | c->setReadOnly (true); 40 | c->setMultiLine (true, true); 41 | c->setFont (18); 42 | c->setColour (TextEditor::backgroundColourId, Colours::transparentBlack); 43 | c->setColour (TextEditor::textColourId, Colours::white); 44 | c->setColour (TextEditor::highlightColourId, Colour::fromRGBA (0, 255, 255, 96)); 45 | c->setColour (TextEditor::highlightedTextColourId, Colours::white); 46 | c->setColour (TextEditor::outlineColourId, Colours::transparentBlack); 47 | c->setColour (TextEditor::shadowColourId, Colour::fromRGBA (255, 255, 255, 32)); 48 | 49 | c->setBounds (0, 0, 400, 100); 50 | addAndMakeVisible (c); 51 | } 52 | 53 | m_luaState.addListener (this); 54 | } 55 | 56 | CConsoleText::~CConsoleText () 57 | { 58 | m_luaState.removeListener (this); 59 | } 60 | 61 | void CConsoleText::resized () 62 | { 63 | m_text->setBounds (0, 0, getWidth (), getHeight ()); 64 | } 65 | 66 | void CConsoleText::onLuaStatePrint (String text) 67 | { 68 | m_text->moveCaretToEnd (); 69 | m_text->insertTextAtCaret (text); 70 | m_text->insertTextAtCaret ("\n"); 71 | } 72 | -------------------------------------------------------------------------------- /Demo/Source/CConsoleText.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | /* 3 | https://github.com/vinniefalco/LuaBridge 4 | https://github.com/vinniefalco/LuaBridgeDemo 5 | 6 | Copyright (C) 2012, Vinnie Falco 7 | 8 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | */ 28 | //============================================================================== 29 | 30 | #ifndef CCONSOLETEXT_HEADER 31 | #define CCONSOLETEXT_HEADER 32 | 33 | #include "LuaState.h" 34 | 35 | class CConsoleText 36 | : public Component 37 | , private LuaState::Listener 38 | { 39 | public: 40 | explicit CConsoleText (LuaState& luaState); 41 | ~CConsoleText (); 42 | 43 | void resized (); 44 | 45 | void onLuaStatePrint (String text); 46 | 47 | private: 48 | LuaState& m_luaState; 49 | ScopedPointer m_text; 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /Demo/Source/CConsoleWindow.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | /* 3 | https://github.com/vinniefalco/LuaBridge 4 | https://github.com/vinniefalco/LuaBridgeDemo 5 | 6 | Copyright (C) 2012, Vinnie Falco 7 | 8 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | */ 28 | //============================================================================== 29 | 30 | CConsoleWindow::CConsoleWindow (LuaState& luaState) 31 | : DocumentWindow ( 32 | TRANS("LuaBridge Demo"), 33 | Colours::black, 34 | DocumentWindow::allButtons, 35 | false) 36 | { 37 | setSize (640, 480); 38 | 39 | setOpaque (true); 40 | setResizable (true, false); 41 | setDropShadowEnabled (false); 42 | //setUsingNativeTitleBar (true); 43 | setWantsKeyboardFocus (true); 44 | 45 | // must happen AFTER setUsingNativeTitleBar() 46 | Component::addToDesktop (getDesktopWindowStyleFlags()); 47 | 48 | // must happen after addToDesktop() 49 | Component* c = new CConsole (luaState); 50 | c->setBounds (0, 0, 640, 480); 51 | setContentOwned (c, true); 52 | 53 | setSize (640, 480); 54 | 55 | centreWithSize (getWidth(), getHeight()); 56 | 57 | grabKeyboardFocus (); 58 | } 59 | 60 | CConsoleWindow::~CConsoleWindow () 61 | { 62 | } 63 | 64 | void CConsoleWindow::closeButtonPressed () 65 | { 66 | JUCEApplication::getInstance()->quit (); 67 | } 68 | -------------------------------------------------------------------------------- /Demo/Source/CConsoleWindow.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | /* 3 | https://github.com/vinniefalco/LuaBridge 4 | https://github.com/vinniefalco/LuaBridgeDemo 5 | 6 | Copyright (C) 2012, Vinnie Falco 7 | 8 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | */ 28 | //============================================================================== 29 | 30 | #ifndef LUABRIDGEDEMO_CCONSOLEWINDOW_HEADER 31 | #define LUABRIDGEDEMO_CCONSOLEWINDOW_HEADER 32 | 33 | class CConsoleWindow : public DocumentWindow 34 | { 35 | public: 36 | explicit CConsoleWindow (LuaState& luaState); 37 | ~CConsoleWindow (); 38 | 39 | void closeButtonPressed (); 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /Demo/Source/LuaState.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | /* 3 | https://github.com/vinniefalco/LuaBridge 4 | https://github.com/vinniefalco/LuaBridgeDemo 5 | 6 | Copyright (C) 2012, Vinnie Falco 7 | 8 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | */ 28 | //============================================================================== 29 | 30 | #ifndef LUABRIDGEDEMO_LUASTATE_HEADER 31 | #define LUABRIDGEDEMO_LUASTATE_HEADER 32 | 33 | #include "TestHost.h" 34 | 35 | /** 36 | lua_State wrapper. 37 | 38 | The state hs the standard Lua libraries opened, and an override for print which 39 | sends the text to observers. There is also a traceback feature installed that 40 | displays the stack when an error occurs. To get the traceback, use the pcall() 41 | of this class. 42 | */ 43 | class LuaState : public TestHost 44 | { 45 | public: 46 | class Listener 47 | { 48 | public: 49 | virtual ~Listener () { } 50 | virtual void onLuaStatePrint (String text) = 0; 51 | }; 52 | 53 | static LuaState* New (); 54 | virtual ~LuaState () = 0; 55 | 56 | virtual void addListener (Listener* listener) = 0; 57 | virtual void removeListener (Listener* listener) = 0; 58 | 59 | virtual lua_State* getState () = 0; 60 | 61 | inline operator lua_State* () 62 | { 63 | return getState (); 64 | } 65 | 66 | virtual int pcall (int numberOfArguments, int numberOfReturnValues) = 0; 67 | 68 | virtual void doString (String chunk) = 0; 69 | 70 | static int pcall (lua_State* L, int numberOfArguments, int numberOfReturnValues); 71 | }; 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /Demo/Source/Main.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | /* 3 | https://github.com/vinniefalco/LuaBridge 4 | https://github.com/vinniefalco/LuaBridgeDemo 5 | 6 | Copyright (C) 2012, Vinnie Falco 7 | 8 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | */ 28 | //============================================================================== 29 | 30 | #include "Lua/LuaLibrary.h" 31 | 32 | #include "LuaBridge/LuaBridge.h" 33 | #include "LuaBridge/RefCountedPtr.h" 34 | #include "LuaBridge/RefCountedObject.h" 35 | 36 | #include "Tests/Source/Tests.h" 37 | #include "Tests/Source/Tests.cpp" 38 | 39 | #include "Demo/JUCEAmalgam/include/juce_core_amalgam.h" 40 | #include "Demo/JUCEAmalgam/include/juce_data_structures_amalgam.h" 41 | #include "Demo/JUCEAmalgam/include/juce_events_amalgam.h" 42 | #include "Demo/JUCEAmalgam/include/juce_graphics_amalgam.h" 43 | #include "Demo/JUCEAmalgam/include/juce_gui_basics_amalgam.h" 44 | 45 | using namespace juce; 46 | 47 | #include "BinaryData.h" 48 | 49 | #include "CConsole.h" 50 | #include "CConsoleEdit.h" 51 | #include "CConsoleText.h" 52 | #include "CConsoleWindow.h" 53 | #include "LuaState.h" 54 | #include "NewTests.h" 55 | 56 | #include "CConsole.cpp" 57 | #include "CConsoleEdit.cpp" 58 | #include "CConsoleText.cpp" 59 | #include "CConsoleWindow.cpp" 60 | #include "LuaState.cpp" 61 | #include "NewTests.cpp" 62 | 63 | #include "App.cpp" 64 | -------------------------------------------------------------------------------- /Demo/Source/NewTests.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | /* 3 | https://github.com/vinniefalco/LuaBridge 4 | https://github.com/vinniefalco/LuaBridgeDemo 5 | 6 | Copyright (C) 2012, Vinnie Falco 7 | 8 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | */ 28 | //============================================================================== 29 | 30 | #ifndef LUABRIDGEDEMO_NEWTESTS_HEADER 31 | #define LUABRIDGEDEMO_NEWTESTS_HEADER 32 | 33 | extern void runNewTests (LuaState& state); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /Demo/Source/TestHost.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | /* 3 | https://github.com/vinniefalco/LuaBridge 4 | https://github.com/vinniefalco/LuaBridgeDemo 5 | 6 | Copyright (C) 2012, Vinnie Falco 7 | 8 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | */ 28 | //============================================================================== 29 | 30 | #ifndef LUABRIDGEDEMO_TESTHOST_HEADER 31 | #define LUABRIDGEDEMO_TESTHOST_HEADER 32 | 33 | struct lua_State; 34 | 35 | /** 36 | Host interface. 37 | 38 | The tests call into a host-provided instance of this interface. 39 | */ 40 | class TestHost 41 | { 42 | protected: 43 | virtual ~TestHost () { } 44 | 45 | public: 46 | /** 47 | Called to create a fresh environment for performing a test. 48 | 49 | The standard libraries are automatically opened. 50 | */ 51 | virtual lua_State* createTestEnvironment () = 0; 52 | 53 | /** 54 | Called to destroy the environment when it is no longer needed. 55 | */ 56 | virtual void destroyTestEnvironment (lua_State* L) = 0; 57 | 58 | /** 59 | Prints output 60 | */ 61 | virtual void print (std::string text) = 0; 62 | }; 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/COPYRIGHT: -------------------------------------------------------------------------------- 1 | Lua License 2 | ----------- 3 | 4 | Lua is licensed under the terms of the MIT license reproduced below. 5 | This means that Lua is free software and can be used for both academic 6 | and commercial purposes at absolutely no cost. 7 | 8 | For details and rationale, see http://www.lua.org/license.html . 9 | 10 | =============================================================================== 11 | 12 | Copyright (C) 1994-2012 Lua.org, PUC-Rio. 13 | 14 | Permission is hereby granted, free of charge, to any person obtaining a copy 15 | of this software and associated documentation files (the "Software"), to deal 16 | in the Software without restriction, including without limitation the rights 17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18 | copies of the Software, and to permit persons to whom the Software is 19 | furnished to do so, subject to the following conditions: 20 | 21 | The above copyright notice and this permission notice shall be included in 22 | all copies or substantial portions of the Software. 23 | 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 30 | THE SOFTWARE. 31 | 32 | =============================================================================== 33 | 34 | (end of COPYRIGHT) 35 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/README: -------------------------------------------------------------------------------- 1 | README for Lua 5.1 2 | 3 | See INSTALL for installation instructions. 4 | See HISTORY for a summary of changes since the last released version. 5 | 6 | * What is Lua? 7 | ------------ 8 | Lua is a powerful, light-weight programming language designed for extending 9 | applications. Lua is also frequently used as a general-purpose, stand-alone 10 | language. Lua is free software. 11 | 12 | For complete information, visit Lua's web site at http://www.lua.org/ . 13 | For an executive summary, see http://www.lua.org/about.html . 14 | 15 | Lua has been used in many different projects around the world. 16 | For a short list, see http://www.lua.org/uses.html . 17 | 18 | * Availability 19 | ------------ 20 | Lua is freely available for both academic and commercial purposes. 21 | See COPYRIGHT and http://www.lua.org/license.html for details. 22 | Lua can be downloaded at http://www.lua.org/download.html . 23 | 24 | * Installation 25 | ------------ 26 | Lua is implemented in pure ANSI C, and compiles unmodified in all known 27 | platforms that have an ANSI C compiler. In most Unix-like platforms, simply 28 | do "make" with a suitable target. See INSTALL for detailed instructions. 29 | 30 | * Origin 31 | ------ 32 | Lua is developed at Lua.org, a laboratory of the Department of Computer 33 | Science of PUC-Rio (the Pontifical Catholic University of Rio de Janeiro 34 | in Brazil). 35 | For more information about the authors, see http://www.lua.org/authors.html . 36 | 37 | (end of README) 38 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/doc/cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinniefalco/LuaBridgeDemo/867ffe17557bbf9a73fb1efff7e0dae39ed4ba73/Lua/Lua.5.1.5/doc/cover.png -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/doc/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinniefalco/LuaBridgeDemo/867ffe17557bbf9a73fb1efff7e0dae39ed4ba73/Lua/Lua.5.1.5/doc/logo.gif -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/doc/lua.css: -------------------------------------------------------------------------------- 1 | body { 2 | color: #000000 ; 3 | background-color: #FFFFFF ; 4 | font-family: Helvetica, Arial, sans-serif ; 5 | text-align: justify ; 6 | margin-right: 30px ; 7 | margin-left: 30px ; 8 | } 9 | 10 | h1, h2, h3, h4 { 11 | font-family: Verdana, Geneva, sans-serif ; 12 | font-weight: normal ; 13 | font-style: italic ; 14 | } 15 | 16 | h2 { 17 | padding-top: 0.4em ; 18 | padding-bottom: 0.4em ; 19 | padding-left: 30px ; 20 | padding-right: 30px ; 21 | margin-left: -30px ; 22 | background-color: #E0E0FF ; 23 | } 24 | 25 | h3 { 26 | padding-left: 0.5em ; 27 | border-left: solid #E0E0FF 1em ; 28 | } 29 | 30 | table h3 { 31 | padding-left: 0px ; 32 | border-left: none ; 33 | } 34 | 35 | a:link { 36 | color: #000080 ; 37 | background-color: inherit ; 38 | text-decoration: none ; 39 | } 40 | 41 | a:visited { 42 | background-color: inherit ; 43 | text-decoration: none ; 44 | } 45 | 46 | a:link:hover, a:visited:hover { 47 | color: #000080 ; 48 | background-color: #E0E0FF ; 49 | } 50 | 51 | a:link:active, a:visited:active { 52 | color: #FF0000 ; 53 | } 54 | 55 | hr { 56 | border: 0 ; 57 | height: 1px ; 58 | color: #a0a0a0 ; 59 | background-color: #a0a0a0 ; 60 | } 61 | 62 | :target { 63 | background-color: #F8F8F8 ; 64 | padding: 8px ; 65 | border: solid #a0a0a0 2px ; 66 | } 67 | 68 | .footer { 69 | color: gray ; 70 | font-size: small ; 71 | } 72 | 73 | input[type=text] { 74 | border: solid #a0a0a0 2px ; 75 | border-radius: 2em ; 76 | -moz-border-radius: 2em ; 77 | background-image: url('images/search.png') ; 78 | background-repeat: no-repeat; 79 | background-position: 4px center ; 80 | padding-left: 20px ; 81 | height: 2em ; 82 | } 83 | 84 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/doc/manual.css: -------------------------------------------------------------------------------- 1 | h3 code { 2 | font-family: inherit ; 3 | font-size: inherit ; 4 | } 5 | 6 | pre, code { 7 | font-size: 12pt ; 8 | } 9 | 10 | span.apii { 11 | float: right ; 12 | font-family: inherit ; 13 | font-style: normal ; 14 | font-size: small ; 15 | color: gray ; 16 | } 17 | 18 | p+h1, ul+h1 { 19 | padding-top: 0.4em ; 20 | padding-bottom: 0.4em ; 21 | padding-left: 30px ; 22 | margin-left: -30px ; 23 | background-color: #E0E0FF ; 24 | } 25 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/doc/readme.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Lua documentation 4 | 5 | 6 | 7 | 8 | 9 |
10 |

11 | Lua 12 | Documentation 13 |

14 | 15 | This is the documentation included in the source distribution of Lua 5.1.5. 16 | 17 | 25 | 26 | Lua's 27 | official web site 28 | contains updated documentation, 29 | especially the 30 | reference manual. 31 |

32 | 33 |


34 | 35 | Last update: 36 | Fri Feb 3 09:44:42 BRST 2012 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/etc/Makefile: -------------------------------------------------------------------------------- 1 | # makefile for Lua etc 2 | 3 | TOP= .. 4 | LIB= $(TOP)/src 5 | INC= $(TOP)/src 6 | BIN= $(TOP)/src 7 | SRC= $(TOP)/src 8 | TST= $(TOP)/test 9 | 10 | CC= gcc 11 | CFLAGS= -O2 -Wall -I$(INC) $(MYCFLAGS) 12 | MYCFLAGS= 13 | MYLDFLAGS= -Wl,-E 14 | MYLIBS= -lm 15 | #MYLIBS= -lm -Wl,-E -ldl -lreadline -lhistory -lncurses 16 | RM= rm -f 17 | 18 | default: 19 | @echo 'Please choose a target: min noparser one strict clean' 20 | 21 | min: min.c 22 | $(CC) $(CFLAGS) $@.c -L$(LIB) -llua $(MYLIBS) 23 | echo 'print"Hello there!"' | ./a.out 24 | 25 | noparser: noparser.o 26 | $(CC) noparser.o $(SRC)/lua.o -L$(LIB) -llua $(MYLIBS) 27 | $(BIN)/luac $(TST)/hello.lua 28 | -./a.out luac.out 29 | -./a.out -e'a=1' 30 | 31 | one: 32 | $(CC) $(CFLAGS) all.c $(MYLIBS) 33 | ./a.out $(TST)/hello.lua 34 | 35 | strict: 36 | -$(BIN)/lua -e 'print(a);b=2' 37 | -$(BIN)/lua -lstrict -e 'print(a)' 38 | -$(BIN)/lua -e 'function f() b=2 end f()' 39 | -$(BIN)/lua -lstrict -e 'function f() b=2 end f()' 40 | 41 | clean: 42 | $(RM) a.out core core.* *.o luac.out 43 | 44 | .PHONY: default min noparser one strict clean 45 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/etc/README: -------------------------------------------------------------------------------- 1 | This directory contains some useful files and code. 2 | Unlike the code in ../src, everything here is in the public domain. 3 | 4 | If any of the makes fail, you're probably not using the same libraries 5 | used to build Lua. Set MYLIBS in Makefile accordingly. 6 | 7 | all.c 8 | Full Lua interpreter in a single file. 9 | Do "make one" for a demo. 10 | 11 | lua.hpp 12 | Lua header files for C++ using 'extern "C"'. 13 | 14 | lua.ico 15 | A Lua icon for Windows (and web sites: save as favicon.ico). 16 | Drawn by hand by Markus Gritsch . 17 | 18 | lua.pc 19 | pkg-config data for Lua 20 | 21 | luavs.bat 22 | Script to build Lua under "Visual Studio .NET Command Prompt". 23 | Run it from the toplevel as etc\luavs.bat. 24 | 25 | min.c 26 | A minimal Lua interpreter. 27 | Good for learning and for starting your own. 28 | Do "make min" for a demo. 29 | 30 | noparser.c 31 | Linking with noparser.o avoids loading the parsing modules in lualib.a. 32 | Do "make noparser" for a demo. 33 | 34 | strict.lua 35 | Traps uses of undeclared global variables. 36 | Do "make strict" for a demo. 37 | 38 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/etc/all.c: -------------------------------------------------------------------------------- 1 | /* 2 | * all.c -- Lua core, libraries and interpreter in a single file 3 | */ 4 | 5 | #define luaall_c 6 | 7 | #include "lapi.c" 8 | #include "lcode.c" 9 | #include "ldebug.c" 10 | #include "ldo.c" 11 | #include "ldump.c" 12 | #include "lfunc.c" 13 | #include "lgc.c" 14 | #include "llex.c" 15 | #include "lmem.c" 16 | #include "lobject.c" 17 | #include "lopcodes.c" 18 | #include "lparser.c" 19 | #include "lstate.c" 20 | #include "lstring.c" 21 | #include "ltable.c" 22 | #include "ltm.c" 23 | #include "lundump.c" 24 | #include "lvm.c" 25 | #include "lzio.c" 26 | 27 | #include "lauxlib.c" 28 | #include "lbaselib.c" 29 | #include "ldblib.c" 30 | #include "liolib.c" 31 | #include "linit.c" 32 | #include "lmathlib.c" 33 | #include "loadlib.c" 34 | #include "loslib.c" 35 | #include "lstrlib.c" 36 | #include "ltablib.c" 37 | 38 | #include "lua.c" 39 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/etc/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "lua.h" 7 | #include "lualib.h" 8 | #include "lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/etc/lua.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinniefalco/LuaBridgeDemo/867ffe17557bbf9a73fb1efff7e0dae39ed4ba73/Lua/Lua.5.1.5/etc/lua.ico -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/etc/lua.pc: -------------------------------------------------------------------------------- 1 | # lua.pc -- pkg-config data for Lua 2 | 3 | # vars from install Makefile 4 | 5 | # grep '^V=' ../Makefile 6 | V= 5.1 7 | # grep '^R=' ../Makefile 8 | R= 5.1.5 9 | 10 | # grep '^INSTALL_.*=' ../Makefile | sed 's/INSTALL_TOP/prefix/' 11 | prefix= /usr/local 12 | INSTALL_BIN= ${prefix}/bin 13 | INSTALL_INC= ${prefix}/include 14 | INSTALL_LIB= ${prefix}/lib 15 | INSTALL_MAN= ${prefix}/man/man1 16 | INSTALL_LMOD= ${prefix}/share/lua/${V} 17 | INSTALL_CMOD= ${prefix}/lib/lua/${V} 18 | 19 | # canonical vars 20 | exec_prefix=${prefix} 21 | libdir=${exec_prefix}/lib 22 | includedir=${prefix}/include 23 | 24 | Name: Lua 25 | Description: An Extensible Extension Language 26 | Version: ${R} 27 | Requires: 28 | Libs: -L${libdir} -llua -lm 29 | Cflags: -I${includedir} 30 | 31 | # (end of lua.pc) 32 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/etc/luavs.bat: -------------------------------------------------------------------------------- 1 | @rem Script to build Lua under "Visual Studio .NET Command Prompt". 2 | @rem Do not run from this directory; run it from the toplevel: etc\luavs.bat . 3 | @rem It creates lua51.dll, lua51.lib, lua.exe, and luac.exe in src. 4 | @rem (contributed by David Manura and Mike Pall) 5 | 6 | @setlocal 7 | @set MYCOMPILE=cl /nologo /MD /O2 /W3 /c /D_CRT_SECURE_NO_DEPRECATE 8 | @set MYLINK=link /nologo 9 | @set MYMT=mt /nologo 10 | 11 | cd src 12 | %MYCOMPILE% /DLUA_BUILD_AS_DLL l*.c 13 | del lua.obj luac.obj 14 | %MYLINK% /DLL /out:lua51.dll l*.obj 15 | if exist lua51.dll.manifest^ 16 | %MYMT% -manifest lua51.dll.manifest -outputresource:lua51.dll;2 17 | %MYCOMPILE% /DLUA_BUILD_AS_DLL lua.c 18 | %MYLINK% /out:lua.exe lua.obj lua51.lib 19 | if exist lua.exe.manifest^ 20 | %MYMT% -manifest lua.exe.manifest -outputresource:lua.exe 21 | %MYCOMPILE% l*.c print.c 22 | del lua.obj linit.obj lbaselib.obj ldblib.obj liolib.obj lmathlib.obj^ 23 | loslib.obj ltablib.obj lstrlib.obj loadlib.obj 24 | %MYLINK% /out:luac.exe *.obj 25 | if exist luac.exe.manifest^ 26 | %MYMT% -manifest luac.exe.manifest -outputresource:luac.exe 27 | del *.obj *.manifest 28 | cd .. 29 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/etc/min.c: -------------------------------------------------------------------------------- 1 | /* 2 | * min.c -- a minimal Lua interpreter 3 | * loads stdin only with minimal error handling. 4 | * no interaction, and no standard library, only a "print" function. 5 | */ 6 | 7 | #include 8 | 9 | #include "lua.h" 10 | #include "lauxlib.h" 11 | 12 | static int print(lua_State *L) 13 | { 14 | int n=lua_gettop(L); 15 | int i; 16 | for (i=1; i<=n; i++) 17 | { 18 | if (i>1) printf("\t"); 19 | if (lua_isstring(L,i)) 20 | printf("%s",lua_tostring(L,i)); 21 | else if (lua_isnil(L,i)) 22 | printf("%s","nil"); 23 | else if (lua_isboolean(L,i)) 24 | printf("%s",lua_toboolean(L,i) ? "true" : "false"); 25 | else 26 | printf("%s:%p",luaL_typename(L,i),lua_topointer(L,i)); 27 | } 28 | printf("\n"); 29 | return 0; 30 | } 31 | 32 | int main(void) 33 | { 34 | lua_State *L=lua_open(); 35 | lua_register(L,"print",print); 36 | if (luaL_dofile(L,NULL)!=0) fprintf(stderr,"%s\n",lua_tostring(L,-1)); 37 | lua_close(L); 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/etc/noparser.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The code below can be used to make a Lua core that does not contain the 3 | * parsing modules (lcode, llex, lparser), which represent 35% of the total core. 4 | * You'll only be able to load binary files and strings, precompiled with luac. 5 | * (Of course, you'll have to build luac with the original parsing modules!) 6 | * 7 | * To use this module, simply compile it ("make noparser" does that) and list 8 | * its object file before the Lua libraries. The linker should then not load 9 | * the parsing modules. To try it, do "make luab". 10 | * 11 | * If you also want to avoid the dump module (ldump.o), define NODUMP. 12 | * #define NODUMP 13 | */ 14 | 15 | #define LUA_CORE 16 | 17 | #include "llex.h" 18 | #include "lparser.h" 19 | #include "lzio.h" 20 | 21 | LUAI_FUNC void luaX_init (lua_State *L) { 22 | UNUSED(L); 23 | } 24 | 25 | LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) { 26 | UNUSED(z); 27 | UNUSED(buff); 28 | UNUSED(name); 29 | lua_pushliteral(L,"parser not loaded"); 30 | lua_error(L); 31 | return NULL; 32 | } 33 | 34 | #ifdef NODUMP 35 | #include "lundump.h" 36 | 37 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip) { 38 | UNUSED(f); 39 | UNUSED(w); 40 | UNUSED(data); 41 | UNUSED(strip); 42 | #if 1 43 | UNUSED(L); 44 | return 0; 45 | #else 46 | lua_pushliteral(L,"dumper not loaded"); 47 | lua_error(L); 48 | #endif 49 | } 50 | #endif 51 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/etc/strict.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- strict.lua 3 | -- checks uses of undeclared global variables 4 | -- All global variables must be 'declared' through a regular assignment 5 | -- (even assigning nil will do) in a main chunk before being used 6 | -- anywhere or assigned to inside a function. 7 | -- 8 | 9 | local getinfo, error, rawset, rawget = debug.getinfo, error, rawset, rawget 10 | 11 | local mt = getmetatable(_G) 12 | if mt == nil then 13 | mt = {} 14 | setmetatable(_G, mt) 15 | end 16 | 17 | mt.__declared = {} 18 | 19 | local function what () 20 | local d = getinfo(3, "S") 21 | return d and d.what or "C" 22 | end 23 | 24 | mt.__newindex = function (t, n, v) 25 | if not mt.__declared[n] then 26 | local w = what() 27 | if w ~= "main" and w ~= "C" then 28 | error("assign to undeclared variable '"..n.."'", 2) 29 | end 30 | mt.__declared[n] = true 31 | end 32 | rawset(t, n, v) 33 | end 34 | 35 | mt.__index = function (t, n) 36 | if not mt.__declared[n] and what() ~= "C" then 37 | error("variable '"..n.."' is not declared", 2) 38 | end 39 | return rawget(t, n) 40 | end 41 | 42 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/src/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Auxiliary functions from Lua API 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lapi_h 8 | #define lapi_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/src/lcode.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Code generator for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lcode_h 8 | #define lcode_h 9 | 10 | #include "llex.h" 11 | #include "lobject.h" 12 | #include "lopcodes.h" 13 | #include "lparser.h" 14 | 15 | 16 | /* 17 | ** Marks the end of a patch list. It is an invalid value both as an absolute 18 | ** address, and as a list link (would link an element to itself). 19 | */ 20 | #define NO_JUMP (-1) 21 | 22 | 23 | /* 24 | ** grep "ORDER OPR" if you change these enums 25 | */ 26 | typedef enum BinOpr { 27 | OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW, 28 | OPR_CONCAT, 29 | OPR_NE, OPR_EQ, 30 | OPR_LT, OPR_LE, OPR_GT, OPR_GE, 31 | OPR_AND, OPR_OR, 32 | OPR_NOBINOPR 33 | } BinOpr; 34 | 35 | 36 | typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; 37 | 38 | 39 | #define getcode(fs,e) ((fs)->f->code[(e)->u.s.info]) 40 | 41 | #define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) 42 | 43 | #define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) 44 | 45 | LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); 46 | LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); 47 | LUAI_FUNC void luaK_fixline (FuncState *fs, int line); 48 | LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); 49 | LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); 50 | LUAI_FUNC void luaK_checkstack (FuncState *fs, int n); 51 | LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s); 52 | LUAI_FUNC int luaK_numberK (FuncState *fs, lua_Number r); 53 | LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); 54 | LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); 55 | LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); 56 | LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); 57 | LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); 58 | LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); 59 | LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); 60 | LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); 61 | LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e); 62 | LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults); 63 | LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e); 64 | LUAI_FUNC int luaK_jump (FuncState *fs); 65 | LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret); 66 | LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target); 67 | LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); 68 | LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); 69 | LUAI_FUNC int luaK_getlabel (FuncState *fs); 70 | LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v); 71 | LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); 72 | LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2); 73 | LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); 74 | 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/src/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Auxiliary functions from Debug Interface module 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldebug_h 8 | #define ldebug_h 9 | 10 | 11 | #include "lstate.h" 12 | 13 | 14 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) 15 | 16 | #define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) 17 | 18 | #define resethookcount(L) (L->hookcount = L->basehookcount) 19 | 20 | 21 | LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o, 22 | const char *opname); 23 | LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2); 24 | LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1, 25 | const TValue *p2); 26 | LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1, 27 | const TValue *p2); 28 | LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...); 29 | LUAI_FUNC void luaG_errormsg (lua_State *L); 30 | LUAI_FUNC int luaG_checkcode (const Proto *pt); 31 | LUAI_FUNC int luaG_checkopenop (Instruction i); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/src/ldo.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Stack and Call structure of Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldo_h 8 | #define ldo_h 9 | 10 | 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | #include "lzio.h" 14 | 15 | 16 | #define luaD_checkstack(L,n) \ 17 | if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \ 18 | luaD_growstack(L, n); \ 19 | else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); 20 | 21 | 22 | #define incr_top(L) {luaD_checkstack(L,1); L->top++;} 23 | 24 | #define savestack(L,p) ((char *)(p) - (char *)L->stack) 25 | #define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) 26 | 27 | #define saveci(L,p) ((char *)(p) - (char *)L->base_ci) 28 | #define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n))) 29 | 30 | 31 | /* results from luaD_precall */ 32 | #define PCRLUA 0 /* initiated a call to a Lua function */ 33 | #define PCRC 1 /* did a call to a C function */ 34 | #define PCRYIELD 2 /* C funtion yielded */ 35 | 36 | 37 | /* type of protected functions, to be ran by `runprotected' */ 38 | typedef void (*Pfunc) (lua_State *L, void *ud); 39 | 40 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name); 41 | LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line); 42 | LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); 43 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); 44 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, 45 | ptrdiff_t oldtop, ptrdiff_t ef); 46 | LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); 47 | LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize); 48 | LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); 49 | LUAI_FUNC void luaD_growstack (lua_State *L, int n); 50 | 51 | LUAI_FUNC void luaD_throw (lua_State *L, int errcode); 52 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); 53 | 54 | LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop); 55 | 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/src/lfunc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Auxiliary functions to manipulate prototypes and closures 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lfunc_h 8 | #define lfunc_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ 15 | cast(int, sizeof(TValue)*((n)-1))) 16 | 17 | #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ 18 | cast(int, sizeof(TValue *)*((n)-1))) 19 | 20 | 21 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); 22 | LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e); 23 | LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e); 24 | LUAI_FUNC UpVal *luaF_newupval (lua_State *L); 25 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 26 | LUAI_FUNC void luaF_close (lua_State *L, StkId level); 27 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 28 | LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c); 29 | LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); 30 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, 31 | int pc); 32 | 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/src/lgc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Garbage Collector 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lgc_h 8 | #define lgc_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | /* 15 | ** Possible states of the Garbage Collector 16 | */ 17 | #define GCSpause 0 18 | #define GCSpropagate 1 19 | #define GCSsweepstring 2 20 | #define GCSsweep 3 21 | #define GCSfinalize 4 22 | 23 | 24 | /* 25 | ** some userful bit tricks 26 | */ 27 | #define resetbits(x,m) ((x) &= cast(lu_byte, ~(m))) 28 | #define setbits(x,m) ((x) |= (m)) 29 | #define testbits(x,m) ((x) & (m)) 30 | #define bitmask(b) (1<<(b)) 31 | #define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2)) 32 | #define l_setbit(x,b) setbits(x, bitmask(b)) 33 | #define resetbit(x,b) resetbits(x, bitmask(b)) 34 | #define testbit(x,b) testbits(x, bitmask(b)) 35 | #define set2bits(x,b1,b2) setbits(x, (bit2mask(b1, b2))) 36 | #define reset2bits(x,b1,b2) resetbits(x, (bit2mask(b1, b2))) 37 | #define test2bits(x,b1,b2) testbits(x, (bit2mask(b1, b2))) 38 | 39 | 40 | 41 | /* 42 | ** Layout for bit use in `marked' field: 43 | ** bit 0 - object is white (type 0) 44 | ** bit 1 - object is white (type 1) 45 | ** bit 2 - object is black 46 | ** bit 3 - for userdata: has been finalized 47 | ** bit 3 - for tables: has weak keys 48 | ** bit 4 - for tables: has weak values 49 | ** bit 5 - object is fixed (should not be collected) 50 | ** bit 6 - object is "super" fixed (only the main thread) 51 | */ 52 | 53 | 54 | #define WHITE0BIT 0 55 | #define WHITE1BIT 1 56 | #define BLACKBIT 2 57 | #define FINALIZEDBIT 3 58 | #define KEYWEAKBIT 3 59 | #define VALUEWEAKBIT 4 60 | #define FIXEDBIT 5 61 | #define SFIXEDBIT 6 62 | #define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) 63 | 64 | 65 | #define iswhite(x) test2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) 66 | #define isblack(x) testbit((x)->gch.marked, BLACKBIT) 67 | #define isgray(x) (!isblack(x) && !iswhite(x)) 68 | 69 | #define otherwhite(g) (g->currentwhite ^ WHITEBITS) 70 | #define isdead(g,v) ((v)->gch.marked & otherwhite(g) & WHITEBITS) 71 | 72 | #define changewhite(x) ((x)->gch.marked ^= WHITEBITS) 73 | #define gray2black(x) l_setbit((x)->gch.marked, BLACKBIT) 74 | 75 | #define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x))) 76 | 77 | #define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS) 78 | 79 | 80 | #define luaC_checkGC(L) { \ 81 | condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); \ 82 | if (G(L)->totalbytes >= G(L)->GCthreshold) \ 83 | luaC_step(L); } 84 | 85 | 86 | #define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \ 87 | luaC_barrierf(L,obj2gco(p),gcvalue(v)); } 88 | 89 | #define luaC_barriert(L,t,v) { if (valiswhite(v) && isblack(obj2gco(t))) \ 90 | luaC_barrierback(L,t); } 91 | 92 | #define luaC_objbarrier(L,p,o) \ 93 | { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \ 94 | luaC_barrierf(L,obj2gco(p),obj2gco(o)); } 95 | 96 | #define luaC_objbarriert(L,t,o) \ 97 | { if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) luaC_barrierback(L,t); } 98 | 99 | LUAI_FUNC size_t luaC_separateudata (lua_State *L, int all); 100 | LUAI_FUNC void luaC_callGCTM (lua_State *L); 101 | LUAI_FUNC void luaC_freeall (lua_State *L); 102 | LUAI_FUNC void luaC_step (lua_State *L); 103 | LUAI_FUNC void luaC_fullgc (lua_State *L); 104 | LUAI_FUNC void luaC_link (lua_State *L, GCObject *o, lu_byte tt); 105 | LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv); 106 | LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v); 107 | LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t); 108 | 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/src/linit.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Initialization of libraries for lua.c 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #define linit_c 9 | #define LUA_LIB 10 | 11 | #include "lua.h" 12 | 13 | #include "lualib.h" 14 | #include "lauxlib.h" 15 | 16 | 17 | static const luaL_Reg lualibs[] = { 18 | {"", luaopen_base}, 19 | {LUA_LOADLIBNAME, luaopen_package}, 20 | {LUA_TABLIBNAME, luaopen_table}, 21 | {LUA_IOLIBNAME, luaopen_io}, 22 | {LUA_OSLIBNAME, luaopen_os}, 23 | {LUA_STRLIBNAME, luaopen_string}, 24 | {LUA_MATHLIBNAME, luaopen_math}, 25 | {LUA_DBLIBNAME, luaopen_debug}, 26 | {NULL, NULL} 27 | }; 28 | 29 | 30 | LUALIB_API void luaL_openlibs (lua_State *L) { 31 | const luaL_Reg *lib = lualibs; 32 | for (; lib->func; lib++) { 33 | lua_pushcfunction(L, lib->func); 34 | lua_pushstring(L, lib->name); 35 | lua_call(L, 1, 0); 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/src/llex.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lexical Analyzer 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef llex_h 8 | #define llex_h 9 | 10 | #include "lobject.h" 11 | #include "lzio.h" 12 | 13 | 14 | #define FIRST_RESERVED 257 15 | 16 | /* maximum length of a reserved word */ 17 | #define TOKEN_LEN (sizeof("function")/sizeof(char)) 18 | 19 | 20 | /* 21 | * WARNING: if you change the order of this enumeration, 22 | * grep "ORDER RESERVED" 23 | */ 24 | enum RESERVED { 25 | /* terminal symbols denoted by reserved words */ 26 | TK_AND = FIRST_RESERVED, TK_BREAK, 27 | TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, 28 | TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, 29 | TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, 30 | /* other terminal symbols */ 31 | TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER, 32 | TK_NAME, TK_STRING, TK_EOS 33 | }; 34 | 35 | /* number of reserved words */ 36 | #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) 37 | 38 | 39 | /* array with token `names' */ 40 | LUAI_DATA const char *const luaX_tokens []; 41 | 42 | 43 | typedef union { 44 | lua_Number r; 45 | TString *ts; 46 | } SemInfo; /* semantics information */ 47 | 48 | 49 | typedef struct Token { 50 | int token; 51 | SemInfo seminfo; 52 | } Token; 53 | 54 | 55 | typedef struct LexState { 56 | int current; /* current character (charint) */ 57 | int linenumber; /* input line counter */ 58 | int lastline; /* line of last token `consumed' */ 59 | Token t; /* current token */ 60 | Token lookahead; /* look ahead token */ 61 | struct FuncState *fs; /* `FuncState' is private to the parser */ 62 | struct lua_State *L; 63 | ZIO *z; /* input stream */ 64 | Mbuffer *buff; /* buffer for tokens */ 65 | TString *source; /* current source name */ 66 | char decpoint; /* locale decimal point */ 67 | } LexState; 68 | 69 | 70 | LUAI_FUNC void luaX_init (lua_State *L); 71 | LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, 72 | TString *source); 73 | LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); 74 | LUAI_FUNC void luaX_next (LexState *ls); 75 | LUAI_FUNC void luaX_lookahead (LexState *ls); 76 | LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token); 77 | LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s); 78 | LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); 79 | 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/src/llimits.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Limits, basic types, and some other `installation-dependent' definitions 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef llimits_h 8 | #define llimits_h 9 | 10 | 11 | #include 12 | #include 13 | 14 | 15 | #include "lua.h" 16 | 17 | 18 | typedef LUAI_UINT32 lu_int32; 19 | 20 | typedef LUAI_UMEM lu_mem; 21 | 22 | typedef LUAI_MEM l_mem; 23 | 24 | 25 | 26 | /* chars used as small naturals (so that `char' is reserved for characters) */ 27 | typedef unsigned char lu_byte; 28 | 29 | 30 | #define MAX_SIZET ((size_t)(~(size_t)0)-2) 31 | 32 | #define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2) 33 | 34 | 35 | #define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */ 36 | 37 | /* 38 | ** conversion of pointer to integer 39 | ** this is for hashing only; there is no problem if the integer 40 | ** cannot hold the whole pointer value 41 | */ 42 | #define IntPoint(p) ((unsigned int)(lu_mem)(p)) 43 | 44 | 45 | 46 | /* type to ensure maximum alignment */ 47 | typedef LUAI_USER_ALIGNMENT_T L_Umaxalign; 48 | 49 | 50 | /* result of a `usual argument conversion' over lua_Number */ 51 | typedef LUAI_UACNUMBER l_uacNumber; 52 | 53 | 54 | /* internal assertions for in-house debugging */ 55 | #ifdef lua_assert 56 | 57 | #define check_exp(c,e) (lua_assert(c), (e)) 58 | #define api_check(l,e) lua_assert(e) 59 | 60 | #else 61 | 62 | #define lua_assert(c) ((void)0) 63 | #define check_exp(c,e) (e) 64 | #define api_check luai_apicheck 65 | 66 | #endif 67 | 68 | 69 | #ifndef UNUSED 70 | #define UNUSED(x) ((void)(x)) /* to avoid warnings */ 71 | #endif 72 | 73 | 74 | #ifndef cast 75 | #define cast(t, exp) ((t)(exp)) 76 | #endif 77 | 78 | #define cast_byte(i) cast(lu_byte, (i)) 79 | #define cast_num(i) cast(lua_Number, (i)) 80 | #define cast_int(i) cast(int, (i)) 81 | 82 | 83 | 84 | /* 85 | ** type for virtual-machine instructions 86 | ** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h) 87 | */ 88 | typedef lu_int32 Instruction; 89 | 90 | 91 | 92 | /* maximum stack for a Lua function */ 93 | #define MAXSTACK 250 94 | 95 | 96 | 97 | /* minimum size for the string table (must be power of 2) */ 98 | #ifndef MINSTRTABSIZE 99 | #define MINSTRTABSIZE 32 100 | #endif 101 | 102 | 103 | /* minimum size for string buffer */ 104 | #ifndef LUA_MINBUFFER 105 | #define LUA_MINBUFFER 32 106 | #endif 107 | 108 | 109 | #ifndef lua_lock 110 | #define lua_lock(L) ((void) 0) 111 | #define lua_unlock(L) ((void) 0) 112 | #endif 113 | 114 | #ifndef luai_threadyield 115 | #define luai_threadyield(L) {lua_unlock(L); lua_lock(L);} 116 | #endif 117 | 118 | 119 | /* 120 | ** macro to control inclusion of some hard tests on stack reallocation 121 | */ 122 | #ifndef HARDSTACKTESTS 123 | #define condhardstacktests(x) ((void)0) 124 | #else 125 | #define condhardstacktests(x) x 126 | #endif 127 | 128 | #endif 129 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/src/lmem.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.c,v 1.70.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #include 9 | 10 | #define lmem_c 11 | #define LUA_CORE 12 | 13 | #include "lua.h" 14 | 15 | #include "ldebug.h" 16 | #include "ldo.h" 17 | #include "lmem.h" 18 | #include "lobject.h" 19 | #include "lstate.h" 20 | 21 | 22 | 23 | /* 24 | ** About the realloc function: 25 | ** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize); 26 | ** (`osize' is the old size, `nsize' is the new size) 27 | ** 28 | ** Lua ensures that (ptr == NULL) iff (osize == 0). 29 | ** 30 | ** * frealloc(ud, NULL, 0, x) creates a new block of size `x' 31 | ** 32 | ** * frealloc(ud, p, x, 0) frees the block `p' 33 | ** (in this specific case, frealloc must return NULL). 34 | ** particularly, frealloc(ud, NULL, 0, 0) does nothing 35 | ** (which is equivalent to free(NULL) in ANSI C) 36 | ** 37 | ** frealloc returns NULL if it cannot create or reallocate the area 38 | ** (any reallocation to an equal or smaller size cannot fail!) 39 | */ 40 | 41 | 42 | 43 | #define MINSIZEARRAY 4 44 | 45 | 46 | void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, 47 | int limit, const char *errormsg) { 48 | void *newblock; 49 | int newsize; 50 | if (*size >= limit/2) { /* cannot double it? */ 51 | if (*size >= limit) /* cannot grow even a little? */ 52 | luaG_runerror(L, errormsg); 53 | newsize = limit; /* still have at least one free place */ 54 | } 55 | else { 56 | newsize = (*size)*2; 57 | if (newsize < MINSIZEARRAY) 58 | newsize = MINSIZEARRAY; /* minimum size */ 59 | } 60 | newblock = luaM_reallocv(L, block, *size, newsize, size_elems); 61 | *size = newsize; /* update only when everything else is OK */ 62 | return newblock; 63 | } 64 | 65 | 66 | void *luaM_toobig (lua_State *L) { 67 | luaG_runerror(L, "memory allocation error: block too big"); 68 | return NULL; /* to avoid warnings */ 69 | } 70 | 71 | 72 | 73 | /* 74 | ** generic allocation routine. 75 | */ 76 | void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { 77 | global_State *g = G(L); 78 | lua_assert((osize == 0) == (block == NULL)); 79 | block = (*g->frealloc)(g->ud, block, osize, nsize); 80 | if (block == NULL && nsize > 0) 81 | luaD_throw(L, LUA_ERRMEM); 82 | lua_assert((nsize == 0) == (block == NULL)); 83 | g->totalbytes = (g->totalbytes - osize) + nsize; 84 | return block; 85 | } 86 | 87 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/src/lmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lmem_h 8 | #define lmem_h 9 | 10 | 11 | #include 12 | 13 | #include "llimits.h" 14 | #include "lua.h" 15 | 16 | #define MEMERRMSG "not enough memory" 17 | 18 | 19 | #define luaM_reallocv(L,b,on,n,e) \ 20 | ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ 21 | luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \ 22 | luaM_toobig(L)) 23 | 24 | #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) 25 | #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) 26 | #define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t)) 27 | 28 | #define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t)) 29 | #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) 30 | #define luaM_newvector(L,n,t) \ 31 | cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) 32 | 33 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \ 34 | if ((nelems)+1 > (size)) \ 35 | ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) 36 | 37 | #define luaM_reallocvector(L, v,oldn,n,t) \ 38 | ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) 39 | 40 | 41 | LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, 42 | size_t size); 43 | LUAI_FUNC void *luaM_toobig (lua_State *L); 44 | LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, 45 | size_t size_elem, int limit, 46 | const char *errormsg); 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/src/lopcodes.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lopcodes.c,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** See Copyright Notice in lua.h 4 | */ 5 | 6 | 7 | #define lopcodes_c 8 | #define LUA_CORE 9 | 10 | 11 | #include "lopcodes.h" 12 | 13 | 14 | /* ORDER OP */ 15 | 16 | const char *const luaP_opnames[NUM_OPCODES+1] = { 17 | "MOVE", 18 | "LOADK", 19 | "LOADBOOL", 20 | "LOADNIL", 21 | "GETUPVAL", 22 | "GETGLOBAL", 23 | "GETTABLE", 24 | "SETGLOBAL", 25 | "SETUPVAL", 26 | "SETTABLE", 27 | "NEWTABLE", 28 | "SELF", 29 | "ADD", 30 | "SUB", 31 | "MUL", 32 | "DIV", 33 | "MOD", 34 | "POW", 35 | "UNM", 36 | "NOT", 37 | "LEN", 38 | "CONCAT", 39 | "JMP", 40 | "EQ", 41 | "LT", 42 | "LE", 43 | "TEST", 44 | "TESTSET", 45 | "CALL", 46 | "TAILCALL", 47 | "RETURN", 48 | "FORLOOP", 49 | "FORPREP", 50 | "TFORLOOP", 51 | "SETLIST", 52 | "CLOSE", 53 | "CLOSURE", 54 | "VARARG", 55 | NULL 56 | }; 57 | 58 | 59 | #define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m)) 60 | 61 | const lu_byte luaP_opmodes[NUM_OPCODES] = { 62 | /* T A B C mode opcode */ 63 | opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ 64 | ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */ 65 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */ 66 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LOADNIL */ 67 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */ 68 | ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_GETGLOBAL */ 69 | ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */ 70 | ,opmode(0, 0, OpArgK, OpArgN, iABx) /* OP_SETGLOBAL */ 71 | ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */ 72 | ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */ 73 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */ 74 | ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */ 75 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */ 76 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */ 77 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */ 78 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */ 79 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */ 80 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */ 81 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */ 82 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */ 83 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */ 84 | ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */ 85 | ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */ 86 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */ 87 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */ 88 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */ 89 | ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TEST */ 90 | ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */ 91 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */ 92 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */ 93 | ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */ 94 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */ 95 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */ 96 | ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TFORLOOP */ 97 | ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */ 98 | ,opmode(0, 0, OpArgN, OpArgN, iABC) /* OP_CLOSE */ 99 | ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */ 100 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */ 101 | }; 102 | 103 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/src/lparser.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lua Parser 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lparser_h 8 | #define lparser_h 9 | 10 | #include "llimits.h" 11 | #include "lobject.h" 12 | #include "lzio.h" 13 | 14 | 15 | /* 16 | ** Expression descriptor 17 | */ 18 | 19 | typedef enum { 20 | VVOID, /* no value */ 21 | VNIL, 22 | VTRUE, 23 | VFALSE, 24 | VK, /* info = index of constant in `k' */ 25 | VKNUM, /* nval = numerical value */ 26 | VLOCAL, /* info = local register */ 27 | VUPVAL, /* info = index of upvalue in `upvalues' */ 28 | VGLOBAL, /* info = index of table; aux = index of global name in `k' */ 29 | VINDEXED, /* info = table register; aux = index register (or `k') */ 30 | VJMP, /* info = instruction pc */ 31 | VRELOCABLE, /* info = instruction pc */ 32 | VNONRELOC, /* info = result register */ 33 | VCALL, /* info = instruction pc */ 34 | VVARARG /* info = instruction pc */ 35 | } expkind; 36 | 37 | typedef struct expdesc { 38 | expkind k; 39 | union { 40 | struct { int info, aux; } s; 41 | lua_Number nval; 42 | } u; 43 | int t; /* patch list of `exit when true' */ 44 | int f; /* patch list of `exit when false' */ 45 | } expdesc; 46 | 47 | 48 | typedef struct upvaldesc { 49 | lu_byte k; 50 | lu_byte info; 51 | } upvaldesc; 52 | 53 | 54 | struct BlockCnt; /* defined in lparser.c */ 55 | 56 | 57 | /* state needed to generate code for a given function */ 58 | typedef struct FuncState { 59 | Proto *f; /* current function header */ 60 | Table *h; /* table to find (and reuse) elements in `k' */ 61 | struct FuncState *prev; /* enclosing function */ 62 | struct LexState *ls; /* lexical state */ 63 | struct lua_State *L; /* copy of the Lua state */ 64 | struct BlockCnt *bl; /* chain of current blocks */ 65 | int pc; /* next position to code (equivalent to `ncode') */ 66 | int lasttarget; /* `pc' of last `jump target' */ 67 | int jpc; /* list of pending jumps to `pc' */ 68 | int freereg; /* first free register */ 69 | int nk; /* number of elements in `k' */ 70 | int np; /* number of elements in `p' */ 71 | short nlocvars; /* number of elements in `locvars' */ 72 | lu_byte nactvar; /* number of active local variables */ 73 | upvaldesc upvalues[LUAI_MAXUPVALUES]; /* upvalues */ 74 | unsigned short actvar[LUAI_MAXVARS]; /* declared-variable stack */ 75 | } FuncState; 76 | 77 | 78 | LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, 79 | const char *name); 80 | 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/src/lstring.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** String table (keeps all strings handled by Lua) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #include 9 | 10 | #define lstring_c 11 | #define LUA_CORE 12 | 13 | #include "lua.h" 14 | 15 | #include "lmem.h" 16 | #include "lobject.h" 17 | #include "lstate.h" 18 | #include "lstring.h" 19 | 20 | 21 | 22 | void luaS_resize (lua_State *L, int newsize) { 23 | GCObject **newhash; 24 | stringtable *tb; 25 | int i; 26 | if (G(L)->gcstate == GCSsweepstring) 27 | return; /* cannot resize during GC traverse */ 28 | newhash = luaM_newvector(L, newsize, GCObject *); 29 | tb = &G(L)->strt; 30 | for (i=0; isize; i++) { 33 | GCObject *p = tb->hash[i]; 34 | while (p) { /* for each node in the list */ 35 | GCObject *next = p->gch.next; /* save next */ 36 | unsigned int h = gco2ts(p)->hash; 37 | int h1 = lmod(h, newsize); /* new position */ 38 | lua_assert(cast_int(h%newsize) == lmod(h, newsize)); 39 | p->gch.next = newhash[h1]; /* chain it */ 40 | newhash[h1] = p; 41 | p = next; 42 | } 43 | } 44 | luaM_freearray(L, tb->hash, tb->size, TString *); 45 | tb->size = newsize; 46 | tb->hash = newhash; 47 | } 48 | 49 | 50 | static TString *newlstr (lua_State *L, const char *str, size_t l, 51 | unsigned int h) { 52 | TString *ts; 53 | stringtable *tb; 54 | if (l+1 > (MAX_SIZET - sizeof(TString))/sizeof(char)) 55 | luaM_toobig(L); 56 | ts = cast(TString *, luaM_malloc(L, (l+1)*sizeof(char)+sizeof(TString))); 57 | ts->tsv.len = l; 58 | ts->tsv.hash = h; 59 | ts->tsv.marked = luaC_white(G(L)); 60 | ts->tsv.tt = LUA_TSTRING; 61 | ts->tsv.reserved = 0; 62 | memcpy(ts+1, str, l*sizeof(char)); 63 | ((char *)(ts+1))[l] = '\0'; /* ending 0 */ 64 | tb = &G(L)->strt; 65 | h = lmod(h, tb->size); 66 | ts->tsv.next = tb->hash[h]; /* chain new entry */ 67 | tb->hash[h] = obj2gco(ts); 68 | tb->nuse++; 69 | if (tb->nuse > cast(lu_int32, tb->size) && tb->size <= MAX_INT/2) 70 | luaS_resize(L, tb->size*2); /* too crowded */ 71 | return ts; 72 | } 73 | 74 | 75 | TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { 76 | GCObject *o; 77 | unsigned int h = cast(unsigned int, l); /* seed */ 78 | size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */ 79 | size_t l1; 80 | for (l1=l; l1>=step; l1-=step) /* compute hash */ 81 | h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1])); 82 | for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)]; 83 | o != NULL; 84 | o = o->gch.next) { 85 | TString *ts = rawgco2ts(o); 86 | if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) { 87 | /* string may be dead */ 88 | if (isdead(G(L), o)) changewhite(o); 89 | return ts; 90 | } 91 | } 92 | return newlstr(L, str, l, h); /* not found */ 93 | } 94 | 95 | 96 | Udata *luaS_newudata (lua_State *L, size_t s, Table *e) { 97 | Udata *u; 98 | if (s > MAX_SIZET - sizeof(Udata)) 99 | luaM_toobig(L); 100 | u = cast(Udata *, luaM_malloc(L, s + sizeof(Udata))); 101 | u->uv.marked = luaC_white(G(L)); /* is not finalized */ 102 | u->uv.tt = LUA_TUSERDATA; 103 | u->uv.len = s; 104 | u->uv.metatable = NULL; 105 | u->uv.env = e; 106 | /* chain it on udata list (after main thread) */ 107 | u->uv.next = G(L)->mainthread->next; 108 | G(L)->mainthread->next = obj2gco(u); 109 | return u; 110 | } 111 | 112 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/src/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** String table (keep all strings handled by Lua) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lstring_h 8 | #define lstring_h 9 | 10 | 11 | #include "lgc.h" 12 | #include "lobject.h" 13 | #include "lstate.h" 14 | 15 | 16 | #define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char)) 17 | 18 | #define sizeudata(u) (sizeof(union Udata)+(u)->len) 19 | 20 | #define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s))) 21 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 22 | (sizeof(s)/sizeof(char))-1)) 23 | 24 | #define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) 25 | 26 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 27 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); 28 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 29 | 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/src/ltable.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lua tables (hash) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltable_h 8 | #define ltable_h 9 | 10 | #include "lobject.h" 11 | 12 | 13 | #define gnode(t,i) (&(t)->node[i]) 14 | #define gkey(n) (&(n)->i_key.nk) 15 | #define gval(n) (&(n)->i_val) 16 | #define gnext(n) ((n)->i_key.nk.next) 17 | 18 | #define key2tval(n) (&(n)->i_key.tvk) 19 | 20 | 21 | LUAI_FUNC const TValue *luaH_getnum (Table *t, int key); 22 | LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key); 23 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); 24 | LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key); 25 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); 26 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); 27 | LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash); 28 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize); 29 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); 30 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); 31 | LUAI_FUNC int luaH_getn (Table *t); 32 | 33 | 34 | #if defined(LUA_DEBUG) 35 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 36 | LUAI_FUNC int luaH_isdummy (Node *n); 37 | #endif 38 | 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/src/ltm.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Tag methods 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #include 9 | 10 | #define ltm_c 11 | #define LUA_CORE 12 | 13 | #include "lua.h" 14 | 15 | #include "lobject.h" 16 | #include "lstate.h" 17 | #include "lstring.h" 18 | #include "ltable.h" 19 | #include "ltm.h" 20 | 21 | 22 | 23 | const char *const luaT_typenames[] = { 24 | "nil", "boolean", "userdata", "number", 25 | "string", "table", "function", "userdata", "thread", 26 | "proto", "upval" 27 | }; 28 | 29 | 30 | void luaT_init (lua_State *L) { 31 | static const char *const luaT_eventname[] = { /* ORDER TM */ 32 | "__index", "__newindex", 33 | "__gc", "__mode", "__eq", 34 | "__add", "__sub", "__mul", "__div", "__mod", 35 | "__pow", "__unm", "__len", "__lt", "__le", 36 | "__concat", "__call" 37 | }; 38 | int i; 39 | for (i=0; itmname[i] = luaS_new(L, luaT_eventname[i]); 41 | luaS_fix(G(L)->tmname[i]); /* never collect these names */ 42 | } 43 | } 44 | 45 | 46 | /* 47 | ** function to be used with macro "fasttm": optimized for absence of 48 | ** tag methods 49 | */ 50 | const TValue *luaT_gettm (Table *events, TMS event, TString *ename) { 51 | const TValue *tm = luaH_getstr(events, ename); 52 | lua_assert(event <= TM_EQ); 53 | if (ttisnil(tm)) { /* no tag method? */ 54 | events->flags |= cast_byte(1u<metatable; 66 | break; 67 | case LUA_TUSERDATA: 68 | mt = uvalue(o)->metatable; 69 | break; 70 | default: 71 | mt = G(L)->mt[ttype(o)]; 72 | } 73 | return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject); 74 | } 75 | 76 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/src/ltm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Tag methods 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltm_h 8 | #define ltm_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | /* 15 | * WARNING: if you change the order of this enumeration, 16 | * grep "ORDER TM" 17 | */ 18 | typedef enum { 19 | TM_INDEX, 20 | TM_NEWINDEX, 21 | TM_GC, 22 | TM_MODE, 23 | TM_EQ, /* last tag method with `fast' access */ 24 | TM_ADD, 25 | TM_SUB, 26 | TM_MUL, 27 | TM_DIV, 28 | TM_MOD, 29 | TM_POW, 30 | TM_UNM, 31 | TM_LEN, 32 | TM_LT, 33 | TM_LE, 34 | TM_CONCAT, 35 | TM_CALL, 36 | TM_N /* number of elements in the enum */ 37 | } TMS; 38 | 39 | 40 | 41 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 42 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 43 | 44 | #define fasttm(l,et,e) gfasttm(G(l), et, e) 45 | 46 | LUAI_DATA const char *const luaT_typenames[]; 47 | 48 | 49 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 50 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 51 | TMS event); 52 | LUAI_FUNC void luaT_init (lua_State *L); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/src/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lualib_h 9 | #define lualib_h 10 | 11 | #include "lua.h" 12 | 13 | 14 | /* Key to file-handle type */ 15 | #define LUA_FILEHANDLE "FILE*" 16 | 17 | 18 | #define LUA_COLIBNAME "coroutine" 19 | LUALIB_API int (luaopen_base) (lua_State *L); 20 | 21 | #define LUA_TABLIBNAME "table" 22 | LUALIB_API int (luaopen_table) (lua_State *L); 23 | 24 | #define LUA_IOLIBNAME "io" 25 | LUALIB_API int (luaopen_io) (lua_State *L); 26 | 27 | #define LUA_OSLIBNAME "os" 28 | LUALIB_API int (luaopen_os) (lua_State *L); 29 | 30 | #define LUA_STRLIBNAME "string" 31 | LUALIB_API int (luaopen_string) (lua_State *L); 32 | 33 | #define LUA_MATHLIBNAME "math" 34 | LUALIB_API int (luaopen_math) (lua_State *L); 35 | 36 | #define LUA_DBLIBNAME "debug" 37 | LUALIB_API int (luaopen_debug) (lua_State *L); 38 | 39 | #define LUA_LOADLIBNAME "package" 40 | LUALIB_API int (luaopen_package) (lua_State *L); 41 | 42 | 43 | /* open all previous libraries */ 44 | LUALIB_API void (luaL_openlibs) (lua_State *L); 45 | 46 | 47 | 48 | #ifndef lua_assert 49 | #define lua_assert(x) ((void)0) 50 | #endif 51 | 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/src/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** load precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lundump_h 8 | #define lundump_h 9 | 10 | #include "lobject.h" 11 | #include "lzio.h" 12 | 13 | /* load one chunk; from lundump.c */ 14 | LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); 15 | 16 | /* make header; from lundump.c */ 17 | LUAI_FUNC void luaU_header (char* h); 18 | 19 | /* dump one chunk; from ldump.c */ 20 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); 21 | 22 | #ifdef luac_c 23 | /* print one chunk; from print.c */ 24 | LUAI_FUNC void luaU_print (const Proto* f, int full); 25 | #endif 26 | 27 | /* for header of binary files -- this is Lua 5.1 */ 28 | #define LUAC_VERSION 0x51 29 | 30 | /* for header of binary files -- this is the official format */ 31 | #define LUAC_FORMAT 0 32 | 33 | /* size of header of binary files */ 34 | #define LUAC_HEADERSIZE 12 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/src/lvm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lua virtual machine 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lvm_h 8 | #define lvm_h 9 | 10 | 11 | #include "ldo.h" 12 | #include "lobject.h" 13 | #include "ltm.h" 14 | 15 | 16 | #define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o))) 17 | 18 | #define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \ 19 | (((o) = luaV_tonumber(o,n)) != NULL)) 20 | 21 | #define equalobj(L,o1,o2) \ 22 | (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2)) 23 | 24 | 25 | LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); 26 | LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2); 27 | LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); 28 | LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); 29 | LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, 30 | StkId val); 31 | LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, 32 | StkId val); 33 | LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls); 34 | LUAI_FUNC void luaV_concat (lua_State *L, int total, int last); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/src/lzio.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** a generic input stream interface 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #include 9 | 10 | #define lzio_c 11 | #define LUA_CORE 12 | 13 | #include "lua.h" 14 | 15 | #include "llimits.h" 16 | #include "lmem.h" 17 | #include "lstate.h" 18 | #include "lzio.h" 19 | 20 | 21 | int luaZ_fill (ZIO *z) { 22 | size_t size; 23 | lua_State *L = z->L; 24 | const char *buff; 25 | lua_unlock(L); 26 | buff = z->reader(L, z->data, &size); 27 | lua_lock(L); 28 | if (buff == NULL || size == 0) return EOZ; 29 | z->n = size - 1; 30 | z->p = buff; 31 | return char2int(*(z->p++)); 32 | } 33 | 34 | 35 | int luaZ_lookahead (ZIO *z) { 36 | if (z->n == 0) { 37 | if (luaZ_fill(z) == EOZ) 38 | return EOZ; 39 | else { 40 | z->n++; /* luaZ_fill removed first byte; put back it */ 41 | z->p--; 42 | } 43 | } 44 | return char2int(*z->p); 45 | } 46 | 47 | 48 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { 49 | z->L = L; 50 | z->reader = reader; 51 | z->data = data; 52 | z->n = 0; 53 | z->p = NULL; 54 | } 55 | 56 | 57 | /* --------------------------------------------------------------- read --- */ 58 | size_t luaZ_read (ZIO *z, void *b, size_t n) { 59 | while (n) { 60 | size_t m; 61 | if (luaZ_lookahead(z) == EOZ) 62 | return n; /* return number of missing bytes */ 63 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ 64 | memcpy(b, z->p, m); 65 | z->n -= m; 66 | z->p += m; 67 | b = (char *)b + m; 68 | n -= m; 69 | } 70 | return 0; 71 | } 72 | 73 | /* ------------------------------------------------------------------------ */ 74 | char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) { 75 | if (n > buff->buffsize) { 76 | if (n < LUA_MINBUFFER) n = LUA_MINBUFFER; 77 | luaZ_resizebuffer(L, buff, n); 78 | } 79 | return buff->buffer; 80 | } 81 | 82 | 83 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/src/lzio.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lzio_h 9 | #define lzio_h 10 | 11 | #include "lua.h" 12 | 13 | #include "lmem.h" 14 | 15 | 16 | #define EOZ (-1) /* end of stream */ 17 | 18 | typedef struct Zio ZIO; 19 | 20 | #define char2int(c) cast(int, cast(unsigned char, (c))) 21 | 22 | #define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z)) 23 | 24 | typedef struct Mbuffer { 25 | char *buffer; 26 | size_t n; 27 | size_t buffsize; 28 | } Mbuffer; 29 | 30 | #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) 31 | 32 | #define luaZ_buffer(buff) ((buff)->buffer) 33 | #define luaZ_sizebuffer(buff) ((buff)->buffsize) 34 | #define luaZ_bufflen(buff) ((buff)->n) 35 | 36 | #define luaZ_resetbuffer(buff) ((buff)->n = 0) 37 | 38 | 39 | #define luaZ_resizebuffer(L, buff, size) \ 40 | (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \ 41 | (buff)->buffsize = size) 42 | 43 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) 44 | 45 | 46 | LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); 47 | LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, 48 | void *data); 49 | LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */ 50 | LUAI_FUNC int luaZ_lookahead (ZIO *z); 51 | 52 | 53 | 54 | /* --------- Private Part ------------------ */ 55 | 56 | struct Zio { 57 | size_t n; /* bytes still unread */ 58 | const char *p; /* current position in buffer */ 59 | lua_Reader reader; 60 | void* data; /* additional data */ 61 | lua_State *L; /* Lua state (for reader) */ 62 | }; 63 | 64 | 65 | LUAI_FUNC int luaZ_fill (ZIO *z); 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/test/README: -------------------------------------------------------------------------------- 1 | These are simple tests for Lua. Some of them contain useful code. 2 | They are meant to be run to make sure Lua is built correctly and also 3 | to be read, to see how Lua programs look. 4 | 5 | Here is a one-line summary of each program: 6 | 7 | bisect.lua bisection method for solving non-linear equations 8 | cf.lua temperature conversion table (celsius to farenheit) 9 | echo.lua echo command line arguments 10 | env.lua environment variables as automatic global variables 11 | factorial.lua factorial without recursion 12 | fib.lua fibonacci function with cache 13 | fibfor.lua fibonacci numbers with coroutines and generators 14 | globals.lua report global variable usage 15 | hello.lua the first program in every language 16 | life.lua Conway's Game of Life 17 | luac.lua bare-bones luac 18 | printf.lua an implementation of printf 19 | readonly.lua make global variables readonly 20 | sieve.lua the sieve of of Eratosthenes programmed with coroutines 21 | sort.lua two implementations of a sort function 22 | table.lua make table, grouping all data for the same item 23 | trace-calls.lua trace calls 24 | trace-globals.lua trace assigments to global variables 25 | xd.lua hex dump 26 | 27 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/test/bisect.lua: -------------------------------------------------------------------------------- 1 | -- bisection method for solving non-linear equations 2 | 3 | delta=1e-6 -- tolerance 4 | 5 | function bisect(f,a,b,fa,fb) 6 | local c=(a+b)/2 7 | io.write(n," c=",c," a=",a," b=",b,"\n") 8 | if c==a or c==b or math.abs(a-b)y end) 58 | show("after reverse selection sort",x) 59 | qsort(x,1,n,function (x,y) return x>> ",string.rep(" ",level)) 9 | if t~=nil and t.currentline>=0 then io.write(t.short_src,":",t.currentline," ") end 10 | t=debug.getinfo(2) 11 | if event=="call" then 12 | level=level+1 13 | else 14 | level=level-1 if level<0 then level=0 end 15 | end 16 | if t.what=="main" then 17 | if event=="call" then 18 | io.write("begin ",t.short_src) 19 | else 20 | io.write("end ",t.short_src) 21 | end 22 | elseif t.what=="Lua" then 23 | -- table.foreach(t,print) 24 | io.write(event," ",t.name or "(Lua)"," <",t.linedefined,":",t.short_src,">") 25 | else 26 | io.write(event," ",t.name or "(C)"," [",t.what,"] ") 27 | end 28 | io.write("\n") 29 | end 30 | 31 | debug.sethook(hook,"cr") 32 | level=0 33 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/test/trace-globals.lua: -------------------------------------------------------------------------------- 1 | -- trace assigments to global variables 2 | 3 | do 4 | -- a tostring that quotes strings. note the use of the original tostring. 5 | local _tostring=tostring 6 | local tostring=function(a) 7 | if type(a)=="string" then 8 | return string.format("%q",a) 9 | else 10 | return _tostring(a) 11 | end 12 | end 13 | 14 | local log=function (name,old,new) 15 | local t=debug.getinfo(3,"Sl") 16 | local line=t.currentline 17 | io.write(t.short_src) 18 | if line>=0 then io.write(":",line) end 19 | io.write(": ",name," is now ",tostring(new)," (was ",tostring(old),")","\n") 20 | end 21 | 22 | local g={} 23 | local set=function (t,name,value) 24 | log(name,g[name],value) 25 | g[name]=value 26 | end 27 | setmetatable(getfenv(),{__index=g,__newindex=set}) 28 | end 29 | 30 | -- an example 31 | 32 | a=1 33 | b=2 34 | a=10 35 | b=20 36 | b=nil 37 | b=200 38 | print(a,b,c) 39 | -------------------------------------------------------------------------------- /Lua/Lua.5.1.5/test/xd.lua: -------------------------------------------------------------------------------- 1 | -- hex dump 2 | -- usage: lua xd.lua < file 3 | 4 | local offset=0 5 | while true do 6 | local s=io.read(16) 7 | if s==nil then return end 8 | io.write(string.format("%08X ",offset)) 9 | string.gsub(s,"(.)", 10 | function (c) io.write(string.format("%02X ",string.byte(c))) end) 11 | io.write(string.rep(" ",3*(16-string.len(s)))) 12 | io.write(" ",string.gsub(s,"%c","."),"\n") 13 | offset=offset+16 14 | end 15 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for installing Lua 2 | # See doc/readme.html for installation and customization instructions. 3 | 4 | # == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT ======================= 5 | 6 | # Your platform. See PLATS for possible values. 7 | PLAT= none 8 | 9 | # Where to install. The installation starts in the src and doc directories, 10 | # so take care if INSTALL_TOP is not an absolute path. See the local target. 11 | # You may want to make INSTALL_LMOD and INSTALL_CMOD consistent with 12 | # LUA_ROOT, LUA_LDIR, and LUA_CDIR in luaconf.h. 13 | INSTALL_TOP= /usr/local 14 | INSTALL_BIN= $(INSTALL_TOP)/bin 15 | INSTALL_INC= $(INSTALL_TOP)/include 16 | INSTALL_LIB= $(INSTALL_TOP)/lib 17 | INSTALL_MAN= $(INSTALL_TOP)/man/man1 18 | INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V 19 | INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V 20 | 21 | # How to install. If your install program does not support "-p", then 22 | # you may have to run ranlib on the installed liblua.a. 23 | INSTALL= install -p 24 | INSTALL_EXEC= $(INSTALL) -m 0755 25 | INSTALL_DATA= $(INSTALL) -m 0644 26 | # 27 | # If you don't have "install" you can use "cp" instead. 28 | # INSTALL= cp -p 29 | # INSTALL_EXEC= $(INSTALL) 30 | # INSTALL_DATA= $(INSTALL) 31 | 32 | # Other utilities. 33 | MKDIR= mkdir -p 34 | RM= rm -f 35 | 36 | # == END OF USER SETTINGS -- NO NEED TO CHANGE ANYTHING BELOW THIS LINE ======= 37 | 38 | # Convenience platforms targets. 39 | PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris 40 | 41 | # What to install. 42 | TO_BIN= lua luac 43 | TO_INC= lua.h luaconf.h lualib.h lauxlib.h lua.hpp 44 | TO_LIB= liblua.a 45 | TO_MAN= lua.1 luac.1 46 | 47 | # Lua version and release. 48 | V= 5.2 49 | R= $V.0 50 | 51 | # Targets start here. 52 | all: $(PLAT) 53 | 54 | $(PLATS) clean: 55 | cd src && $(MAKE) $@ 56 | 57 | test: dummy 58 | src/lua -v 59 | 60 | install: dummy 61 | cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD) 62 | cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN) 63 | cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC) 64 | cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB) 65 | cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN) 66 | 67 | uninstall: 68 | cd src && cd $(INSTALL_BIN) && $(RM) $(TO_BIN) 69 | cd src && cd $(INSTALL_INC) && $(RM) $(TO_INC) 70 | cd src && cd $(INSTALL_LIB) && $(RM) $(TO_LIB) 71 | cd doc && cd $(INSTALL_MAN) && $(RM) $(TO_MAN) 72 | 73 | local: 74 | $(MAKE) install INSTALL_TOP=../install 75 | 76 | none: 77 | @echo "Please do 'make PLATFORM' where PLATFORM is one of these:" 78 | @echo " $(PLATS)" 79 | @echo "See doc/readme.html for complete instructions." 80 | 81 | # make may get confused with test/ and install/ 82 | dummy: 83 | 84 | # echo config parameters 85 | echo: 86 | @cd src && $(MAKE) -s echo 87 | @echo "PLAT= $(PLAT)" 88 | @echo "V= $V" 89 | @echo "R= $R" 90 | @echo "TO_BIN= $(TO_BIN)" 91 | @echo "TO_INC= $(TO_INC)" 92 | @echo "TO_LIB= $(TO_LIB)" 93 | @echo "TO_MAN= $(TO_MAN)" 94 | @echo "INSTALL_TOP= $(INSTALL_TOP)" 95 | @echo "INSTALL_BIN= $(INSTALL_BIN)" 96 | @echo "INSTALL_INC= $(INSTALL_INC)" 97 | @echo "INSTALL_LIB= $(INSTALL_LIB)" 98 | @echo "INSTALL_MAN= $(INSTALL_MAN)" 99 | @echo "INSTALL_LMOD= $(INSTALL_LMOD)" 100 | @echo "INSTALL_CMOD= $(INSTALL_CMOD)" 101 | @echo "INSTALL_EXEC= $(INSTALL_EXEC)" 102 | @echo "INSTALL_DATA= $(INSTALL_DATA)" 103 | 104 | # echo pkg-config data 105 | pc: 106 | @echo "version=$R" 107 | @echo "prefix=$(INSTALL_TOP)" 108 | @echo "libdir=$(INSTALL_LIB)" 109 | @echo "includedir=$(INSTALL_INC)" 110 | 111 | # list targets that do not create files (but not all makes understand .PHONY) 112 | .PHONY: all $(PLATS) clean test install local none dummy echo pecho lecho 113 | 114 | # (end of Makefile) 115 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/README: -------------------------------------------------------------------------------- 1 | 2 | This is Lua 5.2, released on 12 Dec 2011. 3 | 4 | For installation instructions, license details, and 5 | further information about Lua, see doc/readme.html. 6 | 7 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/doc/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinniefalco/LuaBridgeDemo/867ffe17557bbf9a73fb1efff7e0dae39ed4ba73/Lua/Lua.5.2.0/doc/logo.gif -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/doc/lua.1: -------------------------------------------------------------------------------- 1 | .\" $Id: lua.man,v 1.13 2011/11/16 17:16:53 lhf Exp $ 2 | .TH LUA 1 "$Date: 2011/11/16 17:16:53 $" 3 | .SH NAME 4 | lua \- Lua interpreter 5 | .SH SYNOPSIS 6 | .B lua 7 | [ 8 | .I options 9 | ] 10 | [ 11 | .I script 12 | [ 13 | .I args 14 | ] 15 | ] 16 | .SH DESCRIPTION 17 | .B lua 18 | is the standalone Lua interpreter. 19 | It loads and executes Lua programs, 20 | either in textual source form or 21 | in precompiled binary form. 22 | (Precompiled binaries are output by 23 | .BR luac , 24 | the Lua compiler.) 25 | .B lua 26 | can be used as a batch interpreter and also interactively. 27 | .LP 28 | The given 29 | .I options 30 | are handled in order and then 31 | the Lua program in file 32 | .I script 33 | is loaded and executed. 34 | The given 35 | .I args 36 | are available to 37 | .I script 38 | as strings in a global table named 39 | .BR arg . 40 | If no options or arguments are given, 41 | then 42 | .B "\-v \-i" 43 | is assumed when the standard input is a terminal; 44 | otherwise, 45 | .B "\-" 46 | is assumed. 47 | .LP 48 | In interactive mode, 49 | .B lua 50 | prompts the user, 51 | reads lines from the standard input, 52 | and executes them as they are read. 53 | If a line does not contain a complete statement, 54 | then a secondary prompt is displayed and 55 | lines are read until a complete statement is formed or 56 | a syntax error is found. 57 | If a line starts with 58 | .BR '=' , 59 | then 60 | .B lua 61 | evaluates and displays 62 | the values of the expressions in the remainder of the line. 63 | .LP 64 | At the very start, 65 | before even handling the command line, 66 | .B lua 67 | checks the contents of the environment variables 68 | .B LUA_INIT_5_2 69 | or 70 | .BR LUA_INIT , 71 | in that order. 72 | If the contents is of the form 73 | .RI '@ filename ', 74 | then 75 | .I filename 76 | is executed. 77 | Otherwise, the string is assumed to be a Lua statement and is executed. 78 | .SH OPTIONS 79 | .TP 80 | .BI \-e " stat" 81 | execute statement 82 | .IR stat . 83 | .TP 84 | .B \-i 85 | enter interactive mode after executing 86 | .IR script . 87 | .TP 88 | .BI \-l " name" 89 | execute the equivalent of 90 | .IB name =require(' name ') 91 | before executing 92 | .IR script . 93 | .TP 94 | .B \-v 95 | show version information. 96 | .TP 97 | .B \-E 98 | ignore environment variables. 99 | .TP 100 | .B \-\- 101 | stop handling options. 102 | .TP 103 | .B \- 104 | stop handling options and execute the standard input as a file. 105 | .SH "SEE ALSO" 106 | .BR luac (1) 107 | .br 108 | The documentation at lua.org, 109 | especially section 7 of the reference manual. 110 | .SH DIAGNOSTICS 111 | Error messages should be self explanatory. 112 | .SH AUTHORS 113 | R. Ierusalimschy, 114 | L. H. de Figueiredo, 115 | W. Celes 116 | .\" EOF 117 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/doc/lua.css: -------------------------------------------------------------------------------- 1 | body { 2 | color: #000000 ; 3 | background-color: #FFFFFF ; 4 | font-family: Helvetica, Arial, sans-serif ; 5 | text-align: justify ; 6 | margin-right: 20px ; 7 | margin-left: 20px ; 8 | } 9 | 10 | h1, h2, h3, h4 { 11 | font-family: Verdana, Geneva, sans-serif ; 12 | font-weight: normal ; 13 | font-style: italic ; 14 | } 15 | 16 | h2 { 17 | padding-top: 0.4em ; 18 | padding-bottom: 0.4em ; 19 | padding-left: 20px ; 20 | padding-right: 20px ; 21 | margin-left: -20px ; 22 | background-color: #E0E0FF ; 23 | } 24 | 25 | h3 { 26 | padding-left: 0.5em ; 27 | border-left: solid #E0E0FF 1em ; 28 | } 29 | 30 | table h3 { 31 | padding-left: 0px ; 32 | border-left: none ; 33 | } 34 | 35 | a:link { 36 | color: #000080 ; 37 | background-color: inherit ; 38 | text-decoration: none ; 39 | } 40 | 41 | a:visited { 42 | background-color: inherit ; 43 | text-decoration: none ; 44 | } 45 | 46 | a:link:hover, a:visited:hover { 47 | color: #000080 ; 48 | background-color: #E0E0FF ; 49 | } 50 | 51 | a:link:active, a:visited:active { 52 | color: #FF0000 ; 53 | } 54 | 55 | hr { 56 | border: 0 ; 57 | height: 1px ; 58 | color: #a0a0a0 ; 59 | background-color: #a0a0a0 ; 60 | } 61 | 62 | :target { 63 | background-color: #F8F8F8 ; 64 | padding: 8px ; 65 | border: solid #a0a0a0 2px ; 66 | } 67 | 68 | .footer { 69 | color: gray ; 70 | font-size: small ; 71 | } 72 | 73 | input[type=text] { 74 | border: solid #a0a0a0 2px ; 75 | border-radius: 2em ; 76 | -moz-border-radius: 2em ; 77 | background-image: url('images/search.png') ; 78 | background-repeat: no-repeat; 79 | background-position: 4px center ; 80 | padding-left: 20px ; 81 | height: 2em ; 82 | } 83 | 84 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/doc/luac.1: -------------------------------------------------------------------------------- 1 | .\" $Id: luac.man,v 1.29 2011/11/16 13:53:40 lhf Exp $ 2 | .TH LUAC 1 "$Date: 2011/11/16 13:53:40 $" 3 | .SH NAME 4 | luac \- Lua compiler 5 | .SH SYNOPSIS 6 | .B luac 7 | [ 8 | .I options 9 | ] [ 10 | .I filenames 11 | ] 12 | .SH DESCRIPTION 13 | .B luac 14 | is the Lua compiler. 15 | It translates programs written in the Lua programming language 16 | into binary files containing precompiled chunks 17 | that can be later loaded and executed. 18 | .LP 19 | The main advantages of precompiling chunks are: 20 | faster loading, 21 | protecting source code from accidental user changes, 22 | and 23 | off-line syntax checking. 24 | Precompiling does not imply faster execution 25 | because in Lua chunks are always compiled into bytecodes before being executed. 26 | .B luac 27 | simply allows those bytecodes to be saved in a file for later execution. 28 | Precompiled chunks are not necessarily smaller than the corresponding source. 29 | The main goal in precompiling is faster loading. 30 | .LP 31 | In the command line, 32 | you can mix 33 | text files containing Lua source and 34 | binary files containing precompiled chunks. 35 | .B luac 36 | produces a single output file containing the combined bytecodes 37 | for all files given. 38 | Executing the combined file is equivalent to executing the given files. 39 | By default, 40 | the output file is named 41 | .BR luac.out , 42 | but you can change this with the 43 | .B \-o 44 | option. 45 | .LP 46 | Precompiled chunks are 47 | .I not 48 | portable across different architectures. 49 | Moreover, 50 | the internal format of precompiled chunks 51 | is likely to change when a new version of Lua is released. 52 | Make sure you save the source files of all Lua programs that you precompile. 53 | .LP 54 | .SH OPTIONS 55 | .TP 56 | .B \-l 57 | produce a listing of the compiled bytecode for Lua's virtual machine. 58 | Listing bytecodes is useful to learn about Lua's virtual machine. 59 | If no files are given, then 60 | .B luac 61 | loads 62 | .B luac.out 63 | and lists its contents. 64 | Use 65 | .B \-l \-l 66 | for a full listing. 67 | .TP 68 | .BI \-o " file" 69 | output to 70 | .IR file , 71 | instead of the default 72 | .BR luac.out . 73 | (You can use 74 | .B "'\-'" 75 | for standard output, 76 | but not on platforms that open standard output in text mode.) 77 | The output file may be one of the given files because 78 | all files are loaded before the output file is written. 79 | Be careful not to overwrite precious files. 80 | .TP 81 | .B \-p 82 | load files but do not generate any output file. 83 | Used mainly for syntax checking and for testing precompiled chunks: 84 | corrupted files will probably generate errors when loaded. 85 | If no files are given, then 86 | .B luac 87 | loads 88 | .B luac.out 89 | and tests its contents. 90 | No messages are displayed if the file loads without errors. 91 | .TP 92 | .B \-s 93 | strip debug information before writing the output file. 94 | This saves some space in very large chunks, 95 | but if errors occur when running a stripped chunk, 96 | then the error messages may not contain the full information they usually do. 97 | In particular, 98 | line numbers and names of local variables are lost. 99 | .TP 100 | .B \-v 101 | show version information. 102 | .TP 103 | .B \-\- 104 | stop handling options. 105 | .TP 106 | .B \- 107 | stop handling options and process standard input. 108 | .SH "SEE ALSO" 109 | .BR lua (1) 110 | .br 111 | The documentation at lua.org. 112 | .SH DIAGNOSTICS 113 | Error messages should be self explanatory. 114 | .SH AUTHORS 115 | R. Ierusalimschy, 116 | L. H. de Figueiredo, 117 | W. Celes 118 | .\" EOF 119 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/doc/manual.css: -------------------------------------------------------------------------------- 1 | h3 code { 2 | font-family: inherit ; 3 | font-size: inherit ; 4 | } 5 | 6 | pre, code { 7 | font-size: 12pt ; 8 | } 9 | 10 | span.apii { 11 | float: right ; 12 | font-family: inherit ; 13 | font-style: normal ; 14 | font-size: small ; 15 | color: gray ; 16 | } 17 | 18 | p+h1, ul+h1 { 19 | padding-top: 0.4em ; 20 | padding-bottom: 0.4em ; 21 | padding-left: 20px ; 22 | margin-left: -20px ; 23 | background-color: #E0E0FF ; 24 | } 25 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/doc/osi-certified-72x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinniefalco/LuaBridgeDemo/867ffe17557bbf9a73fb1efff7e0dae39ed4ba73/Lua/Lua.5.2.0/doc/osi-certified-72x60.png -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/src/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.7 2009/11/27 15:37:59 roberto Exp $ 3 | ** Auxiliary functions from Lua API 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lapi_h 8 | #define lapi_h 9 | 10 | 11 | #include "llimits.h" 12 | #include "lstate.h" 13 | 14 | #define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \ 15 | "stack overflow");} 16 | 17 | #define adjustresults(L,nres) \ 18 | { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } 19 | 20 | #define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ 21 | "not enough elements in the stack") 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/src/lcode.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lcode.h,v 1.58 2011/08/30 16:26:41 roberto Exp $ 3 | ** Code generator for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lcode_h 8 | #define lcode_h 9 | 10 | #include "llex.h" 11 | #include "lobject.h" 12 | #include "lopcodes.h" 13 | #include "lparser.h" 14 | 15 | 16 | /* 17 | ** Marks the end of a patch list. It is an invalid value both as an absolute 18 | ** address, and as a list link (would link an element to itself). 19 | */ 20 | #define NO_JUMP (-1) 21 | 22 | 23 | /* 24 | ** grep "ORDER OPR" if you change these enums (ORDER OP) 25 | */ 26 | typedef enum BinOpr { 27 | OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW, 28 | OPR_CONCAT, 29 | OPR_EQ, OPR_LT, OPR_LE, 30 | OPR_NE, OPR_GT, OPR_GE, 31 | OPR_AND, OPR_OR, 32 | OPR_NOBINOPR 33 | } BinOpr; 34 | 35 | 36 | typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; 37 | 38 | 39 | #define getcode(fs,e) ((fs)->f->code[(e)->u.info]) 40 | 41 | #define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) 42 | 43 | #define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) 44 | 45 | #define luaK_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t) 46 | 47 | LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); 48 | LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); 49 | LUAI_FUNC int luaK_codek (FuncState *fs, int reg, int k); 50 | LUAI_FUNC void luaK_fixline (FuncState *fs, int line); 51 | LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); 52 | LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); 53 | LUAI_FUNC void luaK_checkstack (FuncState *fs, int n); 54 | LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s); 55 | LUAI_FUNC int luaK_numberK (FuncState *fs, lua_Number r); 56 | LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); 57 | LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); 58 | LUAI_FUNC void luaK_exp2anyregup (FuncState *fs, expdesc *e); 59 | LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); 60 | LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); 61 | LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); 62 | LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); 63 | LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); 64 | LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); 65 | LUAI_FUNC void luaK_goiffalse (FuncState *fs, expdesc *e); 66 | LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e); 67 | LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults); 68 | LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e); 69 | LUAI_FUNC int luaK_jump (FuncState *fs); 70 | LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret); 71 | LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target); 72 | LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); 73 | LUAI_FUNC void luaK_patchclose (FuncState *fs, int list, int level); 74 | LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); 75 | LUAI_FUNC int luaK_getlabel (FuncState *fs); 76 | LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v, int line); 77 | LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); 78 | LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, 79 | expdesc *v2, int line); 80 | LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); 81 | 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/src/lctype.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.c,v 1.11 2011/10/03 16:19:23 roberto Exp $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lctype_c 8 | #define LUA_CORE 9 | 10 | #include "lctype.h" 11 | 12 | #if !LUA_USE_CTYPE /* { */ 13 | 14 | #include 15 | 16 | LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = { 17 | 0x00, /* EOZ */ 18 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */ 19 | 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 20 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1. */ 21 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 22 | 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, /* 2. */ 23 | 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 24 | 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, /* 3. */ 25 | 0x16, 0x16, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 26 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 4. */ 27 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 28 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 5. */ 29 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05, 30 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 6. */ 31 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 32 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 7. */ 33 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00, 34 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8. */ 35 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 36 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9. */ 37 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 38 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a. */ 39 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 40 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b. */ 41 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 42 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c. */ 43 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 44 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d. */ 45 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 46 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e. */ 47 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 48 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* f. */ 49 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 50 | }; 51 | 52 | #endif /* } */ 53 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/src/lctype.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.h,v 1.12 2011/07/15 12:50:29 roberto Exp $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lctype_h 8 | #define lctype_h 9 | 10 | #include "lua.h" 11 | 12 | 13 | /* 14 | ** WARNING: the functions defined here do not necessarily correspond 15 | ** to the similar functions in the standard C ctype.h. They are 16 | ** optimized for the specific needs of Lua 17 | */ 18 | 19 | #if !defined(LUA_USE_CTYPE) 20 | 21 | #if 'A' == 65 && '0' == 48 22 | /* ASCII case: can use its own tables; faster and fixed */ 23 | #define LUA_USE_CTYPE 0 24 | #else 25 | /* must use standard C ctype */ 26 | #define LUA_USE_CTYPE 1 27 | #endif 28 | 29 | #endif 30 | 31 | 32 | #if !LUA_USE_CTYPE /* { */ 33 | 34 | #include 35 | 36 | #include "llimits.h" 37 | 38 | 39 | #define ALPHABIT 0 40 | #define DIGITBIT 1 41 | #define PRINTBIT 2 42 | #define SPACEBIT 3 43 | #define XDIGITBIT 4 44 | 45 | 46 | #define MASK(B) (1 << (B)) 47 | 48 | 49 | /* 50 | ** add 1 to char to allow index -1 (EOZ) 51 | */ 52 | #define testprop(c,p) (luai_ctype_[(c)+1] & (p)) 53 | 54 | /* 55 | ** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_' 56 | */ 57 | #define lislalpha(c) testprop(c, MASK(ALPHABIT)) 58 | #define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT))) 59 | #define lisdigit(c) testprop(c, MASK(DIGITBIT)) 60 | #define lisspace(c) testprop(c, MASK(SPACEBIT)) 61 | #define lisprint(c) testprop(c, MASK(PRINTBIT)) 62 | #define lisxdigit(c) testprop(c, MASK(XDIGITBIT)) 63 | 64 | /* 65 | ** this 'ltolower' only works for alphabetic characters 66 | */ 67 | #define ltolower(c) ((c) | ('A' ^ 'a')) 68 | 69 | 70 | /* two more entries for 0 and -1 (EOZ) */ 71 | LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2]; 72 | 73 | 74 | #else /* }{ */ 75 | 76 | /* 77 | ** use standard C ctypes 78 | */ 79 | 80 | #include 81 | 82 | 83 | #define lislalpha(c) (isalpha(c) || (c) == '_') 84 | #define lislalnum(c) (isalnum(c) || (c) == '_') 85 | #define lisdigit(c) (isdigit(c)) 86 | #define lisspace(c) (isspace(c)) 87 | #define lisprint(c) (isprint(c)) 88 | #define lisxdigit(c) (isxdigit(c)) 89 | 90 | #define ltolower(c) (tolower(c)) 91 | 92 | #endif /* } */ 93 | 94 | #endif 95 | 96 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/src/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h,v 2.7 2011/10/07 20:45:19 roberto Exp $ 3 | ** Auxiliary functions from Debug Interface module 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldebug_h 8 | #define ldebug_h 9 | 10 | 11 | #include "lstate.h" 12 | 13 | 14 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) 15 | 16 | #define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) 17 | 18 | #define resethookcount(L) (L->hookcount = L->basehookcount) 19 | 20 | /* Active Lua function (given call info) */ 21 | #define ci_func(ci) (clLvalue((ci)->func)) 22 | 23 | 24 | LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, 25 | const char *opname); 26 | LUAI_FUNC l_noret luaG_concaterror (lua_State *L, StkId p1, StkId p2); 27 | LUAI_FUNC l_noret luaG_aritherror (lua_State *L, const TValue *p1, 28 | const TValue *p2); 29 | LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, 30 | const TValue *p2); 31 | LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); 32 | LUAI_FUNC l_noret luaG_errormsg (lua_State *L); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/src/ldo.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldo.h,v 2.20 2011/11/29 15:55:08 roberto Exp $ 3 | ** Stack and Call structure of Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldo_h 8 | #define ldo_h 9 | 10 | 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | #include "lzio.h" 14 | 15 | 16 | #define luaD_checkstack(L,n) if (L->stack_last - L->top <= (n)) \ 17 | luaD_growstack(L, n); else condmovestack(L); 18 | 19 | 20 | #define incr_top(L) {L->top++; luaD_checkstack(L,0);} 21 | 22 | #define savestack(L,p) ((char *)(p) - (char *)L->stack) 23 | #define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) 24 | 25 | 26 | /* type of protected functions, to be ran by `runprotected' */ 27 | typedef void (*Pfunc) (lua_State *L, void *ud); 28 | 29 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, 30 | const char *mode); 31 | LUAI_FUNC void luaD_hook (lua_State *L, int event, int line); 32 | LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); 33 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults, 34 | int allowyield); 35 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, 36 | ptrdiff_t oldtop, ptrdiff_t ef); 37 | LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); 38 | LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); 39 | LUAI_FUNC void luaD_growstack (lua_State *L, int n); 40 | LUAI_FUNC void luaD_shrinkstack (lua_State *L); 41 | 42 | LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode); 43 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); 44 | 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/src/lfunc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.h,v 2.6 2010/06/04 13:06:15 roberto Exp $ 3 | ** Auxiliary functions to manipulate prototypes and closures 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lfunc_h 8 | #define lfunc_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ 15 | cast(int, sizeof(TValue)*((n)-1))) 16 | 17 | #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ 18 | cast(int, sizeof(TValue *)*((n)-1))) 19 | 20 | 21 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); 22 | LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems); 23 | LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, Proto *p); 24 | LUAI_FUNC UpVal *luaF_newupval (lua_State *L); 25 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 26 | LUAI_FUNC void luaF_close (lua_State *L, StkId level); 27 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 28 | LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c); 29 | LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); 30 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, 31 | int pc); 32 | 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/src/linit.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: linit.c,v 1.32 2011/04/08 19:17:36 roberto Exp $ 3 | ** Initialization of libraries for lua.c and other clients 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | /* 9 | ** If you embed Lua in your program and need to open the standard 10 | ** libraries, call luaL_openlibs in your program. If you need a 11 | ** different set of libraries, copy this file to your project and edit 12 | ** it to suit your needs. 13 | */ 14 | 15 | 16 | #define linit_c 17 | #define LUA_LIB 18 | 19 | #include "lua.h" 20 | 21 | #include "lualib.h" 22 | #include "lauxlib.h" 23 | 24 | 25 | /* 26 | ** these libs are loaded by lua.c and are readily available to any Lua 27 | ** program 28 | */ 29 | static const luaL_Reg loadedlibs[] = { 30 | {"_G", luaopen_base}, 31 | {LUA_LOADLIBNAME, luaopen_package}, 32 | {LUA_COLIBNAME, luaopen_coroutine}, 33 | {LUA_TABLIBNAME, luaopen_table}, 34 | {LUA_IOLIBNAME, luaopen_io}, 35 | {LUA_OSLIBNAME, luaopen_os}, 36 | {LUA_STRLIBNAME, luaopen_string}, 37 | {LUA_BITLIBNAME, luaopen_bit32}, 38 | {LUA_MATHLIBNAME, luaopen_math}, 39 | {LUA_DBLIBNAME, luaopen_debug}, 40 | {NULL, NULL} 41 | }; 42 | 43 | 44 | /* 45 | ** these libs are preloaded and must be required before used 46 | */ 47 | static const luaL_Reg preloadedlibs[] = { 48 | {NULL, NULL} 49 | }; 50 | 51 | 52 | LUALIB_API void luaL_openlibs (lua_State *L) { 53 | const luaL_Reg *lib; 54 | /* call open functions from 'loadedlibs' and set results to global table */ 55 | for (lib = loadedlibs; lib->func; lib++) { 56 | luaL_requiref(L, lib->name, lib->func, 1); 57 | lua_pop(L, 1); /* remove lib */ 58 | } 59 | /* add open functions from 'preloadedlibs' into 'package.preload' table */ 60 | luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD"); 61 | for (lib = preloadedlibs; lib->func; lib++) { 62 | lua_pushcfunction(L, lib->func); 63 | lua_setfield(L, -2, lib->name); 64 | } 65 | lua_pop(L, 1); /* remove _PRELOAD table */ 66 | } 67 | 68 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/src/llex.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: llex.h,v 1.72 2011/11/30 12:43:51 roberto Exp $ 3 | ** Lexical Analyzer 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef llex_h 8 | #define llex_h 9 | 10 | #include "lobject.h" 11 | #include "lzio.h" 12 | 13 | 14 | #define FIRST_RESERVED 257 15 | 16 | 17 | 18 | /* 19 | * WARNING: if you change the order of this enumeration, 20 | * grep "ORDER RESERVED" 21 | */ 22 | enum RESERVED { 23 | /* terminal symbols denoted by reserved words */ 24 | TK_AND = FIRST_RESERVED, TK_BREAK, 25 | TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, 26 | TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, 27 | TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, 28 | /* other terminal symbols */ 29 | TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_DBCOLON, TK_EOS, 30 | TK_NUMBER, TK_NAME, TK_STRING 31 | }; 32 | 33 | /* number of reserved words */ 34 | #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) 35 | 36 | 37 | typedef union { 38 | lua_Number r; 39 | TString *ts; 40 | } SemInfo; /* semantics information */ 41 | 42 | 43 | typedef struct Token { 44 | int token; 45 | SemInfo seminfo; 46 | } Token; 47 | 48 | 49 | /* state of the lexer plus state of the parser when shared by all 50 | functions */ 51 | typedef struct LexState { 52 | int current; /* current character (charint) */ 53 | int linenumber; /* input line counter */ 54 | int lastline; /* line of last token `consumed' */ 55 | Token t; /* current token */ 56 | Token lookahead; /* look ahead token */ 57 | struct FuncState *fs; /* current function (parser) */ 58 | struct lua_State *L; 59 | ZIO *z; /* input stream */ 60 | Mbuffer *buff; /* buffer for tokens */ 61 | struct Dyndata *dyd; /* dynamic structures used by the parser */ 62 | TString *source; /* current source name */ 63 | TString *envn; /* environment variable name */ 64 | char decpoint; /* locale decimal point */ 65 | } LexState; 66 | 67 | 68 | LUAI_FUNC void luaX_init (lua_State *L); 69 | LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, 70 | TString *source, int firstchar); 71 | LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); 72 | LUAI_FUNC void luaX_next (LexState *ls); 73 | LUAI_FUNC int luaX_lookahead (LexState *ls); 74 | LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s); 75 | LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); 76 | 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/src/lmem.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.c,v 1.83 2011/11/30 12:42:49 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #include 9 | 10 | #define lmem_c 11 | #define LUA_CORE 12 | 13 | #include "lua.h" 14 | 15 | #include "ldebug.h" 16 | #include "ldo.h" 17 | #include "lgc.h" 18 | #include "lmem.h" 19 | #include "lobject.h" 20 | #include "lstate.h" 21 | 22 | 23 | 24 | /* 25 | ** About the realloc function: 26 | ** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize); 27 | ** (`osize' is the old size, `nsize' is the new size) 28 | ** 29 | ** * frealloc(ud, NULL, x, s) creates a new block of size `s' (no 30 | ** matter 'x'). 31 | ** 32 | ** * frealloc(ud, p, x, 0) frees the block `p' 33 | ** (in this specific case, frealloc must return NULL); 34 | ** particularly, frealloc(ud, NULL, 0, 0) does nothing 35 | ** (which is equivalent to free(NULL) in ANSI C) 36 | ** 37 | ** frealloc returns NULL if it cannot create or reallocate the area 38 | ** (any reallocation to an equal or smaller size cannot fail!) 39 | */ 40 | 41 | 42 | 43 | #define MINSIZEARRAY 4 44 | 45 | 46 | void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, 47 | int limit, const char *what) { 48 | void *newblock; 49 | int newsize; 50 | if (*size >= limit/2) { /* cannot double it? */ 51 | if (*size >= limit) /* cannot grow even a little? */ 52 | luaG_runerror(L, "too many %s (limit is %d)", what, limit); 53 | newsize = limit; /* still have at least one free place */ 54 | } 55 | else { 56 | newsize = (*size)*2; 57 | if (newsize < MINSIZEARRAY) 58 | newsize = MINSIZEARRAY; /* minimum size */ 59 | } 60 | newblock = luaM_reallocv(L, block, *size, newsize, size_elems); 61 | *size = newsize; /* update only when everything else is OK */ 62 | return newblock; 63 | } 64 | 65 | 66 | l_noret luaM_toobig (lua_State *L) { 67 | luaG_runerror(L, "memory allocation error: block too big"); 68 | } 69 | 70 | 71 | 72 | /* 73 | ** generic allocation routine. 74 | */ 75 | void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { 76 | void *newblock; 77 | global_State *g = G(L); 78 | size_t realosize = (block) ? osize : 0; 79 | lua_assert((realosize == 0) == (block == NULL)); 80 | #if defined(HARDMEMTESTS) 81 | if (nsize > realosize && g->gcrunning) 82 | luaC_fullgc(L, 1); /* force a GC whenever possible */ 83 | #endif 84 | newblock = (*g->frealloc)(g->ud, block, osize, nsize); 85 | if (newblock == NULL && nsize > 0) { 86 | api_check(L, nsize > realosize, 87 | "realloc cannot fail when shrinking a block"); 88 | if (g->gcrunning) { 89 | luaC_fullgc(L, 1); /* try to free some memory... */ 90 | newblock = (*g->frealloc)(g->ud, block, osize, nsize); /* try again */ 91 | } 92 | if (newblock == NULL) 93 | luaD_throw(L, LUA_ERRMEM); 94 | } 95 | lua_assert((nsize == 0) == (newblock == NULL)); 96 | g->GCdebt = (g->GCdebt + nsize) - realosize; 97 | #if defined(TRACEMEM) 98 | { /* auxiliary patch to monitor garbage collection. 99 | ** To plot, gnuplot with following command: 100 | ** plot TRACEMEM using 1:2 with lines, TRACEMEM using 1:3 with lines 101 | */ 102 | static unsigned long total = 0; /* our "time" */ 103 | static FILE *f = NULL; /* output file */ 104 | total++; /* "time" always grows */ 105 | if ((total % 200) == 0) { 106 | if (f == NULL) f = fopen(TRACEMEM, "w"); 107 | fprintf(f, "%lu %u %d %d\n", total, 108 | gettotalbytes(g), g->GCdebt, g->gcstate * 10000); 109 | } 110 | } 111 | #endif 112 | 113 | return newblock; 114 | } 115 | 116 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/src/lmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.h,v 1.38 2011/12/02 13:26:54 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lmem_h 8 | #define lmem_h 9 | 10 | 11 | #include 12 | 13 | #include "llimits.h" 14 | #include "lua.h" 15 | 16 | 17 | #define luaM_reallocv(L,b,on,n,e) \ 18 | ((cast(size_t, (n)+1) > MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ 19 | (luaM_toobig(L), (void *)0) : \ 20 | luaM_realloc_(L, (b), (on)*(e), (n)*(e))) 21 | 22 | #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) 23 | #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) 24 | #define luaM_freearray(L, b, n) luaM_reallocv(L, (b), n, 0, sizeof((b)[0])) 25 | 26 | #define luaM_malloc(L,s) luaM_realloc_(L, NULL, 0, (s)) 27 | #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) 28 | #define luaM_newvector(L,n,t) \ 29 | cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) 30 | 31 | #define luaM_newobject(L,tag,s) luaM_realloc_(L, NULL, tag, (s)) 32 | 33 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \ 34 | if ((nelems)+1 > (size)) \ 35 | ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) 36 | 37 | #define luaM_reallocvector(L, v,oldn,n,t) \ 38 | ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) 39 | 40 | LUAI_FUNC l_noret luaM_toobig (lua_State *L); 41 | 42 | /* not to be called directly */ 43 | LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, 44 | size_t size); 45 | LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, 46 | size_t size_elem, int limit, 47 | const char *what); 48 | 49 | #endif 50 | 51 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/src/lopcodes.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lopcodes.c,v 1.48 2011/04/19 16:22:13 roberto Exp $ 3 | ** See Copyright Notice in lua.h 4 | */ 5 | 6 | 7 | #define lopcodes_c 8 | #define LUA_CORE 9 | 10 | 11 | #include "lopcodes.h" 12 | 13 | 14 | /* ORDER OP */ 15 | 16 | LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = { 17 | "MOVE", 18 | "LOADK", 19 | "LOADKX", 20 | "LOADBOOL", 21 | "LOADNIL", 22 | "GETUPVAL", 23 | "GETTABUP", 24 | "GETTABLE", 25 | "SETTABUP", 26 | "SETUPVAL", 27 | "SETTABLE", 28 | "NEWTABLE", 29 | "SELF", 30 | "ADD", 31 | "SUB", 32 | "MUL", 33 | "DIV", 34 | "MOD", 35 | "POW", 36 | "UNM", 37 | "NOT", 38 | "LEN", 39 | "CONCAT", 40 | "JMP", 41 | "EQ", 42 | "LT", 43 | "LE", 44 | "TEST", 45 | "TESTSET", 46 | "CALL", 47 | "TAILCALL", 48 | "RETURN", 49 | "FORLOOP", 50 | "FORPREP", 51 | "TFORCALL", 52 | "TFORLOOP", 53 | "SETLIST", 54 | "CLOSURE", 55 | "VARARG", 56 | "EXTRAARG", 57 | NULL 58 | }; 59 | 60 | 61 | #define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m)) 62 | 63 | LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = { 64 | /* T A B C mode opcode */ 65 | opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ 66 | ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */ 67 | ,opmode(0, 1, OpArgN, OpArgN, iABx) /* OP_LOADKX */ 68 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */ 69 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_LOADNIL */ 70 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */ 71 | ,opmode(0, 1, OpArgU, OpArgK, iABC) /* OP_GETTABUP */ 72 | ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */ 73 | ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABUP */ 74 | ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */ 75 | ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */ 76 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */ 77 | ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */ 78 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */ 79 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */ 80 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */ 81 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */ 82 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */ 83 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */ 84 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */ 85 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */ 86 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */ 87 | ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */ 88 | ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */ 89 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */ 90 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */ 91 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */ 92 | ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TEST */ 93 | ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */ 94 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */ 95 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */ 96 | ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */ 97 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */ 98 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */ 99 | ,opmode(0, 0, OpArgN, OpArgU, iABC) /* OP_TFORCALL */ 100 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_TFORLOOP */ 101 | ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */ 102 | ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */ 103 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */ 104 | ,opmode(0, 0, OpArgU, OpArgU, iAx) /* OP_EXTRAARG */ 105 | }; 106 | 107 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/src/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h,v 1.46 2010/04/05 16:26:37 roberto Exp $ 3 | ** String table (keep all strings handled by Lua) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lstring_h 8 | #define lstring_h 9 | 10 | #include "lgc.h" 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | 14 | 15 | #define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char)) 16 | 17 | #define sizeudata(u) (sizeof(union Udata)+(u)->len) 18 | 19 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 20 | (sizeof(s)/sizeof(char))-1)) 21 | 22 | #define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) 23 | 24 | 25 | /* 26 | ** as all string are internalized, string equality becomes 27 | ** pointer equality 28 | */ 29 | #define eqstr(a,b) ((a) == (b)) 30 | 31 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 32 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); 33 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 34 | LUAI_FUNC TString *luaS_new (lua_State *L, const char *str); 35 | 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/src/ltable.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltable.h,v 2.16 2011/08/17 20:26:47 roberto Exp $ 3 | ** Lua tables (hash) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltable_h 8 | #define ltable_h 9 | 10 | #include "lobject.h" 11 | 12 | 13 | #define gnode(t,i) (&(t)->node[i]) 14 | #define gkey(n) (&(n)->i_key.tvk) 15 | #define gval(n) (&(n)->i_val) 16 | #define gnext(n) ((n)->i_key.nk.next) 17 | 18 | #define invalidateTMcache(t) ((t)->flags = 0) 19 | 20 | 21 | LUAI_FUNC const TValue *luaH_getint (Table *t, int key); 22 | LUAI_FUNC void luaH_setint (lua_State *L, Table *t, int key, TValue *value); 23 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); 24 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); 25 | LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key); 26 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); 27 | LUAI_FUNC Table *luaH_new (lua_State *L); 28 | LUAI_FUNC void luaH_resize (lua_State *L, Table *t, int nasize, int nhsize); 29 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize); 30 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); 31 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); 32 | LUAI_FUNC int luaH_getn (Table *t); 33 | 34 | 35 | #if defined(LUA_DEBUG) 36 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 37 | LUAI_FUNC int luaH_isdummy (Node *n); 38 | #endif 39 | 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/src/ltm.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.c,v 2.14 2011/06/02 19:31:40 roberto Exp $ 3 | ** Tag methods 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #include 9 | 10 | #define ltm_c 11 | #define LUA_CORE 12 | 13 | #include "lua.h" 14 | 15 | #include "lobject.h" 16 | #include "lstate.h" 17 | #include "lstring.h" 18 | #include "ltable.h" 19 | #include "ltm.h" 20 | 21 | 22 | static const char udatatypename[] = "userdata"; 23 | 24 | LUAI_DDEF const char *const luaT_typenames_[LUA_TOTALTAGS] = { 25 | "no value", 26 | "nil", "boolean", udatatypename, "number", 27 | "string", "table", "function", udatatypename, "thread", 28 | "proto", "upval" /* these last two cases are used for tests only */ 29 | }; 30 | 31 | 32 | void luaT_init (lua_State *L) { 33 | static const char *const luaT_eventname[] = { /* ORDER TM */ 34 | "__index", "__newindex", 35 | "__gc", "__mode", "__len", "__eq", 36 | "__add", "__sub", "__mul", "__div", "__mod", 37 | "__pow", "__unm", "__lt", "__le", 38 | "__concat", "__call" 39 | }; 40 | int i; 41 | for (i=0; itmname[i] = luaS_new(L, luaT_eventname[i]); 43 | luaS_fix(G(L)->tmname[i]); /* never collect these names */ 44 | } 45 | } 46 | 47 | 48 | /* 49 | ** function to be used with macro "fasttm": optimized for absence of 50 | ** tag methods 51 | */ 52 | const TValue *luaT_gettm (Table *events, TMS event, TString *ename) { 53 | const TValue *tm = luaH_getstr(events, ename); 54 | lua_assert(event <= TM_EQ); 55 | if (ttisnil(tm)) { /* no tag method? */ 56 | events->flags |= cast_byte(1u<metatable; 68 | break; 69 | case LUA_TUSERDATA: 70 | mt = uvalue(o)->metatable; 71 | break; 72 | default: 73 | mt = G(L)->mt[ttypenv(o)]; 74 | } 75 | return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject); 76 | } 77 | 78 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/src/ltm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.h,v 2.11 2011/02/28 17:32:10 roberto Exp $ 3 | ** Tag methods 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltm_h 8 | #define ltm_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | /* 15 | * WARNING: if you change the order of this enumeration, 16 | * grep "ORDER TM" 17 | */ 18 | typedef enum { 19 | TM_INDEX, 20 | TM_NEWINDEX, 21 | TM_GC, 22 | TM_MODE, 23 | TM_LEN, 24 | TM_EQ, /* last tag method with `fast' access */ 25 | TM_ADD, 26 | TM_SUB, 27 | TM_MUL, 28 | TM_DIV, 29 | TM_MOD, 30 | TM_POW, 31 | TM_UNM, 32 | TM_LT, 33 | TM_LE, 34 | TM_CONCAT, 35 | TM_CALL, 36 | TM_N /* number of elements in the enum */ 37 | } TMS; 38 | 39 | 40 | 41 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 42 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 43 | 44 | #define fasttm(l,et,e) gfasttm(G(l), et, e) 45 | 46 | #define ttypename(x) luaT_typenames_[(x) + 1] 47 | #define objtypename(x) ttypename(ttypenv(x)) 48 | 49 | LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS]; 50 | 51 | 52 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 53 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 54 | TMS event); 55 | LUAI_FUNC void luaT_init (lua_State *L); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/src/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "lua.h" 7 | #include "lualib.h" 8 | #include "lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/src/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.43 2011/12/08 12:11:37 roberto Exp $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lualib_h 9 | #define lualib_h 10 | 11 | #include "lua.h" 12 | 13 | 14 | 15 | LUAMOD_API int (luaopen_base) (lua_State *L); 16 | 17 | #define LUA_COLIBNAME "coroutine" 18 | LUAMOD_API int (luaopen_coroutine) (lua_State *L); 19 | 20 | #define LUA_TABLIBNAME "table" 21 | LUAMOD_API int (luaopen_table) (lua_State *L); 22 | 23 | #define LUA_IOLIBNAME "io" 24 | LUAMOD_API int (luaopen_io) (lua_State *L); 25 | 26 | #define LUA_OSLIBNAME "os" 27 | LUAMOD_API int (luaopen_os) (lua_State *L); 28 | 29 | #define LUA_STRLIBNAME "string" 30 | LUAMOD_API int (luaopen_string) (lua_State *L); 31 | 32 | #define LUA_BITLIBNAME "bit32" 33 | LUAMOD_API int (luaopen_bit32) (lua_State *L); 34 | 35 | #define LUA_MATHLIBNAME "math" 36 | LUAMOD_API int (luaopen_math) (lua_State *L); 37 | 38 | #define LUA_DBLIBNAME "debug" 39 | LUAMOD_API int (luaopen_debug) (lua_State *L); 40 | 41 | #define LUA_LOADLIBNAME "package" 42 | LUAMOD_API int (luaopen_package) (lua_State *L); 43 | 44 | 45 | /* open all previous libraries */ 46 | LUALIB_API void (luaL_openlibs) (lua_State *L); 47 | 48 | 49 | 50 | #if !defined(lua_assert) 51 | #define lua_assert(x) ((void)0) 52 | #endif 53 | 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/src/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.44 2011/05/06 13:35:17 lhf Exp $ 3 | ** load precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lundump_h 8 | #define lundump_h 9 | 10 | #include "lobject.h" 11 | #include "lzio.h" 12 | 13 | /* load one chunk; from lundump.c */ 14 | LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); 15 | 16 | /* make header; from lundump.c */ 17 | LUAI_FUNC void luaU_header (lu_byte* h); 18 | 19 | /* dump one chunk; from ldump.c */ 20 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); 21 | 22 | /* data to catch conversion errors */ 23 | #define LUAC_TAIL "\x19\x93\r\n\x1a\n" 24 | 25 | /* size in bytes of header of binary files */ 26 | #define LUAC_HEADERSIZE (sizeof(LUA_SIGNATURE)-sizeof(char)+2+6+sizeof(LUAC_TAIL)-sizeof(char)) 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/src/lvm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lvm.h,v 2.17 2011/05/31 18:27:56 roberto Exp $ 3 | ** Lua virtual machine 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lvm_h 8 | #define lvm_h 9 | 10 | 11 | #include "ldo.h" 12 | #include "lobject.h" 13 | #include "ltm.h" 14 | 15 | 16 | #define tostring(L,o) (ttisstring(o) || (luaV_tostring(L, o))) 17 | 18 | #define tonumber(o,n) (ttisnumber(o) || (((o) = luaV_tonumber(o,n)) != NULL)) 19 | 20 | #define equalobj(L,o1,o2) (ttisequal(o1, o2) && luaV_equalobj_(L, o1, o2)) 21 | 22 | #define luaV_rawequalobj(t1,t2) \ 23 | (ttisequal(t1,t2) && luaV_equalobj_(NULL,t1,t2)) 24 | 25 | 26 | /* not to called directly */ 27 | LUAI_FUNC int luaV_equalobj_ (lua_State *L, const TValue *t1, const TValue *t2); 28 | 29 | 30 | LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); 31 | LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r); 32 | LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); 33 | LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); 34 | LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, 35 | StkId val); 36 | LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, 37 | StkId val); 38 | LUAI_FUNC void luaV_finishOp (lua_State *L); 39 | LUAI_FUNC void luaV_execute (lua_State *L); 40 | LUAI_FUNC void luaV_concat (lua_State *L, int total); 41 | LUAI_FUNC void luaV_arith (lua_State *L, StkId ra, const TValue *rb, 42 | const TValue *rc, TMS op); 43 | LUAI_FUNC void luaV_objlen (lua_State *L, StkId ra, const TValue *rb); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/src/lzio.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.c,v 1.34 2011/07/15 12:35:32 roberto Exp $ 3 | ** a generic input stream interface 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #include 9 | 10 | #define lzio_c 11 | #define LUA_CORE 12 | 13 | #include "lua.h" 14 | 15 | #include "llimits.h" 16 | #include "lmem.h" 17 | #include "lstate.h" 18 | #include "lzio.h" 19 | 20 | 21 | int luaZ_fill (ZIO *z) { 22 | size_t size; 23 | lua_State *L = z->L; 24 | const char *buff; 25 | lua_unlock(L); 26 | buff = z->reader(L, z->data, &size); 27 | lua_lock(L); 28 | if (buff == NULL || size == 0) 29 | return EOZ; 30 | z->n = size - 1; /* discount char being returned */ 31 | z->p = buff; 32 | return cast_uchar(*(z->p++)); 33 | } 34 | 35 | 36 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { 37 | z->L = L; 38 | z->reader = reader; 39 | z->data = data; 40 | z->n = 0; 41 | z->p = NULL; 42 | } 43 | 44 | 45 | /* --------------------------------------------------------------- read --- */ 46 | size_t luaZ_read (ZIO *z, void *b, size_t n) { 47 | while (n) { 48 | size_t m; 49 | if (z->n == 0) { /* no bytes in buffer? */ 50 | if (luaZ_fill(z) == EOZ) /* try to read more */ 51 | return n; /* no more input; return number of missing bytes */ 52 | else { 53 | z->n++; /* luaZ_fill consumed first byte; put it back */ 54 | z->p--; 55 | } 56 | } 57 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ 58 | memcpy(b, z->p, m); 59 | z->n -= m; 60 | z->p += m; 61 | b = (char *)b + m; 62 | n -= m; 63 | } 64 | return 0; 65 | } 66 | 67 | /* ------------------------------------------------------------------------ */ 68 | char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) { 69 | if (n > buff->buffsize) { 70 | if (n < LUA_MINBUFFER) n = LUA_MINBUFFER; 71 | luaZ_resizebuffer(L, buff, n); 72 | } 73 | return buff->buffer; 74 | } 75 | 76 | 77 | -------------------------------------------------------------------------------- /Lua/Lua.5.2.0/src/lzio.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.h,v 1.26 2011/07/15 12:48:03 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lzio_h 9 | #define lzio_h 10 | 11 | #include "lua.h" 12 | 13 | #include "lmem.h" 14 | 15 | 16 | #define EOZ (-1) /* end of stream */ 17 | 18 | typedef struct Zio ZIO; 19 | 20 | #define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z)) 21 | 22 | 23 | typedef struct Mbuffer { 24 | char *buffer; 25 | size_t n; 26 | size_t buffsize; 27 | } Mbuffer; 28 | 29 | #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) 30 | 31 | #define luaZ_buffer(buff) ((buff)->buffer) 32 | #define luaZ_sizebuffer(buff) ((buff)->buffsize) 33 | #define luaZ_bufflen(buff) ((buff)->n) 34 | 35 | #define luaZ_resetbuffer(buff) ((buff)->n = 0) 36 | 37 | 38 | #define luaZ_resizebuffer(L, buff, size) \ 39 | (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \ 40 | (buff)->buffsize = size) 41 | 42 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) 43 | 44 | 45 | LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); 46 | LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, 47 | void *data); 48 | LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */ 49 | 50 | 51 | 52 | /* --------- Private Part ------------------ */ 53 | 54 | struct Zio { 55 | size_t n; /* bytes still unread */ 56 | const char *p; /* current position in buffer */ 57 | lua_Reader reader; /* reader function */ 58 | void* data; /* additional data */ 59 | lua_State *L; /* Lua state (for reader) */ 60 | }; 61 | 62 | 63 | LUAI_FUNC int luaZ_fill (ZIO *z); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /Lua/LuaLibrary.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | /* 3 | https://github.com/vinniefalco/LuaBridge 4 | https://github.com/vinniefalco/LuaBridgeDemo 5 | 6 | Copyright (C) 2012, Vinnie Falco 7 | 8 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | */ 28 | //============================================================================== 29 | 30 | /** Include file for the Lua library. 31 | */ 32 | 33 | #ifndef LUALIBRARY_HEADER 34 | #define LUALIBRARY_HEADER 35 | 36 | // This determines which version of Lua to use. 37 | // The value is the same as LUA_VERSION_NUM in lua.h 38 | 39 | #ifndef LUABRIDGEDEMO_LUA_VERSION 40 | #if 1 41 | #define LUABRIDGEDEMO_LUA_VERSION 502 // use 5.2.0 42 | #else 43 | #define LUABRIDGEDEMO_LUA_VERSION 501 // use 5.1.0 (really 5.1.5) 44 | #endif 45 | #endif 46 | 47 | #ifndef LUALIBRARY_SOURCE 48 | 49 | #if LUABRIDGEDEMO_LUA_VERSION >= 502 50 | #include "Lua.5.2.0/src/lua.hpp" 51 | 52 | #elif LUABRIDGEDEMO_LUA_VERSION >= 501 53 | extern "C" 54 | { 55 | #include "Lua.5.1.5/src/lua.h" 56 | #include "Lua.5.1.5/src/lualib.h" 57 | #include "Lua.5.1.5/src/lauxlib.h" 58 | } 59 | 60 | #else 61 | #error "Unknown LUA_VERSION_NUM" 62 | 63 | #endif 64 | 65 | #endif 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /LuaBridge/.gitignore: -------------------------------------------------------------------------------- 1 | Documentation 2 | -------------------------------------------------------------------------------- /LuaBridge/CHANGES: -------------------------------------------------------------------------------- 1 | Version 1.0.2 2 | 3 | * Option to hide metatables selectable at runtime, default to true. 4 | * addStaticMethod () renamed to addStaticFunction () for consistency. 5 | * addMethod () renamed to addFunction() for consistency. 6 | * addCFunction () registrations. 7 | * Convert null pointers to and from nil. 8 | * Small performance increase in class pointer extraction. 9 | 10 | 2012-05-30 Version 1.0.1 11 | 12 | * Backward compatibility with Lua 5.1.x. 13 | 14 | 2012-05-29 Version 1.0 15 | 16 | * Explicit lifetime management models. 17 | * Generalized containers. 18 | * Single header distribution. 19 | 20 | 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | # LuaBridgeDemo 1.0.2 6 | 7 | [LuaBridge][3] is a lightweight, dependency-free library for making C++ data, 8 | functions, and classes available to [Lua][4]: A powerful, fast, lightweight, 9 | embeddable scripting language. LuaBridge has been tested and works with Lua 10 | revisions starting from 5.1.5., although it should work in any version of Lua 11 | from 5.1.0 and later. 12 | 13 | The LuaBridgeDemo is a stand-alone graphical program for compiling and running 14 | the LuaBridge test suite with an included interactive window where you can enter 15 | and execute Lua statements in a persistent environment. The demo has these 16 | features: 17 | 18 | - Cross platform: Compiles on Mac OS, Windows, iOS, Android, and GNU/Linux 19 | 20 | - No external dependencies: Comes with Lua, LuaBridge, and [JUCE][5], just build and run! 21 | 22 | - Demonstrates the usage of LuaBridge with functional code. 23 | 24 | Also included is a separate project for building a command line version of 25 | the test suite, suitable as a starting point for building an automated 26 | testing suite. 27 | 28 | This is the LuaBridge Demo application, and the corresponding registration code 29 | to export classes `A` and `B` to Lua. 30 | 31 | 32 | 33 |
34 | 35 | 36 | 37 |
38 | 39 | ### Version 40 | 41 | LuaBridgeDemo repository tracks the LuaBridge branches: 42 | 43 | - **[master][6]**: Tagged, stable release versions. 44 | 45 | - **[develop][7]**: Work in progress. 46 | 47 | ## JUCE 48 | 49 | [JUCE][5] is licensed separately, visit http://rawmaterialsoftware.com for more 50 | details. 51 | 52 | ## License 53 | 54 | Copyright (C) 2012, [Vinnie Falco][1] ([e-mail][0])
55 | Copyright (C) 2007, Nathan Reed
56 | 57 | Portions from The Loki Library:
58 | Copyright (C) 2001 by Andrei Alexandrescu 59 | 60 | License: The [MIT License][2] 61 | 62 | [0]: mailto:vinnie.falco@gmail.com "Vinnie Falco (Email)" 63 | [1]: http://www.vinniefalco.com "Vinnie Falco" 64 | [2]: http://www.opensource.org/licenses/mit-license.html "The MIT License" 65 | [3]: https://github.com/vinniefalco/LuaBridge "LuaBridge" 66 | [4]: http://lua.org "The Lua Programming Language" 67 | [5]: http://www.rawmaterialsoftware.com "The JUCE Library" 68 | [6]: https://github.com/vinniefalco/LuaBridgeDemo "LuaBridgeDemo master branch" 69 | [7]: https://github.com/vinniefalco/LuaBridgeDemo/tree/develop "LuaBridgeDemo develop branch" 70 | -------------------------------------------------------------------------------- /Solutions/VisualStudio2010/LuaBridge.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 11.00 2 | # Visual Studio 2010 3 | Project("{8EC338BF-BCDD-F3E3-C66F-F7F361BB1A8A}") = "LuaBridgeDemo", "..\..\Demo\Builds\VisualStudio2010\LuaBridgeDemo.vcxproj", "{340ACBA7-0099-FD85-2AB7-7948DD2F983D}" 4 | EndProject 5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LuaBridgeTests", "..\..\Tests\Builds\VisualStudio2010\LuaBridgeTests.vcxproj", "{FCE7759B-A150-5B3D-4F34-7CDFD3F94209}" 6 | EndProject 7 | Global 8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 9 | Debug|Win32 = Debug|Win32 10 | Release|Win32 = Release|Win32 11 | EndGlobalSection 12 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 13 | {340ACBA7-0099-FD85-2AB7-7948DD2F983D}.Debug|Win32.ActiveCfg = Debug|Win32 14 | {340ACBA7-0099-FD85-2AB7-7948DD2F983D}.Debug|Win32.Build.0 = Debug|Win32 15 | {340ACBA7-0099-FD85-2AB7-7948DD2F983D}.Release|Win32.ActiveCfg = Release|Win32 16 | {340ACBA7-0099-FD85-2AB7-7948DD2F983D}.Release|Win32.Build.0 = Release|Win32 17 | {FCE7759B-A150-5B3D-4F34-7CDFD3F94209}.Debug|Win32.ActiveCfg = Debug|Win32 18 | {FCE7759B-A150-5B3D-4F34-7CDFD3F94209}.Debug|Win32.Build.0 = Debug|Win32 19 | {FCE7759B-A150-5B3D-4F34-7CDFD3F94209}.Release|Win32.ActiveCfg = Release|Win32 20 | {FCE7759B-A150-5B3D-4F34-7CDFD3F94209}.Release|Win32.Build.0 = Release|Win32 21 | EndGlobalSection 22 | GlobalSection(SolutionProperties) = preSolution 23 | HideSolutionNode = FALSE 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Tests/Builds/Linux/Makefile: -------------------------------------------------------------------------------- 1 | # Automatically generated makefile, created by the Introjucer 2 | # Don't edit this file! Your changes will be overwritten when you re-save the Introjucer project! 3 | 4 | ifndef CONFIG 5 | CONFIG=Debug 6 | endif 7 | 8 | ifeq ($(TARGET_ARCH),) 9 | TARGET_ARCH := -march=native 10 | endif 11 | 12 | # (this disables dependency generation if multiple architectures are set) 13 | DEPFLAGS := $(if $(word 2, $(TARGET_ARCH)), , -MMD) 14 | 15 | ifeq ($(CONFIG),Debug) 16 | BINDIR := build 17 | LIBDIR := build 18 | OBJDIR := build/intermediate/Debug 19 | OUTDIR := build 20 | CPPFLAGS := $(DEPFLAGS) -D "LINUX=1" -D "DEBUG=1" -D "_DEBUG=1" -D "JUCER_LINUX_MAKE_7346DA2A=1" -I /usr/include -I /usr/include/freetype2 -I ../../JuceLibraryCode -I ../../../Lua 21 | CFLAGS += $(CPPFLAGS) $(TARGET_ARCH) -g -ggdb -O0 22 | CXXFLAGS += $(CFLAGS) 23 | LDFLAGS += -L$(BINDIR) -L$(LIBDIR) -L/usr/X11R6/lib/ -ldl -lfreetype -lpthread -lrt -lX11 -lGL -lXinerama -lasound -lXext 24 | LDDEPS := 25 | RESFLAGS := -D "LINUX=1" -D "DEBUG=1" -D "_DEBUG=1" -D "JUCER_LINUX_MAKE_7346DA2A=1" -I /usr/include -I /usr/include/freetype2 -I ../../JuceLibraryCode -I ../../../Lua 26 | TARGET := LuaBridgeTests 27 | BLDCMD = $(CXX) -o $(OUTDIR)/$(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(TARGET_ARCH) 28 | endif 29 | 30 | ifeq ($(CONFIG),Release) 31 | BINDIR := build 32 | LIBDIR := build 33 | OBJDIR := build/intermediate/Release 34 | OUTDIR := build 35 | CPPFLAGS := $(DEPFLAGS) -D "LINUX=1" -D "NDEBUG=1" -D "JUCER_LINUX_MAKE_7346DA2A=1" -I /usr/include -I /usr/include/freetype2 -I ../../JuceLibraryCode -I ../../../Lua 36 | CFLAGS += $(CPPFLAGS) $(TARGET_ARCH) -Os 37 | CXXFLAGS += $(CFLAGS) 38 | LDFLAGS += -L$(BINDIR) -L$(LIBDIR) -L/usr/X11R6/lib/ -ldl -lfreetype -lpthread -lrt -lX11 -lGL -lXinerama -lasound -lXext 39 | LDDEPS := 40 | RESFLAGS := -D "LINUX=1" -D "NDEBUG=1" -D "JUCER_LINUX_MAKE_7346DA2A=1" -I /usr/include -I /usr/include/freetype2 -I ../../JuceLibraryCode -I ../../../Lua 41 | TARGET := LuaBridgeTests 42 | BLDCMD = $(CXX) -o $(OUTDIR)/$(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(TARGET_ARCH) 43 | endif 44 | 45 | OBJECTS := \ 46 | $(OBJDIR)/LuaLibrary5.1.5_2cc1eeeb.o \ 47 | $(OBJDIR)/LuaLibrary5.2.0_6161b4a7.o \ 48 | $(OBJDIR)/Performance_fdb1291.o \ 49 | $(OBJDIR)/TestsMain_d88417db.o \ 50 | $(OBJDIR)/BinaryData_ce4232d4.o \ 51 | 52 | .PHONY: clean 53 | 54 | $(OUTDIR)/$(TARGET): $(OBJECTS) $(LDDEPS) $(RESOURCES) 55 | @echo Linking LuaBridgeTests 56 | -@mkdir -p $(BINDIR) 57 | -@mkdir -p $(LIBDIR) 58 | -@mkdir -p $(OUTDIR) 59 | @$(BLDCMD) 60 | 61 | clean: 62 | @echo Cleaning LuaBridgeTests 63 | -@rm -f $(OUTDIR)/$(TARGET) 64 | -@rm -rf $(OBJDIR)/* 65 | -@rm -rf $(OBJDIR) 66 | 67 | $(OBJDIR)/LuaLibrary5.1.5_2cc1eeeb.o: ../../../Lua/LuaLibrary5.1.5.cpp 68 | -@mkdir -p $(OBJDIR) 69 | @echo "Compiling LuaLibrary5.1.5.cpp" 70 | @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" 71 | 72 | $(OBJDIR)/LuaLibrary5.2.0_6161b4a7.o: ../../../Lua/LuaLibrary5.2.0.cpp 73 | -@mkdir -p $(OBJDIR) 74 | @echo "Compiling LuaLibrary5.2.0.cpp" 75 | @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" 76 | 77 | $(OBJDIR)/Performance_fdb1291.o: ../../Source/Performance.cpp 78 | -@mkdir -p $(OBJDIR) 79 | @echo "Compiling Performance.cpp" 80 | @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" 81 | 82 | $(OBJDIR)/TestsMain_d88417db.o: ../../Source/TestsMain.cpp 83 | -@mkdir -p $(OBJDIR) 84 | @echo "Compiling TestsMain.cpp" 85 | @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" 86 | 87 | $(OBJDIR)/BinaryData_ce4232d4.o: ../../JuceLibraryCode/BinaryData.cpp 88 | -@mkdir -p $(OBJDIR) 89 | @echo "Compiling BinaryData.cpp" 90 | @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" 91 | 92 | -include $(OBJECTS:%.o=%.d) 93 | -------------------------------------------------------------------------------- /Tests/Builds/VisualStudio2008/LuaBridgeTests.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 10.00 2 | # Visual C++ Express 2008 3 | Project("{A6A44DE4-C16B-0B63-1658-5361E7C66830}") = "LuaBridgeTests", "LuaBridgeTests.vcproj", "{FCE7759B-A150-5B3D-4F34-7CDFD3F94209}" 4 | EndProject 5 | Global 6 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 7 | Debug|Win32 = Debug|Win32 8 | Release|Win32 = Release|Win32 9 | EndGlobalSection 10 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 11 | {FCE7759B-A150-5B3D-4F34-7CDFD3F94209}.Debug|Win32.ActiveCfg = Debug|Win32 12 | {FCE7759B-A150-5B3D-4F34-7CDFD3F94209}.Debug|Win32.Build.0 = Debug|Win32 13 | {FCE7759B-A150-5B3D-4F34-7CDFD3F94209}.Release|Win32.ActiveCfg = Release|Win32 14 | {FCE7759B-A150-5B3D-4F34-7CDFD3F94209}.Release|Win32.Build.0 = Release|Win32 15 | EndGlobalSection 16 | GlobalSection(SolutionProperties) = preSolution 17 | HideSolutionNode = FALSE 18 | EndGlobalSection 19 | EndGlobal 20 | -------------------------------------------------------------------------------- /Tests/Builds/VisualStudio2008/resources.rc: -------------------------------------------------------------------------------- 1 | #undef WIN32_LEAN_AND_MEAN 2 | #define WIN32_LEAN_AND_MEAN 3 | #include 4 | 5 | VS_VERSION_INFO VERSIONINFO 6 | FILEVERSION 1,0,0,0 7 | BEGIN 8 | BLOCK "StringFileInfo" 9 | BEGIN 10 | BLOCK "040904E4" 11 | BEGIN 12 | VALUE "FileDescription", "LuaBridgeTests\0" 13 | VALUE "FileVersion", "1.0.0\0" 14 | VALUE "ProductName", "LuaBridgeTests\0" 15 | VALUE "ProductVersion", "1.0.0\0" 16 | END 17 | END 18 | 19 | BLOCK "VarFileInfo" 20 | BEGIN 21 | VALUE "Translation", 0x409, 65001 22 | END 23 | END 24 | -------------------------------------------------------------------------------- /Tests/Builds/VisualStudio2010/LuaBridgeTests.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 11.00 2 | # Visual Studio 2010 3 | Project("{A6A44DE4-C16B-0B63-1658-5361E7C66830}") = "LuaBridgeTests", "LuaBridgeTests.vcxproj", "{FCE7759B-A150-5B3D-4F34-7CDFD3F94209}" 4 | EndProject 5 | Global 6 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 7 | Debug|Win32 = Debug|Win32 8 | Release|Win32 = Release|Win32 9 | EndGlobalSection 10 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 11 | {FCE7759B-A150-5B3D-4F34-7CDFD3F94209}.Debug|Win32.ActiveCfg = Debug|Win32 12 | {FCE7759B-A150-5B3D-4F34-7CDFD3F94209}.Debug|Win32.Build.0 = Debug|Win32 13 | {FCE7759B-A150-5B3D-4F34-7CDFD3F94209}.Release|Win32.ActiveCfg = Release|Win32 14 | {FCE7759B-A150-5B3D-4F34-7CDFD3F94209}.Release|Win32.Build.0 = Release|Win32 15 | EndGlobalSection 16 | GlobalSection(SolutionProperties) = preSolution 17 | HideSolutionNode = FALSE 18 | EndGlobalSection 19 | EndGlobal 20 | -------------------------------------------------------------------------------- /Tests/Builds/VisualStudio2010/LuaBridgeTests.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {A96618DE-BB98-2E8A-F822-6ABB0C143EBA} 7 | 8 | 9 | {CCF4926C-65EC-86D5-6269-AEED2DFE137F} 10 | 11 | 12 | {5CEEC36B-49EE-E46E-2D98-B0C9636EF93B} 13 | 14 | 15 | {5B9442C6-ACEC-79A7-E777-456D11CBB6BE} 16 | 17 | 18 | {8B4D1BAA-6DB4-CAEC-A0FA-271F354D5C61} 19 | 20 | 21 | 22 | 23 | LuaBridgeTests\Lua 24 | 25 | 26 | LuaBridgeTests\Lua 27 | 28 | 29 | LuaBridgeTests\Source 30 | 31 | 32 | LuaBridgeTests\Source 33 | 34 | 35 | LuaBridgeTests\Source 36 | 37 | 38 | Juce Library Code 39 | 40 | 41 | 42 | 43 | LuaBridgeTests\Lua 44 | 45 | 46 | LuaBridgeTests\LuaBridge 47 | 48 | 49 | LuaBridgeTests\LuaBridge 50 | 51 | 52 | LuaBridgeTests\LuaBridge 53 | 54 | 55 | LuaBridgeTests\Source 56 | 57 | 58 | LuaBridgeTests\Source 59 | 60 | 61 | Juce Library Code 62 | 63 | 64 | Juce Library Code 65 | 66 | 67 | Juce Library Code 68 | 69 | 70 | 71 | 72 | LuaBridgeTests\Source 73 | 74 | 75 | 76 | 77 | Juce Library Code 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /Tests/Builds/VisualStudio2010/resources.rc: -------------------------------------------------------------------------------- 1 | #undef WIN32_LEAN_AND_MEAN 2 | #define WIN32_LEAN_AND_MEAN 3 | #include 4 | 5 | VS_VERSION_INFO VERSIONINFO 6 | FILEVERSION 1,0,0,0 7 | BEGIN 8 | BLOCK "StringFileInfo" 9 | BEGIN 10 | BLOCK "040904E4" 11 | BEGIN 12 | VALUE "FileDescription", "LuaBridgeTests\0" 13 | VALUE "FileVersion", "1.0.0\0" 14 | VALUE "ProductName", "LuaBridgeTests\0" 15 | VALUE "ProductVersion", "1.0.0\0" 16 | END 17 | END 18 | 19 | BLOCK "VarFileInfo" 20 | BEGIN 21 | VALUE "Translation", 0x409, 65001 22 | END 23 | END 24 | -------------------------------------------------------------------------------- /Tests/JuceLibraryCode/AppConfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | IMPORTANT! This file is auto-generated each time you save your 4 | project - if you alter its contents, your changes may be overwritten! 5 | 6 | There's a section below where you can add your own custom code safely, and the 7 | Introjucer will preserve the contents of that block, but the best way to change 8 | any of these definitions is by using the Introjucer's project settings. 9 | 10 | Any commented-out settings will assume their default values. 11 | 12 | */ 13 | 14 | #ifndef __JUCE_APPCONFIG_K9UFLC__ 15 | #define __JUCE_APPCONFIG_K9UFLC__ 16 | 17 | //============================================================================== 18 | // [BEGIN_USER_CODE_SECTION] 19 | 20 | // (You can add your own code in this section, and the Introjucer will not overwrite it) 21 | 22 | // [END_USER_CODE_SECTION] 23 | 24 | //============================================================================== 25 | 26 | 27 | #endif // __JUCE_APPCONFIG_K9UFLC__ 28 | -------------------------------------------------------------------------------- /Tests/JuceLibraryCode/BinaryData.h: -------------------------------------------------------------------------------- 1 | /* ========================================================================================= 2 | 3 | This is an auto-generated file, created by The Introjucer 3.0.0 4 | Do not edit anything in this file! 5 | 6 | */ 7 | 8 | namespace BinaryData 9 | { 10 | extern const char* Tests_lua; 11 | const int Tests_luaSize = 3877; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Tests/JuceLibraryCode/JuceHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | IMPORTANT! This file is auto-generated each time you save your 4 | project - if you alter its contents, your changes may be overwritten! 5 | 6 | This is the header file that your files should include in order to get all the 7 | JUCE library headers. You should avoid including the JUCE headers directly in 8 | your own source files, because that wouldn't pick up the correct configuration 9 | options for your app. 10 | 11 | */ 12 | 13 | #ifndef __APPHEADERFILE_K9UFLC__ 14 | #define __APPHEADERFILE_K9UFLC__ 15 | 16 | #include "AppConfig.h" 17 | #include "BinaryData.h" 18 | 19 | #if ! DONT_SET_USING_JUCE_NAMESPACE 20 | // If your code uses a lot of JUCE classes, then this will obviously save you 21 | // a lot of typing, but can be disabled by setting DONT_SET_USING_JUCE_NAMESPACE. 22 | using namespace juce; 23 | #endif 24 | 25 | namespace ProjectInfo 26 | { 27 | const char* const projectName = "LuaBridgeTests"; 28 | const char* const versionString = "1.0.0"; 29 | const int versionNumber = 0x10000; 30 | } 31 | 32 | #endif // __APPHEADERFILE_K9UFLC__ 33 | -------------------------------------------------------------------------------- /Tests/JuceLibraryCode/ReadMe.txt: -------------------------------------------------------------------------------- 1 | 2 | Important Note!! 3 | ================ 4 | 5 | The purpose of this folder is to contain files that are auto-generated by the Introjucer, 6 | and ALL files in this folder will be mercilessly DELETED and completely re-written whenever 7 | the Introjucer saves your project. 8 | 9 | Therefore, it's a bad idea to make any manual changes to the files in here, or to 10 | put any of your own files in here if you don't want to lose them. (Of course you may choose 11 | to add the folder's contents to your version-control system so that you can re-merge your own 12 | modifications after the Introjucer has saved its changes). 13 | -------------------------------------------------------------------------------- /Tests/Source/Performance.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | /* 3 | https://github.com/vinniefalco/LuaBridge 4 | https://github.com/vinniefalco/LuaBridgeDemo 5 | 6 | Copyright (C) 2012, Vinnie Falco 7 | Copyright (C) 2007, Nathan Reed 8 | 9 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) 10 | 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | copies of the Software, and to permit persons to whom the Software is 16 | furnished to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in all 19 | copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | SOFTWARE. 28 | */ 29 | //============================================================================== 30 | 31 | #ifndef LUABRIDGE_PERFORMANCE_HEADER 32 | #define LUABRIDGE_PERFORMANCE_HEADER 33 | 34 | extern void runPerformanceTests (); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /Tests/Source/Tests.h: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | /* 3 | https://github.com/vinniefalco/LuaBridge 4 | https://github.com/vinniefalco/LuaBridgeDemo 5 | 6 | Copyright (C) 2012, Vinnie Falco 7 | Copyright (C) 2007, Nathan Reed 8 | 9 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) 10 | 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | copies of the Software, and to permit persons to whom the Software is 16 | furnished to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in all 19 | copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | SOFTWARE. 28 | */ 29 | //============================================================================== 30 | 31 | #ifndef LUABRIDGE_TESTS_HEADER 32 | #define LUABRIDGE_TESTS_HEADER 33 | 34 | namespace LuaBridgeTests 35 | { 36 | 37 | extern void addToState (lua_State* L); 38 | 39 | /** 40 | Returns a registry reference to the message handler to 41 | use in subsequent calls to lua_pcall (). 42 | */ 43 | extern int addTraceback (lua_State* L); 44 | 45 | extern void resetTests (); 46 | 47 | } 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /Tests/Source/TestsMain.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================== 2 | /* 3 | https://github.com/vinniefalco/LuaBridge 4 | https://github.com/vinniefalco/LuaBridgeDemo 5 | 6 | Copyright (C) 2012, Vinnie Falco 7 | Copyright (C) 2007, Nathan Reed 8 | 9 | License: The MIT License (http://www.opensource.org/licenses/mit-license.php) 10 | 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | copies of the Software, and to permit persons to whom the Software is 16 | furnished to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in all 19 | copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | SOFTWARE. 28 | */ 29 | //============================================================================== 30 | 31 | /** 32 | Command line version of LuaBridge test suite. 33 | */ 34 | 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | #include "LuaLibrary.h" 42 | 43 | #include "../../LuaBridge/LuaBridge.h" 44 | #include "../../LuaBridge/RefCountedPtr.h" 45 | 46 | #include "BinaryData.h" 47 | #include "Performance.h" 48 | #include "Tests.h" 49 | #include "Tests.cpp" 50 | 51 | using namespace std; 52 | 53 | int main (int, char **) 54 | { 55 | lua_State* L = luaL_newstate (); 56 | 57 | luaL_openlibs (L); 58 | 59 | int errorFunctionRef = LuaBridgeTests::addTraceback (L); 60 | 61 | LuaBridgeTests::addToState (L); 62 | 63 | // Execute lua files in order 64 | if (luaL_loadstring (L, BinaryData::Tests_lua) != 0) 65 | { 66 | // compile-time error 67 | cerr << lua_tostring(L, -1) << endl; 68 | lua_close(L); 69 | return 1; 70 | } 71 | else if (lua_pcall(L, 0, 0, errorFunctionRef) != 0) 72 | { 73 | // runtime error 74 | cerr << lua_tostring(L, -1) << endl; 75 | lua_close(L); 76 | return 1; 77 | } 78 | 79 | runPerformanceTests (); 80 | 81 | lua_close(L); 82 | return 0; 83 | } 84 | --------------------------------------------------------------------------------