Browse Source

Converted MoonSharp line endings to OSX for consistency with rest of project.

master
Christopher 8 years ago
parent
commit
aeda0dedec
  1. 10
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/DebuggerLogic/IAsyncDebuggerClient.cs
  2. 66
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/DebuggerLogic/MoonSharpDebugSession.cs
  3. 6
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/DebuggerLogic/VariableInspector.cs
  4. 796
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/MoonSharpVsCodeDebugServer.cs
  5. 50
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/SDK/DebugSession.cs
  6. 50
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/SDK/Protocol.cs
  7. 58
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/SDK/Utilities.cs
  8. 16
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/AsyncExtensions.cs
  9. 6
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Attributes.cs
  10. 32
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Framework.cs
  11. 150
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/Base/FrameworkBase.cs
  12. 230
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/Base/FrameworkClrBase.cs
  13. 152
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/Base/FrameworkReflectionBase.cs
  14. 62
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/FrameworkCLR.cs
  15. 262
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/FrameworkCore.cs
  16. 56
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/FrameworkPCL.cs
  17. 318
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/FrameworkWin8.cs
  18. 2
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/BasicModule.cs
  19. 4
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/IO/FileUserDataBase.cs
  20. 6
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/IoModule.cs
  21. 4
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/LoadModule.cs
  22. 4
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/OsTimeModule.cs
  23. 6
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/DataTypes/CallbackFunction.cs
  24. 20
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/DataTypes/UserData.cs
  25. 8
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/DynamicExpressionException.cs
  26. 4
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/InternalErrorException.cs
  27. 4
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/InterpreterException.cs
  28. 4
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/ScriptRuntimeException.cs
  29. 2
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/SyntaxErrorException.cs
  30. 8
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Execution/VM/ByteCode.cs
  31. 14
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Execution/VM/Processor/Processor.cs
  32. 12
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/IO/UndisposableStream.cs
  33. 2
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/BasicDescriptors/DispatchingUserDataDescriptor.cs
  34. 4
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/BasicDescriptors/ParameterDescriptor.cs
  35. 12
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/Converters/ClrToScriptConversions.cs
  36. 4
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/Converters/ScriptToClrConversions.cs
  37. 4
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/Converters/TableConversions.cs
  38. 16
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/DescriptorHelpers.cs
  39. 1088
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/LuaStateInterop/Tools.cs
  40. 4
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/PropertyTableAssigner.cs
  41. 2
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/AutoDescribingUserDataDescriptor.cs
  42. 4
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/CompositeUserDataDescriptor.cs
  43. 2
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/MemberDescriptors/FunctionMemberDescriptorBase.cs
  44. 4
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ProxyUserDataDescriptor.cs
  45. 4
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/EventMemberDescriptor.cs
  46. 4
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/FieldMemberDescriptor.cs
  47. 2
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/MethodMemberDescriptor.cs
  48. 6
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/OverloadedMethodMemberDescriptor.cs
  49. 2
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/PropertyMemberDescriptor.cs
  50. 2
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/ValueTypeDefaultCtorMemberDescriptor.cs
  51. 2
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/StandardEnumUserDataDescriptor.cs
  52. 8
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/StandardGenericsUserDataDescriptor.cs
  53. 28
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/StandardUserDataDescriptor.cs
  54. 16
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/UserDataRegistries/ExtensionMethodsRegistry.cs
  55. 192
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/UserDataRegistries/TypeDescriptorRegistry.cs
  56. 18
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Loaders/EmbeddedResourcesScriptLoader.cs
  57. 348
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Loaders/UnityAssetsScriptLoader.cs
  58. 14
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Modules/ModuleRegister.cs
  59. 98
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Platforms/DotNetCorePlatformAccessor.cs
  60. 156
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Platforms/PlatformAccessorBase.cs
  61. 58
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Platforms/PlatformAutoDetector.cs
  62. 136
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Platforms/StandardPlatformAccessor.cs
  63. 22
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Script.cs
  64. 2
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Serialization/ObjectValueConverter.cs
  65. 6
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Tree/Lexer/LexerUtils.cs
  66. 14
      Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Tree/Statements/FunctionCallStatement.cs

10
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/DebuggerLogic/IAsyncDebuggerClient.cs vendored

@ -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

66
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/DebuggerLogic/MoonSharpDebugSession.cs vendored

@ -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

6
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/DebuggerLogic/VariableInspector.cs vendored

@ -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

796
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/MoonSharpVsCodeDebugServer.cs vendored

@ -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
{
/// <summary>
/// Class implementing a debugger allowing attaching from a Visual Studio Code debugging session.
/// </summary>
public class MoonSharpVsCodeDebugServer : IDisposable
{
object m_Lock = new object();
List<AsyncDebugger> m_DebuggerList = new List<AsyncDebugger>();
AsyncDebugger m_Current = null;
ManualResetEvent m_StopEvent = new ManualResetEvent(false);
bool m_Started = false;
int m_Port;
/// <summary>
/// Initializes a new instance of the <see cref="MoonSharpVsCodeDebugServer" /> class.
/// </summary>
/// <param name="port">The port on which the debugger listens. It's recommended to use 41912.</param>
public MoonSharpVsCodeDebugServer(int port = 41912)
{
m_Port = port;
}
/// <summary>
/// Initializes a new instance of the <see cref="MoonSharpVsCodeDebugServer" /> class with a default script.
/// Note that for this specific script, it will NOT attach the debugger to the script.
/// </summary>
/// <param name="script">The script object to debug.</param>
/// <param name="port">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.</param>
/// <param name="sourceFinder">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.</param>
[Obsolete("Use the constructor taking only a port, and the 'Attach' method instead.")]
public MoonSharpVsCodeDebugServer(Script script, int port, Func<SourceCode, string> sourceFinder = null)
{
m_Port = port;
m_Current = new AsyncDebugger(script, sourceFinder ?? (s => s.Name), "Default script");
m_DebuggerList.Add(m_Current);
}
/// <summary>
/// Attaches the specified script to the debugger
/// </summary>
/// <param name="script">The script.</param>
/// <param name="name">The name of the script.</param>
/// <param name="sourceFinder">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.</param>
/// <exception cref="ArgumentException">If the script has already been attached to this debugger.</exception>
public void AttachToScript(Script script, string name, Func<SourceCode, string> 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;
}
}
/// <summary>
/// Gets a list of the attached debuggers by id and name
/// </summary>
public IEnumerable<KeyValuePair<int, string>> GetAttachedDebuggersByIdAndName()
{
lock (m_Lock)
return m_DebuggerList
.OrderBy(d => d.Id)
.Select(d => new KeyValuePair<int, string>(d.Id, d.Name))
.ToArray();
}
/// <summary>
/// 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.
/// </summary>
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;
}
}
}
/// <summary>
/// Gets or sets the current script. New vscode connections will attach to this script. Changing the current script does NOT disconnect
/// connected clients.
/// </summary>
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;
}
}
}
/// <summary>
/// Detaches the specified script. The debugger attached to that script will get disconnected.
/// </summary>
/// <param name="script">The script.</param>
/// <exception cref="ArgumentException">Thrown if the script cannot be found.</exception>
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;
}
}
}
/// <summary>
/// Gets or sets a delegate which will be called when logging messages are generated
/// </summary>
public Action<string> Logger { get; set; }
/// <summary>
/// Gets the debugger object. Obsolete, use the new interface using the Attach method instead.
/// </summary>
[Obsolete("Use the Attach method instead.")]
public IDebugger GetDebugger()
{
lock(m_Lock)
return m_Current;
}
/// <summary>
/// Stops listening
/// </summary>
/// <exception cref="InvalidOperationException">Cannot stop; server was not started.</exception>
public void Dispose()
{
m_StopEvent.Set();
}
/// <summary>
/// Starts listening on the localhost for incoming connections.
/// </summary>
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<string> 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<SourceCode, string> sourceFinder = null)
{
}
public void AttachToScript(Script script, string name, Func<SourceCode, string> sourceFinder = null)
{
}
public IEnumerable<KeyValuePair<int, string>> GetAttachedDebuggersByIdAndName()
{
yield break;
}
public int? CurrentId
{
get { return null; }
set { }
}
public Script Current
{
get { return null; }
set { }
}
/// <summary>
/// Detaches the specified script. The debugger attached to that script will get disconnected.
/// </summary>
/// <param name="script">The script.</param>
/// <exception cref="ArgumentException">Thrown if the script cannot be found.</exception>
public void Detach(Script script)
{
}
public Action<string> 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
{
/// <summary>
/// Class implementing a debugger allowing attaching from a Visual Studio Code debugging session.
/// </summary>
public class MoonSharpVsCodeDebugServer : IDisposable
{
object m_Lock = new object();
List<AsyncDebugger> m_DebuggerList = new List<AsyncDebugger>();
AsyncDebugger m_Current = null;
ManualResetEvent m_StopEvent = new ManualResetEvent(false);
bool m_Started = false;
int m_Port;
/// <summary>
/// Initializes a new instance of the <see cref="MoonSharpVsCodeDebugServer" /> class.
/// </summary>
/// <param name="port">The port on which the debugger listens. It's recommended to use 41912.</param>
public MoonSharpVsCodeDebugServer(int port = 41912)
{
m_Port = port;
}
/// <summary>
/// Initializes a new instance of the <see cref="MoonSharpVsCodeDebugServer" /> class with a default script.
/// Note that for this specific script, it will NOT attach the debugger to the script.
/// </summary>
/// <param name="script">The script object to debug.</param>
/// <param name="port">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.</param>
/// <param name="sourceFinder">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.</param>
[Obsolete("Use the constructor taking only a port, and the 'Attach' method instead.")]
public MoonSharpVsCodeDebugServer(Script script, int port, Func<SourceCode, string> sourceFinder = null)
{
m_Port = port;
m_Current = new AsyncDebugger(script, sourceFinder ?? (s => s.Name), "Default script");
m_DebuggerList.Add(m_Current);
}
/// <summary>
/// Attaches the specified script to the debugger
/// </summary>
/// <param name="script">The script.</param>
/// <param name="name">The name of the script.</param>
/// <param name="sourceFinder">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.</param>
/// <exception cref="ArgumentException">If the script has already been attached to this debugger.</exception>
public void AttachToScript(Script script, string name, Func<SourceCode, string> 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;
}
}
/// <summary>
/// Gets a list of the attached debuggers by id and name
/// </summary>
public IEnumerable<KeyValuePair<int, string>> GetAttachedDebuggersByIdAndName()
{
lock (m_Lock)
return m_DebuggerList
.OrderBy(d => d.Id)
.Select(d => new KeyValuePair<int, string>(d.Id, d.Name))
.ToArray();
}
/// <summary>
/// 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.
/// </summary>
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;
}
}
}
/// <summary>
/// Gets or sets the current script. New vscode connections will attach to this script. Changing the current script does NOT disconnect
/// connected clients.
/// </summary>
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;
}
}
}
/// <summary>
/// Detaches the specified script. The debugger attached to that script will get disconnected.
/// </summary>
/// <param name="script">The script.</param>
/// <exception cref="ArgumentException">Thrown if the script cannot be found.</exception>
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;
}
}
}
/// <summary>
/// Gets or sets a delegate which will be called when logging messages are generated
/// </summary>
public Action<string> Logger { get; set; }
/// <summary>
/// Gets the debugger object. Obsolete, use the new interface using the Attach method instead.
/// </summary>
[Obsolete("Use the Attach method instead.")]
public IDebugger GetDebugger()
{
lock(m_Lock)
return m_Current;
}
/// <summary>
/// Stops listening
/// </summary>
/// <exception cref="InvalidOperationException">Cannot stop; server was not started.</exception>
public void Dispose()
{
m_StopEvent.Set();
}
/// <summary>
/// Starts listening on the localhost for incoming connections.
/// </summary>
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<string> 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<SourceCode, string> sourceFinder = null)
{
}
public void AttachToScript(Script script, string name, Func<SourceCode, string> sourceFinder = null)
{
}
public IEnumerable<KeyValuePair<int, string>> GetAttachedDebuggersByIdAndName()
{
yield break;
}
public int? CurrentId
{
get { return null; }
set { }
}
public Script Current
{
get { return null; }
set { }
}
/// <summary>
/// Detaches the specified script. The debugger attached to that script will get disconnected.
/// </summary>
/// <param name="script">The script.</param>
/// <exception cref="ArgumentException">Thrown if the script cannot be found.</exception>
public void Detach(Script script)
{
}
public Action<string> Logger { get; set; }
[Obsolete("Use the Attach method instead.")]
public IDebugger GetDebugger()
{
return null;
}
public void Dispose()
{
}
public MoonSharpVsCodeDebugServer Start()
{
return this;
}
}
}
#endif

50
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/SDK/DebugSession.cs vendored

@ -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

50
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/SDK/Protocol.cs vendored

@ -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

58
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Debugger/SDK/Utilities.cs vendored

@ -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

16
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/AsyncExtensions.cs vendored

@ -69,8 +69,8 @@ namespace MoonSharp.Interpreter
public static Task<DynValue> CallAsync(this Closure function, params DynValue[] args)
{
return ExecAsync(() => function.Call(args));
}
}
/// <summary>
/// Asynchronously loads and executes a string containing a Lua/MoonSharp script.
///
@ -86,9 +86,9 @@ namespace MoonSharp.Interpreter
public static Task<DynValue> DoStringAsync(this Script script, string code, Table globalContext = null, string codeFriendlyName = null)
{
return ExecAsync(() => script.DoString(code, globalContext, codeFriendlyName));
}
}
/// <summary>
/// Asynchronously loads and executes a stream containing a Lua/MoonSharp script.
///
@ -104,9 +104,9 @@ namespace MoonSharp.Interpreter
public static Task<DynValue> DoStreamAsync(this Script script, Stream stream, Table globalContext = null, string codeFriendlyName = null)
{
return ExecAsync(() => script.DoStream(stream, globalContext, codeFriendlyName));
}
}
/// <summary>
/// Asynchronously loads and executes a file containing a Lua/MoonSharp script.
///

