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
05ba53d3
Commit
05ba53d3
authored
Jun 21, 2012
by
Megax
Browse files
* Javitasok kerultek be a kodba gfoot repo-bol.
parent
b5b573a3
Changes
33
Show whitespace changes
Inline
Side-by-side
Core/KopiLua/luaconf.cs
View file @
05ba53d3
...
...
@@ -849,6 +849,7 @@ namespace KopiLua
public
static
char
tolower
(
int
c
)
{
return
Char
.
ToLower
((
char
)
c
);
}
public
static
char
toupper
(
int
c
)
{
return
Char
.
ToUpper
((
char
)
c
);
}
[
CLSCompliantAttribute
(
false
)]
public
static
ulong
strtoul
(
CharPtr
s
,
out
CharPtr
end
,
int
base_
)
{
try
...
...
@@ -1038,6 +1039,8 @@ namespace KopiLua
get
{
return
chars
[
index
+
offset
];
}
set
{
chars
[
index
+
offset
]
=
value
;
}
}
[
CLSCompliantAttribute
(
false
)]
public
char
this
[
uint
offset
]
{
get
{
return
chars
[
index
+
offset
];
}
...
...
@@ -1096,7 +1099,9 @@ namespace KopiLua
public
static
CharPtr
operator
+(
CharPtr
ptr
,
int
offset
)
{
return
new
CharPtr
(
ptr
.
chars
,
ptr
.
index
+
offset
);}
public
static
CharPtr
operator
-(
CharPtr
ptr
,
int
offset
)
{
return
new
CharPtr
(
ptr
.
chars
,
ptr
.
index
-
offset
);}
[
CLSCompliantAttribute
(
false
)]
public
static
CharPtr
operator
+(
CharPtr
ptr
,
uint
offset
)
{
return
new
CharPtr
(
ptr
.
chars
,
ptr
.
index
+
(
int
)
offset
);
}
[
CLSCompliantAttribute
(
false
)]
public
static
CharPtr
operator
-(
CharPtr
ptr
,
uint
offset
)
{
return
new
CharPtr
(
ptr
.
chars
,
ptr
.
index
-
(
int
)
offset
);
}
public
void
inc
()
{
this
.
index
++;
}
...
...
@@ -1157,6 +1162,7 @@ namespace KopiLua
}
}
[
CLSCompliantAttribute
(
false
)]
public
static
int
memcmp
(
CharPtr
ptr1
,
CharPtr
ptr2
,
uint
size
)
{
return
memcmp
(
ptr1
,
ptr2
,
(
int
)
size
);
}
public
static
int
memcmp
(
CharPtr
ptr1
,
CharPtr
ptr2
,
int
size
)
{
...
...
@@ -1171,6 +1177,7 @@ namespace KopiLua
return
0
;
}
[
CLSCompliantAttribute
(
false
)]
public
static
CharPtr
memchr
(
CharPtr
ptr
,
char
c
,
uint
count
)
{
for
(
uint
i
=
0
;
i
<
count
;
i
++)
...
...
@@ -1229,6 +1236,7 @@ namespace KopiLua
return
dst
;
}
[
CLSCompliantAttribute
(
false
)]
public
static
uint
strcspn
(
CharPtr
str
,
CharPtr
charset
)
{
int
index
=
str
.
ToString
().
IndexOfAny
(
charset
.
ToString
().
ToCharArray
());
...
...
@@ -1512,6 +1520,7 @@ namespace KopiLua
return
0
;
}
[
CLSCompliantAttribute
(
false
)]
public
static
int
setvbuf
(
Stream
stream
,
CharPtr
buffer
,
int
mode
,
uint
size
)
{
Debug
.
Assert
(
false
,
"setvbuf not implemented yet - mjf"
);
...
...
@@ -1536,6 +1545,7 @@ namespace KopiLua
dst
[
i
]
=
src
[
srcofs
+
i
];
}
[
CLSCompliantAttribute
(
false
)]
public
static
void
memcpy
(
CharPtr
ptr1
,
CharPtr
ptr2
,
uint
size
)
{
memcpy
(
ptr1
,
ptr2
,
(
int
)
size
);
}
public
static
void
memcpy
(
CharPtr
ptr1
,
CharPtr
ptr2
,
int
size
)
{
...
...
@@ -1546,10 +1556,14 @@ namespace KopiLua
public
static
object
VOID
(
object
f
)
{
return
f
;
}
public
const
double
HUGE_VAL
=
System
.
Double
.
MaxValue
;
[
CLSCompliantAttribute
(
false
)]
public
const
uint
SHRT_MAX
=
System
.
UInt16
.
MaxValue
;
[
CLSCompliantAttribute
(
false
)]
public
const
int
_IONBF
=
0
;
[
CLSCompliantAttribute
(
false
)]
public
const
int
_IOFBF
=
1
;
[
CLSCompliantAttribute
(
false
)]
public
const
int
_IOLBF
=
2
;
public
const
int
SEEK_SET
=
0
;
...
...
Core/KopiLua/lvm.cs
View file @
05ba53d3
...
...
@@ -20,6 +20,7 @@ namespace KopiLua
public
partial
class
Lua
{
[
CLSCompliantAttribute
(
false
)]
public
static
int
tostring
(
lua_State
L
,
StkId
o
)
{
return
((
ttype
(
o
)
==
LUA_TSTRING
)
||
(
luaV_tostring
(
L
,
o
)
!=
0
))
?
1
:
0
;
}
...
...
@@ -372,6 +373,7 @@ namespace KopiLua
//#define Protect(x) { L.savedpc = pc; {x;}; base = L.base_; }
[
CLSCompliantAttribute
(
false
)]
public
static
void
arith_op
(
lua_State
L
,
op_delegate
op
,
TMS
tm
,
StkId
base_
,
Instruction
i
,
TValue
[]
k
,
StkId
ra
,
InstructionPtr
pc
)
{
TValue
rb
=
RKB
(
L
,
base_
,
i
,
k
);
TValue
rc
=
RKC
(
L
,
base_
,
i
,
k
);
...
...
Core/KopiLua/lzio.cs
View file @
05ba53d3
...
...
@@ -35,7 +35,9 @@ namespace KopiLua
public
class
Mbuffer
{
public
CharPtr
buffer
=
new
CharPtr
();
[
CLSCompliantAttribute
(
false
)]
public
uint
n
;
[
CLSCompliantAttribute
(
false
)]
public
uint
buffsize
;
};
...
...
@@ -45,7 +47,9 @@ namespace KopiLua
}
public
static
CharPtr
luaZ_buffer
(
Mbuffer
buff
)
{
return
buff
.
buffer
;}
[
CLSCompliantAttribute
(
false
)]
public
static
uint
luaZ_sizebuffer
(
Mbuffer
buff
)
{
return
buff
.
buffsize
;
}
[
CLSCompliantAttribute
(
false
)]
public
static
uint
luaZ_bufflen
(
Mbuffer
buff
)
{
return
buff
.
n
;}
public
static
void
luaZ_resetbuffer
(
Mbuffer
buff
)
{
buff
.
n
=
0
;}
...
...
@@ -65,8 +69,10 @@ namespace KopiLua
/* --------- Private Part ------------------ */
public
class
Zio
{
[
CLSCompliantAttribute
(
false
)]
public
uint
n
;
/* bytes still unread */
public
CharPtr
p
;
/* current position in buffer */
[
CLSCompliantAttribute
(
false
)]
public
lua_Reader
reader
;
public
object
data
;
/* additional data */
public
lua_State
L
;
/* Lua state (for reader) */
...
...
@@ -101,7 +107,7 @@ namespace KopiLua
return
char2int
(
z
.
p
[
0
]);
}
[
CLSCompliantAttribute
(
false
)]
public
static
void
luaZ_init
(
lua_State
L
,
ZIO
z
,
lua_Reader
reader
,
object
data
)
{
z
.
L
=
L
;
...
...
@@ -113,6 +119,7 @@ namespace KopiLua
/* --------------------------------------------------------------- read --- */
[
CLSCompliantAttribute
(
false
)]
public
static
uint
luaZ_read
(
ZIO
z
,
CharPtr
b
,
uint
n
)
{
b
=
new
CharPtr
(
b
);
while
(
n
!=
0
)
{
...
...
@@ -130,6 +137,7 @@ namespace KopiLua
}
/* ------------------------------------------------------------------------ */
[
CLSCompliantAttribute
(
false
)]
public
static
CharPtr
luaZ_openspace
(
lua_State
L
,
Mbuffer
buff
,
uint
n
)
{
if
(
n
>
buff
.
buffsize
)
{
if
(
n
<
LUA_MINBUFFER
)
n
=
LUA_MINBUFFER
;
...
...
Core/KopiLua/printf/Tools.cs
View file @
05ba53d3
...
...
@@ -471,7 +471,7 @@ namespace AT.MIN
#
endregion
#
region
s
-
string
case
's'
:
// string
string
t
=
"{0"
+
(
fieldLength
!=
int
.
MinValue
?
","
+
(
flagLeft2Right
?
"-"
:
String
.
Empty
)
+
fieldLength
.
ToString
()
:
String
.
Empty
)
+
":s}"
;
//
string t = "{0" + ( fieldLength != int.MinValue ? "," + ( flagLeft2Right ? "-" : String.Empty ) + fieldLength.ToString() : String.Empty ) + ":s}";
w
=
o
.
ToString
();
if
(
fieldPrecision
>=
0
)
w
=
w
.
Substring
(
0
,
fieldPrecision
);
...
...
Core/LuaInterface/Lua.cs
View file @
05ba53d3
...
...
@@ -87,7 +87,7 @@ namespace LuaInterface
/// <summary>
/// Used to ensure multiple .net threads all get serialized by this single lock for access to the lua stack/objects
/// </summary>
private
object
luaLock
=
new
object
();
//
private object luaLock = new object();
private
bool
_StatePassed
;
private
bool
executing
;
...
...
Core/LuaInterface/LuaBase.cs
View file @
05ba53d3
...
...
@@ -35,7 +35,9 @@ namespace LuaInterface
public
abstract
class
LuaBase
:
IDisposable
{
private
bool
_Disposed
;
[
CLSCompliantAttribute
(
false
)]
protected
int
_Reference
;
[
CLSCompliantAttribute
(
false
)]
protected
Lua
_Interpreter
;
~
LuaBase
()
...
...
Core/LuaInterface/LuaLib/LuaLib.cs
View file @
05ba53d3
...
...
@@ -143,7 +143,8 @@ namespace LuaInterface
public
static
int
luanet_rawnetobj
(
LuaCore
.
lua_State
luaState
,
int
obj
)
{
int
udata
=
(
int
)
LuaCore
.
lua_touserdata2
(
luaState
,
obj
);
//int udata = (int)LuaCore.lua_touserdata2(luaState, obj);
int
udata
=
fourBytesToInt
(
LuaCore
.
lua_touserdata
(
luaState
,
obj
)
as
byte
[]);
return
udata
!=
0
?
udata
:
-
1
;
}
...
...
@@ -154,7 +155,9 @@ namespace LuaInterface
public
static
int
checkudata_raw
(
LuaCore
.
lua_State
luaState
,
int
ud
,
string
tname
)
{
int
p
=
(
int
)
LuaCore
.
lua_touserdata2
(
luaState
,
ud
);
//int p = (int)LuaCore.lua_touserdata2(luaState, ud);
int
p
=
fourBytesToInt
(
LuaCore
.
lua_touserdata
(
luaState
,
ud
)
as
byte
[]);
Console
.
WriteLine
(
"asddddd:"
+
p
.
ToString
());
if
(
p
!=
0
)
{
...
...
@@ -163,6 +166,12 @@ namespace LuaInterface
{
/* does it have a metatable? */
LuaCore
.
lua_getfield
(
luaState
,
(
int
)
PseudoIndex
.
Registry
,
tname
);
/* get correct metatable */
Console
.
Write
(
"valami:"
);
Console
.
Write
(
LuaCore
.
lua_rawequal
(
luaState
,
-
1
,
-
2
)
!=
0
);
Console
.
Write
(
"\n"
);
Console
.
Write
(
"valami2:"
);
Console
.
Write
(
LuaCore
.
lua_rawequal
(
luaState
,
-
1
,
-
2
).
ToBoolean
());
Console
.
Write
(
"\n"
);
bool
isEqual
=
LuaCore
.
lua_rawequal
(
luaState
,
-
1
,
-
2
).
ToBoolean
();
// NASTY - we need our own version of the lua_pop macro
...
...
@@ -185,7 +194,9 @@ namespace LuaInterface
public
static
void
luanet_newudata
(
LuaCore
.
lua_State
luaState
,
int
val
)
{
LuaCore
.
lua_newuserdata
(
luaState
,
(
uint
)
val
);
//LuaCore.lua_newuserdata(luaState, (uint)val);
byte
[]
userdata
=
LuaCore
.
lua_newuserdata
(
luaState
,
sizeof
(
int
))
as
byte
[];
intToFourBytes
(
val
,
userdata
);
}
public
static
int
luanet_tonetobject
(
LuaCore
.
lua_State
luaState
,
int
index
)
...
...
@@ -197,7 +208,7 @@ namespace LuaInterface
{
if
(
luaL_checkmetatable
(
luaState
,
index
))
{
udata
=
(
i
nt
)
LuaCore
.
lua_touserdata
2
(
luaState
,
index
);
udata
=
fourBytesToI
nt
(
LuaCore
.
lua_touserdata
(
luaState
,
index
)
as
byte
[])
;
if
(
udata
!=
0
)
return
udata
;
}
...
...
@@ -222,6 +233,21 @@ namespace LuaInterface
{
return
lockRef
!=
0
?
LuaCore
.
luaL_ref
(
luaState
,
(
int
)
PseudoIndex
.
Registry
)
:
0
;
}
private
static
int
fourBytesToInt
(
byte
[]
bytes
)
{
Console
.
WriteLine
(
"tömb:"
+
bytes
.
Length
.
ToString
());
return
bytes
[
0
]
+
(
bytes
[
1
]
<<
8
)
+
(
bytes
[
2
]
<<
16
)
+
(
bytes
[
3
]
<<
24
);
}
private
static
void
intToFourBytes
(
int
val
,
byte
[]
bytes
)
{
// gfoot: is this really a good idea?
bytes
[
0
]
=
(
byte
)
val
;
bytes
[
1
]
=
(
byte
)(
val
>>
8
);
bytes
[
2
]
=
(
byte
)(
val
>>
16
);
bytes
[
3
]
=
(
byte
)(
val
>>
24
);
}
#
endregion
}
}
\ No newline at end of file
Core/LuaInterface/Method/LuaMethodWrapper.cs
View file @
05ba53d3
...
...
@@ -248,7 +248,7 @@ namespace LuaInterface.Method
{
if
(
methodToCall
.
ContainsGenericParameters
)
{
bool
isMethod
=
_Translator
.
matchParameters
(
luaState
,
methodToCall
,
ref
_LastCalledMethod
);
/*
bool isMethod =
*/
_Translator
.
matchParameters
(
luaState
,
methodToCall
,
ref
_LastCalledMethod
);
if
(
methodToCall
.
IsGenericMethodDefinition
)
{
...
...
Core/LuaInterface/Properties/AssemblyInfo.cs
View file @
05ba53d3
...
...
@@ -43,7 +43,7 @@ using System.Runtime.InteropServices;
[
assembly
:
AssemblyCopyright
(
"Copyright 2003-2008 Fabio Mascarenhas, Kevin Hesterm and 2012 Megax"
)]
//[assembly: AssemblyTrademark("")]
//
[assembly: CLSCompliant(true)]
[
assembly
:
CLSCompliant
(
true
)]
// 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
...
...
Test/LuaInterface.Test/LuaTests.cs
View file @
05ba53d3
...
...
@@ -55,7 +55,7 @@ namespace LuaInterface.Test
//failed
Assert
.
True
(
false
);
}
catch
(
Exception
e
)
catch
(
Exception
/* e*/
)
{
//passed
Assert
.
True
(
true
);
...
...
@@ -160,7 +160,7 @@ namespace LuaInterface.Test
lua
.
DoString
(
"function calcVP(a,b) return a+b end"
);
LuaFunction
lf
=
lua
.
GetFunction
(
"calcVP"
);
Object
[]
ret
=
lf
.
Call
(
i
,
20
);
/*
Object[] ret =
*/
lf
.
Call
(
i
,
20
);
}
[
Fact
]
...
...
@@ -347,7 +347,7 @@ namespace LuaInterface.Test
//failed
Assert
.
True
(
false
);
}
catch
(
LuaException
e
)
catch
(
LuaException
/* e*/
)
{
//passed
Assert
.
True
(
true
);
...
...
Test/LuaInterface.Test/Mock/TestLua.cs
View file @
05ba53d3
...
...
@@ -64,7 +64,7 @@ namespace LuaInterface.Test.Mock
/// </summary>
class
DoWorkClass
{
private
object
_Lock
=
new
object
();
//
private object _Lock = new object();
public
void
DoWork
()
{
...
...
Test/TestLuaInterface/TestLua.cs
View file @
05ba53d3
...
...
@@ -62,7 +62,7 @@ namespace LuaInterface.Tests
/// </summary>
class
DoWorkClass
{
private
object
_Lock
=
new
object
();
//
private object _Lock = new object();
public
void
DoWork
()
{
...
...
Test/TestLuaInterface/TestLuaInterface.cs
View file @
05ba53d3
...
...
@@ -1107,7 +1107,7 @@ namespace LuaInterface.Tests
lua
.
DoString
(
"function calcVP(a,b) return a+b end"
);
LuaFunction
lf
=
lua
.
GetFunction
(
"calcVP"
);
Object
[]
ret
=
lf
.
Call
(
i
,
20
);
/*
Object[] ret =
*/
lf
.
Call
(
i
,
20
);
}
private
void
TestThreading
()
...
...
Prev
1
2
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