Commit 96e10fff authored by Mangatome's avatar Mangatome
Browse files

Silverlight fixes

parent feabc83e
......@@ -24,14 +24,18 @@
* THE SOFTWARE.
*/
using System;
#if !SILVERLIGHT
using System.Runtime.Serialization;
#endif
namespace NLua.Exceptions
{
/// <summary>
/// Exceptions thrown by the Lua runtime
/// </summary>
#if !SILVERLIGHT
[Serializable]
#endif
public class LuaException : Exception
{
public LuaException ()
......@@ -46,8 +50,10 @@ namespace NLua.Exceptions
{
}
#if !SILVERLIGHT
protected LuaException (SerializationInfo info, StreamingContext context) : base(info, context)
{
}
#endif
}
}
\ No newline at end of file
......@@ -42,7 +42,11 @@ namespace NLua.Exceptions
/// <summary>
/// The position in the script where the exception was triggered.
/// </summary>
#if SILVERLIGHT
public string Source { get { return source; } }
#else
public override string Source { get { return source; } }
#endif
/// <summary>
/// Creates a new Lua-only exception.
......
......@@ -51,7 +51,7 @@ namespace NLua
private static readonly CodeGeneration instance = new CodeGeneration ();
private AssemblyName assemblyName;
#if !MONOTOUCH
#if !MONOTOUCH && !SILVERLIGHT
private Dictionary<Type, Type> eventHandlerCollection = new Dictionary<Type, Type> ();
private Type eventHandlerParent = typeof(LuaEventHandler);
private Type delegateParent = typeof(LuaDelegate);
......@@ -314,6 +314,8 @@ namespace NLua
{
#if MONOTOUCH
throw new NotImplementedException (" Emit not available on MonoTouch ");
#elif SILVERLIGHT
throw new NotImplementedException (" Emit not available on Silverlight ");
#else
string typeName;
lock (this) {
......@@ -413,7 +415,7 @@ namespace NLua
returnTypes = returnTypesList.ToArray ();
}
#if !MONOTOUCH
#if !MONOTOUCH && !SILVERLIGHT
/*
* Generates an overriden implementation of method inside myType that delegates
......
......@@ -817,9 +817,9 @@ end
LuaLib.lua_settop (luaState, oldTop);
}
public ListDictionary GetTableDict (LuaTable table)
public Dictionary<object, object> GetTableDict (LuaTable table)
{
var dict = new ListDictionary ();
var dict = new Dictionary<object, object> ();
int oldTop = LuaLib.lua_gettop (luaState);
translator.push (luaState, table);
LuaLib.lua_pushnil (luaState);
......
......@@ -27,7 +27,9 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
#if !SILVERLIGHT
using System.Runtime.Serialization.Formatters.Binary;
#endif
using NLua.Extensions;
namespace NLua
......
......@@ -51,7 +51,7 @@ namespace NLua
{
internal LuaCore.lua_CFunction gcFunction, indexFunction, newindexFunction, baseIndexFunction,
classIndexFunction, classNewindexFunction, execDelegateFunction, callConstructorFunction, toStringFunction;
private Hashtable memberCache = new Hashtable ();
private Dictionary<object, object> memberCache = new Dictionary<object, object> ();
private ObjectTranslator translator;
/*
......@@ -176,7 +176,11 @@ namespace NLua
strrep = obj.ToString ();
}
#if WINDOWS_PHONE
Debug.WriteLine("{0}: ({1}) {2}", i, typestr, strrep);
#elif !SILVERLIGHT
Debug.Print ("{0}: ({1}) {2}", i, typestr, strrep);
#endif
}
}
......@@ -470,21 +474,21 @@ namespace NLua
/*
* Checks if a MemberInfo object is cached, returning it or null.
*/
private object checkMemberCache (Hashtable memberCache, IReflect objType, string memberName)
private object checkMemberCache (Dictionary<object, object> memberCache, IReflect objType, string memberName)
{
var members = (Hashtable)memberCache [objType];
var members = (Dictionary<object, object>)memberCache [objType];
return !members.IsNull () ? members [memberName] : null;
}
/*
* Stores a MemberInfo object in the member cache.
*/
private void setMemberCache (Hashtable memberCache, IReflect objType, string memberName, object member)
private void setMemberCache (Dictionary<object, object> memberCache, IReflect objType, string memberName, object member)
{
var members = (Hashtable)memberCache [objType];
var members = (Dictionary<object, object>)memberCache[objType];
if (members.IsNull ()) {
members = new Hashtable ();
members = new Dictionary<object, object>();
memberCache [objType] = members;
}
......@@ -553,9 +557,11 @@ namespace NLua
} else
translator.throwError (luaState, detailMessage); // Pass the original message from trySetMember because it is probably best
}
#if !SILVERLIGHT
} catch (SEHException) {
// If we are seeing a C++ exception - this must actually be for Lua's private use. Let it handle it
throw;
#endif
} catch (Exception e) {
ThrowError (luaState, e);
}
......
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