6
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Attributes.cs vendored

@ -16,6 +16,6 @@ namespace System.Reflection
public GuidAttribute(string dummy)
{ }
}
}
#endif
}
#endif

32
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Framework.cs vendored

@ -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; } }
}
}

150
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/Base/FrameworkBase.cs vendored

@ -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);
}
}

230
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/Base/FrameworkClrBase.cs vendored

@ -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

152
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/Base/FrameworkReflectionBase.cs vendored

@ -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<Attribute>().ToArray();
}
public override Attribute[] GetCustomAttributes(Type t, Type at, bool inherit)
{
return GetTypeInfoFromType(t).GetCustomAttributes(at, inherit).OfType<Attribute>().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<Attribute>().ToArray();
}
public override Attribute[] GetCustomAttributes(Type t, Type at, bool inherit)
{
return GetTypeInfoFromType(t).GetCustomAttributes(at, inherit).OfType<Attribute>().ToArray();
}
}
}

62
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/FrameworkCLR.cs vendored

@ -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

262
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/FrameworkCore.cs vendored

@ -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<T>(IEnumerable<T> 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<T>(IEnumerable<T> 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

56
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/FrameworkPCL.cs vendored

@ -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

318
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Compatibility/Frameworks/FrameworkWin8.cs vendored

@ -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<T>(IEnumerable<T> 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<T>(IEnumerable<T> 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

2
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/BasicModule.cs vendored

@ -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

4
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/IO/FileUserDataBase.cs vendored

@ -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
{
/// <summary>

6
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/IoModule.cs vendored

@ -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;

4
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/LoadModule.cs vendored

@ -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

4
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/CoreLib/OsTimeModule.cs vendored

@ -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);

6
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/DataTypes/CallbackFunction.cs vendored

@ -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

20
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/DataTypes/UserData.cs vendored

@ -141,16 +141,16 @@ namespace MoonSharp.Interpreter
/// <param name="asm">The assembly.</param>
/// <param name="includeExtensionTypes">if set to <c>true</c> extension types are registered to the appropriate registry.</param>
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);
}

8
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/DynamicExpressionException.cs vendored

@ -1,13 +1,13 @@

using System;
using System;
namespace MoonSharp.Interpreter
{
{
/// <summary>
/// Exception thrown when a dynamic expression is invalid
/// </summary>
#if !(PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET)) || NETFX_CORE)
[Serializable]
[Serializable]
#endif
public class DynamicExpressionException : ScriptRuntimeException
{

4
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/InternalErrorException.cs vendored

@ -1,12 +1,12 @@
using System;
namespace MoonSharp.Interpreter
{
{
/// <summary>
/// Exception thrown when an inconsistent state is reached in the interpreter
/// </summary>
#if !(PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET)) || NETFX_CORE)
[Serializable]
[Serializable]
#endif
public class InternalErrorException : InterpreterException
{

4
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/InterpreterException.cs vendored

@ -3,12 +3,12 @@ using System.Collections.Generic;
using MoonSharp.Interpreter.Debugging;
namespace MoonSharp.Interpreter
{
{
/// <summary>
/// Base type of all exceptions thrown in MoonSharp
/// </summary>
#if !(PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET)) || NETFX_CORE)
[Serializable]
[Serializable]
#endif
public class InterpreterException : Exception
{

4
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/ScriptRuntimeException.cs vendored

@ -3,13 +3,13 @@ using MoonSharp.Interpreter.Interop;
using MoonSharp.Interpreter.Interop.BasicDescriptors;
namespace MoonSharp.Interpreter
{
{
/// <summary>
/// Exception for all runtime errors. In addition to constructors, it offers a lot of static methods
/// generating more "standard" Lua errors.
/// </summary>
#if !(PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET)) || NETFX_CORE)
[Serializable]
[Serializable]
#endif
public class ScriptRuntimeException : InterpreterException
{

2
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Errors/SyntaxErrorException.cs vendored

@ -8,7 +8,7 @@ namespace MoonSharp.Interpreter
/// Exception for all parsing/lexing errors.
/// </summary>
#if !(PCL || ((!UNITY_EDITOR) && (ENABLE_DOTNET)) || NETFX_CORE)
[Serializable]
[Serializable]
#endif
public class SyntaxErrorException : InterpreterException
{

8
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Execution/VM/ByteCode.cs vendored

@ -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

14
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Execution/VM/Processor/Processor.cs vendored

@ -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()

12
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/IO/UndisposableStream.cs vendored

@ -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
{

2
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/BasicDescriptors/DispatchingUserDataDescriptor.cs vendored

@ -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

4
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/BasicDescriptors/ParameterDescriptor.cs vendored

@ -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
{
/// <summary>

12
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/Converters/ClrToScriptConversions.cs vendored

@ -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<ScriptExecutionContext, CallbackArguments, DynValue>)d);
}

4
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/Converters/ScriptToClrConversions.cs vendored

@ -1,6 +1,6 @@
using System;
using MoonSharp.Interpreter.Compatibility;
using MoonSharp.Interpreter.Compatibility;
namespace MoonSharp.Interpreter.Interop.Converters
{
internal static class ScriptToClrConversions

4
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/Converters/TableConversions.cs vendored

@ -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

16
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/DescriptorHelpers.cs vendored

@ -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
{
/// <summary>
@ -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);
}
/// <summary>
/// Gets the visibility of the type as a string
/// </summary>
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)

1088
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/LuaStateInterop/Tools.cs vendored

File diff suppressed because it is too large Load Diff

4
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/PropertyTableAssigner.cs vendored

@ -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
{
/// <summary>

2
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/AutoDescribingUserDataDescriptor.cs vendored

@ -1,5 +1,5 @@
using System;
using MoonSharp.Interpreter.Compatibility;
using MoonSharp.Interpreter.Compatibility;
using MoonSharp.Interpreter.Interop;
namespace MoonSharp.Interpreter

4
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/CompositeUserDataDescriptor.cs vendored

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using MoonSharp.Interpreter.Compatibility;
using MoonSharp.Interpreter.Compatibility;
namespace MoonSharp.Interpreter.Interop
{
/// <summary>

2
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/MemberDescriptors/FunctionMemberDescriptorBase.cs vendored

@ -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;

4
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ProxyUserDataDescriptor.cs vendored

@ -1,6 +1,6 @@
using System;
using MoonSharp.Interpreter.Compatibility;
using MoonSharp.Interpreter.Compatibility;
namespace MoonSharp.Interpreter.Interop
{
/// <summary>

4
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/EventMemberDescriptor.cs vendored

@ -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

4
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/FieldMemberDescriptor.cs vendored

@ -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)
{

2
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/MethodMemberDescriptor.cs vendored

@ -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;

6
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/OverloadedMethodMemberDescriptor.cs vendored

@ -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;

2
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/PropertyMemberDescriptor.cs vendored

@ -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;

2
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/ReflectionMemberDescriptors/ValueTypeDefaultCtorMemberDescriptor.cs vendored

@ -1,5 +1,5 @@
using System;
using MoonSharp.Interpreter.Compatibility;
using MoonSharp.Interpreter.Compatibility;
using MoonSharp.Interpreter.Interop.BasicDescriptors;
using MoonSharp.Interpreter.Interop.Converters;

2
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/StandardEnumUserDataDescriptor.cs vendored

@ -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

8
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/StandardGenericsUserDataDescriptor.cs vendored

@ -1,6 +1,6 @@
using System;
using MoonSharp.Interpreter.Compatibility;
using MoonSharp.Interpreter.Compatibility;
namespace MoonSharp.Interpreter.Interop
{
/// <summary>
@ -64,8 +64,8 @@ namespace MoonSharp.Interpreter.Interop
public bool IsTypeCompatible(Type type, object obj)
{
return Framework.Do.IsInstanceOfType(type, obj);
}
}
/// <inheritdoc/>
public IUserDataDescriptor Generate(Type type)
{

28
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/StandardDescriptors/StandardUserDataDescriptor.cs vendored

@ -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));
}

16
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/UserDataRegistries/ExtensionMethodsRegistry.cs vendored

@ -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();
}
/// <summary>
/// Gets all the extension methods which can match a given name
/// </summary>

192
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Interop/UserDataRegistries/TypeDescriptorRegistry.cs vendored

@ -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
{
{
/// <summary>
/// Registry of all type descriptors. Use UserData statics to access these.
/// </summary>
@ -18,8 +18,8 @@ namespace MoonSharp.Interpreter.Interop.UserDataRegistries
private static object s_Lock = new object();
private static Dictionary<Type, IUserDataDescriptor> s_TypeRegistry = new Dictionary<Type, IUserDataDescriptor>();
private static Dictionary<Type, IUserDataDescriptor> s_TypeRegistryHistory = new Dictionary<Type, IUserDataDescriptor>();
private static InteropAccessMode s_DefaultAccessMode;
private static InteropAccessMode s_DefaultAccessMode;
/// <summary>
/// Registers all types marked with a MoonSharpUserDataAttribute that ar contained in an assembly.
/// </summary>
@ -27,14 +27,14 @@ namespace MoonSharp.Interpreter.Interop.UserDataRegistries
/// <param name="includeExtensionTypes">if set to <c>true</c> extension types are registered to the appropriate registry.</param>
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);
}
}
}
/// <summary>
/// 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);
}
}
/// <summary>
/// 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]);
}
}
}
}
/// <summary>
/// Gets or sets the default access mode to be used in the whole application
/// </summary>
@ -114,8 +114,8 @@ namespace MoonSharp.Interpreter.Interop.UserDataRegistries
s_DefaultAccessMode = value;
}
}
}
/// <summary>
/// Registers a proxy type.
/// </summary>
@ -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));
}
}
/// <summary>
/// Registers a type
/// </summary>
@ -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;
}
}
/// <summary>
/// Resolves the default type of the access mode for the given type
/// </summary>
@ -233,10 +233,10 @@ namespace MoonSharp.Interpreter.Interop.UserDataRegistries
accessMode = s_DefaultAccessMode;
return accessMode;
}
}
/// <summary>
/// Gets the best possible type descriptor for a specified CLR type.
/// </summary>
@ -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();
}
/// <summary>
/// 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;
}
}
/// <summary>
/// Gets the list of registered types.
/// </summary>
@ -364,8 +364,8 @@ namespace MoonSharp.Interpreter.Interop.UserDataRegistries
public static IEnumerable<KeyValuePair<Type, IUserDataDescriptor>> RegisteredTypes
{
get { lock (s_Lock) return s_TypeRegistry.ToArray(); }
}
}
/// <summary>
/// Gets the list of registered types, including unregistered types.
/// </summary>
@ -375,9 +375,9 @@ namespace MoonSharp.Interpreter.Interop.UserDataRegistries
public static IEnumerable<KeyValuePair<Type, IUserDataDescriptor>> RegisteredTypesHistory
{
get { lock (s_Lock) return s_TypeRegistryHistory.ToArray(); }
}
}
/// <summary>
/// Gets or sets the registration policy.
/// </summary>

