Commit 6218d711 authored by Megax's avatar Megax
Browse files

* LuaLib adatok szet lettek valasztva.

parent be104eac
......@@ -36,10 +36,10 @@ namespace LuaInterface.Event
/// <author>Reinhard Ostermeier</author>
public enum EventCodes
{
LUA_HOOKCALL = 0,
LUA_HOOKRET = 1,
LUA_HOOKLINE = 2,
LUA_HOOKCOUNT = 3,
LUA_HOOKTAILRET = 4,
LUA_HOOKCALL = 0,
LUA_HOOKRET = 1,
LUA_HOOKLINE = 2,
LUA_HOOKCOUNT = 3,
LUA_HOOKTAILRET = 4
}
}
\ No newline at end of file
......@@ -37,10 +37,10 @@ namespace LuaInterface.Event
[Flags]
public enum EventMasks
{
LUA_MASKCALL = (1 << EventCodes.LUA_HOOKCALL),
LUA_MASKRET = (1 << EventCodes.LUA_HOOKRET),
LUA_MASKLINE = (1 << EventCodes.LUA_HOOKLINE),
LUA_MASKCALL = (1 << EventCodes.LUA_HOOKCALL),
LUA_MASKRET = (1 << EventCodes.LUA_HOOKRET),
LUA_MASKLINE = (1 << EventCodes.LUA_HOOKLINE),
LUA_MASKCOUNT = (1 << EventCodes.LUA_HOOKCOUNT),
LUA_MASKALL = Int32.MaxValue,
LUA_MASKALL = Int32.MaxValue
}
}
\ No newline at end of file
......@@ -39,19 +39,19 @@ namespace LuaInterface.Event
{
public EventCodes eventCode;
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPStr)]
public String name;
public string name;
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPStr)]
public String namewhat;
public string namewhat;
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPStr)]
public String what;
public string what;
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPStr)]
public String source;
public string source;
public int currentline;
public int nups;
public int linedefined;
public int lastlinedefined;
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst = 60/*LUA_IDSIZE*/)]
public String shortsrc;
public string shortsrc;
public int i_ci;
}
}
\ No newline at end of file
......@@ -63,6 +63,11 @@
<Compile Include="Event\HookExceptionEventArgs.cs" />
<Compile Include="Exceptions\LuaException.cs" />
<Compile Include="Exceptions\LuaScriptException.cs" />
<Compile Include="LuaLib\LuaEnums.cs" />
<Compile Include="LuaLib\References.cs" />
<Compile Include="LuaLib\LuaTypes.cs" />
<Compile Include="LuaLib\GCOption.cs" />
<Compile Include="LuaLib\PseudoIndex.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
......
/*
* This file is part of LuaInterface.
*
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* Copyright (C) 2009 Joshua Simmons <simmons.44@gmail.com>
* Copyright (C) 2012 Megax <http://megax.yeahunter.hu/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
namespace LuaInterface
{
public enum GCOption : int
{
/// <summary>
/// Stops the garbage collector.
/// </summary>
Stop = 0,
/// <summary>
/// Restarts the garbage collector.
/// </summary>
Restart = 1,
/// <summary>
/// Performs a full garbage-collection cycle.
/// </summary>
Collect = 2,
/// <summary>
/// Returns the current amount of memory (in Kbytes) in use by KopiLua.Lua.
/// </summary>
Count = 3,
/// <summary>
/// Returns the remainder of dividing the current amount of bytes of memory in use by Lua by 1024.
/// </summary>
CountB = 4,
/// <summary>
/// Performs an incremental step of garbage collection. The step "size" is controlled by data (larger values mean more steps) in a non-specified way. ifyou want to control the step size you must experimentally tune the value of data. The function returns 1 ifthe step finished a garbage-collection cycle.
/// </summary>
Step = 5,
/// <summary>
/// Sets data as the new value for the pause (Controls how long the collector waits before starting a new cycle) of the collector (see §2.10). The function returns the previous value of the pause.
/// </summary>
SetPause = 6,
/// <summary>
/// Sets data as the new value for the step multiplier of the collector (Controls the relative speed of the collector relative to memory allocation.). The function returns the previous value of the step multiplier.
/// </summary>
SetStepMul = 7
}
}
\ No newline at end of file
/*
* This file is part of LuaInterface.
*
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* Copyright (C) 2009 Joshua Simmons <simmons.44@gmail.com>
* Copyright (C) 2012 Megax <http://megax.yeahunter.hu/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
namespace LuaInterface
{
/// <summary>
/// Enumeration of basic lua globals.
/// </summary>
public enum LuaEnums : int
{
/// <summary>
/// Option for multiple returns in `lua_pcall' and `lua_call'
/// </summary>
MultiRet = -1,
/// <summary>
/// Everything is OK.
/// </summary>
Ok = 0,
/// <summary>
/// Thread status, Ok or Yield
/// </summary>
Yield = 1,
/// <summary>
/// A Runtime error.
/// </summary>
ErrorRun = 2,
/// <summary>
/// A syntax error.
/// </summary>
ErrorSyntax = 3,
/// <summary>
/// A memory allocation error. For such errors, Lua does not call the error handler function.
/// </summary>
ErrorMemory = 4,
/// <summary>
/// An error in the error handling function.
/// </summary>
ErrorError = 5,
/// <summary>
/// An extra error for file load errors when using luaL_loadfile.
/// </summary>
ErrorFile = 6
}
}
\ No newline at end of file
......@@ -23,130 +23,15 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using LuaInterface.Extensions;
namespace LuaInterface
{
/// <summary>
/// Enumeration of basic lua globals.
/// </summary>
public enum LuaEnum : int
{
/// <summary>
/// Option for multiple returns in `lua_pcall' and `lua_call'
/// </summary>
MultiRet = -1,
/// <summary>
/// Everything is OK.
/// </summary>
Ok = 0,
/// <summary>
/// Thread status, Ok or Yield
/// </summary>
Yield = 1,
/// <summary>
/// A Runtime error.
/// </summary>
ErrorRun = 2,
/// <summary>
/// A syntax error.
/// </summary>
ErrorSyntax = 3,
/// <summary>
/// A memory allocation error. For such errors, Lua does not call the error handler function.
/// </summary>
ErrorMemory = 4,
/// <summary>
/// An error in the error handling function.
/// </summary>
ErrorError = 5,
/// <summary>
/// An extra error for file load errors when using luaL_loadfile.
/// </summary>
ErrorFile = 6,
}
public enum References : int
{
RefNil = -1,
NoRef = -2
}
public enum LuaTypes : int
{
None = -1,
Nil = 0,
Boolean = 1,
LightUserdata = 2,
Number = 3,
String = 4,
Table = 5,
Function = 6,
UserData = 7,
Thread = 8
}
public enum GCOption : int
{
/// <summary>
/// Stops the garbage collector.
/// </summary>
Stop = 0,
/// <summary>
/// Restarts the garbage collector.
/// </summary>
Restart = 1,
/// <summary>
/// Performs a full garbage-collection cycle.
/// </summary>
Collect = 2,
/// <summary>
/// Returns the current amount of memory (in Kbytes) in use by KopiLua.Lua.
/// </summary>
Count = 3,
/// <summary>
/// Returns the remainder of dividing the current amount of bytes of memory in use by Lua by 1024.
/// </summary>
CountB = 4,
/// <summary>
/// Performs an incremental step of garbage collection. The step "size" is controlled by data (larger values mean more steps) in a non-specified way. ifyou want to control the step size you must experimentally tune the value of data. The function returns 1 ifthe step finished a garbage-collection cycle.
/// </summary>
Step = 5,
/// <summary>
/// Sets data as the new value for the pause (Controls how long the collector waits before starting a new cycle) of the collector (see §2.10). The function returns the previous value of the pause.
/// </summary>
SetPause = 6,
/// <summary>
/// Sets data as the new value for the step multiplier of the collector (Controls the relative speed of the collector relative to memory allocation.). The function returns the previous value of the step multiplier.
/// </summary>
SetStepMul = 7
}
public enum PseudoIndex : int
{
Registry = (-10000),
Environment = (-10001),
Globals = (-10002)
}
public static class LuaLib
{
private static int tag = 0;
......@@ -172,9 +57,9 @@ namespace LuaInterface
return (LuaTypes)type;
}
public static LuaEnum ToLuaEnum(this int lenum)
public static LuaEnums ToLuaEnums(this int lenum)
{
return (LuaEnum)lenum;
return (LuaEnums)lenum;
}
public static bool ToBoolean(this int number)
......@@ -213,7 +98,7 @@ namespace LuaInterface
/// </returns>
public static bool luaL_dofile(KopiLua.Lua.lua_State state, string filename)
{
return (KopiLua.Lua.luaL_loadfile(state, filename).ToLuaEnum() == LuaEnum.Ok) && (KopiLua.Lua.lua_pcall(state, 0, (int)LuaEnum.MultiRet, 0).ToLuaEnum() == LuaEnum.Ok);
return (KopiLua.Lua.luaL_loadfile(state, filename).ToLuaEnums() == LuaEnums.Ok) && (KopiLua.Lua.lua_pcall(state, 0, (int)LuaEnums.MultiRet, 0).ToLuaEnums() == LuaEnums.Ok);
}
/// <summary>
......@@ -230,12 +115,12 @@ namespace LuaInterface
/// </returns>
public static bool luaL_dostring(KopiLua.Lua.lua_State state, string chunk)
{
return (KopiLua.Lua.luaL_loadstring(state, chunk).ToLuaEnum() == LuaEnum.Ok) && (KopiLua.Lua.lua_pcall(state, 0, (int)LuaEnum.MultiRet, 0).ToLuaEnum() == LuaEnum.Ok);
return (KopiLua.Lua.luaL_loadstring(state, chunk).ToLuaEnums() == LuaEnums.Ok) && (KopiLua.Lua.lua_pcall(state, 0, (int)LuaEnums.MultiRet, 0).ToLuaEnums() == LuaEnums.Ok);
}
public static LuaEnum luaL_loadbuffer(KopiLua.Lua.lua_State luaState, string buff, string name)
public static LuaEnums luaL_loadbuffer(KopiLua.Lua.lua_State luaState, string buff, string name)
{
var result = KopiLua.Lua.luaL_loadbuffer(luaState, buff, (uint)buff.Length, name).ToLuaEnum();
var result = KopiLua.Lua.luaL_loadbuffer(luaState, buff, (uint)buff.Length, name).ToLuaEnums();
return result;
}
......
/*
* This file is part of LuaInterface.
*
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* Copyright (C) 2009 Joshua Simmons <simmons.44@gmail.com>
* Copyright (C) 2012 Megax <http://megax.yeahunter.hu/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using LuaInterface.Extensions;
namespace LuaInterface
{
public enum LuaTypes : int
{
None = -1,
Nil = 0,
Boolean = 1,
LightUserdata = 2,
Number = 3,
String = 4,
Table = 5,
Function = 6,
UserData = 7,
Thread = 8
}
}
\ No newline at end of file
/*
* This file is part of LuaInterface.
*
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* Copyright (C) 2009 Joshua Simmons <simmons.44@gmail.com>
* Copyright (C) 2012 Megax <http://megax.yeahunter.hu/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
namespace LuaInterface
{
public enum PseudoIndex : int
{
Registry = (-10000),
Environment = (-10001),
Globals = (-10002)
}
}
\ No newline at end of file
/*
* This file is part of LuaInterface.
*
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* Copyright (C) 2009 Joshua Simmons <simmons.44@gmail.com>
* Copyright (C) 2012 Megax <http://megax.yeahunter.hu/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
namespace LuaInterface
{
public enum References : int
{
RefNil = -1,
NoRef = -2
}
}
\ No newline at end of file
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