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
00eddcac
Commit
00eddcac
authored
Jun 03, 2012
by
Megax
Browse files
* Kisebb modositasok.
parent
a0afbf36
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
KopiLua/lapi.cs
View file @
00eddcac
...
...
@@ -277,8 +277,6 @@ namespace KopiLua
public
static
int
lua_rawequal
(
lua_State
L
,
int
index1
,
int
index2
)
{
StkId
o1
=
index2adr
(
L
,
index1
);
StkId
o2
=
index2adr
(
L
,
index2
);
Console
.
WriteLine
(
"lua_rawequal: {0}"
,
(
o1
==
luaO_nilobject
||
o2
==
luaO_nilobject
));
Console
.
WriteLine
(
"lua_rawequal2: {0}"
,
luaO_rawequalObj
(
o1
,
o2
));
return
(
o1
==
luaO_nilobject
||
o2
==
luaO_nilobject
)
?
0
:
luaO_rawequalObj
(
o1
,
o2
);
}
...
...
@@ -392,11 +390,10 @@ namespace KopiLua
public
static
uint
lua_touserdata2
(
lua_State
L
,
int
idx
)
{
StkId
o
=
index2adr
(
L
,
idx
);
Console
.
WriteLine
(
"x0:{0}"
,
o
);
switch
(
ttype
(
o
))
{
case
LUA_TUSERDATA
:
Console
.
WriteLine
(
"x:{0}"
,
rawuvalue
(
o
).
len
);
return
(
rawuvalue
(
o
).
len
);
case
LUA_TLIGHTUSERDATA
:
Console
.
WriteLine
(
"x2:{0}"
,
rawuvalue
(
o
).
len
);
return
(
rawuvalue
(
o
).
len
);
default
:
Console
.
WriteLine
(
"x3:{0}"
,
0
);
return
0
;
case
LUA_TUSERDATA
:
return
(
rawuvalue
(
o
).
len
);
case
LUA_TLIGHTUSERDATA
:
return
(
rawuvalue
(
o
).
len
);
default
:
return
0
;
}
}
...
...
@@ -556,7 +553,6 @@ namespace KopiLua
}
public
static
void
lua_getfield
(
lua_State
L
,
int
idx
,
CharPtr
k
)
{
Console
.
WriteLine
(
"lllll:{0}"
,
k
);
StkId
t
;
TValue
key
=
new
TValue
();
lua_lock
(
L
);
...
...
@@ -624,7 +620,6 @@ namespace KopiLua
res
=
1
;
}
lua_unlock
(
L
);
Console
.
WriteLine
(
"nulllll: {0}"
,
res
);
return
res
;
}
...
...
@@ -835,7 +830,6 @@ namespace KopiLua
api_checkvalidindex
(
L
,
o
);
func
=
savestack
(
L
,
o
);
}
Console
.
WriteLine
(
"func:{0}"
,
func
);
c
.
func
=
L
.
top
-
(
nargs
+
1
);
/* function to be called */
c
.
nresults
=
nresults
;
status
=
luaD_pcall
(
L
,
f_call
,
c
,
savestack
(
L
,
c
.
func
),
func
);
...
...
KopiLua/lobject.cs
View file @
00eddcac
...
...
@@ -758,7 +758,6 @@ namespace KopiLua
public
static
int
luaO_rawequalObj
(
TValue
t1
,
TValue
t2
)
{
Console
.
WriteLine
(
"luaO_rawequalObj: {0}"
,
ttype
(
t1
)
!=
ttype
(
t2
));
if
(
ttype
(
t1
)
!=
ttype
(
t2
))
return
0
;
else
switch
(
ttype
(
t1
))
{
case
LUA_TNIL
:
...
...
@@ -771,9 +770,6 @@ namespace KopiLua
return
pvalue
(
t1
)
==
pvalue
(
t2
)
?
1
:
0
;
default
:
lua_assert
(
iscollectable
(
t1
));
Console
.
WriteLine
(
"luaO_rawequalObj1-0: {0}"
,
gcvalue
(
t1
));
Console
.
WriteLine
(
"luaO_rawequalObj1-1: {0}"
,
gcvalue
(
t2
));
Console
.
WriteLine
(
"luaO_rawequalObj1: {0}"
,
gcvalue
(
t1
)
==
gcvalue
(
t2
));
return
gcvalue
(
t1
)
==
gcvalue
(
t2
)
?
1
:
0
;
}
}
...
...
KopiLua/lstring.cs
View file @
00eddcac
...
...
@@ -107,7 +107,6 @@ namespace KopiLua
}
//return newlstr(L, str, l, h); /* not found */
TString
res
=
newlstr
(
L
,
str
,
l
,
h
);
Console
.
WriteLine
(
res
);
return
res
;
}
...
...
LuaInterface/Lua.cs
View file @
00eddcac
...
...
@@ -237,11 +237,8 @@ namespace LuaInterface
public
object
[]
DoFile
(
string
fileName
)
{
int
oldTop
=
KopiLua
.
Lua
.
lua_gettop
(
luaState
);
//Console.WriteLine("aaa: {0}",oldTop);
if
(
KopiLua
.
Lua
.
luaL_loadfile
(
luaState
,
fileName
)==
0
)
{
//Console.WriteLine("aaa2: {0}",KopiLua.Lua.lua_pcall(luaState, 0, -1, 0));
//Console.WriteLine("zzzzzzzzzzzzzzzzzz");
if
(
KopiLua
.
Lua
.
lua_pcall
(
luaState
,
0
,
-
1
,
0
)
==
0
)
return
translator
.
popValues
(
luaState
,
oldTop
);
else
...
...
@@ -348,7 +345,8 @@ namespace LuaInterface
public
LuaFunction
GetFunction
(
string
fullPath
)
{
object
obj
=
this
[
fullPath
];
return
(
obj
is
KopiLua
.
Lua
.
lua_CFunction
?
new
LuaFunction
((
KopiLua
.
Lua
.
lua_CFunction
)
obj
,
this
)
:
(
LuaFunction
)
obj
);
//return (obj is KopiLua.Lua.lua_CFunction ? new LuaFunction((KopiLua.Lua.lua_CFunction)obj,this) : (LuaFunction)obj);
return
(
obj
is
KopiLua
.
Lua
.
lua_CFunction
?
new
LuaFunction
((
KopiLua
.
Lua
.
lua_CFunction
)
obj
,
this
)
:
/*(LuaFunction)*/
new
LuaFunction
(
obj
.
GetHashCode
(),
this
));
}
/*
* Gets a function global variable as a delegate of
...
...
@@ -533,7 +531,7 @@ namespace LuaInterface
* Registers an object's method as a Lua function (global or table field)
* The method may have any signature
*/
public
LuaFunction
RegisterFunction
(
string
path
,
object
target
,
MethodInfo
function
)
public
LuaFunction
RegisterFunction
(
string
path
,
object
target
,
MethodInfo
function
)
{
// We leave nothing on the stack when we are done
int
oldTop
=
KopiLua
.
Lua
.
lua_gettop
(
luaState
);
...
...
@@ -545,7 +543,6 @@ namespace LuaInterface
LuaFunction
f
=
GetFunction
(
path
);
KopiLua
.
Lua
.
lua_settop
(
luaState
,
oldTop
);
return
f
;
}
...
...
LuaInterface/LuaLib/LuaLib.cs
View file @
00eddcac
...
...
@@ -270,7 +270,7 @@ namespace LuaWrap
public
static
int
luanet_rawnetobj
(
Lua
.
lua_State
luaState
,
int
obj
)
{
int
udata
=
Convert
.
ToInt32
(
Lua
.
lua_touserdata2
(
luaState
,
obj
)
)
;
int
udata
=
(
int
)
Lua
.
lua_touserdata2
(
luaState
,
obj
);
if
(
udata
!=
0
)
return
udata
;
return
-
1
;
...
...
@@ -284,25 +284,19 @@ namespace LuaWrap
public
static
int
checkudata_raw
(
Lua
.
lua_State
luaState
,
int
ud
,
string
tname
)
{
int
p
=
(
int
)
Lua
.
lua_touserdata2
(
luaState
,
ud
);
Console
.
WriteLine
(
"z:{0}"
,
p
);
if
(
p
!=
0
)
{
/* value is a userdata? */
Console
.
WriteLine
(
"z0:{0}"
,
p
);
//Console.WriteLine("z2:{0}", Lua.lua_getmetatable(luaState, ud));
if
(
Lua
.
lua_getmetatable
(
luaState
,
ud
)!=
0
)
{
/* does it have a metatable? */
Console
.
WriteLine
(
"z1:{0}"
,
p
);
Lua
.
lua_getfield
(
luaState
,
(
int
)
PseudoIndex
.
Registry
,
tname
);
/* get correct metatable */
//Console.WriteLine("z3:{0}", p);
bool
isEqual
=
Lua
.
lua_rawequal
(
luaState
,
-
1
,
-
2
).
ToBoolean
();
Console
.
WriteLine
(
"z2:{0}"
,
p
);
Console
.
WriteLine
(
"z2-1:{0}"
,
isEqual
);
// NASTY - we need our own version of the lua_pop macro
// lua_pop(L, 2); /* remove both metatables */
Lua
.
lua_settop
(
luaState
,
-(
2
)
-
1
);
Console
.
WriteLine
(
"z3:{0}"
,
p
);
if
(
isEqual
)
/* does it have the correct mt? */
return
p
;
}
...
...
@@ -330,29 +324,23 @@ Console.WriteLine("z3:{0}", p);
{
int
udata
;
Console
.
WriteLine
(
"asd:"
+(
Lua
.
lua_type
(
luaState
,
index
).
ToLuaType
()
==
LuaType
.
UserData
).
ToString
());
Console
.
WriteLine
(
"asd:1"
+
Lua
.
lua_type
(
luaState
,
index
));
if
(
Lua
.
lua_type
(
luaState
,
index
).
ToLuaType
()
==
LuaType
.
UserData
)
{
if
(
luaL_checkmetatable
(
luaState
,
index
))
{
udata
=
(
int
)
Lua
.
lua_touserdata2
(
luaState
,
index
);
Console
.
WriteLine
(
"asd0:{0}"
,
udata
);
if
(
udata
!=
0
)
return
udata
;
}
udata
=
checkudata_raw
(
luaState
,
index
,
"luaNet_class"
);
Console
.
WriteLine
(
"asd2:{0}"
,
udata
);
if
(
udata
!=
0
)
return
udata
;
udata
=
checkudata_raw
(
luaState
,
index
,
"luaNet_searchbase"
);
Console
.
WriteLine
(
"asd3:{0}"
,
udata
);
if
(
udata
!=
0
)
return
udata
;
udata
=
checkudata_raw
(
luaState
,
index
,
"luaNet_function"
);
Console
.
WriteLine
(
"asd4:{0}"
,
udata
);
if
(
udata
!=
0
)
return
udata
;
}
...
...
LuaInterface/Metatables.cs
View file @
00eddcac
This diff is collapsed.
Click to expand it.
LuaInterface/MethodWrapper.cs
View file @
00eddcac
...
...
@@ -106,13 +106,15 @@ namespace LuaInterface
object
targetObject
=
target
;
bool
failedCall
=
true
;
int
nReturnValues
=
0
;
Console
.
WriteLine
(
"asyyyyyyyyyyyyyy"
);
if
(!
KopiLua
.
Lua
.
lua_checkstack
(
luaState
,
5
).
ToBoolean
())
throw
new
LuaException
(
"Lua stack overflow"
);
Console
.
WriteLine
(
"asyyyyyyyyyyyyyy1"
);
bool
isStatic
=
(
bindingType
&
BindingFlags
.
Static
)
==
BindingFlags
.
Static
;
Console
.
WriteLine
(
"asyyyyyyyyyyyyyy2"
);
SetPendingException
(
null
);
Console
.
WriteLine
(
"asyyyyyyyyyyyyyy3"
);
Console
.
WriteLine
(
methodToCall
==
null
);
if
(
methodToCall
==
null
)
// Method from name
{
if
(
isStatic
)
...
...
@@ -120,6 +122,9 @@ namespace LuaInterface
else
targetObject
=
extractTarget
(
luaState
,
1
);
//KopiLua.Lua.lua_remove(luaState,1); // Pops the receiver
Console
.
WriteLine
(
"asdxxxxxx"
);
Console
.
WriteLine
(
lastCalledMethod
.
cachedMethod
);
Console
.
WriteLine
(
lastCalledMethod
.
cachedMethod
!=
null
);
if
(
lastCalledMethod
.
cachedMethod
!=
null
)
// Cached?
{
int
numStackToSkip
=
isStatic
?
0
:
1
;
// If this is an instance invoe we will have an extra arg on the stack for the targetObject
...
...
@@ -131,6 +136,8 @@ namespace LuaInterface
throw
new
LuaException
(
"Lua stack overflow"
);
try
{
Console
.
WriteLine
(
"0"
);
Console
.
WriteLine
(
lastCalledMethod
.
argTypes
.
Length
);
for
(
int
i
=
0
;
i
<
lastCalledMethod
.
argTypes
.
Length
;
i
++)
{
lastCalledMethod
.
args
[
lastCalledMethod
.
argTypes
[
i
].
index
]=
...
...
@@ -142,12 +149,14 @@ namespace LuaInterface
throw
new
LuaException
(
"argument number "
+(
i
+
1
)+
" is invalid"
);
}
}
Console
.
WriteLine
(
"asd"
);
if
((
bindingType
&
BindingFlags
.
Static
)==
BindingFlags
.
Static
)
{
translator
.
push
(
luaState
,
lastCalledMethod
.
cachedMethod
.
Invoke
(
null
,
lastCalledMethod
.
args
));
}
else
{
Console
.
WriteLine
(
"asd2"
);
if
(
lastCalledMethod
.
cachedMethod
.
IsConstructor
)
translator
.
push
(
luaState
,((
ConstructorInfo
)
lastCalledMethod
.
cachedMethod
).
Invoke
(
lastCalledMethod
.
args
));
else
...
...
LuaInterface/ObjectTranslator.cs
View file @
00eddcac
...
...
@@ -618,6 +618,7 @@ namespace LuaInterface
if
(
udata
!=-
1
)
return
objects
[
udata
];
else
//return null;
return
getUserData
(
luaState
,
index
);
}
default
:
...
...
@@ -749,7 +750,6 @@ namespace LuaInterface
{
// Make sure we are _really_ ILuaGenerated
Type
typ
=
o
.
GetType
();
return
(
typ
.
GetInterface
(
"ILuaGeneratedType"
)
!=
null
);
}
else
...
...
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