Commit 05ba53d3 authored by Megax's avatar Megax
Browse files

* Javitasok kerultek be a kodba gfoot repo-bol.

parent b5b573a3
...@@ -849,6 +849,7 @@ namespace KopiLua ...@@ -849,6 +849,7 @@ namespace KopiLua
public static char tolower(int c) { return Char.ToLower((char)c); } public static char tolower(int c) { return Char.ToLower((char)c); }
public static char toupper(int c) { return Char.ToUpper((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_) public static ulong strtoul(CharPtr s, out CharPtr end, int base_)
{ {
try try
...@@ -1038,6 +1039,8 @@ namespace KopiLua ...@@ -1038,6 +1039,8 @@ namespace KopiLua
get { return chars[index + offset]; } get { return chars[index + offset]; }
set { chars[index + offset] = value; } set { chars[index + offset] = value; }
} }
[CLSCompliantAttribute(false)]
public char this[uint offset] public char this[uint offset]
{ {
get { return chars[index + offset]; } get { return chars[index + offset]; }
...@@ -1096,7 +1099,9 @@ namespace KopiLua ...@@ -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);}
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); } 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 static CharPtr operator -(CharPtr ptr, uint offset) { return new CharPtr(ptr.chars, ptr.index - (int)offset); }
public void inc() { this.index++; } public void inc() { this.index++; }
...@@ -1157,6 +1162,7 @@ namespace KopiLua ...@@ -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, uint size) { return memcmp(ptr1, ptr2, (int)size); }
public static int memcmp(CharPtr ptr1, CharPtr ptr2, int size) public static int memcmp(CharPtr ptr1, CharPtr ptr2, int size)
{ {
...@@ -1171,6 +1177,7 @@ namespace KopiLua ...@@ -1171,6 +1177,7 @@ namespace KopiLua
return 0; return 0;
} }
[CLSCompliantAttribute(false)]
public static CharPtr memchr(CharPtr ptr, char c, uint count) public static CharPtr memchr(CharPtr ptr, char c, uint count)
{ {
for (uint i = 0; i < count; i++) for (uint i = 0; i < count; i++)
...@@ -1229,6 +1236,7 @@ namespace KopiLua ...@@ -1229,6 +1236,7 @@ namespace KopiLua
return dst; return dst;
} }
[CLSCompliantAttribute(false)]
public static uint strcspn(CharPtr str, CharPtr charset) public static uint strcspn(CharPtr str, CharPtr charset)
{ {
int index = str.ToString().IndexOfAny(charset.ToString().ToCharArray()); int index = str.ToString().IndexOfAny(charset.ToString().ToCharArray());
...@@ -1512,6 +1520,7 @@ namespace KopiLua ...@@ -1512,6 +1520,7 @@ namespace KopiLua
return 0; return 0;
} }
[CLSCompliantAttribute(false)]
public static int setvbuf(Stream stream, CharPtr buffer, int mode, uint size) public static int setvbuf(Stream stream, CharPtr buffer, int mode, uint size)
{ {
Debug.Assert(false, "setvbuf not implemented yet - mjf"); Debug.Assert(false, "setvbuf not implemented yet - mjf");
...@@ -1536,6 +1545,7 @@ namespace KopiLua ...@@ -1536,6 +1545,7 @@ namespace KopiLua
dst[i] = src[srcofs+i]; 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, uint size) { memcpy(ptr1, ptr2, (int)size); }
public static void memcpy(CharPtr ptr1, CharPtr ptr2, int size) public static void memcpy(CharPtr ptr1, CharPtr ptr2, int size)
{ {
...@@ -1546,10 +1556,14 @@ namespace KopiLua ...@@ -1546,10 +1556,14 @@ namespace KopiLua
public static object VOID(object f) { return f; } public static object VOID(object f) { return f; }
public const double HUGE_VAL = System.Double.MaxValue; public const double HUGE_VAL = System.Double.MaxValue;
[CLSCompliantAttribute(false)]
public const uint SHRT_MAX = System.UInt16.MaxValue; public const uint SHRT_MAX = System.UInt16.MaxValue;
[CLSCompliantAttribute(false)]
public const int _IONBF = 0; public const int _IONBF = 0;
[CLSCompliantAttribute(false)]
public const int _IOFBF = 1; public const int _IOFBF = 1;
[CLSCompliantAttribute(false)]
public const int _IOLBF = 2; public const int _IOLBF = 2;
public const int SEEK_SET = 0; public const int SEEK_SET = 0;
......
...@@ -20,6 +20,7 @@ namespace KopiLua ...@@ -20,6 +20,7 @@ namespace KopiLua
public partial class Lua public partial class Lua
{ {
[CLSCompliantAttribute(false)]
public static int tostring(lua_State L, StkId o) { public static int tostring(lua_State L, StkId o) {
return ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o) != 0)) ? 1 : 0; return ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o) != 0)) ? 1 : 0;
} }
...@@ -372,6 +373,7 @@ namespace KopiLua ...@@ -372,6 +373,7 @@ namespace KopiLua
//#define Protect(x) { L.savedpc = pc; {x;}; base = L.base_; } //#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) { 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 rb = RKB(L, base_, i, k);
TValue rc = RKC(L, base_, i, k); TValue rc = RKC(L, base_, i, k);
......
...@@ -35,7 +35,9 @@ namespace KopiLua ...@@ -35,7 +35,9 @@ namespace KopiLua
public class Mbuffer { public class Mbuffer {
public CharPtr buffer = new CharPtr(); public CharPtr buffer = new CharPtr();
[CLSCompliantAttribute(false)]
public uint n; public uint n;
[CLSCompliantAttribute(false)]
public uint buffsize; public uint buffsize;
}; };
...@@ -45,7 +47,9 @@ namespace KopiLua ...@@ -45,7 +47,9 @@ namespace KopiLua
} }
public static CharPtr luaZ_buffer(Mbuffer buff) {return buff.buffer;} public static CharPtr luaZ_buffer(Mbuffer buff) {return buff.buffer;}
[CLSCompliantAttribute(false)]
public static uint luaZ_sizebuffer(Mbuffer buff) { return buff.buffsize; } public static uint luaZ_sizebuffer(Mbuffer buff) { return buff.buffsize; }
[CLSCompliantAttribute(false)]
public static uint luaZ_bufflen(Mbuffer buff) {return buff.n;} public static uint luaZ_bufflen(Mbuffer buff) {return buff.n;}
public static void luaZ_resetbuffer(Mbuffer buff) {buff.n = 0;} public static void luaZ_resetbuffer(Mbuffer buff) {buff.n = 0;}
...@@ -65,8 +69,10 @@ namespace KopiLua ...@@ -65,8 +69,10 @@ namespace KopiLua
/* --------- Private Part ------------------ */ /* --------- Private Part ------------------ */
public class Zio { public class Zio {
[CLSCompliantAttribute(false)]
public uint n; /* bytes still unread */ public uint n; /* bytes still unread */
public CharPtr p; /* current position in buffer */ public CharPtr p; /* current position in buffer */
[CLSCompliantAttribute(false)]
public lua_Reader reader; public lua_Reader reader;
public object data; /* additional data */ public object data; /* additional data */
public lua_State L; /* Lua state (for reader) */ public lua_State L; /* Lua state (for reader) */
...@@ -101,7 +107,7 @@ namespace KopiLua ...@@ -101,7 +107,7 @@ namespace KopiLua
return char2int(z.p[0]); return char2int(z.p[0]);
} }
[CLSCompliantAttribute(false)]
public static void luaZ_init(lua_State L, ZIO z, lua_Reader reader, object data) public static void luaZ_init(lua_State L, ZIO z, lua_Reader reader, object data)
{ {
z.L = L; z.L = L;
...@@ -113,6 +119,7 @@ namespace KopiLua ...@@ -113,6 +119,7 @@ namespace KopiLua
/* --------------------------------------------------------------- read --- */ /* --------------------------------------------------------------- read --- */
[CLSCompliantAttribute(false)]
public static uint luaZ_read (ZIO z, CharPtr b, uint n) { public static uint luaZ_read (ZIO z, CharPtr b, uint n) {
b = new CharPtr(b); b = new CharPtr(b);
while (n != 0) { while (n != 0) {
...@@ -130,6 +137,7 @@ namespace KopiLua ...@@ -130,6 +137,7 @@ namespace KopiLua
} }
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
[CLSCompliantAttribute(false)]
public static CharPtr luaZ_openspace (lua_State L, Mbuffer buff, uint n) { public static CharPtr luaZ_openspace (lua_State L, Mbuffer buff, uint n) {
if (n > buff.buffsize) { if (n > buff.buffsize) {
if (n < LUA_MINBUFFER) n = LUA_MINBUFFER; if (n < LUA_MINBUFFER) n = LUA_MINBUFFER;
......
...@@ -471,7 +471,7 @@ namespace AT.MIN ...@@ -471,7 +471,7 @@ namespace AT.MIN
#endregion #endregion
#region s - string #region s - string
case '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(); w = o.ToString();
if ( fieldPrecision >= 0 ) if ( fieldPrecision >= 0 )
w = w.Substring( 0, fieldPrecision ); w = w.Substring( 0, fieldPrecision );
......
...@@ -87,7 +87,7 @@ namespace LuaInterface ...@@ -87,7 +87,7 @@ namespace LuaInterface
/// <summary> /// <summary>
/// Used to ensure multiple .net threads all get serialized by this single lock for access to the lua stack/objects /// Used to ensure multiple .net threads all get serialized by this single lock for access to the lua stack/objects
/// </summary> /// </summary>
private object luaLock = new object(); //private object luaLock = new object();
private bool _StatePassed; private bool _StatePassed;
private bool executing; private bool executing;
......
...@@ -35,7 +35,9 @@ namespace LuaInterface ...@@ -35,7 +35,9 @@ namespace LuaInterface
public abstract class LuaBase : IDisposable public abstract class LuaBase : IDisposable
{ {
private bool _Disposed; private bool _Disposed;
[CLSCompliantAttribute(false)]
protected int _Reference; protected int _Reference;
[CLSCompliantAttribute(false)]
protected Lua _Interpreter; protected Lua _Interpreter;
~LuaBase() ~LuaBase()
......
...@@ -143,7 +143,8 @@ namespace LuaInterface ...@@ -143,7 +143,8 @@ namespace LuaInterface
public static int luanet_rawnetobj(LuaCore.lua_State luaState, int obj) 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; return udata != 0 ? udata : -1;
} }
...@@ -154,7 +155,9 @@ namespace LuaInterface ...@@ -154,7 +155,9 @@ namespace LuaInterface
public static int checkudata_raw(LuaCore.lua_State luaState, int ud, string tname) 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) if(p != 0)
{ {
...@@ -163,6 +166,12 @@ namespace LuaInterface ...@@ -163,6 +166,12 @@ namespace LuaInterface
{ {
/* does it have a metatable? */ /* does it have a metatable? */
LuaCore.lua_getfield(luaState, (int)PseudoIndex.Registry, tname); /* get correct 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(); bool isEqual = LuaCore.lua_rawequal(luaState, -1, -2).ToBoolean();
// NASTY - we need our own version of the lua_pop macro // NASTY - we need our own version of the lua_pop macro
...@@ -185,7 +194,9 @@ namespace LuaInterface ...@@ -185,7 +194,9 @@ namespace LuaInterface
public static void luanet_newudata(LuaCore.lua_State luaState, int val) 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) public static int luanet_tonetobject(LuaCore.lua_State luaState, int index)
...@@ -197,7 +208,7 @@ namespace LuaInterface ...@@ -197,7 +208,7 @@ namespace LuaInterface
{ {
if(luaL_checkmetatable(luaState, index)) if(luaL_checkmetatable(luaState, index))
{ {
udata = (int)LuaCore.lua_touserdata2(luaState, index); udata = fourBytesToInt(LuaCore.lua_touserdata(luaState, index) as byte[]);
if(udata != 0) if(udata != 0)
return udata; return udata;
} }
...@@ -222,6 +233,21 @@ namespace LuaInterface ...@@ -222,6 +233,21 @@ namespace LuaInterface
{ {
return lockRef != 0 ? LuaCore.luaL_ref(luaState, (int)PseudoIndex.Registry) : 0; 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 #endregion
} }
} }
\ No newline at end of file
...@@ -248,7 +248,7 @@ namespace LuaInterface.Method ...@@ -248,7 +248,7 @@ namespace LuaInterface.Method
{ {
if(methodToCall.ContainsGenericParameters) if(methodToCall.ContainsGenericParameters)
{ {
bool isMethod = _Translator.matchParameters(luaState, methodToCall, ref _LastCalledMethod); /*bool isMethod = */_Translator.matchParameters(luaState, methodToCall, ref _LastCalledMethod);
if(methodToCall.IsGenericMethodDefinition) if(methodToCall.IsGenericMethodDefinition)
{ {
......
...@@ -43,7 +43,7 @@ using System.Runtime.InteropServices; ...@@ -43,7 +43,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCopyright("Copyright 2003-2008 Fabio Mascarenhas, Kevin Hesterm and 2012 Megax")] [assembly: AssemblyCopyright("Copyright 2003-2008 Fabio Mascarenhas, Kevin Hesterm and 2012 Megax")]
//[assembly: AssemblyTrademark("")] //[assembly: AssemblyTrademark("")]
//[assembly: CLSCompliant(true)] [assembly: CLSCompliant(true)]
// Setting ComVisible to false makes the types in this assembly not visible // 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 // to COM components. If you need to access a type in this assembly from
......
...@@ -55,7 +55,7 @@ namespace LuaInterface.Test ...@@ -55,7 +55,7 @@ namespace LuaInterface.Test
//failed //failed
Assert.True(false); Assert.True(false);
} }
catch (Exception e) catch (Exception/* e*/)
{ {
//passed //passed
Assert.True(true); Assert.True(true);
...@@ -160,7 +160,7 @@ namespace LuaInterface.Test ...@@ -160,7 +160,7 @@ namespace LuaInterface.Test
lua.DoString("function calcVP(a,b) return a+b end"); lua.DoString("function calcVP(a,b) return a+b end");
LuaFunction lf = lua.GetFunction("calcVP"); LuaFunction lf = lua.GetFunction("calcVP");
Object[] ret = lf.Call(i, 20); /*Object[] ret = */lf.Call(i, 20);
} }
[Fact] [Fact]
...@@ -347,7 +347,7 @@ namespace LuaInterface.Test ...@@ -347,7 +347,7 @@ namespace LuaInterface.Test
//failed //failed
Assert.True(false); Assert.True(false);
} }
catch (LuaException e) catch (LuaException/* e*/)
{ {
//passed //passed
Assert.True(true); Assert.True(true);
......
...@@ -64,7 +64,7 @@ namespace LuaInterface.Test.Mock ...@@ -64,7 +64,7 @@ namespace LuaInterface.Test.Mock
/// </summary> /// </summary>
class DoWorkClass class DoWorkClass
{ {
private object _Lock = new object(); //private object _Lock = new object();
public void DoWork() public void DoWork()
{ {
......
...@@ -62,7 +62,7 @@ namespace LuaInterface.Tests ...@@ -62,7 +62,7 @@ namespace LuaInterface.Tests
/// </summary> /// </summary>
class DoWorkClass class DoWorkClass
{ {
private object _Lock = new object(); //private object _Lock = new object();
public void DoWork() public void DoWork()
{ {
......
...@@ -1107,7 +1107,7 @@ namespace LuaInterface.Tests ...@@ -1107,7 +1107,7 @@ namespace LuaInterface.Tests
lua.DoString("function calcVP(a,b) return a+b end"); lua.DoString("function calcVP(a,b) return a+b end");
LuaFunction lf = lua.GetFunction("calcVP"); LuaFunction lf = lua.GetFunction("calcVP");
Object[] ret = lf.Call(i, 20); /*Object[] ret = */lf.Call(i, 20);
} }
private void TestThreading() private void TestThreading()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment