diff --git a/.gitignore b/.gitignore
old mode 100755
new mode 100644
index 1dc7f9d0d202e16f891df661ffc484e8cae9f9d0..811b8e06f9cc10a211bfed82dcc1bd883cb8ab05
--- a/.gitignore
+++ b/.gitignore
@@ -1,66 +1,31 @@
-# Autosave files
-*~
-
-*.pc
-*.obj
-*.pidb
-*.mdb
-*/bin/*
-Run/
-
-# build stuff
-Applications/LuaRunner/luarunner
-ConsoleTest/consoletest
-tests/KeraLua.dll
-tests/KopiLua.dll
-tests/NLua.dll
-tests/NLuaTest.dll
-tests/nunit.framework.dll
-
-#ignore thumbnails created by windows
-Thumbs.db
-#Ignore files build by Visual Studio
-*.obj
-*.exe
-*.pdb
-*.user
-*.aps
-*.pch
-*.vspscc
-*_i.c
-*_p.c
-*.ncb
-*.suo
-*.tlb
-*.tlh
-*.bak
-*.cache
-*.ilk
-*.log
-[Bb]in
-[Dd]ebug*/
-*.lib
-*.sbr
-obj/
-[Rr]elease*/
-_ReSharper*/
-[Tt]est[Rr]esult*
-UpgradeLog.XML
-*.ReSharper
-*.userprefs
-
-# http://www.gnu.org/software/automake
-
-Makefile
-Makefile.in
-
-# http://www.gnu.org/software/autoconf
-
-/autom4te.cache
-/aclocal.m4
-/compile
-/configure
-/depcomp
-/install-sh
-/missing
-/config.status
+*.userprefs
+src/bin
+src/obj
+tests/bin
+tests/obj
+build/net45/obj/
+build/netstandard1.0/bin/
+build/netstandard1.0/obj/
+build/netstandard1.3/bin/
+build/netstandard1.3/obj/
+build/netstandard1.6/bin/
+build/netstandard1.6/obj/
+build/netstandard2.0/bin/
+build/netstandard2.0/obj/
+build/portable-net45+win8+wp8/obj/
+build/portable-net45+win8+wpa81/obj/Debug/CoreCompileInputs.cache
+build/portable-net45+win8+wpa81/obj/
+lib/Debug/
+lib/Release/
+.vs/
+build/Android/obj/
+build/TVOS/obj/
+build/WatchOS/obj/
+build/XamariniOS/obj/
+build/XamarinMac/obj/
+build/netcore/obj/
+tests/build/net45/bin/Debug/KeraLua.dll
+tests/build/net45/bin/
+tests/build/net45/obj/
+tests/build/netcore/bin/
+tests/build/netcore/obj/
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index 14daff709a4e151386d308fbd6d5413b239fde14..0000000000000000000000000000000000000000
--- a/.gitmodules
+++ /dev/null
@@ -1,9 +0,0 @@
-[submodule "Core/KopiLua"]
- path = Core/KopiLua
- url = git://github.com/NLua/KopiLua.git
-[submodule "Core/KeraLua"]
- path = Core/KeraLua
- url = git://github.com/NLua/KeraLua.git
-[submodule "tests/LuaTests"]
- path = tests/LuaTests
- url = git://github.com/NLua/LuaTests.git
diff --git a/.travis.yml b/.travis.yml
index c43b11187d010c9970b57c051a3db2ee0d0decf1..b62ccec33943d429f327de40f365677d5b8e0a30 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,21 +1,20 @@
#
-# lua Travis-CI Hook
+# NLua Travis-CI Hook
#
-# Travis language: c(sharp) :-P
language: csharp
before_install:
- - date -u
- - uname -a
- - export PATH=/opt/mono/bin:$PATH
- - env | sort
+ - export PATH=/opt/mono/bin:$PATH
-install: ./CI/travis.${TRAVIS_OS_NAME}.install.deps.sh
+install:
+ - sudo apt-get install mono-devel nunit nuget
script:
- - git submodule update --init --recursive
- - ./run_all.linux64.sh
+ - nuget restore
+ - msbuild /p:Configuration=Release /t:Restore
+ - msbuild /p:Configuration=Release
+ - nunit-console ./tests/build/net45/bin/Release/NLuaTest.dll
# Execute additional tests or commands
#after_script:
@@ -32,4 +31,4 @@ notifications:
- viniciusjarina@gmail.com
email:
on_success: change
- on_failure: always
\ No newline at end of file
+ on_failure: always
diff --git a/Applications/LuaRunner/LuaNetRunner.cs b/Applications/LuaRunner/LuaNetRunner.cs
deleted file mode 100644
index 6f9066fb5f8e7ba50d510d29e10a4b1b30fd8d44..0000000000000000000000000000000000000000
--- a/Applications/LuaRunner/LuaNetRunner.cs
+++ /dev/null
@@ -1,485 +0,0 @@
-/*
- * This file is part of NLua.
- *
- * Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
- * Copyright (C) 2012 Megax
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Threading;
-using NLua;
-using System.Collections.Generic;
-
-/*
- * Application to run Lua scripts that can use NLua
- * from the console
- *
- * Author: Fabio Mascarenhas
- * Version: 1.0
- */
-namespace NLua
-{
- public class LuaNetRunner
- {
- const string lua_script = @"-- lua.lua - Lua 5.1 interpreter (lua.c) reimplemented in Lua.
---
--- WARNING: This is not completed but was quickly done just an experiment.
--- Fix omissions/bugs and test if you want to use this in production.
--- Particularly pay attention to error handling.
---
--- (c) David Manura, 2008-08
--- Licensed under the same terms as Lua itself.
--- Based on lua.c from Lua 5.1.3.
--- Improvements by Shmuel Zeigerman.
-
--- Variables analogous to those in luaconf.h
-local LUA_INIT = ""LUA_INIT""
-local LUA_PROGNAME = ""lua""
-local LUA_PROMPT = ""> ""
-local LUA_PROMPT2 = "">> ""
-local function LUA_QL(x) return ""'"" .. x .. ""'"" end
-
-local lua51 = _VERSION:match '5%.1$'
--- Variables analogous to those in lua.h
-local LUA_RELEASE, LUA_COPYRIGHT, eof_ender
-if lua51 then
- LUA_RELEASE = ""Lua 5.1.4""
- LUA_COPYRIGHT = ""Copyright (C) 1994-2008 Lua.org, PUC-Rio""
- eof_ender = LUA_QL("""")
-else
- LUA_RELEASE = ""Lua 5.2.2""
- LUA_COPYRIGHT = ""Copyright (C) 1994-2013 Lua.org, PUC-Rio""
- eof_ender = ''
-end
-local EXTRA_COPYRIGHT = ""lua.lua (c) David Manura, 2008-08""
-
--- Note: don't allow user scripts to change implementation.
--- Check for globals with ""cat lua.lua | luac -p -l - | grep ETGLOBAL""
-
-local _G = _G
-local assert = assert
-local collectgarbage = collectgarbage
-local loadfile = loadfile
-local loadstring = loadstring or load
-local pcall = pcall
-local rawget = rawget
-local select = select
-local tostring = tostring
-local type = type
-local unpack = unpack or table.unpack
-local xpcall = xpcall
-local io_stderr = io.stderr
-local io_stdout = io.stdout
-local io_stdin = io.stdin
-local string_format = string.format
-local string_sub = string.sub
-local os_getenv = os.getenv
-local os_exit = os.exit
-
-
-local progname = LUA_PROGNAME
-
--- Use external functions, if available
-local lua_stdin_is_tty = function() return true end
-local setsignal = function() end
-
-local function print_usage()
- io_stderr:write(string_format(
- ""usage: %s [options] [script [args]].\n"" ..
- ""Available options are:\n"" ..
- "" -e stat execute string "" .. LUA_QL(""stat"") .. ""\n"" ..
- "" -l name require library "" .. LUA_QL(""name"") .. ""\n"" ..
- "" -i enter interactive mode after executing "" ..
- LUA_QL(""script"") .. ""\n"" ..
- "" -v show version information\n"" ..
- "" -- stop handling options\n"" ..
- "" - execute stdin and stop handling options\n""
- ,
- progname))
- io_stderr:flush()
-end
-
-local our_tostring = tostring
-
-local tuple = table.pack or function(...)
- return {n=select('#', ...), ...}
-end
-
-local using_lsh,lsh
-
-local function our_print (...)
- local args = tuple(...)
- for i = 1,args.n do
- io.write(our_tostring(args[i]),'\t')
- end
- _G._ = args[1]
- io.write '\n'
-end
-
-local function saveline(s)
- if using_lsh then
- lsh.saveline(s)
- end
-end
-
-local function getline(prmt)
- if using_lsh then
- return lsh.readline(prmt)
- else
- io_stdout:write(prmt)
- io_stdout:flush()
- return io_stdin:read'*l'
- end
-end
-
-local function l_message (pname, msg)
- if pname then io_stderr:write(string_format(""%s: "", pname)) end
- io_stderr:write(string_format(""%s\n"", msg))
- io_stderr:flush()
-end
-
-local function report(status, msg)
- if not status and msg ~= nil then
- msg = tostring(msg)
---~ msg = (type(msg) == 'string' or type(msg) == 'number') and tostring(msg)
---~ or ""(error object is not a string)""
- l_message(progname, msg);
- end
- return status
-end
-
-local function traceback (message)
- local tp = type(message)
- if tp ~= ""string"" and tp ~= ""number"" then return message end
- local debug = _G.debug
- if type(debug) ~= ""table"" then return message end
- local tb = debug.traceback
- if type(tb) ~= ""function"" then return message end
- return tb(message, 2)
-end
-
-local function docall(f, ...)
- local tp = {...} -- no need in tuple (string arguments only)
- local F = function() return f(unpack(tp)) end
- setsignal(true)
- local result = tuple(xpcall(F, traceback))
- setsignal(false)
- -- force a complete garbage collection in case of errors
- if not result[1] then collectgarbage(""collect"") end
- return unpack(result, 1, result.n)
-end
-
-function dofile(name)
- local f, msg = loadfile(name)
- if f then f, msg = docall(f) end
- return report(f, msg)
-end
-
-local function dostring(s, name)
- local f, msg = loadstring(s, name)
- if f then f, msg = docall(f) end
- return report(f, msg)
-end
-
-local function dolibrary (name)
- return report(docall(_G.require, name))
-end
-
-local function print_version()
- l_message(nil, LUA_RELEASE .. "" "" .. LUA_COPYRIGHT..""\n""..EXTRA_COPYRIGHT)
-end
-
-local function getargs (argv, n)
- local arg = {}
- for i=1,#argv do arg[i - n] = argv[i] end
- if _G.arg then
- local i = 0
- while _G.arg[i] do
- arg[i - n] = _G.arg[i]
- i = i - 1
- end
- end
- return arg
-end
-
-local function get_prompt (firstline)
- -- use rawget to play fine with require 'strict'
- local pmt = rawget(_G, firstline and ""_PROMPT"" or ""_PROMPT2"")
- local tp = type(pmt)
- if tp == ""string"" or tp == ""number"" then
- return tostring(pmt)
- end
- return firstline and LUA_PROMPT or LUA_PROMPT2
-end
-
-local function fetchline(firstline)
- return getline(get_prompt(firstline))
-end
-
-local function incomplete (msg)
- if msg then
- if string_sub(msg, -#eof_ender) == eof_ender then
- return true
- end
- end
- return false
-end
-
-
-local function pushline (firstline)
- local fine,b = true
- repeat
- b = fetchline(firstline)
- if not b then return end -- no input
- if using_lsh then
- fine = lsh.checkline(b)
- end
- until fine
- if firstline and string_sub(b, 1, 1) == '=' then
- return ""return "" .. string_sub(b, 2) -- change '=' to `return'
- else
- return b
- end
-end
-
-
-local function loadline ()
- local b = pushline(true)
- if not b then return -1 end -- no input
- local f, msg
- while true do -- repeat until gets a complete line
- f, msg = loadstring(b, ""=stdin"")
- if not incomplete(msg) then break end -- cannot try to add lines?
- local b2 = pushline(false)
- if not b2 then -- no more input?
- return -1
- end
- b = b .. ""\n"" .. b2 -- join them
- end
-
- saveline(b)
-
- return f, msg
-end
-
-
-local function dotty ()
- local oldprogname = progname
- progname = nil
- using_lsh,lsh = false -- pcall(require, 'luaish') blows with LI ??
- if using_lsh then
- our_tostring = lsh.tostring
- else
- --print('problem loading luaish:',lsh)
- our_tostring = tostring
- end
- while true do
- local result
- local status, msg = loadline()
- if status == -1 then break end
- if status then
- result = tuple(docall(status))
- status, msg = result[1], result[2]
- end
- report(status, msg)
- if status and result.n > 1 then -- any result to print?
- status, msg = pcall(our_print, unpack(result, 2, result.n))
- if not status then
- l_message(progname, string_format(
- ""error calling %s (%s)"",
- LUA_QL(""print""), msg))
- end
- end
- end
- io_stdout:write""\n""
- io_stdout:flush()
- progname = oldprogname
-end
-
-
-local function handle_script(argv, n)
- _G.arg = getargs(argv, n) -- collect arguments
- local fname = argv[n]
- if fname == ""-"" and argv[n-1] ~= ""--"" then
- fname = nil -- stdin
- end
- local status, msg = loadfile(fname)
- if status then
- status, msg = docall(status, unpack(_G.arg))
- end
- return report(status, msg)
-end
-
-
-local function collectargs (argv, p)
- local i = 1
- while i <= #argv do
- if string_sub(argv[i], 1, 1) ~= '-' then -- not an option?
- return i
- end
- local prefix = string_sub(argv[i], 1, 2)
- if prefix == '--' then
- if #argv[i] > 2 then return -1 end
- return argv[i+1] and i+1 or 0
- elseif prefix == '-' then
- return i
- elseif prefix == '-i' then
- if #argv[i] > 2 then return -1 end
- p.i = true
- p.v = true
- elseif prefix == '-v' then
- if #argv[i] > 2 then return -1 end
- p.v = true
- elseif prefix == '-e' then
- p.e = true
- if #argv[i] == 2 then
- i = i + 1
- if argv[i] == nil then return -1 end
- end
- elseif prefix == '-l' then
- if #argv[i] == 2 then
- i = i + 1
- if argv[i] == nil then return -1 end
- end
- else
- return -1 -- invalid option
- end
- i = i + 1
- end
- return 0
-end
-
-
-local function runargs(argv, n)
- local i = 1
- while i <= n do if argv[i] then
- assert(string_sub(argv[i], 1, 1) == '-')
- local c = string_sub(argv[i], 2, 2) -- option
- if c == 'e' then
- local chunk = string_sub(argv[i], 3)
- if chunk == '' then i = i + 1; chunk = argv[i] end
- assert(chunk)
- if not dostring(chunk, ""=(command line)"") then return false end
- elseif c == 'l' then
- local filename = string_sub(argv[i], 3)
- if filename == '' then i = i + 1; filename = argv[i] end
- assert(filename)
- if not dolibrary(filename) then return false end
- end
- i = i + 1
- end end
- return true
-end
-
-
-local function handle_luainit()
- local init = os_getenv(LUA_INIT)
- if init == nil then
- return -- status OK
- elseif string_sub(init, 1, 1) == '@' then
- dofile(string_sub(init, 2))
- else
- dostring(init, ""="" .. LUA_INIT)
- end
-end
-
-
-if _G.arg and _G.arg[0] and #_G.arg[0] > 0 then progname = _G.arg[0] end
-local argv = arg
-handle_luainit()
-local has = {i=false, v=false, e=false}
-local script = collectargs(argv, has)
-if script < 0 then -- invalid args?
- print_usage()
- os_exit(1)
-end
-if has.v then print_version() end
-local status = runargs(argv, (script > 0) and script-1 or #argv)
-if not status then os_exit(1) end
-if script ~= 0 then
- status = handle_script(argv, script)
- if not status then os_exit(1) end
-else
- _G.arg = nil
-end
-if has.i then
- dotty()
-elseif script == 0 and not has.e and not has.v then
- if lua_stdin_is_tty() then
- print_version()
- import 'System'
- dotty()
- else dofile(nil) -- executes stdin as a file
- end
-end
-";
- /*
- * Runs the Lua script passed as the first command-line argument.
- * It passed all the command-line arguments to the script.
- */
- [STAThread]
- public static void Main(string[] args)
- {
- try {
-
- using (Lua lua = new Lua ()) {
- //lua.OpenLibs(); // steffenj: Lua 5.1.1 API change (all libs already opened in Lua constructor!)
- lua.NewTable ("arg");
- LuaTable argc = (LuaTable)lua ["arg"];
-
- argc [0] = "NLua";
-
- for (int i = 0; i < args.Length; i++) {
- argc [i + 1] = args [i];
- }
-
- argc ["n"] = args.Length;
-
- lua.LoadCLRPackage ();
-
- try {
- lua.DoString (lua_script,"lua");
- } catch (Exception e) {
- // limit size of stack traceback message to roughly 1 console screen height
- string trace = e.StackTrace;
-
- if (e.StackTrace.Length > 1300)
- trace = e.StackTrace.Substring (0, 1300) + " [...] (traceback cut short)";
-
- Console.WriteLine ();
- Console.WriteLine (e.Message);
- Console.WriteLine (e.Source + " raised a " + e.GetType ().ToString ());
- Console.WriteLine (trace);
-
- // wait for key press if there is an error
- Console.ReadKey ();
- }
- }
- } catch (Exception e) {
- Console.WriteLine ();
- Console.WriteLine (e.Message);
- Console.WriteLine (e.Source + " raised a " + e.GetType ().ToString ());
-
- Console.ReadKey ();
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Applications/LuaRunner/Makefile.am b/Applications/LuaRunner/Makefile.am
deleted file mode 100644
index e2d4738c3268d05de3ff5600577f162168794132..0000000000000000000000000000000000000000
--- a/Applications/LuaRunner/Makefile.am
+++ /dev/null
@@ -1,31 +0,0 @@
-
-EXTRA_DIST =
-
-#Warning: This is an automatically generated file, do not edit!
-if ENABLE_DEBUG
- SUBDIRS = .
-endif
-if ENABLE_DEBUGKOPILUA
- SUBDIRS = .
-endif
-if ENABLE_RELEASE
- SUBDIRS = .
-endif
-if ENABLE_RELEASEKOPILUA
- SUBDIRS = .
-endif
-if ENABLE_DEBUG_X64
- SUBDIRS = .
-endif
-if ENABLE_RELEASE_X64
- SUBDIRS = .
-endif
-if ENABLE_DEBUGKOPILUA_X64
- SUBDIRS = .
-endif
-if ENABLE_RELEASEKOPILUA_X64
- SUBDIRS = .
-endif
-
-# Projekt-specifikus makefile beszúrása
-include NLua.40.make
\ No newline at end of file
diff --git a/Applications/LuaRunner/NLua.40.csproj b/Applications/LuaRunner/NLua.40.csproj
deleted file mode 100644
index 3db070c179b1c814a055be5d41ebe51e96a24eed..0000000000000000000000000000000000000000
--- a/Applications/LuaRunner/NLua.40.csproj
+++ /dev/null
@@ -1,138 +0,0 @@
-
-
-
- Debug
- AnyCPU
- {3CE4CCB6-3465-43E3-B5ED-5FB9B70D20E5}
- Exe
- Properties
- NLua
- NLua
- 2.x
- v4.0
-
-
-
- True
- full
- False
- ..\..\tests\
- DEBUG
- prompt
- 4
- AllRules.ruleset
- true
-
-
- none
- True
- ..\..\tests\
- RELEASE
- prompt
- 4
- AnyCPU
- AllRules.ruleset
-
-
- True
- full
- False
- ..\..\Run\Debug_x64
- DEBUG
- prompt
- 4
- x64
- AllRules.ruleset
-
-
- none
- True
- ..\..\Run\Release_x64
- RELEASE
- prompt
- 4
- x64
- AllRules.ruleset
-
-
- true
- ..\..\tests\
- DEBUG
- full
- AnyCPU
- prompt
- AllRules.ruleset
- 4
- false
-
-
- true
- bin\x64\DebugKopiLua\
- DEBUG
- full
- x64
- prompt
- AllRules.ruleset
- 4
- false
-
-
- ..\..\tests\
- 4
- false
-
-
- bin\x64\ReleaseKopiLua\
- 4
- false
-
-
- NLua.ico
-
-
-
-
-
-
-
-
-
-
-
-
- False
- .NET Framework 3.5 SP1 Client Profile
- false
-
-
- False
- .NET Framework 3.5 SP1
- true
-
-
- False
- Windows Installer 3.1
- true
-
-
-
-
-
-
-
- {F55CABBB-4108-4A39-94E1-581FD46DC021}
- NLua.Net40
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Applications/LuaRunner/NLua.40.make b/Applications/LuaRunner/NLua.40.make
deleted file mode 100644
index 7463ef0a6eccd5d09e4005d68637196b7048e180..0000000000000000000000000000000000000000
--- a/Applications/LuaRunner/NLua.40.make
+++ /dev/null
@@ -1,264 +0,0 @@
-
-
-# Warning: This is an automatically generated file, do not edit!
-
-if ENABLE_DEBUG
-ASSEMBLY_COMPILER_COMMAND = dmcs
-ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -optimize- -debug "-define:DEBUG"
-ASSEMBLY = ../../tests/NLua.exe
-ASSEMBLY_MDB = $(ASSEMBLY).mdb
-COMPILE_TARGET = exe
-PROJECT_REFERENCES = \
- ../../Run/Debug/net40/NLua.dll
-BUILD_DIR = ../../tests/
-
-NLUA_EXE_MDB_SOURCE=../../tests/NLua.exe.mdb
-NLUA_EXE_MDB=$(BUILD_DIR)/NLua.exe.mdb
-NLUA_EXE_CONFIG_SOURCE=app.config
-NLUA_DLL_SOURCE=../../Run/Debug/net40/NLua.dll
-NLUA_DLL_MDB_SOURCE=../../Run/Debug/net40/NLua.dll.mdb
-NLUA_DLL_MDB=$(BUILD_DIR)/NLua.dll.mdb
-KERALUA_DLL_SOURCE=../../Core/KeraLua/src/bin/Debug/net40/KeraLua.dll
-KERALUA_DLL_MDB_SOURCE=../../Core/KeraLua/src/bin/Debug/net40/KeraLua.dll.mdb
-KERALUA_DLL_MDB=$(BUILD_DIR)/KeraLua.dll.mdb
-KOPILUA_DLL_SOURCE=../../Core/KopiLua/Bin/Debug/net40/KopiLua.dll
-KOPILUA_DLL_MDB_SOURCE=../../Core/KopiLua/Bin/Debug/net40/KopiLua.dll.mdb
-KOPILUA_DLL_MDB=$(BUILD_DIR)/KopiLua.dll.mdb
-
-endif
-
-if ENABLE_DEBUGKOPILUA
-ASSEMBLY_COMPILER_COMMAND = dmcs
-ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -optimize- -debug "-define:DEBUG"
-ASSEMBLY = ../../tests/NLua.exe
-ASSEMBLY_MDB = $(ASSEMBLY).mdb
-COMPILE_TARGET = exe
-PROJECT_REFERENCES = \
- ../../Core/NLua/bin/DebugKopiLua/NLua.dll
-BUILD_DIR = ../../tests/
-
-NLUA_EXE_MDB_SOURCE=../../tests/NLua.exe.mdb
-NLUA_EXE_MDB=$(BUILD_DIR)/NLua.exe.mdb
-NLUA_EXE_CONFIG_SOURCE=app.config
-NLUA_DLL_SOURCE=../../Core/NLua/bin/DebugKopiLua/NLua.dll
-NLUA_DLL_MDB_SOURCE=../../Core/NLua/bin/DebugKopiLua/NLua.dll.mdb
-NLUA_DLL_MDB=$(BUILD_DIR)/NLua.dll.mdb
-KERALUA_DLL_SOURCE=../../Core/KeraLua/src/bin/DebugKopiLua/KeraLua.dll
-KERALUA_DLL_MDB_SOURCE=../../Core/KeraLua/src/bin/DebugKopiLua/KeraLua.dll.mdb
-KERALUA_DLL_MDB=$(BUILD_DIR)/KeraLua.dll.mdb
-KOPILUA_DLL_SOURCE=../../Core/KopiLua/KopiLua/bin/DebugKopiLua/KopiLua.dll
-KOPILUA_DLL_MDB_SOURCE=../../Core/KopiLua/KopiLua/bin/DebugKopiLua/KopiLua.dll.mdb
-KOPILUA_DLL_MDB=$(BUILD_DIR)/KopiLua.dll.mdb
-
-endif
-
-if ENABLE_RELEASE
-ASSEMBLY_COMPILER_COMMAND = dmcs
-ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -optimize+ "-define:RELEASE"
-ASSEMBLY = ../../tests/NLua.exe
-ASSEMBLY_MDB =
-COMPILE_TARGET = exe
-PROJECT_REFERENCES = \
- ../../Run/Release/net40/NLua.dll
-BUILD_DIR = ../../tests/
-
-NLUA_EXE_MDB=
-NLUA_EXE_CONFIG_SOURCE=app.config
-NLUA_DLL_SOURCE=../../Run/Release/net40/NLua.dll
-NLUA_DLL_MDB=
-KERALUA_DLL_SOURCE=../../Core/KeraLua/src/bin/Release/net40/KeraLua.dll
-KERALUA_DLL_MDB=
-KOPILUA_DLL_SOURCE=../../Core/KopiLua/Bin/Release/net40/KopiLua.dll
-KOPILUA_DLL_MDB=
-
-endif
-
-if ENABLE_RELEASEKOPILUA
-ASSEMBLY_COMPILER_COMMAND = dmcs
-ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -optimize-
-ASSEMBLY = ../../tests/NLua.exe
-ASSEMBLY_MDB =
-COMPILE_TARGET = exe
-PROJECT_REFERENCES = \
- ../../Core/NLua/bin/ReleaseKopiLua/NLua.dll
-BUILD_DIR = ../../tests/
-
-NLUA_EXE_MDB=
-NLUA_EXE_CONFIG_SOURCE=app.config
-NLUA_DLL_SOURCE=../../Core/NLua/bin/ReleaseKopiLua/NLua.dll
-NLUA_DLL_MDB=
-KERALUA_DLL_SOURCE=../../Core/KeraLua/src/bin/ReleaseKopiLua/KeraLua.dll
-KERALUA_DLL_MDB=
-KOPILUA_DLL_SOURCE=../../Core/KopiLua/KopiLua/bin/ReleaseKopiLua/KopiLua.dll
-KOPILUA_DLL_MDB=
-
-endif
-
-if ENABLE_DEBUG_X64
-ASSEMBLY_COMPILER_COMMAND = dmcs
-ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -optimize- -debug "-define:DEBUG"
-ASSEMBLY = ../../Run/Debug_x64/NLua.exe
-ASSEMBLY_MDB = $(ASSEMBLY).mdb
-COMPILE_TARGET = exe
-PROJECT_REFERENCES = \
- ../../Run/Debug/net40/NLua.dll
-BUILD_DIR = ../../Run/Debug_x64
-
-NLUA_EXE_MDB_SOURCE=../../Run/Debug_x64/NLua.exe.mdb
-NLUA_EXE_MDB=$(BUILD_DIR)/NLua.exe.mdb
-NLUA_EXE_CONFIG_SOURCE=app.config
-NLUA_DLL_SOURCE=../../Run/Debug/net40/NLua.dll
-NLUA_DLL_MDB_SOURCE=../../Run/Debug/net40/NLua.dll.mdb
-NLUA_DLL_MDB=$(BUILD_DIR)/NLua.dll.mdb
-KERALUA_DLL_SOURCE=../../Core/KeraLua/src/bin/Debug/net40/KeraLua.dll
-KERALUA_DLL_MDB_SOURCE=../../Core/KeraLua/src/bin/Debug/net40/KeraLua.dll.mdb
-KERALUA_DLL_MDB=$(BUILD_DIR)/KeraLua.dll.mdb
-KOPILUA_DLL_SOURCE=../../Core/KopiLua/Bin/Debug/net40/KopiLua.dll
-KOPILUA_DLL_MDB_SOURCE=../../Core/KopiLua/Bin/Debug/net40/KopiLua.dll.mdb
-KOPILUA_DLL_MDB=$(BUILD_DIR)/KopiLua.dll.mdb
-
-endif
-
-if ENABLE_RELEASE_X64
-ASSEMBLY_COMPILER_COMMAND = dmcs
-ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -optimize+ "-define:RELEASE"
-ASSEMBLY = ../../Run/Release_x64/NLua.exe
-ASSEMBLY_MDB =
-COMPILE_TARGET = exe
-PROJECT_REFERENCES = \
- ../../Run/Release/net40/NLua.dll
-BUILD_DIR = ../../Run/Release_x64
-
-NLUA_EXE_MDB=
-NLUA_EXE_CONFIG_SOURCE=app.config
-NLUA_DLL_SOURCE=../../Run/Debug/net40/NLua.dll
-NLUA_DLL_MDB_SOURCE=../../Run/Debug/net40/NLua.dll.mdb
-NLUA_DLL_MDB=$(BUILD_DIR)/NLua.dll.mdb
-KERALUA_DLL_SOURCE=../../Core/KeraLua/src/bin/Debug/net40/KeraLua.dll
-KERALUA_DLL_MDB_SOURCE=../../Core/KeraLua/src/bin/Debug/net40/KeraLua.dll.mdb
-KERALUA_DLL_MDB=$(BUILD_DIR)/KeraLua.dll.mdb
-KOPILUA_DLL_SOURCE=../../Core/KopiLua/Bin/Debug/net40/KopiLua.dll
-KOPILUA_DLL_MDB_SOURCE=../../Core/KopiLua/Bin/Debug/net40/KopiLua.dll.mdb
-KOPILUA_DLL_MDB=$(BUILD_DIR)/KopiLua.dll.mdb
-
-endif
-
-if ENABLE_DEBUGKOPILUA_X64
-ASSEMBLY_COMPILER_COMMAND = dmcs
-ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -optimize- -debug "-define:DEBUG"
-ASSEMBLY = bin/x64/DebugKopiLua/NLua.exe
-ASSEMBLY_MDB = $(ASSEMBLY).mdb
-COMPILE_TARGET = exe
-PROJECT_REFERENCES = \
- ../../Core/NLua/bin/DebugKopiLua/NLua.dll
-BUILD_DIR = bin/x64/DebugKopiLua/
-
-NLUA_EXE_MDB_SOURCE=bin/x64/DebugKopiLua/NLua.exe.mdb
-NLUA_EXE_MDB=$(BUILD_DIR)/NLua.exe.mdb
-NLUA_EXE_CONFIG_SOURCE=app.config
-NLUA_DLL_SOURCE=../../Run/Debug/net40/NLua.dll
-NLUA_DLL_MDB_SOURCE=../../Run/Debug/net40/NLua.dll.mdb
-NLUA_DLL_MDB=$(BUILD_DIR)/NLua.dll.mdb
-KERALUA_DLL_SOURCE=../../Core/KeraLua/src/bin/Debug/net40/KeraLua.dll
-KERALUA_DLL_MDB_SOURCE=../../Core/KeraLua/src/bin/Debug/net40/KeraLua.dll.mdb
-KERALUA_DLL_MDB=$(BUILD_DIR)/KeraLua.dll.mdb
-KOPILUA_DLL_SOURCE=../../Core/KopiLua/Bin/Debug/net40/KopiLua.dll
-KOPILUA_DLL_MDB_SOURCE=../../Core/KopiLua/Bin/Debug/net40/KopiLua.dll.mdb
-KOPILUA_DLL_MDB=$(BUILD_DIR)/KopiLua.dll.mdb
-
-endif
-
-if ENABLE_RELEASEKOPILUA_X64
-ASSEMBLY_COMPILER_COMMAND = dmcs
-ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -optimize-
-ASSEMBLY = bin/x64/ReleaseKopiLua/NLua.exe
-ASSEMBLY_MDB =
-COMPILE_TARGET = exe
-PROJECT_REFERENCES = \
- ../../Core/NLua/bin/ReleaseKopiLua/NLua.dll
-BUILD_DIR = bin/x64/ReleaseKopiLua/
-
-NLUA_EXE_MDB=
-NLUA_EXE_CONFIG_SOURCE=app.config
-NLUA_DLL_SOURCE=../../Run/Debug/net40/NLua.dll
-NLUA_DLL_MDB_SOURCE=../../Run/Debug/net40/NLua.dll.mdb
-NLUA_DLL_MDB=$(BUILD_DIR)/NLua.dll.mdb
-KERALUA_DLL_SOURCE=../../Core/KeraLua/src/bin/Debug/net40/KeraLua.dll
-KERALUA_DLL_MDB_SOURCE=../../Core/KeraLua/src/bin/Debug/net40/KeraLua.dll.mdb
-KERALUA_DLL_MDB=$(BUILD_DIR)/KeraLua.dll.mdb
-KOPILUA_DLL_SOURCE=../../Core/KopiLua/Bin/Debug/net40/KopiLua.dll
-KOPILUA_DLL_MDB_SOURCE=../../Core/KopiLua/Bin/Debug/net40/KopiLua.dll.mdb
-KOPILUA_DLL_MDB=$(BUILD_DIR)/KopiLua.dll.mdb
-
-endif
-
-AL=al
-SATELLITE_ASSEMBLY_NAME=$(notdir $(basename $(ASSEMBLY))).resources.dll
-
-PROGRAMFILES = \
- $(NLUA_EXE_MDB) \
- $(NLUA_EXE_CONFIG) \
- $(NLUA_DLL) \
- $(NLUA_DLL_MDB) \
- $(KERALUA_DLL) \
- $(KERALUA_DLL_MDB) \
- $(KOPILUA_DLL) \
- $(KOPILUA_DLL_MDB)
-
-BINARIES = \
- $(NLUA_40)
-
-
-RESGEN=resgen2
-
-all: $(ASSEMBLY) $(PROGRAMFILES) $(BINARIES)
-
-FILES = \
- LuaNetRunner.cs \
- Properties/AssemblyInfo.cs
-
-DATA_FILES =
-
-RESOURCES =
-
-EXTRAS = \
- app.config \
- NLua.ico \
- nlua.40.in
-
-REFERENCES = \
- System \
- System.Data \
- System.Xml
-
-DLL_REFERENCES =
-
-CLEANFILES = $(PROGRAMFILES) $(BINARIES)
-
-include $(top_srcdir)/Makefile.include
-
-NLUA_EXE_CONFIG = $(BUILD_DIR)/NLua.exe.config
-NLUA_DLL = $(BUILD_DIR)/NLua.dll
-KERALUA_DLL = $(BUILD_DIR)/KeraLua.dll
-KOPILUA_DLL = $(BUILD_DIR)/KopiLua.dll
-NLUA_40 = $(BUILD_DIR)/nlua.40
-
-$(eval $(call emit-deploy-target,NLUA_EXE_CONFIG))
-$(eval $(call emit-deploy-target,NLUA_DLL))
-$(eval $(call emit-deploy-target,NLUA_DLL_MDB))
-$(eval $(call emit-deploy-target,KERALUA_DLL))
-$(eval $(call emit-deploy-target,KERALUA_DLL_MDB))
-$(eval $(call emit-deploy-target,KOPILUA_DLL))
-$(eval $(call emit-deploy-target,KOPILUA_DLL_MDB))
-$(eval $(call emit-deploy-wrapper,NLUA_40,nlua.40,x))
-
-
-$(eval $(call emit_resgen_targets))
-$(build_xamlg_list): %.xaml.g.cs: %.xaml
- xamlg '$<'
-
-$(ASSEMBLY_MDB): $(ASSEMBLY)
-
-$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) $(DLL_REFERENCES) $(PROJECT_REFERENCES) $(build_xamlg_list) $(build_satellite_assembly_list)
- mkdir -p $(shell dirname $(ASSEMBLY))
- $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$(ASSEMBLY) -target:$(COMPILE_TARGET) $(build_sources_embed) $(build_resources_embed) $(build_references_ref)
diff --git a/Applications/LuaRunner/NLua.csproj b/Applications/LuaRunner/NLua.csproj
deleted file mode 100644
index 9d1205eb16088ba77b2bac3a500ce9961c865a76..0000000000000000000000000000000000000000
--- a/Applications/LuaRunner/NLua.csproj
+++ /dev/null
@@ -1,138 +0,0 @@
-
-
-
- Debug
- AnyCPU
- {3CE4CCB6-3465-43E3-B5ED-5FB9B70D20E5}
- Exe
- Properties
- NLua
- NLua
- 1.3.2
- v4.5
-
-
-
- True
- full
- False
- ..\..\tests\
- DEBUG
- prompt
- 4
- AllRules.ruleset
- true
-
-
- none
- True
- ..\..\tests\
- RELEASE
- prompt
- 4
- AnyCPU
- AllRules.ruleset
-
-
- True
- full
- False
- ..\..\Run\Debug_x64
- DEBUG
- prompt
- 4
- x64
- AllRules.ruleset
-
-
- none
- True
- ..\..\Run\Release_x64
- RELEASE
- prompt
- 4
- x64
- AllRules.ruleset
-
-
- true
- ..\..\tests\
- DEBUG
- full
- AnyCPU
- prompt
- AllRules.ruleset
- 4
- false
-
-
- true
- bin\x64\DebugKopiLua\
- DEBUG
- full
- x64
- prompt
- AllRules.ruleset
- 4
- false
-
-
- ..\..\tests\
- 4
- false
-
-
- bin\x64\ReleaseKopiLua\
- 4
- false
-
-
- NLua.ico
-
-
-
-
-
-
-
-
-
-
-
-
- False
- .NET Framework 3.5 SP1 Client Profile
- false
-
-
- False
- .NET Framework 3.5 SP1
- true
-
-
- False
- Windows Installer 3.1
- true
-
-
-
-
-
-
-
-
-
-
-
-
- {F55CABBB-4108-4A39-94E1-581FD46DC021}
- NLua.Net45
-
-
-
\ No newline at end of file
diff --git a/Applications/LuaRunner/NLua.ico b/Applications/LuaRunner/NLua.ico
deleted file mode 100644
index 77c174bad12deea5ce7c6dda45810c2fa4440b95..0000000000000000000000000000000000000000
Binary files a/Applications/LuaRunner/NLua.ico and /dev/null differ
diff --git a/Applications/LuaRunner/Properties/AssemblyInfo.cs b/Applications/LuaRunner/Properties/AssemblyInfo.cs
deleted file mode 100644
index 925608de0a6b782155e81d5e8c439f67ec60540f..0000000000000000000000000000000000000000
--- a/Applications/LuaRunner/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * This file is part of NLua.
- *
- * Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
- * Copyright (C) 2012 Megax
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-using System;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-using NLua.Config;
-
-// Information about this assembly is defined by the following attributes.
-// Change them to the values specific to your project.
-
-[assembly: AssemblyTitle("LuaRunner")]
-[assembly: AssemblyDescription(Consts.NLuaDescription)]
-[assembly: AssemblyConfiguration(Consts.NLuaConfiguration)]
-[assembly: AssemblyCompany(Consts.NLuaCompany)]
-[assembly: AssemblyProduct(Consts.NLuaProduct)]
-[assembly: AssemblyCopyright(Consts.NLuaCopyright)]
-[assembly: AssemblyTrademark(Consts.NLuaTrademark)]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.5.2")]
-[assembly: AssemblyFileVersion("1.5.2")]
\ No newline at end of file
diff --git a/Applications/LuaRunner/app.config b/Applications/LuaRunner/app.config
deleted file mode 100644
index cb2586beb1dbb3ea3773ec7384aa1f440c2e1ba8..0000000000000000000000000000000000000000
--- a/Applications/LuaRunner/app.config
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
diff --git a/Applications/LuaRunner/nlua.40.in b/Applications/LuaRunner/nlua.40.in
deleted file mode 100644
index 90bb4419c9dbaab8ca9698903b1d56155c54491e..0000000000000000000000000000000000000000
--- a/Applications/LuaRunner/nlua.40.in
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-exec mono "@expanded_libdir@/@PACKAGE@/NLua.exe" "$@"
diff --git a/BuildFunctions.ps1 b/BuildFunctions.ps1
new file mode 100644
index 0000000000000000000000000000000000000000..5189dc661f56a4378d74953050ff1dda44a7f890
--- /dev/null
+++ b/BuildFunctions.ps1
@@ -0,0 +1,300 @@
+function Get-Current-Branch-Name ()
+{
+ $branch = ([string](git rev-parse --abbrev-ref HEAD)).Trim()
+ $parts = $branch.Split('/')
+ $branch = $parts[$parts.Length - 1]
+ return $branch
+}
+
+function Get-Current-Commit-Hash ()
+{
+ return ([string](git log -1 --pretty=%h)).Trim()
+}
+
+function Get-Current-Commit-Message ()
+{
+ return ([string](git log -1 --pretty=%B)).Trim()
+}
+
+function Test-Should-Deploy ()
+{
+ $nugetGitVersion = Get-Git-Package-Version
+ $buildMetaData = Get-Git-Build-MetaData
+ $fullSemVer = Get-Git-Full-Sem-Ver
+
+ if (Test-Tag-Build $nugetGitVersion $buildMetaData $fullSemVer) {
+ return $true
+ }
+ return $false
+}
+
+function Get-Published-PreRelase-Package ($PackageId)
+{
+ $out = [string](nuget list -PreRelease id:$PackageId)
+ $version = $out.Split(' ')[1]
+ return $version
+}
+
+function Get-Published-PreRelase-Package-Version ($PackageId)
+{
+ $version = Get-Published-PreRelase-Package $PackageId
+ $version = $version.Split('-')[0]
+ return $version
+}
+
+function Get-Published-Package ($PackageId)
+{
+ $out = [string](nuget list id:$PackageId)
+ $version = $out.Split(' ')[1]
+ return $version
+}
+
+function Get-Published-Package-Version ($PackageId)
+{
+ $version = Get-Published-Package $PackageId
+ $version = $version.Split('-')[0]
+ return $version
+}
+
+function Get-Git-Package-Version ()
+{
+ Update-Ensure-Git-Not-Detached
+ return [string](gitversion /showvariable MajorMinorPatch)
+}
+
+function Get-Git-Build-MetaData ()
+{
+ Update-Ensure-Git-Not-Detached
+ return [string](gitversion /showvariable BuildMetaData)
+}
+
+function Get-Git-Full-Sem-Ver ()
+{
+ Update-Ensure-Git-Not-Detached
+
+ return [string](gitversion /showvariable FullSemVer)
+}
+
+function Update-NuSpec-Release-Notes($File, $releaseNotes)
+{
+ $File = Resolve-Path $File
+
+ [xml] $fileContents = Get-Content -Encoding UTF8 -Path $File
+
+ $releaseNotesPath = "package.metadata.releaseNotes"
+
+ if ($releaseNotes -ne $null -and $releaseNotes -ne "") {
+ Set-XmlElementsTextValue -XmlDocument $fileContents -ElementPath $releaseNotesPath -TextValue $releaseNotes
+ }
+ $fileContents.Save($File)
+}
+
+function Update-NuSpec-Version($File, $Version)
+{
+ $File = Resolve-Path $File
+
+ [xml] $fileContents = Get-Content -Encoding UTF8 -Path $File
+
+ $versionPath = "package.metadata.version"
+
+ if ($Version -ne $null -and $Version -ne "") {
+ Set-XmlElementsTextValue -XmlDocument $fileContents -ElementPath $versionPath -TextValue $Version
+ }
+
+ $fileContents.Save($File)
+}
+
+function Get-XmlNamespaceManager([xml]$XmlDocument, [string]$NamespaceURI = "")
+{
+ # If a Namespace URI was not given, use the Xml document's default namespace.
+ if ([string]::IsNullOrEmpty($NamespaceURI)) { $NamespaceURI = $XmlDocument.DocumentElement.NamespaceURI }
+
+ # In order for SelectSingleNode() to actually work, we need to use the fully qualified node path along with an Xml Namespace Manager, so set them up.
+ [System.Xml.XmlNamespaceManager]$xmlNsManager = New-Object System.Xml.XmlNamespaceManager($XmlDocument.NameTable)
+ $xmlNsManager.AddNamespace("ns", $NamespaceURI)
+ return ,$xmlNsManager # Need to put the comma before the variable name so that PowerShell doesn't convert it into an Object[].
+}
+
+function Get-FullyQualifiedXmlNodePath([string]$NodePath, [string]$NodeSeparatorCharacter = '.')
+{
+ return "/ns:$($NodePath.Replace($($NodeSeparatorCharacter), '/ns:'))"
+}
+
+function Get-XmlNode([xml]$XmlDocument, [string]$NodePath, [string]$NamespaceURI = "", [string]$NodeSeparatorCharacter = '.')
+{
+ $xmlNsManager = Get-XmlNamespaceManager -XmlDocument $XmlDocument -NamespaceURI $NamespaceURI
+ [string]$fullyQualifiedNodePath = Get-FullyQualifiedXmlNodePath -NodePath $NodePath -NodeSeparatorCharacter $NodeSeparatorCharacter
+
+ # Try and get the node, then return it. Returns $null if the node was not found.
+ $node = $XmlDocument.SelectSingleNode($fullyQualifiedNodePath, $xmlNsManager)
+ return $node
+}
+
+function Set-XmlElementsTextValue([xml]$XmlDocument, [string]$ElementPath, [string]$TextValue, [string]$NamespaceURI = "", [string]$NodeSeparatorCharacter = '.')
+{
+ # Try and get the node.
+ $node = Get-XmlNode -XmlDocument $XmlDocument -NodePath $ElementPath -NamespaceURI $NamespaceURI -NodeSeparatorCharacter $NodeSeparatorCharacter
+
+ # If the node already exists, update its value.
+ if ($node)
+ {
+ $node.InnerText = $TextValue
+ }
+ # Else the node doesn't exist yet, so create it with the given value.
+ else
+ {
+ # Create the new element with the given value.
+ $elementName = $ElementPath.Substring($ElementPath.LastIndexOf($NodeSeparatorCharacter) + 1)
+ $element = $XmlDocument.CreateElement($elementName, $XmlDocument.DocumentElement.NamespaceURI)
+ $textNode = $XmlDocument.CreateTextNode($TextValue)
+ $element.AppendChild($textNode) > $null
+
+ # Try and get the parent node.
+ $parentNodePath = $ElementPath.Substring(0, $ElementPath.LastIndexOf($NodeSeparatorCharacter))
+ $parentNode = Get-XmlNode -XmlDocument $XmlDocument -NodePath $parentNodePath -NamespaceURI $NamespaceURI -NodeSeparatorCharacter $NodeSeparatorCharacter
+
+ if ($parentNode)
+ {
+ $parentNode.AppendChild($element) > $null
+ }
+ else
+ {
+ throw "$parentNodePath does not exist in the xml."
+ }
+ }
+}
+
+function Test-Tag-Build ($nugetGitVersion, $buildMetaData, $fullSemVer) {
+ if ([string]::IsNullOrEmpty($buildMetaData) -and $fullSemVer -eq $nugetGitVersion) {
+ return $true
+ }
+ return $false
+}
+
+function Test-Stable-Release ($stableVersion, $preReleaseVersion, $nugetGitVersion, $buildMetaData, $fullSemVer)
+{
+ # This is unlikelly to heppen, but could happen if the tag creation didn't triggered the Package
+ if ($stableVersion -ne $preReleaseVersion -and $preReleaseVersion -ne $nugetGitVersion) {
+ return 1
+ }
+ if (Test-Tag-Build $nugetGitVersion $buildMetaData $fullSemVer) {
+ return 2
+ }
+ return 0
+}
+
+function Set-Forced-Git-Version ($version)
+{
+ Write-Output "next-version: $version" > GitVersion.yml
+}
+
+function Get-Prefix-Name ()
+{
+ $branchName = Get-Current-Branch-Name
+
+ if ($branchName -ne "master") {
+ return $branchName
+ }
+ return "beta"
+}
+
+function Get-Next-Version-String ($PackageId)
+{
+ $stableVersion = Get-Published-Package-Version ($PackageId)
+ $preReleaseVersion = Get-Published-PreRelase-Package-Version ($PackageId)
+
+ $nugetGitVersion = Get-Git-Package-Version
+ $buildMetaData = Get-Git-Build-MetaData
+ $fullSemVer = Get-Git-Full-Sem-Ver
+
+ $prefix = Get-Prefix-Name
+ $prefix = $prefix.Replace("-", "")
+ $prefix = $prefix.Replace("_", "")
+ $prefix = $prefix.Replace(".", "")
+ $nextVersion = ""
+
+ $stable = Test-Stable-Release $stableVersion $preReleaseVersion $nugetGitVersion $buildMetaData $fullSemVer
+ if ($stable -eq 1){
+ $nextVersion = $preReleaseVersion
+ Set-Forced-Git-Version $nextVersion
+ } elseif ($stable -eq 2) {
+ $nextVersion = $nugetGitVersion
+ } else {
+ $nextVersion = "$($nugetGitVersion)-$($prefix)-build$($buildMetaData)"
+ }
+ return $nextVersion
+}
+
+function Test-Version-Stable-Release ($version)
+{
+ $count = $version.Split("-").Length
+ if ($count -eq 3) {
+ return $false
+ }
+ return $true
+}
+
+function Test-Package-Already-Published ($PackageId, $nextVersion)
+{
+ if (Test-Version-Stable-Release $nextVersion) {
+ $publishedVersion = Get-Published-Package $PackageId
+ if ($publishedVersion -eq $nextVersion) {
+ return $true
+ }
+ return $false
+ }
+
+ $buildMetaData = Get-Git-Build-MetaData
+ $currentVersion = $nextVersion.Split('-')[0]
+
+ [int]$currentBuild = [Convert]::ToInt32($buildMetaData, 10)
+ $currentPrefix = Get-Prefix-Name
+
+ $version = Get-Published-PreRelase-Package $PackageId
+ #if the latest pre-relese returned is a stable release
+ if (Test-Version-Stable-Release $version) {
+ return $false
+ }
+
+ $publishedVersion = $version.Split('-')[0]
+ $publishedPrefix = $version.Split('-')[1]
+ $build = $version.Split('-')[2]
+ $build = $build.Replace("build", "")
+ [int]$publishedBuild = [Convert]::ToInt32($build, 10)
+
+ if ($currentVersion -ne $publishedVersion) {
+ return $false
+ }
+ if ($currentPrefix -ne $publishedPrefix) {
+ return $false
+ }
+ if ($currentBuild -gt $publishedPrefix) {
+ return $false
+ }
+ return $true
+}
+
+function Test-Git-Detached ()
+{
+ $output = [string](git branch | head -1)
+ $detached = $output.Contains("detached")
+ return $detached
+}
+
+function Get-Git-Current-Tag
+{
+ return [string](git describe --tags | head -1)
+}
+
+# GitVersion only works in attached branches, if we try to build a tag from the commit hash gitversion will fail
+# so we ensure we are always attached to a branch
+function Update-Ensure-Git-Not-Detached ()
+{
+ $detached = Test-Git-Detached
+ if (!$detached) {
+ return
+ }
+ $currentTag = Get-Git-Current-Tag
+ & git checkout -B $currentTag
+ # We are using -B because maybe the branch alrady exist
+}
diff --git a/CI/travis.linux.install.deps.sh b/CI/travis.linux.install.deps.sh
deleted file mode 100755
index d4e02389d24cb8d6cdcc9381c6d0fba0c6d28712..0000000000000000000000000000000000000000
--- a/CI/travis.linux.install.deps.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-set -ev
-
-sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
-
-echo "deb http://download.mono-project.com/repo/debian wheezy/snapshots/3.12.0 main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
-echo "deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list
-
-sudo apt-get update
-sudo apt-get install mono-devel cmake nunit
\ No newline at end of file
diff --git a/COPYRIGHT b/COPYRIGHT
deleted file mode 100644
index b5f5ac69b5e6f729dd45d02a294413f77e20ef50..0000000000000000000000000000000000000000
--- a/COPYRIGHT
+++ /dev/null
@@ -1,78 +0,0 @@
-NLua License
---------------------
-
-NLua is licensed under the terms of the MIT license reproduced below.
-This mean that NLua is free software and can be used for both academic and
-commercial purposes at absolutely no cost.
-
-===============================================================================
-
-Copyright (C) 2013 - Vinicius Jarina (viniciusjarina@gmail.com)
-Copyright (C) 2012 Megax
-Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
-
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-
-===============================================================================
-
-Kopi Lua License
-----------------
-
-Kopi Lua is licensed under the terms of the MIT license. Both the MIT
-license and the original Lua copyright notice are reproduced below.
-
-Please see http://www.ppl-pilot.com/KopiLua for details.
-
-===============================================================================
-
-Lua License
------------
-
-Lua is licensed under the terms of the MIT license reproduced below.
-This means that Lua is free software and can be used for both academic
-and commercial purposes at absolutely no cost.
-
-For details and rationale, see http://www.lua.org/license.html .
-
-===============================================================================
-
-Copyright (C) 1994-2008 Lua.org, PUC-Rio.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-
-===============================================================================
-
-(end of COPYRIGHT)
diff --git a/ConsoleTest/App.config b/ConsoleTest/App.config
deleted file mode 100644
index fad249e406f0363449addb9c6ecaf61077d5b19b..0000000000000000000000000000000000000000
--- a/ConsoleTest/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ConsoleTest/ConsoleTest.40.csproj b/ConsoleTest/ConsoleTest.40.csproj
deleted file mode 100644
index 8fc96dc30ae3e429fb0355d57b9877ff8d3c499d..0000000000000000000000000000000000000000
--- a/ConsoleTest/ConsoleTest.40.csproj
+++ /dev/null
@@ -1,90 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {A42D438C-34B3-4D3D-8165-8D3779FE16A7}
- Exe
- Properties
- ConsoleTest
- ConsoleTest
- v4.0
- 512
- 2.x
-
-
- x86
- true
- full
- false
- ..\tests\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
- true
- bin\DebugKopiLua\
- DEBUG;TRACE
- full
- AnyCPU
- prompt
- MinimumRecommendedRules.ruleset
- 4
- false
-
-
- bin\ReleaseKopiLua\
- 4
- false
-
-
-
-
-
-
-
-
-
-
-
- Entity.cs
-
-
- TestLua.cs
-
-
-
-
-
-
-
-
-
- {F55CABBB-4108-4A39-94E1-581FD46DC021}
- NLua.Net40
-
-
- {d5fcadfa-5047-40c2-b392-256875862920}
- NLuaTest.40
-
-
-
-
-
\ No newline at end of file
diff --git a/ConsoleTest/ConsoleTest.csproj b/ConsoleTest/ConsoleTest.csproj
deleted file mode 100644
index 711d6f7b315ac92c4236f31bbdfd11fc086188af..0000000000000000000000000000000000000000
--- a/ConsoleTest/ConsoleTest.csproj
+++ /dev/null
@@ -1,95 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {A42D438C-34B3-4D3D-8165-8D3779FE16A7}
- Exe
- Properties
- ConsoleTest
- ConsoleTest
- v4.5
- 512
- 1.3.2
-
-
- x86
- true
- full
- false
- ..\tests\
- TRACE;DEBUG
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
- true
- bin\DebugKopiLua\
- DEBUG;TRACE
- full
- AnyCPU
- prompt
- MinimumRecommendedRules.ruleset
- 4
- false
-
-
- bin\ReleaseKopiLua\
- 4
- false
-
-
-
-
-
-
-
-
-
-
-
- Entity.cs
-
-
-
-
-
-
-
-
-
-
-
- {E8DDBC21-EF74-4ABA-9C49-BFC702BE25D8}
- KopiLua.Net45
-
-
- {F55CABBB-4108-4A39-94E1-581FD46DC021}
- NLua.Net45
-
-
- {47153754-10F5-44D8-B578-F5A32B69061A}
- KeraLua.Net45
-
-
- {D5FCADFA-5047-40C2-B392-256875862920}
- NLuaTest
-
-
-
\ No newline at end of file
diff --git a/ConsoleTest/Makefile.am b/ConsoleTest/Makefile.am
deleted file mode 100644
index 5a1185703bed25a171ef0adf3dce5c6b2a30cb0b..0000000000000000000000000000000000000000
--- a/ConsoleTest/Makefile.am
+++ /dev/null
@@ -1,307 +0,0 @@
-
-EXTRA_DIST =
-
-# Warning: This is an automatically generated file, do not edit!
-
-if ENABLE_DEBUG
-ASSEMBLY_COMPILER_COMMAND = dmcs
-ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -optimize- -debug "-define:DEBUG;TRACE"
-ASSEMBLY = ../tests/ConsoleTest.exe
-ASSEMBLY_MDB = $(ASSEMBLY).mdb
-COMPILE_TARGET = exe
-PROJECT_REFERENCES = \
- ../Run/Debug/net40/NLua.dll \
- ../tests/NLuaTest.dll
-BUILD_DIR = ../tests/
-
-CONSOLETEST_EXE_MDB_SOURCE=../tests/ConsoleTest.exe.mdb
-CONSOLETEST_EXE_MDB=$(BUILD_DIR)/ConsoleTest.exe.mdb
-CONSOLETEST_EXE_CONFIG_SOURCE=App.config
-NLUA_DLL_SOURCE=../Run/Debug/net40/NLua.dll
-NLUA_DLL_MDB_SOURCE=../Run/Debug/net40/NLua.dll.mdb
-NLUA_DLL_MDB=$(BUILD_DIR)/NLua.dll.mdb
-KERALUA_DLL_SOURCE=../Core/KeraLua/src/bin/Debug/net40/KeraLua.dll
-KERALUA_DLL_MDB_SOURCE=../Core/KeraLua/src/bin/Debug/net40/KeraLua.dll.mdb
-KERALUA_DLL_MDB=$(BUILD_DIR)/KeraLua.dll.mdb
-KOPILUA_DLL_SOURCE=../Core/KopiLua/Bin/Debug/net40/KopiLua.dll
-KOPILUA_DLL_MDB_SOURCE=../Core/KopiLua/Bin/Debug/net40/KopiLua.dll.mdb
-KOPILUA_DLL_MDB=$(BUILD_DIR)/KopiLua.dll.mdb
-NLUATEST_DLL_SOURCE=../tests/NLuaTest.dll
-NLUATEST_DLL_MDB_SOURCE=../tests/NLuaTest.dll.mdb
-NLUATEST_DLL_MDB=$(BUILD_DIR)/NLuaTest.dll.mdb
-NUNIT_FRAMEWORK_DLL_SOURCE=../packages/NUnit.2.6.2/lib/nunit.framework.dll
-
-endif
-
-if ENABLE_DEBUGKOPILUA
-ASSEMBLY_COMPILER_COMMAND = dmcs
-ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -optimize- -debug "-define:DEBUG;TRACE"
-ASSEMBLY = bin/DebugKopiLua/ConsoleTest.exe
-ASSEMBLY_MDB = $(ASSEMBLY).mdb
-COMPILE_TARGET = exe
-PROJECT_REFERENCES = \
- ../Core/NLua/bin/DebugKopiLua/NLua.dll \
- ../NLuaTest/bin/DebugKopiLua/NLuaTest.dll
-BUILD_DIR = bin/DebugKopiLua/
-
-CONSOLETEST_EXE_MDB_SOURCE=bin/DebugKopiLua/ConsoleTest.exe.mdb
-CONSOLETEST_EXE_MDB=$(BUILD_DIR)/ConsoleTest.exe.mdb
-CONSOLETEST_EXE_CONFIG_SOURCE=App.config
-NLUA_DLL_SOURCE=../Core/NLua/bin/DebugKopiLua/NLua.dll
-NLUA_DLL_MDB_SOURCE=../Core/NLua/bin/DebugKopiLua/NLua.dll.mdb
-NLUA_DLL_MDB=$(BUILD_DIR)/NLua.dll.mdb
-KERALUA_DLL_SOURCE=../Core/KeraLua/src/bin/DebugKopiLua/KeraLua.dll
-KERALUA_DLL_MDB_SOURCE=../Core/KeraLua/src/bin/DebugKopiLua/KeraLua.dll.mdb
-KERALUA_DLL_MDB=$(BUILD_DIR)/KeraLua.dll.mdb
-KOPILUA_DLL_SOURCE=../Core/KopiLua/KopiLua/bin/DebugKopiLua/KopiLua.dll
-KOPILUA_DLL_MDB_SOURCE=../Core/KopiLua/KopiLua/bin/DebugKopiLua/KopiLua.dll.mdb
-KOPILUA_DLL_MDB=$(BUILD_DIR)/KopiLua.dll.mdb
-NLUATEST_DLL_SOURCE=../NLuaTest/bin/DebugKopiLua/NLuaTest.dll
-NLUATEST_DLL_MDB_SOURCE=../NLuaTest/bin/DebugKopiLua/NLuaTest.dll.mdb
-NLUATEST_DLL_MDB=$(BUILD_DIR)/NLuaTest.dll.mdb
-NUNIT_FRAMEWORK_DLL_SOURCE=../packages/NUnit.2.6.2/lib/nunit.framework.dll
-
-endif
-
-if ENABLE_RELEASE
-ASSEMBLY_COMPILER_COMMAND = dmcs
-ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -optimize+ "-define:TRACE"
-ASSEMBLY = bin/Release/ConsoleTest.exe
-ASSEMBLY_MDB =
-COMPILE_TARGET = exe
-PROJECT_REFERENCES = \
- ../Run/Release/net40/NLua.dll \
- ../tests/NLuaTest.dll
-BUILD_DIR = bin/Release/
-
-CONSOLETEST_EXE_MDB=
-CONSOLETEST_EXE_CONFIG_SOURCE=App.config
-NLUA_DLL_SOURCE=../Run/Release/net40/NLua.dll
-NLUA_DLL_MDB=
-KERALUA_DLL_SOURCE=../Core/KeraLua/src/bin/Release/net40/KeraLua.dll
-KERALUA_DLL_MDB=
-KOPILUA_DLL_SOURCE=../Core/KopiLua/Bin/Release/net40/KopiLua.dll
-KOPILUA_DLL_MDB=
-NLUATEST_DLL_SOURCE=../tests/NLuaTest.dll
-NLUATEST_DLL_MDB=
-NUNIT_FRAMEWORK_DLL_SOURCE=../packages/NUnit.2.6.2/lib/nunit.framework.dll
-
-endif
-
-if ENABLE_RELEASEKOPILUA
-ASSEMBLY_COMPILER_COMMAND = dmcs
-ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -optimize-
-ASSEMBLY = bin/ReleaseKopiLua/ConsoleTest.exe
-ASSEMBLY_MDB =
-COMPILE_TARGET = exe
-PROJECT_REFERENCES = \
- ../Core/NLua/bin/ReleaseKopiLua/NLua.dll \
- ../tests/NLuaTest.dll
-BUILD_DIR = bin/ReleaseKopiLua/
-
-CONSOLETEST_EXE_MDB=
-CONSOLETEST_EXE_CONFIG_SOURCE=App.config
-NLUA_DLL_SOURCE=../Core/NLua/bin/ReleaseKopiLua/NLua.dll
-NLUA_DLL_MDB=
-KERALUA_DLL_SOURCE=../Core/KeraLua/src/bin/ReleaseKopiLua/KeraLua.dll
-KERALUA_DLL_MDB=
-KOPILUA_DLL_SOURCE=../Core/KopiLua/KopiLua/bin/ReleaseKopiLua/KopiLua.dll
-KOPILUA_DLL_MDB=
-NLUATEST_DLL_SOURCE=../tests/NLuaTest.dll
-NLUATEST_DLL_MDB=
-NUNIT_FRAMEWORK_DLL_SOURCE=../packages/NUnit.2.6.2/lib/nunit.framework.dll
-
-endif
-
-if ENABLE_DEBUG_X64
-ASSEMBLY_COMPILER_COMMAND = dmcs
-ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -optimize- -debug "-define:DEBUG;TRACE"
-ASSEMBLY = ../tests/ConsoleTest.exe
-ASSEMBLY_MDB = $(ASSEMBLY).mdb
-COMPILE_TARGET = exe
-PROJECT_REFERENCES = \
- ../Run/Debug/net40/NLua.dll \
- ../tests/NLuaTest.dll
-BUILD_DIR = ../tests/
-
-CONSOLETEST_EXE_MDB_SOURCE=../tests/ConsoleTest.exe.mdb
-CONSOLETEST_EXE_MDB=$(BUILD_DIR)/ConsoleTest.exe.mdb
-CONSOLETEST_EXE_CONFIG_SOURCE=App.config
-NLUA_DLL_SOURCE=../Run/Debug/net40/NLua.dll
-NLUA_DLL_MDB_SOURCE=../Run/Debug/net40/NLua.dll.mdb
-NLUA_DLL_MDB=$(BUILD_DIR)/NLua.dll.mdb
-KERALUA_DLL_SOURCE=../Core/KeraLua/src/bin/Debug/net40/KeraLua.dll
-KERALUA_DLL_MDB_SOURCE=../Core/KeraLua/src/bin/Debug/net40/KeraLua.dll.mdb
-KERALUA_DLL_MDB=$(BUILD_DIR)/KeraLua.dll.mdb
-KOPILUA_DLL_SOURCE=../Core/KopiLua/Bin/Debug/net40/KopiLua.dll
-KOPILUA_DLL_MDB_SOURCE=../Core/KopiLua/Bin/Debug/net40/KopiLua.dll.mdb
-KOPILUA_DLL_MDB=$(BUILD_DIR)/KopiLua.dll.mdb
-NLUATEST_DLL_SOURCE=../tests/NLuaTest.dll
-NLUATEST_DLL_MDB_SOURCE=../tests/NLuaTest.dll.mdb
-NLUATEST_DLL_MDB=$(BUILD_DIR)/NLuaTest.dll.mdb
-NUNIT_FRAMEWORK_DLL_SOURCE=../packages/NUnit.2.6.2/lib/nunit.framework.dll
-
-endif
-
-if ENABLE_RELEASE_X64
-ASSEMBLY_COMPILER_COMMAND = dmcs
-ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -optimize+ "-define:TRACE"
-ASSEMBLY = bin/Release/ConsoleTest.exe
-ASSEMBLY_MDB =
-COMPILE_TARGET = exe
-PROJECT_REFERENCES = \
- ../Run/Release/net40/NLua.dll \
- ../tests/NLuaTest.dll
-BUILD_DIR = bin/Release/
-
-CONSOLETEST_EXE_MDB=
-CONSOLETEST_EXE_CONFIG_SOURCE=App.config
-NLUA_DLL_SOURCE=../Run/Release/net40/NLua.dll
-NLUA_DLL_MDB=
-KERALUA_DLL_SOURCE=../Core/KeraLua/src/bin/Release/net40/KeraLua.dll
-KERALUA_DLL_MDB=
-KOPILUA_DLL_SOURCE=../Core/KopiLua/Bin/Release/net40/KopiLua.dll
-KOPILUA_DLL_MDB=
-NLUATEST_DLL_SOURCE=../tests/NLuaTest.dll
-NLUATEST_DLL_MDB=
-NUNIT_FRAMEWORK_DLL_SOURCE=../packages/NUnit.2.6.2/lib/nunit.framework.dll
-
-endif
-
-if ENABLE_DEBUGKOPILUA_X64
-ASSEMBLY_COMPILER_COMMAND = dmcs
-ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -optimize- -debug "-define:DEBUG;TRACE"
-ASSEMBLY = bin/DebugKopiLua/ConsoleTest.exe
-ASSEMBLY_MDB = $(ASSEMBLY).mdb
-COMPILE_TARGET = exe
-PROJECT_REFERENCES = \
- ../Core/NLua/bin/DebugKopiLua/NLua.dll \
- ../NLuaTest/bin/DebugKopiLua/NLuaTest.dll
-BUILD_DIR = bin/DebugKopiLua/
-
-CONSOLETEST_EXE_MDB_SOURCE=bin/DebugKopiLua/ConsoleTest.exe.mdb
-CONSOLETEST_EXE_MDB=$(BUILD_DIR)/ConsoleTest.exe.mdb
-CONSOLETEST_EXE_CONFIG_SOURCE=App.config
-NLUA_DLL_SOURCE=../Core/NLua/bin/DebugKopiLua/NLua.dll
-NLUA_DLL_MDB_SOURCE=../Core/NLua/bin/DebugKopiLua/NLua.dll.mdb
-NLUA_DLL_MDB=$(BUILD_DIR)/NLua.dll.mdb
-KERALUA_DLL_SOURCE=../Core/KeraLua/src/bin/DebugKopiLua/KeraLua.dll
-KERALUA_DLL_MDB_SOURCE=../Core/KeraLua/src/bin/DebugKopiLua/KeraLua.dll.mdb
-KERALUA_DLL_MDB=$(BUILD_DIR)/KeraLua.dll.mdb
-KOPILUA_DLL_SOURCE=../Core/KopiLua/KopiLua/bin/DebugKopiLua/KopiLua.dll
-KOPILUA_DLL_MDB_SOURCE=../Core/KopiLua/KopiLua/bin/DebugKopiLua/KopiLua.dll.mdb
-KOPILUA_DLL_MDB=$(BUILD_DIR)/KopiLua.dll.mdb
-NLUATEST_DLL_SOURCE=../NLuaTest/bin/DebugKopiLua/NLuaTest.dll
-NLUATEST_DLL_MDB_SOURCE=../NLuaTest/bin/DebugKopiLua/NLuaTest.dll.mdb
-NLUATEST_DLL_MDB=$(BUILD_DIR)/NLuaTest.dll.mdb
-NUNIT_FRAMEWORK_DLL_SOURCE=../packages/NUnit.2.6.2/lib/nunit.framework.dll
-
-endif
-
-if ENABLE_RELEASEKOPILUA_X64
-ASSEMBLY_COMPILER_COMMAND = dmcs
-ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -warn:4 -optimize-
-ASSEMBLY = bin/ReleaseKopiLua/ConsoleTest.exe
-ASSEMBLY_MDB =
-COMPILE_TARGET = exe
-PROJECT_REFERENCES = \
- ../Core/NLua/bin/ReleaseKopiLua/NLua.dll \
- ../tests/NLuaTest.dll
-BUILD_DIR = bin/ReleaseKopiLua/
-
-CONSOLETEST_EXE_MDB=
-CONSOLETEST_EXE_CONFIG_SOURCE=App.config
-NLUA_DLL_SOURCE=../Core/NLua/bin/ReleaseKopiLua/NLua.dll
-NLUA_DLL_MDB=
-KERALUA_DLL_SOURCE=../Core/KeraLua/src/bin/ReleaseKopiLua/KeraLua.dll
-KERALUA_DLL_MDB=
-KOPILUA_DLL_SOURCE=../Core/KopiLua/KopiLua/bin/ReleaseKopiLua/KopiLua.dll
-KOPILUA_DLL_MDB=
-NLUATEST_DLL_SOURCE=../tests/NLuaTest.dll
-NLUATEST_DLL_MDB=
-NUNIT_FRAMEWORK_DLL_SOURCE=../packages/NUnit.2.6.2/lib/nunit.framework.dll
-
-endif
-
-AL=al
-SATELLITE_ASSEMBLY_NAME=$(notdir $(basename $(ASSEMBLY))).resources.dll
-
-PROGRAMFILES = \
- $(CONSOLETEST_EXE_MDB) \
- $(CONSOLETEST_EXE_CONFIG) \
- $(NLUA_DLL) \
- $(NLUA_DLL_MDB) \
- $(KERALUA_DLL) \
- $(KERALUA_DLL_MDB) \
- $(KOPILUA_DLL) \
- $(KOPILUA_DLL_MDB) \
- $(NLUATEST_DLL) \
- $(NLUATEST_DLL_MDB) \
- $(NUNIT_FRAMEWORK_DLL)
-
-BINARIES = \
- $(CONSOLETEST_40)
-
-
-RESGEN=resgen2
-
-all: $(ASSEMBLY) $(PROGRAMFILES) $(BINARIES)
-
-FILES = \
- ../tests/Entity.cs \
- ../tests/TestLua.cs \
- Program.cs \
- Properties/AssemblyInfo.cs
-
-DATA_FILES =
-
-RESOURCES =
-
-EXTRAS = \
- App.config \
- consoletest.40.in
-
-REFERENCES = \
- System \
- System.Core \
- System.Numerics \
- System.Xml.Linq \
- System.Data \
- System.Xml
-
-DLL_REFERENCES =
-
-CLEANFILES = $(PROGRAMFILES) $(BINARIES)
-
-include $(top_srcdir)/Makefile.include
-
-CONSOLETEST_EXE_CONFIG = $(BUILD_DIR)/ConsoleTest.exe.config
-NLUA_DLL = $(BUILD_DIR)/NLua.dll
-KERALUA_DLL = $(BUILD_DIR)/KeraLua.dll
-KOPILUA_DLL = $(BUILD_DIR)/KopiLua.dll
-NLUATEST_DLL = $(BUILD_DIR)/NLuaTest.dll
-NUNIT_FRAMEWORK_DLL = $(BUILD_DIR)/nunit.framework.dll
-CONSOLETEST_40 = $(BUILD_DIR)/consoletest.40
-
-$(eval $(call emit-deploy-target,CONSOLETEST_EXE_CONFIG))
-$(eval $(call emit-deploy-target,NLUA_DLL))
-$(eval $(call emit-deploy-target,NLUA_DLL_MDB))
-$(eval $(call emit-deploy-target,KERALUA_DLL))
-$(eval $(call emit-deploy-target,KERALUA_DLL_MDB))
-$(eval $(call emit-deploy-target,KOPILUA_DLL))
-$(eval $(call emit-deploy-target,KOPILUA_DLL_MDB))
-$(eval $(call emit-deploy-target,NLUATEST_DLL))
-$(eval $(call emit-deploy-target,NLUATEST_DLL_MDB))
-$(eval $(call emit-deploy-target,NUNIT_FRAMEWORK_DLL))
-$(eval $(call emit-deploy-wrapper,CONSOLETEST_40,consoletest.40,x))
-
-
-$(eval $(call emit_resgen_targets))
-$(build_xamlg_list): %.xaml.g.cs: %.xaml
- xamlg '$<'
-
-$(ASSEMBLY_MDB): $(ASSEMBLY)
-
-$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) $(DLL_REFERENCES) $(PROJECT_REFERENCES) $(build_xamlg_list) $(build_satellite_assembly_list)
- mkdir -p $(shell dirname $(ASSEMBLY))
- $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$(ASSEMBLY) -target:$(COMPILE_TARGET) $(build_sources_embed) $(build_resources_embed) $(build_references_ref)
diff --git a/ConsoleTest/Program.cs b/ConsoleTest/Program.cs
deleted file mode 100755
index 96231ddced66930aca02aea26e1a0744da827e90..0000000000000000000000000000000000000000
--- a/ConsoleTest/Program.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using NLua;
-using NLuaTest.Mock;
-using NLuaTest;
-
-namespace ConsoleTest
-{
-
- public class Program
- {
- static public void Method(int a, params int[] others) {
- Console.WriteLine (a);
- foreach (int val in others)
- Console.WriteLine (val);
- }
-
- static void Main (string [] args)
- {
- using (var l = new Lua ()) {
- l.LoadCLRPackage ();
- l.DoString (" import ('ConsoleTest', 'NLuaTest.Mock') ");
- l.DoString (@"
- e1 = Entity()
- e2 = Entity ('Another world')
- e3 = Entity (10)
- ");
- }
- }
- }
-}
diff --git a/ConsoleTest/Properties/AssemblyInfo.cs b/ConsoleTest/Properties/AssemblyInfo.cs
deleted file mode 100644
index f4a250fa339169f7d15147ed111026004ec114db..0000000000000000000000000000000000000000
--- a/ConsoleTest/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle ("ConsoleTest")]
-[assembly: AssemblyDescription ("")]
-[assembly: AssemblyConfiguration ("")]
-[assembly: AssemblyCompany ("")]
-[assembly: AssemblyProduct ("ConsoleTest")]
-[assembly: AssemblyCopyright ("Copyright © 2015")]
-[assembly: AssemblyTrademark ("")]
-[assembly: AssemblyCulture ("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible (false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid ("7c99edf7-f9ea-40fd-9ff9-c463f501e21a")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion ("1.0.0.0")]
-[assembly: AssemblyFileVersion ("1.0.0.0")]
diff --git a/ConsoleTest/consoletest.40.in b/ConsoleTest/consoletest.40.in
deleted file mode 100644
index 0521b34b71e01e6c5bf20e36625fc5050ca095c7..0000000000000000000000000000000000000000
--- a/ConsoleTest/consoletest.40.in
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-exec mono "@expanded_libdir@/@PACKAGE@/ConsoleTest.exe" "$@"
diff --git a/Core/KeraLua b/Core/KeraLua
deleted file mode 160000
index e5ef8341688d8a25e8cf6f6d812ab3da365399b6..0000000000000000000000000000000000000000
--- a/Core/KeraLua
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit e5ef8341688d8a25e8cf6f6d812ab3da365399b6
diff --git a/Core/KopiLua b/Core/KopiLua
deleted file mode 160000
index 6855aea035e73911cb01da1f1616f2f579251e65..0000000000000000000000000000000000000000
--- a/Core/KopiLua
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 6855aea035e73911cb01da1f1616f2f579251e65
diff --git a/Core/Makefile.am b/Core/Makefile.am
deleted file mode 100644
index f894acac7423b3756f8eb5ff0a8113df777a9ee9..0000000000000000000000000000000000000000
--- a/Core/Makefile.am
+++ /dev/null
@@ -1,28 +0,0 @@
-
-EXTRA_DIST =
-
-#Warning: This is an automatically generated file, do not edit!
-if ENABLE_DEBUG
- SUBDIRS = KopiLua/KopiLua KeraLua/src NLua
-endif
-if ENABLE_DEBUGKOPILUA
- SUBDIRS = KopiLua/KopiLua KeraLua/src NLua
-endif
-if ENABLE_RELEASE
- SUBDIRS = KopiLua/KopiLua KeraLua/src NLua
-endif
-if ENABLE_RELEASEKOPILUA
- SUBDIRS = KopiLua/KopiLua KeraLua/src NLua
-endif
-if ENABLE_DEBUG_X64
- SUBDIRS = KopiLua/KopiLua KeraLua/src NLua
-endif
-if ENABLE_RELEASE_X64
- SUBDIRS = KopiLua/KopiLua KeraLua/src NLua
-endif
-if ENABLE_DEBUGKOPILUA_X64
- SUBDIRS = KopiLua/KopiLua KeraLua/src NLua
-endif
-if ENABLE_RELEASEKOPILUA_X64
- SUBDIRS = KopiLua/KopiLua KeraLua/src NLua
-endif
diff --git a/Core/NLua/CheckType.cs b/Core/NLua/CheckType.cs
deleted file mode 100755
index 80371a5a0a134b5a9bcd2fbe889992954466e0aa..0000000000000000000000000000000000000000
--- a/Core/NLua/CheckType.cs
+++ /dev/null
@@ -1,388 +0,0 @@
-/*
- * This file is part of NLua.
- *
- * Copyright (c) 2015 Vinicius Jarina (viniciusjarina@gmail.com)
- * Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
- * Copyright (C) 2012 Megax
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-using System;
-using System.Reflection;
-using System.Collections.Generic;
-using NLua.Method;
-using NLua.Extensions;
-
-namespace NLua
-{
- #if USE_KOPILUA
- using LuaCore = KopiLua.Lua;
- using LuaState = KopiLua.LuaState;
- #else
- using LuaCore = KeraLua.Lua;
- using LuaState = KeraLua.LuaState;
- #endif
-
- /*
- * Type checking and conversion functions.
- *
- * Author: Fabio Mascarenhas
- * Version: 1.0
- */
- sealed class CheckType
- {
- Dictionary extractValues = new Dictionary();
- ExtractValue extractNetObject;
- ObjectTranslator translator;
-
- public CheckType (ObjectTranslator translator)
- {
- this.translator = translator;
- extractValues.Add(GetExtractDictionaryKey(typeof(object)), new ExtractValue(GetAsObject));
- extractValues.Add(GetExtractDictionaryKey(typeof(sbyte)), new ExtractValue(GetAsSbyte));
- extractValues.Add(GetExtractDictionaryKey(typeof(byte)), new ExtractValue(GetAsByte));
- extractValues.Add(GetExtractDictionaryKey(typeof(short)), new ExtractValue(GetAsShort));
- extractValues.Add(GetExtractDictionaryKey(typeof(ushort)), new ExtractValue(GetAsUshort));
- extractValues.Add(GetExtractDictionaryKey(typeof(int)), new ExtractValue(GetAsInt));
- extractValues.Add(GetExtractDictionaryKey(typeof(uint)), new ExtractValue(GetAsUint));
- extractValues.Add(GetExtractDictionaryKey(typeof(long)), new ExtractValue(GetAsLong));
- extractValues.Add(GetExtractDictionaryKey(typeof(ulong)), new ExtractValue(GetAsUlong));
- extractValues.Add(GetExtractDictionaryKey(typeof(double)), new ExtractValue(GetAsDouble));
- extractValues.Add(GetExtractDictionaryKey(typeof(char)), new ExtractValue(GetAsChar));
- extractValues.Add(GetExtractDictionaryKey(typeof(float)), new ExtractValue(GetAsFloat));
- extractValues.Add(GetExtractDictionaryKey(typeof(decimal)), new ExtractValue(GetAsDecimal));
- extractValues.Add(GetExtractDictionaryKey(typeof(bool)), new ExtractValue(GetAsBoolean));
- extractValues.Add(GetExtractDictionaryKey(typeof(string)), new ExtractValue(GetAsString));
- extractValues.Add(GetExtractDictionaryKey(typeof(char[])), new ExtractValue (GetAsCharArray));
- extractValues.Add(GetExtractDictionaryKey(typeof(LuaFunction)), new ExtractValue(GetAsFunction));
- extractValues.Add(GetExtractDictionaryKey(typeof(LuaTable)), new ExtractValue(GetAsTable));
- extractValues.Add(GetExtractDictionaryKey(typeof(LuaUserData)), new ExtractValue(GetAsUserdata));
- extractNetObject = new ExtractValue (GetAsNetObject);
- }
-
- /*
- * Checks if the value at Lua stack index stackPos matches paramType,
- * returning a conversion function if it does and null otherwise.
- */
- internal ExtractValue GetExtractor (ProxyType paramType)
- {
- return GetExtractor (paramType.UnderlyingSystemType);
- }
-
- internal ExtractValue GetExtractor (Type paramType)
- {
- if (paramType.IsByRef)
- paramType = paramType.GetElementType ();
-
- var extractKey = GetExtractDictionaryKey(paramType);
- return extractValues.ContainsKey(extractKey) ? extractValues[extractKey] : extractNetObject;
- }
-
- internal ExtractValue CheckLuaType (LuaState luaState, int stackPos, Type paramType)
- {
- var luatype = LuaLib.LuaType (luaState, stackPos);
-
- if (paramType.IsByRef)
- paramType = paramType.GetElementType ();
-
- var underlyingType = Nullable.GetUnderlyingType (paramType);
-
- if (underlyingType != null) {
- paramType = underlyingType; // Silently convert nullable types to their non null requics
- }
-
- var extractKey = GetExtractDictionaryKey (paramType);
-
- bool netParamIsNumeric = paramType == typeof (int) ||
- paramType == typeof (uint) ||
- paramType == typeof (long) ||
- paramType == typeof (ulong) ||
- paramType == typeof (short) ||
- paramType == typeof (ushort) ||
- paramType == typeof (float) ||
- paramType == typeof (double) ||
- paramType == typeof (decimal) ||
- paramType == typeof (byte);
-
- // If it is a nullable
- if (underlyingType != null) {
- // null can always be assigned to nullable
- if (luatype == LuaTypes.Nil) {
- // Return the correct extractor anyways
- if (netParamIsNumeric || paramType == typeof (bool))
- return extractValues [extractKey];
- return extractNetObject;
- }
- }
-
- if (paramType.Equals (typeof(object)))
- return extractValues [extractKey];
-
- //CP: Added support for generic parameters
- if (paramType.IsGenericParameter) {
- if (luatype == LuaTypes.Boolean)
- return extractValues [GetExtractDictionaryKey (typeof(bool))];
- else if (luatype == LuaTypes.String)
- return extractValues[GetExtractDictionaryKey (typeof(string))];
- else if (luatype == LuaTypes.Table)
- return extractValues [GetExtractDictionaryKey (typeof(LuaTable))];
- else if (luatype == LuaTypes.UserData)
- return extractValues [GetExtractDictionaryKey (typeof(object))];
- else if (luatype == LuaTypes.Function)
- return extractValues [GetExtractDictionaryKey (typeof(LuaFunction))];
- else if (luatype == LuaTypes.Number)
- return extractValues [GetExtractDictionaryKey (typeof(double))];
- }
- bool netParamIsString = paramType == typeof (string) || paramType == typeof (char []);
-
- if (netParamIsNumeric) {
- if (LuaLib.LuaIsNumber (luaState, stackPos) && !netParamIsString)
- return extractValues [extractKey];
- } else if (paramType == typeof(bool)) {
- if (LuaLib.LuaIsBoolean (luaState, stackPos))
- return extractValues [extractKey];
- } else if (netParamIsString) {
- if (LuaLib.LuaNetIsStringStrict (luaState, stackPos))
- return extractValues [extractKey];
- else if (luatype == LuaTypes.Nil)
- return extractNetObject; // kevinh - silently convert nil to a null string pointer
- } else if (paramType == typeof(LuaTable)) {
- if (luatype == LuaTypes.Table || luatype == LuaTypes.Nil)
- return extractValues [extractKey];
- } else if (paramType == typeof(LuaUserData)) {
- if (luatype == LuaTypes.UserData || luatype == LuaTypes.Nil)
- return extractValues [extractKey];
- } else if (paramType == typeof(LuaFunction)) {
- if (luatype == LuaTypes.Function || luatype == LuaTypes.Nil)
- return extractValues [extractKey];
- } else if (typeof(Delegate).IsAssignableFrom (paramType) && luatype == LuaTypes.Function)
- return new ExtractValue (new DelegateGenerator (translator, paramType).ExtractGenerated);
- else if (paramType.IsInterface() && luatype == LuaTypes.Table)
- return new ExtractValue (new ClassGenerator (translator, paramType).ExtractGenerated);
- else if ((paramType.IsInterface() || paramType.IsClass()) && luatype == LuaTypes.Nil) {
- // kevinh - allow nil to be silently converted to null - extractNetObject will return null when the item ain't found
- return extractNetObject;
- } else if (LuaLib.LuaType (luaState, stackPos) == LuaTypes.Table) {
- if (LuaLib.LuaLGetMetafield (luaState, stackPos, "__index")) {
- object obj = translator.GetNetObject (luaState, -1);
- LuaLib.LuaSetTop (luaState, -2);
- if (obj != null && paramType.IsAssignableFrom (obj.GetType ()))
- return extractNetObject;
- } else
- return null;
- } else {
- object obj = translator.GetNetObject (luaState, stackPos);
- if (obj != null && paramType.IsAssignableFrom (obj.GetType ()))
- return extractNetObject;
- }
-
- return null;
- }
-
- Type GetExtractDictionaryKey(Type targetType)
- {
- return targetType;
- }
-
- /*
- * The following functions return the value in the Lua stack
- * index stackPos as the desired type if it can, or null
- * otherwise.
- */
- private object GetAsSbyte (LuaState luaState, int stackPos)
- {
- sbyte retVal = (sbyte)LuaLib.LuaToNumber (luaState, stackPos);
- if (retVal == 0 && !LuaLib.LuaIsNumber (luaState, stackPos))
- return null;
-
- return retVal;
- }
-
- private object GetAsByte (LuaState luaState, int stackPos)
- {
- byte retVal = (byte)LuaLib.LuaToNumber (luaState, stackPos);
- if (retVal == 0 && !LuaLib.LuaIsNumber (luaState, stackPos))
- return null;
-
- return retVal;
- }
-
- private object GetAsShort (LuaState luaState, int stackPos)
- {
- short retVal = (short)LuaLib.LuaToNumber (luaState, stackPos);
- if (retVal == 0 && !LuaLib.LuaIsNumber (luaState, stackPos))
- return null;
-
- return retVal;
- }
-
- private object GetAsUshort (LuaState luaState, int stackPos)
- {
- ushort retVal = (ushort)LuaLib.LuaToNumber (luaState, stackPos);
- if (retVal == 0 && !LuaLib.LuaIsNumber (luaState, stackPos))
- return null;
-
- return retVal;
- }
-
- private object GetAsInt (LuaState luaState, int stackPos)
- {
- if (!LuaLib.LuaIsNumber (luaState, stackPos))
- return null;
-
- int retVal = (int)LuaLib.LuaToNumber (luaState, stackPos);
- return retVal;
- }
-
- private object GetAsUint (LuaState luaState, int stackPos)
- {
- uint retVal = (uint)LuaLib.LuaToNumber (luaState, stackPos);
- if (retVal == 0 && !LuaLib.LuaIsNumber (luaState, stackPos))
- return null;
-
- return retVal;
- }
-
- private object GetAsLong (LuaState luaState, int stackPos)
- {
- long retVal = (long)LuaLib.LuaToNumber (luaState, stackPos);
- if (retVal == 0 && !LuaLib.LuaIsNumber (luaState, stackPos))
- return null;
-
- return retVal;
- }
-
- private object GetAsUlong (LuaState luaState, int stackPos)
- {
- ulong retVal = (ulong)LuaLib.LuaToNumber (luaState, stackPos);
- if (retVal == 0 && !LuaLib.LuaIsNumber (luaState, stackPos))
- return null;
-
- return retVal;
- }
-
- private object GetAsDouble (LuaState luaState, int stackPos)
- {
- double retVal = LuaLib.LuaToNumber (luaState, stackPos);
- if (retVal == 0 && !LuaLib.LuaIsNumber (luaState, stackPos))
- return null;
-
- return retVal;
- }
-
- private object GetAsChar (LuaState luaState, int stackPos)
- {
- char retVal = (char)LuaLib.LuaToNumber (luaState, stackPos);
- if (retVal == 0 && !LuaLib.LuaIsNumber (luaState, stackPos))
- return null;
-
- return retVal;
- }
-
- private object GetAsFloat (LuaState luaState, int stackPos)
- {
- float retVal = (float)LuaLib.LuaToNumber (luaState, stackPos);
- if (retVal == 0 && !LuaLib.LuaIsNumber (luaState, stackPos))
- return null;
-
- return retVal;
- }
-
- private object GetAsDecimal (LuaState luaState, int stackPos)
- {
- decimal retVal = (decimal)LuaLib.LuaToNumber (luaState, stackPos);
- if (retVal == 0 && !LuaLib.LuaIsNumber (luaState, stackPos))
- return null;
-
- return retVal;
- }
-
- private object GetAsBoolean (LuaState luaState, int stackPos)
- {
- return LuaLib.LuaToBoolean (luaState, stackPos);
- }
-
-
-
- private object GetAsCharArray (LuaState luaState, int stackPos)
- {
- if (!LuaLib.LuaNetIsStringStrict (luaState, stackPos))
- return null;
- string retVal = LuaLib.LuaToString (luaState, stackPos).ToString ();
- return retVal.ToCharArray();
- }
-
- private object GetAsString (LuaState luaState, int stackPos)
- {
- if (!LuaLib.LuaNetIsStringStrict (luaState, stackPos))
- return null;
- string retVal = LuaLib.LuaToString (luaState, stackPos).ToString ();
- return retVal;
- }
-
- private object GetAsTable (LuaState luaState, int stackPos)
- {
- return translator.GetTable (luaState, stackPos);
- }
-
- private object GetAsFunction (LuaState luaState, int stackPos)
- {
- return translator.GetFunction (luaState, stackPos);
- }
-
- private object GetAsUserdata (LuaState luaState, int stackPos)
- {
- return translator.GetUserData (luaState, stackPos);
- }
-
- public object GetAsObject (LuaState luaState, int stackPos)
- {
- if (LuaLib.LuaType (luaState, stackPos) == LuaTypes.Table) {
- if (LuaLib.LuaLGetMetafield (luaState, stackPos, "__index")) {
- if (LuaLib.LuaLCheckMetatable (luaState, -1)) {
- LuaLib.LuaInsert (luaState, stackPos);
- LuaLib.LuaRemove (luaState, stackPos + 1);
- } else
- LuaLib.LuaSetTop (luaState, -2);
- }
- }
-
- object obj = translator.GetObject (luaState, stackPos);
- return obj;
- }
-
- public object GetAsNetObject (LuaState luaState, int stackPos)
- {
- object obj = translator.GetNetObject (luaState, stackPos);
-
- if (obj == null && LuaLib.LuaType (luaState, stackPos) == LuaTypes.Table) {
- if (LuaLib.LuaLGetMetafield (luaState, stackPos, "__index")) {
- if (LuaLib.LuaLCheckMetatable (luaState, -1)) {
- LuaLib.LuaInsert (luaState, stackPos);
- LuaLib.LuaRemove (luaState, stackPos + 1);
- obj = translator.GetNetObject (luaState, stackPos);
- } else
- LuaLib.LuaSetTop (luaState, -2);
- }
- }
-
- return obj;
- }
- }
-}
\ No newline at end of file
diff --git a/Core/NLua/Config/NLuaConfig.cs b/Core/NLua/Config/NLuaConfig.cs
deleted file mode 100644
index d23d06b8d500f868f35473c9e107f7bae29241ad..0000000000000000000000000000000000000000
--- a/Core/NLua/Config/NLuaConfig.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * This file is part of NLua.
- *
- * Copyright (c) 2015 Vinicius Jarina (viniciusjarina@gmail.com)
- * Copyright (C) 2012 Megax
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-using System;
-
-namespace NLua.Config
-{
- public static class Consts
- {
- public const string NLuaDescription = "Bridge between the Lua runtime and the CLR";
-#if DEBUG
- public const string NLuaConfiguration = "Debug";
-#else
- public const string NLuaConfiguration = "Release";
-#endif
- public const string NLuaCompany = "NLua.org";
- public const string NLuaProduct = "NLua";
- public const string NLuaCopyright = "Copyright 2003-2015 Vinicius Jarina , Fabio Mascarenhas, Kevin Hesterm and Megax";
- public const string NLuaTrademark = "MIT license";
- public const string NLuaVersion = "1.3.2";
- public const string NLuaFileVersion = "1.3.2";
- }
-}
\ No newline at end of file
diff --git a/Core/NLua/Event/DebugHookEventArgs.cs b/Core/NLua/Event/DebugHookEventArgs.cs
deleted file mode 100644
index b1b0194fa005d0c147705a45698191f257f1bc41..0000000000000000000000000000000000000000
--- a/Core/NLua/Event/DebugHookEventArgs.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * This file is part of NLua.
- *
- * Copyright (c) 2015 Vinicius Jarina (viniciusjarina@gmail.com)
- * Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
- * Copyright (C) 2012 Megax
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-using System;
-
-namespace NLua.Event
-{
- #if USE_KOPILUA
- using LuaCore = KopiLua.Lua;
- using LuaState = KopiLua.LuaState;
- using LuaDebug = KopiLua.LuaDebug;
- #else
- using LuaCore = KeraLua.Lua;
- using LuaState = KeraLua.LuaState;
- using LuaDebug = KeraLua.LuaDebug;
- #endif
-
- ///
- /// Event args for hook callback event
- ///
- /// Reinhard Ostermeier
- public class DebugHookEventArgs : EventArgs
- {
- private readonly LuaDebug luaDebug;
-
- public DebugHookEventArgs (LuaDebug luaDebug)
- {
- this.luaDebug = luaDebug;
- }
-
- public LuaDebug LuaDebug {
- get { return luaDebug; }
- }
- }
-}
\ No newline at end of file
diff --git a/Core/NLua/Event/EventCodes.cs b/Core/NLua/Event/EventCodes.cs
deleted file mode 100755
index 9d962a4ed6724450777b205326bd7c3b3a385d0a..0000000000000000000000000000000000000000
--- a/Core/NLua/Event/EventCodes.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * This file is part of NLua.
- *
- * Copyright (c) 2015 Vinicius Jarina (viniciusjarina@gmail.com)
- * Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
- * Copyright (C) 2012 Megax
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-using System;
-
-namespace NLua.Event
-{
- ///
- /// Event codes for lua hook function
- ///
- ///
- /// Do not change any of the values because they must match the lua values
- ///
- public enum EventCodes
- {
- LUA_HOOKCALL = 0,
- LUA_HOOKRET = 1,
- LUA_HOOKLINE = 2,
- LUA_HOOKCOUNT = 3,
- LUA_HOOKTAILRET = 4
- }
-}
\ No newline at end of file
diff --git a/Core/NLua/Event/EventMasks.cs b/Core/NLua/Event/EventMasks.cs
deleted file mode 100755
index bd4da588303dca30feb74e42e9b108f008a45e8d..0000000000000000000000000000000000000000
--- a/Core/NLua/Event/EventMasks.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * This file is part of NLua.
- *
- * Copyright (c) 2015 Vinicius Jarina (viniciusjarina@gmail.com)
- * Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
- * Copyright (C) 2012 Megax
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-using System;
-
-namespace NLua.Event
-{
- ///
- /// Event masks for lua hook callback
- ///
- ///
- /// Do not change any of the values because they must match the lua values
- ///
- [Flags]
- public enum EventMasks
- {
- LUA_MASKCALL = (1 << EventCodes.LUA_HOOKCALL),
- LUA_MASKRET = (1 << EventCodes.LUA_HOOKRET),
- LUA_MASKLINE = (1 << EventCodes.LUA_HOOKLINE),
- LUA_MASKCOUNT = (1 << EventCodes.LUA_HOOKCOUNT),
- LUA_MASKALL = Int32.MaxValue
- }
-}
\ No newline at end of file
diff --git a/Core/NLua/Event/HookExceptionEventArgs.cs b/Core/NLua/Event/HookExceptionEventArgs.cs
deleted file mode 100644
index dd7fd98126c4842ae7ec13e91da0296ad46d4292..0000000000000000000000000000000000000000
--- a/Core/NLua/Event/HookExceptionEventArgs.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * This file is part of NLua.
- *
- * Copyright (c) 2015 Vinicius Jarina (viniciusjarina@gmail.com)
- * Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
- * Copyright (C) 2012 Megax
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-using System;
-
-namespace NLua.Event
-{
- public class HookExceptionEventArgs : EventArgs
- {
- private readonly Exception m_Exception;
-
- public Exception Exception {
- get { return m_Exception; }
- }
-
- public HookExceptionEventArgs (Exception ex)
- {
- m_Exception = ex;
- }
- }
-}
\ No newline at end of file
diff --git a/Core/NLua/Exceptions/LuaException.cs b/Core/NLua/Exceptions/LuaException.cs
deleted file mode 100755
index 163a29a4e44bd28a493ff73cf32095575d58d838..0000000000000000000000000000000000000000
--- a/Core/NLua/Exceptions/LuaException.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * This file is part of NLua.
- *
- * Copyright (c) 2015 Vinicius Jarina (viniciusjarina@gmail.com)
- * Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
- * Copyright (C) 2012 Megax
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-using System;
-#if !SILVERLIGHT && !NETFX_CORE
-using System.Runtime.Serialization;
-#endif
-
-namespace NLua.Exceptions
-{
- ///
- /// Exceptions thrown by the Lua runtime
- ///
-#if !SILVERLIGHT && !NETFX_CORE
- [Serializable]
-#endif
- public class LuaException : Exception
- {
- public LuaException ()
- {
- }
-
- public LuaException (string message) : base(message)
- {
- }
-
- public LuaException (string message, Exception innerException) : base(message, innerException)
- {
- }
-
-#if !SILVERLIGHT && !NETFX_CORE
- protected LuaException (SerializationInfo info, StreamingContext context) : base(info, context)
- {
- }
-#endif
- }
-}
\ No newline at end of file
diff --git a/Core/NLua/Exceptions/LuaScriptException.cs b/Core/NLua/Exceptions/LuaScriptException.cs
deleted file mode 100755
index e37b191dd263ae882f639e90adfe1d33ddd32cb2..0000000000000000000000000000000000000000
--- a/Core/NLua/Exceptions/LuaScriptException.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * This file is part of NLua.
- *
- * Copyright (c) 2015 Vinicius Jarina (viniciusjarina@gmail.com)
- * Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
- * Copyright (C) 2012 Megax
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-using System;
-
-namespace NLua.Exceptions
-{
- ///
- /// Exceptions thrown by the Lua runtime because of errors in the script
- ///
- ///
-#if !SILVERLIGHT && !NETFX_CORE
- [Serializable]
-#endif
- public class LuaScriptException : LuaException
- {
- ///
- /// Returns true if the exception has occured as the result of a .NET exception in user code
- ///
- public bool IsNetException { get; private set; }
-
- private readonly string source;
-
- ///
- /// The position in the script where the exception was triggered.
- ///
-#if SILVERLIGHT && !WINDOWS_PHONE
- public string Source { get { return source; } }
-#else
- public override string Source { get { return source; } }
-#endif
-
- ///
- /// Creates a new Lua-only exception.
- ///
- /// The message that describes the error.
- /// The position in the script where the exception was triggered.
- public LuaScriptException (string message, string source) : base(message)
- {
- this.source = source;
- }
-
- ///
- /// Creates a new .NET wrapping exception.
- ///
- /// The .NET exception triggered by user-code.
- /// The position in the script where the exception was triggered.
- public LuaScriptException (Exception innerException, string source)
- : base("A .NET exception occured in user-code", innerException)
- {
- this.source = source;
- this.IsNetException = true;
- }
-
- public override string ToString ()
- {
- // Prepend the error source
- return GetType ().FullName + ": " + source + Message;
- }
- }
-}
\ No newline at end of file
diff --git a/Core/NLua/Extensions/GeneralExtensions.cs b/Core/NLua/Extensions/GeneralExtensions.cs
deleted file mode 100755
index 9aeb72f6e31d20818bec25d5ff03af5b84398a30..0000000000000000000000000000000000000000
--- a/Core/NLua/Extensions/GeneralExtensions.cs
+++ /dev/null
@@ -1,415 +0,0 @@
-/*
- * This file is part of NLua.
- *
- * Copyright (c) 2015 Vinicius Jarina (viniciusjarina@gmail.com)
- * Copyright (C) 2012 Megax
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-using System;
-using System.Linq;
-using System.Collections.Generic;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-
-namespace NLua.Extensions
-{
- ///
- /// Some random extension stuff.
- ///
- static class CheckNull
- {
- ///
- /// Determines whether the specified obj is null.
- ///
- /// The obj.
- ///
- /// true if the specified obj is null; otherwise, false.
- ///
- ///
-
-#if USE_KOPILUA
- public static bool IsNull (object obj)
- {
- return (obj == null);
- }
-#else
-
- public static bool IsNull (IntPtr ptr)
- {
- return (ptr.Equals (IntPtr.Zero));
- }
-#endif
- }
-
- static class TypeExtensions
- {
- public static bool HasMethod (this Type t, string name)
- {
- var op = t.GetMethods (BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
- return op.Any (m => m.Name == name);
- }
-
- public static bool HasAdditionOpertator (this Type t)
- {
- if (t.IsPrimitive ())
- return true;
-
- return t.HasMethod ("op_Addition");
- }
-
- public static bool HasSubtractionOpertator (this Type t)
- {
- if (t.IsPrimitive ())
- return true;
-
- return t.HasMethod ("op_Subtraction");
- }
-
- public static bool HasMultiplyOpertator (this Type t)
- {
- if (t.IsPrimitive ())
- return true;
-
- return t.HasMethod ("op_Multiply");
- }
-
- public static bool HasDivisionOpertator (this Type t)
- {
- if (t.IsPrimitive ())
- return true;
-
- return t.HasMethod ("op_Division");
- }
-
- public static bool HasModulusOpertator (this Type t)
- {
- if (t.IsPrimitive ())
- return true;
-
- return t.HasMethod ("op_Modulus");
- }
-
- public static bool HasUnaryNegationOpertator (this Type t)
- {
- if (t.IsPrimitive ())
- return true;
- // Unary - will always have only one version.
- var op = t.GetMethod ("op_UnaryNegation", BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
- return op != null;
- }
-
- public static bool HasEqualityOpertator (this Type t)
- {
- if (t.IsPrimitive ())
- return true;
- return t.HasMethod ("op_Equality");
- }
-
- public static bool HasLessThanOpertator (this Type t)
- {
- if (t.IsPrimitive ())
- return true;
-
- return t.HasMethod ("op_LessThan");
- }
-
- public static bool HasLessThanOrEqualOpertator (this Type t)
- {
- if (t.IsPrimitive ())
- return true;
- return t.HasMethod ("op_LessThanOrEqual");
- }
-
- public static MethodInfo [] GetMethods (this Type t, string name, BindingFlags flags)
- {
- return t.GetMethods (flags).Where (m => m.Name == name).ToArray ();
- }
-
- public static MethodInfo [] GetExtensionMethods (this Type type, IEnumerable assemblies = null)
- {
- List types = new List ();
-
- types.AddRange (type.GetAssembly().GetTypes ().Where (t => t.IsPublic ()));
-
- if (assemblies != null) {
- foreach (Assembly item in assemblies) {
- if (item == type.GetAssembly ())
- continue;
- types.AddRange (item.GetTypes ().Where (t => t.IsPublic ()));
- }
- }
-
- var query = from extensionType in types
- where extensionType.IsSealed() && !extensionType.IsGenericType() && !extensionType.IsNested
- from method in extensionType.GetMethods (BindingFlags.Static | BindingFlags.Public)
- where method.IsDefined (typeof (ExtensionAttribute), false)
- where (method.GetParameters()[0].ParameterType == type
- || type.IsSubclassOf(method.GetParameters()[0].ParameterType)
- || type.GetInterfaces().Contains(method.GetParameters()[0].ParameterType))
- select method;
- return query.ToArray ();
- }
-
- ///
- /// Extends the System.Type-type to search for a given extended MethodeName.
- ///
- /// Name of the Methode
- /// the found Method or null
- public static MethodInfo GetExtensionMethod (this Type t, string name, IEnumerable assemblies = null)
- {
- var mi = from methode in t.GetExtensionMethods (assemblies)
- where methode.Name == name
- select methode;
- if (!mi.Any ())
- return null;
- else
- return mi.First ();
- }
-
- public static bool IsPrimitive (this Type t)
- {
-#if NETFX_CORE
- return t.GetTypeInfo ().IsPrimitive;
-#else
- return t.IsPrimitive;
-#endif
- }
-
- public static bool IsClass (this Type t)
- {
-#if NETFX_CORE
- return t.GetTypeInfo ().IsClass;
-#else
- return t.IsClass;
-#endif
- }
-
- public static bool IsEnum (this Type t)
- {
-#if NETFX_CORE
- return t.GetTypeInfo ().IsEnum;
-#else
- return t.IsEnum;
-#endif
- }
-
- public static bool IsPublic (this Type t)
- {
-#if NETFX_CORE
- return t.GetTypeInfo ().IsPublic;
-#else
- return t.IsPublic;
-#endif
- }
-
- public static bool IsSealed (this Type t)
- {
-#if NETFX_CORE
- return t.GetTypeInfo ().IsSealed;
-#else
- return t.IsSealed;
-#endif
- }
-
- public static bool IsGenericType (this Type t)
- {
-#if NETFX_CORE
- return t.GetTypeInfo ().IsGenericType;
-#else
- return t.IsGenericType;
-#endif
- }
-
- public static bool IsInterface (this Type t)
- {
-#if NETFX_CORE
- return t.GetTypeInfo ().IsInterface;
-#else
- return t.IsInterface;
-#endif
- }
-
- public static Assembly GetAssembly (this Type t)
- {
-#if NETFX_CORE
- return t.GetTypeInfo ().Assembly;
-#else
- return t.Assembly;
-#endif
- }
-
-#if NETFX_CORE
- // Missing Reflection methods from WinRT
-
- public const BindingFlags Default = BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance;
-
- public static MethodInfo GetMethod (this Type type, string name, BindingFlags flags, Type [] signature)
- {
- return GetMethods (type, flags).FirstOrDefault (c => c.Name == name && c.GetParameters ().Select (p => p.ParameterType).SequenceEqual (signature));
- }
-
- static IEnumerable GetTypes (this Assembly assembly)
- {
- return assembly.ExportedTypes;
- }
-
- public static bool IsAssignableFrom (this Type t, Type t2)
- {
- return t.GetTypeInfo ().IsAssignableFrom (t2.GetTypeInfo ());
- }
-
- public static MemberInfo [] GetMember (this Type type, string name, BindingFlags flags)
- {
- return GetMembers (type, flags).Where (m => m.Name == name).ToArray ();
- }
-
- public static MemberInfo [] GetMembers (this Type type, BindingFlags flags)
- {
- // Metro does have DeclaredMembers but nothing otherwise
- return GetEvents (type, flags).Cast ()
- .Concat (GetFields (type, flags).Cast ())
- .Concat (GetMethods (type, flags).Cast ())
- .Concat (GetProperties (type, flags).Cast ())
- .ToArray ();
- }
-
- public static MethodInfo GetMethod (this Type type, string name)
- {
- return GetMethod (type, name, Default);
- }
-
- public static MethodInfo GetMethod (this Type type, string name, BindingFlags flags)
- {
- return GetMethods (type, flags).FirstOrDefault (m => m.Name == name);
- }
-
- public static MethodInfo [] GetMethods (this Type type)
- {
- return GetMethods (type, Default);
- }
-
- public static MethodInfo [] GetMethods (this Type type, BindingFlags flags)
- {
- var methods = type.GetRuntimeMethods ();
- return methods.Where (m =>
- ((flags.HasFlag (BindingFlags.Static) == m.IsStatic) || (flags.HasFlag (BindingFlags.Instance) == !m.IsStatic)
- ) &&
- (flags.HasFlag (BindingFlags.Public) == m.IsPublic)
- ).ToArray ();
- }
-
- public static PropertyInfo [] GetProperties (this Type type, BindingFlags flags)
- {
- var props = type.GetRuntimeProperties ();
-
- return props.Where (p =>
- ((flags.HasFlag (BindingFlags.Static) == (p.GetMethod != null && p.GetMethod.IsStatic)) ||
- (flags.HasFlag (BindingFlags.Instance) == (p.GetMethod != null && !p.GetMethod.IsStatic))
- ) &&
- (flags.HasFlag (BindingFlags.Public) == (p.GetMethod != null && p.GetMethod.IsPublic)
- )).ToArray ();
- }
- public static ConstructorInfo GetConstructor (this Type type, Type [] paramTypes)
- {
- return GetConstructors (type, Default).FirstOrDefault (c => c.GetParameters ().Select (p => p.ParameterType).SequenceEqual (paramTypes));
- }
-
- public static ConstructorInfo [] GetConstructors (this Type type)
- {
- return GetConstructors (type, Default);
- }
-
- public static ConstructorInfo [] GetConstructors (this Type type, BindingFlags flags)
- {
- var props = type.GetTypeInfo ().DeclaredConstructors;
- return props.Where (p =>
- ((flags.HasFlag (BindingFlags.Static) == p.IsStatic) ||
- (flags.HasFlag (BindingFlags.Instance) == !p.IsStatic)
- ) &&
- (flags.HasFlag (BindingFlags.Public) == p.IsPublic)
- ).ToArray ();
- }
-
- public static EventInfo [] GetEvents (this Type type, BindingFlags flags)
- {
- var props = type.GetRuntimeEvents ();
-
- return props.Where (p =>
- ((flags.HasFlag (BindingFlags.Static) == p.AddMethod.IsStatic) ||
- (flags.HasFlag (BindingFlags.Instance) == !p.AddMethod.IsStatic)
- ) &&
- (flags.HasFlag (BindingFlags.Public) == p.AddMethod.IsPublic)
- ).ToArray ();
- }
-
- public static FieldInfo GetField (this Type type, string name)
- {
- return GetField (type, name, Default);
- }
-
- public static FieldInfo GetField (this Type type, string name, BindingFlags flags)
- {
- return GetFields (type, flags).FirstOrDefault (f => f.Name == name);
- }
-
- public static FieldInfo [] GetFields (this Type type, BindingFlags flags)
- {
- var fields = type.GetRuntimeFields ();
-
- return fields.Where (p =>
- ((flags.HasFlag (BindingFlags.Static) == p.IsStatic) || (flags.HasFlag (BindingFlags.Instance) == !p.IsStatic)
- ) &&
- (flags.HasFlag (BindingFlags.Public) == p.IsPublic)
- ).ToArray ();
- }
-
- public static bool ImplementInterface (this Type t, string name)
- {
- return t.GetTypeInfo ().ImplementedInterfaces.Any (i => i.Name == name);
- }
-
-#endif
- }
-
- static class StringExtensions
- {
- public static IEnumerable SplitWithEscape (this string input, char separator, char escapeCharacter)
- {
- int start = 0;
- int index = 0;
- while (index < input.Length) {
- index = input.IndexOf (separator, index);
- if (index == -1)
- break;
-
- if (input [index - 1] == escapeCharacter) {
- input = input.Remove (index - 1, 1);
- continue;
- }
-
-
- yield return input.Substring (start, index - start);
- index++;
- start = index;
- }
- yield return input.Substring (start);
- }
- }
-}
\ No newline at end of file
diff --git a/Core/NLua/GenerateEventAssembly/ClassGenerator.cs b/Core/NLua/GenerateEventAssembly/ClassGenerator.cs
deleted file mode 100644
index 291e302a4ba69104622ba8645f6a6dafa13888a8..0000000000000000000000000000000000000000
--- a/Core/NLua/GenerateEventAssembly/ClassGenerator.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * This file is part of NLua.
- *
- * Copyright (c) 2015 Vinicius Jarina (viniciusjarina@gmail.com)
- * Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
- * Copyright (C) 2012 Megax
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-using System;
-
-namespace NLua
-{
- #if USE_KOPILUA
- using LuaCore = KopiLua.Lua;
- using LuaState = KopiLua.LuaState;
- #else
- using LuaCore = KeraLua.Lua;
- using LuaState = KeraLua.LuaState;
- #endif
- /*
- * Class used for generating delegates that get a table from the Lua
- * stack as a an object of a specific type.
- *
- * Author: Fabio Mascarenhas
- * Version: 1.0
- */
- class ClassGenerator
- {
- private ObjectTranslator translator;
- private Type klass;
-
- public ClassGenerator (ObjectTranslator objTranslator, Type typeClass)
- {
- translator = objTranslator;
- klass = typeClass;
- }
-
- public object ExtractGenerated (LuaState luaState, int stackPos)
- {
- return CodeGeneration.Instance.GetClassInstance (klass, translator.GetTable (luaState, stackPos));
- }
- }
-}
\ No newline at end of file
diff --git a/Core/NLua/GenerateEventAssembly/CodeGeneration.cs b/Core/NLua/GenerateEventAssembly/CodeGeneration.cs
deleted file mode 100755
index fa6aa460db3d8459dbcc6d3402218489ed315da9..0000000000000000000000000000000000000000
--- a/Core/NLua/GenerateEventAssembly/CodeGeneration.cs
+++ /dev/null
@@ -1,749 +0,0 @@
-/*
- * This file is part of NLua.
- *
- * Copyright (c) 2015 Vinicius Jarina (viniciusjarina@gmail.com)
- * Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
- * Copyright (C) 2012 Megax
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-using System;
-using System.Linq;
-using System.Threading;
-using System.Reflection;
-
-using NLua.Extensions;
-
-
-#if !MONOTOUCH
-using System.Reflection.Emit;
-#endif
-using System.Collections;
-using System.Collections.Generic;
-using NLua.Method;
-
-namespace NLua
-{
- /*
- * Dynamically generates new types from existing types and
- * Lua function and table values. Generated types are event handlers,
- * delegates, interface implementations and subclasses.
- *
- * Author: Fabio Mascarenhas
- * Version: 1.0
- */
- class CodeGeneration
- {
- private Dictionary classCollection = new Dictionary ();
- private Dictionary delegateCollection = new Dictionary ();
- private static readonly CodeGeneration instance = new CodeGeneration ();
- private AssemblyName assemblyName;
-
-#if !MONOTOUCH && !SILVERLIGHT && !NETFX_CORE
- private Dictionary eventHandlerCollection = new Dictionary ();
- private Type eventHandlerParent = typeof(LuaEventHandler);
- private Type delegateParent = typeof(LuaDelegate);
- private Type classHelper = typeof(LuaClassHelper);
- private AssemblyBuilder newAssembly;
- private ModuleBuilder newModule;
- private int luaClassNumber = 1;
-#endif
-
- static CodeGeneration ()
- {
- }
-
- private CodeGeneration ()
- {
- // Create an assembly name
- assemblyName = new AssemblyName ();
- assemblyName.Name = "NLua_generatedcode";
- // Create a new assembly with one module.
-#if !MONOTOUCH && !SILVERLIGHT && !NETFX_CORE
- newAssembly = Thread.GetDomain ().DefineDynamicAssembly (assemblyName, AssemblyBuilderAccess.Run);
- newModule = newAssembly.DefineDynamicModule ("NLua_generatedcode");
-#endif
- }
-
- /*
- * Singleton instance of the class
- */
- public static CodeGeneration Instance {
- get { return instance; }
- }
-
- /*
- * Generates an event handler that calls a Lua function
- */
- private Type GenerateEvent (Type eventHandlerType)
- {
-#if MONOTOUCH
- throw new NotImplementedException (" Emit not available on MonoTouch ");
-#elif SILVERLIGHT
- throw new NotImplementedException(" Emit not available on Silverlight ");
-#elif NETFX_CORE
- throw new NotImplementedException(" Emit not available on Windows Store ");
-#else
- string typeName;
- lock (this) {
- typeName = "LuaGeneratedClass" + luaClassNumber.ToString ();
- luaClassNumber++;
- }
-
- // Define a public class in the assembly, called typeName
- var myType = newModule.DefineType (typeName, TypeAttributes.Public, eventHandlerParent);
-
- // Defines the handler method. Its signature is void(object, )
- var paramTypes = new Type[2];
- paramTypes [0] = typeof(object);
- paramTypes [1] = eventHandlerType;
- var returnType = typeof(void);
- var handleMethod = myType.DefineMethod ("HandleEvent", MethodAttributes.Public | MethodAttributes.HideBySig, returnType, paramTypes);
-
- // Emits the IL for the method. It loads the arguments
- // and calls the handleEvent method of the base class
- ILGenerator generator = handleMethod.GetILGenerator ();
- generator.Emit (OpCodes.Ldarg_0);
- generator.Emit (OpCodes.Ldarg_1);
- generator.Emit (OpCodes.Ldarg_2);
- var miGenericEventHandler = eventHandlerParent.GetMethod ("HandleEvent");
- generator.Emit (OpCodes.Call, miGenericEventHandler);
- // returns
- generator.Emit (OpCodes.Ret);
- // creates the new type
- return myType.CreateType ();
-#endif
- }
-
- /*
- * Generates a type that can be used for instantiating a delegate
- * of the provided type, given a Lua function.
- */
- private Type GenerateDelegate (Type delegateType)
- {
-#if MONOTOUCH
- throw new NotImplementedException ("GenerateDelegate is not available on iOS, please register your LuaDelegate type with Lua.RegisterLuaDelegateType( yourDelegate, theLuaDelegateHandler) ");
-#elif SILVERLIGHT
- throw new NotImplementedException("GenerateDelegate is not available on Silverlight, please register your LuaDelegate type with Lua.RegisterLuaDelegateType( yourDelegate, theLuaDelegateHandler) ");
-#elif NETFX_CORE
- throw new NotImplementedException("GenerateDelegate is not available on Windows Store, please register your LuaDelegate type with Lua.RegisterLuaDelegateType( yourDelegate, theLuaDelegateHandler) ");
-#else
- string typeName;
- lock (this) {
- typeName = "LuaGeneratedClass" + luaClassNumber.ToString ();
- luaClassNumber++;
- }
-
- // Define a public class in the assembly, called typeName
- var myType = newModule.DefineType (typeName, TypeAttributes.Public, delegateParent);
-
- // Defines the delegate method with the same signature as the
- // Invoke method of delegateType
- var invokeMethod = delegateType.GetMethod ("Invoke");
- var paramInfo = invokeMethod.GetParameters ();
- var paramTypes = new Type[paramInfo.Length];
- var returnType = invokeMethod.ReturnType;
-
- // Counts out and ref params, for use later
- int nOutParams = 0;
- int nOutAndRefParams = 0;
-
- for (int i = 0; i < paramTypes.Length; i++) {
- paramTypes [i] = paramInfo [i].ParameterType;
-
- if ((!paramInfo [i].IsIn) && paramInfo [i].IsOut)
- nOutParams++;
-
- if (paramTypes [i].IsByRef)
- nOutAndRefParams++;
- }
-
- int[] refArgs = new int[nOutAndRefParams];
- var delegateMethod = myType.DefineMethod ("CallFunction", invokeMethod.Attributes, returnType, paramTypes);
-
- // Generates the IL for the method
- ILGenerator generator = delegateMethod.GetILGenerator ();
- generator.DeclareLocal (typeof(object[])); // original arguments
- generator.DeclareLocal (typeof(object[])); // with out-only arguments removed
- generator.DeclareLocal (typeof(int[])); // indexes of out and ref arguments
-
- if (!(returnType == typeof(void))) // return value
- generator.DeclareLocal (returnType);
- else
- generator.DeclareLocal (typeof(object));
-
- // Initializes local variables
- generator.Emit (OpCodes.Ldc_I4, paramTypes.Length);
- generator.Emit (OpCodes.Newarr, typeof(object));
- generator.Emit (OpCodes.Stloc_0);
- generator.Emit (OpCodes.Ldc_I4, paramTypes.Length - nOutParams);
- generator.Emit (OpCodes.Newarr, typeof(object));
- generator.Emit (OpCodes.Stloc_1);
- generator.Emit (OpCodes.Ldc_I4, nOutAndRefParams);
- generator.Emit (OpCodes.Newarr, typeof(int));
- generator.Emit (OpCodes.Stloc_2);
-
- // Stores the arguments in the local variables
- for (int iArgs = 0, iInArgs = 0, iOutArgs = 0; iArgs < paramTypes.Length; iArgs++) {
- generator.Emit (OpCodes.Ldloc_0);
- generator.Emit (OpCodes.Ldc_I4, iArgs);
- generator.Emit (OpCodes.Ldarg, iArgs + 1);
-
- if (paramTypes [iArgs].IsByRef) {
- if (paramTypes [iArgs].GetElementType ().IsValueType) {
- generator.Emit (OpCodes.Ldobj, paramTypes [iArgs].GetElementType ());
- generator.Emit (OpCodes.Box, paramTypes [iArgs].GetElementType ());
- } else
- generator.Emit (OpCodes.Ldind_Ref);
- } else {
- if (paramTypes [iArgs].IsValueType)
- generator.Emit (OpCodes.Box, paramTypes [iArgs]);
- }
-
- generator.Emit (OpCodes.Stelem_Ref);
-
- if (paramTypes [iArgs].IsByRef) {
- generator.Emit (OpCodes.Ldloc_2);
- generator.Emit (OpCodes.Ldc_I4, iOutArgs);
- generator.Emit (OpCodes.Ldc_I4, iArgs);
- generator.Emit (OpCodes.Stelem_I4);
- refArgs [iOutArgs] = iArgs;
- iOutArgs++;
- }
-
- if (paramInfo [iArgs].IsIn || (!paramInfo [iArgs].IsOut)) {
- generator.Emit (OpCodes.Ldloc_1);
- generator.Emit (OpCodes.Ldc_I4, iInArgs);
- generator.Emit (OpCodes.Ldarg, iArgs + 1);
-
- if (paramTypes [iArgs].IsByRef) {
- if (paramTypes [iArgs].GetElementType ().IsValueType) {
- generator.Emit (OpCodes.Ldobj, paramTypes [iArgs].GetElementType ());
- generator.Emit (OpCodes.Box, paramTypes [iArgs].GetElementType ());
- } else
- generator.Emit (OpCodes.Ldind_Ref);
- } else {
- if (paramTypes [iArgs].IsValueType)
- generator.Emit (OpCodes.Box, paramTypes [iArgs]);
- }
-
- generator.Emit (OpCodes.Stelem_Ref);
- iInArgs++;
- }
- }
-
- // Calls the callFunction method of the base class
- generator.Emit (OpCodes.Ldarg_0);
- generator.Emit (OpCodes.Ldloc_0);
- generator.Emit (OpCodes.Ldloc_1);
- generator.Emit (OpCodes.Ldloc_2);
- var miGenericEventHandler = delegateParent.GetMethod ("CallFunction");
- generator.Emit (OpCodes.Call, miGenericEventHandler);
-
- // Stores return value
- if (returnType == typeof(void)) {
- generator.Emit (OpCodes.Pop);
- generator.Emit (OpCodes.Ldnull);
- } else if (returnType.IsValueType) {
- generator.Emit (OpCodes.Unbox, returnType);
- generator.Emit (OpCodes.Ldobj, returnType);
- } else
- generator.Emit (OpCodes.Castclass, returnType);
-
- generator.Emit (OpCodes.Stloc_3);
-
- // Stores new value of out and ref params
- for (int i = 0; i < refArgs.Length; i++) {
- generator.Emit (OpCodes.Ldarg, refArgs [i] + 1);
- generator.Emit (OpCodes.Ldloc_0);
- generator.Emit (OpCodes.Ldc_I4, refArgs [i]);
- generator.Emit (OpCodes.Ldelem_Ref);
-
- if (paramTypes [refArgs [i]].GetElementType ().IsValueType) {
- generator.Emit (OpCodes.Unbox, paramTypes [refArgs [i]].GetElementType ());
- generator.Emit (OpCodes.Ldobj, paramTypes [refArgs [i]].GetElementType ());
- generator.Emit (OpCodes.Stobj, paramTypes [refArgs [i]].GetElementType ());
- } else {
- generator.Emit (OpCodes.Castclass, paramTypes [refArgs [i]].GetElementType ());
- generator.Emit (OpCodes.Stind_Ref);
- }
- }
-
- // Returns
- if (!(returnType == typeof(void)))
- generator.Emit (OpCodes.Ldloc_3);
-
- generator.Emit (OpCodes.Ret);
- return myType.CreateType (); // creates the new type
-#endif
- }
-
- void GetReturnTypesFromClass (Type klass, out Type[][] returnTypes)
- {
- var classMethods = klass.GetMethods ();
- returnTypes = new Type[classMethods.Length][];
-
- int i = 0;
-
- foreach (var method in classMethods) {
- if (klass.IsInterface ()) {
- GetReturnTypesFromMethod (method, out returnTypes [i]);
- i++;
- } else {
- if (!method.IsPrivate && !method.IsFinal && method.IsVirtual) {
- GetReturnTypesFromMethod (method, out returnTypes [i]);
- i++;
- }
- }
- }
- }
-
- /*
- * Generates an implementation of klass, if it is an interface, or
- * a subclass of klass that delegates its virtual methods to a Lua table.
- */
- public void GenerateClass (Type klass, out Type newType, out Type[][] returnTypes)
- {
-#if MONOTOUCH
- throw new NotImplementedException (" Emit not available on MonoTouch ");
-#elif SILVERLIGHT
- throw new NotImplementedException (" Emit not available on Silverlight ");
-#elif NETFX_CORE
- throw new NotImplementedException (" Emit not available on Windows Store ");
-#else
- string typeName;
- lock (this) {
- typeName = "LuaGeneratedClass" + luaClassNumber.ToString ();
- luaClassNumber++;
- }
-
- TypeBuilder myType;
- // Define a public class in the assembly, called typeName
- if (klass.IsInterface)
- myType = newModule.DefineType (typeName, TypeAttributes.Public, typeof(object), new Type[] {
- klass,
- typeof(ILuaGeneratedType)
- });
- else
- myType = newModule.DefineType (typeName, TypeAttributes.Public, klass, new Type[] { typeof(ILuaGeneratedType) });
-
- // Field that stores the Lua table
- var luaTableField = myType.DefineField ("__luaInterface_luaTable", typeof(LuaTable), FieldAttributes.Public);
- // Field that stores the return types array
- var returnTypesField = myType.DefineField ("__luaInterface_returnTypes", typeof(Type[][]), FieldAttributes.Public);
- // Generates the constructor for the new type, it takes a Lua table and an array
- // of return types and stores them in the respective fields
- var constructor = myType.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, new Type[] {
- typeof(LuaTable),
- typeof(Type[][])
- });
- ILGenerator generator = constructor.GetILGenerator ();
- generator.Emit (OpCodes.Ldarg_0);
-
- if (klass.IsInterface)
- generator.Emit (OpCodes.Call, typeof(object).GetConstructor (Type.EmptyTypes));
- else
- generator.Emit (OpCodes.Call, klass.GetConstructor (Type.EmptyTypes));
-
- generator.Emit (OpCodes.Ldarg_0);
- generator.Emit (OpCodes.Ldarg_1);
- generator.Emit (OpCodes.Stfld, luaTableField);
- generator.Emit (OpCodes.Ldarg_0);
- generator.Emit (OpCodes.Ldarg_2);
- generator.Emit (OpCodes.Stfld, returnTypesField);
- generator.Emit (OpCodes.Ret);
- // Generates overriden versions of the klass' public virtual methods
- var classMethods = klass.GetMethods ();
- returnTypes = new Type[classMethods.Length][];
- int i = 0;
-
- foreach (var method in classMethods) {
- if (klass.IsInterface) {
- GenerateMethod (myType, method, MethodAttributes.HideBySig | MethodAttributes.Virtual | MethodAttributes.NewSlot,
- i, luaTableField, returnTypesField, false, out returnTypes [i]);
- i++;
- } else {
- if (!method.IsPrivate && !method.IsFinal && method.IsVirtual) {
- GenerateMethod (myType, method, (method.Attributes | MethodAttributes.NewSlot) ^ MethodAttributes.NewSlot, i,
- luaTableField, returnTypesField, true, out returnTypes [i]);
- i++;
- }
- }
- }
-
- // Generates an implementation of the luaInterfaceGetLuaTable method
- var returnTableMethod = myType.DefineMethod ("LuaInterfaceGetLuaTable",
- MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Virtual, typeof(LuaTable), new Type[0]);
- myType.DefineMethodOverride (returnTableMethod, typeof(ILuaGeneratedType).GetMethod ("LuaInterfaceGetLuaTable"));
- generator = returnTableMethod.GetILGenerator ();
- generator.Emit (OpCodes.Ldfld, luaTableField);
- generator.Emit (OpCodes.Ret);
- newType = myType.CreateType (); // Creates the type
-#endif
- }
-
- void GetReturnTypesFromMethod (MethodInfo method, out Type[] returnTypes)
- {
- var paramInfo = method.GetParameters ();
- var paramTypes = new Type[paramInfo.Length];
- var returnTypesList = new List ();
-
- // Counts out and ref parameters, for later use,
- // and creates the list of return types
- int nOutParams = 0;
- int nOutAndRefParams = 0;
- var returnType = method.ReturnType;
- returnTypesList.Add (returnType);
-
- for (int i = 0; i < paramTypes.Length; i++) {
- paramTypes [i] = paramInfo [i].ParameterType;
-#if SILVERLIGHT
- if (paramInfo[i].IsOut) {
-#else
- if ((!paramInfo [i].IsIn) && paramInfo [i].IsOut) {
-#endif
- nOutParams++;
- }
-
- if (paramTypes [i].IsByRef) {
- returnTypesList.Add (paramTypes [i].GetElementType ());
- nOutAndRefParams++;
- }
- }
-
- returnTypes = returnTypesList.ToArray ();
- }
-
-#if !MONOTOUCH && !SILVERLIGHT && !NETFX_CORE
-
- /*
- * Generates an overriden implementation of method inside myType that delegates
- * to a function in a Lua table with the same name, if the function exists. If it
- * doesn't the method calls the base method (or does nothing, in case of interface
- * implementations).
- */
- private void GenerateMethod (TypeBuilder myType, MethodInfo method, MethodAttributes attributes, int methodIndex,
- FieldInfo luaTableField, FieldInfo returnTypesField, bool generateBase, out Type[] returnTypes)
- {
- var paramInfo = method.GetParameters ();
- var paramTypes = new Type[paramInfo.Length];
- var returnTypesList = new List ();
-
- // Counts out and ref parameters, for later use,
- // and creates the list of return types
- int nOutParams = 0;
- int nOutAndRefParams = 0;
- var returnType = method.ReturnType;
- returnTypesList.Add (returnType);
-
- for (int i = 0; i < paramTypes.Length; i++) {
- paramTypes [i] = paramInfo [i].ParameterType;
- if ((!paramInfo [i].IsIn) && paramInfo [i].IsOut)
- nOutParams++;
-
- if (paramTypes [i].IsByRef) {
- returnTypesList.Add (paramTypes [i].GetElementType ());
- nOutAndRefParams++;
- }
- }
-
- int[] refArgs = new int[nOutAndRefParams];
- returnTypes = returnTypesList.ToArray ();
-
- // Generates a version of the method that calls the base implementation
- // directly, for use by the base field of the table
- if (generateBase) {
- var baseMethod = myType.DefineMethod ("__luaInterface_base_" + method.Name,
- MethodAttributes.Private | MethodAttributes.NewSlot | MethodAttributes.HideBySig,
- returnType, paramTypes);
- ILGenerator generatorBase = baseMethod.GetILGenerator ();
- generatorBase.Emit (OpCodes.Ldarg_0);
-
- for (int i = 0; i < paramTypes.Length; i++)
- generatorBase.Emit (OpCodes.Ldarg, i + 1);
-
- generatorBase.Emit (OpCodes.Call, method);
-
- if (returnType == typeof(void))
- generatorBase.Emit (OpCodes.Pop);
-
- generatorBase.Emit (OpCodes.Ret);
- }
-
- // Defines the method
- var methodImpl = myType.DefineMethod (method.Name, attributes, returnType, paramTypes);
-
- // If it's an implementation of an interface tells what method it
- // is overriding
- if (myType.BaseType.Equals (typeof(object)))
- myType.DefineMethodOverride (methodImpl, method);
-
- ILGenerator generator = methodImpl.GetILGenerator ();
- generator.DeclareLocal (typeof(object[])); // original arguments
- generator.DeclareLocal (typeof(object[])); // with out-only arguments removed
- generator.DeclareLocal (typeof(int[])); // indexes of out and ref arguments
-
- if (!(returnType == typeof(void))) // return value
- generator.DeclareLocal (returnType);
- else
- generator.DeclareLocal (typeof(object));
-
- // Initializes local variables
- generator.Emit (OpCodes.Ldc_I4, paramTypes.Length);
- generator.Emit (OpCodes.Newarr, typeof(object));
- generator.Emit (OpCodes.Stloc_0);
- generator.Emit (OpCodes.Ldc_I4, paramTypes.Length - nOutParams + 1);
- generator.Emit (OpCodes.Newarr, typeof(object));
- generator.Emit (OpCodes.Stloc_1);
- generator.Emit (OpCodes.Ldc_I4, nOutAndRefParams);
- generator.Emit (OpCodes.Newarr, typeof(int));
- generator.Emit (OpCodes.Stloc_2);
- generator.Emit (OpCodes.Ldloc_1);
- generator.Emit (OpCodes.Ldc_I4_0);
- generator.Emit (OpCodes.Ldarg_0);
- generator.Emit (OpCodes.Ldfld, luaTableField);
- generator.Emit (OpCodes.Stelem_Ref);
-
- // Stores the arguments into the local variables, as needed
- for (int iArgs = 0, iInArgs = 1, iOutArgs = 0; iArgs < paramTypes.Length; iArgs++) {
- generator.Emit (OpCodes.Ldloc_0);
- generator.Emit (OpCodes.Ldc_I4, iArgs);
- generator.Emit (OpCodes.Ldarg, iArgs + 1);
-
- if (paramTypes [iArgs].IsByRef) {
- if (paramTypes [iArgs].GetElementType ().IsValueType) {
- generator.Emit (OpCodes.Ldobj, paramTypes [iArgs].GetElementType ());
- generator.Emit (OpCodes.Box, paramTypes [iArgs].GetElementType ());
- } else
- generator.Emit (OpCodes.Ldind_Ref);
- } else {
- if (paramTypes [iArgs].IsValueType)
- generator.Emit (OpCodes.Box, paramTypes [iArgs]);
- }
-
- generator.Emit (OpCodes.Stelem_Ref);
-
- if (paramTypes [iArgs].IsByRef) {
- generator.Emit (OpCodes.Ldloc_2);
- generator.Emit (OpCodes.Ldc_I4, iOutArgs);
- generator.Emit (OpCodes.Ldc_I4, iArgs);
- generator.Emit (OpCodes.Stelem_I4);
- refArgs [iOutArgs] = iArgs;
- iOutArgs++;
- }
-
- if (paramInfo [iArgs].IsIn || (!paramInfo [iArgs].IsOut)) {
- generator.Emit (OpCodes.Ldloc_1);
- generator.Emit (OpCodes.Ldc_I4, iInArgs);
- generator.Emit (OpCodes.Ldarg, iArgs + 1);
-
- if (paramTypes [iArgs].IsByRef) {
- if (paramTypes [iArgs].GetElementType ().IsValueType) {
- generator.Emit (OpCodes.Ldobj, paramTypes [iArgs].GetElementType ());
- generator.Emit (OpCodes.Box, paramTypes [iArgs].GetElementType ());
- } else
- generator.Emit (OpCodes.Ldind_Ref);
- } else {
- if (paramTypes [iArgs].IsValueType)
- generator.Emit (OpCodes.Box, paramTypes [iArgs]);
- }
-
- generator.Emit (OpCodes.Stelem_Ref);
- iInArgs++;
- }
- }
-
- // Gets the function the method will delegate to by calling
- // the getTableFunction method of class LuaClassHelper
- generator.Emit (OpCodes.Ldarg_0);
- generator.Emit (OpCodes.Ldfld, luaTableField);
- generator.Emit (OpCodes.Ldstr, method.Name);
- generator.Emit (OpCodes.Call, classHelper.GetMethod ("GetTableFunction"));
- var lab1 = generator.DefineLabel ();
- generator.Emit (OpCodes.Dup);
- generator.Emit (OpCodes.Brtrue_S, lab1);
- // Function does not exist, call base method
- generator.Emit (OpCodes.Pop);
-
- if (!method.IsAbstract) {
- generator.Emit (OpCodes.Ldarg_0);
-
- for (int i = 0; i < paramTypes.Length; i++)
- generator.Emit (OpCodes.Ldarg, i + 1);
-
- generator.Emit (OpCodes.Call, method);
-
- if (returnType == typeof(void))
- generator.Emit (OpCodes.Pop);
-
- generator.Emit (OpCodes.Ret);
- generator.Emit (OpCodes.Ldnull);
- } else
- generator.Emit (OpCodes.Ldnull);
-
- var lab2 = generator.DefineLabel ();
- generator.Emit (OpCodes.Br_S, lab2);
- generator.MarkLabel (lab1);
- // Function exists, call using method callFunction of LuaClassHelper
- generator.Emit (OpCodes.Ldloc_0);
- generator.Emit (OpCodes.Ldarg_0);
- generator.Emit (OpCodes.Ldfld, returnTypesField);
- generator.Emit (OpCodes.Ldc_I4, methodIndex);
- generator.Emit (OpCodes.Ldelem_Ref);
- generator.Emit (OpCodes.Ldloc_1);
- generator.Emit (OpCodes.Ldloc_2);
- generator.Emit (OpCodes.Call, classHelper.GetMethod ("CallFunction"));
- generator.MarkLabel (lab2);
-
- // Stores the function return value
- if (returnType == typeof(void)) {
- generator.Emit (OpCodes.Pop);
- generator.Emit (OpCodes.Ldnull);
- } else if (returnType.IsValueType) {
- generator.Emit (OpCodes.Unbox, returnType);
- generator.Emit (OpCodes.Ldobj, returnType);
- } else
- generator.Emit (OpCodes.Castclass, returnType);
-
- generator.Emit (OpCodes.Stloc_3);
-
- // Sets return values of out and ref parameters
- for (int i = 0; i < refArgs.Length; i++) {
- generator.Emit (OpCodes.Ldarg, refArgs [i] + 1);
- generator.Emit (OpCodes.Ldloc_0);
- generator.Emit (OpCodes.Ldc_I4, refArgs [i]);
- generator.Emit (OpCodes.Ldelem_Ref);
-
- if (paramTypes [refArgs [i]].GetElementType ().IsValueType) {
- generator.Emit (OpCodes.Unbox, paramTypes [refArgs [i]].GetElementType ());
- generator.Emit (OpCodes.Ldobj, paramTypes [refArgs [i]].GetElementType ());
- generator.Emit (OpCodes.Stobj, paramTypes [refArgs [i]].GetElementType ());
- } else {
- generator.Emit (OpCodes.Castclass, paramTypes [refArgs [i]].GetElementType ());
- generator.Emit (OpCodes.Stind_Ref);
- }
- }
-
- // Returns
- if (!(returnType == typeof(void)))
- generator.Emit (OpCodes.Ldloc_3);
-
- generator.Emit (OpCodes.Ret);
- }
-#endif
- /*
- * Gets an event handler for the event type that delegates to the eventHandler Lua function.
- * Caches the generated type.
- */
- public LuaEventHandler GetEvent (Type eventHandlerType, LuaFunction eventHandler)
- {
-#if MONOTOUCH
- throw new NotImplementedException (" Emit not available on MonoTouch ");
-#elif SILVERLIGHT
- throw new NotImplementedException (" Emit not available on Silverlight ");
-#elif NETFX_CORE
- throw new NotImplementedException (" Emit not available on Windows Store ");
-#else
- Type eventConsumerType;
-
- if (eventHandlerCollection.ContainsKey (eventHandlerType))
- eventConsumerType = eventHandlerCollection [eventHandlerType];
- else {
- eventConsumerType = GenerateEvent (eventHandlerType);
- eventHandlerCollection [eventHandlerType] = eventConsumerType;
- }
-
- var luaEventHandler = (LuaEventHandler)Activator.CreateInstance (eventConsumerType);
- luaEventHandler.handler = eventHandler;
- return luaEventHandler;
-#endif
- }
-
- public void RegisterLuaDelegateType (Type delegateType, Type luaDelegateType)
- {
- delegateCollection [delegateType] = luaDelegateType;
- }
-
- public void RegisterLuaClassType (Type klass, Type luaClass)
- {
- LuaClassType luaClassType = new LuaClassType ();
- luaClassType.klass = luaClass;
- GetReturnTypesFromClass (klass, out luaClassType.returnTypes);
- classCollection [klass] = luaClassType;
- }
- /*
- * Gets a delegate with delegateType that calls the luaFunc Lua function
- * Caches the generated type.
- */
- public Delegate GetDelegate (Type delegateType, LuaFunction luaFunc)
- {
- var returnTypes = new List ();
- Type luaDelegateType;
-
- if (delegateCollection.ContainsKey (delegateType))
- luaDelegateType = delegateCollection [delegateType];
- else {
- luaDelegateType = GenerateDelegate (delegateType);
- delegateCollection [delegateType] = luaDelegateType;
- }
-
- var methodInfo = delegateType.GetMethod ("Invoke");
- returnTypes.Add (methodInfo.ReturnType);
-
- foreach (ParameterInfo paramInfo in methodInfo.GetParameters()) {
- if (paramInfo.ParameterType.IsByRef)
- returnTypes.Add (paramInfo.ParameterType);
- }
-
- var luaDelegate = (LuaDelegate)Activator.CreateInstance (luaDelegateType);
- luaDelegate.function = luaFunc;
- luaDelegate.returnTypes = returnTypes.ToArray ();
-#if NETFX_CORE
- var mi = luaDelegate.GetType ().GetTypeInfo ().GetDeclaredMethod ("CallFunction");
- return mi.CreateDelegate (delegateType, luaDelegate);
-#else
- return Delegate.CreateDelegate (delegateType, luaDelegate, "CallFunction");
-#endif
- }
-
- /*
- * Gets an instance of an implementation of the klass interface or
- * subclass of klass that delegates public virtual methods to the
- * luaTable table.
- * Caches the generated type.
- */
- public object GetClassInstance (Type klass, LuaTable luaTable)
- {
- LuaClassType luaClassType;
-
- if (classCollection.ContainsKey (klass))
- luaClassType = classCollection [klass];
- else {
- luaClassType = new LuaClassType ();
- GenerateClass (klass, out luaClassType.klass, out luaClassType.returnTypes);
- classCollection [klass] = luaClassType;
- }
-
- return Activator.CreateInstance (luaClassType.klass, new object[] {
- luaTable,
- luaClassType.returnTypes
- });
- }
- }
-}
\ No newline at end of file
diff --git a/Core/NLua/GenerateEventAssembly/DelegateGenerator.cs b/Core/NLua/GenerateEventAssembly/DelegateGenerator.cs
deleted file mode 100644
index b944d96f2fc019d1142f0c5cf3dac1d894b90c74..0000000000000000000000000000000000000000
--- a/Core/NLua/GenerateEventAssembly/DelegateGenerator.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * This file is part of NLua.
- *
- * Copyright (c) 2015 Vinicius Jarina (viniciusjarina@gmail.com)
- * Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
- * Copyright (C) 2012 Megax
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-using System;
-
-namespace NLua
-{
- #if USE_KOPILUA
- using LuaCore = KopiLua.Lua;
- using LuaState = KopiLua.LuaState;
- #else
- using LuaCore = KeraLua.Lua;
- using LuaState = KeraLua.LuaState;
- #endif
- /*
- * Class used for generating delegates that get a function from the Lua
- * stack as a delegate of a specific type.
- *
- * Author: Fabio Mascarenhas
- * Version: 1.0
- */
- class DelegateGenerator
- {
- private ObjectTranslator translator;
- private Type delegateType;
-
-
- public DelegateGenerator (ObjectTranslator objectTranslator, Type type)
- {
- translator = objectTranslator;
- delegateType = type;
- }
-
- public object ExtractGenerated (LuaState luaState, int stackPos)
- {
- return CodeGeneration.Instance.GetDelegate (delegateType, translator.GetFunction (luaState, stackPos));
- }
- }
-}
\ No newline at end of file
diff --git a/Core/NLua/GenerateEventAssembly/ILuaGeneratedType.cs b/Core/NLua/GenerateEventAssembly/ILuaGeneratedType.cs
deleted file mode 100644
index 543d273d1a8f8f7286743c030b2b9101298212fd..0000000000000000000000000000000000000000
--- a/Core/NLua/GenerateEventAssembly/ILuaGeneratedType.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * This file is part of NLua.
- *
- * Copyright (c) 2015 Vinicius Jarina (viniciusjarina@gmail.com)
- * Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
- * Copyright (C) 2012 Megax
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-using System;
-
-namespace NLua
-{
- /*
- * Common interface for types generated from tables. The method
- * returns the table that overrides some or all of the type's methods.
- */
- public interface ILuaGeneratedType
- {
- LuaTable LuaInterfaceGetLuaTable ();
- }
-}
\ No newline at end of file
diff --git a/Core/NLua/GenerateEventAssembly/LuaClassType.cs b/Core/NLua/GenerateEventAssembly/LuaClassType.cs
deleted file mode 100644
index d40b523702515020976387dd8519b657e00a5f9c..0000000000000000000000000000000000000000
--- a/Core/NLua/GenerateEventAssembly/LuaClassType.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * This file is part of NLua.
- *
- * Copyright (c) 2015 Vinicius Jarina (viniciusjarina@gmail.com)
- * Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
- * Copyright (C) 2012 Megax
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-using System;
-
-namespace NLua
-{
- /*
- * Structure to store a type and the return types of
- * its methods (the type of the returned value and out/ref
- * parameters).
- */
- struct LuaClassType
- {
- public Type klass;
- public Type[][] returnTypes;
- }
-}
\ No newline at end of file
diff --git a/Core/NLua/Lua.cs b/Core/NLua/Lua.cs
deleted file mode 100644
index 6193dce1082f8d9dd5473aaf452f98bf68b0973c..0000000000000000000000000000000000000000
--- a/Core/NLua/Lua.cs
+++ /dev/null
@@ -1,1216 +0,0 @@
-/*
- * This file is part of NLua.
- *
- * Copyright (c) 2014 Vinicius Jarina (viniciusjarina@gmail.com)
- * Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
- * Copyright (C) 2012 Megax
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-using System;
-using System.IO;
-using System.Linq;
-using System.Threading;
-using System.Reflection;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using NLua.Event;
-using NLua.Method;
-using NLua.Exceptions;
-using NLua.Extensions;
-
-#if MONOTOUCH
- using ObjCRuntime;
-#endif
-
-namespace NLua
-{
- #if USE_KOPILUA
- using LuaCore = KopiLua.Lua;
- using LuaState = KopiLua.LuaState;
- using LuaHook = KopiLua.LuaHook;
- using LuaDebug = KopiLua.LuaDebug;
- using LuaNativeFunction = KopiLua.LuaNativeFunction;
- #else
- using LuaCore = KeraLua.Lua;
- using LuaState = KeraLua.LuaState;
- using LuaHook = KeraLua.LuaHook;
- using LuaDebug = KeraLua.LuaDebug;
- using LuaNativeFunction = KeraLua.LuaNativeFunction;
- #endif
-
- /*
- * Main class of NLua
- * Object-oriented wrapper to Lua API
- *
- * Author: Fabio Mascarenhas
- * Version: 1.0
- *
- * // steffenj: important changes in Lua class:
- * - removed all Open*Lib() functions
- * - all libs automatically open in the Lua class constructor (just assign nil to unwanted libs)
- * */
- [CLSCompliant(true)]
- public class Lua : IDisposable
- {
- #region lua debug functions
- ///
- /// Event that is raised when an exception occures during a hook call.
- ///
- public event EventHandler HookException;
- ///
- /// Event when lua hook callback is called
- ///
- ///
- /// Is only raised if SetDebugHook is called before.
- ///
- public event EventHandler DebugHook;
- ///
- /// lua hook calback delegate
- ///
- private LuaHook hookCallback = null;
- #endregion
- #region Globals auto-complete
- private readonly List globals = new List ();
- private bool globalsSorted;
- #endregion
- private LuaState luaState;
- ///
- /// True while a script is being executed
- ///
- public bool IsExecuting { get { return executing; } }
-
- private LuaNativeFunction panicCallback;
- private ObjectTranslator translator;
- ///
- /// Used to protect the (global) object translator pool during add/remove
- ///
- private static readonly object translatorPoolLock = new object();
-
- ///
- /// Used to ensure multiple .net threads all get serialized by this single lock for access to the lua stack/objects
- ///
- //private object luaLock = new object();
- private bool _StatePassed;
- private bool executing;
- static string initLuanet =
- @"local metatable = {}
- local rawget = rawget
- local import_type = luanet.import_type
- local load_assembly = luanet.load_assembly
- luanet.error, luanet.type = error, type
- -- Lookup a .NET identifier component.
- function metatable:__index(key) -- key is e.g. 'Form'
- -- Get the fully-qualified name, e.g. 'System.Windows.Forms.Form'
- local fqn = rawget(self,'.fqn')
- fqn = ((fqn and fqn .. '.') or '') .. key
-
- -- Try to find either a luanet function or a CLR type
- local obj = rawget(luanet,key) or import_type(fqn)
-
- -- If key is neither a luanet function or a CLR type, then it is simply
- -- an identifier component.
- if obj == nil then
- -- It might be an assembly, so we load it too.
- pcall(load_assembly,fqn)
- obj = { ['.fqn'] = fqn }
- setmetatable(obj, metatable)
- end
-
- -- Cache this lookup
- rawset(self, key, obj)
- return obj
- end
-
- -- A non-type has been called; e.g. foo = System.Foo()
- function metatable:__call(...)
- error('No such type: ' .. rawget(self,'.fqn'), 2)
- end
-
- -- This is the root of the .NET namespace
- luanet['.fqn'] = false
- setmetatable(luanet, metatable)
-
- -- Preload the mscorlib assembly
- luanet.load_assembly('mscorlib')";
-
- static string clr_package = @"---
---- This lua module provides auto importing of .net classes into a named package.
---- Makes for super easy use of LuaInterface glue
----
---- example:
---- Threading = CLRPackage(""System"", ""System.Threading"")
---- Threading.Thread.Sleep(100)
----
---- Extensions:
---- import() is a version of CLRPackage() which puts the package into a list which is used by a global __index lookup,
---- and thus works rather like C#'s using statement. It also recognizes the case where one is importing a local
---- assembly, which must end with an explicit .dll extension.
-
---- Alternatively, luanet.namespace can be used for convenience without polluting the global namespace:
---- local sys,sysi = luanet.namespace {'System','System.IO'}
--- sys.Console.WriteLine(""we are at {0}"",sysi.Directory.GetCurrentDirectory())
-
-
--- LuaInterface hosted with stock Lua interpreter will need to explicitly require this...
-if not luanet then require 'luanet' end
-
-local import_type, load_assembly = luanet.import_type, luanet.load_assembly
-
-local mt = {
- --- Lookup a previously unfound class and add it to our table
- __index = function(package, classname)
- local class = rawget(package, classname)
- if class == nil then
- class = import_type(package.packageName .. ""."" .. classname)
- if class == nil then class = import_type(classname) end
- package[classname] = class -- keep what we found around, so it will be shared
- end
- return class
- end
-}
-
-function luanet.namespace(ns)
- if type(ns) == 'table' then
- local res = {}
- for i = 1,#ns do
- res[i] = luanet.namespace(ns[i])
- end
- return unpack(res)
- end
- -- FIXME - table.packageName could instead be a private index (see Lua 13.4.4)
- local t = { packageName = ns }
- setmetatable(t,mt)
- return t
-end
-
-local globalMT, packages
-
-local function set_global_mt()
- packages = {}
- globalMT = {
- __index = function(T,classname)
- for i,package in ipairs(packages) do
- local class = package[classname]
- if class then
- _G[classname] = class
- return class
- end
- end
- end
- }
- setmetatable(_G, globalMT)
-end
-
---- Create a new Package class
-function CLRPackage(assemblyName, packageName)
- -- a sensible default...
- packageName = packageName or assemblyName
- local ok = pcall(load_assembly,assemblyName) -- Make sure our assembly is loaded
- return luanet.namespace(packageName)
-end
-
-function import (assemblyName, packageName)
- if not globalMT then
- set_global_mt()
- end
- if not packageName then
- local i = assemblyName:find('%.dll$')
- if i then packageName = assemblyName:sub(1,i-1)
- else packageName = assemblyName end
- end
- local t = CLRPackage(assemblyName,packageName)
- table.insert(packages,t)
- return t
-end
-
-
-function luanet.make_array (tp,tbl)
- local arr = tp[#tbl]
- for i,v in ipairs(tbl) do
- arr:SetValue(v,i-1)
- end
- return arr
-end
-
-function luanet.each(o)
- local e = o:GetEnumerator()
- return function()
- if e:MoveNext() then
- return e.Current
- end
- end
-end
-";
- public bool UseTraceback { get; set; } = false;
-
- #region Globals auto-complete
- ///
- /// An alphabetically sorted list of all globals (objects, methods, etc.) externally added to this Lua instance
- ///
- /// Members of globals are also listed. The formatting is optimized for text input auto-completion.
- public IEnumerable Globals {
- get {
- // Only sort list when necessary
- if (!globalsSorted) {
- globals.Sort ();
- globalsSorted = true;
- }
-
- return globals;
- }
- }
- #endregion
-
- public Lua ()
- {
- luaState = LuaLib.LuaLNewState ();
- LuaLib.LuaLOpenLibs (luaState);
- Init ();
- // We need to keep this in a managed reference so the delegate doesn't get garbage collected
- panicCallback = new LuaNativeFunction (PanicCallback);
- LuaLib.LuaAtPanic (luaState, panicCallback);
- }
-
- /*
- * CAUTION: NLua.Lua instances can't share the same lua state!
- */
- public Lua (LuaState lState)
- {
- LuaLib.LuaPushString (lState, "LUAINTERFACE LOADED");
- LuaLib.LuaGetTable (lState, (int)LuaIndexes.Registry);
-
- if (LuaLib.LuaToBoolean (lState, -1)) {
- LuaLib.LuaSetTop (lState, -2);
- throw new LuaException ("There is already a NLua.Lua instance associated with this Lua state");
- } else {
- luaState = lState;
- _StatePassed = true;
- LuaLib.LuaSetTop (luaState, -2);
- Init ();
- }
- }
-
- void Init ()
- {
- LuaLib.LuaPushString (luaState, "LUAINTERFACE LOADED");
- LuaLib.LuaPushBoolean (luaState, true);
- LuaLib.LuaSetTable (luaState, (int)LuaIndexes.Registry);
- if (_StatePassed == false) {
- LuaLib.LuaNewTable (luaState);
- LuaLib.LuaSetGlobal (luaState, "luanet");
- }
- LuaLib.LuaNetPushGlobalTable (luaState);
- LuaLib.LuaGetGlobal (luaState, "luanet");
- LuaLib.LuaPushString (luaState, "getmetatable");
- LuaLib.LuaGetGlobal (luaState, "getmetatable");
- LuaLib.LuaSetTable (luaState, -3);
- LuaLib.LuaNetPopGlobalTable (luaState);
- translator = new ObjectTranslator (this, luaState);
- lock (translatorPoolLock)
- {
- ObjectTranslatorPool.Instance.Add (luaState, translator);
- }
- LuaLib.LuaNetPopGlobalTable (luaState);
- LuaLib.LuaLDoString (luaState, Lua.initLuanet);
- }
-
- public void Close ()
- {
- if (_StatePassed)
- return;
-
- if (! CheckNull.IsNull(luaState)) {
- lock (translatorPoolLock)
- {
- LuaCore.LuaClose (luaState);
- ObjectTranslatorPool.Instance.Remove (luaState);
- }
- }
- }
-
-#if MONOTOUCH
- [MonoPInvokeCallback (typeof (LuaNativeFunction))]
-#endif
- static int PanicCallback (LuaState luaState)
- {
- string reason = string.Format ("unprotected error in call to Lua API ({0})", LuaLib.LuaToString (luaState, -1));
- throw new LuaException (reason);
- }
-
- ///
- /// Assuming we have a Lua error string sitting on the stack, throw a C# exception out to the user's app
- ///
- /// Thrown if the script caused an exception
- private void ThrowExceptionFromError (int oldTop)
- {
- object err = translator.GetObject (luaState, -1);
- LuaLib.LuaSetTop (luaState, oldTop);
-
- // A pre-wrapped exception - just rethrow it (stack trace of InnerException will be preserved)
- var luaEx = err as LuaScriptException;
-
- if (luaEx != null)
- throw luaEx;
-
- // A non-wrapped Lua error (best interpreted as a string) - wrap it and throw it
- if (err == null)
- err = "Unknown Lua Error";
-
- throw new LuaScriptException (err.ToString (), string.Empty);
- }
-
- ///
- /// Push a debug.traceback reference onto the stack, for a pcall function to use as error handler. (Remember to increment any top-of-stack markers!)
- ///
- private int PushDebugTraceback(LuaState luaState, int argcount)
- {
- LuaLib.LuaGetGlobal(luaState, "debug");
- LuaLib.LuaGetField(luaState, -1, "traceback");
- LuaLib.LuaRemove(luaState, -2);
- int errindex = -argcount -2;
- LuaLib.LuaInsert(luaState, errindex);
- return errindex;
- }
-
- ///
- /// Return a debug.traceback() call result (a multi-line string, containing a full stack trace, including C calls.
- /// Note: it won't return anything unless the interpreter is in the middle of execution - that is, it only makes sense to call it from a method called from Lua, or during a coroutine yield.
- ///
- public string GetDebugTraceback()
- {
- int oldTop = LuaLib.LuaGetTop(luaState);
- LuaLib.LuaGetGlobal(luaState, "debug"); // stack: debug
- LuaLib.LuaGetField(luaState, -1, "traceback"); // stack: debug,traceback
- LuaLib.LuaRemove(luaState, -2); // stack: traceback
- LuaLib.LuaPCall(luaState, 0, -1, 0);
- return translator.PopValues(luaState, oldTop)[0] as string;
- }
-
- ///
- /// Convert C# exceptions into Lua errors
- ///
- /// num of things on stack
- /// null for no pending exception
- internal int SetPendingException (Exception e)
- {
- var caughtExcept = e;
-
- if (caughtExcept != null) {
- translator.ThrowError (luaState, caughtExcept);
- LuaLib.LuaPushNil (luaState);
- return 1;
- } else
- return 0;
- }
-
- ///
- ///
- ///
- ///
- ///
- ///
- public LuaFunction LoadString (string chunk, string name)
- {
- int oldTop = LuaLib.LuaGetTop (luaState);
- executing = true;
-
- try {
- if (LuaLib.LuaLLoadBuffer (luaState, chunk, name) != 0)
- ThrowExceptionFromError (oldTop);
- } finally {
- executing = false;
- }
-
- var result = translator.GetFunction (luaState, -1);
- translator.PopValues (luaState, oldTop);
- return result;
- }
-
- ///
- ///
- ///
- ///
- ///
- ///
- public LuaFunction LoadString (byte[] chunk, string name)
- {
- int oldTop = LuaLib.LuaGetTop (luaState);
- executing = true;
-
- try {
- if (LuaLib.LuaLLoadBuffer (luaState, chunk, name) != 0)
- ThrowExceptionFromError (oldTop);
- } finally {
- executing = false;
- }
-
- var result = translator.GetFunction (luaState, -1);
- translator.PopValues (luaState, oldTop);
- return result;
- }
-
- ///
- /// Load a File on, and return a LuaFunction to execute the file loaded (useful to see if the syntax of a file is ok)
- ///
- ///
- ///
- public LuaFunction LoadFile (string fileName)
- {
- int oldTop = LuaLib.LuaGetTop (luaState);
-
- if (LuaLib.LuaLLoadFile (luaState, fileName) != 0)
- ThrowExceptionFromError (oldTop);
-
- var result = translator.GetFunction (luaState, -1);
- translator.PopValues (luaState, oldTop);
- return result;
- }
-
- ///
- /// Executes a Lua chunk and returns all the chunk's return values in an array.
- ///
- /// Chunk to execute
- /// Name to associate with the chunk. Defaults to "chunk".
- ///
- public object[] DoString (byte[] chunk, string chunkName = "chunk")
- {
- int oldTop = LuaLib.LuaGetTop(luaState);
- executing = true;
-
- if (LuaLib.LuaLLoadBuffer(luaState, chunk, chunkName) == 0)
- {
- int errfunction = 0;
- if (UseTraceback) {
- errfunction = PushDebugTraceback(luaState, 0);
- oldTop++;
- }
-
- try
- {
- if (LuaLib.LuaPCall(luaState, 0, -1, errfunction) == 0)
- return translator.PopValues(luaState, oldTop);
- else
- ThrowExceptionFromError(oldTop);
- }
- finally
- {
- executing = false;
- }
- }
- else
- ThrowExceptionFromError(oldTop);
-
- return null; // Never reached - keeps compiler happy
- }
-
- ///
- /// Executes a Lua chunk and returns all the chunk's return values in an array.
- ///
- /// Chunk to execute
- /// Name to associate with the chunk. Defaults to "chunk".
- ///
- public object[] DoString (string chunk, string chunkName = "chunk")
- {
- int oldTop = LuaLib.LuaGetTop(luaState);
- executing = true;
-
- if (LuaLib.LuaLLoadBuffer(luaState, chunk, chunkName) == 0)
- {
- int errfunction = 0;
- if (UseTraceback) {
- errfunction = PushDebugTraceback(luaState, 0);
- oldTop++;
- }
-
- try
- {
- if (LuaLib.LuaPCall(luaState, 0, -1, errfunction) == 0)
- return translator.PopValues(luaState, oldTop);
- else
- ThrowExceptionFromError(oldTop);
- }
- finally
- {
- executing = false;
- }
- }
- else
- ThrowExceptionFromError(oldTop);
-
- return null; // Never reached - keeps compiler happy
- }
-
- /*
- * Excutes a Lua file and returns all the chunk's return
- * values in an array
- */
- public object[] DoFile (string fileName)
- {
- int oldTop = LuaLib.LuaGetTop (luaState);
-
- if (LuaLib.LuaLLoadFile (luaState, fileName) == 0) {
- executing = true;
-
- int errfunction = 0;
- if (UseTraceback) {
- errfunction = PushDebugTraceback(luaState, 0);
- oldTop++;
- }
-
- try {
- if (LuaLib.LuaPCall(luaState, 0, -1, errfunction) == 0)
- return translator.PopValues (luaState, oldTop);
- else
- ThrowExceptionFromError (oldTop);
- } finally {
- executing = false;
- }
- } else
- ThrowExceptionFromError (oldTop);
-
- return null; // Never reached - keeps compiler happy
- }
-
-
- /*
- * Indexer for global variables from the LuaInterpreter
- * Supports navigation of tables by using . operator
- */
- public object this [string fullPath] {
- get {
- object returnValue = null;
- int oldTop = LuaLib.LuaGetTop (luaState);
- string [] path = FullPathToArray (fullPath);
- LuaLib.LuaGetGlobal (luaState, path [0]);
- returnValue = translator.GetObject (luaState, -1);
- LuaBase dispose = null;
-
- if (path.Length > 1) {
- dispose = returnValue as LuaBase;
- string[] remainingPath = new string[path.Length - 1];
- Array.Copy (path, 1, remainingPath, 0, path.Length - 1);
- returnValue = GetObject (remainingPath);
- if (dispose != null)
- dispose.Dispose ();
- }
-
- LuaLib.LuaSetTop (luaState, oldTop);
- return returnValue;
- }
- set {
- int oldTop = LuaLib.LuaGetTop (luaState);
- string [] path = FullPathToArray (fullPath);
- if (path.Length == 1) {
- translator.Push (luaState, value);
- LuaLib.LuaSetGlobal (luaState, fullPath);
- } else {
- LuaLib.LuaGetGlobal (luaState, path [0]);
- string[] remainingPath = new string[path.Length - 1];
- Array.Copy (path, 1, remainingPath, 0, path.Length - 1);
- SetObject (remainingPath, value);
- }
-
- LuaLib.LuaSetTop (luaState, oldTop);
-
- // Globals auto-complete
- if (value == null) {
- // Remove now obsolete entries
- globals.Remove (fullPath);
- } else {
- // Add new entries
- if (!globals.Contains (fullPath))
- RegisterGlobal (fullPath, value.GetType (), 0);
- }
- }
- }
-
- #region Globals auto-complete
- ///
- /// Adds an entry to (recursivley handles 2 levels of members)
- ///
- /// The index accessor path ot the entry
- /// The type of the entry
- /// How deep have we gone with recursion?
- private void RegisterGlobal (string path, Type type, int recursionCounter)
- {
- // If the type is a global method, list it directly
- if (type == typeof(LuaNativeFunction)) {
- // Format for easy method invocation
- globals.Add (path + "(");
- }
- // If the type is a class or an interface and recursion hasn't been running too long, list the members
- else if ((type.IsClass () || type.IsInterface ()) && type != typeof(string) && recursionCounter < 2) {
- #region Methods
- foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Instance)) {
- string name = method.Name;
- if (
- // Check that the LuaHideAttribute and LuaGlobalAttribute were not applied
- (!method.GetCustomAttributes (typeof(LuaHideAttribute), false).Any ()) &&
- (!method.GetCustomAttributes (typeof(LuaGlobalAttribute), false).Any ()) &&
- // Exclude some generic .NET methods that wouldn't be very usefull in Lua
- name != "GetType" && name != "GetHashCode" && name != "Equals" &&
- name != "ToString" && name != "Clone" && name != "Dispose" &&
- name != "GetEnumerator" && name != "CopyTo" &&
- !name.StartsWith ("get_", StringComparison.Ordinal) &&
- !name.StartsWith ("set_", StringComparison.Ordinal) &&
- !name.StartsWith ("add_", StringComparison.Ordinal) &&
- !name.StartsWith ("remove_", StringComparison.Ordinal)) {
- // Format for easy method invocation
- string command = path + ":" + name + "(";
-
- if (method.GetParameters ().Length == 0)
- command += ")";
- globals.Add (command);
- }
- }
- #endregion
-
- #region Fields
- foreach (var field in type.GetFields(BindingFlags.Public | BindingFlags.Instance)) {
- if (
- // Check that the LuaHideAttribute and LuaGlobalAttribute were not applied
- (!field.GetCustomAttributes (typeof(LuaHideAttribute), false).Any ()) &&
- (!field.GetCustomAttributes (typeof(LuaGlobalAttribute), false).Any ())) {
- // Go into recursion for members
- RegisterGlobal (path + "." + field.Name, field.FieldType, recursionCounter + 1);
- }
- }
- #endregion
-
- #region Properties
- foreach (var property in type.GetProperties (BindingFlags.Public | BindingFlags.Instance)) {
- if (
- // Check that the LuaHideAttribute and LuaGlobalAttribute were not applied
- (!property.GetCustomAttributes (typeof(LuaHideAttribute), false).Any ()) &&
- (!property.GetCustomAttributes (typeof(LuaGlobalAttribute), false).Any ())
- // Exclude some generic .NET properties that wouldn't be very useful in Lua
- && property.Name != "Item") {
- // Go into recursion for members
- RegisterGlobal (path + "." + property.Name, property.PropertyType, recursionCounter + 1);
- }
- }
- #endregion
- } else
- globals.Add (path); // Otherwise simply add the element to the list
-
- // List will need to be sorted on next access
- globalsSorted = false;
- }
- #endregion
-
- /*
- * Navigates a table in the top of the stack, returning
- * the value of the specified field
- */
- object GetObject (string[] remainingPath)
- {
- object returnValue = null;
-
- for (int i = 0; i < remainingPath.Length; i++) {
- LuaLib.LuaPushString (luaState, remainingPath [i]);
- LuaLib.LuaGetTable (luaState, -2);
- returnValue = translator.GetObject (luaState, -1);
-
- if (returnValue == null)
- break;
- }
-
- return returnValue;
- }
-
- /*
- * Gets a numeric global variable
- */
- public double GetNumber (string fullPath)
- {
- return (double)this [fullPath];
- }
-
- /*
- * Gets a string global variable
- */
- public string GetString (string fullPath)
- {
- return this [fullPath].ToString ();
- }
-
- /*
- * Gets a table global variable
- */
- public LuaTable GetTable (string fullPath)
- {
- return (LuaTable)this [fullPath];
- }
-
- /*
- * Gets a table global variable as an object implementing
- * the interfaceType interface
- */
- public object GetTable (Type interfaceType, string fullPath)
- {
- return CodeGeneration.Instance.GetClassInstance (interfaceType, GetTable (fullPath));
- }
-
- /*
- * Gets a function global variable
- */
- public LuaFunction GetFunction (string fullPath)
- {
- object obj = this [fullPath];
- return (obj is LuaNativeFunction ? new LuaFunction ((LuaNativeFunction)obj, this) : (LuaFunction)obj);
- }
-
- /*
- * Register a delegate type to be used to convert Lua functions to C# delegates (useful for iOS where there is no dynamic code generation)
- * type delegateType
- */
- public void RegisterLuaDelegateType (Type delegateType, Type luaDelegateType)
- {
- CodeGeneration.Instance.RegisterLuaDelegateType (delegateType, luaDelegateType);
- }
-
- public void RegisterLuaClassType (Type klass, Type luaClass)
- {
- CodeGeneration.Instance.RegisterLuaClassType (klass, luaClass);
- }
-
- public void LoadCLRPackage ()
- {
- LuaLib.LuaLDoString (luaState, Lua.clr_package);
- }
- /*
- * Gets a function global variable as a delegate of
- * type delegateType
- */
- public Delegate GetFunction (Type delegateType, string fullPath)
- {
- return CodeGeneration.Instance.GetDelegate (delegateType, GetFunction (fullPath));
- }
-
- /*
- * Calls the object as a function with the provided arguments,
- * returning the function's returned values inside an array
- */
- internal object[] CallFunction (object function, object[] args)
- {
- return CallFunction (function, args, null);
- }
-
- /*
- * Calls the object as a function with the provided arguments and
- * casting returned values to the types in returnTypes before returning
- * them in an array
- */
- internal object[] CallFunction (object function, object[] args, Type[] returnTypes)
- {
- int nArgs = 0;
- int oldTop = LuaLib.LuaGetTop (luaState);
-
- if (!LuaLib.LuaCheckStack (luaState, args.Length + 6))
- throw new LuaException ("Lua stack overflow");
-
- translator.Push (luaState, function);
-
- if (args != null) {
- nArgs = args.Length;
-
- for (int i = 0; i < args.Length; i++)
- translator.Push (luaState, args [i]);
- }
-
- executing = true;
-
- try {
- int errfunction = 0;
- if (UseTraceback) {
- errfunction = PushDebugTraceback(luaState, nArgs);
- oldTop++;
- }
-
- int error = LuaLib.LuaPCall (luaState, nArgs, -1, errfunction);
- if (error != 0)
- ThrowExceptionFromError (oldTop);
- } finally {
- executing = false;
- }
-
- return returnTypes != null ? translator.PopValues (luaState, oldTop, returnTypes) : translator.PopValues (luaState, oldTop);
- }
-
- /*
- * Navigates a table to set the value of one of its fields
- */
- void SetObject (string[] remainingPath, object val)
- {
- for (int i = 0; i < remainingPath.Length-1; i++) {
- LuaLib.LuaPushString (luaState, remainingPath [i]);
- LuaLib.LuaGetTable (luaState, -2);
- }
-
- LuaLib.LuaPushString (luaState, remainingPath [remainingPath.Length - 1]);
- translator.Push (luaState, val);
- LuaLib.LuaSetTable (luaState, -3);
- }
-
- string [] FullPathToArray (string fullPath)
- {
- return fullPath.SplitWithEscape ('.', '\\').ToArray ();
- }
- /*
- * Creates a new table as a global variable or as a field
- * inside an existing table
- */
- public void NewTable (string fullPath)
- {
- string [] path = FullPathToArray (fullPath);
- int oldTop = LuaLib.LuaGetTop (luaState);
-
- if (path.Length == 1) {
- LuaLib.LuaNewTable (luaState);
- LuaLib.LuaSetGlobal (luaState, fullPath);
- } else {
- LuaLib.LuaGetGlobal (luaState, path [0]);
-
- for (int i = 1; i < path.Length-1; i++) {
- LuaLib.LuaPushString (luaState, path [i]);
- LuaLib.LuaGetTable (luaState, -2);
- }
-
- LuaLib.LuaPushString (luaState, path [path.Length - 1]);
- LuaLib.LuaNewTable (luaState);
- LuaLib.LuaSetTable (luaState, -3);
- }
-
- LuaLib.LuaSetTop (luaState, oldTop);
- }
-
- public Dictionary