"packages/KeraLua.1.0.27/lib/MonoAndroid/KeraLua.xml" did not exist on "ea29d831588935c714eba08858d2fd78ab81ecfe"
Commit 91321617 authored by Vinicius Jarina's avatar Vinicius Jarina
Browse files

Fixed more gendarme warnings.

parent 5866945e
......@@ -106,7 +106,7 @@ namespace NLua
var underlyingType = Nullable.GetUnderlyingType (paramType);
if (!underlyingType.IsNull ())
if (underlyingType != null)
paramType = underlyingType; // Silently convert nullable types to their non null requics
var extractKey = GetExtractDictionaryKey (paramType);
......@@ -161,13 +161,13 @@ namespace NLua
if (LuaLib.LuaLGetMetafield (luaState, stackPos, "__index")) {
object obj = translator.GetNetObject (luaState, -1);
LuaLib.LuaSetTop (luaState, -2);
if (!obj.IsNull () && paramType.IsAssignableFrom (obj.GetType ()))
if (obj != null && paramType.IsAssignableFrom (obj.GetType ()))
return extractNetObject;
} else
return null;
} else {
object obj = translator.GetNetObject (luaState, stackPos);
if (!obj.IsNull () && paramType.IsAssignableFrom (obj.GetType ()))
if (obj != null && paramType.IsAssignableFrom (obj.GetType ()))
return extractNetObject;
}
......@@ -348,7 +348,7 @@ namespace NLua
{
object obj = translator.GetNetObject (luaState, stackPos);
if (obj.IsNull () && LuaLib.LuaType (luaState, stackPos) == LuaTypes.Table) {
if (obj == null && LuaLib.LuaType (luaState, stackPos) == LuaTypes.Table) {
if (LuaLib.LuaLGetMetafield (luaState, stackPos, "__index")) {
if (LuaLib.LuaLCheckMetatable (luaState, -1)) {
LuaLib.LuaInsert (luaState, stackPos);
......
......@@ -30,6 +30,8 @@ namespace NLua.Exceptions
/// <summary>
/// Exceptions thrown by the Lua runtime because of errors in the script
/// </summary>
///
[Serializable]
public class LuaScriptException : LuaException
{
/// <summary>
......
......@@ -29,7 +29,7 @@ namespace NLua.Extensions
/// <summary>
/// Some random extension stuff.
/// </summary>
static class GeneralExtensions
static class CheckNull
{
/// <summary>
/// Determines whether the specified obj is null.
......@@ -38,14 +38,18 @@ namespace NLua.Extensions
/// <returns>
/// <c>true</c> if the specified obj is null; otherwise, <c>false</c>.
/// </returns>
public static bool IsNull (this object obj)
///
#if USE_KOPILUA
public static bool IsNull (object obj)
{
return (obj == null);
}
#else
public static bool IsNull (this IntPtr ptr)
public static bool IsNull (IntPtr ptr)
{
return (ptr.Equals (IntPtr.Zero));
}
#endif
}
}
\ No newline at end of file
......@@ -96,7 +96,7 @@ namespace NLua
#else
string typeName;
lock (this) {
typeName = "LuaGeneratedClass" + luaClassNumber;
typeName = "LuaGeneratedClass" + luaClassNumber.ToString ();
luaClassNumber++;
}
......@@ -138,7 +138,7 @@ namespace NLua
#else
string typeName;
lock (this) {
typeName = "LuaGeneratedClass" + luaClassNumber;
typeName = "LuaGeneratedClass" + luaClassNumber.ToString ();
luaClassNumber++;
}
......@@ -319,7 +319,7 @@ namespace NLua
#else
string typeName;
lock (this) {
typeName = "LuaGeneratedClass" + luaClassNumber;
typeName = "LuaGeneratedClass" + luaClassNumber.ToString ();
luaClassNumber++;
}
......
......@@ -324,7 +324,7 @@ end
if (_StatePassed)
return;
if (!luaState.IsNull ()) {
if (! CheckNull.IsNull(luaState)) {
LuaCore.LuaClose (luaState);
ObjectTranslatorPool.Instance.Remove (luaState);
}
......@@ -352,11 +352,11 @@ end
// A pre-wrapped exception - just rethrow it (stack trace of InnerException will be preserved)
var luaEx = err as LuaScriptException;
if (!luaEx.IsNull ())
if (luaEx != null)
throw luaEx;
// A non-wrapped Lua error (best interpreted as a string) - wrap it and throw it
if (err.IsNull ())
if (err == null)
err = "Unknown Lua Error";
throw new LuaScriptException (err.ToString (), string.Empty);
......@@ -371,7 +371,7 @@ end
{
var caughtExcept = e;
if (!caughtExcept.IsNull ()) {
if (caughtExcept != null) {
translator.ThrowError (luaState, caughtExcept);
LuaLib.LuaPushNil (luaState);
return 1;
......@@ -568,7 +568,7 @@ end
LuaLib.LuaSetTop (luaState, oldTop);
// Globals auto-complete
if (value.IsNull ()) {
if (value == null) {
// Remove now obsolete entries
globals.Remove (fullPath);
} else {
......@@ -597,20 +597,21 @@ end
else if ((type.IsClass || type.IsInterface) && type != typeof(string) && recursionCounter < 2) {
#region Methods
foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Instance)) {
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) &&
// Exclude some generic .NET methods that wouldn't be very usefull in Lua
method.Name != "GetType" && method.Name != "GetHashCode" && method.Name != "Equals" &&
method.Name != "ToString" && method.Name != "Clone" && method.Name != "Dispose" &&
method.Name != "GetEnumerator" && method.Name != "CopyTo" &&
!method.Name.StartsWith ("get_", StringComparison.Ordinal) &&
!method.Name.StartsWith ("set_", StringComparison.Ordinal) &&
!method.Name.StartsWith ("add_", StringComparison.Ordinal) &&
!method.Name.StartsWith ("remove_", StringComparison.Ordinal)) {
name != "GetType" && name != "GetHashCode" && name != "Equals" &&
name != "ToString" && name != "Clone" && name != "Dispose" &&
name != "GetEnumerator" && name != "CopyTo" &&
!name.StartsWith ("get_", StringComparison.Ordinal) &&
!name.StartsWith ("set_", StringComparison.Ordinal) &&
!name.StartsWith ("add_", StringComparison.Ordinal) &&
!name.StartsWith ("remove_", StringComparison.Ordinal)) {
// Format for easy method invocation
string command = path + ":" + method.Name + "(";
string command = path + ":" + name + "(";
if (method.GetParameters ().Length == 0)
command += ")";
......@@ -665,7 +666,7 @@ end
LuaLib.LuaGetTable (luaState, -2);
returnValue = translator.GetObject (luaState, -1);
if (returnValue.IsNull ())
if (returnValue == null)
break;
}
......@@ -765,7 +766,7 @@ end
translator.Push (luaState, function);
if (!args.IsNull ()) {
if (args != null) {
nArgs = args.Length;
for (int i = 0; i < args.Length; i++)
......@@ -782,7 +783,7 @@ end
executing = false;
}
return !returnTypes.IsNull () ? translator.PopValues (luaState, oldTop, returnTypes) : translator.PopValues (luaState, oldTop);
return returnTypes != null ? translator.PopValues (luaState, oldTop, returnTypes) : translator.PopValues (luaState, oldTop);
}
/*
......@@ -858,7 +859,7 @@ end
/// <author>Reinhard Ostermeier</author>
public int SetDebugHook (EventMasks mask, int count)
{
if (hookCallback.IsNull ()) {
if (hookCallback == null) {
hookCallback = new LuaHook (Lua.DebugHookCallback);
return LuaCore.LuaSetHook (luaState, hookCallback, (int)mask, count);
}
......@@ -1014,7 +1015,7 @@ end
try {
var temp = DebugHook;
if (!temp.IsNull ())
if (temp != null)
temp (this, new DebugHookEventArgs (luaDebug));
} catch (Exception ex) {
OnHookException (new HookExceptionEventArgs (ex));
......@@ -1024,7 +1025,7 @@ end
private void OnHookException (HookExceptionEventArgs e)
{
var temp = HookException;
if (!temp.IsNull ())
if (temp != null)
temp (this, e);
}
......@@ -1052,7 +1053,7 @@ end
internal void DisposeInternal (int reference)
{
if (!luaState.IsNull ()) //Fix submitted by Qingrui Li
if (! CheckNull.IsNull(luaState)) //Fix submitted by Qingrui Li
LuaLib.LuaUnref (luaState, reference);
}
......@@ -1166,13 +1167,12 @@ end
#region IDisposable Members
public virtual void Dispose ()
{
if (!translator.IsNull ()) {
if (translator != null) {
translator.pendingEvents.Dispose ();
translator = null;
}
this.Close ();
GC.Collect ();
Close ();
GC.WaitForPendingFinalizers ();
}
#endregion
......
......@@ -44,10 +44,10 @@ namespace NLua
public static void TaggedInstanceMethods (Lua lua, object o)
{
#region Sanity checks
if (lua.IsNull ())
if (lua == null)
throw new ArgumentNullException ("lua");
if (o.IsNull ())
if (o == null)
throw new ArgumentNullException ("o");
#endregion
......@@ -71,10 +71,10 @@ namespace NLua
public static void TaggedStaticMethods (Lua lua, Type type)
{
#region Sanity checks
if (lua.IsNull ())
if (lua == null)
throw new ArgumentNullException ("lua");
if (type.IsNull ())
if (type == null)
throw new ArgumentNullException ("type");
if (!type.IsClass)
......@@ -102,7 +102,7 @@ namespace NLua
public static void Enumeration<T> (Lua lua)
{
#region Sanity checks
if (lua.IsNull ())
if (lua == null)
throw new ArgumentNullException ("lua");
#endregion
......
......@@ -100,16 +100,6 @@ namespace NLua
return _Interpreter.RawGetObject (_Reference, field);
}
internal object RawGetFunction (string field)
{
object obj = _Interpreter.RawGetObject (_Reference, field);
if (obj is LuaNativeFunction)
return new LuaFunction ((LuaNativeFunction)obj, _Interpreter);
else
return obj;
}
/*
* Pushes this table into the Lua stack
*/
......
......@@ -78,13 +78,6 @@ namespace NLua
return _Interpreter.CallFunction (this, args);
}
/*
* Pushes the userdata into the Lua stack
*/
internal void Push (LuaState luaState)
{
LuaLib.LuaGetRef (luaState, _Reference);
}
public override string ToString ()
{
......
......@@ -152,8 +152,8 @@ namespace NLua
{
object obj = translator.GetRawNetObject (luaState, 1);
if (!obj.IsNull ())
translator.Push (luaState, obj.ToString () + ": " + obj.GetHashCode ());
if (obj != null)
translator.Push (luaState, obj.ToString () + ": " + obj.GetHashCode ().ToString());
else
LuaLib.LuaPushNil (luaState);
......@@ -168,7 +168,12 @@ namespace NLua
public static void DumpStack (ObjectTranslator translator, LuaState luaState)
{
int depth = LuaLib.LuaGetTop (luaState);
Debug.WriteLine ("lua stack depth: " + depth);
#if WINDOWS_PHONE
Debug.WriteLine("lua stack depth: {0}", depth);
#elif !SILVERLIGHT
Debug.Print ("lua stack depth: {0}", depth);
#endif
for (int i = 1; i <= depth; i++) {
var type = LuaLib.LuaType (luaState, i);
......@@ -211,7 +216,7 @@ namespace NLua
{
object obj = translator.GetRawNetObject (luaState, 1);
if (obj.IsNull ()) {
if (obj == null) {
translator.ThrowError (luaState, "trying to index an invalid object reference");
LuaLib.LuaPushNil (luaState);
return 1;
......@@ -227,7 +232,7 @@ namespace NLua
// CP: This will fail when using indexers and attempting to get a value with the same name as a property of the object,
// ie: xmlelement['item'] <- item is a property of xmlelement
try {
if (!methodName.IsNull () && IsMemberPresent (objType, methodName))
if (!string.IsNullOrEmpty(methodName) && IsMemberPresent (objType, methodName))
return GetMember (luaState, objType, obj, methodName, BindingFlags.Instance | BindingFlags.IgnoreCase);
} catch {
}
......@@ -258,9 +263,9 @@ namespace NLua
//check if the signature matches the input
if (mInfo.GetParameters ().Length == 1) {
var getter = mInfo;
var actualParms = (!getter.IsNull ()) ? getter.GetParameters () : null;
var actualParms = (getter != null) ? getter.GetParameters () : null;
if (actualParms.IsNull () || actualParms.Length != 1) {
if (actualParms == null || actualParms.Length != 1) {
translator.ThrowError (luaState, "method not found (or no indexer): " + index);
LuaLib.LuaPushNil (luaState);
} else {
......@@ -312,7 +317,7 @@ namespace NLua
{
object obj = translator.GetRawNetObject (luaState, 1);
if (obj.IsNull ()) {
if (obj == null) {
translator.ThrowError (luaState, "trying to index an invalid object reference");
LuaLib.LuaPushNil (luaState);
LuaLib.LuaPushBoolean (luaState, false);
......@@ -321,7 +326,7 @@ namespace NLua
string methodName = LuaLib.LuaToString (luaState, 2).ToString ();
if (methodName.IsNull ()) {
if (string.IsNullOrEmpty(methodName)) {
LuaLib.LuaPushNil (luaState);
LuaLib.LuaPushBoolean (luaState, false);
return 2;
......@@ -349,7 +354,7 @@ namespace NLua
{
object cachedMember = CheckMemberCache (memberCache, objType, methodName);
if (!cachedMember.IsNull ())
if (cachedMember != null)
return true;
//CP: Removed NonPublic binding search
......@@ -374,7 +379,7 @@ namespace NLua
translator.PushFunction (luaState, (LuaNativeFunction)cachedMember);
translator.Push (luaState, true);
return 2;
} else if (!cachedMember.IsNull ())
} else if (cachedMember != null)
member = (MemberInfo)cachedMember;
else {
//CP: Removed NonPublic binding search
......@@ -395,11 +400,11 @@ namespace NLua
}
}
if (!member.IsNull ()) {
if (member != null) {
if (member.MemberType == MemberTypes.Field) {
var field = (FieldInfo)member;
if (cachedMember.IsNull ())
if (cachedMember == null)
SetMemberCache (memberCache, objType, methodName, member);
try {
......@@ -409,7 +414,7 @@ namespace NLua
}
} else if (member.MemberType == MemberTypes.Property) {
var property = (PropertyInfo)member;
if (cachedMember.IsNull ())
if (cachedMember == null)
SetMemberCache (memberCache, objType, methodName, member);
try {
......@@ -428,7 +433,7 @@ namespace NLua
}
} else if (member.MemberType == MemberTypes.Event) {
var eventInfo = (EventInfo)member;
if (cachedMember.IsNull ())
if (cachedMember == null)
SetMemberCache (memberCache, objType, methodName, member);
translator.Push (luaState, new RegisterEventHandler (translator.pendingEvents, obj, eventInfo));
......@@ -436,7 +441,7 @@ namespace NLua
if (member.MemberType == MemberTypes.NestedType) {
// kevinh - added support for finding nested types
// cache us
if (cachedMember.IsNull ())
if (cachedMember == null)
SetMemberCache (memberCache, objType, methodName, member);
// Find the name of our class
......@@ -451,7 +456,7 @@ namespace NLua
// Member type must be 'method'
var wrapper = new LuaNativeFunction ((new LuaMethodWrapper (translator, objType, methodName, bindingType)).invokeFunction);
if (cachedMember.IsNull ())
if (cachedMember == null)
SetMemberCache (memberCache, objType, methodName, wrapper);
translator.PushFunction (luaState, wrapper);
......@@ -489,7 +494,7 @@ namespace NLua
object memberValue = null;
if (!members.IsNull() && membersDict.TryGetValue(memberName, out memberValue))
if (members != null && membersDict.TryGetValue(memberName, out memberValue))
{
return memberValue;
}
......@@ -534,7 +539,7 @@ namespace NLua
{
object target = translator.GetRawNetObject (luaState, 1);
if (target.IsNull ()) {
if (target == null) {
translator.ThrowError (luaState, "trying to index and invalid object reference");
return 0;
}
......@@ -558,7 +563,7 @@ namespace NLua
} else {
// Try to see if we have a this[] accessor
var setter = type.GetMethod ("set_Item");
if (!setter.IsNull ()) {
if (setter != null) {
var args = setter.GetParameters ();
var valueType = args [1].ParameterType;
......@@ -611,14 +616,14 @@ namespace NLua
// We only look up property names by string
string fieldName = LuaLib.LuaToString (luaState, 2).ToString ();
if (fieldName.IsNull () || fieldName.Length < 1 || !(char.IsLetter (fieldName [0]) || fieldName [0] == '_')) {
if (fieldName == null || fieldName.Length < 1 || !(char.IsLetter (fieldName [0]) || fieldName [0] == '_')) {
detailMessage = "invalid property name";
return false;
}
// Find our member via reflection or the cache
var member = (MemberInfo)CheckMemberCache (memberCache, targetType, fieldName);
if (member.IsNull ()) {
if (member == null) {
//CP: Removed NonPublic binding search and made case insensitive
var members = targetType.GetMember (fieldName, bindingType | BindingFlags.Public | BindingFlags.IgnoreCase/*| BindingFlags.NonPublic*/);
......@@ -686,7 +691,7 @@ namespace NLua
// If we got inside a reflection show what really happened
var te = e as TargetInvocationException;
if (!te.IsNull ())
if (te != null)
e = te.InnerException;
translator.ThrowError (luaState, e);
......@@ -711,7 +716,7 @@ namespace NLua
IReflect klass;
object obj = translator.GetRawNetObject (luaState, 1);
if (obj.IsNull () || !(obj is IReflect)) {
if (obj == null || !(obj is IReflect)) {
translator.ThrowError (luaState, "trying to index an invalid type reference");
LuaLib.LuaPushNil (luaState);
return 1;
......@@ -725,7 +730,7 @@ namespace NLua
} else {
string methodName = LuaLib.LuaToString (luaState, 2).ToString ();
if (methodName.IsNull ()) {
if (string.IsNullOrEmpty(methodName)) {
LuaLib.LuaPushNil (luaState);
return 1;
} //CP: Ignore case
......@@ -753,7 +758,7 @@ namespace NLua
IReflect target;
object obj = translator.GetRawNetObject (luaState, 1);
if (obj.IsNull () || !(obj is IReflect)) {
if (obj == null || !(obj is IReflect)) {
translator.ThrowError (luaState, "trying to index an invalid type reference");
return 0;
} else
......@@ -785,7 +790,7 @@ namespace NLua
IReflect klass;
object obj = translator.GetRawNetObject (luaState, 1);
if (obj.IsNull () || !(obj is IReflect)) {
if (obj == null || !(obj is IReflect)) {
translator.ThrowError (luaState, "trying to call constructor on an invalid type reference");
LuaLib.LuaPushNil (luaState);
return 1;
......@@ -983,7 +988,7 @@ namespace NLua
Debug.WriteLine ("An error occurred during an attempt to retrieve a LuaTable extractor while checking for params array status.");
}
if (!extractValue.IsNull ()) {
if (extractValue != null) {
return true;
}
} else {
......@@ -995,7 +1000,7 @@ namespace NLua
Debug.WriteLine (string.Format ("An error occurred during an attempt to retrieve an extractor ({0}) while checking for params array status.", paramElementType.FullName));
}
if (!extractValue.IsNull ()) {
if (extractValue != null) {
return true;
}
}
......
......@@ -72,7 +72,7 @@ namespace NLua.Method
_Translator = translator;
_Target = target;
if (!targetType.IsNull ())
if (targetType != null)
_ExtractTarget = translator.typeChecker.GetExtractor (targetType);
_Method = method;
......@@ -94,7 +94,7 @@ namespace NLua.Method
_Translator = translator;
_MethodName = methodName;
if (!targetType.IsNull ())
if (targetType != null)
_ExtractTarget = translator.typeChecker.GetExtractor (targetType);
_BindingType = bindingType;
......@@ -129,14 +129,13 @@ namespace NLua.Method
bool isStatic = (_BindingType & BindingFlags.Static) == BindingFlags.Static;
SetPendingException (null);
if (methodToCall.IsNull ()) { // Method from name
if (methodToCall == null) { // Method from name
if (isStatic)
targetObject = null;
else
targetObject = _ExtractTarget (luaState, 1);
//LuaLib.lua_remove(luaState,1); // Pops the receiver
if (!_LastCalledMethod.cachedMethod.IsNull ()) { // Cached?
if (_LastCalledMethod.cachedMethod != null) { // Cached?
int numStackToSkip = isStatic ? 0 : 1; // If this is an instance invoe we will have an extra arg on the stack for the targetObject
int numArgsPassed = LuaLib.LuaGetTop (luaState) - numStackToSkip;
MethodBase method = _LastCalledMethod.cachedMethod;
......@@ -162,7 +161,7 @@ namespace NLua.Method
if (_LastCalledMethod.args [_LastCalledMethod.argTypes [i].index] == null &&
!LuaLib.LuaIsNil (luaState, i + 1 + numStackToSkip))
throw new LuaException ("argument number " + (i + 1) + " is invalid");
throw new LuaException (string.Format("argument number {0} is invalid",(i + 1)));
}
if ((_BindingType & BindingFlags.Static) == BindingFlags.Static)
......@@ -191,7 +190,7 @@ namespace NLua.Method
// System.Diagnostics.Debug.WriteLine("cache miss on " + methodName);
// If we are running an instance variable, we can now pop the targetObject from the stack
if (!isStatic) {
if (targetObject.IsNull ()) {
if (targetObject == null) {
_Translator.ThrowError (luaState, String.Format ("instance method '{0}' requires a non null target object", _MethodName));
LuaLib.LuaPushNil (luaState);
return 1;
......
......@@ -43,7 +43,7 @@ namespace NLua.Method
_cachedMethod = value;
var mi = value as MethodInfo;
if (!mi.IsNull ()) {
if (mi != null) {
IsReturnVoid = mi.ReturnType == typeof (void);
}
}
......
......@@ -232,13 +232,13 @@ namespace NLua
string message = e as string;
if (!message.IsNull ()) {
if (message != null) {
// Wrap Lua error (just a string) and store the error location
e = new LuaScriptException (message, errLocation);
} else {
var ex = e as Exception;
if (!ex.IsNull ()) {
if (ex != null) {
// Wrap generic .NET exception as an InnerException and store the error location
e = new LuaScriptException (ex, errLocation);
}
......@@ -275,11 +275,11 @@ namespace NLua
}
#if !SILVERLIGHT
if (assembly.IsNull ())
if (assembly == null)
assembly = Assembly.Load (AssemblyName.GetAssemblyName (assemblyName));
#endif
if (!assembly.IsNull () && !assemblies.Contains (assembly))
if (assembly != null && !assemblies.Contains (assembly))
assemblies.Add (assembly);
} catch (Exception e) {
ThrowError (luaState, e);
......@@ -293,7 +293,7 @@ namespace NLua
foreach (var assembly in assemblies) {
var klass = assembly.GetType (className);
if (!klass.IsNull ())
if (klass != null)
return klass;
}
return null;
......@@ -318,7 +318,7 @@ namespace NLua
string className = LuaLib.LuaToString (luaState, 1).ToString ();
var klass = FindType (className);
if (!klass.IsNull ())
if (klass != null)
PushType (luaState, klass);
else
LuaLib.LuaPushNil (luaState);
......@@ -347,10 +347,10 @@ namespace NLua
var luaTable = GetTable (luaState, 1);
string superclassName = LuaLib.LuaToString (luaState, 2).ToString ();
if (!superclassName.IsNull ()) {
if (superclassName != null) {
var klass = FindType (superclassName);
if (!klass.IsNull ()) {
if (klass != null) {
// Creates and pushes the object in the stack, setting
// it as the metatable of the first argument
object obj = CodeGeneration.Instance.GetClassInstance (klass, luaTable);
......@@ -401,12 +401,12 @@ namespace NLua
LuaLib.LuaGetTable (luaState, -2);
object obj = GetRawNetObject (luaState, -1);
if (obj.IsNull ())
if (obj == null)
ThrowError (luaState, "unregister_table: arg is not valid table");
var luaTableField = obj.GetType ().GetField ("__luaInterface_luaTable");
if (luaTableField.IsNull ())
if (luaTableField == null)
ThrowError (luaState, "unregister_table: arg is not valid table");
luaTableField.SetValue (obj, null);
......@@ -450,7 +450,7 @@ namespace NLua
} else {
target = GetRawNetObject (luaState, 1);
if (target.IsNull ()) {
if (target == null) {
ThrowError (luaState, "get_method_bysig: first arg is not type or object reference");
LuaLib.LuaPushNil (luaState);
return 1;
......@@ -500,7 +500,7 @@ namespace NLua
if (udata != -1)
klass = (IReflect)objects [udata];
if (klass.IsNull ())
if (klass == null)
ThrowError (luaState, "get_constructor_bysig: first arg is invalid type reference");
var signature = new Type[LuaLib.LuaGetTop (luaState) - 1];
......@@ -544,7 +544,7 @@ namespace NLua
int index = -1;
// Pushes nil
if (o.IsNull ()) {
if (o == null) {
LuaLib.LuaPushNil (luaState);
return;
}
......@@ -632,7 +632,7 @@ namespace NLua
internal object GetAsType (LuaState luaState, int stackPos, Type paramType)
{
var extractor = typeChecker.CheckLuaType (luaState, stackPos, paramType);
return !extractor.IsNull () ? extractor (luaState, stackPos) : null;
return extractor != null ? extractor (luaState, stackPos) : null;
}
/// <summary>
......@@ -757,20 +757,6 @@ namespace NLua
return udata != -1 ? objects [udata] : null;
}
/*
* Pushes the entire array into the Lua stack and returns the number
* of elements pushed.
*/
internal int ReturnValues (LuaState luaState, object[] returnValues)
{
if (LuaLib.LuaCheckStack (luaState, returnValues.Length + 5)) {
for (int i = 0; i < returnValues.Length; i++)
Push (luaState, returnValues [i]);
return returnValues.Length;
} else
return 0;
}
/*
* Gets the values from the provided index to
......@@ -829,13 +815,9 @@ namespace NLua
if (o is ILuaGeneratedType) {
// Make sure we are _really_ ILuaGenerated
var typ = o.GetType ();
#if SILVERLIGHT
return (!typ.GetInterface ("ILuaGeneratedType", true).IsNull ());
#else
return (!typ.GetInterface ("ILuaGeneratedType").IsNull ());
#endif
} else
return false;
return typ.GetInterface ("ILuaGeneratedType", true) != null;
}
return false;
}
/*
......@@ -843,7 +825,7 @@ namespace NLua
*/
internal void Push (LuaState luaState, object o)
{
if (o.IsNull ())
if (o == null)
LuaLib.LuaPushNil (luaState);
else if (o is sbyte || o is byte || o is short || o is ushort ||
o is int || o is uint || o is long || o is float ||
......
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