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
b7ad3ad6
"vscode:/vscode.git/clone" did not exist on "e72b6eff0884673997d0ca6385169bbd9b31936d"
Commit
b7ad3ad6
authored
Feb 19, 2013
by
Vinicius Jarina
Browse files
Updated KopiLua hash
Moved luanet functions to KopiLua
parent
5fc72461
Changes
3
Hide whitespace changes
Inline
Side-by-side
KopiLua
@
f86c4bf4
Compare
fa091a6e
...
f86c4bf4
Subproject commit f
a091a6e786c9665dc3d0f491770fa8576e1cf76
Subproject commit f
86c4bf4f9afb2716f80c97c972d6dad24f1cebf
Core/LuaInterface/LuaLib/LuaLib.cs
View file @
b7ad3ad6
...
@@ -33,9 +33,6 @@ namespace LuaInterface
...
@@ -33,9 +33,6 @@ namespace LuaInterface
public
class
LuaLib
public
class
LuaLib
{
{
// Not sure of the purpose of this, but I'm keeping it -kevinh
private
static
object
tag
=
0
;
// steffenj: BEGIN additional Lua API functions new in Lua 5.1
// steffenj: BEGIN additional Lua API functions new in Lua 5.1
public
static
int
lua_gc
(
LuaCore
.
lua_State
luaState
,
GCOptions
what
,
int
data
)
public
static
int
lua_gc
(
LuaCore
.
lua_State
luaState
,
GCOptions
what
,
int
data
)
{
{
...
@@ -283,6 +280,11 @@ namespace LuaInterface
...
@@ -283,6 +280,11 @@ namespace LuaInterface
LuaCore
.
lua_call
(
luaState
,
nArgs
,
nResults
);
LuaCore
.
lua_call
(
luaState
,
nArgs
,
nResults
);
}
}
public
static
void
lua_pushstdcallcfunction
(
LuaCore
.
lua_State
luaState
,
LuaCore
.
lua_CFunction
function
)
{
LuaCore
.
lua_pushstdcallcfunction
(
luaState
,
function
);
}
public
static
int
lua_pcall
(
LuaCore
.
lua_State
luaState
,
int
nArgs
,
int
nResults
,
int
errfunc
)
public
static
int
lua_pcall
(
LuaCore
.
lua_State
luaState
,
int
nArgs
,
int
nResults
,
int
errfunc
)
{
{
return
LuaCore
.
lua_pcall
(
luaState
,
nArgs
,
nResults
,
errfunc
);
return
LuaCore
.
lua_pcall
(
luaState
,
nArgs
,
nResults
,
errfunc
);
...
@@ -336,10 +338,6 @@ namespace LuaInterface
...
@@ -336,10 +338,6 @@ namespace LuaInterface
LuaCore
.
lua_atpanic
(
luaState
,
(
LuaCore
.
lua_CFunction
)
panicf
);
LuaCore
.
lua_atpanic
(
luaState
,
(
LuaCore
.
lua_CFunction
)
panicf
);
}
}
public
static
void
lua_pushstdcallcfunction
(
LuaCore
.
lua_State
luaState
,
LuaCore
.
lua_CFunction
function
)
{
LuaCore
.
lua_pushcfunction
(
luaState
,
function
);
}
public
static
void
lua_pushnumber
(
LuaCore
.
lua_State
luaState
,
double
number
)
public
static
void
lua_pushnumber
(
LuaCore
.
lua_State
luaState
,
double
number
)
{
{
...
@@ -392,130 +390,55 @@ namespace LuaInterface
...
@@ -392,130 +390,55 @@ namespace LuaInterface
return
LuaCore
.
luaL_loadfile
(
luaState
,
filename
);
return
LuaCore
.
luaL_loadfile
(
luaState
,
filename
);
}
}
public
static
void
lua_error
(
LuaCore
.
lua_State
luaState
)
public
static
bool
luaL_checkmetatable
(
LuaCore
.
lua_State
luaState
,
int
index
)
{
LuaCore
.
lua_error
(
luaState
);
}
public
static
bool
lua_checkstack
(
LuaCore
.
lua_State
luaState
,
int
extra
)
{
{
return
LuaCore
.
lua_check
stack
(
luaState
,
extra
)
!=
0
;
return
LuaCore
.
lua
L
_check
metatable
(
luaState
,
index
)
;
}
}
public
static
int
lua
_nex
t
(
LuaCore
.
lua_State
luaState
,
int
index
)
public
static
int
lua
net_tonetobjec
t
(
LuaCore
.
lua_State
luaState
,
int
index
)
{
{
return
LuaCore
.
lua
_nex
t
(
luaState
,
index
);
return
LuaCore
.
lua
net_tonetobjec
t
(
luaState
,
index
);
}
}
public
static
void
lua
_pushlightuser
data
(
LuaCore
.
lua_State
luaState
,
object
udata
)
public
static
void
lua
net_newu
data
(
LuaCore
.
lua_State
luaState
,
int
val
)
{
{
LuaCore
.
lua
_pushlightuser
data
(
luaState
,
udata
);
LuaCore
.
lua
net_newu
data
(
luaState
,
val
);
}
}
public
static
int
luanet_rawnetobj
(
LuaCore
.
lua_State
luaState
,
int
obj
)
public
static
int
luanet_rawnetobj
(
LuaCore
.
lua_State
luaState
,
int
obj
)
{
{
byte
[]
bytes
=
lua_touserdata
(
luaState
,
obj
)
as
byte
[];
return
LuaCore
.
luanet_rawnetobj
(
luaState
,
obj
);
return
fourBytesToInt
(
bytes
);
}
// Starting with 5.1 the auxlib version of checkudata throws an exception if the type isn't right
// Instead, we want to run our own version that checks the type and just returns null for failure
private
static
object
checkudata_raw
(
LuaCore
.
lua_State
L
,
int
ud
,
string
tname
)
{
object
p
=
LuaCore
.
lua_touserdata
(
L
,
ud
);
if
(
p
!=
null
)
{
/* value is a userdata? */
if
(
LuaCore
.
lua_getmetatable
(
L
,
ud
)
!=
0
)
{
bool
isEqual
;
/* does it have a metatable? */
LuaCore
.
lua_getfield
(
L
,
(
int
)
LuaIndexes
.
Registry
,
tname
);
/* get correct metatable */
isEqual
=
LuaCore
.
lua_rawequal
(
L
,
-
1
,
-
2
)
!=
0
;
// NASTY - we need our own version of the lua_pop macro
// lua_pop(L, 2); /* remove both metatables */
LuaCore
.
lua_settop
(
L
,
-(
2
)
-
1
);
if
(
isEqual
)
/* does it have the correct mt? */
return
p
;
}
}
return
null
;
}
}
public
static
int
luanet_checkudata
(
LuaCore
.
lua_State
luaState
,
int
ud
,
string
tname
)
public
static
int
luanet_checkudata
(
LuaCore
.
lua_State
luaState
,
int
ud
,
string
tname
)
{
{
object
udata
=
checkudata_raw
(
luaState
,
ud
,
tname
);
return
LuaCore
.
luanet_checkudata
(
luaState
,
ud
,
tname
);
return
!
udata
.
IsNull
()
?
fourBytesToInt
(
udata
as
byte
[])
:
-
1
;
}
}
public
static
bool
luaL_checkmetatable
(
LuaCore
.
lua_State
luaState
,
int
index
)
public
static
void
lua_error
(
LuaCore
.
lua_State
luaState
)
{
{
bool
retVal
=
false
;
LuaCore
.
lua_error
(
luaState
);
if
(
lua_getmetatable
(
luaState
,
index
)
!=
0
)
{
lua_pushlightuserdata
(
luaState
,
tag
);
lua_rawget
(
luaState
,
-
2
);
retVal
=
!
lua_isnil
(
luaState
,
-
1
);
lua_settop
(
luaState
,
-
3
);
}
return
retVal
;
}
}
public
static
object
luanet_gettag
(
)
public
static
bool
lua_checkstack
(
LuaCore
.
lua_State
luaState
,
int
extra
)
{
{
return
tag
;
return
LuaCore
.
lua_checkstack
(
luaState
,
extra
)
!=
0
;
}
}
public
static
void
luanet_newudata
(
LuaCore
.
lua_State
luaState
,
int
val
)
public
static
int
lua_next
(
LuaCore
.
lua_State
luaState
,
int
index
)
{
{
var
userdata
=
lua_newuserdata
(
luaState
,
sizeof
(
int
))
as
byte
[];
return
LuaCore
.
lua_next
(
luaState
,
index
);
intToFourBytes
(
val
,
userdata
);
}
}
public
static
int
luanet_tonetobject
(
LuaCore
.
lua_State
luaState
,
int
index
)
public
static
void
lua_pushlightuserdata
(
LuaCore
.
lua_State
luaState
,
LuaCore
.
LuaTag
udata
)
{
{
byte
[]
udata
;
LuaCore
.
lua_pushlightuserdata
(
luaState
,
udata
);
if
(
lua_type
(
luaState
,
index
)
==
LuaTypes
.
UserData
)
{
if
(
luaL_checkmetatable
(
luaState
,
index
))
{
udata
=
lua_touserdata
(
luaState
,
index
)
as
byte
[];
if
(!
udata
.
IsNull
())
return
fourBytesToInt
(
udata
);
}
udata
=
checkudata_raw
(
luaState
,
index
,
"luaNet_class"
)
as
byte
[];
if
(!
udata
.
IsNull
())
return
fourBytesToInt
(
udata
);
udata
=
checkudata_raw
(
luaState
,
index
,
"luaNet_searchbase"
)
as
byte
[];
if
(!
udata
.
IsNull
())
return
fourBytesToInt
(
udata
);
udata
=
checkudata_raw
(
luaState
,
index
,
"luaNet_function"
)
as
byte
[];
if
(!
udata
.
IsNull
())
return
fourBytesToInt
(
udata
);
}
return
-
1
;
}
}
p
rivate
static
int
fourBytesToInt
(
byte
[]
bytes
)
p
ublic
static
LuaCore
.
LuaTag
luanet_gettag
(
)
{
{
return
bytes
[
0
]
+
(
bytes
[
1
]
<<
8
)
+
(
bytes
[
2
]
<<
16
)
+
(
bytes
[
3
]
<<
24
);
return
LuaCore
.
luanet_gettag
(
);
}
}
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
);
}
}
}
}
}
\ No newline at end of file
ios/LuaInterfaceTest/LuaInterfaceTest.csproj
View file @
b7ad3ad6
...
@@ -21,8 +21,10 @@
...
@@ -21,8 +21,10 @@
<ErrorReport>
prompt
</ErrorReport>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
<WarningLevel>
4
</WarningLevel>
<ConsolePause>
False
</ConsolePause>
<ConsolePause>
False
</ConsolePause>
<MtouchLink>
None
</MtouchLink>
<MtouchLink>
Full
</MtouchLink>
<MtouchDebug>
True
</MtouchDebug>
<MtouchDebug>
True
</MtouchDebug>
<MtouchI18n
/>
<MtouchArch>
ARMv7
</MtouchArch>
</PropertyGroup>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' "
>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' "
>
<DebugType>
none
</DebugType>
<DebugType>
none
</DebugType>
...
@@ -31,7 +33,9 @@
...
@@ -31,7 +33,9 @@
<ErrorReport>
prompt
</ErrorReport>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
<WarningLevel>
4
</WarningLevel>
<ConsolePause>
False
</ConsolePause>
<ConsolePause>
False
</ConsolePause>
<MtouchLink>
None
</MtouchLink>
<MtouchLink>
Full
</MtouchLink>
<MtouchI18n
/>
<MtouchArch>
ARMv7
</MtouchArch>
</PropertyGroup>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Debug|iPhone' "
>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Debug|iPhone' "
>
<DebugSymbols>
True
</DebugSymbols>
<DebugSymbols>
True
</DebugSymbols>
...
...
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