Commit 8f41eff7 authored by Vinicius Jarina's avatar Vinicius Jarina
Browse files

Minor cleanup. (removed unnecessary attributes).

parent e029feb0
......@@ -47,13 +47,9 @@ namespace NLua
*/
sealed class CheckType
{
#if SILVERLIGHT
private Dictionary<Type, ExtractValue> extractValues = new Dictionary<Type, ExtractValue>();
#else
private Dictionary<long, ExtractValue> extractValues = new Dictionary<long, ExtractValue> ();
#endif
private ExtractValue extractNetObject;
private ObjectTranslator translator;
Dictionary<Type, ExtractValue> extractValues = new Dictionary<Type, ExtractValue>();
ExtractValue extractNetObject;
ObjectTranslator translator;
public CheckType (ObjectTranslator translator)
{
......@@ -185,17 +181,10 @@ namespace NLua
return null;
}
#if SILVERLIGHT
private Type GetExtractDictionaryKey(Type targetType)
Type GetExtractDictionaryKey(Type targetType)
{
return targetType;
}
#else
private long GetExtractDictionaryKey(Type targetType)
{
return targetType.TypeHandle.Value.ToInt64();
}
#endif
/*
* The following functions return the value in the Lua stack
......
......@@ -333,7 +333,6 @@ end
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
static int PanicCallback (LuaState luaState)
{
string reason = string.Format ("unprotected error in call to Lua API ({0})", LuaLib.LuaToString (luaState, -1));
......@@ -426,7 +425,7 @@ end
}
/// <summary>
///
/// Load a File on, and return a LuaFunction to execute the file loaded (useful to see if the syntax of a file is ok)
/// </summary>
/// <param name = "fileName"></param>
/// <returns></returns>
......@@ -603,8 +602,8 @@ end
string name = method.Name;
if (
// Check that the LuaHideAttribute and LuaGlobalAttribute were not applied
(method.GetCustomAttributes (typeof(LuaHideAttribute), false).Length == 0) &&
(method.GetCustomAttributes (typeof(LuaGlobalAttribute), false).Length == 0) &&
(!method.GetCustomAttributes (typeof(LuaHideAttribute), false).Any ()) &&
(!method.GetCustomAttributes (typeof(LuaGlobalAttribute), false).Any ()) &&
// Exclude some generic .NET methods that wouldn't be very usefull in Lua
name != "GetType" && name != "GetHashCode" && name != "Equals" &&
name != "ToString" && name != "Clone" && name != "Dispose" &&
......@@ -627,8 +626,8 @@ end
foreach (var field in type.GetFields(BindingFlags.Public | BindingFlags.Instance)) {
if (
// Check that the LuaHideAttribute and LuaGlobalAttribute were not applied
(field.GetCustomAttributes (typeof(LuaHideAttribute), false).Length == 0) &&
(field.GetCustomAttributes (typeof(LuaGlobalAttribute), false).Length == 0)) {
(!field.GetCustomAttributes (typeof(LuaHideAttribute), false).Any ()) &&
(!field.GetCustomAttributes (typeof(LuaGlobalAttribute), false).Any ())) {
// Go into recursion for members
RegisterGlobal (path + "." + field.Name, field.FieldType, recursionCounter + 1);
}
......@@ -639,8 +638,8 @@ end
foreach (var property in type.GetProperties(BindingFlags.Public | BindingFlags.Instance)) {
if (
// Check that the LuaHideAttribute and LuaGlobalAttribute were not applied
(property.GetCustomAttributes (typeof(LuaHideAttribute), false).Length == 0) &&
(property.GetCustomAttributes (typeof(LuaGlobalAttribute), false).Length == 0)
(!property.GetCustomAttributes (typeof(LuaHideAttribute), false).Any ()) &&
(!property.GetCustomAttributes (typeof(LuaGlobalAttribute), false).Any ())
// Exclude some generic .NET properties that wouldn't be very usefull in Lua
&& property.Name != "Item") {
// Go into recursion for members
......@@ -660,7 +659,7 @@ end
* Navigates a table in the top of the stack, returning
* the value of the specified field
*/
internal object GetObject (string[] remainingPath)
object GetObject (string[] remainingPath)
{
object returnValue = null;
......@@ -792,7 +791,7 @@ end
/*
* Navigates a table to set the value of one of its fields
*/
internal void SetObject (string[] remainingPath, object val)
void SetObject (string[] remainingPath, object val)
{
for (int i = 0; i < remainingPath.Length-1; i++) {
LuaLib.LuaPushString (luaState, remainingPath [i]);
......@@ -965,7 +964,6 @@ end
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaHook))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
#if USE_KOPILUA
static void DebugHookCallback (LuaState luaState, LuaDebug debug)
{
......@@ -1068,7 +1066,8 @@ end
/*
* Sets a field of the table or userdata corresponding the the provided reference
* to the provided value
*/ internal void SetObject (int reference, string field, object val)
*/
internal void SetObject (int reference, string field, object val)
{
int oldTop = LuaLib.LuaGetTop (luaState);
LuaLib.LuaGetRef (luaState, reference);
......
......@@ -126,7 +126,6 @@ namespace NLua
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int RunFunctionDelegate (LuaState luaState)
{
var translator = ObjectTranslatorPool.Instance.Find (luaState);
......@@ -146,7 +145,6 @@ namespace NLua
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int CollectObject (LuaState luaState)
{
var translator = ObjectTranslatorPool.Instance.Find (luaState);
......@@ -169,7 +167,6 @@ namespace NLua
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int ToStringLua (LuaState luaState)
{
var translator = ObjectTranslatorPool.Instance.Find (luaState);
......@@ -195,7 +192,6 @@ namespace NLua
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
static int AddLua (LuaState luaState)
{
var translator = ObjectTranslatorPool.Instance.Find (luaState);
......@@ -208,7 +204,6 @@ namespace NLua
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
static int SubtractLua (LuaState luaState)
{
var translator = ObjectTranslatorPool.Instance.Find (luaState);
......@@ -221,7 +216,6 @@ namespace NLua
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
static int MultiplyLua (LuaState luaState)
{
var translator = ObjectTranslatorPool.Instance.Find (luaState);
......@@ -234,7 +228,6 @@ namespace NLua
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
static int DivideLua (LuaState luaState)
{
var translator = ObjectTranslatorPool.Instance.Find (luaState);
......@@ -247,7 +240,6 @@ namespace NLua
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
static int ModLua (LuaState luaState)
{
var translator = ObjectTranslatorPool.Instance.Find (luaState);
......@@ -260,12 +252,12 @@ namespace NLua
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
static int UnaryNegationLua (LuaState luaState)
{
var translator = ObjectTranslatorPool.Instance.Find (luaState);
return UnaryNegationLua (luaState, translator);
}
static int UnaryNegationLua (LuaState luaState, ObjectTranslator translator)
{
object obj1 = translator.GetRawNetObject (luaState, 1);
......@@ -296,7 +288,6 @@ namespace NLua
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
static int EqualLua (LuaState luaState)
{
var translator = ObjectTranslatorPool.Instance.Find (luaState);
......@@ -309,7 +300,6 @@ namespace NLua
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
static int LessThanLua (LuaState luaState)
{
var translator = ObjectTranslatorPool.Instance.Find (luaState);
......@@ -322,7 +312,6 @@ namespace NLua
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
static int LessThanOrEqualLua (LuaState luaState)
{
var translator = ObjectTranslatorPool.Instance.Find (luaState);
......@@ -376,7 +365,6 @@ namespace NLua
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int GetMethod (LuaState luaState)
{
var translator = ObjectTranslatorPool.Instance.Find (luaState);
......@@ -481,7 +469,6 @@ namespace NLua
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int GetBaseMethod (LuaState luaState)
{
var translator = ObjectTranslatorPool.Instance.Find (luaState);
......@@ -740,7 +727,6 @@ namespace NLua
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int SetFieldOrProperty (LuaState luaState)
{
var translator = ObjectTranslatorPool.Instance.Find (luaState);
......@@ -915,7 +901,6 @@ namespace NLua
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int GetClassMethod (LuaState luaState)
{
var translator = ObjectTranslatorPool.Instance.Find (luaState);
......@@ -957,7 +942,6 @@ namespace NLua
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int SetClassFieldOrProperty (LuaState luaState)
{
var translator = ObjectTranslatorPool.Instance.Find (luaState);
......@@ -988,7 +972,6 @@ namespace NLua
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int CallConstructor (LuaState luaState)
{
var translator = ObjectTranslatorPool.Instance.Find (luaState);
......@@ -1252,7 +1235,7 @@ namespace NLua
{
extractValue = null;
if (currentNetParam.GetCustomAttributes (typeof(ParamArrayAttribute), false).Length > 0) {
if (currentNetParam.GetCustomAttributes (typeof(ParamArrayAttribute), false).Any ()) {
LuaTypes luaType;
try {
......
......@@ -262,7 +262,6 @@ namespace NLua
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int LoadAssembly (LuaState luaState)
{
var translator = ObjectTranslatorPool.Instance.Find (luaState);
......@@ -346,7 +345,6 @@ namespace NLua
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int ImportType (LuaState luaState)
{
var translator = ObjectTranslatorPool.Instance.Find (luaState);
......@@ -374,7 +372,6 @@ namespace NLua
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int RegisterTable (LuaState luaState)
{
var translator = ObjectTranslatorPool.Instance.Find (luaState);
......@@ -426,7 +423,6 @@ namespace NLua
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int UnregisterTable (LuaState luaState)
{
var translator = ObjectTranslatorPool.Instance.Find (luaState);
......@@ -471,7 +467,6 @@ namespace NLua
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int GetMethodSignature (LuaState luaState)
{
var translator = ObjectTranslatorPool.Instance.Find (luaState);
......@@ -524,7 +519,6 @@ namespace NLua
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int GetConstructorSignature (LuaState luaState)
{
var translator = ObjectTranslatorPool.Instance.Find (luaState);
......@@ -974,7 +968,6 @@ namespace NLua
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int CType (LuaState luaState)
{
var translator = ObjectTranslatorPool.Instance.Find (luaState);
......@@ -994,7 +987,6 @@ namespace NLua
#if MONOTOUCH
[MonoTouch.MonoPInvokeCallback (typeof (LuaNativeFunction))]
#endif
[System.Runtime.InteropServices.AllowReversePInvokeCalls]
private static int EnumFromInt (LuaState luaState)
{
var translator = ObjectTranslatorPool.Instance.Find (luaState);
......
......@@ -2181,7 +2181,7 @@ namespace NLuaTest
string expected = "[0] [C]:-1 -- func [field]\n[1] [string \"chunk\"]:12 -- f3 [global]\n[2] [string \"chunk\"]:8 -- f2 [global]\n[3] [string \"chunk\"]:4 -- f1 [global]\n[4] [string \"chunk\"]:15 -- <unknow> []\n";
KopiLua.LuaDebug info = new KopiLua.LuaDebug ();
#else
string expected = "[0] func:-1 -- <unknown> [func]\n[1] f3:12 -- <unknown> [f3]\n[2] f2:8 -- <unknown> [f2]\n[3] f1:4 -- <unknown> [f1]\n[4] :15 -- []\n";
//string expected = "[0] func:-1 -- <unknown> [func]\n[1] f3:12 -- <unknown> [f3]\n[2] f2:8 -- <unknown> [f2]\n[3] f1:4 -- <unknown> [f1]\n[4] :15 -- []\n";
KeraLua.LuaDebug info = new KeraLua.LuaDebug ();
#endif
......
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