18
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Loaders/EmbeddedResourcesScriptLoader.cs vendored

@ -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
/// </summary>
/// <param name="resourceAssembly">The assembly containing the scripts as embedded resources or null to use the calling assembly.</param>
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;

348
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Loaders/UnityAssetsScriptLoader.cs vendored

@ -1,175 +1,175 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using MoonSharp.Interpreter.Compatibility;
namespace MoonSharp.Interpreter.Loaders
{
/// <summary>
/// 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.
/// </summary>
public class UnityAssetsScriptLoader : ScriptLoaderBase
{
Dictionary<string, string> m_Resources = new Dictionary<string, string>();
/// <summary>
/// The default path where scripts are meant to be stored (if not changed)
/// </summary>
public const string DEFAULT_PATH = "MoonSharp/Scripts";
/// <summary>
/// Initializes a new instance of the <see cref="UnityAssetsScriptLoader"/> class.
/// </summary>
/// <param name="assetsPath">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. </param>
public UnityAssetsScriptLoader(string assetsPath = null)
{
assetsPath = assetsPath ?? DEFAULT_PATH;
#if UNITY_5
LoadResourcesUnityNative(assetsPath);
#else
LoadResourcesWithReflection(assetsPath);
#endif
}
/// <summary>
/// Initializes a new instance of the <see cref="UnityAssetsScriptLoader"/> class.
/// </summary>
/// <param name="scriptToCodeMap">A dictionary mapping filenames to the proper Lua script code.</param>
public UnityAssetsScriptLoader(Dictionary<string, string> 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
{
/// <summary>
/// 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.
/// </summary>
public class UnityAssetsScriptLoader : ScriptLoaderBase
{
Dictionary<string, string> m_Resources = new Dictionary<string, string>();
/// <summary>
/// The default path where scripts are meant to be stored (if not changed)
/// </summary>
public const string DEFAULT_PATH = "MoonSharp/Scripts";
/// <summary>
/// Initializes a new instance of the <see cref="UnityAssetsScriptLoader"/> class.
/// </summary>
/// <param name="assetsPath">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. </param>
public UnityAssetsScriptLoader(string assetsPath = null)
{
assetsPath = assetsPath ?? DEFAULT_PATH;
#if UNITY_5
LoadResourcesUnityNative(assetsPath);
#else
LoadResourcesWithReflection(assetsPath);
#endif
}
/// <summary>
/// Initializes a new instance of the <see cref="UnityAssetsScriptLoader"/> class.
/// </summary>
/// <param name="scriptToCodeMap">A dictionary mapping filenames to the proper Lua script code.</param>
public UnityAssetsScriptLoader(Dictionary<string, string> 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;
}
/// <summary>
/// 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.
/// </summary>
/// <param name="file">The file.</param>
/// <param name="globalContext">The global context.</param>
/// <returns>
/// A string, a byte[] or a Stream.
/// </returns>
/// <exception cref="System.Exception">UnityAssetsScriptLoader.LoadFile : Cannot load + file</exception>
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);
}
}
/// <summary>
/// Checks if a given file exists
/// </summary>
/// <param name="file">The file.</param>
/// <returns></returns>
public override bool ScriptFileExists(string file)
{
file = GetFileName(file);
return m_Resources.ContainsKey(file);
}
/// <summary>
/// Gets the list of loaded scripts filenames (useful for debugging purposes).
/// </summary>
/// <returns></returns>
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;
}
/// <summary>
/// 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.
/// </summary>
/// <param name="file">The file.</param>
/// <param name="globalContext">The global context.</param>
/// <returns>
/// A string, a byte[] or a Stream.
/// </returns>
/// <exception cref="System.Exception">UnityAssetsScriptLoader.LoadFile : Cannot load + file</exception>
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);
}
}
/// <summary>
/// Checks if a given file exists
/// </summary>
/// <param name="file">The file.</param>
/// <returns></returns>
public override bool ScriptFileExists(string file)
{
file = GetFileName(file);
return m_Resources.ContainsKey(file);
}
/// <summary>
/// Gets the list of loaded scripts filenames (useful for debugging purposes).
/// </summary>
/// <returns></returns>
public string[] GetLoadedScripts()
{
return m_Resources.Keys.ToArray();
}
}
}

