Unverified Commit 1cc74393 authored by Vinicius Jarina's avatar Vinicius Jarina Committed by GitHub
Browse files

* Giant cleanup/reshuffle of all files. (#265)

* * Giant cleanup/reshuffle of all files.

* * Update upstream `KeraLua` to `0.1.14`

* Fixed .NET Core build.

* Add runsettings file

* * Fixed nuspec `dependencies` node

* Ignore _ in branch names for package names.

* * Fixed nuspec.
parent 3f254585
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle ("ConsoleTest")]
[assembly: AssemblyDescription ("")]
[assembly: AssemblyConfiguration ("")]
[assembly: AssemblyCompany ("")]
[assembly: AssemblyProduct ("ConsoleTest")]
[assembly: AssemblyCopyright ("Copyright © 2015")]
[assembly: AssemblyTrademark ("")]
[assembly: AssemblyCulture ("")]
// 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.
[assembly: ComVisible (false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid ("7c99edf7-f9ea-40fd-9ff9-c463f501e21a")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion ("1.0.0.0")]
[assembly: AssemblyFileVersion ("1.0.0.0")]
#!/bin/sh
exec mono "@expanded_libdir@/@PACKAGE@/ConsoleTest.exe" "$@"
Subproject commit e5ef8341688d8a25e8cf6f6d812ab3da365399b6
Subproject commit 6855aea035e73911cb01da1f1616f2f579251e65
EXTRA_DIST =
#Warning: This is an automatically generated file, do not edit!
if ENABLE_DEBUG
SUBDIRS = KopiLua/KopiLua KeraLua/src NLua
endif
if ENABLE_DEBUGKOPILUA
SUBDIRS = KopiLua/KopiLua KeraLua/src NLua
endif
if ENABLE_RELEASE
SUBDIRS = KopiLua/KopiLua KeraLua/src NLua
endif
if ENABLE_RELEASEKOPILUA
SUBDIRS = KopiLua/KopiLua KeraLua/src NLua
endif
if ENABLE_DEBUG_X64
SUBDIRS = KopiLua/KopiLua KeraLua/src NLua
endif
if ENABLE_RELEASE_X64
SUBDIRS = KopiLua/KopiLua KeraLua/src NLua
endif
if ENABLE_DEBUGKOPILUA_X64
SUBDIRS = KopiLua/KopiLua KeraLua/src NLua
endif
if ENABLE_RELEASEKOPILUA_X64
SUBDIRS = KopiLua/KopiLua KeraLua/src NLua
endif
/*
* This file is part of NLua.
*
* Copyright (c) 2015 Vinicius Jarina (viniciusjarina@gmail.com)
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* 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.Reflection;
using System.Collections.Generic;
using NLua.Method;
using NLua.Extensions;
namespace NLua
{
#if USE_KOPILUA
using LuaCore = KopiLua.Lua;
using LuaState = KopiLua.LuaState;
#else
using LuaCore = KeraLua.Lua;
using LuaState = KeraLua.LuaState;
#endif
/*
* Type checking and conversion functions.
*
* Author: Fabio Mascarenhas
* Version: 1.0
*/
sealed class CheckType
{
Dictionary<Type, ExtractValue> extractValues = new Dictionary<Type, ExtractValue>();
ExtractValue extractNetObject;
ObjectTranslator translator;
public CheckType (ObjectTranslator translator)
{
this.translator = translator;
extractValues.Add(GetExtractDictionaryKey(typeof(object)), new ExtractValue(GetAsObject));
extractValues.Add(GetExtractDictionaryKey(typeof(sbyte)), new ExtractValue(GetAsSbyte));
extractValues.Add(GetExtractDictionaryKey(typeof(byte)), new ExtractValue(GetAsByte));
extractValues.Add(GetExtractDictionaryKey(typeof(short)), new ExtractValue(GetAsShort));
extractValues.Add(GetExtractDictionaryKey(typeof(ushort)), new ExtractValue(GetAsUshort));
extractValues.Add(GetExtractDictionaryKey(typeof(int)), new ExtractValue(GetAsInt));
extractValues.Add(GetExtractDictionaryKey(typeof(uint)), new ExtractValue(GetAsUint));
extractValues.Add(GetExtractDictionaryKey(typeof(long)), new ExtractValue(GetAsLong));
extractValues.Add(GetExtractDictionaryKey(typeof(ulong)), new ExtractValue(GetAsUlong));
extractValues.Add(GetExtractDictionaryKey(typeof(double)), new ExtractValue(GetAsDouble));
extractValues.Add(GetExtractDictionaryKey(typeof(char)), new ExtractValue(GetAsChar));
extractValues.Add(GetExtractDictionaryKey(typeof(float)), new ExtractValue(GetAsFloat));
extractValues.Add(GetExtractDictionaryKey(typeof(decimal)), new ExtractValue(GetAsDecimal));
extractValues.Add(GetExtractDictionaryKey(typeof(bool)), new ExtractValue(GetAsBoolean));
extractValues.Add(GetExtractDictionaryKey(typeof(string)), new ExtractValue(GetAsString));
extractValues.Add(GetExtractDictionaryKey(typeof(char[])), new ExtractValue (GetAsCharArray));
extractValues.Add(GetExtractDictionaryKey(typeof(LuaFunction)), new ExtractValue(GetAsFunction));
extractValues.Add(GetExtractDictionaryKey(typeof(LuaTable)), new ExtractValue(GetAsTable));
extractValues.Add(GetExtractDictionaryKey(typeof(LuaUserData)), new ExtractValue(GetAsUserdata));
extractNetObject = new ExtractValue (GetAsNetObject);
}
/*
* Checks if the value at Lua stack index stackPos matches paramType,
* returning a conversion function if it does and null otherwise.
*/
internal ExtractValue GetExtractor (ProxyType paramType)
{
return GetExtractor (paramType.UnderlyingSystemType);
}
internal ExtractValue GetExtractor (Type paramType)
{
if (paramType.IsByRef)
paramType = paramType.GetElementType ();
var extractKey = GetExtractDictionaryKey(paramType);
return extractValues.ContainsKey(extractKey) ? extractValues[extractKey] : extractNetObject;
}
internal ExtractValue CheckLuaType (LuaState luaState, int stackPos, Type paramType)
{
var luatype = LuaLib.LuaType (luaState, stackPos);
if (paramType.IsByRef)
paramType = paramType.GetElementType ();
var underlyingType = Nullable.GetUnderlyingType (paramType);
if (underlyingType != null) {
paramType = underlyingType; // Silently convert nullable types to their non null requics
}
var extractKey = GetExtractDictionaryKey (paramType);
bool netParamIsNumeric = paramType == typeof (int) ||
paramType == typeof (uint) ||
paramType == typeof (long) ||
paramType == typeof (ulong) ||
paramType == typeof (short) ||
paramType == typeof (ushort) ||
paramType == typeof (float) ||
paramType == typeof (double) ||
paramType == typeof (decimal) ||
paramType == typeof (byte);
// If it is a nullable
if (underlyingType != null) {
// null can always be assigned to nullable
if (luatype == LuaTypes.Nil) {
// Return the correct extractor anyways
if (netParamIsNumeric || paramType == typeof (bool))
return extractValues [extractKey];
return extractNetObject;
}
}
if (paramType.Equals (typeof(object)))
return extractValues [extractKey];
//CP: Added support for generic parameters
if (paramType.IsGenericParameter) {
if (luatype == LuaTypes.Boolean)
return extractValues [GetExtractDictionaryKey (typeof(bool))];
else if (luatype == LuaTypes.String)
return extractValues[GetExtractDictionaryKey (typeof(string))];
else if (luatype == LuaTypes.Table)
return extractValues [GetExtractDictionaryKey (typeof(LuaTable))];
else if (luatype == LuaTypes.UserData)
return extractValues [GetExtractDictionaryKey (typeof(object))];
else if (luatype == LuaTypes.Function)
return extractValues [GetExtractDictionaryKey (typeof(LuaFunction))];
else if (luatype == LuaTypes.Number)
return extractValues [GetExtractDictionaryKey (typeof(double))];
}
bool netParamIsString = paramType == typeof (string) || paramType == typeof (char []);
if (netParamIsNumeric) {
if (LuaLib.LuaIsNumber (luaState, stackPos) && !netParamIsString)
return extractValues [extractKey];
} else if (paramType == typeof(bool)) {
if (LuaLib.LuaIsBoolean (luaState, stackPos))
return extractValues [extractKey];
} else if (netParamIsString) {
if (LuaLib.LuaNetIsStringStrict (luaState, stackPos))
return extractValues [extractKey];
else if (luatype == LuaTypes.Nil)
return extractNetObject; // kevinh - silently convert nil to a null string pointer
} else if (paramType == typeof(LuaTable)) {
if (luatype == LuaTypes.Table || luatype == LuaTypes.Nil)
return extractValues [extractKey];
} else if (paramType == typeof(LuaUserData)) {
if (luatype == LuaTypes.UserData || luatype == LuaTypes.Nil)
return extractValues [extractKey];
} else if (paramType == typeof(LuaFunction)) {
if (luatype == LuaTypes.Function || luatype == LuaTypes.Nil)
return extractValues [extractKey];
} else if (typeof(Delegate).IsAssignableFrom (paramType) && luatype == LuaTypes.Function)
return new ExtractValue (new DelegateGenerator (translator, paramType).ExtractGenerated);
else if (paramType.IsInterface() && luatype == LuaTypes.Table)
return new ExtractValue (new ClassGenerator (translator, paramType).ExtractGenerated);
else if ((paramType.IsInterface() || paramType.IsClass()) && luatype == LuaTypes.Nil) {
// kevinh - allow nil to be silently converted to null - extractNetObject will return null when the item ain't found
return extractNetObject;
} else if (LuaLib.LuaType (luaState, stackPos) == LuaTypes.Table) {
if (LuaLib.LuaLGetMetafield (luaState, stackPos, "__index")) {
object obj = translator.GetNetObject (luaState, -1);
LuaLib.LuaSetTop (luaState, -2);
if (obj != null && paramType.IsAssignableFrom (obj.GetType ()))
return extractNetObject;
} else
return null;
} else {
object obj = translator.GetNetObject (luaState, stackPos);
if (obj != null && paramType.IsAssignableFrom (obj.GetType ()))
return extractNetObject;
}
return null;
}
Type GetExtractDictionaryKey(Type targetType)
{
return targetType;
}
/*
* The following functions return the value in the Lua stack
* index stackPos as the desired type if it can, or null
* otherwise.
*/
private object GetAsSbyte (LuaState luaState, int stackPos)
{
sbyte retVal = (sbyte)LuaLib.LuaToNumber (luaState, stackPos);
if (retVal == 0 && !LuaLib.LuaIsNumber (luaState, stackPos))
return null;
return retVal;
}
private object GetAsByte (LuaState luaState, int stackPos)
{
byte retVal = (byte)LuaLib.LuaToNumber (luaState, stackPos);
if (retVal == 0 && !LuaLib.LuaIsNumber (luaState, stackPos))
return null;
return retVal;
}
private object GetAsShort (LuaState luaState, int stackPos)
{
short retVal = (short)LuaLib.LuaToNumber (luaState, stackPos);
if (retVal == 0 && !LuaLib.LuaIsNumber (luaState, stackPos))
return null;
return retVal;
}
private object GetAsUshort (LuaState luaState, int stackPos)
{
ushort retVal = (ushort)LuaLib.LuaToNumber (luaState, stackPos);
if (retVal == 0 && !LuaLib.LuaIsNumber (luaState, stackPos))
return null;
return retVal;
}
private object GetAsInt (LuaState luaState, int stackPos)
{
if (!LuaLib.LuaIsNumber (luaState, stackPos))
return null;
int retVal = (int)LuaLib.LuaToNumber (luaState, stackPos);
return retVal;
}
private object GetAsUint (LuaState luaState, int stackPos)
{
uint retVal = (uint)LuaLib.LuaToNumber (luaState, stackPos);
if (retVal == 0 && !LuaLib.LuaIsNumber (luaState, stackPos))
return null;
return retVal;
}
private object GetAsLong (LuaState luaState, int stackPos)
{
long retVal = (long)LuaLib.LuaToNumber (luaState, stackPos);
if (retVal == 0 && !LuaLib.LuaIsNumber (luaState, stackPos))
return null;
return retVal;
}
private object GetAsUlong (LuaState luaState, int stackPos)
{
ulong retVal = (ulong)LuaLib.LuaToNumber (luaState, stackPos);
if (retVal == 0 && !LuaLib.LuaIsNumber (luaState, stackPos))
return null;
return retVal;
}
private object GetAsDouble (LuaState luaState, int stackPos)
{
double retVal = LuaLib.LuaToNumber (luaState, stackPos);
if (retVal == 0 && !LuaLib.LuaIsNumber (luaState, stackPos))
return null;
return retVal;
}
private object GetAsChar (LuaState luaState, int stackPos)
{
char retVal = (char)LuaLib.LuaToNumber (luaState, stackPos);
if (retVal == 0 && !LuaLib.LuaIsNumber (luaState, stackPos))
return null;
return retVal;
}
private object GetAsFloat (LuaState luaState, int stackPos)
{
float retVal = (float)LuaLib.LuaToNumber (luaState, stackPos);
if (retVal == 0 && !LuaLib.LuaIsNumber (luaState, stackPos))
return null;
return retVal;
}
private object GetAsDecimal (LuaState luaState, int stackPos)
{
decimal retVal = (decimal)LuaLib.LuaToNumber (luaState, stackPos);
if (retVal == 0 && !LuaLib.LuaIsNumber (luaState, stackPos))
return null;
return retVal;
}
private object GetAsBoolean (LuaState luaState, int stackPos)
{
return LuaLib.LuaToBoolean (luaState, stackPos);
}
private object GetAsCharArray (LuaState luaState, int stackPos)
{
if (!LuaLib.LuaNetIsStringStrict (luaState, stackPos))
return null;
string retVal = LuaLib.LuaToString (luaState, stackPos).ToString ();
return retVal.ToCharArray();
}
private object GetAsString (LuaState luaState, int stackPos)
{
if (!LuaLib.LuaNetIsStringStrict (luaState, stackPos))
return null;
string retVal = LuaLib.LuaToString (luaState, stackPos).ToString ();
return retVal;
}
private object GetAsTable (LuaState luaState, int stackPos)
{
return translator.GetTable (luaState, stackPos);
}
private object GetAsFunction (LuaState luaState, int stackPos)
{
return translator.GetFunction (luaState, stackPos);
}
private object GetAsUserdata (LuaState luaState, int stackPos)
{
return translator.GetUserData (luaState, stackPos);
}
public object GetAsObject (LuaState luaState, int stackPos)
{
if (LuaLib.LuaType (luaState, stackPos) == LuaTypes.Table) {
if (LuaLib.LuaLGetMetafield (luaState, stackPos, "__index")) {
if (LuaLib.LuaLCheckMetatable (luaState, -1)) {
LuaLib.LuaInsert (luaState, stackPos);
LuaLib.LuaRemove (luaState, stackPos + 1);
} else
LuaLib.LuaSetTop (luaState, -2);
}
}
object obj = translator.GetObject (luaState, stackPos);
return obj;
}
public object GetAsNetObject (LuaState luaState, int stackPos)
{
object obj = translator.GetNetObject (luaState, stackPos);
if (obj == null && LuaLib.LuaType (luaState, stackPos) == LuaTypes.Table) {
if (LuaLib.LuaLGetMetafield (luaState, stackPos, "__index")) {
if (LuaLib.LuaLCheckMetatable (luaState, -1)) {
LuaLib.LuaInsert (luaState, stackPos);
LuaLib.LuaRemove (luaState, stackPos + 1);
obj = translator.GetNetObject (luaState, stackPos);
} else
LuaLib.LuaSetTop (luaState, -2);
}
}
return obj;
}
}
}
\ No newline at end of file
/*
* This file is part of NLua.
*
* Copyright (c) 2015 Vinicius Jarina (viniciusjarina@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 NLua.Config
{
public static class Consts
{
public const string NLuaDescription = "Bridge between the Lua runtime and the CLR";
#if DEBUG
public const string NLuaConfiguration = "Debug";
#else
public const string NLuaConfiguration = "Release";
#endif
public const string NLuaCompany = "NLua.org";
public const string NLuaProduct = "NLua";
public const string NLuaCopyright = "Copyright 2003-2015 Vinicius Jarina , Fabio Mascarenhas, Kevin Hesterm and Megax";
public const string NLuaTrademark = "MIT license";
public const string NLuaVersion = "1.3.2";
public const string NLuaFileVersion = "1.3.2";
}
}
\ No newline at end of file
/*
* This file is part of NLua.
*
* Copyright (c) 2015 Vinicius Jarina (viniciusjarina@gmail.com)
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* 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 NLua.Event
{
#if USE_KOPILUA
using LuaCore = KopiLua.Lua;
using LuaState = KopiLua.LuaState;
using LuaDebug = KopiLua.LuaDebug;
#else
using LuaCore = KeraLua.Lua;
using LuaState = KeraLua.LuaState;
using LuaDebug = KeraLua.LuaDebug;
#endif
/// <summary>
/// Event args for hook callback event
/// </summary>
/// <author>Reinhard Ostermeier</author>
public class DebugHookEventArgs : EventArgs
{
private readonly LuaDebug luaDebug;
public DebugHookEventArgs (LuaDebug luaDebug)
{
this.luaDebug = luaDebug;
}
public LuaDebug LuaDebug {
get { return luaDebug; }
}
}
}
\ No newline at end of file
/*
* This file is part of NLua.
*
* Copyright (c) 2015 Vinicius Jarina (viniciusjarina@gmail.com)
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* 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 NLua.Event
{
/// <summary>
/// Event codes for lua hook function
/// </summary>
/// <remarks>
/// Do not change any of the values because they must match the lua values
/// </remarks>
public enum EventCodes
{
LUA_HOOKCALL = 0,
LUA_HOOKRET = 1,
LUA_HOOKLINE = 2,
LUA_HOOKCOUNT = 3,
LUA_HOOKTAILRET = 4
}
}
\ No newline at end of file
/*
* This file is part of NLua.
*
* Copyright (c) 2015 Vinicius Jarina (viniciusjarina@gmail.com)
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* 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 NLua.Event
{
/// <summary>
/// Event masks for lua hook callback
/// </summary>
/// <remarks>
/// Do not change any of the values because they must match the lua values
/// </remarks>
[Flags]
public enum EventMasks
{
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
}
}
\ No newline at end of file
/*
* This file is part of NLua.
*
* Copyright (c) 2015 Vinicius Jarina (viniciusjarina@gmail.com)
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* 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 NLua.Event
{
public class HookExceptionEventArgs : EventArgs
{
private readonly Exception m_Exception;
public Exception Exception {
get { return m_Exception; }
}
public HookExceptionEventArgs (Exception ex)
{
m_Exception = ex;
}
}
}
\ No newline at end of file
/*
* This file is part of NLua.
*
* Copyright (c) 2015 Vinicius Jarina (viniciusjarina@gmail.com)
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* 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;
#if !SILVERLIGHT && !NETFX_CORE
using System.Runtime.Serialization;
#endif
namespace NLua.Exceptions
{
/// <summary>
/// Exceptions thrown by the Lua runtime
/// </summary>
#if !SILVERLIGHT && !NETFX_CORE
[Serializable]
#endif
public class LuaException : Exception
{
public LuaException ()
{
}
public LuaException (string message) : base(message)
{
}
public LuaException (string message, Exception innerException) : base(message, innerException)
{
}
#if !SILVERLIGHT && !NETFX_CORE
protected LuaException (SerializationInfo info, StreamingContext context) : base(info, context)
{
}
#endif
}
}
\ No newline at end of file
/*
* This file is part of NLua.
*
* Copyright (c) 2015 Vinicius Jarina (viniciusjarina@gmail.com)
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* 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 NLua.Exceptions
{
/// <summary>
/// Exceptions thrown by the Lua runtime because of errors in the script
/// </summary>
///
#if !SILVERLIGHT && !NETFX_CORE
[Serializable]
#endif
public class LuaScriptException : LuaException
{
/// <summary>
/// Returns true if the exception has occured as the result of a .NET exception in user code
/// </summary>
public bool IsNetException { get; private set; }
private readonly string source;
/// <summary>
/// The position in the script where the exception was triggered.
/// </summary>
#if SILVERLIGHT && !WINDOWS_PHONE
public string Source { get { return source; } }
#else
public override string Source { get { return source; } }
#endif
/// <summary>
/// Creates a new Lua-only exception.
/// </summary>
/// <param name="message">The message that describes the error.</param>
/// <param name="source">The position in the script where the exception was triggered.</param>
public LuaScriptException (string message, string source) : base(message)
{
this.source = source;
}
/// <summary>
/// Creates a new .NET wrapping exception.
/// </summary>
/// <param name="innerException">The .NET exception triggered by user-code.</param>
/// <param name="source">The position in the script where the exception was triggered.</param>
public LuaScriptException (Exception innerException, string source)
: base("A .NET exception occured in user-code", innerException)
{
this.source = source;
this.IsNetException = true;
}
public override string ToString ()
{
// Prepend the error source
return GetType ().FullName + ": " + source + Message;
}
}
}
\ No newline at end of file
/*
* This file is part of NLua.
*
* Copyright (c) 2015 Vinicius Jarina (viniciusjarina@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.Linq;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace NLua.Extensions
{
/// <summary>
/// Some random extension stuff.
/// </summary>
static class CheckNull
{
/// <summary>
/// Determines whether the specified obj is null.
/// </summary>
/// <param name="obj">The obj.</param>
/// <returns>
/// <c>true</c> if the specified obj is null; otherwise, <c>false</c>.
/// </returns>
///
#if USE_KOPILUA
public static bool IsNull (object obj)
{
return (obj == null);
}
#else
public static bool IsNull (IntPtr ptr)
{
return (ptr.Equals (IntPtr.Zero));
}
#endif
}
static class TypeExtensions
{
public static bool HasMethod (this Type t, string name)
{
var op = t.GetMethods (BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
return op.Any (m => m.Name == name);
}
public static bool HasAdditionOpertator (this Type t)
{
if (t.IsPrimitive ())
return true;
return t.HasMethod ("op_Addition");
}
public static bool HasSubtractionOpertator (this Type t)
{
if (t.IsPrimitive ())
return true;
return t.HasMethod ("op_Subtraction");
}
public static bool HasMultiplyOpertator (this Type t)
{
if (t.IsPrimitive ())
return true;
return t.HasMethod ("op_Multiply");
}
public static bool HasDivisionOpertator (this Type t)
{
if (t.IsPrimitive ())
return true;
return t.HasMethod ("op_Division");
}
public static bool HasModulusOpertator (this Type t)
{
if (t.IsPrimitive ())
return true;
return t.HasMethod ("op_Modulus");
}
public static bool HasUnaryNegationOpertator (this Type t)
{
if (t.IsPrimitive ())
return true;
// Unary - will always have only one version.
var op = t.GetMethod ("op_UnaryNegation", BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
return op != null;
}
public static bool HasEqualityOpertator (this Type t)
{
if (t.IsPrimitive ())
return true;
return t.HasMethod ("op_Equality");
}
public static bool HasLessThanOpertator (this Type t)
{
if (t.IsPrimitive ())
return true;
return t.HasMethod ("op_LessThan");
}
public static bool HasLessThanOrEqualOpertator (this Type t)
{
if (t.IsPrimitive ())
return true;
return t.HasMethod ("op_LessThanOrEqual");
}
public static MethodInfo [] GetMethods (this Type t, string name, BindingFlags flags)
{
return t.GetMethods (flags).Where (m => m.Name == name).ToArray ();
}
public static MethodInfo [] GetExtensionMethods (this Type type, IEnumerable<Assembly> assemblies = null)
{
List<Type> types = new List<Type> ();
types.AddRange (type.GetAssembly().GetTypes ().Where (t => t.IsPublic ()));
if (assemblies != null) {
foreach (Assembly item in assemblies) {
if (item == type.GetAssembly ())
continue;
types.AddRange (item.GetTypes ().Where (t => t.IsPublic ()));
}
}
var query = from extensionType in types
where extensionType.IsSealed() && !extensionType.IsGenericType() && !extensionType.IsNested
from method in extensionType.GetMethods (BindingFlags.Static | BindingFlags.Public)
where method.IsDefined (typeof (ExtensionAttribute), false)
where (method.GetParameters()[0].ParameterType == type
|| type.IsSubclassOf(method.GetParameters()[0].ParameterType)
|| type.GetInterfaces().Contains(method.GetParameters()[0].ParameterType))
select method;
return query.ToArray<MethodInfo> ();
}
/// <summary>
/// Extends the System.Type-type to search for a given extended MethodeName.
/// </summary>
/// <param name="MethodeName">Name of the Methode</param>
/// <returns>the found Method or null</returns>
public static MethodInfo GetExtensionMethod (this Type t, string name, IEnumerable<Assembly> assemblies = null)
{
var mi = from methode in t.GetExtensionMethods (assemblies)
where methode.Name == name
select methode;
if (!mi.Any<MethodInfo> ())
return null;
else
return mi.First<MethodInfo> ();
}
public static bool IsPrimitive (this Type t)
{
#if NETFX_CORE
return t.GetTypeInfo ().IsPrimitive;
#else
return t.IsPrimitive;
#endif
}
public static bool IsClass (this Type t)
{
#if NETFX_CORE
return t.GetTypeInfo ().IsClass;
#else
return t.IsClass;
#endif
}
public static bool IsEnum (this Type t)
{
#if NETFX_CORE
return t.GetTypeInfo ().IsEnum;
#else
return t.IsEnum;
#endif
}
public static bool IsPublic (this Type t)
{
#if NETFX_CORE
return t.GetTypeInfo ().IsPublic;
#else
return t.IsPublic;
#endif
}
public static bool IsSealed (this Type t)
{
#if NETFX_CORE
return t.GetTypeInfo ().IsSealed;
#else
return t.IsSealed;
#endif
}
public static bool IsGenericType (this Type t)
{
#if NETFX_CORE
return t.GetTypeInfo ().IsGenericType;
#else
return t.IsGenericType;
#endif
}
public static bool IsInterface (this Type t)
{
#if NETFX_CORE
return t.GetTypeInfo ().IsInterface;
#else
return t.IsInterface;
#endif
}
public static Assembly GetAssembly (this Type t)
{
#if NETFX_CORE
return t.GetTypeInfo ().Assembly;
#else
return t.Assembly;
#endif
}
#if NETFX_CORE
// Missing Reflection methods from WinRT
public const BindingFlags Default = BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance;
public static MethodInfo GetMethod (this Type type, string name, BindingFlags flags, Type [] signature)
{
return GetMethods (type, flags).FirstOrDefault (c => c.Name == name && c.GetParameters ().Select (p => p.ParameterType).SequenceEqual (signature));
}
static IEnumerable<Type> GetTypes (this Assembly assembly)
{
return assembly.ExportedTypes;
}
public static bool IsAssignableFrom (this Type t, Type t2)
{
return t.GetTypeInfo ().IsAssignableFrom (t2.GetTypeInfo ());
}
public static MemberInfo [] GetMember (this Type type, string name, BindingFlags flags)
{
return GetMembers (type, flags).Where (m => m.Name == name).ToArray ();
}
public static MemberInfo [] GetMembers (this Type type, BindingFlags flags)
{
// Metro does have DeclaredMembers but nothing otherwise
return GetEvents (type, flags).Cast<MemberInfo> ()
.Concat (GetFields (type, flags).Cast<MemberInfo> ())
.Concat (GetMethods (type, flags).Cast<MemberInfo> ())
.Concat (GetProperties (type, flags).Cast<MemberInfo> ())
.ToArray ();
}
public static MethodInfo GetMethod (this Type type, string name)
{
return GetMethod (type, name, Default);
}
public static MethodInfo GetMethod (this Type type, string name, BindingFlags flags)
{
return GetMethods (type, flags).FirstOrDefault (m => m.Name == name);
}
public static MethodInfo [] GetMethods (this Type type)
{
return GetMethods (type, Default);
}
public static MethodInfo [] GetMethods (this Type type, BindingFlags flags)
{
var methods = type.GetRuntimeMethods ();
return methods.Where (m =>
((flags.HasFlag (BindingFlags.Static) == m.IsStatic) || (flags.HasFlag (BindingFlags.Instance) == !m.IsStatic)
) &&
(flags.HasFlag (BindingFlags.Public) == m.IsPublic)
).ToArray ();
}
public static PropertyInfo [] GetProperties (this Type type, BindingFlags flags)
{
var props = type.GetRuntimeProperties ();
return props.Where (p =>
((flags.HasFlag (BindingFlags.Static) == (p.GetMethod != null && p.GetMethod.IsStatic)) ||
(flags.HasFlag (BindingFlags.Instance) == (p.GetMethod != null && !p.GetMethod.IsStatic))
) &&
(flags.HasFlag (BindingFlags.Public) == (p.GetMethod != null && p.GetMethod.IsPublic)
)).ToArray ();
}
public static ConstructorInfo GetConstructor (this Type type, Type [] paramTypes)
{
return GetConstructors (type, Default).FirstOrDefault (c => c.GetParameters ().Select (p => p.ParameterType).SequenceEqual (paramTypes));
}
public static ConstructorInfo [] GetConstructors (this Type type)
{
return GetConstructors (type, Default);
}
public static ConstructorInfo [] GetConstructors (this Type type, BindingFlags flags)
{
var props = type.GetTypeInfo ().DeclaredConstructors;
return props.Where (p =>
((flags.HasFlag (BindingFlags.Static) == p.IsStatic) ||
(flags.HasFlag (BindingFlags.Instance) == !p.IsStatic)
) &&
(flags.HasFlag (BindingFlags.Public) == p.IsPublic)
).ToArray ();
}
public static EventInfo [] GetEvents (this Type type, BindingFlags flags)
{
var props = type.GetRuntimeEvents ();
return props.Where (p =>
((flags.HasFlag (BindingFlags.Static) == p.AddMethod.IsStatic) ||
(flags.HasFlag (BindingFlags.Instance) == !p.AddMethod.IsStatic)
) &&
(flags.HasFlag (BindingFlags.Public) == p.AddMethod.IsPublic)
).ToArray ();
}
public static FieldInfo GetField (this Type type, string name)
{
return GetField (type, name, Default);
}
public static FieldInfo GetField (this Type type, string name, BindingFlags flags)
{
return GetFields (type, flags).FirstOrDefault (f => f.Name == name);
}
public static FieldInfo [] GetFields (this Type type, BindingFlags flags)
{
var fields = type.GetRuntimeFields ();
return fields.Where (p =>
((flags.HasFlag (BindingFlags.Static) == p.IsStatic) || (flags.HasFlag (BindingFlags.Instance) == !p.IsStatic)
) &&
(flags.HasFlag (BindingFlags.Public) == p.IsPublic)
).ToArray ();
}
public static bool ImplementInterface (this Type t, string name)
{
return t.GetTypeInfo ().ImplementedInterfaces.Any (i => i.Name == name);
}
#endif
}
static class StringExtensions
{
public static IEnumerable<string> SplitWithEscape (this string input, char separator, char escapeCharacter)
{
int start = 0;
int index = 0;
while (index < input.Length) {
index = input.IndexOf (separator, index);
if (index == -1)
break;
if (input [index - 1] == escapeCharacter) {
input = input.Remove (index - 1, 1);
continue;
}
yield return input.Substring (start, index - start);
index++;
start = index;
}
yield return input.Substring (start);
}
}
}
\ No newline at end of file
/*
* This file is part of NLua.
*
* Copyright (c) 2015 Vinicius Jarina (viniciusjarina@gmail.com)
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* 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 NLua
{
#if USE_KOPILUA
using LuaCore = KopiLua.Lua;
using LuaState = KopiLua.LuaState;
#else
using LuaCore = KeraLua.Lua;
using LuaState = KeraLua.LuaState;
#endif
/*
* Class used for generating delegates that get a table from the Lua
* stack as a an object of a specific type.
*
* Author: Fabio Mascarenhas
* Version: 1.0
*/
class ClassGenerator
{
private ObjectTranslator translator;
private Type klass;
public ClassGenerator (ObjectTranslator objTranslator, Type typeClass)
{
translator = objTranslator;
klass = typeClass;
}
public object ExtractGenerated (LuaState luaState, int stackPos)
{
return CodeGeneration.Instance.GetClassInstance (klass, translator.GetTable (luaState, stackPos));
}
}
}
\ No newline at end of file
This diff is collapsed.
/*
* This file is part of NLua.
*
* Copyright (c) 2015 Vinicius Jarina (viniciusjarina@gmail.com)
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* 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 NLua
{
#if USE_KOPILUA
using LuaCore = KopiLua.Lua;
using LuaState = KopiLua.LuaState;
#else
using LuaCore = KeraLua.Lua;
using LuaState = KeraLua.LuaState;
#endif
/*
* Class used for generating delegates that get a function from the Lua
* stack as a delegate of a specific type.
*
* Author: Fabio Mascarenhas
* Version: 1.0
*/
class DelegateGenerator
{
private ObjectTranslator translator;
private Type delegateType;
public DelegateGenerator (ObjectTranslator objectTranslator, Type type)
{
translator = objectTranslator;
delegateType = type;
}
public object ExtractGenerated (LuaState luaState, int stackPos)
{
return CodeGeneration.Instance.GetDelegate (delegateType, translator.GetFunction (luaState, stackPos));
}
}
}
\ No newline at end of file
/*
* This file is part of NLua.
*
* Copyright (c) 2015 Vinicius Jarina (viniciusjarina@gmail.com)
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* 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 NLua
{
/*
* Common interface for types generated from tables. The method
* returns the table that overrides some or all of the type's methods.
*/
public interface ILuaGeneratedType
{
LuaTable LuaInterfaceGetLuaTable ();
}
}
\ No newline at end of file
/*
* This file is part of NLua.
*
* Copyright (c) 2015 Vinicius Jarina (viniciusjarina@gmail.com)
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* 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 NLua
{
/*
* Structure to store a type and the return types of
* its methods (the type of the returned value and out/ref
* parameters).
*/
struct LuaClassType
{
public Type klass;
public Type[][] returnTypes;
}
}
\ No newline at end of file
This diff is collapsed.
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