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
Hide whitespace changes
Inline
Side-by-side
Core/KopiLua/KopiLua.csproj
View file @
05ba53d3
...
...
@@ -22,6 +22,7 @@
<WarningLevel>
4
</WarningLevel>
<PlatformTarget>
x86
</PlatformTarget>
<CodeAnalysisRuleSet>
AllRules.ruleset
</CodeAnalysisRuleSet>
<NoWarn>
3001;
</NoWarn>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Release|x86' "
>
<DebugType>
none
</DebugType>
...
...
Core/KopiLua/Properties/AssemblyInfo.cs
View file @
05ba53d3
using
System.Reflection
;
using
System
;
using
System.Reflection
;
using
System.Runtime.CompilerServices
;
using
System.Runtime.InteropServices
;
...
...
@@ -14,6 +15,8 @@ using System.Runtime.InteropServices;
[
assembly
:
AssemblyTrademark
(
""
)]
[
assembly
:
AssemblyCulture
(
""
)]
[
assembly
:
CLSCompliantAttribute
(
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
// COM, set the ComVisible attribute to true on that type.
...
...
Core/KopiLua/lapi.cs
View file @
05ba53d3
...
...
@@ -337,6 +337,7 @@ namespace KopiLua
return
(
l_isfalse
(
o
)
==
0
)
?
1
:
0
;
}
[
CLSCompliantAttribute
(
false
)]
public
static
CharPtr
lua_tolstring
(
lua_State
L
,
int
idx
,
out
uint
len
)
{
StkId
o
=
index2adr
(
L
,
idx
);
if
(!
ttisstring
(
o
))
{
...
...
@@ -354,7 +355,7 @@ namespace KopiLua
return
svalue
(
o
);
}
[
CLSCompliantAttribute
(
false
)]
public
static
uint
lua_objlen
(
lua_State
L
,
int
idx
)
{
StkId
o
=
index2adr
(
L
,
idx
);
switch
(
ttype
(
o
))
{
...
...
@@ -388,16 +389,6 @@ namespace KopiLua
}
}
public
static
uint
lua_touserdata2
(
lua_State
L
,
int
idx
)
{
StkId
o
=
index2adr
(
L
,
idx
);
switch
(
ttype
(
o
))
{
case
LUA_TUSERDATA
:
return
(
rawuvalue
(
o
).
len
);
case
LUA_TLIGHTUSERDATA
:
return
(
rawuvalue
(
o
).
len
);
default
:
return
0
;
}
}
public
static
lua_State
lua_tothread
(
lua_State
L
,
int
idx
)
{
StkId
o
=
index2adr
(
L
,
idx
);
return
(!
ttisthread
(
o
))
?
null
:
thvalue
(
o
);
...
...
@@ -447,7 +438,7 @@ namespace KopiLua
lua_unlock
(
L
);
}
[
CLSCompliantAttribute
(
false
)]
public
static
void
lua_pushlstring
(
lua_State
L
,
CharPtr
s
,
uint
len
)
{
lua_lock
(
L
);
luaC_checkGC
(
L
);
...
...
@@ -873,7 +864,7 @@ namespace KopiLua
return
status
;
}
[
CLSCompliantAttribute
(
false
)]
public
static
int
lua_load
(
lua_State
L
,
lua_Reader
reader
,
object
data
,
CharPtr
chunkname
)
{
ZIO
z
=
new
ZIO
();
...
...
@@ -886,7 +877,7 @@ namespace KopiLua
return
status
;
}
[
CLSCompliantAttribute
(
false
)]
public
static
int
lua_dump
(
lua_State
L
,
lua_Writer
writer
,
object
data
)
{
int
status
;
TValue
o
;
...
...
@@ -1038,7 +1029,7 @@ namespace KopiLua
lua_unlock
(
L
);
}
[
CLSCompliantAttribute
(
false
)]
public
static
object
lua_newuserdata
(
lua_State
L
,
uint
size
)
{
Udata
u
;
...
...
Core/KopiLua/lauxlib.cs
View file @
05ba53d3
...
...
@@ -269,6 +269,8 @@ namespace KopiLua
public
static
CharPtr
luaL_checklstring
(
lua_State
L
,
int
narg
)
{
uint
len
;
return
luaL_checklstring
(
L
,
narg
,
out
len
);}
[
CLSCompliantAttribute
(
false
)]
public
static
CharPtr
luaL_checklstring
(
lua_State
L
,
int
narg
,
out
uint
len
)
{
CharPtr
s
=
lua_tolstring
(
L
,
narg
,
out
len
);
if
(
s
==
null
)
tag_error
(
L
,
narg
,
LUA_TSTRING
);
...
...
@@ -278,6 +280,8 @@ namespace KopiLua
public
static
CharPtr
luaL_optlstring
(
lua_State
L
,
int
narg
,
CharPtr
def
)
{
uint
len
;
return
luaL_optlstring
(
L
,
narg
,
def
,
out
len
);
}
[
CLSCompliantAttribute
(
false
)]
public
static
CharPtr
luaL_optlstring
(
lua_State
L
,
int
narg
,
CharPtr
def
,
out
uint
len
)
{
if
(
lua_isnoneornil
(
L
,
narg
))
{
len
=
(
uint
)((
def
!=
null
)
?
strlen
(
def
)
:
0
);
...
...
@@ -546,7 +550,7 @@ namespace KopiLua
return
new
CharPtr
(
B
.
buffer
,
B
.
p
);
}
[
CLSCompliantAttribute
(
false
)]
public
static
void
luaL_addlstring
(
luaL_Buffer
B
,
CharPtr
s
,
uint
l
)
{
while
(
l
--
!=
0
)
{
...
...
@@ -646,7 +650,7 @@ namespace KopiLua
public
CharPtr
buff
=
new
char
[
LUAL_BUFFERSIZE
];
};
[
CLSCompliantAttribute
(
false
)]
public
static
CharPtr
getF
(
lua_State
L
,
object
ud
,
out
uint
size
)
{
size
=
0
;
LoadF
lf
=
(
LoadF
)
ud
;
...
...
@@ -714,6 +718,7 @@ namespace KopiLua
public
class
LoadS
{
public
CharPtr
s
;
[
CLSCompliantAttribute
(
false
)]
public
uint
size
;
};
...
...
@@ -727,7 +732,7 @@ namespace KopiLua
return
ls
.
s
;
}
[
CLSCompliantAttribute
(
false
)]
public
static
int
luaL_loadbuffer
(
lua_State
L
,
CharPtr
buff
,
uint
size
,
CharPtr
name
)
{
LoadS
ls
=
new
LoadS
();
...
...
Core/KopiLua/lcode.cs
View file @
05ba53d3
...
...
@@ -17,10 +17,12 @@ namespace KopiLua
public
class
InstructionPtr
{
[
CLSCompliantAttribute
(
false
)]
public
Instruction
[]
codes
;
public
int
pc
;
public
InstructionPtr
()
{
this
.
codes
=
null
;
;
this
.
pc
=
-
1
;
}
[
CLSCompliantAttribute
(
false
)]
public
InstructionPtr
(
Instruction
[]
codes
,
int
pc
)
{
this
.
codes
=
codes
;
this
.
pc
=
pc
;
}
public
static
InstructionPtr
Assign
(
InstructionPtr
ptr
)
...
...
@@ -28,6 +30,7 @@ namespace KopiLua
if
(
ptr
==
null
)
return
null
;
return
new
InstructionPtr
(
ptr
.
codes
,
ptr
.
pc
);
}
[
CLSCompliantAttribute
(
false
)]
public
Instruction
this
[
int
index
]
{
get
{
return
this
.
codes
[
pc
+
index
];
}
...
...
Core/KopiLua/ldebug.cs
View file @
05ba53d3
...
...
@@ -279,6 +279,7 @@ namespace KopiLua
public
static
int
checkopenop
(
Proto
pt
,
int
pc
)
{
return
luaG_checkopenop
(
pt
.
code
[
pc
+
1
]);
}
[
CLSCompliantAttribute
(
false
)]
public
static
int
luaG_checkopenop
(
Instruction
i
)
{
switch
(
GET_OPCODE
(
i
))
{
case
OpCode
.
OP_CALL
:
...
...
Core/KopiLua/ldo.cs
View file @
05ba53d3
...
...
@@ -80,6 +80,7 @@ namespace KopiLua
public
class
lua_longjmp
{
public
lua_longjmp
previous
;
public
luai_jmpbuf
b
;
[
CLSCompliantAttribute
(
false
)]
public
volatile
int
status
;
/* error code */
};
...
...
@@ -526,7 +527,7 @@ namespace KopiLua
return
status
;
}
[
CLSCompliantAttribute
(
false
)]
public
static
int
lua_yield
(
lua_State
L
,
int
nresults
)
{
luai_userstateyield
(
L
,
nresults
);
lua_lock
(
L
);
...
...
Core/KopiLua/ldump.cs
View file @
05ba53d3
...
...
@@ -22,6 +22,7 @@ namespace KopiLua
{
public
class
DumpState
{
public
lua_State
L
;
[
CLSCompliantAttribute
(
false
)]
public
lua_Writer
writer
;
public
object
data
;
public
int
strip
;
...
...
@@ -186,6 +187,7 @@ namespace KopiLua
/*
** dump Lua function as precompiled chunk
*/
[
CLSCompliantAttribute
(
false
)]
public
static
int
luaU_dump
(
lua_State
L
,
Proto
f
,
lua_Writer
w
,
object
data
,
int
strip
)
{
DumpState
D
=
new
DumpState
();
...
...
Core/KopiLua/lgc.cs
View file @
05ba53d3
...
...
@@ -110,6 +110,7 @@ namespace KopiLua
public
static
void
luaC_objbarriert
(
lua_State
L
,
Table
t
,
object
o
)
{
if
(
iswhite
(
obj2gco
(
o
))
&&
isblack
(
obj2gco
(
t
)))
luaC_barrierback
(
L
,
t
);
}
[
CLSCompliantAttribute
(
false
)]
public
const
uint
GCSTEPSIZE
=
1024
;
public
const
int
GCSWEEPMAX
=
40
;
public
const
int
GCSWEEPCOST
=
10
;
...
...
@@ -224,6 +225,7 @@ namespace KopiLua
/* move `dead' udata that need finalization to list `tmudata' */
[
CLSCompliantAttribute
(
false
)]
public
static
uint
luaC_separateudata
(
lua_State
L
,
int
all
)
{
global_State
g
=
G
(
L
);
uint
deadmem
=
0
;
...
...
@@ -286,7 +288,7 @@ namespace KopiLua
if
(
ttisnil
(
gval
(
n
)))
removeentry
(
n
);
/* remove empty entries */
else
{
lua_assert
(
ttisnil
(
gkey
(
n
)));
lua_assert
(
!
ttisnil
(
gkey
(
n
)));
if
(
weakkey
==
0
)
markvalue
(
g
,
gkey
(
n
));
if
(
weakvalue
==
0
)
markvalue
(
g
,
gval
(
n
));
}
...
...
@@ -516,7 +518,7 @@ namespace KopiLua
if
(
curr
.
gch
.
tt
==
LUA_TTHREAD
)
/* sweep open upvalues of each thread */
sweepwholelist
(
L
,
new
OpenValRef
(
gco2th
(
curr
)
));
if
(((
curr
.
gch
.
marked
^
WHITEBITS
)
&
deadmask
)
!=
0
)
{
/* not dead? */
lua_assert
(
isdead
(
g
,
curr
)
||
testbit
(
curr
.
gch
.
marked
,
FIXEDBIT
));
lua_assert
(
!
isdead
(
g
,
curr
)
||
testbit
(
curr
.
gch
.
marked
,
FIXEDBIT
));
makewhite
(
g
,
curr
);
/* make it white (for next cycle) */
p
=
new
NextRef
(
curr
.
gch
);
}
...
...
Core/KopiLua/llex.cs
View file @
05ba53d3
...
...
@@ -162,6 +162,7 @@ namespace KopiLua
luaX_lexerror
(
ls
,
msg
,
ls
.
t
.
token
);
}
[
CLSCompliantAttribute
(
false
)]
public
static
TString
luaX_newstring
(
LexState
ls
,
CharPtr
str
,
uint
l
)
{
lua_State
L
=
ls
.
L
;
...
...
Core/KopiLua/llimits.cs
View file @
05ba53d3
...
...
@@ -35,9 +35,9 @@ namespace KopiLua
/* chars used as small naturals (so that `char' is reserved for characters) */
//typedef unsigned char lu_byte;
[
CLSCompliantAttribute
(
false
)]
public
const
uint
MAX_SIZET
=
uint
.
MaxValue
-
2
;
[
CLSCompliantAttribute
(
false
)]
public
const
lu_mem
MAX_LUMEM
=
lu_mem
.
MaxValue
-
2
;
...
...
Core/KopiLua/lobject.cs
View file @
05ba53d3
...
...
@@ -125,6 +125,7 @@ namespace KopiLua
get
{
return
this
.
values
[
this
.
index
+
offset
];
}
}
[
CLSCompliantAttribute
(
false
)]
public
lua_TValue
this
[
uint
offset
]
{
get
{
return
this
.
values
[
this
.
index
+
(
int
)
offset
];
}
...
...
@@ -220,8 +221,27 @@ namespace KopiLua
public
Value
value
=
new
Value
();
public
int
tt
;
};
public
override
string
ToString
()
{
string
typename
=
null
;
string
val
=
null
;
switch
(
tt
)
{
case
LUA_TNIL
:
typename
=
"LUA_TNIL"
;
val
=
string
.
Empty
;
break
;
case
LUA_TNUMBER
:
typename
=
"LUA_TNUMBER"
;
val
=
value
.
n
.
ToString
();
break
;
case
LUA_TSTRING
:
typename
=
"LUA_TSTRING"
;
val
=
value
.
gc
.
ts
.
ToString
();
break
;
case
LUA_TTABLE
:
typename
=
"LUA_TTABLE"
;
break
;
case
LUA_TFUNCTION
:
typename
=
"LUA_TFUNCTION"
;
break
;
case
LUA_TBOOLEAN
:
typename
=
"LUA_TBOOLEAN"
;
break
;
case
LUA_TUSERDATA
:
typename
=
"LUA_TUSERDATA"
;
break
;
case
LUA_TTHREAD
:
typename
=
"LUA_TTHREAD"
;
break
;
case
LUA_TLIGHTUSERDATA
:
typename
=
"LUA_TLIGHTUSERDATA"
;
break
;
default
:
typename
=
"unknown"
;
break
;
}
return
string
.
Format
(
"TValue<{0}>({1})"
,
typename
,
val
);
}
};
/* Macros to test type */
internal
static
bool
ttisnil
(
TValue
o
)
{
return
(
ttype
(
o
)
==
LUA_TNIL
);
}
...
...
@@ -397,7 +417,9 @@ namespace KopiLua
public
class
TString_tsv
:
GCObject
{
public
lu_byte
reserved
;
[
CLSCompliantAttribute
(
false
)]
public
uint
hash
;
[
CLSCompliantAttribute
(
false
)]
public
uint
len
;
};
public
class
TString
:
TString_tsv
{
...
...
@@ -421,6 +443,7 @@ namespace KopiLua
{
public
Table
metatable
;
public
Table
env
;
[
CLSCompliantAttribute
(
false
)]
public
uint
len
;
};
...
...
@@ -451,6 +474,7 @@ namespace KopiLua
public
Proto
this
[
int
offset
]
{
get
{
return
this
.
protos
[
this
.
index
+
offset
];
}}
public
TValue
[]
k
;
/* constants used by the function */
[
CLSCompliantAttribute
(
false
)]
public
Instruction
[]
code
;
public
new
Proto
[]
p
;
/* functions defined inside the function */
public
int
[]
lineinfo
;
/* map from opcodes to source lines */
...
...
@@ -492,10 +516,10 @@ namespace KopiLua
public
class
UpVal
:
GCObject
{
public
TValue
v
;
/* points to stack or to its own value */
[
CLSCompliantAttribute
(
false
)]
public
class
_u
{
public
TValue
value
=
new
TValue
();
/* the value (when closed) */
[
CLSCompliantAttribute
(
false
)]
public
class
_l
{
/* double linked list (when open) */
public
UpVal
prev
;
public
UpVal
next
;
...
...
@@ -503,6 +527,7 @@ namespace KopiLua
public
_l
l
=
new
_l
();
}
[
CLSCompliantAttribute
(
false
)]
public
new
_u
u
=
new
_u
();
};
...
...
@@ -635,6 +660,7 @@ namespace KopiLua
public
TValue
i_val
;
public
TKey
i_key
;
[
CLSCompliantAttribute
(
false
)]
public
Node
this
[
uint
offset
]
{
get
{
return
this
.
values
[
this
.
index
+
(
int
)
offset
];
}
...
...
@@ -719,6 +745,7 @@ namespace KopiLua
** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if
** eeeee != 0 and (xxx) otherwise.
*/
[
CLSCompliantAttribute
(
false
)]
public
static
int
luaO_int2fb
(
uint
x
)
{
int
e
=
0
;
/* expoent */
while
(
x
>=
16
)
{
...
...
@@ -749,6 +776,7 @@ namespace KopiLua
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
,
8
};
[
CLSCompliantAttribute
(
false
)]
public
static
int
luaO_log2
(
uint
x
)
{
int
l
=
-
1
;
while
(
x
>=
256
)
{
l
+=
8
;
x
>>=
8
;
}
...
...
@@ -871,7 +899,7 @@ namespace KopiLua
return
luaO_pushvfstring
(
L
,
fmt
,
args
);
}
[
CLSCompliantAttribute
(
false
)]
public
static
void
luaO_chunkid
(
CharPtr
out_
,
CharPtr
source
,
uint
bufflen
)
{
//out_ = "";
if
(
source
[
0
]
==
'='
)
{
...
...
Core/KopiLua/lopcodes.cs
View file @
05ba53d3
...
...
@@ -65,9 +65,11 @@ namespace KopiLua
//public const int MAXARG_sBx = System.Int32.MaxValue;
//#endif
[
CLSCompliantAttribute
(
false
)]
public
const
uint
MAXARG_A
=
(
uint
)((
1
<<
(
int
)
SIZE_A
)
-
1
);
[
CLSCompliantAttribute
(
false
)]
public
const
uint
MAXARG_B
=
(
uint
)((
1
<<
(
int
)
SIZE_B
)
-
1
);
[
CLSCompliantAttribute
(
false
)]
public
const
uint
MAXARG_C
=
(
uint
)((
1
<<
(
int
)
SIZE_C
)
-
1
);
...
...
@@ -161,7 +163,7 @@ namespace KopiLua
internal
static
int
CREATE_ABx
(
OpCode
o
,
int
a
,
int
bc
)
{
int
result
=
(
int
)(((
int
)
o
<<
POS_OP
)
|
(
a
<<
POS_A
)
|
(
bc
<<
POS_Bx
));
return
(
int
)(((
int
)
o
<<
POS_OP
)
|
(
a
<<
POS_A
)
|
(
bc
<<
POS_Bx
))
;
return
result
;
}
...
...
Core/KopiLua/loslib.cs
View file @
05ba53d3
...
...
@@ -203,7 +203,7 @@ namespace KopiLua
int
day
=
getfield
(
L
,
"day"
,
-
1
);
int
month
=
getfield
(
L
,
"month"
,
-
1
)
-
1
;
int
year
=
getfield
(
L
,
"year"
,
-
1
)
-
1900
;
int
isdst
=
getboolfield
(
L
,
"isdst"
);
// todo: implement this - mjf
/*
int isdst =
*/
getboolfield
(
L
,
"isdst"
);
// todo: implement this - mjf
t
=
new
DateTime
(
year
,
month
,
day
,
hour
,
min
,
sec
);
}
lua_pushnumber
(
L
,
t
.
Ticks
);
...
...
Core/KopiLua/lparser.cs
View file @
05ba53d3
...
...
@@ -53,6 +53,8 @@ namespace KopiLua
}
public
expkind
k
;
[
CLSCompliantAttribute
(
false
)]
public
class
_u
{
public
void
Copy
(
_u
u
)
...
...
@@ -61,6 +63,7 @@ namespace KopiLua
this
.
nval
=
u
.
nval
;
}
[
CLSCompliantAttribute
(
false
)]
public
class
_s
{
public
void
Copy
(
_s
s
)
...
...
@@ -73,6 +76,8 @@ namespace KopiLua
public
_s
s
=
new
_s
();
public
lua_Number
nval
;
};
[
CLSCompliantAttribute
(
false
)]
public
_u
u
=
new
_u
();
public
int
t
;
/* patch list of `exit when true' */
...
...
@@ -109,6 +114,7 @@ namespace KopiLua
public
short
nlocvars
;
/* number of elements in `locvars' */
public
lu_byte
nactvar
;
/* number of active local variables */
public
upvaldesc
[]
upvalues
=
new
upvaldesc
[
LUAI_MAXUPVALUES
];
/* upvalues */
[
CLSCompliantAttribute
(
false
)]
public
ushort
[]
actvar
=
new
ushort
[
LUAI_MAXVARS
];
/* declared-variable stack */
};
...
...
@@ -1449,4 +1455,4 @@ namespace KopiLua
/* }====================================================================== */
}
}
}
\ No newline at end of file
Core/KopiLua/lstate.cs
View file @
05ba53d3
...
...
@@ -161,9 +161,13 @@ namespace KopiLua
public
GCObject
weak
;
/* list of weak tables (to be cleared) */
public
GCObject
tmudata
;
/* last element of list of userdata to be GC */
public
Mbuffer
buff
=
new
Mbuffer
();
/* temporary buffer for string concatentation */
[
CLSCompliantAttribute
(
false
)]
public
lu_mem
GCthreshold
;
[
CLSCompliantAttribute
(
false
)]
public
lu_mem
totalbytes
;
/* number of bytes currently allocated */
[
CLSCompliantAttribute
(
false
)]
public
lu_mem
estimate
;
/* an estimate of number of bytes actually in use */
[
CLSCompliantAttribute
(
false
)]
public
lu_mem
gcdept
;
/* how much GC is `behind schedule' */
public
int
gcpause
;
/* size of pause between successive GCs */
public
int
gcstepmul
;
/* GC `granularity' */
...
...
@@ -193,7 +197,9 @@ namespace KopiLua
public
CallInfo
[]
base_ci
;
/* array of CallInfo's */
public
int
stacksize
;
public
int
size_ci
;
/* size of array `base_ci' */
[
CLSCompliantAttribute
(
false
)]
public
ushort
nCcalls
;
/* number of nested C calls */
[
CLSCompliantAttribute
(
false
)]
public
ushort
baseCcalls
;
/* nested C calls when resuming coroutine */
public
lu_byte
hookmask
;
public
lu_byte
allowhook
;
...
...
Core/KopiLua/lstring.cs
View file @
05ba53d3
...
...
@@ -61,7 +61,7 @@ namespace KopiLua
tb
.
hash
=
newhash
;
}
[
CLSCompliantAttribute
(
false
)]
public
static
TString
newlstr
(
lua_State
L
,
CharPtr
str
,
uint
l
,
uint
h
)
{
TString
ts
;
...
...
@@ -88,6 +88,7 @@ namespace KopiLua
return
ts
;
}
[
CLSCompliantAttribute
(
false
)]
public
static
TString
luaS_newlstr
(
lua_State
L
,
CharPtr
str
,
uint
l
)
{
GCObject
o
;
uint
h
=
(
uint
)
l
;
/* seed */
...
...
@@ -110,7 +111,7 @@ namespace KopiLua
return
res
;
}
[
CLSCompliantAttribute
(
false
)]
public
static
Udata
luaS_newudata
(
lua_State
L
,
uint
s
,
Table
e
)
{
Udata
u
=
new
Udata
();
...
...
@@ -120,6 +121,7 @@ namespace KopiLua
u
.
uv
.
metatable
=
null
;
u
.
uv
.
env
=
e
;
u
.
user_data
=
new
byte
[
s
];
AddTotalBytes
(
L
,
GetUnmanagedSize
(
typeof
(
Udata
))
+
sizeudata
(
u
));
/* chain it on udata list (after main thread) */
u
.
uv
.
next
=
G
(
L
).
mainthread
.
next
;
G
(
L
).
mainthread
.
next
=
obj2gco
(
u
);
...
...
@@ -131,7 +133,7 @@ namespace KopiLua
Udata
u
=
new
Udata
();
u
.
uv
.
marked
=
luaC_white
(
G
(
L
));
/* is not finalized */
u
.
uv
.
tt
=
LUA_TUSERDATA
;
u
.
uv
.
len
=
0
;
u
.
uv
.
len
=
0
;
/* gfoot: not sizeof(t)? */
u
.
uv
.
metatable
=
null
;
u
.
uv
.
env
=
e
;
u
.
user_data
=
luaM_realloc_
(
L
,
t
);
...
...
Core/KopiLua/lstrlib.cs
View file @
05ba53d3
...
...
@@ -674,6 +674,7 @@ namespace KopiLua
add_s
(
ms
,
b
,
s
,
e
);
return
;
}
case
LUA_TUSERDATA
:
case
LUA_TFUNCTION
:
{
int
n
;
lua_pushvalue
(
L
,
3
);
...
...
@@ -713,7 +714,8 @@ namespace KopiLua
MatchState
ms
=
new
MatchState
();
luaL_Buffer
b
=
new
luaL_Buffer
();
luaL_argcheck
(
L
,
tr
==
LUA_TNUMBER
||
tr
==
LUA_TSTRING
||
tr
==
LUA_TFUNCTION
||
tr
==
LUA_TTABLE
,
3
,
tr
==
LUA_TFUNCTION
||
tr
==
LUA_TTABLE
||
tr
==
LUA_TUSERDATA
,
3
,
"string/function/table expected"
);
luaL_buffinit
(
L
,
b
);
ms
.
L
=
L
;
...
...
Core/KopiLua/ltable.cs
View file @
05ba53d3
...
...
@@ -64,7 +64,7 @@ namespace KopiLua
** for some types, it is better to avoid modulus by power of 2, as
** they tend to have many 2 factors.
*/
public
static
Node
hashmod
(
Table
t
,
int
n
)
{
return
gnode
(
t
,
(
n
%
((
sizenode
(
t
)
-
1
)
|
1
)));
}
public
static
Node
hashmod
(
Table
t
,
int
n
)
{
return
gnode
(
t
,
(
int
)((
uint
)
n
%
((
sizenode
(
t
)
-
1
)
|
1
)));
}
public
static
Node
hashpointer
(
Table
t
,
object
p
)
{
return
hashmod
(
t
,
p
.
GetHashCode
());
}
...
...
@@ -537,7 +537,7 @@ namespace KopiLua
}
}
[
CLSCompliantAttribute
(
false
)]
public
static
int
unbound_search
(
Table
t
,
uint
j
)
{
uint
i
=
j
;
/* i is zero or a present index */
j
++;
...
...
Core/KopiLua/lua.cs
View file @
05ba53d3
...
...
@@ -15,6 +15,7 @@ namespace KopiLua
using
lua_Number
=
Double
;
using
lua_Integer
=
System
.
Int32
;
[
CLSCompliantAttribute
(
true
)]
public
partial
class
Lua
{
...
...
@@ -55,8 +56,9 @@ namespace KopiLua
/*
** functions that read/write blocks when loading/dumping Lua chunks
*/
[
CLSCompliantAttribute
(
false
)]
public
delegate
CharPtr
lua_Reader
(
lua_State
L
,
object
ud
,
out
uint
sz
);
[
CLSCompliantAttribute
(
false
)]
public
delegate
int
lua_Writer
(
lua_State
L
,
CharPtr
p
,
uint
sz
,
object
ud
);
...
...
@@ -135,6 +137,7 @@ namespace KopiLua
lua_pushcclosure
(
L
,
f
,
0
);
}
[
CLSCompliantAttribute
(
false
)]
public
static
uint
lua_strlen
(
lua_State
L
,
int
i
)
{
return
lua_objlen
(
L
,
i
);
...
...
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