14
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Modules/ModuleRegister.cs vendored

@ -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<ScriptExecutionContext, CallbackArguments, DynValue>));
Delegate deleg = mi.CreateDelegate(typeof(Func<ScriptExecutionContext, CallbackArguments, DynValue>));
#else
Delegate deleg = Delegate.CreateDelegate(typeof(Func<ScriptExecutionContext, CallbackArguments, DynValue>), mi);
Delegate deleg = Delegate.CreateDelegate(typeof(Func<ScriptExecutionContext, CallbackArguments, DynValue>), mi);
#endif
Func<ScriptExecutionContext, CallbackArguments, DynValue> func =
Func<ScriptExecutionContext, CallbackArguments, DynValue> func =
(Func<ScriptExecutionContext, CallbackArguments, DynValue>)deleg;

98
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Platforms/DotNetCorePlatformAccessor.cs vendored

@ -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
{
/// <summary>
/// Class providing the IPlatformAccessor interface for .NET Core builds
/// </summary>
public class DotNetCorePlatformAccessor : PlatformAccessorBase
{
{
/// <summary>
/// Converts a Lua string access mode to a FileAccess enum
/// </summary>
@ -32,8 +32,8 @@ namespace MoonSharp.Interpreter.Platforms
return FileAccess.ReadWrite;
else
return FileAccess.ReadWrite;
}
}
/// <summary>
/// Converts a Lua string access mode to a ParseFileMode enum
/// </summary>
@ -53,9 +53,9 @@ namespace MoonSharp.Interpreter.Platforms
return FileMode.Truncate;
else
return FileMode.Append;
}
}
/// <summary>
/// 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);
}
}
/// <summary>
/// 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);
}
}
/// <summary>
/// Gets a standard stream (stdin, stdout, stderr).
/// </summary>
@ -104,8 +104,8 @@ namespace MoonSharp.Interpreter.Platforms
default:
throw new ArgumentException("type");
}
}
}
/// <summary>
/// Default handler for 'print' calls. Can be customized in ScriptOptions
/// </summary>
@ -113,9 +113,9 @@ namespace MoonSharp.Interpreter.Platforms
public override void DefaultPrint(string content)
{
Console.WriteLine(content);
}
}
/// <summary>
/// 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();
}
}
/// <summary>
/// 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);
}
}
/// <summary>
/// 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);
}
}
/// <summary>
/// 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);
}
}
/// <summary>
/// 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
/// <param name="src">The source.</param>
/// <param name="dst">The DST.</param>
public override void OS_FileMove(string src, string dst)
{
{
#if (!PCL) && ((!UNITY_5) || UNITY_STANDALONE)
File.Move(src, dst);
File.Move(src, dst);
#endif
}
}
/// <summary>
/// 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
/// <param name="cmdline">The cmdline.</param>
/// <returns></returns>
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;
}
}
/// <summary>
/// Filters the CoreModules enumeration to exclude non-supported operations
/// </summary>
@ -201,8 +201,8 @@ namespace MoonSharp.Interpreter.Platforms
public override CoreModules FilterSupportedCoreModules(CoreModules module)
{
return module;
}
}
/// <summary>
/// Gets the platform name prefix
/// </summary>
@ -212,7 +212,7 @@ namespace MoonSharp.Interpreter.Platforms
{
return "core";
}
}
}
#endif
}
}
#endif

