From aeda0dedec496f29eb5b711e018527b8cc5a5565 Mon Sep 17 00:00:00 2001 From: Christopher Date: Tue, 18 Oct 2016 16:38:53 +0100 Subject: [PATCH] Converted MoonSharp line endings to OSX for consistency with rest of project. --- .../DebuggerLogic/IAsyncDebuggerClient.cs | 10 +- .../DebuggerLogic/MoonSharpDebugSession.cs | 66 +- .../DebuggerLogic/VariableInspector.cs | 6 +- .../Debugger/MoonSharpVsCodeDebugServer.cs | 796 ++++++------ .../MoonSharp/Debugger/SDK/DebugSession.cs | 50 +- .../MoonSharp/Debugger/SDK/Protocol.cs | 50 +- .../MoonSharp/Debugger/SDK/Utilities.cs | 58 +- .../MoonSharp/Interpreter/AsyncExtensions.cs | 16 +- .../Interpreter/Compatibility/Attributes.cs | 6 +- .../Interpreter/Compatibility/Framework.cs | 32 +- .../Frameworks/Base/FrameworkBase.cs | 150 +-- .../Frameworks/Base/FrameworkClrBase.cs | 230 ++-- .../Base/FrameworkReflectionBase.cs | 152 +-- .../Compatibility/Frameworks/FrameworkCLR.cs | 62 +- .../Compatibility/Frameworks/FrameworkCore.cs | 262 ++-- .../Compatibility/Frameworks/FrameworkPCL.cs | 56 +- .../Compatibility/Frameworks/FrameworkWin8.cs | 318 ++--- .../Interpreter/CoreLib/BasicModule.cs | 2 +- .../CoreLib/IO/FileUserDataBase.cs | 4 +- .../MoonSharp/Interpreter/CoreLib/IoModule.cs | 6 +- .../Interpreter/CoreLib/LoadModule.cs | 4 +- .../Interpreter/CoreLib/OsTimeModule.cs | 4 +- .../Interpreter/DataTypes/CallbackFunction.cs | 6 +- .../Interpreter/DataTypes/UserData.cs | 20 +- .../Errors/DynamicExpressionException.cs | 8 +- .../Errors/InternalErrorException.cs | 4 +- .../Errors/InterpreterException.cs | 4 +- .../Errors/ScriptRuntimeException.cs | 4 +- .../Errors/SyntaxErrorException.cs | 2 +- .../Interpreter/Execution/VM/ByteCode.cs | 8 +- .../Execution/VM/Processor/Processor.cs | 14 +- .../Interpreter/IO/UndisposableStream.cs | 12 +- .../DispatchingUserDataDescriptor.cs | 2 +- .../BasicDescriptors/ParameterDescriptor.cs | 4 +- .../Converters/ClrToScriptConversions.cs | 12 +- .../Converters/ScriptToClrConversions.cs | 4 +- .../Interop/Converters/TableConversions.cs | 4 +- .../Interpreter/Interop/DescriptorHelpers.cs | 16 +- .../Interop/LuaStateInterop/Tools.cs | 1088 ++++++++--------- .../Interop/PropertyTableAssigner.cs | 4 +- .../AutoDescribingUserDataDescriptor.cs | 2 +- .../CompositeUserDataDescriptor.cs | 4 +- .../FunctionMemberDescriptorBase.cs | 2 +- .../ProxyUserDataDescriptor.cs | 4 +- .../EventMemberDescriptor.cs | 4 +- .../FieldMemberDescriptor.cs | 4 +- .../MethodMemberDescriptor.cs | 2 +- .../OverloadedMethodMemberDescriptor.cs | 6 +- .../PropertyMemberDescriptor.cs | 2 +- .../ValueTypeDefaultCtorMemberDescriptor.cs | 2 +- .../StandardEnumUserDataDescriptor.cs | 2 +- .../StandardGenericsUserDataDescriptor.cs | 8 +- .../StandardUserDataDescriptor.cs | 28 +- .../ExtensionMethodsRegistry.cs | 16 +- .../TypeDescriptorRegistry.cs | 192 +-- .../Loaders/EmbeddedResourcesScriptLoader.cs | 18 +- .../Loaders/UnityAssetsScriptLoader.cs | 348 +++--- .../Interpreter/Modules/ModuleRegister.cs | 14 +- .../Platforms/DotNetCorePlatformAccessor.cs | 98 +- .../Platforms/PlatformAccessorBase.cs | 156 +-- .../Platforms/PlatformAutoDetector.cs | 58 +- .../Platforms/StandardPlatformAccessor.cs | 136 +-- .../MoonSharp/Interpreter/Script.cs | 22 +- .../Serialization/ObjectValueConverter.cs | 2 +- .../Interpreter/Tree/Lexer/LexerUtils.cs | 6 +- .../Tree/Statements/FunctionCallStatement.cs | 14 +- 66 files changed, 2353 insertions(+), 2353 deletions(-) diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/DebuggerLogic/IAsyncDebuggerClient.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/DebuggerLogic/IAsyncDebuggerClient.cs index 16c0ac81..a4059f80 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/DebuggerLogic/IAsyncDebuggerClient.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/DebuggerLogic/IAsyncDebuggerClient.cs @@ -1,5 +1,5 @@ #if (!PCL) && ((!UNITY_5) || UNITY_STANDALONE) - + using System; using System.Collections.Generic; using System.Linq; @@ -15,9 +15,9 @@ namespace MoonSharp.VsCodeDebugger.DebuggerLogic void OnWatchesUpdated(WatchType watchType); void OnSourceCodeChanged(int sourceID); void OnExecutionEnded(); - void OnException(ScriptRuntimeException ex); - void Unbind(); + void OnException(ScriptRuntimeException ex); + void Unbind(); } -} - +} + #endif \ No newline at end of file diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/DebuggerLogic/MoonSharpDebugSession.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/DebuggerLogic/MoonSharpDebugSession.cs index 11ba7983..e3cb4994 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/DebuggerLogic/MoonSharpDebugSession.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/DebuggerLogic/MoonSharpDebugSession.cs @@ -1,5 +1,5 @@ #if (!PCL) && ((!UNITY_5) || UNITY_STANDALONE) - + using System; using System.Collections.Generic; using System.IO; @@ -32,19 +32,19 @@ namespace MoonSharp.VsCodeDebugger.DebuggerLogic } public override void Initialize(Response response, Table args) - { + { #if DOTNET_CORE SendText("Connected to MoonSharp {0} [{1}]", Script.VERSION, - Script.GlobalOptions.Platform.GetPlatformName()); + Script.GlobalOptions.Platform.GetPlatformName()); #else SendText("Connected to MoonSharp {0} [{1}] on process {2} (PID {3})", Script.VERSION, Script.GlobalOptions.Platform.GetPlatformName(), System.Diagnostics.Process.GetCurrentProcess().ProcessName, - System.Diagnostics.Process.GetCurrentProcess().Id); + System.Diagnostics.Process.GetCurrentProcess().Id); #endif - + SendText("Debugging script '{0}'; use the debug console to debug another script.", m_Debug.Name); SendText("Type '!help' in the Debug Console for available commands."); @@ -174,31 +174,31 @@ namespace MoonSharp.VsCodeDebugger.DebuggerLogic SendText("Notifications of execution end are : {0}", m_NotifyExecutionEnd ? "enabled" : "disabled"); } - else if (cmd == "list") - { - int currId = m_Server.CurrentId ?? -1000; - - foreach (var pair in m_Server.GetAttachedDebuggersByIdAndName()) - { - string isthis = (pair.Key == m_Debug.Id) ? " (this)" : ""; - string isdef = (pair.Key == currId) ? " (default)" : ""; - - SendText("{0} : {1}{2}{3}", pair.Key.ToString().PadLeft(9), pair.Value, isdef, isthis); - } + else if (cmd == "list") + { + int currId = m_Server.CurrentId ?? -1000; + + foreach (var pair in m_Server.GetAttachedDebuggersByIdAndName()) + { + string isthis = (pair.Key == m_Debug.Id) ? " (this)" : ""; + string isdef = (pair.Key == currId) ? " (default)" : ""; + + SendText("{0} : {1}{2}{3}", pair.Key.ToString().PadLeft(9), pair.Value, isdef, isthis); + } } - else if (cmd.StartsWith("select") || cmd.StartsWith("switch")) - { + else if (cmd.StartsWith("select") || cmd.StartsWith("switch")) + { string arg = cmd.Substring("switch".Length).Trim(); try { int id = int.Parse(arg); - m_Server.CurrentId = id; - - if (cmd.StartsWith("switch")) - Unbind(); - else - SendText("Next time you'll attach the debugger, it will be atteched to script #{0}", id); + m_Server.CurrentId = id; + + if (cmd.StartsWith("switch")) + Unbind(); + else + SendText("Next time you'll attach the debugger, it will be atteched to script #{0}", id); } catch (Exception ex) { @@ -447,14 +447,14 @@ namespace MoonSharp.VsCodeDebugger.DebuggerLogic public void OnException(ScriptRuntimeException ex) { SendText("runtime error : {0}", ex.DecoratedMessage); - } - - public void Unbind() - { - SendText("Debug session has been closed by the hosting process."); - SendText("Bye."); - SendEvent(new TerminatedEvent()); - } + } + + public void Unbind() + { + SendText("Debug session has been closed by the hosting process."); + SendText("Bye."); + SendEvent(new TerminatedEvent()); + } } -} +} #endif \ No newline at end of file diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/DebuggerLogic/VariableInspector.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/DebuggerLogic/VariableInspector.cs index 5f2b0be4..4c161d8d 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/DebuggerLogic/VariableInspector.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/DebuggerLogic/VariableInspector.cs @@ -1,5 +1,5 @@ #if (!PCL) && ((!UNITY_5) || UNITY_STANDALONE) - + using System; using System.Collections.Generic; using System.Linq; @@ -83,6 +83,6 @@ namespace MoonSharp.VsCodeDebugger.DebuggerLogic } } } -} - +} + #endif \ No newline at end of file diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/MoonSharpVsCodeDebugServer.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/MoonSharpVsCodeDebugServer.cs index 91f6f27e..e33979a1 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/MoonSharpVsCodeDebugServer.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/MoonSharpVsCodeDebugServer.cs @@ -1,399 +1,399 @@ -#if (!PCL) && ((!UNITY_5) || UNITY_STANDALONE) - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net; -using System.Net.Sockets; -using System.Text; -using System.Threading; -using MoonSharp.VsCodeDebugger.DebuggerLogic; -using MoonSharp.Interpreter; -using MoonSharp.Interpreter.Debugging; -using MoonSharp.VsCodeDebugger.SDK; - -namespace MoonSharp.VsCodeDebugger -{ - /// - /// Class implementing a debugger allowing attaching from a Visual Studio Code debugging session. - /// - public class MoonSharpVsCodeDebugServer : IDisposable - { - object m_Lock = new object(); - List m_DebuggerList = new List(); - AsyncDebugger m_Current = null; - ManualResetEvent m_StopEvent = new ManualResetEvent(false); - bool m_Started = false; - int m_Port; - - /// - /// Initializes a new instance of the class. - /// - /// The port on which the debugger listens. It's recommended to use 41912. - public MoonSharpVsCodeDebugServer(int port = 41912) - { - m_Port = port; - } - - /// - /// Initializes a new instance of the class with a default script. - /// Note that for this specific script, it will NOT attach the debugger to the script. - /// - /// The script object to debug. - /// The port on which the debugger listens. It's recommended to use 41912 unless you are going to keep more than one script object around. - /// A function which gets in input a source code and returns the path to - /// source file to use. It can return null and in that case (or if the file cannot be found) - /// a temporary file will be generated on the fly. - [Obsolete("Use the constructor taking only a port, and the 'Attach' method instead.")] - public MoonSharpVsCodeDebugServer(Script script, int port, Func sourceFinder = null) - { - m_Port = port; - m_Current = new AsyncDebugger(script, sourceFinder ?? (s => s.Name), "Default script"); - m_DebuggerList.Add(m_Current); - } - - /// - /// Attaches the specified script to the debugger - /// - /// The script. - /// The name of the script. - /// A function which gets in input a source code and returns the path to - /// source file to use. It can return null and in that case (or if the file cannot be found) - /// a temporary file will be generated on the fly. - /// If the script has already been attached to this debugger. - public void AttachToScript(Script script, string name, Func sourceFinder = null) - { - lock (m_Lock) - { - if (m_DebuggerList.Any(d => d.Script == script)) - throw new ArgumentException("Script already attached to this debugger."); - - var debugger = new AsyncDebugger(script, sourceFinder ?? (s => s.Name), name); - script.AttachDebugger(debugger); - m_DebuggerList.Add(debugger); - - if (m_Current == null) - m_Current = debugger; - } - } - - /// - /// Gets a list of the attached debuggers by id and name - /// - public IEnumerable> GetAttachedDebuggersByIdAndName() - { - lock (m_Lock) - return m_DebuggerList - .OrderBy(d => d.Id) - .Select(d => new KeyValuePair(d.Id, d.Name)) - .ToArray(); - } - - - /// - /// Gets or sets the current script by ID (see GetAttachedDebuggersByIdAndName). - /// New vscode connections will attach to this debugger ID. Changing the current ID does NOT disconnect - /// connected clients. - /// - public int? CurrentId - { - get { lock (m_Lock) return m_Current != null ? m_Current.Id : (int?)null; } - set - { - lock (m_Lock) - { - if (value == null) - { - m_Current = null; - return; - } - - var current = (m_DebuggerList.FirstOrDefault(d => d.Id == value)); - - if (current == null) - throw new ArgumentException("Cannot find debugger with given Id."); - - m_Current = current; - } - } - } - - - /// - /// Gets or sets the current script. New vscode connections will attach to this script. Changing the current script does NOT disconnect - /// connected clients. - /// - public Script Current - { - get { lock(m_Lock) return m_Current != null ? m_Current.Script : null; } - set - { - lock (m_Lock) - { - if (value == null) - { - m_Current = null; - return; - } - - var current = (m_DebuggerList.FirstOrDefault(d => d.Script == value)); - - if (current == null) - throw new ArgumentException("Cannot find debugger with given script associated."); - - m_Current = current; - } - } - } - - /// - /// Detaches the specified script. The debugger attached to that script will get disconnected. - /// - /// The script. - /// Thrown if the script cannot be found. - public void Detach(Script script) - { - lock (m_Lock) - { - var removed = m_DebuggerList.FirstOrDefault(d => d.Script == script); - - if (removed == null) - throw new ArgumentException("Cannot detach script - not found."); - - removed.Client = null; - - m_DebuggerList.Remove(removed); - - if (m_Current == removed) - { - if (m_DebuggerList.Count > 0) - m_Current = m_DebuggerList[m_DebuggerList.Count - 1]; - else - m_Current = null; - } - - } - } - - /// - /// Gets or sets a delegate which will be called when logging messages are generated - /// - public Action Logger { get; set; } - - - /// - /// Gets the debugger object. Obsolete, use the new interface using the Attach method instead. - /// - [Obsolete("Use the Attach method instead.")] - public IDebugger GetDebugger() - { - lock(m_Lock) - return m_Current; - } - - /// - /// Stops listening - /// - /// Cannot stop; server was not started. - public void Dispose() - { - m_StopEvent.Set(); - } - - /// - /// Starts listening on the localhost for incoming connections. - /// - public MoonSharpVsCodeDebugServer Start() - { - lock (m_Lock) - { - if (m_Started) - throw new InvalidOperationException("Cannot start; server has already been started."); - - m_StopEvent.Reset(); - - TcpListener serverSocket = null; - serverSocket = new TcpListener(IPAddress.Parse("127.0.0.1"), m_Port); - serverSocket.Start(); - - SpawnThread("VsCodeDebugServer_" + m_Port.ToString(), () => ListenThread(serverSocket)); - - m_Started = true; - - return this; - } - } - - - private void ListenThread(TcpListener serverSocket) - { - try - { - while (!m_StopEvent.WaitOne(0)) - { -#if DOTNET_CORE - var task = serverSocket.AcceptSocketAsync(); - task.Wait(); - var clientSocket = task.Result; -#else - var clientSocket = serverSocket.AcceptSocket(); -#endif - - if (clientSocket != null) - { - string sessionId = Guid.NewGuid().ToString("N"); - Log("[{0}] : Accepted connection from client {1}", sessionId, clientSocket.RemoteEndPoint); - - SpawnThread("VsCodeDebugSession_" + sessionId, () => - { - using (var networkStream = new NetworkStream(clientSocket)) - { - try - { - RunSession(sessionId, networkStream); - } - catch (Exception ex) - { - Log("[{0}] : Error : {1}", ex.Message); - } - } - -#if DOTNET_CORE - clientSocket.Dispose(); -#else - clientSocket.Close(); -#endif - Log("[{0}] : Client connection closed", sessionId); - }); - } - } - } - catch (Exception e) - { - Log("Fatal error in listening thread : {0}", e.Message); - } - finally - { - if (serverSocket != null) - serverSocket.Stop(); - } - } - - - private void RunSession(string sessionId, NetworkStream stream) - { - DebugSession debugSession = null; - - lock (m_Lock) - { - if (m_Current != null) - debugSession = new MoonSharpDebugSession(this, m_Current); - else - debugSession = new EmptyDebugSession(this); - } - - debugSession.ProcessLoop(stream, stream); - } - - private void Log(string format, params object[] args) - { - Action logger = Logger; - - if (logger != null) - { - string msg = string.Format(format, args); - logger(msg); - } - } - - - private static void SpawnThread(string name, Action threadProc) - { -#if DOTNET_CORE - System.Threading.Tasks.Task.Run(() => threadProc()); -#else - new System.Threading.Thread(() => threadProc()) - { - IsBackground = true, - Name = name - } - .Start(); -#endif - } - } -} - -#else - using System; -using System.Collections.Generic; -using MoonSharp.Interpreter; -using MoonSharp.Interpreter.Debugging; - -namespace MoonSharp.VsCodeDebugger -{ - public class MoonSharpVsCodeDebugServer : IDisposable - { - public MoonSharpVsCodeDebugServer(int port = 41912) - { - } - - [Obsolete("Use the constructor taking only a port, and the 'Attach' method instead.")] - public MoonSharpVsCodeDebugServer(Script script, int port, Func sourceFinder = null) - { - } - - public void AttachToScript(Script script, string name, Func sourceFinder = null) - { - } - - public IEnumerable> GetAttachedDebuggersByIdAndName() - { - yield break; - } - - - public int? CurrentId - { - get { return null; } - set { } - } - - - public Script Current - { - get { return null; } - set { } - } - - /// - /// Detaches the specified script. The debugger attached to that script will get disconnected. - /// - /// The script. - /// Thrown if the script cannot be found. - public void Detach(Script script) - { - - } - - public Action Logger { get; set; } - - - [Obsolete("Use the Attach method instead.")] - public IDebugger GetDebugger() - { - return null; - } - - public void Dispose() - { - } - - public MoonSharpVsCodeDebugServer Start() - { - return this; - } - - } -} +#if (!PCL) && ((!UNITY_5) || UNITY_STANDALONE) + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.Sockets; +using System.Text; +using System.Threading; +using MoonSharp.VsCodeDebugger.DebuggerLogic; +using MoonSharp.Interpreter; +using MoonSharp.Interpreter.Debugging; +using MoonSharp.VsCodeDebugger.SDK; + +namespace MoonSharp.VsCodeDebugger +{ + /// + /// Class implementing a debugger allowing attaching from a Visual Studio Code debugging session. + /// + public class MoonSharpVsCodeDebugServer : IDisposable + { + object m_Lock = new object(); + List m_DebuggerList = new List(); + AsyncDebugger m_Current = null; + ManualResetEvent m_StopEvent = new ManualResetEvent(false); + bool m_Started = false; + int m_Port; + + /// + /// Initializes a new instance of the class. + /// + /// The port on which the debugger listens. It's recommended to use 41912. + public MoonSharpVsCodeDebugServer(int port = 41912) + { + m_Port = port; + } + + /// + /// Initializes a new instance of the class with a default script. + /// Note that for this specific script, it will NOT attach the debugger to the script. + /// + /// The script object to debug. + /// The port on which the debugger listens. It's recommended to use 41912 unless you are going to keep more than one script object around. + /// A function which gets in input a source code and returns the path to + /// source file to use. It can return null and in that case (or if the file cannot be found) + /// a temporary file will be generated on the fly. + [Obsolete("Use the constructor taking only a port, and the 'Attach' method instead.")] + public MoonSharpVsCodeDebugServer(Script script, int port, Func sourceFinder = null) + { + m_Port = port; + m_Current = new AsyncDebugger(script, sourceFinder ?? (s => s.Name), "Default script"); + m_DebuggerList.Add(m_Current); + } + + /// + /// Attaches the specified script to the debugger + /// + /// The script. + /// The name of the script. + /// A function which gets in input a source code and returns the path to + /// source file to use. It can return null and in that case (or if the file cannot be found) + /// a temporary file will be generated on the fly. + /// If the script has already been attached to this debugger. + public void AttachToScript(Script script, string name, Func sourceFinder = null) + { + lock (m_Lock) + { + if (m_DebuggerList.Any(d => d.Script == script)) + throw new ArgumentException("Script already attached to this debugger."); + + var debugger = new AsyncDebugger(script, sourceFinder ?? (s => s.Name), name); + script.AttachDebugger(debugger); + m_DebuggerList.Add(debugger); + + if (m_Current == null) + m_Current = debugger; + } + } + + /// + /// Gets a list of the attached debuggers by id and name + /// + public IEnumerable> GetAttachedDebuggersByIdAndName() + { + lock (m_Lock) + return m_DebuggerList + .OrderBy(d => d.Id) + .Select(d => new KeyValuePair(d.Id, d.Name)) + .ToArray(); + } + + + /// + /// Gets or sets the current script by ID (see GetAttachedDebuggersByIdAndName). + /// New vscode connections will attach to this debugger ID. Changing the current ID does NOT disconnect + /// connected clients. + /// + public int? CurrentId + { + get { lock (m_Lock) return m_Current != null ? m_Current.Id : (int?)null; } + set + { + lock (m_Lock) + { + if (value == null) + { + m_Current = null; + return; + } + + var current = (m_DebuggerList.FirstOrDefault(d => d.Id == value)); + + if (current == null) + throw new ArgumentException("Cannot find debugger with given Id."); + + m_Current = current; + } + } + } + + + /// + /// Gets or sets the current script. New vscode connections will attach to this script. Changing the current script does NOT disconnect + /// connected clients. + /// + public Script Current + { + get { lock(m_Lock) return m_Current != null ? m_Current.Script : null; } + set + { + lock (m_Lock) + { + if (value == null) + { + m_Current = null; + return; + } + + var current = (m_DebuggerList.FirstOrDefault(d => d.Script == value)); + + if (current == null) + throw new ArgumentException("Cannot find debugger with given script associated."); + + m_Current = current; + } + } + } + + /// + /// Detaches the specified script. The debugger attached to that script will get disconnected. + /// + /// The script. + /// Thrown if the script cannot be found. + public void Detach(Script script) + { + lock (m_Lock) + { + var removed = m_DebuggerList.FirstOrDefault(d => d.Script == script); + + if (removed == null) + throw new ArgumentException("Cannot detach script - not found."); + + removed.Client = null; + + m_DebuggerList.Remove(removed); + + if (m_Current == removed) + { + if (m_DebuggerList.Count > 0) + m_Current = m_DebuggerList[m_DebuggerList.Count - 1]; + else + m_Current = null; + } + + } + } + + /// + /// Gets or sets a delegate which will be called when logging messages are generated + /// + public Action Logger { get; set; } + + + /// + /// Gets the debugger object. Obsolete, use the new interface using the Attach method instead. + /// + [Obsolete("Use the Attach method instead.")] + public IDebugger GetDebugger() + { + lock(m_Lock) + return m_Current; + } + + /// + /// Stops listening + /// + /// Cannot stop; server was not started. + public void Dispose() + { + m_StopEvent.Set(); + } + + /// + /// Starts listening on the localhost for incoming connections. + /// + public MoonSharpVsCodeDebugServer Start() + { + lock (m_Lock) + { + if (m_Started) + throw new InvalidOperationException("Cannot start; server has already been started."); + + m_StopEvent.Reset(); + + TcpListener serverSocket = null; + serverSocket = new TcpListener(IPAddress.Parse("127.0.0.1"), m_Port); + serverSocket.Start(); + + SpawnThread("VsCodeDebugServer_" + m_Port.ToString(), () => ListenThread(serverSocket)); + + m_Started = true; + + return this; + } + } + + + private void ListenThread(TcpListener serverSocket) + { + try + { + while (!m_StopEvent.WaitOne(0)) + { +#if DOTNET_CORE + var task = serverSocket.AcceptSocketAsync(); + task.Wait(); + var clientSocket = task.Result; +#else + var clientSocket = serverSocket.AcceptSocket(); +#endif + + if (clientSocket != null) + { + string sessionId = Guid.NewGuid().ToString("N"); + Log("[{0}] : Accepted connection from client {1}", sessionId, clientSocket.RemoteEndPoint); + + SpawnThread("VsCodeDebugSession_" + sessionId, () => + { + using (var networkStream = new NetworkStream(clientSocket)) + { + try + { + RunSession(sessionId, networkStream); + } + catch (Exception ex) + { + Log("[{0}] : Error : {1}", ex.Message); + } + } + +#if DOTNET_CORE + clientSocket.Dispose(); +#else + clientSocket.Close(); +#endif + Log("[{0}] : Client connection closed", sessionId); + }); + } + } + } + catch (Exception e) + { + Log("Fatal error in listening thread : {0}", e.Message); + } + finally + { + if (serverSocket != null) + serverSocket.Stop(); + } + } + + + private void RunSession(string sessionId, NetworkStream stream) + { + DebugSession debugSession = null; + + lock (m_Lock) + { + if (m_Current != null) + debugSession = new MoonSharpDebugSession(this, m_Current); + else + debugSession = new EmptyDebugSession(this); + } + + debugSession.ProcessLoop(stream, stream); + } + + private void Log(string format, params object[] args) + { + Action logger = Logger; + + if (logger != null) + { + string msg = string.Format(format, args); + logger(msg); + } + } + + + private static void SpawnThread(string name, Action threadProc) + { +#if DOTNET_CORE + System.Threading.Tasks.Task.Run(() => threadProc()); +#else + new System.Threading.Thread(() => threadProc()) + { + IsBackground = true, + Name = name + } + .Start(); +#endif + } + } +} + +#else + using System; +using System.Collections.Generic; +using MoonSharp.Interpreter; +using MoonSharp.Interpreter.Debugging; + +namespace MoonSharp.VsCodeDebugger +{ + public class MoonSharpVsCodeDebugServer : IDisposable + { + public MoonSharpVsCodeDebugServer(int port = 41912) + { + } + + [Obsolete("Use the constructor taking only a port, and the 'Attach' method instead.")] + public MoonSharpVsCodeDebugServer(Script script, int port, Func sourceFinder = null) + { + } + + public void AttachToScript(Script script, string name, Func sourceFinder = null) + { + } + + public IEnumerable> GetAttachedDebuggersByIdAndName() + { + yield break; + } + + + public int? CurrentId + { + get { return null; } + set { } + } + + + public Script Current + { + get { return null; } + set { } + } + + /// + /// Detaches the specified script. The debugger attached to that script will get disconnected. + /// + /// The script. + /// Thrown if the script cannot be found. + public void Detach(Script script) + { + + } + + public Action Logger { get; set; } + + + [Obsolete("Use the Attach method instead.")] + public IDebugger GetDebugger() + { + return null; + } + + public void Dispose() + { + } + + public MoonSharpVsCodeDebugServer Start() + { + return this; + } + + } +} #endif \ No newline at end of file diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/SDK/DebugSession.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/SDK/DebugSession.cs index ee26d7d0..357303ce 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/SDK/DebugSession.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/SDK/DebugSession.cs @@ -1,30 +1,30 @@ #if (!PCL) && ((!UNITY_5) || UNITY_STANDALONE) - + /*--------------------------------------------------------------------------------------------- -Copyright (c) Microsoft Corporation - -All rights reserved. - -MIT License - -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 +Copyright (c) Microsoft Corporation + +All rights reserved. + +MIT License + +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.Collections.Generic; using System.Linq; @@ -606,5 +606,5 @@ namespace MoonSharp.VsCodeDebugger.SDK } } } -} +} #endif \ No newline at end of file diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/SDK/Protocol.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/SDK/Protocol.cs index 5a8bafb6..9db92859 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/SDK/Protocol.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/SDK/Protocol.cs @@ -1,30 +1,30 @@ #if (!PCL) && ((!UNITY_5) || UNITY_STANDALONE) - + /*--------------------------------------------------------------------------------------------- -Copyright (c) Microsoft Corporation - -All rights reserved. - -MIT License - -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 +Copyright (c) Microsoft Corporation + +All rights reserved. + +MIT License + +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.Text; using System.IO; @@ -338,5 +338,5 @@ namespace MoonSharp.VsCodeDebugger.SDK } -} +} #endif \ No newline at end of file diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/SDK/Utilities.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/SDK/Utilities.cs index ed185185..afd92ae0 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/SDK/Utilities.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/SDK/Utilities.cs @@ -1,38 +1,38 @@ #if (!PCL) && ((!UNITY_5) || UNITY_STANDALONE) - + /*--------------------------------------------------------------------------------------------- -Copyright (c) Microsoft Corporation - -All rights reserved. - -MIT License - -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 +Copyright (c) Microsoft Corporation + +All rights reserved. + +MIT License + +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.Net; using System.IO; using System.Linq; using System.Text.RegularExpressions; using System.Reflection; -using MoonSharp.Interpreter.Compatibility; - +using MoonSharp.Interpreter.Compatibility; + namespace MoonSharp.VsCodeDebugger.SDK { internal class Utilities @@ -90,6 +90,6 @@ namespace MoonSharp.VsCodeDebugger.SDK */ } } -} - -#endif +} + +#endif diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/AsyncExtensions.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/AsyncExtensions.cs index d68f914a..eb0055c5 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/AsyncExtensions.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/AsyncExtensions.cs @@ -69,8 +69,8 @@ namespace MoonSharp.Interpreter public static Task CallAsync(this Closure function, params DynValue[] args) { return ExecAsync(() => function.Call(args)); - } - + } + /// /// Asynchronously loads and executes a string containing a Lua/MoonSharp script. /// @@ -86,9 +86,9 @@ namespace MoonSharp.Interpreter public static Task DoStringAsync(this Script script, string code, Table globalContext = null, string codeFriendlyName = null) { return ExecAsync(() => script.DoString(code, globalContext, codeFriendlyName)); - } - - + } + + /// /// Asynchronously loads and executes a stream containing a Lua/MoonSharp script. /// @@ -104,9 +104,9 @@ namespace MoonSharp.Interpreter public static Task DoStreamAsync(this Script script, Stream stream, Table globalContext = null, string codeFriendlyName = null) { return ExecAsync(() => script.DoStream(stream, globalContext, codeFriendlyName)); - } - - + } + + /// /// Asynchronously loads and executes a file containing a Lua/MoonSharp script. /// diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Attributes.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Attributes.cs index c3ad5ca2..a53bc57c 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Attributes.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Attributes.cs @@ -16,6 +16,6 @@ namespace System.Reflection public GuidAttribute(string dummy) { } } -} -#endif - +} +#endif + diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Framework.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Framework.cs index b52784c3..5961fd1e 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Framework.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Framework.cs @@ -1,16 +1,16 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using MoonSharp.Interpreter.Compatibility.Frameworks; - -namespace MoonSharp.Interpreter.Compatibility -{ - public static class Framework - { - static FrameworkCurrent s_FrameworkCurrent = new FrameworkCurrent(); - - public static FrameworkBase Do { get { return s_FrameworkCurrent; } } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using MoonSharp.Interpreter.Compatibility.Frameworks; + +namespace MoonSharp.Interpreter.Compatibility +{ + public static class Framework + { + static FrameworkCurrent s_FrameworkCurrent = new FrameworkCurrent(); + + public static FrameworkBase Do { get { return s_FrameworkCurrent; } } + } +} diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/Base/FrameworkBase.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/Base/FrameworkBase.cs index e5566bf6..fd60c9db 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/Base/FrameworkBase.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/Base/FrameworkBase.cs @@ -1,75 +1,75 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; - -namespace MoonSharp.Interpreter.Compatibility.Frameworks -{ - public abstract class FrameworkBase - { - public abstract bool StringContainsChar(string str, char chr); - - public abstract bool IsValueType(Type t); - - public abstract Assembly GetAssembly(Type t); - - public abstract Type GetBaseType(Type t); - - public abstract bool IsGenericType(Type t); - - public abstract bool IsGenericTypeDefinition(Type t); - - public abstract bool IsEnum(Type t); - - public abstract bool IsNestedPublic(Type t); - - public abstract bool IsAbstract(Type t); - - public abstract bool IsInterface(Type t); - - public abstract Attribute[] GetCustomAttributes(Type t, bool inherit); - - public abstract Attribute[] GetCustomAttributes(Type t, Type at, bool inherit); - - public abstract Type[] GetInterfaces(Type t); - - public abstract bool IsInstanceOfType(Type t, object o); - - public abstract MethodInfo GetAddMethod(EventInfo ei); - - public abstract MethodInfo GetRemoveMethod(EventInfo ei); - - public abstract MethodInfo GetGetMethod(PropertyInfo pi); - - public abstract MethodInfo GetSetMethod(PropertyInfo pi); - - public abstract Type GetInterface(Type type, string name); - - public abstract PropertyInfo[] GetProperties(Type type); - - public abstract PropertyInfo GetProperty(Type type, string name); - - public abstract Type[] GetNestedTypes(Type type); - - public abstract EventInfo[] GetEvents(Type type); - - public abstract ConstructorInfo[] GetConstructors(Type type); - - public abstract Type[] GetAssemblyTypes(Assembly asm); - - public abstract MethodInfo[] GetMethods(Type type); - - public abstract FieldInfo[] GetFields(Type t); - - public abstract MethodInfo GetMethod(Type type, string name); - - public abstract Type[] GetGenericArguments(Type t); - - public abstract bool IsAssignableFrom(Type current, Type toCompare); - - public abstract bool IsDbNull(object o); - - public abstract MethodInfo GetMethod(Type resourcesType, string v, Type[] type); - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; + +namespace MoonSharp.Interpreter.Compatibility.Frameworks +{ + public abstract class FrameworkBase + { + public abstract bool StringContainsChar(string str, char chr); + + public abstract bool IsValueType(Type t); + + public abstract Assembly GetAssembly(Type t); + + public abstract Type GetBaseType(Type t); + + public abstract bool IsGenericType(Type t); + + public abstract bool IsGenericTypeDefinition(Type t); + + public abstract bool IsEnum(Type t); + + public abstract bool IsNestedPublic(Type t); + + public abstract bool IsAbstract(Type t); + + public abstract bool IsInterface(Type t); + + public abstract Attribute[] GetCustomAttributes(Type t, bool inherit); + + public abstract Attribute[] GetCustomAttributes(Type t, Type at, bool inherit); + + public abstract Type[] GetInterfaces(Type t); + + public abstract bool IsInstanceOfType(Type t, object o); + + public abstract MethodInfo GetAddMethod(EventInfo ei); + + public abstract MethodInfo GetRemoveMethod(EventInfo ei); + + public abstract MethodInfo GetGetMethod(PropertyInfo pi); + + public abstract MethodInfo GetSetMethod(PropertyInfo pi); + + public abstract Type GetInterface(Type type, string name); + + public abstract PropertyInfo[] GetProperties(Type type); + + public abstract PropertyInfo GetProperty(Type type, string name); + + public abstract Type[] GetNestedTypes(Type type); + + public abstract EventInfo[] GetEvents(Type type); + + public abstract ConstructorInfo[] GetConstructors(Type type); + + public abstract Type[] GetAssemblyTypes(Assembly asm); + + public abstract MethodInfo[] GetMethods(Type type); + + public abstract FieldInfo[] GetFields(Type t); + + public abstract MethodInfo GetMethod(Type type, string name); + + public abstract Type[] GetGenericArguments(Type t); + + public abstract bool IsAssignableFrom(Type current, Type toCompare); + + public abstract bool IsDbNull(object o); + + public abstract MethodInfo GetMethod(Type resourcesType, string v, Type[] type); + } +} diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/Base/FrameworkClrBase.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/Base/FrameworkClrBase.cs index 59bb96b0..de9b72e4 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/Base/FrameworkClrBase.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/Base/FrameworkClrBase.cs @@ -1,116 +1,116 @@ -#if !(DOTNET_CORE || NETFX_CORE) - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; - -namespace MoonSharp.Interpreter.Compatibility.Frameworks -{ - abstract class FrameworkClrBase : FrameworkReflectionBase - { - BindingFlags BINDINGFLAGS_MEMBER = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static; - BindingFlags BINDINGFLAGS_INNERCLASS = BindingFlags.Public | BindingFlags.NonPublic; - - public override Type GetTypeInfoFromType(Type t) - { - return t; - } - - public override MethodInfo GetAddMethod(EventInfo ei) - { - return ei.GetAddMethod(true); - } - - public override ConstructorInfo[] GetConstructors(Type type) - { - return type.GetConstructors(BINDINGFLAGS_MEMBER); - } - - public override EventInfo[] GetEvents(Type type) - { - return type.GetEvents(BINDINGFLAGS_MEMBER); - } - - public override FieldInfo[] GetFields(Type type) - { - return type.GetFields(BINDINGFLAGS_MEMBER); - } - - public override Type[] GetGenericArguments(Type type) - { - return type.GetGenericArguments(); - } - - public override MethodInfo GetGetMethod(PropertyInfo pi) - { - return pi.GetGetMethod(true); - } - - public override Type[] GetInterfaces(Type t) - { - return t.GetInterfaces(); - } - - public override MethodInfo GetMethod(Type type, string name) - { - return type.GetMethod(name); - } - - public override MethodInfo[] GetMethods(Type type) - { - return type.GetMethods(BINDINGFLAGS_MEMBER); - } - - public override Type[] GetNestedTypes(Type type) - { - return type.GetNestedTypes(BINDINGFLAGS_INNERCLASS); - } - - public override PropertyInfo[] GetProperties(Type type) - { - return type.GetProperties(BINDINGFLAGS_MEMBER); - } - - public override PropertyInfo GetProperty(Type type, string name) - { - return type.GetProperty(name); - } - - public override MethodInfo GetRemoveMethod(EventInfo ei) - { - return ei.GetRemoveMethod(true); - } - - public override MethodInfo GetSetMethod(PropertyInfo pi) - { - return pi.GetSetMethod(true); - } - - - public override bool IsAssignableFrom(Type current, Type toCompare) - { - return current.IsAssignableFrom(toCompare); - } - - public override bool IsInstanceOfType(Type t, object o) - { - return t.IsInstanceOfType(o); - } - - - public override MethodInfo GetMethod(Type resourcesType, string name, Type[] types) - { - return resourcesType.GetMethod(name, types); - } - - public override Type[] GetAssemblyTypes(Assembly asm) - { - return asm.GetTypes(); - } - - } -} - +#if !(DOTNET_CORE || NETFX_CORE) + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; + +namespace MoonSharp.Interpreter.Compatibility.Frameworks +{ + abstract class FrameworkClrBase : FrameworkReflectionBase + { + BindingFlags BINDINGFLAGS_MEMBER = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static; + BindingFlags BINDINGFLAGS_INNERCLASS = BindingFlags.Public | BindingFlags.NonPublic; + + public override Type GetTypeInfoFromType(Type t) + { + return t; + } + + public override MethodInfo GetAddMethod(EventInfo ei) + { + return ei.GetAddMethod(true); + } + + public override ConstructorInfo[] GetConstructors(Type type) + { + return type.GetConstructors(BINDINGFLAGS_MEMBER); + } + + public override EventInfo[] GetEvents(Type type) + { + return type.GetEvents(BINDINGFLAGS_MEMBER); + } + + public override FieldInfo[] GetFields(Type type) + { + return type.GetFields(BINDINGFLAGS_MEMBER); + } + + public override Type[] GetGenericArguments(Type type) + { + return type.GetGenericArguments(); + } + + public override MethodInfo GetGetMethod(PropertyInfo pi) + { + return pi.GetGetMethod(true); + } + + public override Type[] GetInterfaces(Type t) + { + return t.GetInterfaces(); + } + + public override MethodInfo GetMethod(Type type, string name) + { + return type.GetMethod(name); + } + + public override MethodInfo[] GetMethods(Type type) + { + return type.GetMethods(BINDINGFLAGS_MEMBER); + } + + public override Type[] GetNestedTypes(Type type) + { + return type.GetNestedTypes(BINDINGFLAGS_INNERCLASS); + } + + public override PropertyInfo[] GetProperties(Type type) + { + return type.GetProperties(BINDINGFLAGS_MEMBER); + } + + public override PropertyInfo GetProperty(Type type, string name) + { + return type.GetProperty(name); + } + + public override MethodInfo GetRemoveMethod(EventInfo ei) + { + return ei.GetRemoveMethod(true); + } + + public override MethodInfo GetSetMethod(PropertyInfo pi) + { + return pi.GetSetMethod(true); + } + + + public override bool IsAssignableFrom(Type current, Type toCompare) + { + return current.IsAssignableFrom(toCompare); + } + + public override bool IsInstanceOfType(Type t, object o) + { + return t.IsInstanceOfType(o); + } + + + public override MethodInfo GetMethod(Type resourcesType, string name, Type[] types) + { + return resourcesType.GetMethod(name, types); + } + + public override Type[] GetAssemblyTypes(Assembly asm) + { + return asm.GetTypes(); + } + + } +} + #endif \ No newline at end of file diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/Base/FrameworkReflectionBase.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/Base/FrameworkReflectionBase.cs index 2b2605ca..47849c83 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/Base/FrameworkReflectionBase.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/Base/FrameworkReflectionBase.cs @@ -1,76 +1,76 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; - -#if DOTNET_CORE || NETFX_CORE - using TTypeInfo = System.Reflection.TypeInfo; -#else - using TTypeInfo = System.Type; -#endif - -namespace MoonSharp.Interpreter.Compatibility.Frameworks -{ - abstract class FrameworkReflectionBase : FrameworkBase - { - public abstract TTypeInfo GetTypeInfoFromType(Type t); - - public override Assembly GetAssembly(Type t) - { - return GetTypeInfoFromType(t).Assembly; - } - - public override Type GetBaseType(Type t) - { - return GetTypeInfoFromType(t).BaseType; - } - - - public override bool IsValueType(Type t) - { - return GetTypeInfoFromType(t).IsValueType; - } - - public override bool IsInterface(Type t) - { - return GetTypeInfoFromType(t).IsInterface; - } - - public override bool IsNestedPublic(Type t) - { - return GetTypeInfoFromType(t).IsNestedPublic; - } - public override bool IsAbstract(Type t) - { - return GetTypeInfoFromType(t).IsAbstract; - } - - public override bool IsEnum(Type t) - { - return GetTypeInfoFromType(t).IsEnum; - } - - public override bool IsGenericTypeDefinition(Type t) - { - return GetTypeInfoFromType(t).IsGenericTypeDefinition; - } - - public override bool IsGenericType(Type t) - { - return GetTypeInfoFromType(t).IsGenericType; - } - - public override Attribute[] GetCustomAttributes(Type t, bool inherit) - { - return GetTypeInfoFromType(t).GetCustomAttributes(inherit).OfType().ToArray(); - } - - public override Attribute[] GetCustomAttributes(Type t, Type at, bool inherit) - { - return GetTypeInfoFromType(t).GetCustomAttributes(at, inherit).OfType().ToArray(); - } - - - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; + +#if DOTNET_CORE || NETFX_CORE + using TTypeInfo = System.Reflection.TypeInfo; +#else + using TTypeInfo = System.Type; +#endif + +namespace MoonSharp.Interpreter.Compatibility.Frameworks +{ + abstract class FrameworkReflectionBase : FrameworkBase + { + public abstract TTypeInfo GetTypeInfoFromType(Type t); + + public override Assembly GetAssembly(Type t) + { + return GetTypeInfoFromType(t).Assembly; + } + + public override Type GetBaseType(Type t) + { + return GetTypeInfoFromType(t).BaseType; + } + + + public override bool IsValueType(Type t) + { + return GetTypeInfoFromType(t).IsValueType; + } + + public override bool IsInterface(Type t) + { + return GetTypeInfoFromType(t).IsInterface; + } + + public override bool IsNestedPublic(Type t) + { + return GetTypeInfoFromType(t).IsNestedPublic; + } + public override bool IsAbstract(Type t) + { + return GetTypeInfoFromType(t).IsAbstract; + } + + public override bool IsEnum(Type t) + { + return GetTypeInfoFromType(t).IsEnum; + } + + public override bool IsGenericTypeDefinition(Type t) + { + return GetTypeInfoFromType(t).IsGenericTypeDefinition; + } + + public override bool IsGenericType(Type t) + { + return GetTypeInfoFromType(t).IsGenericType; + } + + public override Attribute[] GetCustomAttributes(Type t, bool inherit) + { + return GetTypeInfoFromType(t).GetCustomAttributes(inherit).OfType().ToArray(); + } + + public override Attribute[] GetCustomAttributes(Type t, Type at, bool inherit) + { + return GetTypeInfoFromType(t).GetCustomAttributes(at, inherit).OfType().ToArray(); + } + + + } +} diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/FrameworkCLR.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/FrameworkCLR.cs index c7fc2b52..e1bc4f2c 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/FrameworkCLR.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/FrameworkCLR.cs @@ -1,31 +1,31 @@ -#if !(DOTNET_CORE || NETFX_CORE) && !PCL - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; - -namespace MoonSharp.Interpreter.Compatibility.Frameworks -{ - class FrameworkCurrent : FrameworkClrBase - { - public override bool IsDbNull(object o) - { - return o != null && Convert.IsDBNull(o); - } - - - public override bool StringContainsChar(string str, char chr) - { - return str.Contains(chr); - } - - public override Type GetInterface(Type type, string name) - { - return type.GetInterface(name); - } - } -} - -#endif +#if !(DOTNET_CORE || NETFX_CORE) && !PCL + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; + +namespace MoonSharp.Interpreter.Compatibility.Frameworks +{ + class FrameworkCurrent : FrameworkClrBase + { + public override bool IsDbNull(object o) + { + return o != null && Convert.IsDBNull(o); + } + + + public override bool StringContainsChar(string str, char chr) + { + return str.Contains(chr); + } + + public override Type GetInterface(Type type, string name) + { + return type.GetInterface(name); + } + } +} + +#endif diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/FrameworkCore.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/FrameworkCore.cs index 95173d5b..1e73d0c9 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/FrameworkCore.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/FrameworkCore.cs @@ -1,132 +1,132 @@ -#if DOTNET_CORE - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; - -namespace MoonSharp.Interpreter.Compatibility.Frameworks -{ - class FrameworkCurrent : FrameworkReflectionBase - { - public override TypeInfo GetTypeInfoFromType(Type t) - { - return t.GetTypeInfo(); - } - - private T[] SafeArray(IEnumerable prop) - { - return prop != null ? prop.ToArray() : new T[0]; - } - - public override MethodInfo GetAddMethod(EventInfo ei) - { - return ei.GetAddMethod(true); - } - - public override ConstructorInfo[] GetConstructors(Type type) - { - return SafeArray(GetTypeInfoFromType(type).DeclaredConstructors); - } - - public override EventInfo[] GetEvents(Type type) - { - return SafeArray(GetTypeInfoFromType(type).DeclaredEvents); - } - - public override FieldInfo[] GetFields(Type type) - { - return SafeArray(GetTypeInfoFromType(type).DeclaredFields); - } - - public override Type[] GetGenericArguments(Type type) - { - return type.GetTypeInfo().GetGenericArguments(); - } - - public override MethodInfo GetGetMethod(PropertyInfo pi) - { - return pi.GetGetMethod(true); - } - - public override Type GetInterface(Type type, string name) - { - return GetTypeInfoFromType(type).GetInterface(name); - } - - public override Type[] GetInterfaces(Type t) - { - return GetTypeInfoFromType(t).GetInterfaces(); - } - - - public override MethodInfo GetMethod(Type type, string name) - { - return GetTypeInfoFromType(type).GetMethod(name); - } - - public override MethodInfo[] GetMethods(Type type) - { - return SafeArray(GetTypeInfoFromType(type).DeclaredMethods); - } - - public override Type[] GetNestedTypes(Type type) - { - return SafeArray(GetTypeInfoFromType(type).DeclaredNestedTypes.Select(ti => ti.AsType())); - } - - public override PropertyInfo[] GetProperties(Type type) - { - return SafeArray(GetTypeInfoFromType(type).DeclaredProperties); - } - - public override PropertyInfo GetProperty(Type type, string name) - { - return GetTypeInfoFromType(type).GetProperty(name); - } - - public override MethodInfo GetRemoveMethod(EventInfo ei) - { - return ei.GetRemoveMethod(true); - } - - public override MethodInfo GetSetMethod(PropertyInfo pi) - { - return pi.GetSetMethod(true); - } - - - public override bool IsAssignableFrom(Type current, Type toCompare) - { - return current.GetTypeInfo().IsAssignableFrom(toCompare.GetTypeInfo()); - } - - public override bool IsDbNull(object o) - { +#if DOTNET_CORE + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; + +namespace MoonSharp.Interpreter.Compatibility.Frameworks +{ + class FrameworkCurrent : FrameworkReflectionBase + { + public override TypeInfo GetTypeInfoFromType(Type t) + { + return t.GetTypeInfo(); + } + + private T[] SafeArray(IEnumerable prop) + { + return prop != null ? prop.ToArray() : new T[0]; + } + + public override MethodInfo GetAddMethod(EventInfo ei) + { + return ei.GetAddMethod(true); + } + + public override ConstructorInfo[] GetConstructors(Type type) + { + return SafeArray(GetTypeInfoFromType(type).DeclaredConstructors); + } + + public override EventInfo[] GetEvents(Type type) + { + return SafeArray(GetTypeInfoFromType(type).DeclaredEvents); + } + + public override FieldInfo[] GetFields(Type type) + { + return SafeArray(GetTypeInfoFromType(type).DeclaredFields); + } + + public override Type[] GetGenericArguments(Type type) + { + return type.GetTypeInfo().GetGenericArguments(); + } + + public override MethodInfo GetGetMethod(PropertyInfo pi) + { + return pi.GetGetMethod(true); + } + + public override Type GetInterface(Type type, string name) + { + return GetTypeInfoFromType(type).GetInterface(name); + } + + public override Type[] GetInterfaces(Type t) + { + return GetTypeInfoFromType(t).GetInterfaces(); + } + + + public override MethodInfo GetMethod(Type type, string name) + { + return GetTypeInfoFromType(type).GetMethod(name); + } + + public override MethodInfo[] GetMethods(Type type) + { + return SafeArray(GetTypeInfoFromType(type).DeclaredMethods); + } + + public override Type[] GetNestedTypes(Type type) + { + return SafeArray(GetTypeInfoFromType(type).DeclaredNestedTypes.Select(ti => ti.AsType())); + } + + public override PropertyInfo[] GetProperties(Type type) + { + return SafeArray(GetTypeInfoFromType(type).DeclaredProperties); + } + + public override PropertyInfo GetProperty(Type type, string name) + { + return GetTypeInfoFromType(type).GetProperty(name); + } + + public override MethodInfo GetRemoveMethod(EventInfo ei) + { + return ei.GetRemoveMethod(true); + } + + public override MethodInfo GetSetMethod(PropertyInfo pi) + { + return pi.GetSetMethod(true); + } + + + public override bool IsAssignableFrom(Type current, Type toCompare) + { + return current.GetTypeInfo().IsAssignableFrom(toCompare.GetTypeInfo()); + } + + public override bool IsDbNull(object o) + { return o != null && o.GetType().FullName.StartsWith("System.DBNull"); - } - - public override bool IsInstanceOfType(Type t, object o) - { - return t.GetTypeInfo().IsInstanceOfType(o); - } - - public override bool StringContainsChar(string str, char chr) - { - return str.Contains(chr); - } - - public override MethodInfo GetMethod(Type resourcesType, string name, Type[] types) - { - return resourcesType.GetTypeInfo().GetMethod(name, types); - } - - public override Type[] GetAssemblyTypes(Assembly asm) - { - return asm.GetExportedTypes(); - } - - } -} -#endif + } + + public override bool IsInstanceOfType(Type t, object o) + { + return t.GetTypeInfo().IsInstanceOfType(o); + } + + public override bool StringContainsChar(string str, char chr) + { + return str.Contains(chr); + } + + public override MethodInfo GetMethod(Type resourcesType, string name, Type[] types) + { + return resourcesType.GetTypeInfo().GetMethod(name, types); + } + + public override Type[] GetAssemblyTypes(Assembly asm) + { + return asm.GetExportedTypes(); + } + + } +} +#endif diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/FrameworkPCL.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/FrameworkPCL.cs index 9fdfe34f..85035012 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/FrameworkPCL.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/FrameworkPCL.cs @@ -1,30 +1,30 @@ -#if !(DOTNET_CORE || NETFX_CORE) && PCL - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace MoonSharp.Interpreter.Compatibility.Frameworks -{ - class FrameworkCurrent : FrameworkClrBase - { - public override bool IsDbNull(object o) - { +#if !(DOTNET_CORE || NETFX_CORE) && PCL + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace MoonSharp.Interpreter.Compatibility.Frameworks +{ + class FrameworkCurrent : FrameworkClrBase + { + public override bool IsDbNull(object o) + { return o != null && o.GetType().FullName.StartsWith("System.DBNull"); - } - - public override bool StringContainsChar(string str, char chr) - { - return str.Contains(chr.ToString()); - } - - public override Type GetInterface(Type type, string name) - { - return type.GetInterfaces(). - FirstOrDefault(t => t.Name == name); - } - } -} - + } + + public override bool StringContainsChar(string str, char chr) + { + return str.Contains(chr.ToString()); + } + + public override Type GetInterface(Type type, string name) + { + return type.GetInterfaces(). + FirstOrDefault(t => t.Name == name); + } + } +} + #endif \ No newline at end of file diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/FrameworkWin8.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/FrameworkWin8.cs index 4ff2ee2e..f8d6e75a 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/FrameworkWin8.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/FrameworkWin8.cs @@ -1,160 +1,160 @@ -#if NETFX_CORE && !DOTNET_CORE - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; - -namespace MoonSharp.Interpreter.Compatibility.Frameworks -{ - class FrameworkCurrent : FrameworkReflectionBase - { - public override TypeInfo GetTypeInfoFromType(Type t) - { - return t.GetTypeInfo(); - } - - private T[] SafeArray(IEnumerable prop) - { - return prop != null ? prop.ToArray() : new T[0]; - } - - public override MethodInfo GetAddMethod(EventInfo ei) - { - return ei.AddMethod; - } - - public override ConstructorInfo[] GetConstructors(Type type) - { - return SafeArray(GetTypeInfoFromType(type).DeclaredConstructors); - } - - public override EventInfo[] GetEvents(Type type) - { - return SafeArray(GetTypeInfoFromType(type).DeclaredEvents); - } - - public override FieldInfo[] GetFields(Type type) - { - return SafeArray(GetTypeInfoFromType(type).DeclaredFields); - } - - public override Type[] GetGenericArguments(Type type) - { - return type.GetTypeInfo().GenericTypeArguments; - } - - public override MethodInfo GetGetMethod(PropertyInfo pi) - { - return pi.GetMethod; - } - - public override Type GetInterface(Type type, string name) - { - return type.GetTypeInfo().ImplementedInterfaces.FirstOrDefault(t => t.Name == name); - } - - public override Type[] GetInterfaces(Type t) - { - return SafeArray(GetTypeInfoFromType(t).ImplementedInterfaces); - } - - - public override MethodInfo GetMethod(Type type, string name) - { - return GetTypeInfoFromType(type).GetDeclaredMethod(name); - } - - public override MethodInfo[] GetMethods(Type type) - { - return SafeArray(GetTypeInfoFromType(type).DeclaredMethods); - } - - public override Type[] GetNestedTypes(Type type) - { - return SafeArray(GetTypeInfoFromType(type).DeclaredNestedTypes.Select(ti => ti.AsType())); - } - - public override PropertyInfo[] GetProperties(Type type) - { - return SafeArray(GetTypeInfoFromType(type).DeclaredProperties); - } - - public override PropertyInfo GetProperty(Type type, string name) - { - return GetTypeInfoFromType(type).GetDeclaredProperty(name); - } - - public override MethodInfo GetRemoveMethod(EventInfo ei) - { - return ei.RemoveMethod; - } - - public override MethodInfo GetSetMethod(PropertyInfo pi) - { - return pi.SetMethod; - } - - - public override bool IsAssignableFrom(Type current, Type toCompare) - { - return current.GetTypeInfo().IsAssignableFrom(toCompare.GetTypeInfo()); - } - - public override bool IsDbNull(object o) - { +#if NETFX_CORE && !DOTNET_CORE + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; + +namespace MoonSharp.Interpreter.Compatibility.Frameworks +{ + class FrameworkCurrent : FrameworkReflectionBase + { + public override TypeInfo GetTypeInfoFromType(Type t) + { + return t.GetTypeInfo(); + } + + private T[] SafeArray(IEnumerable prop) + { + return prop != null ? prop.ToArray() : new T[0]; + } + + public override MethodInfo GetAddMethod(EventInfo ei) + { + return ei.AddMethod; + } + + public override ConstructorInfo[] GetConstructors(Type type) + { + return SafeArray(GetTypeInfoFromType(type).DeclaredConstructors); + } + + public override EventInfo[] GetEvents(Type type) + { + return SafeArray(GetTypeInfoFromType(type).DeclaredEvents); + } + + public override FieldInfo[] GetFields(Type type) + { + return SafeArray(GetTypeInfoFromType(type).DeclaredFields); + } + + public override Type[] GetGenericArguments(Type type) + { + return type.GetTypeInfo().GenericTypeArguments; + } + + public override MethodInfo GetGetMethod(PropertyInfo pi) + { + return pi.GetMethod; + } + + public override Type GetInterface(Type type, string name) + { + return type.GetTypeInfo().ImplementedInterfaces.FirstOrDefault(t => t.Name == name); + } + + public override Type[] GetInterfaces(Type t) + { + return SafeArray(GetTypeInfoFromType(t).ImplementedInterfaces); + } + + + public override MethodInfo GetMethod(Type type, string name) + { + return GetTypeInfoFromType(type).GetDeclaredMethod(name); + } + + public override MethodInfo[] GetMethods(Type type) + { + return SafeArray(GetTypeInfoFromType(type).DeclaredMethods); + } + + public override Type[] GetNestedTypes(Type type) + { + return SafeArray(GetTypeInfoFromType(type).DeclaredNestedTypes.Select(ti => ti.AsType())); + } + + public override PropertyInfo[] GetProperties(Type type) + { + return SafeArray(GetTypeInfoFromType(type).DeclaredProperties); + } + + public override PropertyInfo GetProperty(Type type, string name) + { + return GetTypeInfoFromType(type).GetDeclaredProperty(name); + } + + public override MethodInfo GetRemoveMethod(EventInfo ei) + { + return ei.RemoveMethod; + } + + public override MethodInfo GetSetMethod(PropertyInfo pi) + { + return pi.SetMethod; + } + + + public override bool IsAssignableFrom(Type current, Type toCompare) + { + return current.GetTypeInfo().IsAssignableFrom(toCompare.GetTypeInfo()); + } + + public override bool IsDbNull(object o) + { return o != null && o.GetType().FullName.StartsWith("System.DBNull"); - } - - public override bool IsInstanceOfType(Type t, object o) - { - if (o == null) - return false; - - return t.GetTypeInfo().IsAssignableFrom(o.GetType().GetTypeInfo()); - } - - public override bool StringContainsChar(string str, char chr) - { - return str.Contains(chr); - } - - private static MethodInfo GetMethodEx(Type t, string name, Type[] parameters) - { - var ti = t.GetTypeInfo(); - var methods = ti.GetDeclaredMethods(name); - foreach (var m in methods) - { - var plist = m.GetParameters(); - bool match = true; - foreach (var param in plist) - { - bool valid = true; - if (parameters != null) - { - foreach (var ptype in parameters) - valid &= ptype == param.ParameterType; - } - match &= valid; - } - if (match) - return m; - } - return null; - } - - - public override MethodInfo GetMethod(Type resourcesType, string name, Type[] types) - { - return GetMethodEx(resourcesType, name, types); - } - - public override Type[] GetAssemblyTypes(Assembly asm) - { - return SafeArray(asm.ExportedTypes); - } - - } -} -#endif + } + + public override bool IsInstanceOfType(Type t, object o) + { + if (o == null) + return false; + + return t.GetTypeInfo().IsAssignableFrom(o.GetType().GetTypeInfo()); + } + + public override bool StringContainsChar(string str, char chr) + { + return str.Contains(chr); + } + + private static MethodInfo GetMethodEx(Type t, string name, Type[] parameters) + { + var ti = t.GetTypeInfo(); + var methods = ti.GetDeclaredMethods(name); + foreach (var m in methods) + { + var plist = m.GetParameters(); + bool match = true; + foreach (var param in plist) + { + bool valid = true; + if (parameters != null) + { + foreach (var ptype in parameters) + valid &= ptype == param.ParameterType; + } + match &= valid; + } + if (match) + return m; + } + return null; + } + + + public override MethodInfo GetMethod(Type resourcesType, string name, Type[] types) + { + return GetMethodEx(resourcesType, name, types); + } + + public override Type[] GetAssemblyTypes(Assembly asm) + { + return SafeArray(asm.ExportedTypes); + } + + } +} +#endif diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/BasicModule.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/BasicModule.cs index ec1d895f..9e93ae3d 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/BasicModule.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/BasicModule.cs @@ -61,7 +61,7 @@ namespace MoonSharp.Interpreter.CoreLib string mode = opt.CastToString(); if (mode == null || mode == "collect" || mode == "restart") - { + { #if PCL || ENABLE_DOTNET GC.Collect(); #else diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/IO/FileUserDataBase.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/IO/FileUserDataBase.cs index c99653f6..3b751476 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/IO/FileUserDataBase.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/IO/FileUserDataBase.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; using System.Linq; -using MoonSharp.Interpreter.Compatibility; - +using MoonSharp.Interpreter.Compatibility; + namespace MoonSharp.Interpreter.CoreLib.IO { /// diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/IoModule.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/IoModule.cs index 2eb0655e..f7b1cd2d 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/IoModule.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/IoModule.cs @@ -1,12 +1,12 @@ -// Disable warnings about XML documentation +// Disable warnings about XML documentation #pragma warning disable 1591 - + using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; -using MoonSharp.Interpreter.Compatibility; +using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.CoreLib.IO; using MoonSharp.Interpreter.Platforms; diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/LoadModule.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/LoadModule.cs index 880e8231..3aaf96a4 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/LoadModule.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/LoadModule.cs @@ -22,8 +22,8 @@ namespace MoonSharp.Interpreter.CoreLib else if (package.Type != DataType.Table) { throw new InternalErrorException("'package' global variable was found and it is not a table"); - } - + } + #if PCL || ENABLE_DOTNET || NETFX_CORE string cfg = "\\\n;\n?\n!\n-\n"; #else diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/OsTimeModule.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/OsTimeModule.cs index 08bb8856..762632fa 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/OsTimeModule.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/OsTimeModule.cs @@ -118,9 +118,9 @@ namespace MoonSharp.Interpreter.CoreLib format = format.Substring(1); } else - { + { #if !(PCL || ENABLE_DOTNET || NETFX_CORE) - + try { reference = TimeZoneInfo.ConvertTimeFromUtc(reference, TimeZoneInfo.Local); diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/DataTypes/CallbackFunction.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/DataTypes/CallbackFunction.cs index a4f95303..33e68c4a 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/DataTypes/CallbackFunction.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/DataTypes/CallbackFunction.cs @@ -87,10 +87,10 @@ namespace MoonSharp.Interpreter public static CallbackFunction FromDelegate(Script script, Delegate del, InteropAccessMode accessMode = InteropAccessMode.Default) { if (accessMode == InteropAccessMode.Default) - accessMode = m_DefaultAccessMode; - + accessMode = m_DefaultAccessMode; + #if NETFX_CORE - MethodMemberDescriptor descr = new MethodMemberDescriptor(del.GetMethodInfo(), accessMode); + MethodMemberDescriptor descr = new MethodMemberDescriptor(del.GetMethodInfo(), accessMode); #else MethodMemberDescriptor descr = new MethodMemberDescriptor(del.Method, accessMode); #endif diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/DataTypes/UserData.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/DataTypes/UserData.cs index bee32b1b..c56f2285 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/DataTypes/UserData.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/DataTypes/UserData.cs @@ -141,16 +141,16 @@ namespace MoonSharp.Interpreter /// The assembly. /// if set to true extension types are registered to the appropriate registry. public static void RegisterAssembly(Assembly asm = null, bool includeExtensionTypes = false) - { - if (asm == null) - { - #if NETFX_CORE || DOTNET_CORE - throw new NotSupportedException("Assembly.GetCallingAssembly is not supported on target framework."); - #else - asm = Assembly.GetCallingAssembly(); - #endif - } - + { + if (asm == null) + { + #if NETFX_CORE || DOTNET_CORE + throw new NotSupportedException("Assembly.GetCallingAssembly is not supported on target framework."); + #else + asm = Assembly.GetCallingAssembly(); + #endif + } + TypeDescriptorRegistry.RegisterAssembly(asm, includeExtensionTypes); } diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/DynamicExpressionException.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/DynamicExpressionException.cs index 02c07cc8..97a1e960 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/DynamicExpressionException.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/DynamicExpressionException.cs @@ -1,13 +1,13 @@  -using System; - +using System; + namespace MoonSharp.Interpreter -{ +{ /// /// Exception thrown when a dynamic expression is invalid /// #if !(PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET)) || NETFX_CORE) - [Serializable] + [Serializable] #endif public class DynamicExpressionException : ScriptRuntimeException { diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/InternalErrorException.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/InternalErrorException.cs index 05dc9a42..651d2eea 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/InternalErrorException.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/InternalErrorException.cs @@ -1,12 +1,12 @@ using System; namespace MoonSharp.Interpreter -{ +{ /// /// Exception thrown when an inconsistent state is reached in the interpreter /// #if !(PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET)) || NETFX_CORE) - [Serializable] + [Serializable] #endif public class InternalErrorException : InterpreterException { diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/InterpreterException.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/InterpreterException.cs index 77db79cb..a63fe83c 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/InterpreterException.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/InterpreterException.cs @@ -3,12 +3,12 @@ using System.Collections.Generic; using MoonSharp.Interpreter.Debugging; namespace MoonSharp.Interpreter -{ +{ /// /// Base type of all exceptions thrown in MoonSharp /// #if !(PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET)) || NETFX_CORE) - [Serializable] + [Serializable] #endif public class InterpreterException : Exception { diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/ScriptRuntimeException.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/ScriptRuntimeException.cs index 1c9158c2..1dfb721d 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/ScriptRuntimeException.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/ScriptRuntimeException.cs @@ -3,13 +3,13 @@ using MoonSharp.Interpreter.Interop; using MoonSharp.Interpreter.Interop.BasicDescriptors; namespace MoonSharp.Interpreter -{ +{ /// /// Exception for all runtime errors. In addition to constructors, it offers a lot of static methods /// generating more "standard" Lua errors. /// #if !(PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET)) || NETFX_CORE) - [Serializable] + [Serializable] #endif public class ScriptRuntimeException : InterpreterException { diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/SyntaxErrorException.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/SyntaxErrorException.cs index efdffa83..8bb572f6 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/SyntaxErrorException.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/SyntaxErrorException.cs @@ -8,7 +8,7 @@ namespace MoonSharp.Interpreter /// Exception for all parsing/lexing errors. /// #if !(PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET)) || NETFX_CORE) - [Serializable] + [Serializable] #endif public class SyntaxErrorException : InterpreterException { diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Execution/VM/ByteCode.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Execution/VM/ByteCode.cs index b0695df9..41a66e89 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Execution/VM/ByteCode.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Execution/VM/ByteCode.cs @@ -57,8 +57,8 @@ namespace MoonSharp.Interpreter.Execution.VM { m_SourceRefStack.RemoveAt(m_SourceRefStack.Count - 1); m_CurrentSourceRef = (m_SourceRefStack.Count > 0) ? m_SourceRefStack[m_SourceRefStack.Count - 1] : null; - } - + } + #if (!PCL) && ((!UNITY_5) || UNITY_STANDALONE) && (!(NETFX_CORE)) public void Dump(string file) { @@ -70,8 +70,8 @@ namespace MoonSharp.Interpreter.Execution.VM sb.AppendFormat(" {0}\n", Code[i]); else sb.AppendFormat("{0:X8} {1}\n", i, Code[i]); - } - + } + File.WriteAllText(file, sb.ToString()); } #endif diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Execution/VM/Processor/Processor.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Execution/VM/Processor/Processor.cs index 78e41069..7e2a068f 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Execution/VM/Processor/Processor.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Execution/VM/Processor/Processor.cs @@ -130,13 +130,13 @@ namespace MoonSharp.Interpreter.Execution.VM } } - int GetThreadId() - { - #if ENABLE_DOTNET || NETFX_CORE - return 1; - #else - return Thread.CurrentThread.ManagedThreadId; - #endif + int GetThreadId() + { + #if ENABLE_DOTNET || NETFX_CORE + return 1; + #else + return Thread.CurrentThread.ManagedThreadId; + #endif } private void EnterProcessor() diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/IO/UndisposableStream.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/IO/UndisposableStream.cs index 6167b738..622b929b 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/IO/UndisposableStream.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/IO/UndisposableStream.cs @@ -19,8 +19,8 @@ namespace MoonSharp.Interpreter.IO protected override void Dispose(bool disposing) { - } - + } + #if !(PCL || ENABLE_DOTNET || NETFX_CORE) public override void Close() { @@ -77,8 +77,8 @@ namespace MoonSharp.Interpreter.IO public override void Write(byte[] buffer, int offset, int count) { m_Stream.Write(buffer, offset, count); - } - + } + #if (!(NETFX_CORE)) public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { @@ -88,7 +88,7 @@ namespace MoonSharp.Interpreter.IO public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { return m_Stream.BeginWrite(buffer, offset, count, callback, state); - } + } public override void EndWrite(IAsyncResult asyncResult) { @@ -98,7 +98,7 @@ namespace MoonSharp.Interpreter.IO public override int EndRead(IAsyncResult asyncResult) { return m_Stream.EndRead(asyncResult); - } + } #endif public override bool CanTimeout { diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/BasicDescriptors/DispatchingUserDataDescriptor.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/BasicDescriptors/DispatchingUserDataDescriptor.cs index 9832a385..209ca2f0 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/BasicDescriptors/DispatchingUserDataDescriptor.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/BasicDescriptors/DispatchingUserDataDescriptor.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; -using MoonSharp.Interpreter.Compatibility; +using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.Interop.Converters; namespace MoonSharp.Interpreter.Interop.BasicDescriptors diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/BasicDescriptors/ParameterDescriptor.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/BasicDescriptors/ParameterDescriptor.cs index 96257b12..547fe66c 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/BasicDescriptors/ParameterDescriptor.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/BasicDescriptors/ParameterDescriptor.cs @@ -1,8 +1,8 @@ using System; using System.Linq; using System.Reflection; -using MoonSharp.Interpreter.Compatibility; - +using MoonSharp.Interpreter.Compatibility; + namespace MoonSharp.Interpreter.Interop.BasicDescriptors { /// diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/Converters/ClrToScriptConversions.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/Converters/ClrToScriptConversions.cs index 49bc0745..7576ffdb 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/Converters/ClrToScriptConversions.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/Converters/ClrToScriptConversions.cs @@ -81,15 +81,15 @@ namespace MoonSharp.Interpreter.Interop.Converters if (obj is Delegate) { - Delegate d = (Delegate)obj; - - + Delegate d = (Delegate)obj; + + #if NETFX_CORE - MethodInfo mi = d.GetMethodInfo(); + MethodInfo mi = d.GetMethodInfo(); #else - MethodInfo mi = d.Method; + MethodInfo mi = d.Method; #endif - + if (CallbackFunction.CheckCallbackSignature(mi, false)) return DynValue.NewCallback((Func)d); } diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/Converters/ScriptToClrConversions.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/Converters/ScriptToClrConversions.cs index c0685e37..d12f80e4 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/Converters/ScriptToClrConversions.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/Converters/ScriptToClrConversions.cs @@ -1,6 +1,6 @@ using System; -using MoonSharp.Interpreter.Compatibility; - +using MoonSharp.Interpreter.Compatibility; + namespace MoonSharp.Interpreter.Interop.Converters { internal static class ScriptToClrConversions diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/Converters/TableConversions.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/Converters/TableConversions.cs index ed620e7e..0f744f45 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/Converters/TableConversions.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/Converters/TableConversions.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -using MoonSharp.Interpreter.Compatibility; - +using MoonSharp.Interpreter.Compatibility; + namespace MoonSharp.Interpreter.Interop.Converters { internal static class TableConversions diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/DescriptorHelpers.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/DescriptorHelpers.cs index f6d246f7..9bf7c402 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/DescriptorHelpers.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/DescriptorHelpers.cs @@ -3,8 +3,8 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; -using MoonSharp.Interpreter.Compatibility; - +using MoonSharp.Interpreter.Compatibility; + namespace MoonSharp.Interpreter.Interop { /// @@ -42,16 +42,16 @@ namespace MoonSharp.Interpreter.Interop return null; } - public static bool IsDelegateType(this Type t) - { - return Framework.Do.IsAssignableFrom(typeof(Delegate), t); + public static bool IsDelegateType(this Type t) + { + return Framework.Do.IsAssignableFrom(typeof(Delegate), t); } /// /// Gets the visibility of the type as a string /// public static string GetClrVisibility(this Type type) - { + { #if NETFX_CORE var t = type.GetTypeInfo(); #else @@ -66,7 +66,7 @@ namespace MoonSharp.Interpreter.Interop if (t.IsNestedFamANDAssem || t.IsNestedFamily) return "protected"; if (t.IsNestedPrivate) - return "private"; + return "private"; return "unknown"; } @@ -165,7 +165,7 @@ namespace MoonSharp.Interpreter.Interop public static Type[] SafeGetTypes(this Assembly asm) { try - { + { return Framework.Do.GetAssemblyTypes(asm); } catch (ReflectionTypeLoadException) diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/LuaStateInterop/Tools.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/LuaStateInterop/Tools.cs index 8e7aa707..4a9b36fd 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/LuaStateInterop/Tools.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/LuaStateInterop/Tools.cs @@ -1,64 +1,64 @@ -// -// This part taken from KopiLua - https://github.com/NLua/KopiLua -// -// ========================================================================================================= -// -// Kopi Lua License -// ---------------- -// MIT License for KopiLua -// Copyright (c) 2012 LoDC -// 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. -// =============================================================================== -// Lua License -// ----------- -// Lua is licensed under the terms of the MIT license reproduced below. -// This means that Lua is free software and can be used for both academic -// and commercial purposes at absolutely no cost. -// For details and rationale, see http://www.lua.org/license.html . -// =============================================================================== -// Copyright (C) 1994-2008 Lua.org, PUC-Rio. -// 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. - - +// +// This part taken from KopiLua - https://github.com/NLua/KopiLua +// +// ========================================================================================================= +// +// Kopi Lua License +// ---------------- +// MIT License for KopiLua +// Copyright (c) 2012 LoDC +// 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. +// =============================================================================== +// Lua License +// ----------- +// Lua is licensed under the terms of the MIT license reproduced below. +// This means that Lua is free software and can be used for both academic +// and commercial purposes at absolutely no cost. +// For details and rationale, see http://www.lua.org/license.html . +// =============================================================================== +// Copyright (C) 1994-2008 Lua.org, PUC-Rio. +// 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. + + #region Usings using System; using System.Globalization; using System.IO; using System.Text; -using System.Text.RegularExpressions; - - +using System.Text.RegularExpressions; + + #endregion - + namespace MoonSharp.Interpreter.Interop.LuaStateInterop { internal static class Tools - { + { #region Public Methods #region IsNumericType /// @@ -81,7 +81,7 @@ namespace MoonSharp.Interpreter.Interop.LuaStateInterop o is float || o is double || o is decimal); - } + } #endregion #region IsPositive /// @@ -93,36 +93,36 @@ namespace MoonSharp.Interpreter.Interop.LuaStateInterop /// true if the specified value is positive; otherwise, false. /// public static bool IsPositive(object Value, bool ZeroIsPositive) - { + { Type t = Value.GetType(); - if (t == typeof(sbyte)) + if (t == typeof(sbyte)) return (ZeroIsPositive ? (sbyte)Value >= 0 : (sbyte)Value > 0); - if (t == typeof(short)) + if (t == typeof(short)) return (ZeroIsPositive ? (short)Value >= 0 : (short)Value > 0); - if (t == typeof(int)) + if (t == typeof(int)) return (ZeroIsPositive ? (int)Value >= 0 : (int)Value > 0); - if (t == typeof(long)) + if (t == typeof(long)) return (ZeroIsPositive ? (long)Value >= 0 : (long)Value > 0); - if (t == typeof(byte)) + if (t == typeof(byte)) return (ZeroIsPositive ? true : (byte)Value > 0); - if (t == typeof(ushort)) + if (t == typeof(ushort)) return (ZeroIsPositive ? true : (ushort)Value > 0); - if (t == typeof(uint)) + if (t == typeof(uint)) return (ZeroIsPositive ? true : (uint)Value > 0); - if (t == typeof(ulong)) + if (t == typeof(ulong)) return (ZeroIsPositive ? true : (ulong)Value > 0); - if (t == typeof(float)) + if (t == typeof(float)) return (ZeroIsPositive ? (float)Value >= 0 : (float)Value > 0); - if (t == typeof(double)) + if (t == typeof(double)) return (ZeroIsPositive ? (double)Value >= 0 : (double)Value > 0); - if (t == typeof(decimal)) + if (t == typeof(decimal)) return (ZeroIsPositive ? (decimal)Value >= 0 : (decimal)Value > 0); - if (t == typeof(char)) + if (t == typeof(char)) return (ZeroIsPositive ? true : (char)Value != '\0'); return ZeroIsPositive; - } + } #endregion #region ToUnsigned /// @@ -135,31 +135,31 @@ namespace MoonSharp.Interpreter.Interop.LuaStateInterop { Type t = Value.GetType(); - if (t == typeof(sbyte)) + if (t == typeof(sbyte)) return (byte)((sbyte)Value); - if (t == typeof(short)) + if (t == typeof(short)) return (ushort)((short)Value); - if (t == typeof(int)) + if (t == typeof(int)) return (uint)((int)Value); - if (t == typeof(long)) + if (t == typeof(long)) return (ulong)((long)Value); - if (t == typeof(byte)) + if (t == typeof(byte)) return Value; - if (t == typeof(ushort)) + if (t == typeof(ushort)) return Value; - if (t == typeof(uint)) + if (t == typeof(uint)) return Value; - if (t == typeof(ulong)) + if (t == typeof(ulong)) return Value; - if (t == typeof(float)) + if (t == typeof(float)) return (uint)((float)Value); - if (t == typeof(double)) + if (t == typeof(double)) return (ulong)((double)Value); - if (t == typeof(decimal)) + if (t == typeof(decimal)) return (ulong)((decimal)Value); return null; - } + } #endregion #region ToInteger /// @@ -175,62 +175,62 @@ namespace MoonSharp.Interpreter.Interop.LuaStateInterop { Type t = Value.GetType(); - if (t == typeof(sbyte)) + if (t == typeof(sbyte)) return Value; - if (t == typeof(short)) + if (t == typeof(short)) return Value; - if (t == typeof(int)) + if (t == typeof(int)) return Value; - if (t == typeof(long)) + if (t == typeof(long)) return Value; - if (t == typeof(byte)) + if (t == typeof(byte)) return Value; - if (t == typeof(ushort)) + if (t == typeof(ushort)) return Value; - if (t == typeof(uint)) + if (t == typeof(uint)) return Value; - if (t == typeof(ulong)) + if (t == typeof(ulong)) return Value; - if (t == typeof(float)) + if (t == typeof(float)) return (Round ? (int)Math.Round((float)Value) : (int)((float)Value)); - if (t == typeof(double)) + if (t == typeof(double)) return (Round ? (long)Math.Round((double)Value) : (long)((double)Value)); - if (t == typeof(decimal)) - return (Round ? Math.Round((decimal)Value) : (decimal)Value); - - return null; - } + if (t == typeof(decimal)) + return (Round ? Math.Round((decimal)Value) : (decimal)Value); + + return null; + } #endregion #region UnboxToLong - public static long UnboxToLong(object Value, bool Round) - { - Type t = Value.GetType(); - - if (t == typeof(sbyte)) - return (long)((sbyte)Value); - if (t == typeof(short)) - return (long)((short)Value); - if (t == typeof(int)) - return (long)((int)Value); - if (t == typeof(long)) - return (long)Value; - if (t == typeof(byte)) - return (long)((byte)Value); - if (t == typeof(ushort)) - return (long)((ushort)Value); - if (t == typeof(uint)) - return (long)((uint)Value); - if (t == typeof(ulong)) - return (long)((ulong)Value); - if (t == typeof(float)) - return (Round ? (long)Math.Round((float)Value) : (long)((float)Value)); - if (t == typeof(double)) - return (Round ? (long)Math.Round((double)Value) : (long)((double)Value)); - if (t == typeof(decimal)) - return (Round ? (long)Math.Round((decimal)Value) : (long)((decimal)Value)); - - return 0; - } + public static long UnboxToLong(object Value, bool Round) + { + Type t = Value.GetType(); + + if (t == typeof(sbyte)) + return (long)((sbyte)Value); + if (t == typeof(short)) + return (long)((short)Value); + if (t == typeof(int)) + return (long)((int)Value); + if (t == typeof(long)) + return (long)Value; + if (t == typeof(byte)) + return (long)((byte)Value); + if (t == typeof(ushort)) + return (long)((ushort)Value); + if (t == typeof(uint)) + return (long)((uint)Value); + if (t == typeof(ulong)) + return (long)((ulong)Value); + if (t == typeof(float)) + return (Round ? (long)Math.Round((float)Value) : (long)((float)Value)); + if (t == typeof(double)) + return (Round ? (long)Math.Round((double)Value) : (long)((double)Value)); + if (t == typeof(decimal)) + return (Round ? (long)Math.Round((decimal)Value) : (long)((decimal)Value)); + + return 0; + } #endregion #region ReplaceMetaChars /// @@ -239,491 +239,491 @@ namespace MoonSharp.Interpreter.Interop.LuaStateInterop /// /// The input. /// A string with all string meta chars are replaced - public static string ReplaceMetaChars(string input) - { - return Regex.Replace(input, @"(\\)(\d{3}|[^\d])?", new MatchEvaluator(ReplaceMetaCharsMatch)); - } - private static string ReplaceMetaCharsMatch(Match m) - { - // convert octal quotes (like \040) - if (m.Groups[2].Length == 3) - return Convert.ToChar(Convert.ToByte(m.Groups[2].Value, 8)).ToString(); - else - { - // convert all other special meta characters - //TODO: \xhhh hex and possible dec !! - switch (m.Groups[2].Value) - { - case "0": // null - return "\0"; - case "a": // alert (beep) - return "\a"; - case "b": // BS - return "\b"; - case "f": // FF - return "\f"; - case "v": // vertical tab - return "\v"; - case "r": // CR - return "\r"; - case "n": // LF - return "\n"; - case "t": // Tab - return "\t"; - default: - // if neither an octal quote nor a special meta character - // so just remove the backslash - return m.Groups[2].Value; - } - } - } + public static string ReplaceMetaChars(string input) + { + return Regex.Replace(input, @"(\\)(\d{3}|[^\d])?", new MatchEvaluator(ReplaceMetaCharsMatch)); + } + private static string ReplaceMetaCharsMatch(Match m) + { + // convert octal quotes (like \040) + if (m.Groups[2].Length == 3) + return Convert.ToChar(Convert.ToByte(m.Groups[2].Value, 8)).ToString(); + else + { + // convert all other special meta characters + //TODO: \xhhh hex and possible dec !! + switch (m.Groups[2].Value) + { + case "0": // null + return "\0"; + case "a": // alert (beep) + return "\a"; + case "b": // BS + return "\b"; + case "f": // FF + return "\f"; + case "v": // vertical tab + return "\v"; + case "r": // CR + return "\r"; + case "n": // LF + return "\n"; + case "t": // Tab + return "\t"; + default: + // if neither an octal quote nor a special meta character + // so just remove the backslash + return m.Groups[2].Value; + } + } + } #endregion #region fprintf - public static void fprintf(TextWriter Destination, string Format, params object[] Parameters) - { - Destination.Write(Tools.sprintf(Format, Parameters)); - } - - + public static void fprintf(TextWriter Destination, string Format, params object[] Parameters) + { + Destination.Write(Tools.sprintf(Format, Parameters)); + } + + #endregion #region sprintf - internal static Regex r = new Regex(@"\%(\d*\$)?([\'\#\-\+ ]*)(\d*)(?:\.(\d+))?([hl])?([dioxXucsfeEgGpn%])"); - public static string sprintf(string Format, params object[] Parameters) - { + internal static Regex r = new Regex(@"\%(\d*\$)?([\'\#\-\+ ]*)(\d*)(?:\.(\d+))?([hl])?([dioxXucsfeEgGpn%])"); + public static string sprintf(string Format, params object[] Parameters) + { #region Variables - StringBuilder f = new StringBuilder(); - //Regex r = new Regex( @"\%(\d*\$)?([\'\#\-\+ ]*)(\d*)(?:\.(\d+))?([hl])?([dioxXucsfeEgGpn%])" ); - //"%[parameter][flags][width][.precision][length]type" - Match m = null; - string w = String.Empty; - int defaultParamIx = 0; - int paramIx; - object o = null; - - bool flagLeft2Right = false; - bool flagAlternate = false; - bool flagPositiveSign = false; - bool flagPositiveSpace = false; - bool flagZeroPadding = false; - bool flagGroupThousands = false; - - int fieldLength = 0; - int fieldPrecision = 0; - char shortLongIndicator = '\0'; - char formatSpecifier = '\0'; - char paddingCharacter = ' '; + StringBuilder f = new StringBuilder(); + //Regex r = new Regex( @"\%(\d*\$)?([\'\#\-\+ ]*)(\d*)(?:\.(\d+))?([hl])?([dioxXucsfeEgGpn%])" ); + //"%[parameter][flags][width][.precision][length]type" + Match m = null; + string w = String.Empty; + int defaultParamIx = 0; + int paramIx; + object o = null; + + bool flagLeft2Right = false; + bool flagAlternate = false; + bool flagPositiveSign = false; + bool flagPositiveSpace = false; + bool flagZeroPadding = false; + bool flagGroupThousands = false; + + int fieldLength = 0; + int fieldPrecision = 0; + char shortLongIndicator = '\0'; + char formatSpecifier = '\0'; + char paddingCharacter = ' '; #endregion - - // find all format parameters in format string - f.Append(Format); - m = r.Match(f.ToString()); - while (m.Success) - { + + // find all format parameters in format string + f.Append(Format); + m = r.Match(f.ToString()); + while (m.Success) + { #region parameter index - paramIx = defaultParamIx; - if (m.Groups[1] != null && m.Groups[1].Value.Length > 0) - { - string val = m.Groups[1].Value.Substring(0, m.Groups[1].Value.Length - 1); - paramIx = Convert.ToInt32(val) - 1; - }; + paramIx = defaultParamIx; + if (m.Groups[1] != null && m.Groups[1].Value.Length > 0) + { + string val = m.Groups[1].Value.Substring(0, m.Groups[1].Value.Length - 1); + paramIx = Convert.ToInt32(val) - 1; + }; #endregion - + #region format flags - // extract format flags - flagAlternate = false; - flagLeft2Right = false; - flagPositiveSign = false; - flagPositiveSpace = false; - flagZeroPadding = false; - flagGroupThousands = false; - if (m.Groups[2] != null && m.Groups[2].Value.Length > 0) - { - string flags = m.Groups[2].Value; - - flagAlternate = (flags.IndexOf('#') >= 0); - flagLeft2Right = (flags.IndexOf('-') >= 0); - flagPositiveSign = (flags.IndexOf('+') >= 0); - flagPositiveSpace = (flags.IndexOf(' ') >= 0); - flagGroupThousands = (flags.IndexOf('\'') >= 0); - - // positive + indicator overrides a - // positive space character - if (flagPositiveSign && flagPositiveSpace) - flagPositiveSpace = false; - } + // extract format flags + flagAlternate = false; + flagLeft2Right = false; + flagPositiveSign = false; + flagPositiveSpace = false; + flagZeroPadding = false; + flagGroupThousands = false; + if (m.Groups[2] != null && m.Groups[2].Value.Length > 0) + { + string flags = m.Groups[2].Value; + + flagAlternate = (flags.IndexOf('#') >= 0); + flagLeft2Right = (flags.IndexOf('-') >= 0); + flagPositiveSign = (flags.IndexOf('+') >= 0); + flagPositiveSpace = (flags.IndexOf(' ') >= 0); + flagGroupThousands = (flags.IndexOf('\'') >= 0); + + // positive + indicator overrides a + // positive space character + if (flagPositiveSign && flagPositiveSpace) + flagPositiveSpace = false; + } #endregion - + #region field length - // extract field length and - // pading character - paddingCharacter = ' '; - fieldLength = int.MinValue; - if (m.Groups[3] != null && m.Groups[3].Value.Length > 0) - { - fieldLength = Convert.ToInt32(m.Groups[3].Value); - flagZeroPadding = (m.Groups[3].Value[0] == '0'); - } + // extract field length and + // pading character + paddingCharacter = ' '; + fieldLength = int.MinValue; + if (m.Groups[3] != null && m.Groups[3].Value.Length > 0) + { + fieldLength = Convert.ToInt32(m.Groups[3].Value); + flagZeroPadding = (m.Groups[3].Value[0] == '0'); + } #endregion - - if (flagZeroPadding) - paddingCharacter = '0'; - - // left2right allignment overrides zero padding - if (flagLeft2Right && flagZeroPadding) - { - flagZeroPadding = false; - paddingCharacter = ' '; - } - + + if (flagZeroPadding) + paddingCharacter = '0'; + + // left2right allignment overrides zero padding + if (flagLeft2Right && flagZeroPadding) + { + flagZeroPadding = false; + paddingCharacter = ' '; + } + #region field precision - // extract field precision - fieldPrecision = int.MinValue; - if (m.Groups[4] != null && m.Groups[4].Value.Length > 0) - fieldPrecision = Convert.ToInt32(m.Groups[4].Value); + // extract field precision + fieldPrecision = int.MinValue; + if (m.Groups[4] != null && m.Groups[4].Value.Length > 0) + fieldPrecision = Convert.ToInt32(m.Groups[4].Value); #endregion - + #region short / long indicator - // extract short / long indicator - shortLongIndicator = Char.MinValue; - if (m.Groups[5] != null && m.Groups[5].Value.Length > 0) - shortLongIndicator = m.Groups[5].Value[0]; + // extract short / long indicator + shortLongIndicator = Char.MinValue; + if (m.Groups[5] != null && m.Groups[5].Value.Length > 0) + shortLongIndicator = m.Groups[5].Value[0]; #endregion - + #region format specifier - // extract format - formatSpecifier = Char.MinValue; - if (m.Groups[6] != null && m.Groups[6].Value.Length > 0) - formatSpecifier = m.Groups[6].Value[0]; + // extract format + formatSpecifier = Char.MinValue; + if (m.Groups[6] != null && m.Groups[6].Value.Length > 0) + formatSpecifier = m.Groups[6].Value[0]; #endregion - - // default precision is 6 digits if none is specified except - if (fieldPrecision == int.MinValue && - formatSpecifier != 's' && - formatSpecifier != 'c' && - Char.ToUpper(formatSpecifier) != 'X' && - formatSpecifier != 'o') - fieldPrecision = 6; - + + // default precision is 6 digits if none is specified except + if (fieldPrecision == int.MinValue && + formatSpecifier != 's' && + formatSpecifier != 'c' && + Char.ToUpper(formatSpecifier) != 'X' && + formatSpecifier != 'o') + fieldPrecision = 6; + #region get next value parameter - // get next value parameter and convert value parameter depending on short / long indicator - if (Parameters == null || paramIx >= Parameters.Length) - o = null; - else - { - o = Parameters[paramIx]; - - if (shortLongIndicator == 'h') - { - if (o is int) - o = (short)((int)o); - else if (o is long) - o = (short)((long)o); - else if (o is uint) - o = (ushort)((uint)o); - else if (o is ulong) - o = (ushort)((ulong)o); - } - else if (shortLongIndicator == 'l') - { - if (o is short) - o = (long)((short)o); - else if (o is int) - o = (long)((int)o); - else if (o is ushort) - o = (ulong)((ushort)o); - else if (o is uint) - o = (ulong)((uint)o); - } - } + // get next value parameter and convert value parameter depending on short / long indicator + if (Parameters == null || paramIx >= Parameters.Length) + o = null; + else + { + o = Parameters[paramIx]; + + if (shortLongIndicator == 'h') + { + if (o is int) + o = (short)((int)o); + else if (o is long) + o = (short)((long)o); + else if (o is uint) + o = (ushort)((uint)o); + else if (o is ulong) + o = (ushort)((ulong)o); + } + else if (shortLongIndicator == 'l') + { + if (o is short) + o = (long)((short)o); + else if (o is int) + o = (long)((int)o); + else if (o is ushort) + o = (ulong)((ushort)o); + else if (o is uint) + o = (ulong)((uint)o); + } + } #endregion - - // convert value parameters to a string depending on the formatSpecifier - w = String.Empty; - switch (formatSpecifier) - { + + // convert value parameters to a string depending on the formatSpecifier + w = String.Empty; + switch (formatSpecifier) + { #region % - character - case '%': // % character - w = "%"; - break; + case '%': // % character + w = "%"; + break; #endregion #region d - integer - case 'd': // integer - w = FormatNumber((flagGroupThousands ? "n" : "d"), flagAlternate, - fieldLength, int.MinValue, flagLeft2Right, - flagPositiveSign, flagPositiveSpace, - paddingCharacter, o); - defaultParamIx++; - break; + case 'd': // integer + w = FormatNumber((flagGroupThousands ? "n" : "d"), flagAlternate, + fieldLength, int.MinValue, flagLeft2Right, + flagPositiveSign, flagPositiveSpace, + paddingCharacter, o); + defaultParamIx++; + break; #endregion #region i - integer - case 'i': // integer - goto case 'd'; + case 'i': // integer + goto case 'd'; #endregion #region o - octal integer - case 'o': // octal integer - no leading zero - w = FormatOct("o", flagAlternate, - fieldLength, int.MinValue, flagLeft2Right, - paddingCharacter, o); - defaultParamIx++; - break; + case 'o': // octal integer - no leading zero + w = FormatOct("o", flagAlternate, + fieldLength, int.MinValue, flagLeft2Right, + paddingCharacter, o); + defaultParamIx++; + break; #endregion #region x - hex integer - case 'x': // hex integer - no leading zero - w = FormatHex("x", flagAlternate, - fieldLength, fieldPrecision, flagLeft2Right, - paddingCharacter, o); - defaultParamIx++; - break; + case 'x': // hex integer - no leading zero + w = FormatHex("x", flagAlternate, + fieldLength, fieldPrecision, flagLeft2Right, + paddingCharacter, o); + defaultParamIx++; + break; #endregion #region X - hex integer - case 'X': // same as x but with capital hex characters - w = FormatHex("X", flagAlternate, - fieldLength, fieldPrecision, flagLeft2Right, - paddingCharacter, o); - defaultParamIx++; - break; + case 'X': // same as x but with capital hex characters + w = FormatHex("X", flagAlternate, + fieldLength, fieldPrecision, flagLeft2Right, + paddingCharacter, o); + defaultParamIx++; + break; #endregion #region u - unsigned integer - case 'u': // unsigned integer - w = FormatNumber((flagGroupThousands ? "n" : "d"), flagAlternate, - fieldLength, int.MinValue, flagLeft2Right, - false, false, - paddingCharacter, ToUnsigned(o)); - defaultParamIx++; - break; + case 'u': // unsigned integer + w = FormatNumber((flagGroupThousands ? "n" : "d"), flagAlternate, + fieldLength, int.MinValue, flagLeft2Right, + false, false, + paddingCharacter, ToUnsigned(o)); + defaultParamIx++; + break; #endregion #region c - character - case 'c': // character - if (IsNumericType(o)) - w = Convert.ToChar(o).ToString(); - else if (o is char) - w = ((char)o).ToString(); - else if (o is string && ((string)o).Length > 0) - w = ((string)o)[0].ToString(); - defaultParamIx++; - break; + case 'c': // character + if (IsNumericType(o)) + w = Convert.ToChar(o).ToString(); + else if (o is char) + w = ((char)o).ToString(); + else if (o is string && ((string)o).Length > 0) + w = ((string)o)[0].ToString(); + defaultParamIx++; + break; #endregion #region s - string - case 's': // string - //string t = "{0" + ( fieldLength != int.MinValue ? "," + ( flagLeft2Right ? "-" : String.Empty ) + fieldLength.ToString() : String.Empty ) + ":s}"; - w = o.ToString(); - if (fieldPrecision >= 0) - w = w.Substring(0, fieldPrecision); - - if (fieldLength != int.MinValue) - if (flagLeft2Right) - w = w.PadRight(fieldLength, paddingCharacter); - else - w = w.PadLeft(fieldLength, paddingCharacter); - defaultParamIx++; - break; + case 's': // string + //string t = "{0" + ( fieldLength != int.MinValue ? "," + ( flagLeft2Right ? "-" : String.Empty ) + fieldLength.ToString() : String.Empty ) + ":s}"; + w = o.ToString(); + if (fieldPrecision >= 0) + w = w.Substring(0, fieldPrecision); + + if (fieldLength != int.MinValue) + if (flagLeft2Right) + w = w.PadRight(fieldLength, paddingCharacter); + else + w = w.PadLeft(fieldLength, paddingCharacter); + defaultParamIx++; + break; #endregion #region f - double number - case 'f': // double - w = FormatNumber((flagGroupThousands ? "n" : "f"), flagAlternate, - fieldLength, fieldPrecision, flagLeft2Right, - flagPositiveSign, flagPositiveSpace, - paddingCharacter, o); - defaultParamIx++; - break; + case 'f': // double + w = FormatNumber((flagGroupThousands ? "n" : "f"), flagAlternate, + fieldLength, fieldPrecision, flagLeft2Right, + flagPositiveSign, flagPositiveSpace, + paddingCharacter, o); + defaultParamIx++; + break; #endregion #region e - exponent number - case 'e': // double / exponent - w = FormatNumber("e", flagAlternate, - fieldLength, fieldPrecision, flagLeft2Right, - flagPositiveSign, flagPositiveSpace, - paddingCharacter, o); - defaultParamIx++; - break; + case 'e': // double / exponent + w = FormatNumber("e", flagAlternate, + fieldLength, fieldPrecision, flagLeft2Right, + flagPositiveSign, flagPositiveSpace, + paddingCharacter, o); + defaultParamIx++; + break; #endregion #region E - exponent number - case 'E': // double / exponent - w = FormatNumber("E", flagAlternate, - fieldLength, fieldPrecision, flagLeft2Right, - flagPositiveSign, flagPositiveSpace, - paddingCharacter, o); - defaultParamIx++; - break; + case 'E': // double / exponent + w = FormatNumber("E", flagAlternate, + fieldLength, fieldPrecision, flagLeft2Right, + flagPositiveSign, flagPositiveSpace, + paddingCharacter, o); + defaultParamIx++; + break; #endregion #region g - general number - case 'g': // double / exponent - w = FormatNumber("g", flagAlternate, - fieldLength, fieldPrecision, flagLeft2Right, - flagPositiveSign, flagPositiveSpace, - paddingCharacter, o); - defaultParamIx++; - break; + case 'g': // double / exponent + w = FormatNumber("g", flagAlternate, + fieldLength, fieldPrecision, flagLeft2Right, + flagPositiveSign, flagPositiveSpace, + paddingCharacter, o); + defaultParamIx++; + break; #endregion #region G - general number - case 'G': // double / exponent - w = FormatNumber("G", flagAlternate, - fieldLength, fieldPrecision, flagLeft2Right, - flagPositiveSign, flagPositiveSpace, - paddingCharacter, o); - defaultParamIx++; - break; + case 'G': // double / exponent + w = FormatNumber("G", flagAlternate, + fieldLength, fieldPrecision, flagLeft2Right, + flagPositiveSign, flagPositiveSpace, + paddingCharacter, o); + defaultParamIx++; + break; #endregion #region p - pointer - case 'p': // pointer - if (o is IntPtr) + case 'p': // pointer + if (o is IntPtr) #if PCL || ENABLE_DOTNET w = ( (IntPtr)o ).ToString(); #else - w = "0x" + ((IntPtr)o).ToString("x"); + w = "0x" + ((IntPtr)o).ToString("x"); #endif - defaultParamIx++; - break; + defaultParamIx++; + break; #endregion #region n - number of processed chars so far - case 'n': // number of characters so far - w = FormatNumber("d", flagAlternate, - fieldLength, int.MinValue, flagLeft2Right, - flagPositiveSign, flagPositiveSpace, - paddingCharacter, m.Index); - break; + case 'n': // number of characters so far + w = FormatNumber("d", flagAlternate, + fieldLength, int.MinValue, flagLeft2Right, + flagPositiveSign, flagPositiveSpace, + paddingCharacter, m.Index); + break; #endregion - default: - w = String.Empty; - defaultParamIx++; - break; - } - - // replace format parameter with parameter value - // and start searching for the next format parameter - // AFTER the position of the current inserted value - // to prohibit recursive matches if the value also - // includes a format specifier - f.Remove(m.Index, m.Length); - f.Insert(m.Index, w); - m = r.Match(f.ToString(), m.Index + w.Length); - } - - return f.ToString(); - } + default: + w = String.Empty; + defaultParamIx++; + break; + } + + // replace format parameter with parameter value + // and start searching for the next format parameter + // AFTER the position of the current inserted value + // to prohibit recursive matches if the value also + // includes a format specifier + f.Remove(m.Index, m.Length); + f.Insert(m.Index, w); + m = r.Match(f.ToString(), m.Index + w.Length); + } + + return f.ToString(); + } #endregion #endregion - + #region Private Methods #region FormatOCT - private static string FormatOct(string NativeFormat, bool Alternate, - int FieldLength, int FieldPrecision, - bool Left2Right, - char Padding, object Value) - { - string w = String.Empty; - string lengthFormat = "{0" + (FieldLength != int.MinValue ? - "," + (Left2Right ? - "-" : - String.Empty) + FieldLength.ToString() : - String.Empty) + "}"; - - if (IsNumericType(Value)) - { - w = Convert.ToString(UnboxToLong(Value, true), 8); - - if (Left2Right || Padding == ' ') - { - if (Alternate && w != "0") - w = "0" + w; - w = String.Format(lengthFormat, w); - } - else - { - if (FieldLength != int.MinValue) - w = w.PadLeft(FieldLength - (Alternate && w != "0" ? 1 : 0), Padding); - if (Alternate && w != "0") - w = "0" + w; - } - } - - return w; - } + private static string FormatOct(string NativeFormat, bool Alternate, + int FieldLength, int FieldPrecision, + bool Left2Right, + char Padding, object Value) + { + string w = String.Empty; + string lengthFormat = "{0" + (FieldLength != int.MinValue ? + "," + (Left2Right ? + "-" : + String.Empty) + FieldLength.ToString() : + String.Empty) + "}"; + + if (IsNumericType(Value)) + { + w = Convert.ToString(UnboxToLong(Value, true), 8); + + if (Left2Right || Padding == ' ') + { + if (Alternate && w != "0") + w = "0" + w; + w = String.Format(lengthFormat, w); + } + else + { + if (FieldLength != int.MinValue) + w = w.PadLeft(FieldLength - (Alternate && w != "0" ? 1 : 0), Padding); + if (Alternate && w != "0") + w = "0" + w; + } + } + + return w; + } #endregion #region FormatHEX - private static string FormatHex(string NativeFormat, bool Alternate, - int FieldLength, int FieldPrecision, - bool Left2Right, - char Padding, object Value) - { - string w = String.Empty; - string lengthFormat = "{0" + (FieldLength != int.MinValue ? - "," + (Left2Right ? - "-" : - String.Empty) + FieldLength.ToString() : - String.Empty) + "}"; - string numberFormat = "{0:" + NativeFormat + (FieldPrecision != int.MinValue ? - FieldPrecision.ToString() : - String.Empty) + "}"; - - if (IsNumericType(Value)) - { - w = String.Format(numberFormat, Value); - - if (Left2Right || Padding == ' ') - { - if (Alternate) - w = (NativeFormat == "x" ? "0x" : "0X") + w; - w = String.Format(lengthFormat, w); - } - else - { - if (FieldLength != int.MinValue) - w = w.PadLeft(FieldLength - (Alternate ? 2 : 0), Padding); - if (Alternate) - w = (NativeFormat == "x" ? "0x" : "0X") + w; - } - } - - return w; - } + private static string FormatHex(string NativeFormat, bool Alternate, + int FieldLength, int FieldPrecision, + bool Left2Right, + char Padding, object Value) + { + string w = String.Empty; + string lengthFormat = "{0" + (FieldLength != int.MinValue ? + "," + (Left2Right ? + "-" : + String.Empty) + FieldLength.ToString() : + String.Empty) + "}"; + string numberFormat = "{0:" + NativeFormat + (FieldPrecision != int.MinValue ? + FieldPrecision.ToString() : + String.Empty) + "}"; + + if (IsNumericType(Value)) + { + w = String.Format(numberFormat, Value); + + if (Left2Right || Padding == ' ') + { + if (Alternate) + w = (NativeFormat == "x" ? "0x" : "0X") + w; + w = String.Format(lengthFormat, w); + } + else + { + if (FieldLength != int.MinValue) + w = w.PadLeft(FieldLength - (Alternate ? 2 : 0), Padding); + if (Alternate) + w = (NativeFormat == "x" ? "0x" : "0X") + w; + } + } + + return w; + } #endregion #region FormatNumber - private static string FormatNumber(string NativeFormat, bool Alternate, - int FieldLength, int FieldPrecision, - bool Left2Right, - bool PositiveSign, bool PositiveSpace, - char Padding, object Value) - { - string w = String.Empty; - string lengthFormat = "{0" + (FieldLength != int.MinValue ? - "," + (Left2Right ? - "-" : - String.Empty) + FieldLength.ToString() : - String.Empty) + "}"; - string numberFormat = "{0:" + NativeFormat + (FieldPrecision != int.MinValue ? - FieldPrecision.ToString() : - "0") + "}"; - - if (IsNumericType(Value)) - { - w = String.Format(CultureInfo.InvariantCulture, numberFormat, Value); - - if (Left2Right || Padding == ' ') - { - if (IsPositive(Value, true)) - w = (PositiveSign ? - "+" : (PositiveSpace ? " " : String.Empty)) + w; - w = String.Format(lengthFormat, w); - } - else - { - if (w.StartsWith("-")) - w = w.Substring(1); - if (FieldLength != int.MinValue) - if (PositiveSign) // xan - change here - w = w.PadLeft(FieldLength - 1, Padding); - else - w = w.PadLeft(FieldLength, Padding); - if (IsPositive(Value, true)) - w = (PositiveSign ? - "+" : "") + w; // xan - change here - else - w = "-" + w; - } - } - - return w; - } + private static string FormatNumber(string NativeFormat, bool Alternate, + int FieldLength, int FieldPrecision, + bool Left2Right, + bool PositiveSign, bool PositiveSpace, + char Padding, object Value) + { + string w = String.Empty; + string lengthFormat = "{0" + (FieldLength != int.MinValue ? + "," + (Left2Right ? + "-" : + String.Empty) + FieldLength.ToString() : + String.Empty) + "}"; + string numberFormat = "{0:" + NativeFormat + (FieldPrecision != int.MinValue ? + FieldPrecision.ToString() : + "0") + "}"; + + if (IsNumericType(Value)) + { + w = String.Format(CultureInfo.InvariantCulture, numberFormat, Value); + + if (Left2Right || Padding == ' ') + { + if (IsPositive(Value, true)) + w = (PositiveSign ? + "+" : (PositiveSpace ? " " : String.Empty)) + w; + w = String.Format(lengthFormat, w); + } + else + { + if (w.StartsWith("-")) + w = w.Substring(1); + if (FieldLength != int.MinValue) + if (PositiveSign) // xan - change here + w = w.PadLeft(FieldLength - 1, Padding); + else + w = w.PadLeft(FieldLength, Padding); + if (IsPositive(Value, true)) + w = (PositiveSign ? + "+" : "") + w; // xan - change here + else + w = "-" + w; + } + } + + return w; + } #endregion #endregion } diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/PropertyTableAssigner.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/PropertyTableAssigner.cs index 5e30b047..a6aed2fd 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/PropertyTableAssigner.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/PropertyTableAssigner.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using MoonSharp.Interpreter.Compatibility; - +using MoonSharp.Interpreter.Compatibility; + namespace MoonSharp.Interpreter.Interop { /// diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/AutoDescribingUserDataDescriptor.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/AutoDescribingUserDataDescriptor.cs index 38b26b71..c9392485 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/AutoDescribingUserDataDescriptor.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/AutoDescribingUserDataDescriptor.cs @@ -1,5 +1,5 @@ using System; -using MoonSharp.Interpreter.Compatibility; +using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.Interop; namespace MoonSharp.Interpreter diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/CompositeUserDataDescriptor.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/CompositeUserDataDescriptor.cs index c124feee..a7e1a528 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/CompositeUserDataDescriptor.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/CompositeUserDataDescriptor.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -using MoonSharp.Interpreter.Compatibility; - +using MoonSharp.Interpreter.Compatibility; + namespace MoonSharp.Interpreter.Interop { /// diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/MemberDescriptors/FunctionMemberDescriptorBase.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/MemberDescriptors/FunctionMemberDescriptorBase.cs index cc5c525a..74af1b11 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/MemberDescriptors/FunctionMemberDescriptorBase.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/MemberDescriptors/FunctionMemberDescriptorBase.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using MoonSharp.Interpreter.Compatibility; +using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.Interop.BasicDescriptors; using MoonSharp.Interpreter.Interop.Converters; diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ProxyUserDataDescriptor.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ProxyUserDataDescriptor.cs index 358570ca..8485bc60 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ProxyUserDataDescriptor.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ProxyUserDataDescriptor.cs @@ -1,6 +1,6 @@ using System; -using MoonSharp.Interpreter.Compatibility; - +using MoonSharp.Interpreter.Compatibility; + namespace MoonSharp.Interpreter.Interop { /// diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/EventMemberDescriptor.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/EventMemberDescriptor.cs index dbf8a99c..3a19cbe5 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/EventMemberDescriptor.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/EventMemberDescriptor.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using MoonSharp.Interpreter.Compatibility; +using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.DataStructs; using MoonSharp.Interpreter.Interop.BasicDescriptors; using MoonSharp.Interpreter.Interop.StandardDescriptors; @@ -202,7 +202,7 @@ namespace MoonSharp.Interpreter.Interop { m_Delegates.GetOrCreate(o, () => { - Delegate d = CreateDelegate(o); + Delegate d = CreateDelegate(o); #if NETFX_CORE Delegate handler = d.GetMethodInfo().CreateDelegate(EventInfo.EventHandlerType, d.Target); #else diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/FieldMemberDescriptor.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/FieldMemberDescriptor.cs index 1aa5f7b5..9b08de21 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/FieldMemberDescriptor.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/FieldMemberDescriptor.cs @@ -2,7 +2,7 @@ using System.Linq.Expressions; using System.Reflection; using System.Threading; -using MoonSharp.Interpreter.Compatibility; +using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.Diagnostics; using MoonSharp.Interpreter.Interop.BasicDescriptors; using MoonSharp.Interpreter.Interop.Converters; @@ -178,7 +178,7 @@ namespace MoonSharp.Interpreter.Interop { // optimized setters fall here throw ScriptRuntimeException.UserDataArgumentTypeMismatch(v.Type, FieldInfo.FieldType); - } + } #if !(PCL || ENABLE_DOTNET || NETFX_CORE) catch (FieldAccessException ex) { diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/MethodMemberDescriptor.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/MethodMemberDescriptor.cs index 8c45c794..f9280ba7 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/MethodMemberDescriptor.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/MethodMemberDescriptor.cs @@ -5,7 +5,7 @@ using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Threading; -using MoonSharp.Interpreter.Compatibility; +using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.Diagnostics; using MoonSharp.Interpreter.Interop.BasicDescriptors; diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/OverloadedMethodMemberDescriptor.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/OverloadedMethodMemberDescriptor.cs index 47a37baf..c1ad734c 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/OverloadedMethodMemberDescriptor.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/OverloadedMethodMemberDescriptor.cs @@ -1,9 +1,9 @@ -//#define DEBUG_OVERLOAD_RESOLVER - +//#define DEBUG_OVERLOAD_RESOLVER + using System; using System.Collections.Generic; using System.Linq; -using MoonSharp.Interpreter.Compatibility; +using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.Interop.BasicDescriptors; using MoonSharp.Interpreter.Interop.Converters; diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/PropertyMemberDescriptor.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/PropertyMemberDescriptor.cs index 52a763b8..618ee3cc 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/PropertyMemberDescriptor.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/PropertyMemberDescriptor.cs @@ -2,7 +2,7 @@ using System.Linq.Expressions; using System.Reflection; using System.Threading; -using MoonSharp.Interpreter.Compatibility; +using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.Diagnostics; using MoonSharp.Interpreter.Interop.BasicDescriptors; using MoonSharp.Interpreter.Interop.Converters; diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/ValueTypeDefaultCtorMemberDescriptor.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/ValueTypeDefaultCtorMemberDescriptor.cs index 2906dca6..7001eac6 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/ValueTypeDefaultCtorMemberDescriptor.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/ValueTypeDefaultCtorMemberDescriptor.cs @@ -1,5 +1,5 @@ using System; -using MoonSharp.Interpreter.Compatibility; +using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.Interop.BasicDescriptors; using MoonSharp.Interpreter.Interop.Converters; diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/StandardEnumUserDataDescriptor.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/StandardEnumUserDataDescriptor.cs index ec2d9d83..9f8c2e20 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/StandardEnumUserDataDescriptor.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/StandardEnumUserDataDescriptor.cs @@ -1,6 +1,6 @@ using System; using System.Linq; -using MoonSharp.Interpreter.Compatibility; +using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.Interop.BasicDescriptors; namespace MoonSharp.Interpreter.Interop diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/StandardGenericsUserDataDescriptor.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/StandardGenericsUserDataDescriptor.cs index 39836706..112e406c 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/StandardGenericsUserDataDescriptor.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/StandardGenericsUserDataDescriptor.cs @@ -1,6 +1,6 @@ using System; -using MoonSharp.Interpreter.Compatibility; - +using MoonSharp.Interpreter.Compatibility; + namespace MoonSharp.Interpreter.Interop { /// @@ -64,8 +64,8 @@ namespace MoonSharp.Interpreter.Interop public bool IsTypeCompatible(Type type, object obj) { return Framework.Do.IsInstanceOfType(type, obj); - } - + } + /// public IUserDataDescriptor Generate(Type type) { diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/StandardUserDataDescriptor.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/StandardUserDataDescriptor.cs index e49c8464..6eece605 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/StandardUserDataDescriptor.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/StandardUserDataDescriptor.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using MoonSharp.Interpreter.Compatibility; +using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.Interop.BasicDescriptors; namespace MoonSharp.Interpreter.Interop @@ -56,19 +56,19 @@ namespace MoonSharp.Interpreter.Interop if (AccessMode == InteropAccessMode.HideMembers) return; - if (!type.IsDelegateType()) - { - // add declared constructors - foreach (ConstructorInfo ci in Framework.Do.GetConstructors(type)) - { - if (membersToIgnore.Contains("__new")) - continue; - - AddMember("__new", MethodMemberDescriptor.TryCreateIfVisible(ci, this.AccessMode)); - } - - // valuetypes don't reflect their empty ctor.. actually empty ctors are a perversion, we don't care and implement ours - if (Framework.Do.IsValueType(type) && !membersToIgnore.Contains("__new")) + if (!type.IsDelegateType()) + { + // add declared constructors + foreach (ConstructorInfo ci in Framework.Do.GetConstructors(type)) + { + if (membersToIgnore.Contains("__new")) + continue; + + AddMember("__new", MethodMemberDescriptor.TryCreateIfVisible(ci, this.AccessMode)); + } + + // valuetypes don't reflect their empty ctor.. actually empty ctors are a perversion, we don't care and implement ours + if (Framework.Do.IsValueType(type) && !membersToIgnore.Contains("__new")) AddMember("__new", new ValueTypeDefaultCtorMemberDescriptor(type)); } diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/UserDataRegistries/ExtensionMethodsRegistry.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/UserDataRegistries/ExtensionMethodsRegistry.cs index 9dfbd875..24faf665 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/UserDataRegistries/ExtensionMethodsRegistry.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/UserDataRegistries/ExtensionMethodsRegistry.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; -using MoonSharp.Interpreter.Compatibility; +using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.DataStructs; using MoonSharp.Interpreter.Interop.BasicDescriptors; @@ -67,13 +67,13 @@ namespace MoonSharp.Interpreter.Interop.UserDataRegistries if (changesDone) ++s_ExtensionMethodChangeVersion; } - } - - private static object FrameworkGetMethods() - { - throw new NotImplementedException(); - } - + } + + private static object FrameworkGetMethods() + { + throw new NotImplementedException(); + } + /// /// Gets all the extension methods which can match a given name /// diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/UserDataRegistries/TypeDescriptorRegistry.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/UserDataRegistries/TypeDescriptorRegistry.cs index d0431b0a..945fbc88 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/UserDataRegistries/TypeDescriptorRegistry.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/UserDataRegistries/TypeDescriptorRegistry.cs @@ -4,12 +4,12 @@ using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Threading; -using MoonSharp.Interpreter.Compatibility; +using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.Interop.BasicDescriptors; using MoonSharp.Interpreter.Interop.RegistrationPolicies; namespace MoonSharp.Interpreter.Interop.UserDataRegistries -{ +{ /// /// Registry of all type descriptors. Use UserData statics to access these. /// @@ -18,8 +18,8 @@ namespace MoonSharp.Interpreter.Interop.UserDataRegistries private static object s_Lock = new object(); private static Dictionary s_TypeRegistry = new Dictionary(); private static Dictionary s_TypeRegistryHistory = new Dictionary(); - private static InteropAccessMode s_DefaultAccessMode; - + private static InteropAccessMode s_DefaultAccessMode; + /// /// Registers all types marked with a MoonSharpUserDataAttribute that ar contained in an assembly. /// @@ -27,14 +27,14 @@ namespace MoonSharp.Interpreter.Interop.UserDataRegistries /// if set to true extension types are registered to the appropriate registry. internal static void RegisterAssembly(Assembly asm = null, bool includeExtensionTypes = false) { - if (asm == null) - { - #if NETFX_CORE || DOTNET_CORE - throw new NotSupportedException("Assembly.GetCallingAssembly is not supported on target framework."); - #else - asm = Assembly.GetCallingAssembly(); - #endif - } + if (asm == null) + { + #if NETFX_CORE || DOTNET_CORE + throw new NotSupportedException("Assembly.GetCallingAssembly is not supported on target framework."); + #else + asm = Assembly.GetCallingAssembly(); + #endif + } if (includeExtensionTypes) { @@ -62,9 +62,9 @@ namespace MoonSharp.Interpreter.Interop.UserDataRegistries .First() .AccessMode); } - } - - + } + + /// /// Determines whether the specified type is registered. Note that this should be used only to check if a descriptor /// has been registered EXACTLY. For many types a descriptor can still be created, for example through the descriptor @@ -76,9 +76,9 @@ namespace MoonSharp.Interpreter.Interop.UserDataRegistries { lock (s_Lock) return s_TypeRegistry.ContainsKey(type); - } - - + } + + /// /// Unregisters a type. /// WARNING: unregistering types at runtime is a dangerous practice and may cause unwanted errors. @@ -95,8 +95,8 @@ namespace MoonSharp.Interpreter.Interop.UserDataRegistries PerformRegistration(t, null, s_TypeRegistry[t]); } } - } - + } + /// /// Gets or sets the default access mode to be used in the whole application /// @@ -114,8 +114,8 @@ namespace MoonSharp.Interpreter.Interop.UserDataRegistries s_DefaultAccessMode = value; } - } - + } + /// /// Registers a proxy type. /// @@ -127,9 +127,9 @@ namespace MoonSharp.Interpreter.Interop.UserDataRegistries { IUserDataDescriptor proxyDescriptor = RegisterType_Impl(proxyFactory.ProxyType, accessMode, friendlyName, null); return RegisterType_Impl(proxyFactory.TargetType, accessMode, friendlyName, new ProxyUserDataDescriptor(proxyFactory, proxyDescriptor, friendlyName)); - } - - + } + + /// /// Registers a type /// @@ -145,48 +145,48 @@ namespace MoonSharp.Interpreter.Interop.UserDataRegistries lock (s_Lock) { IUserDataDescriptor oldDescriptor = null; - s_TypeRegistry.TryGetValue(type, out oldDescriptor); - - if (descriptor == null) - { - if (IsTypeBlacklisted(type)) - return null; - - if (Framework.Do.GetInterfaces(type).Any(ii => ii == typeof(IUserDataType))) - { - AutoDescribingUserDataDescriptor audd = new AutoDescribingUserDataDescriptor(type, friendlyName); - return PerformRegistration(type, audd, oldDescriptor); - } - else if (Framework.Do.IsGenericTypeDefinition(type)) - { - StandardGenericsUserDataDescriptor typeGen = new StandardGenericsUserDataDescriptor(type, accessMode); - return PerformRegistration(type, typeGen, oldDescriptor); - } - else if (Framework.Do.IsEnum(type)) - { - var enumDescr = new StandardEnumUserDataDescriptor(type, friendlyName); - return PerformRegistration(type, enumDescr, oldDescriptor); - } - else - { - StandardUserDataDescriptor udd = new StandardUserDataDescriptor(type, accessMode, friendlyName); - - if (accessMode == InteropAccessMode.BackgroundOptimized) - { + s_TypeRegistry.TryGetValue(type, out oldDescriptor); + + if (descriptor == null) + { + if (IsTypeBlacklisted(type)) + return null; + + if (Framework.Do.GetInterfaces(type).Any(ii => ii == typeof(IUserDataType))) + { + AutoDescribingUserDataDescriptor audd = new AutoDescribingUserDataDescriptor(type, friendlyName); + return PerformRegistration(type, audd, oldDescriptor); + } + else if (Framework.Do.IsGenericTypeDefinition(type)) + { + StandardGenericsUserDataDescriptor typeGen = new StandardGenericsUserDataDescriptor(type, accessMode); + return PerformRegistration(type, typeGen, oldDescriptor); + } + else if (Framework.Do.IsEnum(type)) + { + var enumDescr = new StandardEnumUserDataDescriptor(type, friendlyName); + return PerformRegistration(type, enumDescr, oldDescriptor); + } + else + { + StandardUserDataDescriptor udd = new StandardUserDataDescriptor(type, accessMode, friendlyName); + + if (accessMode == InteropAccessMode.BackgroundOptimized) + { #if NETFX_CORE System.Threading.Tasks.Task.Run(() => ((IOptimizableDescriptor)udd).Optimize()); #else - ThreadPool.QueueUserWorkItem(o => ((IOptimizableDescriptor)udd).Optimize()); + ThreadPool.QueueUserWorkItem(o => ((IOptimizableDescriptor)udd).Optimize()); #endif - } - - return PerformRegistration(type, udd, oldDescriptor); - } - } - else - { - PerformRegistration(type, descriptor, oldDescriptor); - return descriptor; + } + + return PerformRegistration(type, udd, oldDescriptor); + } + } + else + { + PerformRegistration(type, descriptor, oldDescriptor); + return descriptor; } } } @@ -209,8 +209,8 @@ namespace MoonSharp.Interpreter.Interop.UserDataRegistries } return result; - } - + } + /// /// Resolves the default type of the access mode for the given type /// @@ -233,10 +233,10 @@ namespace MoonSharp.Interpreter.Interop.UserDataRegistries accessMode = s_DefaultAccessMode; return accessMode; - } - - - + } + + + /// /// Gets the best possible type descriptor for a specified CLR type. /// @@ -247,22 +247,22 @@ namespace MoonSharp.Interpreter.Interop.UserDataRegistries { lock (s_Lock) { - IUserDataDescriptor typeDescriptor = null; - - // if the type has been explicitly registered, return its descriptor as it's complete + IUserDataDescriptor typeDescriptor = null; + + // if the type has been explicitly registered, return its descriptor as it's complete if (s_TypeRegistry.ContainsKey(type)) return s_TypeRegistry[type]; if (RegistrationPolicy.AllowTypeAutoRegistration(type)) - { - // no autoreg of delegates + { + // no autoreg of delegates if (!Framework.Do.IsAssignableFrom((typeof(Delegate)), type)) { return RegisterType_Impl(type, DefaultAccessMode, type.FullName, null); } - } - - // search for the base object descriptors + } + + // search for the base object descriptors for (Type t = type; t != null; t = Framework.Do.GetBaseType(t)) { IUserDataDescriptor u; @@ -283,10 +283,10 @@ namespace MoonSharp.Interpreter.Interop.UserDataRegistries } if (typeDescriptor is IGeneratorUserDataDescriptor) - typeDescriptor = ((IGeneratorUserDataDescriptor)typeDescriptor).Generate(type); - - - // we should not search interfaces (for example, it's just for statics..), no need to look further + typeDescriptor = ((IGeneratorUserDataDescriptor)typeDescriptor).Generate(type); + + + // we should not search interfaces (for example, it's just for statics..), no need to look further if (!searchInterfaces) return typeDescriptor; @@ -331,14 +331,14 @@ namespace MoonSharp.Interpreter.Interop.UserDataRegistries else return new CompositeUserDataDescriptor(descriptors, type); } - } - - private static bool FrameworkIsAssignableFrom(Type type) - { - throw new NotImplementedException(); - } - - + } + + private static bool FrameworkIsAssignableFrom(Type type) + { + throw new NotImplementedException(); + } + + /// /// Determines whether the specified type is blacklisted. /// Blacklisted types CANNOT be registered using default descriptors but they can still be registered @@ -353,8 +353,8 @@ namespace MoonSharp.Interpreter.Interop.UserDataRegistries return true; return false; - } - + } + /// /// Gets the list of registered types. /// @@ -364,8 +364,8 @@ namespace MoonSharp.Interpreter.Interop.UserDataRegistries public static IEnumerable> RegisteredTypes { get { lock (s_Lock) return s_TypeRegistry.ToArray(); } - } - + } + /// /// Gets the list of registered types, including unregistered types. /// @@ -375,9 +375,9 @@ namespace MoonSharp.Interpreter.Interop.UserDataRegistries public static IEnumerable> RegisteredTypesHistory { get { lock (s_Lock) return s_TypeRegistryHistory.ToArray(); } - } - - + } + + /// /// Gets or sets the registration policy. /// diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Loaders/EmbeddedResourcesScriptLoader.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Loaders/EmbeddedResourcesScriptLoader.cs index 665a05a5..5c76dfa1 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Loaders/EmbeddedResourcesScriptLoader.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Loaders/EmbeddedResourcesScriptLoader.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -19,14 +19,14 @@ namespace MoonSharp.Interpreter.Loaders /// /// The assembly containing the scripts as embedded resources or null to use the calling assembly. public EmbeddedResourcesScriptLoader(Assembly resourceAssembly = null) - { - if (resourceAssembly == null) - { -#if NETFX_CORE || DOTNET_CORE - throw new NotSupportedException("Assembly.GetCallingAssembly is not supported on target framework."); -#else - resourceAssembly = Assembly.GetCallingAssembly(); -#endif + { + if (resourceAssembly == null) + { +#if NETFX_CORE || DOTNET_CORE + throw new NotSupportedException("Assembly.GetCallingAssembly is not supported on target framework."); +#else + resourceAssembly = Assembly.GetCallingAssembly(); +#endif } m_ResourceAssembly = resourceAssembly; diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Loaders/UnityAssetsScriptLoader.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Loaders/UnityAssetsScriptLoader.cs index 020ede33..7db23081 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Loaders/UnityAssetsScriptLoader.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Loaders/UnityAssetsScriptLoader.cs @@ -1,175 +1,175 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using MoonSharp.Interpreter.Compatibility; - -namespace MoonSharp.Interpreter.Loaders -{ - /// - /// A script loader which can load scripts from assets in Unity3D. - /// Scripts should be saved as .txt files in a subdirectory of Assets/Resources. - /// - /// When MoonSharp is activated on Unity3D and the default script loader is used, - /// scripts should be saved as .txt files in Assets/Resources/MoonSharp/Scripts. - /// - public class UnityAssetsScriptLoader : ScriptLoaderBase - { - Dictionary m_Resources = new Dictionary(); - - /// - /// The default path where scripts are meant to be stored (if not changed) - /// - public const string DEFAULT_PATH = "MoonSharp/Scripts"; - - /// - /// Initializes a new instance of the class. - /// - /// The path, relative to Assets/Resources. For example - /// if your scripts are stored under Assets/Resources/Scripts, you should - /// pass the value "Scripts". If null, "MoonSharp/Scripts" is used. - public UnityAssetsScriptLoader(string assetsPath = null) - { - assetsPath = assetsPath ?? DEFAULT_PATH; -#if UNITY_5 - LoadResourcesUnityNative(assetsPath); -#else - LoadResourcesWithReflection(assetsPath); -#endif - } - - - /// - /// Initializes a new instance of the class. - /// - /// A dictionary mapping filenames to the proper Lua script code. - public UnityAssetsScriptLoader(Dictionary scriptToCodeMap) - { - m_Resources = scriptToCodeMap; - } - -#if UNITY_5 - void LoadResourcesUnityNative(string assetsPath) - { - try - { - UnityEngine.Object[] array = UnityEngine.Resources.LoadAll(assetsPath, typeof(UnityEngine.TextAsset)); - - for (int i = 0; i < array.Length; i++) - { - UnityEngine.TextAsset o = (UnityEngine.TextAsset)array[i]; - - string name = o.name; - string text = o.text; - - m_Resources.Add(name, text); - } - } - catch (Exception ex) - { - UnityEngine.Debug.LogErrorFormat("Error initializing UnityScriptLoader : {0}", ex); - } - } - -#else - - void LoadResourcesWithReflection(string assetsPath) - { - try - { - Type resourcesType = Type.GetType("UnityEngine.Resources, UnityEngine"); - Type textAssetType = Type.GetType("UnityEngine.TextAsset, UnityEngine"); - - MethodInfo textAssetNameGet = Framework.Do.GetGetMethod(Framework.Do.GetProperty(textAssetType, "name")); - MethodInfo textAssetTextGet = Framework.Do.GetGetMethod(Framework.Do.GetProperty(textAssetType, "text")); - - MethodInfo loadAll = Framework.Do.GetMethod(resourcesType, "LoadAll", - new Type[] { typeof(string), typeof(Type) }); - - Array array = (Array)loadAll.Invoke(null, new object[] { assetsPath, textAssetType }); - - for (int i = 0; i < array.Length; i++) - { - object o = array.GetValue(i); - - string name = textAssetNameGet.Invoke(o, null) as string; - string text = textAssetTextGet.Invoke(o, null) as string; - - m_Resources.Add(name, text); - } - } - catch (Exception ex) - { +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using MoonSharp.Interpreter.Compatibility; + +namespace MoonSharp.Interpreter.Loaders +{ + /// + /// A script loader which can load scripts from assets in Unity3D. + /// Scripts should be saved as .txt files in a subdirectory of Assets/Resources. + /// + /// When MoonSharp is activated on Unity3D and the default script loader is used, + /// scripts should be saved as .txt files in Assets/Resources/MoonSharp/Scripts. + /// + public class UnityAssetsScriptLoader : ScriptLoaderBase + { + Dictionary m_Resources = new Dictionary(); + + /// + /// The default path where scripts are meant to be stored (if not changed) + /// + public const string DEFAULT_PATH = "MoonSharp/Scripts"; + + /// + /// Initializes a new instance of the class. + /// + /// The path, relative to Assets/Resources. For example + /// if your scripts are stored under Assets/Resources/Scripts, you should + /// pass the value "Scripts". If null, "MoonSharp/Scripts" is used. + public UnityAssetsScriptLoader(string assetsPath = null) + { + assetsPath = assetsPath ?? DEFAULT_PATH; +#if UNITY_5 + LoadResourcesUnityNative(assetsPath); +#else + LoadResourcesWithReflection(assetsPath); +#endif + } + + + /// + /// Initializes a new instance of the class. + /// + /// A dictionary mapping filenames to the proper Lua script code. + public UnityAssetsScriptLoader(Dictionary scriptToCodeMap) + { + m_Resources = scriptToCodeMap; + } + +#if UNITY_5 + void LoadResourcesUnityNative(string assetsPath) + { + try + { + UnityEngine.Object[] array = UnityEngine.Resources.LoadAll(assetsPath, typeof(UnityEngine.TextAsset)); + + for (int i = 0; i < array.Length; i++) + { + UnityEngine.TextAsset o = (UnityEngine.TextAsset)array[i]; + + string name = o.name; + string text = o.text; + + m_Resources.Add(name, text); + } + } + catch (Exception ex) + { + UnityEngine.Debug.LogErrorFormat("Error initializing UnityScriptLoader : {0}", ex); + } + } + +#else + + void LoadResourcesWithReflection(string assetsPath) + { + try + { + Type resourcesType = Type.GetType("UnityEngine.Resources, UnityEngine"); + Type textAssetType = Type.GetType("UnityEngine.TextAsset, UnityEngine"); + + MethodInfo textAssetNameGet = Framework.Do.GetGetMethod(Framework.Do.GetProperty(textAssetType, "name")); + MethodInfo textAssetTextGet = Framework.Do.GetGetMethod(Framework.Do.GetProperty(textAssetType, "text")); + + MethodInfo loadAll = Framework.Do.GetMethod(resourcesType, "LoadAll", + new Type[] { typeof(string), typeof(Type) }); + + Array array = (Array)loadAll.Invoke(null, new object[] { assetsPath, textAssetType }); + + for (int i = 0; i < array.Length; i++) + { + object o = array.GetValue(i); + + string name = textAssetNameGet.Invoke(o, null) as string; + string text = textAssetTextGet.Invoke(o, null) as string; + + m_Resources.Add(name, text); + } + } + catch (Exception ex) + { #if !(PCL || ENABLE_DOTNET || NETFX_CORE) - Console.WriteLine("Error initializing UnityScriptLoader : {0}", ex); -#endif - System.Diagnostics.Debug.WriteLine(string.Format("Error initializing UnityScriptLoader : {0}", ex)); - } - } -#endif - - private string GetFileName(string filename) - { - int b = Math.Max(filename.LastIndexOf('\\'), filename.LastIndexOf('/')); - - if (b > 0) - filename = filename.Substring(b + 1); - - return filename; - } - - /// - /// Opens a file for reading the script code. - /// It can return either a string, a byte[] or a Stream. - /// If a byte[] is returned, the content is assumed to be a serialized (dumped) bytecode. If it's a string, it's - /// assumed to be either a script or the output of a string.dump call. If a Stream, autodetection takes place. - /// - /// The file. - /// The global context. - /// - /// A string, a byte[] or a Stream. - /// - /// UnityAssetsScriptLoader.LoadFile : Cannot load + file - public override object LoadFile(string file, Table globalContext) - { - file = GetFileName(file); - - if (m_Resources.ContainsKey(file)) - return m_Resources[file]; - else - { - var error = string.Format( -@"Cannot load script '{0}'. By default, scripts should be .txt files placed under a Assets/Resources/{1} directory. -If you want scripts to be put in another directory or another way, use a custom instance of UnityAssetsScriptLoader or implement -your own IScriptLoader (possibly extending ScriptLoaderBase).", file, DEFAULT_PATH); - - throw new Exception(error); - } - } - - /// - /// Checks if a given file exists - /// - /// The file. - /// - public override bool ScriptFileExists(string file) - { - file = GetFileName(file); - return m_Resources.ContainsKey(file); - } - - - /// - /// Gets the list of loaded scripts filenames (useful for debugging purposes). - /// - /// - public string[] GetLoadedScripts() - { - return m_Resources.Keys.ToArray(); - } - - - - } -} - + Console.WriteLine("Error initializing UnityScriptLoader : {0}", ex); +#endif + System.Diagnostics.Debug.WriteLine(string.Format("Error initializing UnityScriptLoader : {0}", ex)); + } + } +#endif + + private string GetFileName(string filename) + { + int b = Math.Max(filename.LastIndexOf('\\'), filename.LastIndexOf('/')); + + if (b > 0) + filename = filename.Substring(b + 1); + + return filename; + } + + /// + /// Opens a file for reading the script code. + /// It can return either a string, a byte[] or a Stream. + /// If a byte[] is returned, the content is assumed to be a serialized (dumped) bytecode. If it's a string, it's + /// assumed to be either a script or the output of a string.dump call. If a Stream, autodetection takes place. + /// + /// The file. + /// The global context. + /// + /// A string, a byte[] or a Stream. + /// + /// UnityAssetsScriptLoader.LoadFile : Cannot load + file + public override object LoadFile(string file, Table globalContext) + { + file = GetFileName(file); + + if (m_Resources.ContainsKey(file)) + return m_Resources[file]; + else + { + var error = string.Format( +@"Cannot load script '{0}'. By default, scripts should be .txt files placed under a Assets/Resources/{1} directory. +If you want scripts to be put in another directory or another way, use a custom instance of UnityAssetsScriptLoader or implement +your own IScriptLoader (possibly extending ScriptLoaderBase).", file, DEFAULT_PATH); + + throw new Exception(error); + } + } + + /// + /// Checks if a given file exists + /// + /// The file. + /// + public override bool ScriptFileExists(string file) + { + file = GetFileName(file); + return m_Resources.ContainsKey(file); + } + + + /// + /// Gets the list of loaded scripts filenames (useful for debugging purposes). + /// + /// + public string[] GetLoadedScripts() + { + return m_Resources.Keys.ToArray(); + } + + + + } +} + diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Modules/ModuleRegister.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Modules/ModuleRegister.cs index e530bea4..f2993260 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Modules/ModuleRegister.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Modules/ModuleRegister.cs @@ -1,7 +1,7 @@ using System; using System.Linq; using System.Reflection; -using MoonSharp.Interpreter.Compatibility; +using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.CoreLib; using MoonSharp.Interpreter.Platforms; @@ -93,15 +93,15 @@ namespace MoonSharp.Interpreter MoonSharpModuleMethodAttribute attr = (MoonSharpModuleMethodAttribute)mi.GetCustomAttributes(typeof(MoonSharpModuleMethodAttribute), false).First(); if (!CallbackFunction.CheckCallbackSignature(mi, true)) - throw new ArgumentException(string.Format("Method {0} does not have the right signature.", mi.Name)); - + throw new ArgumentException(string.Format("Method {0} does not have the right signature.", mi.Name)); + #if NETFX_CORE - Delegate deleg = mi.CreateDelegate(typeof(Func)); + Delegate deleg = mi.CreateDelegate(typeof(Func)); #else - Delegate deleg = Delegate.CreateDelegate(typeof(Func), mi); + Delegate deleg = Delegate.CreateDelegate(typeof(Func), mi); #endif - - Func func = + + Func func = (Func)deleg; diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Platforms/DotNetCorePlatformAccessor.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Platforms/DotNetCorePlatformAccessor.cs index 437a1afa..2671fac8 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Platforms/DotNetCorePlatformAccessor.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Platforms/DotNetCorePlatformAccessor.cs @@ -1,18 +1,18 @@ -#if DOTNET_CORE -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.IO; -using System.Diagnostics; - -namespace MoonSharp.Interpreter.Platforms -{ +#if DOTNET_CORE +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; +using System.Diagnostics; + +namespace MoonSharp.Interpreter.Platforms +{ /// /// Class providing the IPlatformAccessor interface for .NET Core builds /// public class DotNetCorePlatformAccessor : PlatformAccessorBase - { + { /// /// Converts a Lua string access mode to a FileAccess enum /// @@ -32,8 +32,8 @@ namespace MoonSharp.Interpreter.Platforms return FileAccess.ReadWrite; else return FileAccess.ReadWrite; - } - + } + /// /// Converts a Lua string access mode to a ParseFileMode enum /// @@ -53,9 +53,9 @@ namespace MoonSharp.Interpreter.Platforms return FileMode.Truncate; else return FileMode.Append; - } - - + } + + /// /// A function used to open files in the 'io' module. /// Can have an invalid implementation if 'io' module is filtered out. @@ -69,8 +69,8 @@ namespace MoonSharp.Interpreter.Platforms public override Stream IO_OpenFile(Script script, string filename, Encoding encoding, string mode) { return new FileStream(filename, ParseFileMode(mode), ParseFileAccess(mode), FileShare.ReadWrite | FileShare.Delete); - } - + } + /// /// Gets an environment variable. Must be implemented, but an implementation is allowed /// to always return null if a more meaningful implementation cannot be achieved or is @@ -83,8 +83,8 @@ namespace MoonSharp.Interpreter.Platforms public override string GetEnvironmentVariable(string envvarname) { return Environment.GetEnvironmentVariable(envvarname); - } - + } + /// /// Gets a standard stream (stdin, stdout, stderr). /// @@ -104,8 +104,8 @@ namespace MoonSharp.Interpreter.Platforms default: throw new ArgumentException("type"); } - } - + } + /// /// Default handler for 'print' calls. Can be customized in ScriptOptions /// @@ -113,9 +113,9 @@ namespace MoonSharp.Interpreter.Platforms public override void DefaultPrint(string content) { Console.WriteLine(content); - } - - + } + + /// /// Gets a temporary filename. Used in 'io' and 'os' modules. /// Can have an invalid implementation if 'io' and 'os' modules are filtered out. @@ -124,8 +124,8 @@ namespace MoonSharp.Interpreter.Platforms public override string IO_OS_GetTempFilename() { return Path.GetTempFileName(); - } - + } + /// /// Exits the process, returning the specified exit code. /// Can have an invalid implementation if the 'os' module is filtered out. @@ -134,8 +134,8 @@ namespace MoonSharp.Interpreter.Platforms public override void OS_ExitFast(int exitCode) { Environment.Exit(exitCode); - } - + } + /// /// Checks if a file exists. Used by the 'os' module. /// Can have an invalid implementation if the 'os' module is filtered out. @@ -147,8 +147,8 @@ namespace MoonSharp.Interpreter.Platforms public override bool OS_FileExists(string file) { return File.Exists(file); - } - + } + /// /// Deletes the specified file. Used by the 'os' module. /// Can have an invalid implementation if the 'os' module is filtered out. @@ -157,8 +157,8 @@ namespace MoonSharp.Interpreter.Platforms public override void OS_FileDelete(string file) { File.Delete(file); - } - + } + /// /// Moves the specified file. Used by the 'os' module. /// Can have an invalid implementation if the 'os' module is filtered out. @@ -166,12 +166,12 @@ namespace MoonSharp.Interpreter.Platforms /// The source. /// The DST. public override void OS_FileMove(string src, string dst) - { + { #if (!PCL) && ((!UNITY_5) || UNITY_STANDALONE) - File.Move(src, dst); + File.Move(src, dst); #endif - } - + } + /// /// Executes the specified command line, returning the child process exit code and blocking in the meantime. /// Can have an invalid implementation if the 'os' module is filtered out. @@ -179,18 +179,18 @@ namespace MoonSharp.Interpreter.Platforms /// The cmdline. /// public override int OS_Execute(string cmdline) - { - // This is windows only! - throw new NotSupportedException("Not supported on .NET core"); - + { + // This is windows only! + throw new NotSupportedException("Not supported on .NET core"); + //ProcessStartInfo psi = new ProcessStartInfo("cmd.exe", string.Format("/C {0}", cmdline)); //psi.ErrorDialog = false; //Process proc = Process.Start(psi); //proc.WaitForExit(); //return proc.ExitCode; - } - + } + /// /// Filters the CoreModules enumeration to exclude non-supported operations /// @@ -201,8 +201,8 @@ namespace MoonSharp.Interpreter.Platforms public override CoreModules FilterSupportedCoreModules(CoreModules module) { return module; - } - + } + /// /// Gets the platform name prefix /// @@ -212,7 +212,7 @@ namespace MoonSharp.Interpreter.Platforms { return "core"; } - } -} - -#endif + } +} + +#endif diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Platforms/PlatformAccessorBase.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Platforms/PlatformAccessorBase.cs index e32dc687..f09c7cc5 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Platforms/PlatformAccessorBase.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Platforms/PlatformAccessorBase.cs @@ -27,15 +27,15 @@ namespace MoonSharp.Interpreter.Platforms if (PlatformAutoDetector.IsRunningOnUnity) { - if (PlatformAutoDetector.IsUnityNative) - { - suffix = "unity." + GetUnityPlatformName().ToLower() + "." + GetUnityRuntimeName(); + if (PlatformAutoDetector.IsUnityNative) + { + suffix = "unity." + GetUnityPlatformName().ToLower() + "." + GetUnityRuntimeName(); } else - { - if (PlatformAutoDetector.IsRunningOnMono) - suffix = "unity.dll.mono"; - else + { + if (PlatformAutoDetector.IsRunningOnMono) + suffix = "unity.dll.mono"; + else suffix = "unity.dll.unknown"; } } @@ -50,84 +50,84 @@ namespace MoonSharp.Interpreter.Platforms if (PlatformAutoDetector.IsRunningOnClr4) suffix = suffix + ".clr4"; else - suffix = suffix + ".clr2"; - + suffix = suffix + ".clr2"; + #if DOTNET_CORE suffix += ".netcore"; #endif - + if (PlatformAutoDetector.IsRunningOnAOT) suffix = suffix + ".aot"; return GetPlatformNamePrefix() + "." + suffix; - } - - private string GetUnityRuntimeName() - { -#if ENABLE_MONO - return "mono"; -#elif ENABLE_IL2CPP - return "il2cpp"; -#elif ENABLE_DOTNET - return "dotnet"; -#else - return "unknown"; -#endif - } - - private string GetUnityPlatformName() - { -#if UNITY_STANDALONE_OSX - return "OSX"; -#elif UNITY_STANDALONE_WIN - return "WIN"; -#elif UNITY_STANDALONE_LINUX - return "LINUX"; -#elif UNITY_STANDALONE - return "STANDALONE"; -#elif UNITY_WII - return "WII"; -#elif UNITY_IOS - return "IOS"; -#elif UNITY_IPHONE - return "IPHONE"; -#elif UNITY_ANDROID - return "ANDROID"; -#elif UNITY_PS3 - return "PS3"; -#elif UNITY_PS4 - return "PS4"; -#elif UNITY_SAMSUNGTV - return "SAMSUNGTV"; -#elif UNITY_XBOX360 - return "XBOX360"; -#elif UNITY_XBOXONE - return "XBOXONE"; -#elif UNITY_TIZEN - return "TIZEN"; -#elif UNITY_TVOS - return "TVOS"; -#elif UNITY_WP_8_1 - return "WP_8_1"; -#elif UNITY_WSA_10_0 - return "WSA_10_0"; -#elif UNITY_WSA_8_1 - return "WSA_8_1"; -#elif UNITY_WSA - return "WSA"; -#elif UNITY_WINRT_10_0 - return "WINRT_10_0"; -#elif UNITY_WINRT_8_1 - return "WINRT_8_1"; -#elif UNITY_WINRT - return "WINRT"; -#elif UNITY_WEBGL - return "WEBGL"; -#else - return "UNKNOWNHW"; -#endif - } - + } + + private string GetUnityRuntimeName() + { +#if ENABLE_MONO + return "mono"; +#elif ENABLE_IL2CPP + return "il2cpp"; +#elif ENABLE_DOTNET + return "dotnet"; +#else + return "unknown"; +#endif + } + + private string GetUnityPlatformName() + { +#if UNITY_STANDALONE_OSX + return "OSX"; +#elif UNITY_STANDALONE_WIN + return "WIN"; +#elif UNITY_STANDALONE_LINUX + return "LINUX"; +#elif UNITY_STANDALONE + return "STANDALONE"; +#elif UNITY_WII + return "WII"; +#elif UNITY_IOS + return "IOS"; +#elif UNITY_IPHONE + return "IPHONE"; +#elif UNITY_ANDROID + return "ANDROID"; +#elif UNITY_PS3 + return "PS3"; +#elif UNITY_PS4 + return "PS4"; +#elif UNITY_SAMSUNGTV + return "SAMSUNGTV"; +#elif UNITY_XBOX360 + return "XBOX360"; +#elif UNITY_XBOXONE + return "XBOXONE"; +#elif UNITY_TIZEN + return "TIZEN"; +#elif UNITY_TVOS + return "TVOS"; +#elif UNITY_WP_8_1 + return "WP_8_1"; +#elif UNITY_WSA_10_0 + return "WSA_10_0"; +#elif UNITY_WSA_8_1 + return "WSA_8_1"; +#elif UNITY_WSA + return "WSA"; +#elif UNITY_WINRT_10_0 + return "WINRT_10_0"; +#elif UNITY_WINRT_8_1 + return "WINRT_8_1"; +#elif UNITY_WINRT + return "WINRT"; +#elif UNITY_WEBGL + return "WEBGL"; +#else + return "UNKNOWNHW"; +#endif + } + /// /// Default handler for 'print' calls. Can be customized in ScriptOptions /// diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Platforms/PlatformAutoDetector.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Platforms/PlatformAutoDetector.cs index b9bcc641..b1765517 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Platforms/PlatformAutoDetector.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Platforms/PlatformAutoDetector.cs @@ -29,17 +29,17 @@ namespace MoonSharp.Interpreter.Platforms /// /// Gets a value indicating whether this instance has been built as a Portable Class Library /// - public static bool IsPortableFramework { get; private set; } - /// - /// Gets a value indicating whether this instance has been compiled natively in Unity (as opposite to importing a DLL). - /// - public static bool IsUnityNative { get; private set; } - /// - /// Gets a value indicating whether this instance has been compiled natively in Unity AND is using IL2CPP - /// - public static bool IsUnityIL2CPP { get; private set; } - - + public static bool IsPortableFramework { get; private set; } + /// + /// Gets a value indicating whether this instance has been compiled natively in Unity (as opposite to importing a DLL). + /// + public static bool IsUnityNative { get; private set; } + /// + /// Gets a value indicating whether this instance has been compiled natively in Unity AND is using IL2CPP + /// + public static bool IsUnityIL2CPP { get; private set; } + + /// /// Gets a value indicating whether this instance is running a system using Ahead-Of-Time compilation /// and not supporting JIT. @@ -48,11 +48,11 @@ namespace MoonSharp.Interpreter.Platforms { // We do a lazy eval here, so we can wire out this code by not calling it, if necessary.. get - { + { #if UNITY_WEBGL || UNITY_IOS || UNITY_TVOS || ENABLE_IL2CPP return true; #else - + if (!m_IsRunningOnAOT.HasValue) { try @@ -76,7 +76,7 @@ namespace MoonSharp.Interpreter.Platforms private static void AutoDetectPlatformFlags() { if (m_AutoDetectionsDone) - return; + return; #if PCL IsPortableFramework = true; #if ENABLE_DOTNET @@ -95,10 +95,10 @@ namespace MoonSharp.Interpreter.Platforms IsRunningOnUnity = AppDomain.CurrentDomain .GetAssemblies() .SelectMany(a => a.SafeGetTypes()) - .Any(t => t.FullName.StartsWith("UnityEngine.")); + .Any(t => t.FullName.StartsWith("UnityEngine.")); #endif #endif - + IsRunningOnMono = (Type.GetType("Mono.Runtime") != null); IsRunningOnClr4 = (Type.GetType("System.Lazy`1") != null); @@ -110,36 +110,36 @@ namespace MoonSharp.Interpreter.Platforms internal static IPlatformAccessor GetDefaultPlatform() { - AutoDetectPlatformFlags(); - + AutoDetectPlatformFlags(); + #if PCL || ENABLE_DOTNET return new LimitedPlatformAccessor(); #else if (IsRunningOnUnity) - return new LimitedPlatformAccessor(); - + return new LimitedPlatformAccessor(); + #if DOTNET_CORE return new DotNetCorePlatformAccessor(); #else - return new StandardPlatformAccessor(); + return new StandardPlatformAccessor(); #endif #endif } internal static IScriptLoader GetDefaultScriptLoader() { - AutoDetectPlatformFlags(); - + AutoDetectPlatformFlags(); + if (IsRunningOnUnity) - return new UnityAssetsScriptLoader(); - else - { -#if (DOTNET_CORE) - return new FileSystemScriptLoader(); + return new UnityAssetsScriptLoader(); + else + { +#if (DOTNET_CORE) + return new FileSystemScriptLoader(); #elif (PCL || ENABLE_DOTNET || NETFX_CORE) return new InvalidScriptLoader("Portable Framework"); #else - return new FileSystemScriptLoader(); + return new FileSystemScriptLoader(); #endif } } diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Platforms/StandardPlatformAccessor.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Platforms/StandardPlatformAccessor.cs index 14714bfa..fae7c2e1 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Platforms/StandardPlatformAccessor.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Platforms/StandardPlatformAccessor.cs @@ -1,76 +1,76 @@ #if (PCL) || (UNITY_5) || NETFX_CORE // Dummy implementation for PCL and Unity targets using System; -using System.IO; -using System.Text; - +using System.IO; +using System.Text; + namespace MoonSharp.Interpreter.Platforms -{ +{ /// /// Class providing the IPlatformAccessor interface for standard full-feaured implementations. /// - public class StandardPlatformAccessor : PlatformAccessorBase - { - public override void DefaultPrint(string content) - { - throw new NotImplementedException(); - } - - public override CoreModules FilterSupportedCoreModules(CoreModules module) - { - throw new NotImplementedException(); - } - - public override string GetEnvironmentVariable(string envvarname) - { - throw new NotImplementedException(); - } - - public override string GetPlatformNamePrefix() - { - throw new NotImplementedException(); - } - - public override Stream IO_GetStandardStream(StandardFileType type) - { - throw new NotImplementedException(); - } - - public override Stream IO_OpenFile(Script script, string filename, Encoding encoding, string mode) - { - throw new NotImplementedException(); - } - - public override string IO_OS_GetTempFilename() - { - throw new NotImplementedException(); - } - - public override int OS_Execute(string cmdline) - { - throw new NotImplementedException(); - } - - public override void OS_ExitFast(int exitCode) - { - throw new NotImplementedException(); - } - - public override void OS_FileDelete(string file) - { - throw new NotImplementedException(); - } - - public override bool OS_FileExists(string file) - { - throw new NotImplementedException(); - } - - public override void OS_FileMove(string src, string dst) - { - throw new NotImplementedException(); - } - } + public class StandardPlatformAccessor : PlatformAccessorBase + { + public override void DefaultPrint(string content) + { + throw new NotImplementedException(); + } + + public override CoreModules FilterSupportedCoreModules(CoreModules module) + { + throw new NotImplementedException(); + } + + public override string GetEnvironmentVariable(string envvarname) + { + throw new NotImplementedException(); + } + + public override string GetPlatformNamePrefix() + { + throw new NotImplementedException(); + } + + public override Stream IO_GetStandardStream(StandardFileType type) + { + throw new NotImplementedException(); + } + + public override Stream IO_OpenFile(Script script, string filename, Encoding encoding, string mode) + { + throw new NotImplementedException(); + } + + public override string IO_OS_GetTempFilename() + { + throw new NotImplementedException(); + } + + public override int OS_Execute(string cmdline) + { + throw new NotImplementedException(); + } + + public override void OS_ExitFast(int exitCode) + { + throw new NotImplementedException(); + } + + public override void OS_FileDelete(string file) + { + throw new NotImplementedException(); + } + + public override bool OS_FileExists(string file) + { + throw new NotImplementedException(); + } + + public override void OS_FileMove(string src, string dst) + { + throw new NotImplementedException(); + } + } } #else using System; @@ -238,9 +238,9 @@ namespace MoonSharp.Interpreter.Platforms /// The source. /// The DST. public override void OS_FileMove(string src, string dst) - { + { #if (!PCL) && ((!UNITY_5) || UNITY_STANDALONE) - File.Move(src, dst); + File.Move(src, dst); #endif } diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Script.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Script.cs index ba3ad023..6e3bb11a 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Script.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Script.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; +using System.Text; using MoonSharp.Interpreter.CoreLib; using MoonSharp.Interpreter.Debugging; using MoonSharp.Interpreter.Diagnostics; @@ -725,16 +725,16 @@ namespace MoonSharp.Interpreter { get; private set; - } - - /// - /// Gets a banner string with copyright info, link to website, version, etc. - /// - public static string GetBanner(string subproduct = null) - { - subproduct = (subproduct != null) ? (subproduct + " ") : ""; - - StringBuilder sb = new StringBuilder(); + } + + /// + /// Gets a banner string with copyright info, link to website, version, etc. + /// + public static string GetBanner(string subproduct = null) + { + subproduct = (subproduct != null) ? (subproduct + " ") : ""; + + StringBuilder sb = new StringBuilder(); sb.AppendLine(string.Format("MoonSharp {0}{1} [{2}]", subproduct, Script.VERSION, Script.GlobalOptions.Platform.GetPlatformName())); sb.AppendLine("Copyright (C) 2014-2016 Marco Mastropaolo"); sb.AppendLine("http://www.moonsharp.org"); diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Serialization/ObjectValueConverter.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Serialization/ObjectValueConverter.cs index 868b349e..62263403 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Serialization/ObjectValueConverter.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Serialization/ObjectValueConverter.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; -using MoonSharp.Interpreter.Compatibility; +using MoonSharp.Interpreter.Compatibility; using MoonSharp.Interpreter.Interop.Converters; namespace MoonSharp.Interpreter.Serialization diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Tree/Lexer/LexerUtils.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Tree/Lexer/LexerUtils.cs index 979b53b5..ea7e18fa 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Tree/Lexer/LexerUtils.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Tree/Lexer/LexerUtils.cs @@ -2,8 +2,8 @@ using System.Globalization; using System.Linq; using System.Text; -using MoonSharp.Interpreter.Compatibility; - +using MoonSharp.Interpreter.Compatibility; + namespace MoonSharp.Interpreter.Tree { internal static class LexerUtils @@ -283,7 +283,7 @@ namespace MoonSharp.Interpreter.Tree } private static string ConvertUtf32ToChar(int i) - { + { #if PCL || ENABLE_DOTNET return ((char)i).ToString(); #else diff --git a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Tree/Statements/FunctionCallStatement.cs b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Tree/Statements/FunctionCallStatement.cs index ac743462..c48f5bee 100755 --- a/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Tree/Statements/FunctionCallStatement.cs +++ b/Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Tree/Statements/FunctionCallStatement.cs @@ -1,4 +1,4 @@ -using System; +using System; using MoonSharp.Interpreter.Execution; using MoonSharp.Interpreter.Execution.VM; using MoonSharp.Interpreter.Tree.Expressions; @@ -24,11 +24,11 @@ namespace MoonSharp.Interpreter.Tree.Statements m_FunctionCallExpression.Compile(bc); RemoveBreakpointStop(bc.Emit_Pop()); } - } - - private void RemoveBreakpointStop(Instruction instruction) - { - instruction.SourceCodeRef = null; - } + } + + private void RemoveBreakpointStop(Instruction instruction) + { + instruction.SourceCodeRef = null; + } } }