Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
NLua
Commits
6336b46a
Commit
6336b46a
authored
Dec 01, 2011
by
Megax
Browse files
bridge from LuaInterface(capresti) to LuaInterface (megax) part 2
parent
52119866
Changes
53
Expand all
Hide whitespace changes
Inline
Side-by-side
luainterface/README.txt
deleted
100644 → 0
View file @
52119866
LuaInterface 2.0.0
------------------
Copyright © 2003-2006 Fabio Mascarenhas de Queiroz
Maintainer: Craig Presti, craig@vastpark.com
lua51.dll and lua51.exe are Copyright © 2005 Tecgraf, PUC-Rio
Getting started with LuaInterface:
---------
* Use LuaRunner.exe to run samples/testluaform.lua
* Run TestLua.exe to see some more test cases
* Look at src/TestLuaInterface/TestLua to see example usage from C#
(optionally run this from inside of the LuaInterface solution in
the debugger). Also provides a good example of how to override .net
methods from Lua and use LuaInterface from within your .net application.
* Look at samples/testluaform.lua to see examples of how to use
.net from inside Lua
* More instructions for installing and using in the doc/guide.pdf file.
What's new in LuaInterface 2.0.3
------------------------------
* Fix: Private methods accessible via LuaInterface
* Fix: Method overload lookup failures
* Fix: Lua DoFile memory leaks when file not found (submitted by Paul Moore)
* Fix: Lua Dispose not freeing memory (submitted by Paul Moore)
* Fix: Better support for accessing indexers
* Fix: Parsing error for MBCS characters (qingrui.li)
* Fix: Dispose errors originating from LuaTable, LuaFunction, LuaUserData
* Fix: LuaInterface no longer disposes the state when passed one via the overloaded constructor
* Added: LoadString and LoadFile (submitted by Paul Moore)
* Added: Overloaded DoString
* Added: Lua debugging support (rostermeier)
What's new in LuaInterface 2.0.1
------------------------------
* Apparently the 2.0 built binaries had an issue for some users, this is just a rebuild with the lua sources pulled into the LuaInterface.zip
What's new in LuaInterface 2.0
------------------------------
* The base lua5.1.2 library is now built as entirely manged code. LuaInterface is now pure CIL
* Various adapters to connect the older x86 version of lua are no longer needed
* Performance fixes contributed by Toby Lawrence, Oliver Nemoz and Craig Presti
What's new in LuaInterface 1.5.3
----------
* Internal lua panics (due to API violations) now throw LuaExceptions into .net
* If .net code throws an exception into Lua and lua does not handle it, the
original exception is forwarded back out to .net land.
* Fix bug in the Lua 5.1.1 gmatch C code - it was improperly assuming gmatch
only works with tables.
What's new in LuaInterface 1.5.2
----------
* Overriding C# methods from Lua is fixed (broken with .net 2.0!)
* Registering static C# functions for Lua is fixed (broken with Lua-5.1.1)
* Rebuilt to fix linking problems with the binaries included in 1.5.1
* RegisterFunction has been leaking things onto the stack
What's new in LuaInterface 1.5.1
----------
Fix a serious bug w.r.t. garbage collection - made especially apparent
with the new lua5.1 switch: If you were *very* unlucky with timing
sometimes Lua would loose track of pointers to CLR functions.
When I added support for static methods, I allowed the user to use either a
colon or a dot to separate the method from the class name. This was not
correct - it broke disambiguation between overloaded static methods.
Therefore, LuaInterface is now more strict: If you want to call a static
method, you must use dot to separate the method name from the class name. Of
course you can still use a colon if an _instance_ is being used.
Static method calls are now much faster (due to better caching).
What's new in LuaInterface 1.5
----------
LuaInterface is now updated to be based on Lua5.1.1. You can either use
your own build/binaries for Lua5.1.1 or use the version distributed here.
(Lots of thanks to Steffen Itterheim for this work!)
LuaInterface.Lua no longer has OpenLibs etc... The base mechanism for
library loading for Lua has changed, and we haven't yet broken appart
the library loading for LuaInterface. Instead, all standard Lua libraries
are automatically loaded at start up.
Fixed a bug where calls of some static methods would reference an
invalid pointer.
Fixed a bug when strings with embedded null characters are passed in or
out of Lua (Thanks to Daniel Néri for the report & fix!)
The native components in LuaInterface (i.e. Lua51 and the loader) are
both built as release builds - to prevent problems loading standard
windows libraries.
Note: You do not need to download/build lua-5.1.1.zip unless you want to
modify Lua internals (a built version of lua51.dll is included in the
regular LuaInterface distribution)
What's New in LuaInterface 1.4
----------
Note: Fabio area of interest has moved off in other directions (hopefully only temporarily).
I've talked with Fabio and he's said he's okay with me doing a new release with various fixes
I've made over the last few months. Changes since 1.3:
Visual Studio 2005/.Net 2.0 is supported.
Compat-5.1 is modified to expect backslash as the path seperator.
LuaInterface will now work correctly with Generic C# classes.
CLR inner types are now supported.
Fixed a problem where sometimes Lua proxy objects would be associated with the wrong CLR object.
If a CLR class has an array accessor, the elements can be accessed using the regular Lua indexing
interface.
Add CLRPackage.lua to the samples directory. This class makes it much easier to automatically
load referenced assemblies. In the next release this loading will be automatic.
To see an quick demonstration of LuaInterface, cd into luainterface/samples and then
type: ..\..\Built\debug\LuaRunner.exe testluaform.lua
Various other minor fixes that I've forgotten. I'll keep better track next time.
Note: LuaInterface is still based on Lua 5.0.2. If someone really wants us to upgrade to Lua 5.1
please send me a note. In the mean time, I'm also distributing a version of
Lua 5.0.2 with an appropriate VS 2005 project file. You do not need to
download this file unless you want to modify Lua internals (a built version
of lua50.dll is included in the regular LuaInterface distribution)
What's New in LuaInterface 1.3
----------
LuaInterface now works with LuaBinaries Release 2 (http://luabinaries.luaforge.net)
and Compat-5.1 Release 3 (http://luaforge.net/projects/compat). The loader DLL is now
called luanet.dll, and does not need a luainterface.lua file anymore
(just put LuaInterface.dll in the GAC, luanet.dll in your package.cpath, and
do require"luanet").
Fixed a bug in the treatment of the char type (thanks to Ron Scott).
LuaInterface.dll now has a strong name, and can be put in the GAC (thanks to Ivan Voras).
You can now use foreach with instances of LuaTable (thanks to Zachary Landau).
There is an alternate form of loading assemblies and importing types (based on an
anonymous contribution in the Lua wiki). Check the _alt files in the samples folder.
What's New in LuaInterface 1.2.1
--------------------------------
Now checks if two LuaInterface.Lua instances are trying to share the same Lua state,
and throws an exception if this is the case. Also included readonly clauses in public
members of the Lua and ObjectTranslator classes.
This version includes the source of LuaInterfaceLoader.dll, with VS.Net 2003 project
files.
What's New in LuaInterface 1.2
------------------------------
LuaInterface now can be loaded as a module, so you can use the lua standalone
interpreter to run scripts. Thanks to Paul Winwood for this idea and sample code
showing how to load the CLR from a C++ program. The module is "luainterface". Make
sure Lua can find luainterface.lua, and LuaInterfaceLoader.dll is either in the
current directory or the GAC. The samples now load LuaInterface as a module, in
its own namespace.
The get_method_bysig, get_constructor_bysig and make_object were changed: now you
pass the *names* of the types to them, instead of the types themselves. E.g:
get_method_bysig(obj,"method","System.String")
instead of
String = import_type("System.String")
get_method_bysig(obj,"method",String)
Make sure the assemblies of the types you are passing have been loaded, or the call
will fail. The test cases in src/TestLuaInterface/TestLua.cs have examples of the new
functions.
luainterface/doc/LuaRunner.txt
deleted
100644 → 0
View file @
52119866
LuaRunner -- runs Lua scripts with CLR access
Usage: luarunner <script.lua> [{<arg>}]
luainterface/doc/guide.pdf
deleted
100644 → 0
View file @
52119866
File deleted
luainterface/doc/luainterface.pdf
deleted
100644 → 0
View file @
52119866
File deleted
luainterface/lib/lua51/net35/lua51.dll
deleted
100644 → 0
View file @
52119866
File deleted
luainterface/lib/lua51/net40/lua51.dll
deleted
100644 → 0
View file @
52119866
File deleted
luainterface/samples/CLRPackage.lua
deleted
100644 → 0
View file @
52119866
---
--- 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)
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
=
luanet
.
import_type
(
package
.
packageName
..
"."
..
classname
)
package
[
classname
]
=
class
-- keep what we found around, so it will be shared
end
return
class
end
}
--- Create a new Package class
function
CLRPackage
(
assemblyName
,
packageName
)
local
table
=
{}
luanet
.
load_assembly
(
assemblyName
)
-- Make sure our assembly is loaded
-- FIXME - table.packageName could instead be a private index (see Lua 13.4.4)
table
.
packageName
=
packageName
setmetatable
(
table
,
mt
)
return
table
end
luainterface/samples/README.txt
deleted
100644 → 0
View file @
52119866
Some example scripts, showing what LuaInterface can do.
form A simple form, basic event handling
socket Fetches the content of a web site and prints to the
console
testluaform A more complex WinForms example, type some Lua code in
the textbox and run it, or load a Lua script.
luainterface/samples/form.lua
deleted
100644 → 0
View file @
52119866
-- kevinh - the following lines are part of our standard init
-- require("compat-5.1")
luanet
.
load_assembly
(
"System.Windows.Forms"
)
luanet
.
load_assembly
(
"System.Drawing"
)
Form
=
luanet
.
import_type
(
"System.Windows.Forms.Form"
)
Button
=
luanet
.
import_type
(
"System.Windows.Forms.Button"
)
Point
=
luanet
.
import_type
(
"System.Drawing.Point"
)
form1
=
Form
()
button1
=
Button
()
button2
=
Button
()
function
handleClick
(
sender
,
data
)
if
sender
.
Text
==
"OK"
then
sender
.
Text
=
"Clicked"
else
sender
.
Text
=
"OK"
end
button1
.
MouseUp
:
Remove
(
handler
)
print
(
sender
:
ToString
())
end
button1
.
Text
=
"OK"
button1
.
Location
=
Point
(
10
,
10
)
button2
.
Text
=
"Cancel"
button2
.
Location
=
Point
(
button1
.
Left
,
button1
.
Height
+
button1
.
Top
+
10
)
handler
=
button1
.
MouseUp
:
Add
(
handleClick
)
form1
.
Text
=
"My Dialog Box"
form1
.
HelpButton
=
true
form1
.
MaximizeBox
=
false
form1
.
MinimizeBox
=
false
form1
.
AcceptButton
=
button1
form1
.
CancelButton
=
button2
form1
.
Controls
:
Add
(
button1
)
form1
.
Controls
:
Add
(
button2
)
form1
:
ShowDialog
()
luainterface/samples/form_alt.lua
deleted
100644 → 0
View file @
52119866
--require("compat-5.1")
Forms
=
luanet
.
System
.
Windows
.
Forms
Form
=
Forms
.
Form
Button
=
Forms
.
Button
Point
=
luanet
.
System
.
Drawing
.
Point
form1
=
Form
()
button1
=
Button
()
button2
=
Button
()
function
handleClick
(
sender
,
data
)
if
sender
.
Text
==
"OK"
then
sender
.
Text
=
"Clicked"
else
sender
.
Text
=
"OK"
end
button1
.
MouseUp
:
Remove
(
handler
)
print
(
sender
:
ToString
())
end
button1
.
Text
=
"OK"
button1
.
Location
=
Point
(
10
,
10
)
button2
.
Text
=
"Cancel"
button2
.
Location
=
Point
(
button1
.
Left
,
button1
.
Height
+
button1
.
Top
+
10
)
handler
=
button1
.
MouseUp
:
Add
(
handleClick
)
form1
.
Text
=
"My Dialog Box"
form1
.
HelpButton
=
true
form1
.
MaximizeBox
=
false
form1
.
MinimizeBox
=
false
form1
.
AcceptButton
=
button1
form1
.
CancelButton
=
button2
form1
.
Controls
:
Add
(
button1
)
form1
.
Controls
:
Add
(
button2
)
form1
:
ShowDialog
()
luainterface/samples/socket.lua
deleted
100644 → 0
View file @
52119866
--require("compat-5.1")
luanet
.
load_assembly
(
"System"
)
WebClient
=
luanet
.
import_type
(
"System.Net.WebClient"
)
StreamReader
=
luanet
.
import_type
(
"System.IO.StreamReader"
)
Math
=
luanet
.
import_type
(
"System.Math"
)
print
(
Math
:
Pow
(
2
,
3
))
myWebClient
=
WebClient
()
myStream
=
myWebClient
:
OpenRead
(
arg
[
1
])
sr
=
StreamReader
(
myStream
)
line
=
sr
:
ReadLine
()
repeat
print
(
line
)
line
=
sr
:
ReadLine
()
until
not
line
myStream
:
Close
()
luainterface/samples/socket_alt.lua
deleted
100644 → 0
View file @
52119866
--require("compat-5.1")
System
=
luanet
.
System
WebClient
=
System
.
Net
.
WebClient
StreamReader
=
System
.
IO
.
StreamReader
Math
=
System
.
Math
print
(
Math
:
Pow
(
2
,
3
))
myWebClient
=
WebClient
()
myStream
=
myWebClient
:
OpenRead
(
arg
[
1
])
sr
=
StreamReader
(
myStream
)
line
=
sr
:
ReadLine
()
repeat
print
(
line
)
line
=
sr
:
ReadLine
()
until
not
line
myStream
:
Close
()
luainterface/samples/testluaform.lua
deleted
100644 → 0
View file @
52119866
require
(
"CLRPackage"
)
Forms
=
CLRPackage
(
"System.Windows.Forms"
,
"System.Windows.Forms"
)
Drawing
=
CLRPackage
(
"System.Drawing"
,
"System.Drawing"
)
LuaInterface
=
CLRPackage
(
"LuaInterface"
,
"LuaInterface"
)
IO
=
CLRPackage
(
"System.IO"
,
"System.IO"
)
System
=
CLRPackage
(
"System"
,
"System"
)
Form
=
Forms
.
Form
TextBox
=
Forms
.
TextBox
Label
=
Forms
.
Label
ListBox
=
Forms
.
ListBox
Button
=
Forms
.
Button
Point
=
Drawing
.
Point
Size
=
Drawing
.
Size
Lua
=
LuaInterface
.
Lua
OpenFileDialog
=
Forms
.
OpenFileDialog
File
=
IO
.
File
StreamReader
=
IO
.
StreamReader
FileMode
=
IO
.
FileMode
ScrollBars
=
Forms
.
ScrollBars
FormBorderStyle
=
Forms
.
FormBorderStyle
FormStartPosition
=
Forms
.
FormStartPosition
function
clear_click
(
sender
,
args
)
code
:
Clear
()
end
function
execute_click
(
sender
,
args
)
results
.
Items
:
Clear
()
result
=
lua
:
DoString
(
code
.
Text
)
if
result
then
for
i
=
0
,
result
.
Length
-
1
do
results
.
Items
:
Add
(
result
[
i
])
end
end
end
function
load_click
(
sender
,
args
)
open_file
:
ShowDialog
()
file
=
StreamReader
(
open_file
.
FileName
)
code
.
Text
=
file
:
ReadToEnd
()
file
:
Close
()
end
form
=
Form
()
code
=
TextBox
()
label1
=
Label
()
execute
=
Button
()
clear
=
Button
()
results
=
ListBox
()
label2
=
Label
()
load
=
Button
()
lua
=
Lua
()
--lua:OpenBaseLib() -- steffenj: Open*Lib() functions no longer exist
open_file
=
OpenFileDialog
()
form
:
SuspendLayout
()
code
.
Location
=
Point
(
16
,
24
)
code
.
Multiline
=
true
code
.
Name
=
"Code"
code
.
Size
=
Size
(
440
,
128
)
code
.
ScrollBars
=
ScrollBars
.
Vertical
code
.
TabIndex
=
0
code
.
Text
=
""
label1
.
Location
=
Point
(
16
,
8
)
label1
.
Name
=
"label1"
label1
.
Size
=
Size
(
100
,
16
)
label1
.
TabIndex
=
1
label1
.
Text
=
"Lua Code:"
execute
.
Location
=
Point
(
96
,
160
)
execute
.
Name
=
"Execute"
execute
.
TabIndex
=
2
execute
.
Text
=
"Execute"
execute
.
Click
:
Add
(
execute_click
)
clear
.
Location
=
Point
(
176
,
160
)
clear
.
Name
=
"Clear"
clear
.
TabIndex
=
3
clear
.
Text
=
"Clear"
clear
.
Click
:
Add
(
clear_click
)
results
.
Location
=
Point
(
16
,
208
)
results
.
Name
=
"Results"
results
.
Size
=
Size
(
440
,
95
)
results
.
TabIndex
=
4
label2
.
Location
=
Point
(
16
,
192
)
label2
.
Name
=
"label2"
label2
.
Size
=
Size
(
100
,
16
)
label2
.
TabIndex
=
5
label2
.
Text
=
"Results:"
load
.
Location
=
Point
(
16
,
160
)
load
.
Name
=
"Load"
load
.
TabIndex
=
6
load
.
Text
=
"Load..."
load
.
Click
:
Add
(
load_click
)
open_file
.
DefaultExt
=
"lua"
open_file
.
Filter
=
"Lua Scripts|*.lua|All Files|*.*"
open_file
.
Title
=
"Pick a File"
form
.
AutoScaleBaseSize
=
Size
(
5
,
13
)
form
.
ClientSize
=
Size
(
472
,
315
)
form
.
Controls
:
Add
(
load
)
form
.
Controls
:
Add
(
label2
)
form
.
Controls
:
Add
(
results
)
form
.
Controls
:
Add
(
clear
)
form
.
Controls
:
Add
(
execute
)
form
.
Controls
:
Add
(
label1
)
form
.
Controls
:
Add
(
code
)
form
.
Name
=
"MainForm"
form
.
Text
=
"LuaNet"
form
.
FormBorderStyle
=
FormBorderStyle
.
Fixed3D
form
.
StartPosition
=
FormStartPosition
.
CenterScreen
form
:
ResumeLayout
(
false
)
form
:
ShowDialog
()
luainterface/samples/testluaform_alt.lua
deleted
100644 → 0
View file @
52119866
--require("compat-5.1")
Forms
=
luanet
.
System
.
Windows
.
Forms
Drawing
=
luanet
.
System
.
Drawing
LuaInterface
=
luanet
.
LuaInterface
IO
=
luanet
.
System
.
IO
Form
=
Forms
.
Form
TextBox
=
Forms
.
TextBox
Label
=
Forms
.
Label
ListBox
=
Forms
.
ListBox
Button
=
Forms
.
Button
Point
=
Drawing
.
Point
Size
=
Drawing
.
Size
Lua
=
LuaInterface
.
Lua
OpenFileDialog
=
Forms
.
OpenFileDialog
File
=
IO
.
File
StreamReader
=
IO
.
StreamReader
FileMode
=
IO
.
FileMode
ScrollBars
=
Forms
.
ScrollBars
FormBorderStyle
=
Forms
.
FormBorderStyle
FormStartPosition
=
Forms
.
FormStartPosition
function
clear_click
(
sender
,
args
)
code
:
Clear
()
end
function
execute_click
(
sender
,
args
)
results
.
Items
:
Clear
()
result
=
lua
:
DoString
(
code
.
Text
)
if
result
then
for
i
=
0
,
result
.
Length
-
1
do
results
.
Items
:
Add
(
result
[
i
])
end
end
end
function
load_click
(
sender
,
args
)
open_file
:
ShowDialog
()
file
=
StreamReader
(
open_file
.
FileName
)
code
.
Text
=
file
:
ReadToEnd
()
file
:
Close
()
end
form
=
Form
()
code
=
TextBox
()
label1
=
Label
()
execute
=
Button
()
clear
=
Button
()
results
=
ListBox
()
label2
=
Label
()
load
=
Button
()
lua
=
Lua
()
--lua:OpenBaseLib() -- steffenj: Open*Lib() functions no longer exist
open_file
=
OpenFileDialog
()
form
:
SuspendLayout
()
code
.
Location
=
Point
(
16
,
24
)
code
.
Multiline
=
true
code
.
Name
=
"Code"
code
.
Size
=
Size
(
440
,
128
)
code
.
ScrollBars
=
ScrollBars
.
Vertical
code
.
TabIndex
=
0
code
.
Text
=
""
label1
.
Location
=
Point
(
16
,
8
)
label1
.
Name
=
"label1"
label1
.
Size
=
Size
(
100
,
16
)
label1
.
TabIndex
=
1
label1
.
Text
=
"Lua Code:"
execute
.
Location
=
Point
(
96
,
160
)
execute
.
Name
=
"Execute"
execute
.
TabIndex
=
2
execute
.
Text
=
"Execute"
execute
.
Click
:
Add
(
execute_click
)
clear
.
Location
=
Point
(
176
,
160
)
clear
.
Name
=
"Clear"
clear
.
TabIndex
=
3
clear
.
Text
=
"Clear"
clear
.
Click
:
Add
(
clear_click
)
results
.
Location
=
Point
(
16
,
208
)
results
.
Name
=
"Results"
results
.
Size
=
Size
(
440
,
95
)
results
.
TabIndex
=
4
label2
.
Location
=
Point
(
16
,
192
)
label2
.
Name
=
"label2"
label2
.
Size
=
Size
(
100
,
16
)
label2
.
TabIndex
=
5
label2
.
Text
=
"Results:"
load
.
Location
=
Point
(
16
,
160
)
load
.
Name
=
"Load"
load
.
TabIndex
=
6
load
.
Text
=
"Load..."
load
.
Click
:
Add
(
load_click
)
open_file
.
DefaultExt
=
"lua"
open_file
.
Filter
=
"Lua Scripts|*.lua|All Files|*.*"
open_file
.
Title
=
"Pick a File"
form
.
AutoScaleBaseSize
=
Size
(
5
,
13
)
form
.
ClientSize
=
Size
(
472
,
315
)
form
.
Controls
:
Add
(
load
)
form
.
Controls
:
Add
(
label2
)
form
.
Controls
:
Add
(
results
)
form
.
Controls
:
Add
(
clear
)
form
.
Controls
:
Add
(
execute
)
form
.
Controls
:
Add
(
label1
)
form
.
Controls
:
Add
(
code
)
form
.
Name
=
"MainForm"
form
.
Text
=
"LuaNet"
form
.
FormBorderStyle
=
FormBorderStyle
.
Fixed3D
form
.
StartPosition
=
FormStartPosition
.
CenterScreen
form
:
ResumeLayout
(
false
)
form
:
ShowDialog
()
luainterface/src/LuaInterface.Test/LuaInterface.Test.csproj
deleted
100644 → 0
View file @
52119866
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"4.0"
DefaultTargets=
"Build"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<PropertyGroup>
<Configuration
Condition=
" '$(Configuration)' == '' "
>
Debug
</Configuration>
<Platform
Condition=
" '$(Platform)' == '' "
>
AnyCPU
</Platform>
<ProductVersion>
9.0.30729
</ProductVersion>
<SchemaVersion>
2.0
</SchemaVersion>
<ProjectGuid>
{F97A7B76-AD92-49F9-B733-F347B7C8439F}
</ProjectGuid>
<OutputType>
Library
</OutputType>
<AppDesignerFolder>
Properties
</AppDesignerFolder>
<RootNamespace>
LuaInterface.Test
</RootNamespace>
<AssemblyName>
LuaInterface.Test
</AssemblyName>
<TargetFrameworkVersion>
v4.0
</TargetFrameworkVersion>
<FileAlignment>
512
</FileAlignment>
<ProjectTypeGuids>
{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
</ProjectTypeGuids>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>
3.5
</OldToolsVersion>
<UpgradeBackupLocation
/>
<PublishUrl>
publish\
</PublishUrl>
<Install>
true
</Install>
<InstallFrom>
Disk
</InstallFrom>
<UpdateEnabled>
false
</UpdateEnabled>
<UpdateMode>
Foreground
</UpdateMode>
<UpdateInterval>
7
</UpdateInterval>
<UpdateIntervalUnits>
Days
</UpdateIntervalUnits>
<UpdatePeriodically>
false
</UpdatePeriodically>
<UpdateRequired>
false
</UpdateRequired>
<MapFileExtensions>
true
</MapFileExtensions>
<ApplicationRevision>
0
</ApplicationRevision>
<ApplicationVersion>
1.0.0.%2a
</ApplicationVersion>
<IsWebBootstrapper>
false
</IsWebBootstrapper>
<UseApplicationTrust>
false
</UseApplicationTrust>
<BootstrapperEnabled>
true
</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "
>
<DebugSymbols>
true
</DebugSymbols>
<DebugType>
full
</DebugType>
<Optimize>
false
</Optimize>
<OutputPath>
bin\Debug\
</OutputPath>
<DefineConstants>
DEBUG;TRACE
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
<CodeAnalysisRuleSet>
AllRules.ruleset
</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "
>
<DebugType>
pdbonly
</DebugType>
<Optimize>
true
</Optimize>
<OutputPath>
bin\Release\
</OutputPath>
<DefineConstants>
TRACE
</DefineConstants>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
<CodeAnalysisRuleSet>
AllRules.ruleset
</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"Moq, Version=4.0.10827.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL"
>
<HintPath>
..\..\packages\Moq.4.0.10827\lib\NET40\Moq.dll
</HintPath>
</Reference>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.Core"
>
<RequiredTargetFramework>
3.5
</RequiredTargetFramework>
</Reference>
<Reference
Include=
"xunit, Version=1.8.0.1545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL"
>
<HintPath>
..\..\packages\xunit.1.8.0.1545\lib\xunit.dll
</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile
Include=
"Mock\Entity.cs"
/>
<Compile
Include=
"Mock\TestLua.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"LuaTests.cs"
/>
</ItemGroup>
<ItemGroup>
<ProjectReference
Include=
"..\LuaInterface\LuaInterface.csproj"
>
<Project>
{F55CABBB-4108-4A39-94E1-581FD46DC021}
</Project>
<Name>
LuaInterface
</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None
Include=
"packages.config"
/>
<None
Include=
"test.lua"
>
<CopyToOutputDirectory>
PreserveNewest
</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage
Include=
".NETFramework,Version=v4.0"
>
<Visible>
False
</Visible>
<ProductName>
Microsoft .NET Framework 4 %28x86 and x64%29
</ProductName>
<Install>
true
</Install>
</BootstrapperPackage>
<BootstrapperPackage
Include=
"Microsoft.Net.Client.3.5"
>
<Visible>
False
</Visible>
<ProductName>
.NET Framework 3.5 SP1 Client Profile
</ProductName>
<Install>
false
</Install>
</BootstrapperPackage>
<BootstrapperPackage
Include=
"Microsoft.Net.Framework.3.5.SP1"
>
<Visible>
False
</Visible>
<ProductName>
.NET Framework 3.5 SP1
</ProductName>
<Install>
false
</Install>
</BootstrapperPackage>
<BootstrapperPackage
Include=
"Microsoft.Windows.Installer.3.1"
>
<Visible>
False
</Visible>
<ProductName>
Windows Installer 3.1
</ProductName>
<Install>
true
</Install>
</BootstrapperPackage>
</ItemGroup>
<Import
Project=
"$(MSBuildBinPath)\Microsoft.CSharp.targets"
/>
<PropertyGroup>
<PreBuildEvent>
$(SolutionDir)tools\nuget install $(ProjectDir)packages.config -o $(SolutionDir)packages
</PreBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
luainterface/src/LuaInterface.Test/LuaTests.cs
deleted
100644 → 0
View file @
52119866
This diff is collapsed.
Click to expand it.
luainterface/src/LuaInterface.Test/Mock/Entity.cs
deleted
100644 → 0
View file @
52119866
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
namespace
LuaInterface.Test.Mock
{
public
class
Entity
{
public
event
EventHandler
<
EventArgs
>
Clicked
;
protected
virtual
void
OnEntityClicked
(
EventArgs
e
)
{
EventHandler
<
EventArgs
>
handler
=
Clicked
;
if
(
handler
!=
null
)
{
// Use the () operator to raise the event.
handler
(
this
,
e
);
}
}
public
Entity
()
{
}
public
void
Click
()
{
OnEntityClicked
(
new
EventArgs
());
}
}
}
luainterface/src/LuaInterface.Test/Mock/TestLua.cs
deleted
100644 → 0
View file @
52119866
//note: this should be cleaned up and replaced with moq mocks where possible
namespace
LuaInterface.Test.Mock
{
using
System
;
using
LuaInterface
;
using
System.Threading
;
using
System.Diagnostics
;
using
System.Reflection
;
/*
* Delegates used for testing Lua function -> delegate translation
*/
public
delegate
int
TestDelegate1
(
int
a
,
int
b
);
public
delegate
int
TestDelegate2
(
int
a
,
out
int
b
);
public
delegate
void
TestDelegate3
(
int
a
,
ref
int
b
);
public
delegate
TestClass
TestDelegate4
(
int
a
,
int
b
);
public
delegate
int
TestDelegate5
(
TestClass
a
,
TestClass
b
);
public
delegate
int
TestDelegate6
(
int
a
,
out
TestClass
b
);
public
delegate
void
TestDelegate7
(
int
a
,
ref
TestClass
b
);
/*
* Interface used for testing Lua table -> interface translation
*/
public
interface
ITest
{
int
intProp
{
get
;
set
;
}
TestClass
refProp
{
get
;
set
;
}
int
test1
(
int
a
,
int
b
);
int
test2
(
int
a
,
out
int
b
);
void
test3
(
int
a
,
ref
int
b
);
TestClass
test4
(
int
a
,
int
b
);
int
test5
(
TestClass
a
,
TestClass
b
);
int
test6
(
int
a
,
out
TestClass
b
);
void
test7
(
int
a
,
ref
TestClass
b
);
}
public
interface
IFoo1
{
int
foo
();
}
public
interface
IFoo2
{
int
foo
();
}
class
MyClass
{
public
int
Func1
()
{
return
1
;
}
}
/// <summary>
/// Use to test threading
/// </summary>
class
DoWorkClass
{
private
object
_Lock
=
new
object
();
public
void
DoWork
()
{
//lock (_Lock)
//{
//simulate work by sleeping
//Console.WriteLine("Started to do work on thread: " + Thread.CurrentThread.ManagedThreadId);
Thread
.
Sleep
(
new
Random
().
Next
(
0
,
1000
));
//Console.WriteLine("Finished work on thread: " + Thread.CurrentThread.ManagedThreadId);
//}
}
}
/// <summary>
/// test structure passing
/// </summary>
public
struct
TestStruct
{
public
TestStruct
(
float
val
)
{
v
=
val
;
}
public
float
v
;
public
float
val
{
get
{
return
v
;
}
set
{
v
=
value
;
}
}
}
/// <summary>
/// Generic class with generic and non-generic methods
/// </summary>
/// <typeparam name="T"></typeparam>
public
class
TestClassGeneric
<
T
>
{
private
object
_PassedValue
;
private
bool
_RegularMethodSuccess
;
public
bool
RegularMethodSuccess
{
get
{
return
_RegularMethodSuccess
;
}
}
private
bool
_GenericMethodSuccess
;
public
bool
GenericMethodSuccess
{
get
{
return
_GenericMethodSuccess
;
}
}
public
void
GenericMethod
(
T
value
)
{
_PassedValue
=
value
;
_GenericMethodSuccess
=
true
;
}
public
void
RegularMethod
()
{
_RegularMethodSuccess
=
true
;
}
/// <summary>
/// Returns true if the generic method was successfully passed a matching value
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public
bool
Validate
(
T
value
)
{
return
value
.
Equals
(
_PassedValue
);
}
}
/// <summary>
/// Normal class containing a generic method
/// </summary>
public
class
TestClassWithGenericMethod
{
private
object
_PassedValue
;
public
object
PassedValue
{
get
{
return
_PassedValue
;
}
}
private
bool
_GenericMethodSuccess
;
public
bool
GenericMethodSuccess
{
get
{
return
_GenericMethodSuccess
;
}
}
public
void
GenericMethod
<
T
>(
T
value
)
{
_PassedValue
=
value
;
_GenericMethodSuccess
=
true
;
}
internal
bool
Validate
<
T
>(
T
value
)
{
return
value
.
Equals
(
_PassedValue
);
}
}
public
class
TestClass2
{
public
static
int
func
(
int
x
,
int
y
)
{
return
x
+
y
;
}
public
int
funcInstance
(
int
x
,
int
y
)
{
return
x
+
y
;
}
}
/*
* Sample class used in several test cases to check if
* Lua scripts are accessing objects correctly
*/
public
class
TestClass
:
IFoo1
,
IFoo2
{
public
int
val
;
private
string
strVal
;
public
TestClass
()
{
val
=
0
;
}
public
TestClass
(
int
val
)
{
this
.
val
=
val
;
}
public
TestClass
(
string
val
)
{
this
.
strVal
=
val
;
}
public
static
TestClass
makeFromString
(
String
str
)
{
return
new
TestClass
(
str
);
}
bool
?
nb2
=
null
;
public
bool
?
NullableBool
{
get
{
return
nb2
;
}
set
{
nb2
=
value
;
}
}
TestStruct
s
=
new
TestStruct
();
public
TestStruct
Struct
{
get
{
return
s
;
}
set
{
s
=
(
TestStruct
)
value
;
}
}
public
int
testval
{
get
{
return
this
.
val
;
}
set
{
this
.
val
=
value
;
}
}
public
int
this
[
int
index
]
{
get
{
return
1
;
}
set
{
}
}
public
int
this
[
string
index
]
{
get
{
return
1
;
}
set
{
}
}
public
int
sum
(
int
x
,
int
y
)
{
return
x
+
y
;
}
public
void
setVal
(
int
newVal
)
{
val
=
newVal
;
}
public
void
setVal
(
string
newVal
)
{
strVal
=
newVal
;
}
public
int
getVal
()
{
return
val
;
}
public
string
getStrVal
()
{
return
strVal
;
}
public
int
outVal
(
out
int
val
)
{
val
=
5
;
return
3
;
}
public
int
outVal
(
out
int
val
,
int
val2
)
{
val
=
5
;
return
val2
;
}
public
int
outVal
(
int
val
,
ref
int
val2
)
{
val2
=
val
+
val2
;
return
val
;
}
public
int
outValMutiple
(
int
arg
,
out
string
arg2
,
out
string
arg3
)
{
arg2
=
Guid
.
NewGuid
().
ToString
();
arg3
=
Guid
.
NewGuid
().
ToString
();
return
arg
;
}
public
int
callDelegate1
(
TestDelegate1
del
)
{
return
del
(
2
,
3
);
}
public
int
callDelegate2
(
TestDelegate2
del
)
{
int
a
=
3
;
int
b
=
del
(
2
,
out
a
);
return
a
+
b
;
}
public
int
callDelegate3
(
TestDelegate3
del
)
{
int
a
=
3
;
del
(
2
,
ref
a
);
//Console.WriteLine(a);
return
a
;
}
public
int
callDelegate4
(
TestDelegate4
del
)
{
return
del
(
2
,
3
).
testval
;
}
public
int
callDelegate5
(
TestDelegate5
del
)
{
return
del
(
new
TestClass
(
2
),
new
TestClass
(
3
));
}
public
int
callDelegate6
(
TestDelegate6
del
)
{
TestClass
test
=
new
TestClass
();
int
a
=
del
(
2
,
out
test
);
return
a
+
test
.
testval
;
}
public
int
callDelegate7
(
TestDelegate7
del
)
{
TestClass
test
=
new
TestClass
(
3
);
del
(
2
,
ref
test
);
return
test
.
testval
;
}
public
int
callInterface1
(
ITest
itest
)
{
return
itest
.
test1
(
2
,
3
);
}
public
int
callInterface2
(
ITest
itest
)
{
int
a
=
3
;
int
b
=
itest
.
test2
(
2
,
out
a
);
return
a
+
b
;
}
public
int
callInterface3
(
ITest
itest
)
{
int
a
=
3
;
itest
.
test3
(
2
,
ref
a
);
//Console.WriteLine(a);
return
a
;
}
public
int
callInterface4
(
ITest
itest
)
{
return
itest
.
test4
(
2
,
3
).
testval
;
}
public
int
callInterface5
(
ITest
itest
)
{
return
itest
.
test5
(
new
TestClass
(
2
),
new
TestClass
(
3
));
}
public
int
callInterface6
(
ITest
itest
)
{
TestClass
test
=
new
TestClass
();
int
a
=
itest
.
test6
(
2
,
out
test
);
return
a
+
test
.
testval
;
}
public
int
callInterface7
(
ITest
itest
)
{
TestClass
test
=
new
TestClass
(
3
);
itest
.
test7
(
2
,
ref
test
);
return
test
.
testval
;
}
public
int
callInterface8
(
ITest
itest
)
{
itest
.
intProp
=
3
;
return
itest
.
intProp
;
}
public
int
callInterface9
(
ITest
itest
)
{
itest
.
refProp
=
new
TestClass
(
3
);
return
itest
.
refProp
.
testval
;
}
public
void
exceptionMethod
()
{
throw
new
Exception
(
"exception test"
);
}
public
virtual
int
overridableMethod
(
int
x
,
int
y
)
{
return
x
+
y
;
}
public
static
int
callOverridable
(
TestClass
test
,
int
x
,
int
y
)
{
return
test
.
overridableMethod
(
x
,
y
);
}
int
IFoo1
.
foo
()
{
return
3
;
}
public
int
foo
()
{
return
5
;
}
private
void
_PrivateMethod
()
{
Console
.
WriteLine
(
"Private method called"
);
}
public
void
MethodOverload
()
{
Console
.
WriteLine
(
"Method with no params"
);
}
public
void
MethodOverload
(
TestClass
testClass
)
{
Console
.
WriteLine
(
"Method with testclass param"
);
}
public
void
MethodOverload
(
int
i
,
int
j
,
int
k
)
{
Console
.
WriteLine
(
"Overload without out param: "
+
i
+
", "
+
j
+
", "
+
k
);
}
public
void
MethodOverload
(
int
i
,
int
j
,
out
int
k
)
{
k
=
5
;
Console
.
WriteLine
(
"Overload with out param"
+
i
+
", "
+
j
);
}
}
}
\ No newline at end of file
luainterface/src/LuaInterface.Test/Properties/AssemblyInfo.cs
deleted
100644 → 0
View file @
52119866
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
(
"LuaInterface.Test"
)]
[
assembly
:
AssemblyDescription
(
""
)]
[
assembly
:
AssemblyConfiguration
(
""
)]
[
assembly
:
AssemblyCompany
(
"Microsoft"
)]
[
assembly
:
AssemblyProduct
(
"LuaInterface.Test"
)]
[
assembly
:
AssemblyCopyright
(
"Copyright © Microsoft 2009"
)]
[
assembly
:
AssemblyTrademark
(
""
)]
[
assembly
:
AssemblyCulture
(
""
)]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM componenets. 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
(
"9a3029b1-b0a5-40fc-8b04-a4f471f69afc"
)]
// 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 Revision and Build Numbers
// by using the '*' as shown below:
[
assembly
:
AssemblyVersion
(
"1.0.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.0.0.0"
)]
luainterface/src/LuaInterface.Test/packages.config
deleted
100644 → 0
View file @
52119866
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
package
id
=
"xunit"
version
=
"1.8.0.1545"
/>
<
package
id
=
"Moq"
version
=
"4.0.10827"
/>
</
packages
>
\ No newline at end of file
Prev
1
2
3
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment