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

Silverlight fixes

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