156
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Platforms/PlatformAccessorBase.cs vendored

@ -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
}
/// <summary>
/// Default handler for 'print' calls. Can be customized in ScriptOptions
/// </summary>

58
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Platforms/PlatformAutoDetector.cs vendored

@ -29,17 +29,17 @@ namespace MoonSharp.Interpreter.Platforms
/// <summary>
/// Gets a value indicating whether this instance has been built as a Portable Class Library
/// </summary>
public static bool IsPortableFramework { get; private set; }
/// <summary>
/// Gets a value indicating whether this instance has been compiled natively in Unity (as opposite to importing a DLL).
/// </summary>
public static bool IsUnityNative { get; private set; }
/// <summary>
/// Gets a value indicating whether this instance has been compiled natively in Unity AND is using IL2CPP
/// </summary>
public static bool IsUnityIL2CPP { get; private set; }
public static bool IsPortableFramework { get; private set; }
/// <summary>
/// Gets a value indicating whether this instance has been compiled natively in Unity (as opposite to importing a DLL).
/// </summary>
public static bool IsUnityNative { get; private set; }
/// <summary>
/// Gets a value indicating whether this instance has been compiled natively in Unity AND is using IL2CPP
/// </summary>
public static bool IsUnityIL2CPP { get; private set; }
/// <summary>
/// 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
}
}

136
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Platforms/StandardPlatformAccessor.cs vendored

@ -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
{
{
/// <summary>
/// Class providing the IPlatformAccessor interface for standard full-feaured implementations.
/// </summary>
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
/// <param name="src">The source.</param>
/// <param name="dst">The DST.</param>
public override void OS_FileMove(string src, string dst)
{
{
#if (!PCL) && ((!UNITY_5) || UNITY_STANDALONE)
File.Move(src, dst);
File.Move(src, dst);
#endif
}

22
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Script.cs vendored

@ -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;
}
/// <summary>
/// Gets a banner string with copyright info, link to website, version, etc.
/// </summary>
public static string GetBanner(string subproduct = null)
{
subproduct = (subproduct != null) ? (subproduct + " ") : "";
StringBuilder sb = new StringBuilder();
}
/// <summary>
/// Gets a banner string with copyright info, link to website, version, etc.
/// </summary>
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");

2
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Serialization/ObjectValueConverter.cs vendored

@ -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

6
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Tree/Lexer/LexerUtils.cs vendored

@ -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

14
Assets/Fungus/Thirdparty/FungusLua/Thirdparty/MoonSharp/Interpreter/Tree/Statements/FunctionCallStatement.cs vendored

@ -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;
}
}
}

Loading…
Cancel
Save