Initial Commit
This commit is contained in:
parent
53eb92e9af
commit
270ab7d11f
15341 changed files with 700234 additions and 0 deletions
|
@ -0,0 +1,9 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public enum ActionDirection
|
||||
{
|
||||
Any = 0,
|
||||
Get = 1,
|
||||
Set = 2
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c5795dc78e5854c17819ad00986647fb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,479 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public static class AttributeUtility
|
||||
{
|
||||
private static readonly Dictionary<object, AttributeCache> optimizedCaches = new Dictionary<object, AttributeCache>();
|
||||
|
||||
private class AttributeCache
|
||||
{
|
||||
// Using lists instead of hashsets because:
|
||||
// - Insertion will be faster
|
||||
// - Iteration will be just as fast
|
||||
// - We don't need contains lookups
|
||||
public List<Attribute> inheritedAttributes { get; } = new List<Attribute>();
|
||||
public List<Attribute> definedAttributes { get; } = new List<Attribute>();
|
||||
|
||||
// Important to use Attribute.GetCustomAttributes, because MemberInfo.GetCustomAttributes
|
||||
// ignores the inherited parameter on properties and events
|
||||
|
||||
// However, Attribute.GetCustomAttributes seems to have at least two obscure Mono 2.0 bugs.
|
||||
|
||||
// 1. Basically, when a parameter is optional and is marked as [OptionalAttribute],
|
||||
// the custom attributes array is typed object[] instead of Attribute[], which
|
||||
// makes Mono throw an exception in Attribute.GetCustomAttributes when trying
|
||||
// to cast the array. After some testing, it appears this only happens for
|
||||
// non-inherited calls, and only for parameter infos (although I'm not sure why).
|
||||
// I *believe* the offending line in the Mono source is this one:
|
||||
// https://github.com/mono/mono/blob/mono-2-0/mcs/class/corlib/System/MonoCustomAttrs.cs#L143
|
||||
|
||||
// 2. For some other implementation reason, on iOS, GetCustomAttributes on MemberInfo fails.
|
||||
// https://support.ludiq.io/forums/5-bolt/topics/729-systeminvalidcastexception-in-attributecache-on-ios/
|
||||
|
||||
// As a fallback, we will use the GetCustomAttributes from the type itself,
|
||||
// which doesn't seem to be bugged (ugh). But because this method ignores the
|
||||
// inherited parameter on some occasions, we will warn if the inherited fetch fails.
|
||||
|
||||
// Additionally, some Unity built-in attributes use threaded API methods in their
|
||||
// constructors and will therefore throw an error if GetCustomAttributes is called
|
||||
// from the serialization thread or from a secondary thread. We'll generally fallback
|
||||
// and warn on any exception to make sure not to block anything more than needed.
|
||||
// https://support.ludiq.io/communities/5/topics/2024-/
|
||||
|
||||
public AttributeCache(MemberInfo element)
|
||||
{
|
||||
Ensure.That(nameof(element)).IsNotNull(element);
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
Cache(Attribute.GetCustomAttributes(element, true), inheritedAttributes);
|
||||
}
|
||||
catch (InvalidCastException ex)
|
||||
{
|
||||
Cache(element.GetCustomAttributes(true).Cast<Attribute>().ToArray(), inheritedAttributes);
|
||||
Debug.LogWarning($"Failed to fetch inherited attributes on {element}.\n{ex}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to fetch inherited attributes on {element}.\n{ex}");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
Cache(Attribute.GetCustomAttributes(element, false), definedAttributes);
|
||||
}
|
||||
catch (InvalidCastException)
|
||||
{
|
||||
Cache(element.GetCustomAttributes(false).Cast<Attribute>().ToArray(), definedAttributes);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to fetch defined attributes on {element}.\n{ex}");
|
||||
}
|
||||
}
|
||||
|
||||
public AttributeCache(ParameterInfo element)
|
||||
{
|
||||
Ensure.That(nameof(element)).IsNotNull(element);
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
Cache(Attribute.GetCustomAttributes(element, true), inheritedAttributes);
|
||||
}
|
||||
catch (InvalidCastException ex)
|
||||
{
|
||||
Cache(element.GetCustomAttributes(true).Cast<Attribute>().ToArray(), inheritedAttributes);
|
||||
Debug.LogWarning($"Failed to fetch inherited attributes on {element}.\n{ex}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to fetch inherited attributes on {element}.\n{ex}");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
Cache(Attribute.GetCustomAttributes(element, false), definedAttributes);
|
||||
}
|
||||
catch (InvalidCastException)
|
||||
{
|
||||
Cache(element.GetCustomAttributes(false).Cast<Attribute>().ToArray(), definedAttributes);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to fetch defined attributes on {element}.\n{ex}");
|
||||
}
|
||||
}
|
||||
|
||||
public AttributeCache(IAttributeProvider element)
|
||||
{
|
||||
Ensure.That(nameof(element)).IsNotNull(element);
|
||||
|
||||
try
|
||||
{
|
||||
Cache(element.GetCustomAttributes(true), inheritedAttributes);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to fetch inherited attributes on {element}.\n{ex}");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Cache(element.GetCustomAttributes(false), definedAttributes);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to fetch defined attributes on {element}.\n{ex}");
|
||||
}
|
||||
}
|
||||
|
||||
private void Cache(Attribute[] attributeObjects, List<Attribute> cache)
|
||||
{
|
||||
foreach (var attributeObject in attributeObjects)
|
||||
{
|
||||
cache.Add(attributeObject);
|
||||
}
|
||||
}
|
||||
|
||||
private bool HasAttribute(Type attributeType, List<Attribute> cache)
|
||||
{
|
||||
for (int i = 0; i < cache.Count; i++)
|
||||
{
|
||||
var attribute = cache[i];
|
||||
|
||||
if (attributeType.IsInstanceOfType(attribute))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private Attribute GetAttribute(Type attributeType, List<Attribute> cache)
|
||||
{
|
||||
for (int i = 0; i < cache.Count; i++)
|
||||
{
|
||||
var attribute = cache[i];
|
||||
|
||||
if (attributeType.IsInstanceOfType(attribute))
|
||||
{
|
||||
return attribute;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private IEnumerable<Attribute> GetAttributes(Type attributeType, List<Attribute> cache)
|
||||
{
|
||||
for (int i = 0; i < cache.Count; i++)
|
||||
{
|
||||
var attribute = cache[i];
|
||||
|
||||
if (attributeType.IsInstanceOfType(attribute))
|
||||
{
|
||||
yield return attribute;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasAttribute(Type attributeType, bool inherit = true)
|
||||
{
|
||||
if (inherit)
|
||||
{
|
||||
return HasAttribute(attributeType, inheritedAttributes);
|
||||
}
|
||||
else
|
||||
{
|
||||
return HasAttribute(attributeType, definedAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
public Attribute GetAttribute(Type attributeType, bool inherit = true)
|
||||
{
|
||||
if (inherit)
|
||||
{
|
||||
return GetAttribute(attributeType, inheritedAttributes);
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetAttribute(attributeType, definedAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Attribute> GetAttributes(Type attributeType, bool inherit = true)
|
||||
{
|
||||
if (inherit)
|
||||
{
|
||||
return GetAttributes(attributeType, inheritedAttributes);
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetAttributes(attributeType, definedAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasAttribute<TAttribute>(bool inherit = true)
|
||||
where TAttribute : Attribute
|
||||
{
|
||||
return HasAttribute(typeof(TAttribute), inherit);
|
||||
}
|
||||
|
||||
public TAttribute GetAttribute<TAttribute>(bool inherit = true)
|
||||
where TAttribute : Attribute
|
||||
{
|
||||
return (TAttribute)GetAttribute(typeof(TAttribute), inherit);
|
||||
}
|
||||
|
||||
public IEnumerable<TAttribute> GetAttributes<TAttribute>(bool inherit = true)
|
||||
where TAttribute : Attribute
|
||||
{
|
||||
return GetAttributes(typeof(TAttribute), inherit).Cast<TAttribute>();
|
||||
}
|
||||
}
|
||||
|
||||
private static AttributeCache GetAttributeCache(MemberInfo element)
|
||||
{
|
||||
Ensure.That(nameof(element)).IsNotNull(element);
|
||||
|
||||
// For MemberInfo (and therefore Type), we use the MetadataToken
|
||||
// as a key instead of the object itself, because member infos
|
||||
// are not singletons but their tokens are, optimizing the cache.
|
||||
var key = element;
|
||||
|
||||
lock (optimizedCaches)
|
||||
{
|
||||
if (!optimizedCaches.TryGetValue(key, out var cache))
|
||||
{
|
||||
cache = new AttributeCache(element);
|
||||
optimizedCaches.Add(key, cache);
|
||||
}
|
||||
|
||||
return cache;
|
||||
}
|
||||
}
|
||||
|
||||
private static AttributeCache GetAttributeCache(ParameterInfo element)
|
||||
{
|
||||
Ensure.That(nameof(element)).IsNotNull(element);
|
||||
|
||||
// For ParameterInfo, we maybe also should use the MetadataToken,
|
||||
// but I'm not sure they're globally unique or just locally unique. TODO: Check
|
||||
var key = element;
|
||||
|
||||
lock (optimizedCaches)
|
||||
{
|
||||
if (!optimizedCaches.TryGetValue(key, out var cache))
|
||||
{
|
||||
cache = new AttributeCache(element);
|
||||
optimizedCaches.Add(key, cache);
|
||||
}
|
||||
|
||||
return cache;
|
||||
}
|
||||
}
|
||||
|
||||
private static AttributeCache GetAttributeCache(IAttributeProvider element)
|
||||
{
|
||||
Ensure.That(nameof(element)).IsNotNull(element);
|
||||
|
||||
var key = element;
|
||||
|
||||
lock (optimizedCaches)
|
||||
{
|
||||
if (!optimizedCaches.TryGetValue(key, out var cache))
|
||||
{
|
||||
cache = new AttributeCache(element);
|
||||
optimizedCaches.Add(key, cache);
|
||||
}
|
||||
|
||||
return cache;
|
||||
}
|
||||
}
|
||||
|
||||
#region Members (& Types)
|
||||
|
||||
public static void CacheAttributes(MemberInfo element)
|
||||
{
|
||||
GetAttributeCache(element);
|
||||
}
|
||||
|
||||
public static bool HasAttribute(this MemberInfo element, Type attributeType, bool inherit = true)
|
||||
{
|
||||
return GetAttributeCache(element).HasAttribute(attributeType, inherit);
|
||||
}
|
||||
|
||||
public static Attribute GetAttribute(this MemberInfo element, Type attributeType, bool inherit = true)
|
||||
{
|
||||
return GetAttributeCache(element).GetAttribute(attributeType, inherit);
|
||||
}
|
||||
|
||||
public static IEnumerable<Attribute> GetAttributes(this MemberInfo element, Type attributeType, bool inherit = true)
|
||||
{
|
||||
return GetAttributeCache(element).GetAttributes(attributeType, inherit);
|
||||
}
|
||||
|
||||
public static bool HasAttribute<TAttribute>(this MemberInfo element, bool inherit = true)
|
||||
where TAttribute : Attribute
|
||||
{
|
||||
return GetAttributeCache(element).HasAttribute<TAttribute>(inherit);
|
||||
}
|
||||
|
||||
public static TAttribute GetAttribute<TAttribute>(this MemberInfo element, bool inherit = true)
|
||||
where TAttribute : Attribute
|
||||
{
|
||||
return GetAttributeCache(element).GetAttribute<TAttribute>(inherit);
|
||||
}
|
||||
|
||||
public static IEnumerable<TAttribute> GetAttributes<TAttribute>(this MemberInfo element, bool inherit = true)
|
||||
where TAttribute : Attribute
|
||||
{
|
||||
return GetAttributeCache(element).GetAttributes<TAttribute>(inherit);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Parameters
|
||||
|
||||
public static void CacheAttributes(ParameterInfo element)
|
||||
{
|
||||
GetAttributeCache(element);
|
||||
}
|
||||
|
||||
public static bool HasAttribute(this ParameterInfo element, Type attributeType, bool inherit = true)
|
||||
{
|
||||
return GetAttributeCache(element).HasAttribute(attributeType, inherit);
|
||||
}
|
||||
|
||||
public static Attribute GetAttribute(this ParameterInfo element, Type attributeType, bool inherit = true)
|
||||
{
|
||||
return GetAttributeCache(element).GetAttribute(attributeType, inherit);
|
||||
}
|
||||
|
||||
public static IEnumerable<Attribute> GetAttributes(this ParameterInfo element, Type attributeType, bool inherit = true)
|
||||
{
|
||||
return GetAttributeCache(element).GetAttributes(attributeType, inherit);
|
||||
}
|
||||
|
||||
public static bool HasAttribute<TAttribute>(this ParameterInfo element, bool inherit = true)
|
||||
where TAttribute : Attribute
|
||||
{
|
||||
return GetAttributeCache(element).HasAttribute<TAttribute>(inherit);
|
||||
}
|
||||
|
||||
public static TAttribute GetAttribute<TAttribute>(this ParameterInfo element, bool inherit = true)
|
||||
where TAttribute : Attribute
|
||||
{
|
||||
return GetAttributeCache(element).GetAttribute<TAttribute>(inherit);
|
||||
}
|
||||
|
||||
public static IEnumerable<TAttribute> GetAttributes<TAttribute>(this ParameterInfo element, bool inherit = true)
|
||||
where TAttribute : Attribute
|
||||
{
|
||||
return GetAttributeCache(element).GetAttributes<TAttribute>(inherit);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Providers
|
||||
|
||||
public static void CacheAttributes(IAttributeProvider element)
|
||||
{
|
||||
GetAttributeCache(element);
|
||||
}
|
||||
|
||||
public static bool HasAttribute(this IAttributeProvider element, Type attributeType, bool inherit = true)
|
||||
{
|
||||
return GetAttributeCache(element).HasAttribute(attributeType, inherit);
|
||||
}
|
||||
|
||||
public static Attribute GetAttribute(this IAttributeProvider element, Type attributeType, bool inherit = true)
|
||||
{
|
||||
return GetAttributeCache(element).GetAttribute(attributeType, inherit);
|
||||
}
|
||||
|
||||
public static IEnumerable<Attribute> GetAttributes(this IAttributeProvider element, Type attributeType, bool inherit = true)
|
||||
{
|
||||
return GetAttributeCache(element).GetAttributes(attributeType, inherit);
|
||||
}
|
||||
|
||||
public static bool HasAttribute<TAttribute>(this IAttributeProvider element, bool inherit = true)
|
||||
where TAttribute : Attribute
|
||||
{
|
||||
return GetAttributeCache(element).HasAttribute<TAttribute>(inherit);
|
||||
}
|
||||
|
||||
public static TAttribute GetAttribute<TAttribute>(this IAttributeProvider element, bool inherit = true)
|
||||
where TAttribute : Attribute
|
||||
{
|
||||
return GetAttributeCache(element).GetAttribute<TAttribute>(inherit);
|
||||
}
|
||||
|
||||
public static IEnumerable<TAttribute> GetAttributes<TAttribute>(this IAttributeProvider element, bool inherit = true)
|
||||
where TAttribute : Attribute
|
||||
{
|
||||
return GetAttributeCache(element).GetAttributes<TAttribute>(inherit);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Conditions
|
||||
|
||||
public static bool CheckCondition(Type type, object target, string conditionMemberName, bool fallback)
|
||||
{
|
||||
Ensure.That(nameof(type)).IsNotNull(type);
|
||||
|
||||
try
|
||||
{
|
||||
if (target != null && !type.IsInstanceOfType(target))
|
||||
{
|
||||
throw new ArgumentException("Target is not an instance of type.", nameof(target));
|
||||
}
|
||||
|
||||
if (conditionMemberName == null)
|
||||
{
|
||||
return fallback;
|
||||
}
|
||||
|
||||
var manipulator = type.GetMember(conditionMemberName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault()?.ToManipulator();
|
||||
|
||||
if (manipulator == null)
|
||||
{
|
||||
throw new MissingMemberException(type.ToString(), conditionMemberName);
|
||||
}
|
||||
|
||||
return manipulator.Get<bool>(target);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning("Failed to check attribute condition: \n" + ex);
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool CheckCondition<T>(T target, string conditionMemberName, bool fallback)
|
||||
{
|
||||
return CheckCondition(target?.GetType() ?? typeof(T), target, conditionMemberName, fallback);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ec7157f997fbc4debb9d6fdccf453f74
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,842 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public static class ConversionUtility
|
||||
{
|
||||
public enum ConversionType
|
||||
{
|
||||
Impossible,
|
||||
Identity,
|
||||
Upcast,
|
||||
Downcast,
|
||||
NumericImplicit,
|
||||
NumericExplicit,
|
||||
UserDefinedImplicit,
|
||||
UserDefinedExplicit,
|
||||
UserDefinedThenNumericImplicit,
|
||||
UserDefinedThenNumericExplicit,
|
||||
UnityHierarchy,
|
||||
EnumerableToArray,
|
||||
EnumerableToList,
|
||||
ToString
|
||||
}
|
||||
|
||||
private const BindingFlags UserDefinedBindingFlags = BindingFlags.Static | BindingFlags.Public;
|
||||
|
||||
private static readonly Dictionary<ConversionQuery, ConversionType> conversionTypesCache = new Dictionary<ConversionQuery, ConversionType>(new ConversionQueryComparer());
|
||||
private static readonly Dictionary<ConversionQuery, MethodInfo[]> userConversionMethodsCache = new Dictionary<ConversionQuery, MethodInfo[]>(new ConversionQueryComparer());
|
||||
|
||||
private static bool RespectsIdentity(Type source, Type destination)
|
||||
{
|
||||
return source == destination;
|
||||
}
|
||||
|
||||
private static bool IsUpcast(Type source, Type destination)
|
||||
{
|
||||
return destination.IsAssignableFrom(source);
|
||||
}
|
||||
|
||||
private static bool IsDowncast(Type source, Type destination)
|
||||
{
|
||||
return source.IsAssignableFrom(destination);
|
||||
}
|
||||
|
||||
private static bool ExpectsString(Type source, Type destination)
|
||||
{
|
||||
return destination == typeof(string);
|
||||
}
|
||||
|
||||
public static bool HasImplicitNumericConversion(Type source, Type destination)
|
||||
{
|
||||
return implicitNumericConversions.ContainsKey(source) && implicitNumericConversions[source].Contains(destination);
|
||||
}
|
||||
|
||||
public static bool HasExplicitNumericConversion(Type source, Type destination)
|
||||
{
|
||||
return explicitNumericConversions.ContainsKey(source) && explicitNumericConversions[source].Contains(destination);
|
||||
}
|
||||
|
||||
public static bool HasNumericConversion(Type source, Type destination)
|
||||
{
|
||||
return HasImplicitNumericConversion(source, destination) || HasExplicitNumericConversion(source, destination);
|
||||
}
|
||||
|
||||
private static IEnumerable<MethodInfo> FindUserDefinedConversionMethods(ConversionQuery query)
|
||||
{
|
||||
var source = query.source;
|
||||
var destination = query.destination;
|
||||
|
||||
var sourceMethods = source.GetMethods(UserDefinedBindingFlags)
|
||||
.Where(m => m.IsUserDefinedConversion());
|
||||
|
||||
var destinationMethods = destination.GetMethods(UserDefinedBindingFlags)
|
||||
.Where(m => m.IsUserDefinedConversion());
|
||||
|
||||
return sourceMethods.Concat(destinationMethods).Where
|
||||
(
|
||||
m => m.GetParameters()[0].ParameterType.IsAssignableFrom(source) ||
|
||||
source.IsAssignableFrom(m.GetParameters()[0].ParameterType)
|
||||
);
|
||||
}
|
||||
|
||||
// Returning an array directly so that the enumeration in
|
||||
// UserDefinedConversion does not allocate memory
|
||||
private static MethodInfo[] GetUserDefinedConversionMethods(Type source, Type destination)
|
||||
{
|
||||
var query = new ConversionQuery(source, destination);
|
||||
|
||||
if (!userConversionMethodsCache.ContainsKey(query))
|
||||
{
|
||||
userConversionMethodsCache.Add(query, FindUserDefinedConversionMethods(query).ToArray());
|
||||
}
|
||||
|
||||
return userConversionMethodsCache[query];
|
||||
}
|
||||
|
||||
private static ConversionType GetUserDefinedConversionType(Type source, Type destination)
|
||||
{
|
||||
var conversionMethods = GetUserDefinedConversionMethods(source, destination);
|
||||
|
||||
// Duplicate user defined conversions are not allowed, so FirstOrDefault is safe.
|
||||
|
||||
// Look for direct conversions.
|
||||
var conversionMethod = conversionMethods.FirstOrDefault(m => m.ReturnType == destination);
|
||||
|
||||
if (conversionMethod != null)
|
||||
{
|
||||
if (conversionMethod.Name == "op_Implicit")
|
||||
{
|
||||
return ConversionType.UserDefinedImplicit;
|
||||
}
|
||||
else if (conversionMethod.Name == "op_Explicit")
|
||||
{
|
||||
return ConversionType.UserDefinedExplicit;
|
||||
}
|
||||
}
|
||||
// Primitive types can skip the middleman cast, even if it is explicit.
|
||||
else if (destination.IsPrimitive && destination != typeof(IntPtr) && destination != typeof(UIntPtr))
|
||||
{
|
||||
// Look for implicit conversions.
|
||||
conversionMethod = conversionMethods.FirstOrDefault(m => HasImplicitNumericConversion(m.ReturnType, destination));
|
||||
|
||||
if (conversionMethod != null)
|
||||
{
|
||||
if (conversionMethod.Name == "op_Implicit")
|
||||
{
|
||||
return ConversionType.UserDefinedThenNumericImplicit;
|
||||
}
|
||||
else if (conversionMethod.Name == "op_Explicit")
|
||||
{
|
||||
return ConversionType.UserDefinedThenNumericExplicit;
|
||||
}
|
||||
}
|
||||
// Look for explicit conversions.
|
||||
else
|
||||
{
|
||||
conversionMethod = conversionMethods.FirstOrDefault(m => HasExplicitNumericConversion(m.ReturnType, destination));
|
||||
|
||||
if (conversionMethod != null)
|
||||
{
|
||||
return ConversionType.UserDefinedThenNumericExplicit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ConversionType.Impossible;
|
||||
}
|
||||
|
||||
private static bool HasEnumerableToArrayConversion(Type source, Type destination)
|
||||
{
|
||||
return source != typeof(string) &&
|
||||
typeof(IEnumerable).IsAssignableFrom(source) &&
|
||||
destination.IsArray &&
|
||||
destination.GetArrayRank() == 1;
|
||||
}
|
||||
|
||||
private static bool HasEnumerableToListConversion(Type source, Type destination)
|
||||
{
|
||||
return source != typeof(string) &&
|
||||
typeof(IEnumerable).IsAssignableFrom(source) &&
|
||||
destination.IsGenericType &&
|
||||
destination.GetGenericTypeDefinition() == typeof(List<>);
|
||||
}
|
||||
|
||||
private static bool HasUnityHierarchyConversion(Type source, Type destination)
|
||||
{
|
||||
if (destination == typeof(GameObject))
|
||||
{
|
||||
return typeof(Component).IsAssignableFrom(source);
|
||||
}
|
||||
else if (typeof(Component).IsAssignableFrom(destination) || destination.IsInterface)
|
||||
{
|
||||
return source == typeof(GameObject) || typeof(Component).IsAssignableFrom(source);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool IsValidConversion(ConversionType conversionType, bool guaranteed)
|
||||
{
|
||||
if (conversionType == ConversionType.Impossible)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (guaranteed)
|
||||
{
|
||||
// Downcasts are not guaranteed to succeed.
|
||||
if (conversionType == ConversionType.Downcast)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool CanConvert(object value, Type type, bool guaranteed)
|
||||
{
|
||||
return IsValidConversion(GetRequiredConversion(value, type), guaranteed);
|
||||
}
|
||||
|
||||
public static bool CanConvert(Type source, Type destination, bool guaranteed)
|
||||
{
|
||||
return IsValidConversion(GetRequiredConversion(source, destination), guaranteed);
|
||||
}
|
||||
|
||||
public static object Convert(object value, Type type)
|
||||
{
|
||||
return Convert(value, type, GetRequiredConversion(value, type));
|
||||
}
|
||||
|
||||
public static T Convert<T>(object value)
|
||||
{
|
||||
return (T)Convert(value, typeof(T));
|
||||
}
|
||||
|
||||
public static bool TryConvert(object value, Type type, out object result, bool guaranteed)
|
||||
{
|
||||
var conversionType = GetRequiredConversion(value, type);
|
||||
|
||||
if (IsValidConversion(conversionType, guaranteed))
|
||||
{
|
||||
result = Convert(value, type, conversionType);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = value;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool TryConvert<T>(object value, out T result, bool guaranteed)
|
||||
{
|
||||
object _result;
|
||||
|
||||
if (TryConvert(value, typeof(T), out _result, guaranteed))
|
||||
{
|
||||
result = (T)_result;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = default(T);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsConvertibleTo(this Type source, Type destination, bool guaranteed)
|
||||
{
|
||||
return CanConvert(source, destination, guaranteed);
|
||||
}
|
||||
|
||||
public static bool IsConvertibleTo(this object source, Type type, bool guaranteed)
|
||||
{
|
||||
return CanConvert(source, type, guaranteed);
|
||||
}
|
||||
|
||||
public static bool IsConvertibleTo<T>(this object source, bool guaranteed)
|
||||
{
|
||||
return CanConvert(source, typeof(T), guaranteed);
|
||||
}
|
||||
|
||||
public static object ConvertTo(this object source, Type type)
|
||||
{
|
||||
return Convert(source, type);
|
||||
}
|
||||
|
||||
public static T ConvertTo<T>(this object source)
|
||||
{
|
||||
return (T)Convert(source, typeof(T));
|
||||
}
|
||||
|
||||
public static ConversionType GetRequiredConversion(Type source, Type destination)
|
||||
{
|
||||
var query = new ConversionQuery(source, destination);
|
||||
|
||||
if (!conversionTypesCache.TryGetValue(query, out var conversionType))
|
||||
{
|
||||
conversionType = DetermineConversionType(query);
|
||||
conversionTypesCache.Add(query, conversionType);
|
||||
}
|
||||
|
||||
return conversionType;
|
||||
}
|
||||
|
||||
private static ConversionType DetermineConversionType(ConversionQuery query)
|
||||
{
|
||||
var source = query.source;
|
||||
var destination = query.destination;
|
||||
|
||||
if (source == null)
|
||||
{
|
||||
if (destination.IsNullable())
|
||||
{
|
||||
return ConversionType.Identity;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ConversionType.Impossible;
|
||||
}
|
||||
}
|
||||
|
||||
Ensure.That(nameof(destination)).IsNotNull(destination);
|
||||
|
||||
if (RespectsIdentity(source, destination))
|
||||
{
|
||||
return ConversionType.Identity;
|
||||
}
|
||||
else if (IsUpcast(source, destination))
|
||||
{
|
||||
return ConversionType.Upcast;
|
||||
}
|
||||
else if (IsDowncast(source, destination))
|
||||
{
|
||||
return ConversionType.Downcast;
|
||||
}
|
||||
// Disabling *.ToString conversion, because it's more often than otherwise very confusing
|
||||
/*else if (ExpectsString(source, destination))
|
||||
{
|
||||
return ConversionType.ToString;
|
||||
}*/
|
||||
else if (HasImplicitNumericConversion(source, destination))
|
||||
{
|
||||
return ConversionType.NumericImplicit;
|
||||
}
|
||||
else if (HasExplicitNumericConversion(source, destination))
|
||||
{
|
||||
return ConversionType.NumericExplicit;
|
||||
}
|
||||
else if (HasUnityHierarchyConversion(source, destination))
|
||||
{
|
||||
return ConversionType.UnityHierarchy;
|
||||
}
|
||||
else if (HasEnumerableToArrayConversion(source, destination))
|
||||
{
|
||||
return ConversionType.EnumerableToArray;
|
||||
}
|
||||
else if (HasEnumerableToListConversion(source, destination))
|
||||
{
|
||||
return ConversionType.EnumerableToList;
|
||||
}
|
||||
else
|
||||
{
|
||||
var userDefinedConversionType = GetUserDefinedConversionType(source, destination);
|
||||
|
||||
if (userDefinedConversionType != ConversionType.Impossible)
|
||||
{
|
||||
return userDefinedConversionType;
|
||||
}
|
||||
}
|
||||
|
||||
return ConversionType.Impossible;
|
||||
}
|
||||
|
||||
public static ConversionType GetRequiredConversion(object value, Type type)
|
||||
{
|
||||
Ensure.That(nameof(type)).IsNotNull(type);
|
||||
|
||||
return GetRequiredConversion(value?.GetType(), type);
|
||||
}
|
||||
|
||||
private static object NumericConversion(object value, Type type)
|
||||
{
|
||||
return System.Convert.ChangeType(value, type);
|
||||
}
|
||||
|
||||
private static object UserDefinedConversion(ConversionType conversion, object value, Type type)
|
||||
{
|
||||
var valueType = value.GetType();
|
||||
var conversionMethods = GetUserDefinedConversionMethods(valueType, type);
|
||||
|
||||
var numeric = conversion == ConversionType.UserDefinedThenNumericImplicit ||
|
||||
conversion == ConversionType.UserDefinedThenNumericExplicit;
|
||||
|
||||
MethodInfo conversionMethod = null;
|
||||
|
||||
if (numeric)
|
||||
{
|
||||
foreach (var m in conversionMethods)
|
||||
{
|
||||
if (HasNumericConversion(m.ReturnType, type))
|
||||
{
|
||||
conversionMethod = m;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var m in conversionMethods)
|
||||
{
|
||||
if (m.ReturnType == type)
|
||||
{
|
||||
conversionMethod = m;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var result = conversionMethod.InvokeOptimized(null, value);
|
||||
|
||||
if (numeric)
|
||||
{
|
||||
result = NumericConversion(result, type);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static object EnumerableToArrayConversion(object value, Type arrayType)
|
||||
{
|
||||
var elementType = arrayType.GetElementType();
|
||||
var objectArray = ((IEnumerable)value).Cast<object>().Where(elementType.IsAssignableFrom).ToArray(); // Non-generic OfType
|
||||
var typedArray = Array.CreateInstance(elementType, objectArray.Length);
|
||||
objectArray.CopyTo(typedArray, 0);
|
||||
return typedArray;
|
||||
}
|
||||
|
||||
private static object EnumerableToListConversion(object value, Type listType)
|
||||
{
|
||||
var elementType = listType.GetGenericArguments()[0];
|
||||
var objectArray = ((IEnumerable)value).Cast<object>().Where(elementType.IsAssignableFrom).ToArray(); // Non-generic OfType
|
||||
var typedList = (IList)Activator.CreateInstance(listType);
|
||||
|
||||
for (var i = 0; i < objectArray.Length; i++)
|
||||
{
|
||||
typedList.Add(objectArray[i]);
|
||||
}
|
||||
|
||||
return typedList;
|
||||
}
|
||||
|
||||
private static object UnityHierarchyConversion(object value, Type type)
|
||||
{
|
||||
if (value.IsUnityNull())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (type == typeof(GameObject) && value is Component)
|
||||
{
|
||||
return ((Component)value).gameObject;
|
||||
}
|
||||
else if (typeof(Component).IsAssignableFrom(type) || type.IsInterface)
|
||||
{
|
||||
if (value is Component)
|
||||
{
|
||||
return ((Component)value).GetComponent(type);
|
||||
}
|
||||
else if (value is GameObject)
|
||||
{
|
||||
return ((GameObject)value).GetComponent(type);
|
||||
}
|
||||
}
|
||||
|
||||
throw new InvalidConversionException();
|
||||
}
|
||||
|
||||
private static object Convert(object value, Type type, ConversionType conversionType)
|
||||
{
|
||||
Ensure.That(nameof(type)).IsNotNull(type);
|
||||
|
||||
if (conversionType == ConversionType.Impossible)
|
||||
{
|
||||
throw new InvalidConversionException($"Cannot convert from '{value?.GetType().ToString() ?? "null"}' to '{type}'.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
switch (conversionType)
|
||||
{
|
||||
case ConversionType.Identity:
|
||||
case ConversionType.Upcast:
|
||||
case ConversionType.Downcast:
|
||||
return value;
|
||||
|
||||
case ConversionType.ToString:
|
||||
return value.ToString();
|
||||
|
||||
case ConversionType.NumericImplicit:
|
||||
case ConversionType.NumericExplicit:
|
||||
return NumericConversion(value, type);
|
||||
|
||||
case ConversionType.UserDefinedImplicit:
|
||||
case ConversionType.UserDefinedExplicit:
|
||||
case ConversionType.UserDefinedThenNumericImplicit:
|
||||
case ConversionType.UserDefinedThenNumericExplicit:
|
||||
return UserDefinedConversion(conversionType, value, type);
|
||||
|
||||
case ConversionType.EnumerableToArray:
|
||||
return EnumerableToArrayConversion(value, type);
|
||||
|
||||
case ConversionType.EnumerableToList:
|
||||
return EnumerableToListConversion(value, type);
|
||||
|
||||
case ConversionType.UnityHierarchy:
|
||||
return UnityHierarchyConversion(value, type);
|
||||
|
||||
default:
|
||||
throw new UnexpectedEnumValueException<ConversionType>(conversionType);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new InvalidConversionException($"Failed to convert from '{value?.GetType().ToString() ?? "null"}' to '{type}' via {conversionType}.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private struct ConversionQuery : IEquatable<ConversionQuery>
|
||||
{
|
||||
public readonly Type source;
|
||||
public readonly Type destination;
|
||||
|
||||
public ConversionQuery(Type source, Type destination)
|
||||
{
|
||||
this.source = source;
|
||||
this.destination = destination;
|
||||
}
|
||||
|
||||
public bool Equals(ConversionQuery other)
|
||||
{
|
||||
return
|
||||
source == other.source &&
|
||||
destination == other.destination;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is ConversionQuery))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return Equals((ConversionQuery)obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashUtility.GetHashCode(source, destination);
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure the equality comparer doesn't use boxing
|
||||
private struct ConversionQueryComparer : IEqualityComparer<ConversionQuery>
|
||||
{
|
||||
public bool Equals(ConversionQuery x, ConversionQuery y)
|
||||
{
|
||||
return x.Equals(y);
|
||||
}
|
||||
|
||||
public int GetHashCode(ConversionQuery obj)
|
||||
{
|
||||
return obj.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
#region Numeric Conversions
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/y5b434w4.aspx
|
||||
private static readonly Dictionary<Type, HashSet<Type>> implicitNumericConversions = new Dictionary<Type, HashSet<Type>>()
|
||||
{
|
||||
{
|
||||
typeof(sbyte),
|
||||
new HashSet<Type>()
|
||||
{
|
||||
typeof(byte),
|
||||
typeof(int),
|
||||
typeof(long),
|
||||
typeof(float),
|
||||
typeof(double),
|
||||
typeof(decimal)
|
||||
}
|
||||
},
|
||||
{
|
||||
typeof(byte),
|
||||
new HashSet<Type>()
|
||||
{
|
||||
typeof(short),
|
||||
typeof(ushort),
|
||||
typeof(int),
|
||||
typeof(uint),
|
||||
typeof(long),
|
||||
typeof(ulong),
|
||||
typeof(float),
|
||||
typeof(double),
|
||||
typeof(decimal)
|
||||
}
|
||||
},
|
||||
{
|
||||
typeof(short),
|
||||
new HashSet<Type>()
|
||||
{
|
||||
typeof(int),
|
||||
typeof(long),
|
||||
typeof(float),
|
||||
typeof(double),
|
||||
typeof(decimal)
|
||||
}
|
||||
},
|
||||
{
|
||||
typeof(ushort),
|
||||
new HashSet<Type>()
|
||||
{
|
||||
typeof(int),
|
||||
typeof(uint),
|
||||
typeof(long),
|
||||
typeof(ulong),
|
||||
typeof(float),
|
||||
typeof(double),
|
||||
typeof(decimal),
|
||||
}
|
||||
},
|
||||
{
|
||||
typeof(int),
|
||||
new HashSet<Type>()
|
||||
{
|
||||
typeof(long),
|
||||
typeof(float),
|
||||
typeof(double),
|
||||
typeof(decimal)
|
||||
}
|
||||
},
|
||||
{
|
||||
typeof(uint),
|
||||
new HashSet<Type>()
|
||||
{
|
||||
typeof(long),
|
||||
typeof(ulong),
|
||||
typeof(float),
|
||||
typeof(double),
|
||||
typeof(decimal)
|
||||
}
|
||||
},
|
||||
{
|
||||
typeof(long),
|
||||
new HashSet<Type>()
|
||||
{
|
||||
typeof(float),
|
||||
typeof(double),
|
||||
typeof(decimal)
|
||||
}
|
||||
},
|
||||
{
|
||||
typeof(char),
|
||||
new HashSet<Type>()
|
||||
{
|
||||
typeof(ushort),
|
||||
typeof(int),
|
||||
typeof(uint),
|
||||
typeof(long),
|
||||
typeof(ulong),
|
||||
typeof(float),
|
||||
typeof(double),
|
||||
typeof(decimal)
|
||||
}
|
||||
},
|
||||
{
|
||||
typeof(float),
|
||||
new HashSet<Type>()
|
||||
{
|
||||
typeof(double)
|
||||
}
|
||||
},
|
||||
{
|
||||
typeof(ulong),
|
||||
new HashSet<Type>()
|
||||
{
|
||||
typeof(float),
|
||||
typeof(double),
|
||||
typeof(decimal)
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/yht2cx7b.aspx
|
||||
private static readonly Dictionary<Type, HashSet<Type>> explicitNumericConversions = new Dictionary<Type, HashSet<Type>>()
|
||||
{
|
||||
{
|
||||
typeof(sbyte),
|
||||
new HashSet<Type>()
|
||||
{
|
||||
typeof(byte),
|
||||
typeof(ushort),
|
||||
typeof(uint),
|
||||
typeof(ulong),
|
||||
typeof(char)
|
||||
}
|
||||
},
|
||||
{
|
||||
typeof(byte),
|
||||
new HashSet<Type>()
|
||||
{
|
||||
typeof(sbyte),
|
||||
typeof(char)
|
||||
}
|
||||
},
|
||||
{
|
||||
typeof(short),
|
||||
new HashSet<Type>()
|
||||
{
|
||||
typeof(sbyte),
|
||||
typeof(byte),
|
||||
typeof(ushort),
|
||||
typeof(uint),
|
||||
typeof(ulong),
|
||||
typeof(char)
|
||||
}
|
||||
},
|
||||
{
|
||||
typeof(ushort),
|
||||
new HashSet<Type>()
|
||||
{
|
||||
typeof(sbyte),
|
||||
typeof(byte),
|
||||
typeof(short),
|
||||
typeof(char)
|
||||
}
|
||||
},
|
||||
{
|
||||
typeof(int),
|
||||
new HashSet<Type>()
|
||||
{
|
||||
typeof(sbyte),
|
||||
typeof(byte),
|
||||
typeof(short),
|
||||
typeof(ushort),
|
||||
typeof(uint),
|
||||
typeof(ulong),
|
||||
typeof(char)
|
||||
}
|
||||
},
|
||||
{
|
||||
typeof(uint),
|
||||
new HashSet<Type>()
|
||||
{
|
||||
typeof(sbyte),
|
||||
typeof(byte),
|
||||
typeof(short),
|
||||
typeof(ushort),
|
||||
typeof(int),
|
||||
typeof(char)
|
||||
}
|
||||
},
|
||||
{
|
||||
typeof(long),
|
||||
new HashSet<Type>()
|
||||
{
|
||||
typeof(sbyte),
|
||||
typeof(byte),
|
||||
typeof(short),
|
||||
typeof(ushort),
|
||||
typeof(int),
|
||||
typeof(uint),
|
||||
typeof(ulong),
|
||||
typeof(char)
|
||||
}
|
||||
},
|
||||
{
|
||||
typeof(ulong),
|
||||
new HashSet<Type>()
|
||||
{
|
||||
typeof(sbyte),
|
||||
typeof(byte),
|
||||
typeof(short),
|
||||
typeof(ushort),
|
||||
typeof(int),
|
||||
typeof(uint),
|
||||
typeof(long),
|
||||
typeof(char)
|
||||
}
|
||||
},
|
||||
{
|
||||
typeof(char),
|
||||
new HashSet<Type>()
|
||||
{
|
||||
typeof(sbyte),
|
||||
typeof(byte),
|
||||
typeof(short)
|
||||
}
|
||||
},
|
||||
{
|
||||
typeof(float),
|
||||
new HashSet<Type>()
|
||||
{
|
||||
typeof(sbyte),
|
||||
typeof(byte),
|
||||
typeof(short),
|
||||
typeof(ushort),
|
||||
typeof(int),
|
||||
typeof(uint),
|
||||
typeof(long),
|
||||
typeof(ulong),
|
||||
typeof(char),
|
||||
typeof(decimal)
|
||||
}
|
||||
},
|
||||
{
|
||||
typeof(double),
|
||||
new HashSet<Type>()
|
||||
{
|
||||
typeof(sbyte),
|
||||
typeof(byte),
|
||||
typeof(short),
|
||||
typeof(ushort),
|
||||
typeof(int),
|
||||
typeof(uint),
|
||||
typeof(long),
|
||||
typeof(ulong),
|
||||
typeof(char),
|
||||
typeof(float),
|
||||
typeof(decimal),
|
||||
}
|
||||
},
|
||||
{
|
||||
typeof(decimal),
|
||||
new HashSet<Type>()
|
||||
{
|
||||
typeof(sbyte),
|
||||
typeof(byte),
|
||||
typeof(short),
|
||||
typeof(ushort),
|
||||
typeof(int),
|
||||
typeof(uint),
|
||||
typeof(long),
|
||||
typeof(ulong),
|
||||
typeof(char),
|
||||
typeof(float),
|
||||
typeof(double)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fa6f472bdcf96422aabee9d2cd19a386
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,10 @@
|
|||
using System;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public sealed class GenericClosingException : Exception
|
||||
{
|
||||
public GenericClosingException(string message) : base(message) { }
|
||||
public GenericClosingException(Type open, Type closed) : base($"Open-constructed type '{open}' is not assignable from closed-constructed type '{closed}'.") { }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 82f21756470a44b4a9e0bb6021481946
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
using System;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public interface IAttributeProvider
|
||||
{
|
||||
Attribute[] GetCustomAttributes(bool inherit);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 823de046c493643b397faa358568303a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,7 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public interface IPrewarmable
|
||||
{
|
||||
void Prewarm();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 77db300ad10574dcb968a20561f8b147
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,65 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public struct LooseAssemblyName
|
||||
{
|
||||
public readonly string name;
|
||||
|
||||
public LooseAssemblyName(string name)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(name));
|
||||
}
|
||||
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is LooseAssemblyName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return ((LooseAssemblyName)obj).name == name;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashUtility.GetHashCode(name);
|
||||
}
|
||||
|
||||
public static bool operator ==(LooseAssemblyName a, LooseAssemblyName b)
|
||||
{
|
||||
return a.Equals(b);
|
||||
}
|
||||
|
||||
public static bool operator !=(LooseAssemblyName a, LooseAssemblyName b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
public static implicit operator LooseAssemblyName(string name)
|
||||
{
|
||||
return new LooseAssemblyName(name);
|
||||
}
|
||||
|
||||
public static implicit operator string(LooseAssemblyName name)
|
||||
{
|
||||
return name.name;
|
||||
}
|
||||
|
||||
public static explicit operator LooseAssemblyName(AssemblyName strongAssemblyName)
|
||||
{
|
||||
return new LooseAssemblyName(strongAssemblyName.Name);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9f4dc1e2bfd0e486eaf70b322db267c1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 628d9148413e5487f8a67004133213e4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,510 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityObject = UnityEngine.Object;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
|
||||
public sealed class MemberFilter : Attribute, ICloneable
|
||||
{
|
||||
public MemberFilter()
|
||||
{
|
||||
// Whitelist
|
||||
Fields = false;
|
||||
Properties = false;
|
||||
Methods = false;
|
||||
Constructors = false;
|
||||
Gettable = false;
|
||||
Settable = false;
|
||||
|
||||
// Blacklist
|
||||
Inherited = true;
|
||||
Targeted = true;
|
||||
NonTargeted = true;
|
||||
Public = true;
|
||||
NonPublic = false;
|
||||
ReadOnly = true;
|
||||
WriteOnly = true;
|
||||
Extensions = true;
|
||||
Operators = true;
|
||||
Conversions = true;
|
||||
Parameters = true;
|
||||
Obsolete = false;
|
||||
OpenConstructedGeneric = false;
|
||||
TypeInitializers = true;
|
||||
ClsNonCompliant = true;
|
||||
}
|
||||
|
||||
public bool Fields { get; set; }
|
||||
public bool Properties { get; set; }
|
||||
public bool Methods { get; set; }
|
||||
public bool Constructors { get; set; }
|
||||
public bool Gettable { get; set; }
|
||||
public bool Settable { get; set; }
|
||||
|
||||
public bool Inherited { get; set; }
|
||||
public bool Targeted { get; set; }
|
||||
public bool NonTargeted { get; set; }
|
||||
public bool Public { get; set; }
|
||||
public bool NonPublic { get; set; }
|
||||
public bool ReadOnly { get; set; }
|
||||
public bool WriteOnly { get; set; }
|
||||
public bool Extensions { get; set; }
|
||||
public bool Operators { get; set; }
|
||||
public bool Conversions { get; set; }
|
||||
public bool Setters { get; set; }
|
||||
public bool Parameters { get; set; }
|
||||
public bool Obsolete { get; set; }
|
||||
public bool OpenConstructedGeneric { get; set; }
|
||||
public bool TypeInitializers { get; set; }
|
||||
public bool ClsNonCompliant { get; set; }
|
||||
|
||||
public BindingFlags validBindingFlags
|
||||
{
|
||||
get
|
||||
{
|
||||
BindingFlags flags = 0;
|
||||
|
||||
if (Public)
|
||||
{
|
||||
flags |= BindingFlags.Public;
|
||||
}
|
||||
if (NonPublic)
|
||||
{
|
||||
flags |= BindingFlags.NonPublic;
|
||||
}
|
||||
if (Targeted || Constructors)
|
||||
{
|
||||
flags |= BindingFlags.Instance;
|
||||
}
|
||||
if (NonTargeted)
|
||||
{
|
||||
flags |= BindingFlags.Static;
|
||||
}
|
||||
if (!Inherited)
|
||||
{
|
||||
flags |= BindingFlags.DeclaredOnly;
|
||||
}
|
||||
if (NonTargeted && Inherited)
|
||||
{
|
||||
flags |= BindingFlags.FlattenHierarchy;
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
|
||||
public MemberTypes validMemberTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
MemberTypes types = 0;
|
||||
|
||||
if (Fields || Gettable || Settable)
|
||||
{
|
||||
types |= MemberTypes.Field;
|
||||
}
|
||||
|
||||
if (Properties || Gettable || Settable)
|
||||
{
|
||||
types |= MemberTypes.Property;
|
||||
}
|
||||
|
||||
if (Methods || Gettable)
|
||||
{
|
||||
types |= MemberTypes.Method;
|
||||
}
|
||||
|
||||
if (Constructors || Gettable)
|
||||
{
|
||||
types |= MemberTypes.Constructor;
|
||||
}
|
||||
|
||||
return types;
|
||||
}
|
||||
}
|
||||
|
||||
object ICloneable.Clone()
|
||||
{
|
||||
return Clone();
|
||||
}
|
||||
|
||||
public MemberFilter Clone()
|
||||
{
|
||||
return new MemberFilter()
|
||||
{
|
||||
Fields = Fields,
|
||||
Properties = Properties,
|
||||
Methods = Methods,
|
||||
Constructors = Constructors,
|
||||
Gettable = Gettable,
|
||||
Settable = Settable,
|
||||
Inherited = Inherited,
|
||||
Targeted = Targeted,
|
||||
NonTargeted = NonTargeted,
|
||||
Public = Public,
|
||||
NonPublic = NonPublic,
|
||||
ReadOnly = ReadOnly,
|
||||
WriteOnly = WriteOnly,
|
||||
Extensions = Extensions,
|
||||
Operators = Operators,
|
||||
Conversions = Conversions,
|
||||
Parameters = Parameters,
|
||||
Obsolete = Obsolete,
|
||||
OpenConstructedGeneric = OpenConstructedGeneric,
|
||||
TypeInitializers = TypeInitializers,
|
||||
ClsNonCompliant = ClsNonCompliant
|
||||
};
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var other = obj as MemberFilter;
|
||||
|
||||
if (other == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return
|
||||
Fields == other.Fields &&
|
||||
Properties == other.Properties &&
|
||||
Methods == other.Methods &&
|
||||
Constructors == other.Constructors &&
|
||||
Gettable == other.Gettable &&
|
||||
Settable == other.Settable &&
|
||||
Inherited == other.Inherited &&
|
||||
Targeted == other.Targeted &&
|
||||
NonTargeted == other.NonTargeted &&
|
||||
Public == other.Public &&
|
||||
NonPublic == other.NonPublic &&
|
||||
ReadOnly == other.ReadOnly &&
|
||||
WriteOnly == other.WriteOnly &&
|
||||
Extensions == other.Extensions &&
|
||||
Operators == other.Operators &&
|
||||
Conversions == other.Conversions &&
|
||||
Parameters == other.Parameters &&
|
||||
Obsolete == other.Obsolete &&
|
||||
OpenConstructedGeneric == other.OpenConstructedGeneric &&
|
||||
TypeInitializers == other.TypeInitializers &&
|
||||
ClsNonCompliant == other.ClsNonCompliant;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
var hash = 17;
|
||||
|
||||
hash = hash * 23 + Fields.GetHashCode();
|
||||
hash = hash * 23 + Properties.GetHashCode();
|
||||
hash = hash * 23 + Methods.GetHashCode();
|
||||
hash = hash * 23 + Constructors.GetHashCode();
|
||||
hash = hash * 23 + Gettable.GetHashCode();
|
||||
hash = hash * 23 + Settable.GetHashCode();
|
||||
|
||||
hash = hash * 23 + Inherited.GetHashCode();
|
||||
hash = hash * 23 + Targeted.GetHashCode();
|
||||
hash = hash * 23 + NonTargeted.GetHashCode();
|
||||
hash = hash * 23 + Public.GetHashCode();
|
||||
hash = hash * 23 + NonPublic.GetHashCode();
|
||||
hash = hash * 23 + ReadOnly.GetHashCode();
|
||||
hash = hash * 23 + WriteOnly.GetHashCode();
|
||||
hash = hash * 23 + Extensions.GetHashCode();
|
||||
hash = hash * 23 + Operators.GetHashCode();
|
||||
hash = hash * 23 + Conversions.GetHashCode();
|
||||
hash = hash * 23 + Parameters.GetHashCode();
|
||||
hash = hash * 23 + Obsolete.GetHashCode();
|
||||
hash = hash * 23 + OpenConstructedGeneric.GetHashCode();
|
||||
hash = hash * 23 + TypeInitializers.GetHashCode();
|
||||
hash = hash * 23 + ClsNonCompliant.GetHashCode();
|
||||
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ValidateMember(MemberInfo member, TypeFilter typeFilter = null)
|
||||
{
|
||||
if (member is FieldInfo)
|
||||
{
|
||||
var field = (FieldInfo)member;
|
||||
|
||||
// Whitelist
|
||||
var isGettable = true;
|
||||
var isSettable = !field.IsLiteral && !field.IsInitOnly;
|
||||
var whitelisted = Fields || (Gettable && isGettable) || (Settable && isSettable);
|
||||
if (!whitelisted)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Targetting
|
||||
var isTargeted = !field.IsStatic;
|
||||
if (!Targeted && isTargeted)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!NonTargeted && !isTargeted)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Accessibility
|
||||
if (!WriteOnly && !isGettable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!ReadOnly && !isSettable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Visibility
|
||||
if (!Public && field.IsPublic)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!NonPublic && !field.IsPublic)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Type
|
||||
if (typeFilter != null && !typeFilter.ValidateType(field.FieldType))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Other
|
||||
if (field.IsSpecialName)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (member is PropertyInfo)
|
||||
{
|
||||
var property = (PropertyInfo)member;
|
||||
var getter = property.GetGetMethod(true);
|
||||
var setter = property.GetSetMethod(true);
|
||||
|
||||
// Whitelist
|
||||
var isGettable = property.CanRead;
|
||||
var isSettable = property.CanWrite;
|
||||
var whitelisted = Properties || (Gettable && isGettable) || (Settable && isSettable);
|
||||
if (!whitelisted)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Visibility & Accessibility
|
||||
// TODO: Refactor + Take into account when Public = false
|
||||
var requiresRead = (!WriteOnly || (!Properties && Gettable));
|
||||
var requiresWrite = (!ReadOnly || (!Properties && Settable));
|
||||
var canRead = property.CanRead && (NonPublic || getter.IsPublic);
|
||||
var canWrite = property.CanWrite && (NonPublic || setter.IsPublic);
|
||||
if (requiresRead && !canRead)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (requiresWrite && !canWrite)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Targetting
|
||||
var isTargeted = !(getter ?? setter).IsStatic;
|
||||
if (!Targeted && isTargeted)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!NonTargeted && !isTargeted)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Type
|
||||
if (typeFilter != null && !typeFilter.ValidateType(property.PropertyType))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Other
|
||||
if (property.IsSpecialName)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (property.GetIndexParameters().Any())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (member is MethodBase)
|
||||
{
|
||||
var methodOrConstructor = (MethodBase)member;
|
||||
var isExtension = methodOrConstructor.IsExtensionMethod();
|
||||
var isTargeted = !methodOrConstructor.IsStatic || isExtension;
|
||||
|
||||
// Visibility
|
||||
if (!Public && methodOrConstructor.IsPublic)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!NonPublic && !methodOrConstructor.IsPublic)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Other
|
||||
if (!Parameters && (methodOrConstructor.GetParameters().Length > (isExtension ? 1 : 0)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!OpenConstructedGeneric && methodOrConstructor.ContainsGenericParameters)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (member is MethodInfo)
|
||||
{
|
||||
var method = (MethodInfo)member;
|
||||
var isOperator = method.IsOperator();
|
||||
var isConversion = method.IsUserDefinedConversion();
|
||||
|
||||
// Whitelist
|
||||
var isGettable = method.ReturnType != typeof(void);
|
||||
var isSettable = false;
|
||||
var whitelisted = Methods || (Gettable && isGettable) || (Settable && isSettable);
|
||||
if (!whitelisted)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Targetting
|
||||
if (!Targeted && isTargeted)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!NonTargeted && !isTargeted)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Operators
|
||||
if (!Operators && isOperator)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Extensions
|
||||
if (!Extensions && isExtension)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Type
|
||||
if (typeFilter != null && !typeFilter.ValidateType(method.ReturnType))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Other
|
||||
if (method.IsSpecialName && !(isOperator || isConversion))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (member is ConstructorInfo)
|
||||
{
|
||||
var constructor = (ConstructorInfo)member;
|
||||
|
||||
// Whitelist
|
||||
var isGettable = true;
|
||||
var isSettable = false;
|
||||
var whitelisted = Constructors || (Gettable && isGettable) || (Settable && isSettable);
|
||||
if (!whitelisted)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Type
|
||||
if (typeFilter != null && !typeFilter.ValidateType(constructor.DeclaringType))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Type Initializers
|
||||
if (constructor.IsStatic && !TypeInitializers)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Other
|
||||
if (typeof(Component).IsAssignableFrom(member.DeclaringType) || typeof(ScriptableObject).IsAssignableFrom(member.DeclaringType))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Obsolete
|
||||
if (!Obsolete && member.HasAttribute<ObsoleteAttribute>(false))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// CLS Compliance
|
||||
if (!ClsNonCompliant)
|
||||
{
|
||||
var clsCompliantAttribute = member.GetAttribute<CLSCompliantAttribute>();
|
||||
|
||||
if (clsCompliantAttribute != null && !clsCompliantAttribute.IsCompliant)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
sb.AppendLine($"Fields: {Fields}");
|
||||
sb.AppendLine($"Properties: {Properties}");
|
||||
sb.AppendLine($"Methods: {Methods}");
|
||||
sb.AppendLine($"Constructors: {Constructors}");
|
||||
sb.AppendLine($"Gettable: {Gettable}");
|
||||
sb.AppendLine($"Settable: {Settable}");
|
||||
sb.AppendLine();
|
||||
sb.AppendLine($"Inherited: {Inherited}");
|
||||
sb.AppendLine($"Instance: {Targeted}");
|
||||
sb.AppendLine($"Static: {NonTargeted}");
|
||||
sb.AppendLine($"Public: {Public}");
|
||||
sb.AppendLine($"NonPublic: {NonPublic}");
|
||||
sb.AppendLine($"ReadOnly: {ReadOnly}");
|
||||
sb.AppendLine($"WriteOnly: {WriteOnly}");
|
||||
sb.AppendLine($"Extensions: {Extensions}");
|
||||
sb.AppendLine($"Operators: {Operators}");
|
||||
sb.AppendLine($"Conversions: {Conversions}");
|
||||
sb.AppendLine($"Parameters: {Parameters}");
|
||||
sb.AppendLine($"Obsolete: {Obsolete}");
|
||||
sb.AppendLine($"OpenConstructedGeneric: {OpenConstructedGeneric}");
|
||||
sb.AppendLine($"TypeInitializers: {TypeInitializers}");
|
||||
sb.AppendLine($"ClsNonCompliant: {ClsNonCompliant}");
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static MemberFilter Any => new MemberFilter()
|
||||
{
|
||||
Fields = true,
|
||||
Properties = true,
|
||||
Methods = true,
|
||||
Constructors = true
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 848222a3967b845b48a00d1f58aaae70
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,22 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
/// <summary>
|
||||
/// A member info comparer that will ignore the ReflectedType
|
||||
/// property by relying on the metadata token for comparison.
|
||||
/// </summary>
|
||||
public class MemberInfoComparer : EqualityComparer<MemberInfo>
|
||||
{
|
||||
public override bool Equals(MemberInfo x, MemberInfo y)
|
||||
{
|
||||
return x?.MetadataToken == y?.MetadataToken;
|
||||
}
|
||||
|
||||
public override int GetHashCode(MemberInfo obj)
|
||||
{
|
||||
return obj.MetadataToken;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6096ca814afb241ae99e9042d996fd27
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,693 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using UnityObject = UnityEngine.Object;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public static class MemberUtility
|
||||
{
|
||||
static MemberUtility()
|
||||
{
|
||||
// Cache a list of all extension methods in assemblies
|
||||
// http://stackoverflow.com/a/299526
|
||||
|
||||
extensionMethodsCache = RuntimeCodebase.types
|
||||
.Where(type => type.IsStatic() && !type.IsGenericType && !type.IsNested)
|
||||
.SelectMany(type => type.GetMethods())
|
||||
.Where(method => method.IsExtension())
|
||||
.ToArray();
|
||||
|
||||
// The process of resolving generic methods is very expensive.
|
||||
// Cache the results for each this parameter type.
|
||||
|
||||
inheritedExtensionMethodsCache = new Dictionary<Type, MethodInfo[]>();
|
||||
genericExtensionMethods = new HashSet<MethodInfo>();
|
||||
}
|
||||
|
||||
private static readonly MethodInfo[] extensionMethodsCache;
|
||||
private static readonly Dictionary<Type, MethodInfo[]> inheritedExtensionMethodsCache;
|
||||
private static readonly HashSet<MethodInfo> genericExtensionMethods;
|
||||
|
||||
public static bool IsOperator(this MethodInfo method)
|
||||
{
|
||||
return method.IsSpecialName && OperatorUtility.operatorNames.ContainsKey(method.Name);
|
||||
}
|
||||
|
||||
public static bool IsUserDefinedConversion(this MethodInfo method)
|
||||
{
|
||||
return method.IsSpecialName && (method.Name == "op_Implicit" || method.Name == "op_Explicit");
|
||||
}
|
||||
|
||||
/// <remarks>This may return an open-constructed method as well.</remarks>
|
||||
public static MethodInfo MakeGenericMethodVia(this MethodInfo openConstructedMethod, params Type[] closedConstructedParameterTypes)
|
||||
{
|
||||
Ensure.That(nameof(openConstructedMethod)).IsNotNull(openConstructedMethod);
|
||||
Ensure.That(nameof(closedConstructedParameterTypes)).IsNotNull(closedConstructedParameterTypes);
|
||||
|
||||
if (!openConstructedMethod.ContainsGenericParameters)
|
||||
{
|
||||
// The method contains no generic parameters,
|
||||
// it is by definition already resolved.
|
||||
return openConstructedMethod;
|
||||
}
|
||||
|
||||
var openConstructedParameterTypes = openConstructedMethod.GetParameters().Select(p => p.ParameterType).ToArray();
|
||||
|
||||
if (openConstructedParameterTypes.Length != closedConstructedParameterTypes.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(closedConstructedParameterTypes));
|
||||
}
|
||||
|
||||
var resolvedGenericParameters = new Dictionary<Type, Type>();
|
||||
|
||||
for (var i = 0; i < openConstructedParameterTypes.Length; i++)
|
||||
{
|
||||
// Resolve each open-constructed parameter type via the equivalent
|
||||
// closed-constructed parameter type.
|
||||
|
||||
var openConstructedParameterType = openConstructedParameterTypes[i];
|
||||
var closedConstructedParameterType = closedConstructedParameterTypes[i];
|
||||
|
||||
openConstructedParameterType.MakeGenericTypeVia(closedConstructedParameterType, resolvedGenericParameters);
|
||||
}
|
||||
|
||||
// Construct the final closed-constructed method from the resolved arguments
|
||||
|
||||
var openConstructedGenericArguments = openConstructedMethod.GetGenericArguments();
|
||||
var closedConstructedGenericArguments = openConstructedGenericArguments.Select(openConstructedGenericArgument =>
|
||||
{
|
||||
// If the generic argument has been successfully resolved, use it;
|
||||
// otherwise, leave the open-constructed argument in place.
|
||||
|
||||
if (resolvedGenericParameters.ContainsKey(openConstructedGenericArgument))
|
||||
{
|
||||
return resolvedGenericParameters[openConstructedGenericArgument];
|
||||
}
|
||||
else
|
||||
{
|
||||
return openConstructedGenericArgument;
|
||||
}
|
||||
}).ToArray();
|
||||
|
||||
return openConstructedMethod.MakeGenericMethod(closedConstructedGenericArguments);
|
||||
}
|
||||
|
||||
public static bool IsGenericExtension(this MethodInfo methodInfo)
|
||||
{
|
||||
return genericExtensionMethods.Contains(methodInfo);
|
||||
}
|
||||
|
||||
private static IEnumerable<MethodInfo> GetInheritedExtensionMethods(Type thisArgumentType)
|
||||
{
|
||||
foreach (var extensionMethod in extensionMethodsCache)
|
||||
{
|
||||
var compatibleThis = extensionMethod.GetParameters()[0].ParameterType.CanMakeGenericTypeVia(thisArgumentType);
|
||||
|
||||
if (compatibleThis)
|
||||
{
|
||||
if (extensionMethod.ContainsGenericParameters)
|
||||
{
|
||||
var closedConstructedParameterTypes = thisArgumentType.Yield().Concat(extensionMethod.GetParametersWithoutThis().Select(p => p.ParameterType));
|
||||
|
||||
var closedConstructedMethod = extensionMethod.MakeGenericMethodVia(closedConstructedParameterTypes.ToArray());
|
||||
|
||||
genericExtensionMethods.Add(closedConstructedMethod);
|
||||
|
||||
yield return closedConstructedMethod;
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return extensionMethod;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<MethodInfo> GetExtensionMethods(this Type thisArgumentType, bool inherited = true)
|
||||
{
|
||||
if (inherited)
|
||||
{
|
||||
lock (inheritedExtensionMethodsCache)
|
||||
{
|
||||
if (!inheritedExtensionMethodsCache.TryGetValue(thisArgumentType, out var inheritedExtensionMethods))
|
||||
{
|
||||
inheritedExtensionMethods = GetInheritedExtensionMethods(thisArgumentType).ToArray();
|
||||
inheritedExtensionMethodsCache.Add(thisArgumentType, inheritedExtensionMethods);
|
||||
}
|
||||
|
||||
return inheritedExtensionMethods;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return extensionMethodsCache.Where(method => method.GetParameters()[0].ParameterType == thisArgumentType);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsExtension(this MethodInfo methodInfo)
|
||||
{
|
||||
return methodInfo.HasAttribute<ExtensionAttribute>(false);
|
||||
}
|
||||
|
||||
public static bool IsExtensionMethod(this MemberInfo memberInfo)
|
||||
{
|
||||
return memberInfo is MethodInfo methodInfo && methodInfo.IsExtension();
|
||||
}
|
||||
|
||||
public static Delegate CreateDelegate(this MethodInfo methodInfo, Type delegateType)
|
||||
{
|
||||
return Delegate.CreateDelegate(delegateType, methodInfo);
|
||||
}
|
||||
|
||||
public static bool IsAccessor(this MemberInfo memberInfo)
|
||||
{
|
||||
return memberInfo is FieldInfo || memberInfo is PropertyInfo;
|
||||
}
|
||||
|
||||
public static Type GetAccessorType(this MemberInfo memberInfo)
|
||||
{
|
||||
if (memberInfo is FieldInfo)
|
||||
{
|
||||
return ((FieldInfo)memberInfo).FieldType;
|
||||
}
|
||||
else if (memberInfo is PropertyInfo)
|
||||
{
|
||||
return ((PropertyInfo)memberInfo).PropertyType;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsPubliclyGettable(this MemberInfo memberInfo)
|
||||
{
|
||||
if (memberInfo is FieldInfo)
|
||||
{
|
||||
return ((FieldInfo)memberInfo).IsPublic;
|
||||
}
|
||||
else if (memberInfo is PropertyInfo)
|
||||
{
|
||||
var propertyInfo = (PropertyInfo)memberInfo;
|
||||
|
||||
return propertyInfo.CanRead && propertyInfo.GetGetMethod(false) != null;
|
||||
}
|
||||
else if (memberInfo is MethodInfo)
|
||||
{
|
||||
return ((MethodInfo)memberInfo).IsPublic;
|
||||
}
|
||||
else if (memberInfo is ConstructorInfo)
|
||||
{
|
||||
return ((ConstructorInfo)memberInfo).IsPublic;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
private static Type ExtendedDeclaringType(this MemberInfo memberInfo)
|
||||
{
|
||||
if (memberInfo is MethodInfo methodInfo && methodInfo.IsExtension())
|
||||
{
|
||||
return methodInfo.GetParameters()[0].ParameterType;
|
||||
}
|
||||
else
|
||||
{
|
||||
return memberInfo.DeclaringType;
|
||||
}
|
||||
}
|
||||
|
||||
public static Type ExtendedDeclaringType(this MemberInfo memberInfo, bool invokeAsExtension)
|
||||
{
|
||||
if (invokeAsExtension)
|
||||
{
|
||||
return memberInfo.ExtendedDeclaringType();
|
||||
}
|
||||
else
|
||||
{
|
||||
return memberInfo.DeclaringType;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsStatic(this PropertyInfo propertyInfo)
|
||||
{
|
||||
return (propertyInfo.GetGetMethod(true)?.IsStatic ?? false) ||
|
||||
(propertyInfo.GetSetMethod(true)?.IsStatic ?? false);
|
||||
}
|
||||
|
||||
public static bool IsStatic(this MemberInfo memberInfo)
|
||||
{
|
||||
if (memberInfo is FieldInfo)
|
||||
{
|
||||
return ((FieldInfo)memberInfo).IsStatic;
|
||||
}
|
||||
else if (memberInfo is PropertyInfo)
|
||||
{
|
||||
return ((PropertyInfo)memberInfo).IsStatic();
|
||||
}
|
||||
else if (memberInfo is MethodBase)
|
||||
{
|
||||
return ((MethodBase)memberInfo).IsStatic;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<ParameterInfo> GetParametersWithoutThis(this MethodBase methodBase)
|
||||
{
|
||||
return methodBase.GetParameters().Skip(methodBase.IsExtensionMethod() ? 1 : 0);
|
||||
}
|
||||
|
||||
public static bool IsInvokedAsExtension(this MethodBase methodBase, Type targetType)
|
||||
{
|
||||
return methodBase.IsExtensionMethod() && methodBase.DeclaringType != targetType;
|
||||
}
|
||||
|
||||
public static IEnumerable<ParameterInfo> GetInvocationParameters(this MethodBase methodBase, bool invokeAsExtension)
|
||||
{
|
||||
if (invokeAsExtension)
|
||||
{
|
||||
return methodBase.GetParametersWithoutThis();
|
||||
}
|
||||
else
|
||||
{
|
||||
return methodBase.GetParameters();
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<ParameterInfo> GetInvocationParameters(this MethodBase methodBase, Type targetType)
|
||||
{
|
||||
return methodBase.GetInvocationParameters(methodBase.IsInvokedAsExtension(targetType));
|
||||
}
|
||||
|
||||
public static Type UnderlyingParameterType(this ParameterInfo parameterInfo)
|
||||
{
|
||||
if (parameterInfo.ParameterType.IsByRef)
|
||||
{
|
||||
return parameterInfo.ParameterType.GetElementType();
|
||||
}
|
||||
else
|
||||
{
|
||||
return parameterInfo.ParameterType;
|
||||
}
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/9977530/
|
||||
// https://stackoverflow.com/questions/16186694
|
||||
public static bool HasDefaultValue(this ParameterInfo parameterInfo)
|
||||
{
|
||||
return (parameterInfo.Attributes & ParameterAttributes.HasDefault) == ParameterAttributes.HasDefault;
|
||||
}
|
||||
|
||||
public static object DefaultValue(this ParameterInfo parameterInfo)
|
||||
{
|
||||
if (parameterInfo.HasDefaultValue())
|
||||
{
|
||||
var defaultValue = parameterInfo.DefaultValue;
|
||||
|
||||
// https://stackoverflow.com/questions/45393580
|
||||
if (defaultValue == null && parameterInfo.ParameterType.IsValueType)
|
||||
{
|
||||
defaultValue = parameterInfo.ParameterType.Default();
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
return parameterInfo.UnderlyingParameterType().Default();
|
||||
}
|
||||
}
|
||||
|
||||
public static object PseudoDefaultValue(this ParameterInfo parameterInfo)
|
||||
{
|
||||
if (parameterInfo.HasDefaultValue())
|
||||
{
|
||||
var defaultValue = parameterInfo.DefaultValue;
|
||||
|
||||
// https://stackoverflow.com/questions/45393580
|
||||
if (defaultValue == null && parameterInfo.ParameterType.IsValueType)
|
||||
{
|
||||
defaultValue = parameterInfo.ParameterType.PseudoDefault();
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
return parameterInfo.UnderlyingParameterType().PseudoDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool AllowsNull(this ParameterInfo parameterInfo)
|
||||
{
|
||||
var type = parameterInfo.ParameterType;
|
||||
|
||||
return (type.IsReferenceType() && parameterInfo.HasAttribute<AllowsNullAttribute>()) || Nullable.GetUnderlyingType(type) != null;
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/30102174/
|
||||
public static bool HasOutModifier(this ParameterInfo parameterInfo)
|
||||
{
|
||||
Ensure.That(nameof(parameterInfo)).IsNotNull(parameterInfo);
|
||||
|
||||
// Checking for IsOut is not enough, because parameters marked with the [Out] attribute
|
||||
// also return true, while not necessarily having the "out" modifier. This is common for P/Invoke,
|
||||
// for example in Unity's ParticleSystem.GetParticles.
|
||||
return parameterInfo.IsOut && parameterInfo.ParameterType.IsByRef;
|
||||
}
|
||||
|
||||
public static bool CanWrite(this FieldInfo fieldInfo)
|
||||
{
|
||||
return !(fieldInfo.IsInitOnly || fieldInfo.IsLiteral);
|
||||
}
|
||||
|
||||
public static Member ToManipulator(this MemberInfo memberInfo)
|
||||
{
|
||||
return ToManipulator(memberInfo, memberInfo.DeclaringType);
|
||||
}
|
||||
|
||||
public static Member ToManipulator(this MemberInfo memberInfo, Type targetType)
|
||||
{
|
||||
if (memberInfo is FieldInfo fieldInfo)
|
||||
{
|
||||
return fieldInfo.ToManipulator(targetType);
|
||||
}
|
||||
|
||||
if (memberInfo is PropertyInfo propertyInfo)
|
||||
{
|
||||
return propertyInfo.ToManipulator(targetType);
|
||||
}
|
||||
|
||||
if (memberInfo is MethodInfo methodInfo)
|
||||
{
|
||||
return methodInfo.ToManipulator(targetType);
|
||||
}
|
||||
|
||||
if (memberInfo is ConstructorInfo constructorInfo)
|
||||
{
|
||||
return constructorInfo.ToManipulator(targetType);
|
||||
}
|
||||
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
public static Member ToManipulator(this FieldInfo fieldInfo, Type targetType)
|
||||
{
|
||||
return new Member(targetType, fieldInfo);
|
||||
}
|
||||
|
||||
public static Member ToManipulator(this PropertyInfo propertyInfo, Type targetType)
|
||||
{
|
||||
return new Member(targetType, propertyInfo);
|
||||
}
|
||||
|
||||
public static Member ToManipulator(this MethodInfo methodInfo, Type targetType)
|
||||
{
|
||||
return new Member(targetType, methodInfo);
|
||||
}
|
||||
|
||||
public static Member ToManipulator(this ConstructorInfo constructorInfo, Type targetType)
|
||||
{
|
||||
return new Member(targetType, constructorInfo);
|
||||
}
|
||||
|
||||
public static ConstructorInfo GetConstructorAccepting(this Type type, Type[] paramTypes, bool nonPublic)
|
||||
{
|
||||
var bindingFlags = BindingFlags.Instance | BindingFlags.Public;
|
||||
|
||||
if (nonPublic)
|
||||
{
|
||||
bindingFlags |= BindingFlags.NonPublic;
|
||||
}
|
||||
|
||||
return type
|
||||
.GetConstructors(bindingFlags)
|
||||
.FirstOrDefault(constructor =>
|
||||
{
|
||||
var parameters = constructor.GetParameters();
|
||||
|
||||
if (parameters.Length != paramTypes.Length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var i = 0; i < parameters.Length; i++)
|
||||
{
|
||||
if (paramTypes[i] == null)
|
||||
{
|
||||
if (!parameters[i].ParameterType.IsNullable())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!parameters[i].ParameterType.IsAssignableFrom(paramTypes[i]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
public static ConstructorInfo GetConstructorAccepting(this Type type, params Type[] paramTypes)
|
||||
{
|
||||
return GetConstructorAccepting(type, paramTypes, true);
|
||||
}
|
||||
|
||||
public static ConstructorInfo GetPublicConstructorAccepting(this Type type, params Type[] paramTypes)
|
||||
{
|
||||
return GetConstructorAccepting(type, paramTypes, false);
|
||||
}
|
||||
|
||||
public static ConstructorInfo GetDefaultConstructor(this Type type)
|
||||
{
|
||||
return GetConstructorAccepting(type);
|
||||
}
|
||||
|
||||
public static ConstructorInfo GetPublicDefaultConstructor(this Type type)
|
||||
{
|
||||
return GetPublicConstructorAccepting(type);
|
||||
}
|
||||
|
||||
public static MemberInfo[] GetExtendedMember(this Type type, string name, MemberTypes types, BindingFlags flags)
|
||||
{
|
||||
var members = type.GetMember(name, types, flags).ToList();
|
||||
|
||||
if (types.HasFlag(MemberTypes.Method)) // Check for extension methods
|
||||
{
|
||||
members.AddRange(type.GetExtensionMethods()
|
||||
.Where(extension => extension.Name == name)
|
||||
.Cast<MemberInfo>());
|
||||
}
|
||||
|
||||
return members.ToArray();
|
||||
}
|
||||
|
||||
public static MemberInfo[] GetExtendedMembers(this Type type, BindingFlags flags)
|
||||
{
|
||||
var members = type.GetMembers(flags).ToHashSet();
|
||||
|
||||
foreach (var extensionMethod in type.GetExtensionMethods())
|
||||
{
|
||||
members.Add(extensionMethod);
|
||||
}
|
||||
|
||||
return members.ToArray();
|
||||
}
|
||||
|
||||
#region Signature Disambiguation
|
||||
|
||||
private static bool NameMatches(this MemberInfo member, string name)
|
||||
{
|
||||
return member.Name == name;
|
||||
}
|
||||
|
||||
private static bool ParametersMatch(this MethodBase methodBase, IEnumerable<Type> parameterTypes, bool invokeAsExtension)
|
||||
{
|
||||
Ensure.That(nameof(parameterTypes)).IsNotNull(parameterTypes);
|
||||
|
||||
return methodBase.GetInvocationParameters(invokeAsExtension).Select(paramInfo => paramInfo.ParameterType).SequenceEqual(parameterTypes);
|
||||
}
|
||||
|
||||
private static bool GenericArgumentsMatch(this MethodInfo method, IEnumerable<Type> genericArgumentTypes)
|
||||
{
|
||||
Ensure.That(nameof(genericArgumentTypes)).IsNotNull(genericArgumentTypes);
|
||||
|
||||
if (method.ContainsGenericParameters)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return method.GetGenericArguments().SequenceEqual(genericArgumentTypes);
|
||||
}
|
||||
|
||||
public static bool SignatureMatches(this FieldInfo field, string name)
|
||||
{
|
||||
return field.NameMatches(name);
|
||||
}
|
||||
|
||||
public static bool SignatureMatches(this PropertyInfo property, string name)
|
||||
{
|
||||
return property.NameMatches(name);
|
||||
}
|
||||
|
||||
public static bool SignatureMatches(this ConstructorInfo constructor, string name, IEnumerable<Type> parameterTypes)
|
||||
{
|
||||
return constructor.NameMatches(name) && constructor.ParametersMatch(parameterTypes, false);
|
||||
}
|
||||
|
||||
public static bool SignatureMatches(this MethodInfo method, string name, IEnumerable<Type> parameterTypes, bool invokeAsExtension)
|
||||
{
|
||||
return method.NameMatches(name) && method.ParametersMatch(parameterTypes, invokeAsExtension) && !method.ContainsGenericParameters;
|
||||
}
|
||||
|
||||
public static bool SignatureMatches(this MethodInfo method, string name, IEnumerable<Type> parameterTypes, IEnumerable<Type> genericArgumentTypes, bool invokeAsExtension)
|
||||
{
|
||||
return method.NameMatches(name) && method.ParametersMatch(parameterTypes, invokeAsExtension) && method.GenericArgumentsMatch(genericArgumentTypes);
|
||||
}
|
||||
|
||||
public static FieldInfo GetFieldUnambiguous(this Type type, string name, BindingFlags flags)
|
||||
{
|
||||
Ensure.That(nameof(type)).IsNotNull(type);
|
||||
Ensure.That(nameof(name)).IsNotNull(name);
|
||||
|
||||
flags |= BindingFlags.DeclaredOnly;
|
||||
|
||||
while (type != null)
|
||||
{
|
||||
var field = type.GetField(name, flags);
|
||||
|
||||
if (field != null)
|
||||
{
|
||||
return field;
|
||||
}
|
||||
|
||||
type = type.BaseType;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static PropertyInfo GetPropertyUnambiguous(this Type type, string name, BindingFlags flags)
|
||||
{
|
||||
Ensure.That(nameof(type)).IsNotNull(type);
|
||||
Ensure.That(nameof(name)).IsNotNull(name);
|
||||
|
||||
flags |= BindingFlags.DeclaredOnly;
|
||||
|
||||
while (type != null)
|
||||
{
|
||||
var property = type.GetProperty(name, flags);
|
||||
|
||||
if (property != null)
|
||||
{
|
||||
return property;
|
||||
}
|
||||
|
||||
type = type.BaseType;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static MethodInfo GetMethodUnambiguous(this Type type, string name, BindingFlags flags)
|
||||
{
|
||||
Ensure.That(nameof(type)).IsNotNull(type);
|
||||
Ensure.That(nameof(name)).IsNotNull(name);
|
||||
|
||||
flags |= BindingFlags.DeclaredOnly;
|
||||
|
||||
while (type != null)
|
||||
{
|
||||
var method = type.GetMethod(name, flags);
|
||||
|
||||
if (method != null)
|
||||
{
|
||||
return method;
|
||||
}
|
||||
|
||||
type = type.BaseType;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static TMemberInfo DisambiguateHierarchy<TMemberInfo>(this IEnumerable<TMemberInfo> members, Type type) where TMemberInfo : MemberInfo
|
||||
{
|
||||
while (type != null)
|
||||
{
|
||||
foreach (var member in members)
|
||||
{
|
||||
var methodInfo = member as MethodInfo;
|
||||
var invokedAsExtension = methodInfo != null && methodInfo.IsInvokedAsExtension(type);
|
||||
|
||||
if (member.ExtendedDeclaringType(invokedAsExtension) == type)
|
||||
{
|
||||
return member;
|
||||
}
|
||||
}
|
||||
|
||||
type = type.BaseType;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static FieldInfo Disambiguate(this IEnumerable<FieldInfo> fields, Type type)
|
||||
{
|
||||
Ensure.That(nameof(fields)).IsNotNull(fields);
|
||||
Ensure.That(nameof(type)).IsNotNull(type);
|
||||
|
||||
return fields.DisambiguateHierarchy(type);
|
||||
}
|
||||
|
||||
public static PropertyInfo Disambiguate(this IEnumerable<PropertyInfo> properties, Type type)
|
||||
{
|
||||
Ensure.That(nameof(properties)).IsNotNull(properties);
|
||||
Ensure.That(nameof(type)).IsNotNull(type);
|
||||
|
||||
return properties.DisambiguateHierarchy(type);
|
||||
}
|
||||
|
||||
public static ConstructorInfo Disambiguate(this IEnumerable<ConstructorInfo> constructors, Type type, IEnumerable<Type> parameterTypes)
|
||||
{
|
||||
Ensure.That(nameof(constructors)).IsNotNull(constructors);
|
||||
Ensure.That(nameof(type)).IsNotNull(type);
|
||||
Ensure.That(nameof(parameterTypes)).IsNotNull(parameterTypes);
|
||||
|
||||
return constructors.Where(m => m.ParametersMatch(parameterTypes, false) && !m.ContainsGenericParameters).DisambiguateHierarchy(type);
|
||||
}
|
||||
|
||||
public static MethodInfo Disambiguate(this IEnumerable<MethodInfo> methods, Type type, IEnumerable<Type> parameterTypes)
|
||||
{
|
||||
Ensure.That(nameof(methods)).IsNotNull(methods);
|
||||
Ensure.That(nameof(type)).IsNotNull(type);
|
||||
Ensure.That(nameof(parameterTypes)).IsNotNull(parameterTypes);
|
||||
|
||||
return methods.Where(m => m.ParametersMatch(parameterTypes, m.IsInvokedAsExtension(type)) && !m.ContainsGenericParameters).DisambiguateHierarchy(type);
|
||||
}
|
||||
|
||||
public static MethodInfo Disambiguate(this IEnumerable<MethodInfo> methods, Type type, IEnumerable<Type> parameterTypes, IEnumerable<Type> genericArgumentTypes)
|
||||
{
|
||||
Ensure.That(nameof(methods)).IsNotNull(methods);
|
||||
Ensure.That(nameof(type)).IsNotNull(type);
|
||||
Ensure.That(nameof(parameterTypes)).IsNotNull(parameterTypes);
|
||||
Ensure.That(nameof(genericArgumentTypes)).IsNotNull(genericArgumentTypes);
|
||||
|
||||
return methods.Where(m => m.ParametersMatch(parameterTypes, m.IsInvokedAsExtension(type)) && m.GenericArgumentsMatch(genericArgumentTypes)).DisambiguateHierarchy(type);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e6d26ae946da54f7494be766b3890929
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,172 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public sealed class Namespace
|
||||
{
|
||||
private Namespace(string fullName)
|
||||
{
|
||||
FullName = fullName;
|
||||
|
||||
if (fullName != null)
|
||||
{
|
||||
var parts = fullName.Split('.');
|
||||
|
||||
Name = parts[parts.Length - 1];
|
||||
|
||||
if (parts.Length > 1)
|
||||
{
|
||||
Root = parts[0];
|
||||
Parent = fullName.Substring(0, fullName.LastIndexOf('.'));
|
||||
}
|
||||
else
|
||||
{
|
||||
Root = this;
|
||||
IsRoot = true;
|
||||
Parent = Global;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Root = this;
|
||||
IsRoot = true;
|
||||
IsGlobal = true;
|
||||
}
|
||||
}
|
||||
|
||||
public Namespace Root { get; }
|
||||
public Namespace Parent { get; }
|
||||
public string FullName { get; }
|
||||
public string Name { get; }
|
||||
public bool IsRoot { get; }
|
||||
public bool IsGlobal { get; }
|
||||
|
||||
public IEnumerable<Namespace> Ancestors
|
||||
{
|
||||
get
|
||||
{
|
||||
var ancestor = Parent;
|
||||
|
||||
while (ancestor != null)
|
||||
{
|
||||
yield return ancestor;
|
||||
ancestor = ancestor.Parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Namespace> AndAncestors()
|
||||
{
|
||||
yield return this;
|
||||
|
||||
foreach (var ancestor in Ancestors)
|
||||
{
|
||||
yield return ancestor;
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
if (FullName == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return FullName.GetHashCode();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return FullName;
|
||||
}
|
||||
|
||||
static Namespace()
|
||||
{
|
||||
collection = new Collection();
|
||||
}
|
||||
|
||||
private static readonly Collection collection;
|
||||
|
||||
public static Namespace Global { get; } = new Namespace(null);
|
||||
|
||||
public static Namespace FromFullName(string fullName)
|
||||
{
|
||||
if (fullName == null)
|
||||
{
|
||||
return Global;
|
||||
}
|
||||
|
||||
Namespace @namespace;
|
||||
|
||||
if (!collection.TryGetValue(fullName, out @namespace))
|
||||
{
|
||||
@namespace = new Namespace(fullName);
|
||||
collection.Add(@namespace);
|
||||
}
|
||||
|
||||
return @namespace;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var other = obj as Namespace;
|
||||
|
||||
if (other == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return FullName == other.FullName;
|
||||
}
|
||||
|
||||
public static implicit operator Namespace(string fullName)
|
||||
{
|
||||
return FromFullName(fullName);
|
||||
}
|
||||
|
||||
public static implicit operator string(Namespace @namespace)
|
||||
{
|
||||
return @namespace.FullName;
|
||||
}
|
||||
|
||||
public static bool operator ==(Namespace a, Namespace b)
|
||||
{
|
||||
if (ReferenceEquals(a, b))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (((object)a == null) || ((object)b == null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return a.Equals(b);
|
||||
}
|
||||
|
||||
public static bool operator !=(Namespace a, Namespace b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
private class Collection : KeyedCollection<string, Namespace>, IKeyedCollection<string, Namespace>
|
||||
{
|
||||
protected override string GetKeyForItem(Namespace item)
|
||||
{
|
||||
return item.FullName;
|
||||
}
|
||||
|
||||
public bool TryGetValue(string key, out Namespace value)
|
||||
{
|
||||
if (Dictionary == null)
|
||||
{
|
||||
value = default(Namespace);
|
||||
return false;
|
||||
}
|
||||
|
||||
return Dictionary.TryGetValue(key, out value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6e8a02b6685f943eebed45a65b807ab8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 752758c2ce0fa4f74b80a07dc04cf745
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,150 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public sealed class AdditionHandler : BinaryOperatorHandler
|
||||
{
|
||||
public AdditionHandler() : base("Addition", "Add", "+", "op_Addition")
|
||||
{
|
||||
Handle<byte, byte>((a, b) => a + b);
|
||||
Handle<byte, sbyte>((a, b) => a + b);
|
||||
Handle<byte, short>((a, b) => a + b);
|
||||
Handle<byte, ushort>((a, b) => a + b);
|
||||
Handle<byte, int>((a, b) => a + b);
|
||||
Handle<byte, uint>((a, b) => a + b);
|
||||
Handle<byte, long>((a, b) => a + b);
|
||||
Handle<byte, ulong>((a, b) => a + b);
|
||||
Handle<byte, float>((a, b) => a + b);
|
||||
Handle<byte, decimal>((a, b) => a + b);
|
||||
Handle<byte, double>((a, b) => a + b);
|
||||
|
||||
Handle<sbyte, byte>((a, b) => a + b);
|
||||
Handle<sbyte, sbyte>((a, b) => a + b);
|
||||
Handle<sbyte, short>((a, b) => a + b);
|
||||
Handle<sbyte, ushort>((a, b) => a + b);
|
||||
Handle<sbyte, int>((a, b) => a + b);
|
||||
Handle<sbyte, uint>((a, b) => a + b);
|
||||
Handle<sbyte, long>((a, b) => a + b);
|
||||
//Handle<sbyte, ulong>((a, b) => a + b);
|
||||
Handle<sbyte, float>((a, b) => a + b);
|
||||
Handle<sbyte, decimal>((a, b) => a + b);
|
||||
Handle<sbyte, double>((a, b) => a + b);
|
||||
|
||||
Handle<short, byte>((a, b) => a + b);
|
||||
Handle<short, sbyte>((a, b) => a + b);
|
||||
Handle<short, short>((a, b) => a + b);
|
||||
Handle<short, ushort>((a, b) => a + b);
|
||||
Handle<short, int>((a, b) => a + b);
|
||||
Handle<short, uint>((a, b) => a + b);
|
||||
Handle<short, long>((a, b) => a + b);
|
||||
//Handle<short, ulong>((a, b) => a + b);
|
||||
Handle<short, float>((a, b) => a + b);
|
||||
Handle<short, decimal>((a, b) => a + b);
|
||||
Handle<short, double>((a, b) => a + b);
|
||||
|
||||
Handle<ushort, byte>((a, b) => a + b);
|
||||
Handle<ushort, sbyte>((a, b) => a + b);
|
||||
Handle<ushort, short>((a, b) => a + b);
|
||||
Handle<ushort, ushort>((a, b) => a + b);
|
||||
Handle<ushort, int>((a, b) => a + b);
|
||||
Handle<ushort, uint>((a, b) => a + b);
|
||||
Handle<ushort, long>((a, b) => a + b);
|
||||
Handle<ushort, ulong>((a, b) => a + b);
|
||||
Handle<ushort, float>((a, b) => a + b);
|
||||
Handle<ushort, decimal>((a, b) => a + b);
|
||||
Handle<ushort, double>((a, b) => a + b);
|
||||
|
||||
Handle<int, byte>((a, b) => a + b);
|
||||
Handle<int, sbyte>((a, b) => a + b);
|
||||
Handle<int, short>((a, b) => a + b);
|
||||
Handle<int, ushort>((a, b) => a + b);
|
||||
Handle<int, int>((a, b) => a + b);
|
||||
Handle<int, uint>((a, b) => a + b);
|
||||
Handle<int, long>((a, b) => a + b);
|
||||
//Handle<int, ulong>((a, b) => a + b);
|
||||
Handle<int, float>((a, b) => a + b);
|
||||
Handle<int, decimal>((a, b) => a + b);
|
||||
Handle<int, double>((a, b) => a + b);
|
||||
|
||||
Handle<uint, byte>((a, b) => a + b);
|
||||
Handle<uint, sbyte>((a, b) => a + b);
|
||||
Handle<uint, short>((a, b) => a + b);
|
||||
Handle<uint, ushort>((a, b) => a + b);
|
||||
Handle<uint, int>((a, b) => a + b);
|
||||
Handle<uint, uint>((a, b) => a + b);
|
||||
Handle<uint, long>((a, b) => a + b);
|
||||
Handle<uint, ulong>((a, b) => a + b);
|
||||
Handle<uint, float>((a, b) => a + b);
|
||||
Handle<uint, decimal>((a, b) => a + b);
|
||||
Handle<uint, double>((a, b) => a + b);
|
||||
|
||||
Handle<long, byte>((a, b) => a + b);
|
||||
Handle<long, sbyte>((a, b) => a + b);
|
||||
Handle<long, short>((a, b) => a + b);
|
||||
Handle<long, ushort>((a, b) => a + b);
|
||||
Handle<long, int>((a, b) => a + b);
|
||||
Handle<long, uint>((a, b) => a + b);
|
||||
Handle<long, long>((a, b) => a + b);
|
||||
//Handle<long, ulong>((a, b) => a + b);
|
||||
Handle<long, float>((a, b) => a + b);
|
||||
Handle<long, decimal>((a, b) => a + b);
|
||||
Handle<long, double>((a, b) => a + b);
|
||||
|
||||
Handle<ulong, byte>((a, b) => a + b);
|
||||
//Handle<ulong, sbyte>((a, b) => a + b);
|
||||
//Handle<ulong, short>((a, b) => a + b);
|
||||
Handle<ulong, ushort>((a, b) => a + b);
|
||||
//Handle<ulong, int>((a, b) => a + b);
|
||||
Handle<ulong, uint>((a, b) => a + b);
|
||||
//Handle<ulong, long>((a, b) => a + b);
|
||||
Handle<ulong, ulong>((a, b) => a + b);
|
||||
Handle<ulong, float>((a, b) => a + b);
|
||||
Handle<ulong, decimal>((a, b) => a + b);
|
||||
Handle<ulong, double>((a, b) => a + b);
|
||||
|
||||
Handle<float, byte>((a, b) => a + b);
|
||||
Handle<float, sbyte>((a, b) => a + b);
|
||||
Handle<float, short>((a, b) => a + b);
|
||||
Handle<float, ushort>((a, b) => a + b);
|
||||
Handle<float, int>((a, b) => a + b);
|
||||
Handle<float, uint>((a, b) => a + b);
|
||||
Handle<float, long>((a, b) => a + b);
|
||||
Handle<float, ulong>((a, b) => a + b);
|
||||
Handle<float, float>((a, b) => a + b);
|
||||
//Handle<float, decimal>((a, b) => a + b);
|
||||
Handle<float, double>((a, b) => a + b);
|
||||
|
||||
Handle<decimal, byte>((a, b) => a + b);
|
||||
Handle<decimal, sbyte>((a, b) => a + b);
|
||||
Handle<decimal, short>((a, b) => a + b);
|
||||
Handle<decimal, ushort>((a, b) => a + b);
|
||||
Handle<decimal, int>((a, b) => a + b);
|
||||
Handle<decimal, uint>((a, b) => a + b);
|
||||
Handle<decimal, long>((a, b) => a + b);
|
||||
Handle<decimal, ulong>((a, b) => a + b);
|
||||
//Handle<decimal, float>((a, b) => a + b);
|
||||
Handle<decimal, decimal>((a, b) => a + b);
|
||||
//Handle<decimal, double>((a, b) => a + b);
|
||||
|
||||
Handle<double, byte>((a, b) => a + b);
|
||||
Handle<double, sbyte>((a, b) => a + b);
|
||||
Handle<double, short>((a, b) => a + b);
|
||||
Handle<double, ushort>((a, b) => a + b);
|
||||
Handle<double, int>((a, b) => a + b);
|
||||
Handle<double, uint>((a, b) => a + b);
|
||||
Handle<double, long>((a, b) => a + b);
|
||||
Handle<double, ulong>((a, b) => a + b);
|
||||
Handle<double, float>((a, b) => a + b);
|
||||
//Handle<double, decimal>((a, b) => a + b);
|
||||
Handle<double, double>((a, b) => a + b);
|
||||
}
|
||||
|
||||
protected override object CustomHandling(object leftOperand, object rightOperand)
|
||||
{
|
||||
if (leftOperand is string || rightOperand is string)
|
||||
{
|
||||
return string.Concat(leftOperand, rightOperand);
|
||||
}
|
||||
|
||||
return base.CustomHandling(leftOperand, rightOperand);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f91a5b4b54ffb45f8a76cfa80c26b799
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
using System;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public sealed class AmbiguousOperatorException : OperatorException
|
||||
{
|
||||
public AmbiguousOperatorException(string symbol, Type leftType, Type rightType) : base($"Ambiguous use of operator '{symbol}' between types '{leftType?.ToString() ?? "null"}' and '{rightType?.ToString() ?? "null"}'.") { }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 440712d4b1f8a4163805ea5af7bca155
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,82 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public class AndHandler : BinaryOperatorHandler
|
||||
{
|
||||
public AndHandler() : base("And", "And", "&", "op_BitwiseAnd")
|
||||
{
|
||||
Handle<bool, bool>((a, b) => a & b);
|
||||
|
||||
Handle<byte, byte>((a, b) => a & b);
|
||||
Handle<byte, sbyte>((a, b) => a & b);
|
||||
Handle<byte, short>((a, b) => a & b);
|
||||
Handle<byte, ushort>((a, b) => a & b);
|
||||
Handle<byte, int>((a, b) => a & b);
|
||||
Handle<byte, uint>((a, b) => a & b);
|
||||
Handle<byte, long>((a, b) => a & b);
|
||||
Handle<byte, ulong>((a, b) => a & b);
|
||||
|
||||
Handle<sbyte, byte>((a, b) => a & b);
|
||||
Handle<sbyte, sbyte>((a, b) => a & b);
|
||||
Handle<sbyte, short>((a, b) => a & b);
|
||||
Handle<sbyte, ushort>((a, b) => a & b);
|
||||
Handle<sbyte, int>((a, b) => a & b);
|
||||
Handle<sbyte, uint>((a, b) => a & b);
|
||||
Handle<sbyte, long>((a, b) => a & b);
|
||||
//Handle<sbyte, ulong>((a, b) => a & b);
|
||||
|
||||
Handle<short, byte>((a, b) => a & b);
|
||||
Handle<short, sbyte>((a, b) => a & b);
|
||||
Handle<short, short>((a, b) => a & b);
|
||||
Handle<short, ushort>((a, b) => a & b);
|
||||
Handle<short, int>((a, b) => a & b);
|
||||
Handle<short, uint>((a, b) => a & b);
|
||||
Handle<short, long>((a, b) => a & b);
|
||||
//Handle<short, ulong>((a, b) => a & b);
|
||||
|
||||
Handle<ushort, byte>((a, b) => a & b);
|
||||
Handle<ushort, sbyte>((a, b) => a & b);
|
||||
Handle<ushort, short>((a, b) => a & b);
|
||||
Handle<ushort, ushort>((a, b) => a & b);
|
||||
Handle<ushort, int>((a, b) => a & b);
|
||||
Handle<ushort, uint>((a, b) => a & b);
|
||||
Handle<ushort, long>((a, b) => a & b);
|
||||
Handle<ushort, ulong>((a, b) => a & b);
|
||||
|
||||
Handle<int, byte>((a, b) => a & b);
|
||||
Handle<int, sbyte>((a, b) => a & b);
|
||||
Handle<int, short>((a, b) => a & b);
|
||||
Handle<int, ushort>((a, b) => a & b);
|
||||
Handle<int, int>((a, b) => a & b);
|
||||
Handle<int, uint>((a, b) => a & b);
|
||||
Handle<int, long>((a, b) => a & b);
|
||||
//Handle<int, ulong>((a, b) => a & b);
|
||||
|
||||
Handle<uint, byte>((a, b) => a & b);
|
||||
Handle<uint, sbyte>((a, b) => a & b);
|
||||
Handle<uint, short>((a, b) => a & b);
|
||||
Handle<uint, ushort>((a, b) => a & b);
|
||||
Handle<uint, int>((a, b) => a & b);
|
||||
Handle<uint, uint>((a, b) => a & b);
|
||||
Handle<uint, long>((a, b) => a & b);
|
||||
Handle<uint, ulong>((a, b) => a & b);
|
||||
|
||||
Handle<long, byte>((a, b) => a & b);
|
||||
Handle<long, sbyte>((a, b) => a & b);
|
||||
Handle<long, short>((a, b) => a & b);
|
||||
Handle<long, ushort>((a, b) => a & b);
|
||||
Handle<long, int>((a, b) => a & b);
|
||||
Handle<long, uint>((a, b) => a & b);
|
||||
Handle<long, long>((a, b) => a & b);
|
||||
//Handle<long, ulong>((a, b) => a & b);
|
||||
|
||||
Handle<ulong, byte>((a, b) => a & b);
|
||||
//Handle<ulong, sbyte>((a, b) => a & b);
|
||||
//Handle<ulong, short>((a, b) => a & b);
|
||||
Handle<ulong, ushort>((a, b) => a & b);
|
||||
//Handle<ulong, int>((a, b) => a & b);
|
||||
Handle<ulong, uint>((a, b) => a & b);
|
||||
//Handle<ulong, long>((a, b) => a & b);
|
||||
Handle<ulong, ulong>((a, b) => a & b);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f7eff71d2342343c3985596ad46e6480
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,22 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public enum BinaryOperator
|
||||
{
|
||||
Addition,
|
||||
Subtraction,
|
||||
Multiplication,
|
||||
Division,
|
||||
Modulo,
|
||||
And,
|
||||
Or,
|
||||
ExclusiveOr,
|
||||
Equality,
|
||||
Inequality,
|
||||
GreaterThan,
|
||||
LessThan,
|
||||
GreaterThanOrEqual,
|
||||
LessThanOrEqual,
|
||||
LeftShift,
|
||||
RightShift,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 188a1e0187f434d3380b492642a43320
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,180 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public abstract class BinaryOperatorHandler : OperatorHandler
|
||||
{
|
||||
protected BinaryOperatorHandler(string name, string verb, string symbol, string customMethodName)
|
||||
: base(name, verb, symbol, customMethodName) { }
|
||||
|
||||
private readonly Dictionary<OperatorQuery, Func<object, object, object>> handlers = new Dictionary<OperatorQuery, Func<object, object, object>>();
|
||||
private readonly Dictionary<OperatorQuery, IOptimizedInvoker> userDefinedOperators = new Dictionary<OperatorQuery, IOptimizedInvoker>();
|
||||
private readonly Dictionary<OperatorQuery, OperatorQuery> userDefinedOperandTypes = new Dictionary<OperatorQuery, OperatorQuery>();
|
||||
|
||||
public virtual object Operate(object leftOperand, object rightOperand)
|
||||
{
|
||||
OperatorQuery query;
|
||||
|
||||
var leftType = leftOperand?.GetType();
|
||||
var rightType = rightOperand?.GetType();
|
||||
|
||||
if (leftType != null && rightType != null)
|
||||
{
|
||||
query = new OperatorQuery(leftType, rightType);
|
||||
}
|
||||
else if (leftType != null && leftType.IsNullable())
|
||||
{
|
||||
query = new OperatorQuery(leftType, leftType);
|
||||
}
|
||||
else if (rightType != null && rightType.IsNullable())
|
||||
{
|
||||
query = new OperatorQuery(rightType, rightType);
|
||||
}
|
||||
else if (leftType == null && rightType == null)
|
||||
{
|
||||
return BothNullHandling();
|
||||
}
|
||||
else
|
||||
{
|
||||
return SingleNullHandling();
|
||||
}
|
||||
|
||||
if (handlers.ContainsKey(query))
|
||||
{
|
||||
return handlers[query](leftOperand, rightOperand);
|
||||
}
|
||||
|
||||
if (customMethodName != null)
|
||||
{
|
||||
if (!userDefinedOperators.ContainsKey(query))
|
||||
{
|
||||
var leftMethod = query.leftType.GetMethod(customMethodName, BindingFlags.Public | BindingFlags.Static, null, new[] { query.leftType, query.rightType }, null);
|
||||
|
||||
if (query.leftType != query.rightType)
|
||||
{
|
||||
var rightMethod = query.rightType.GetMethod(customMethodName, BindingFlags.Public | BindingFlags.Static, null, new[] { query.leftType, query.rightType }, null);
|
||||
|
||||
if (leftMethod != null && rightMethod != null)
|
||||
{
|
||||
throw new AmbiguousOperatorException(symbol, query.leftType, query.rightType);
|
||||
}
|
||||
|
||||
var method = (leftMethod ?? rightMethod);
|
||||
|
||||
if (method != null)
|
||||
{
|
||||
userDefinedOperandTypes.Add(query, ResolveUserDefinedOperandTypes(method));
|
||||
}
|
||||
|
||||
userDefinedOperators.Add(query, method?.Prewarm());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (leftMethod != null)
|
||||
{
|
||||
userDefinedOperandTypes.Add(query, ResolveUserDefinedOperandTypes(leftMethod));
|
||||
}
|
||||
|
||||
userDefinedOperators.Add(query, leftMethod?.Prewarm());
|
||||
}
|
||||
}
|
||||
|
||||
if (userDefinedOperators[query] != null)
|
||||
{
|
||||
leftOperand = ConversionUtility.Convert(leftOperand, userDefinedOperandTypes[query].leftType);
|
||||
rightOperand = ConversionUtility.Convert(rightOperand, userDefinedOperandTypes[query].rightType);
|
||||
|
||||
return userDefinedOperators[query].Invoke(null, leftOperand, rightOperand);
|
||||
}
|
||||
}
|
||||
|
||||
return CustomHandling(leftOperand, rightOperand);
|
||||
}
|
||||
|
||||
protected virtual object CustomHandling(object leftOperand, object rightOperand)
|
||||
{
|
||||
throw new InvalidOperatorException(symbol, leftOperand?.GetType(), rightOperand?.GetType());
|
||||
}
|
||||
|
||||
protected virtual object BothNullHandling()
|
||||
{
|
||||
throw new InvalidOperatorException(symbol, null, null);
|
||||
}
|
||||
|
||||
protected virtual object SingleNullHandling()
|
||||
{
|
||||
throw new InvalidOperatorException(symbol, null, null);
|
||||
}
|
||||
|
||||
protected void Handle<TLeft, TRight>(Func<TLeft, TRight, object> handler, bool reverse = false)
|
||||
{
|
||||
var query = new OperatorQuery(typeof(TLeft), typeof(TRight));
|
||||
|
||||
if (handlers.ContainsKey(query))
|
||||
{
|
||||
throw new ArgumentException($"A handler is already registered for '{typeof(TLeft)} {symbol} {typeof(TRight)}'.");
|
||||
}
|
||||
|
||||
handlers.Add(query, (left, right) => handler((TLeft)left, (TRight)right));
|
||||
|
||||
if (reverse && typeof(TLeft) != typeof(TRight))
|
||||
{
|
||||
var reverseQuery = new OperatorQuery(typeof(TRight), typeof(TLeft));
|
||||
|
||||
if (!handlers.ContainsKey(reverseQuery))
|
||||
{
|
||||
handlers.Add(reverseQuery, (left, right) => handler((TLeft)left, (TRight)right));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static OperatorQuery ResolveUserDefinedOperandTypes(MethodInfo userDefinedOperator)
|
||||
{
|
||||
// We will need to convert the operands to the argument types,
|
||||
// because .NET is actually permissive of implicit conversion
|
||||
// in its GetMethod calls. For example, an operator requiring
|
||||
// a float operand will accept an int. However, our optimized
|
||||
// reflection code is more strict, and will only accept the
|
||||
// exact type, hence why we need to manually store the expected
|
||||
// parameter types here to convert them later.
|
||||
var parameters = userDefinedOperator.GetParameters();
|
||||
return new OperatorQuery(parameters[0].ParameterType, parameters[1].ParameterType);
|
||||
}
|
||||
|
||||
private struct OperatorQuery : IEquatable<OperatorQuery>
|
||||
{
|
||||
public readonly Type leftType;
|
||||
public readonly Type rightType;
|
||||
|
||||
public OperatorQuery(Type leftType, Type rightType)
|
||||
{
|
||||
this.leftType = leftType;
|
||||
this.rightType = rightType;
|
||||
}
|
||||
|
||||
public bool Equals(OperatorQuery other)
|
||||
{
|
||||
return
|
||||
leftType == other.leftType &&
|
||||
rightType == other.rightType;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is OperatorQuery))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return Equals((OperatorQuery)obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashUtility.GetHashCode(leftType, rightType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bb87afcd70abd4879b116234b7d3667b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,20 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public sealed class DecrementHandler : UnaryOperatorHandler
|
||||
{
|
||||
public DecrementHandler() : base("Decrement", "Decrement", "--", "op_Decrement")
|
||||
{
|
||||
Handle<byte>(a => --a);
|
||||
Handle<sbyte>(a => --a);
|
||||
Handle<short>(a => --a);
|
||||
Handle<ushort>(a => --a);
|
||||
Handle<int>(a => --a);
|
||||
Handle<uint>(a => --a);
|
||||
Handle<long>(a => --a);
|
||||
Handle<ulong>(a => --a);
|
||||
Handle<float>(a => --a);
|
||||
Handle<decimal>(a => --a);
|
||||
Handle<double>(a => --a);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1b7bec94ee62948d38a0ec6c2ffb8dab
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,140 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public sealed class DivisionHandler : BinaryOperatorHandler
|
||||
{
|
||||
public DivisionHandler() : base("Division", "Divide", "/", "op_Division")
|
||||
{
|
||||
Handle<byte, byte>((a, b) => a / b);
|
||||
Handle<byte, sbyte>((a, b) => a / b);
|
||||
Handle<byte, short>((a, b) => a / b);
|
||||
Handle<byte, ushort>((a, b) => a / b);
|
||||
Handle<byte, int>((a, b) => a / b);
|
||||
Handle<byte, uint>((a, b) => a / b);
|
||||
Handle<byte, long>((a, b) => a / b);
|
||||
Handle<byte, ulong>((a, b) => a / b);
|
||||
Handle<byte, float>((a, b) => a / b);
|
||||
Handle<byte, decimal>((a, b) => a / b);
|
||||
Handle<byte, double>((a, b) => a / b);
|
||||
|
||||
Handle<sbyte, byte>((a, b) => a / b);
|
||||
Handle<sbyte, sbyte>((a, b) => a / b);
|
||||
Handle<sbyte, short>((a, b) => a / b);
|
||||
Handle<sbyte, ushort>((a, b) => a / b);
|
||||
Handle<sbyte, int>((a, b) => a / b);
|
||||
Handle<sbyte, uint>((a, b) => a / b);
|
||||
Handle<sbyte, long>((a, b) => a / b);
|
||||
//Handle<sbyte, ulong>((a, b) => a / b);
|
||||
Handle<sbyte, float>((a, b) => a / b);
|
||||
Handle<sbyte, decimal>((a, b) => a / b);
|
||||
Handle<sbyte, double>((a, b) => a / b);
|
||||
|
||||
Handle<short, byte>((a, b) => a / b);
|
||||
Handle<short, sbyte>((a, b) => a / b);
|
||||
Handle<short, short>((a, b) => a / b);
|
||||
Handle<short, ushort>((a, b) => a / b);
|
||||
Handle<short, int>((a, b) => a / b);
|
||||
Handle<short, uint>((a, b) => a / b);
|
||||
Handle<short, long>((a, b) => a / b);
|
||||
//Handle<short, ulong>((a, b) => a / b);
|
||||
Handle<short, float>((a, b) => a / b);
|
||||
Handle<short, decimal>((a, b) => a / b);
|
||||
Handle<short, double>((a, b) => a / b);
|
||||
|
||||
Handle<ushort, byte>((a, b) => a / b);
|
||||
Handle<ushort, sbyte>((a, b) => a / b);
|
||||
Handle<ushort, short>((a, b) => a / b);
|
||||
Handle<ushort, ushort>((a, b) => a / b);
|
||||
Handle<ushort, int>((a, b) => a / b);
|
||||
Handle<ushort, uint>((a, b) => a / b);
|
||||
Handle<ushort, long>((a, b) => a / b);
|
||||
Handle<ushort, ulong>((a, b) => a / b);
|
||||
Handle<ushort, float>((a, b) => a / b);
|
||||
Handle<ushort, decimal>((a, b) => a / b);
|
||||
Handle<ushort, double>((a, b) => a / b);
|
||||
|
||||
Handle<int, byte>((a, b) => a / b);
|
||||
Handle<int, sbyte>((a, b) => a / b);
|
||||
Handle<int, short>((a, b) => a / b);
|
||||
Handle<int, ushort>((a, b) => a / b);
|
||||
Handle<int, int>((a, b) => a / b);
|
||||
Handle<int, uint>((a, b) => a / b);
|
||||
Handle<int, long>((a, b) => a / b);
|
||||
//Handle<int, ulong>((a, b) => a / b);
|
||||
Handle<int, float>((a, b) => a / b);
|
||||
Handle<int, decimal>((a, b) => a / b);
|
||||
Handle<int, double>((a, b) => a / b);
|
||||
|
||||
Handle<uint, byte>((a, b) => a / b);
|
||||
Handle<uint, sbyte>((a, b) => a / b);
|
||||
Handle<uint, short>((a, b) => a / b);
|
||||
Handle<uint, ushort>((a, b) => a / b);
|
||||
Handle<uint, int>((a, b) => a / b);
|
||||
Handle<uint, uint>((a, b) => a / b);
|
||||
Handle<uint, long>((a, b) => a / b);
|
||||
Handle<uint, ulong>((a, b) => a / b);
|
||||
Handle<uint, float>((a, b) => a / b);
|
||||
Handle<uint, decimal>((a, b) => a / b);
|
||||
Handle<uint, double>((a, b) => a / b);
|
||||
|
||||
Handle<long, byte>((a, b) => a / b);
|
||||
Handle<long, sbyte>((a, b) => a / b);
|
||||
Handle<long, short>((a, b) => a / b);
|
||||
Handle<long, ushort>((a, b) => a / b);
|
||||
Handle<long, int>((a, b) => a / b);
|
||||
Handle<long, uint>((a, b) => a / b);
|
||||
Handle<long, long>((a, b) => a / b);
|
||||
//Handle<long, ulong>((a, b) => a / b);
|
||||
Handle<long, float>((a, b) => a / b);
|
||||
Handle<long, decimal>((a, b) => a / b);
|
||||
Handle<long, double>((a, b) => a / b);
|
||||
|
||||
Handle<ulong, byte>((a, b) => a / b);
|
||||
//Handle<ulong, sbyte>((a, b) => a / b);
|
||||
//Handle<ulong, short>((a, b) => a / b);
|
||||
Handle<ulong, ushort>((a, b) => a / b);
|
||||
//Handle<ulong, int>((a, b) => a / b);
|
||||
Handle<ulong, uint>((a, b) => a / b);
|
||||
//Handle<ulong, long>((a, b) => a / b);
|
||||
Handle<ulong, ulong>((a, b) => a / b);
|
||||
Handle<ulong, float>((a, b) => a / b);
|
||||
Handle<ulong, decimal>((a, b) => a / b);
|
||||
Handle<ulong, double>((a, b) => a / b);
|
||||
|
||||
Handle<float, byte>((a, b) => a / b);
|
||||
Handle<float, sbyte>((a, b) => a / b);
|
||||
Handle<float, short>((a, b) => a / b);
|
||||
Handle<float, ushort>((a, b) => a / b);
|
||||
Handle<float, int>((a, b) => a / b);
|
||||
Handle<float, uint>((a, b) => a / b);
|
||||
Handle<float, long>((a, b) => a / b);
|
||||
Handle<float, ulong>((a, b) => a / b);
|
||||
Handle<float, float>((a, b) => a / b);
|
||||
//Handle<float, decimal>((a, b) => a / b);
|
||||
Handle<float, double>((a, b) => a / b);
|
||||
|
||||
Handle<decimal, byte>((a, b) => a / b);
|
||||
Handle<decimal, sbyte>((a, b) => a / b);
|
||||
Handle<decimal, short>((a, b) => a / b);
|
||||
Handle<decimal, ushort>((a, b) => a / b);
|
||||
Handle<decimal, int>((a, b) => a / b);
|
||||
Handle<decimal, uint>((a, b) => a / b);
|
||||
Handle<decimal, long>((a, b) => a / b);
|
||||
Handle<decimal, ulong>((a, b) => a / b);
|
||||
//Handle<decimal, float>((a, b) => a / b);
|
||||
Handle<decimal, decimal>((a, b) => a / b);
|
||||
//Handle<decimal, double>((a, b) => a / b);
|
||||
|
||||
Handle<double, byte>((a, b) => a / b);
|
||||
Handle<double, sbyte>((a, b) => a / b);
|
||||
Handle<double, short>((a, b) => a / b);
|
||||
Handle<double, ushort>((a, b) => a / b);
|
||||
Handle<double, int>((a, b) => a / b);
|
||||
Handle<double, uint>((a, b) => a / b);
|
||||
Handle<double, long>((a, b) => a / b);
|
||||
Handle<double, ulong>((a, b) => a / b);
|
||||
Handle<double, float>((a, b) => a / b);
|
||||
//Handle<double, decimal>((a, b) => a / b);
|
||||
Handle<double, double>((a, b) => a / b);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: aaade9cbed5b4446fa6850d4f1ba05d6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,157 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public class EqualityHandler : BinaryOperatorHandler
|
||||
{
|
||||
public EqualityHandler() : base("Equality", "Equal", "==", "op_Equality")
|
||||
{
|
||||
Handle<byte, byte>((a, b) => a == b);
|
||||
Handle<byte, sbyte>((a, b) => a == b);
|
||||
Handle<byte, short>((a, b) => a == b);
|
||||
Handle<byte, ushort>((a, b) => a == b);
|
||||
Handle<byte, int>((a, b) => a == b);
|
||||
Handle<byte, uint>((a, b) => a == b);
|
||||
Handle<byte, long>((a, b) => a == b);
|
||||
Handle<byte, ulong>((a, b) => a == b);
|
||||
Handle<byte, float>((a, b) => a == b);
|
||||
Handle<byte, decimal>((a, b) => a == b);
|
||||
Handle<byte, double>((a, b) => a == b);
|
||||
|
||||
Handle<sbyte, byte>((a, b) => a == b);
|
||||
Handle<sbyte, sbyte>((a, b) => a == b);
|
||||
Handle<sbyte, short>((a, b) => a == b);
|
||||
Handle<sbyte, ushort>((a, b) => a == b);
|
||||
Handle<sbyte, int>((a, b) => a == b);
|
||||
Handle<sbyte, uint>((a, b) => a == b);
|
||||
Handle<sbyte, long>((a, b) => a == b);
|
||||
//Handle<sbyte, ulong>((a, b) => a == b);
|
||||
Handle<sbyte, float>((a, b) => a == b);
|
||||
Handle<sbyte, decimal>((a, b) => a == b);
|
||||
Handle<sbyte, double>((a, b) => a == b);
|
||||
|
||||
Handle<short, byte>((a, b) => a == b);
|
||||
Handle<short, sbyte>((a, b) => a == b);
|
||||
Handle<short, short>((a, b) => a == b);
|
||||
Handle<short, ushort>((a, b) => a == b);
|
||||
Handle<short, int>((a, b) => a == b);
|
||||
Handle<short, uint>((a, b) => a == b);
|
||||
Handle<short, long>((a, b) => a == b);
|
||||
//Handle<short, ulong>((a, b) => a == b);
|
||||
Handle<short, float>((a, b) => a == b);
|
||||
Handle<short, decimal>((a, b) => a == b);
|
||||
Handle<short, double>((a, b) => a == b);
|
||||
|
||||
Handle<ushort, byte>((a, b) => a == b);
|
||||
Handle<ushort, sbyte>((a, b) => a == b);
|
||||
Handle<ushort, short>((a, b) => a == b);
|
||||
Handle<ushort, ushort>((a, b) => a == b);
|
||||
Handle<ushort, int>((a, b) => a == b);
|
||||
Handle<ushort, uint>((a, b) => a == b);
|
||||
Handle<ushort, long>((a, b) => a == b);
|
||||
Handle<ushort, ulong>((a, b) => a == b);
|
||||
Handle<ushort, float>((a, b) => a == b);
|
||||
Handle<ushort, decimal>((a, b) => a == b);
|
||||
Handle<ushort, double>((a, b) => a == b);
|
||||
|
||||
Handle<int, byte>((a, b) => a == b);
|
||||
Handle<int, sbyte>((a, b) => a == b);
|
||||
Handle<int, short>((a, b) => a == b);
|
||||
Handle<int, ushort>((a, b) => a == b);
|
||||
Handle<int, int>((a, b) => a == b);
|
||||
Handle<int, uint>((a, b) => a == b);
|
||||
Handle<int, long>((a, b) => a == b);
|
||||
//Handle<int, ulong>((a, b) => a == b);
|
||||
Handle<int, float>((a, b) => a == b);
|
||||
Handle<int, decimal>((a, b) => a == b);
|
||||
Handle<int, double>((a, b) => a == b);
|
||||
|
||||
Handle<uint, byte>((a, b) => a == b);
|
||||
Handle<uint, sbyte>((a, b) => a == b);
|
||||
Handle<uint, short>((a, b) => a == b);
|
||||
Handle<uint, ushort>((a, b) => a == b);
|
||||
Handle<uint, int>((a, b) => a == b);
|
||||
Handle<uint, uint>((a, b) => a == b);
|
||||
Handle<uint, long>((a, b) => a == b);
|
||||
Handle<uint, ulong>((a, b) => a == b);
|
||||
Handle<uint, float>((a, b) => a == b);
|
||||
Handle<uint, decimal>((a, b) => a == b);
|
||||
Handle<uint, double>((a, b) => a == b);
|
||||
|
||||
Handle<long, byte>((a, b) => a == b);
|
||||
Handle<long, sbyte>((a, b) => a == b);
|
||||
Handle<long, short>((a, b) => a == b);
|
||||
Handle<long, ushort>((a, b) => a == b);
|
||||
Handle<long, int>((a, b) => a == b);
|
||||
Handle<long, uint>((a, b) => a == b);
|
||||
Handle<long, long>((a, b) => a == b);
|
||||
//Handle<long, ulong>((a, b) => a == b);
|
||||
Handle<long, float>((a, b) => a == b);
|
||||
Handle<long, decimal>((a, b) => a == b);
|
||||
Handle<long, double>((a, b) => a == b);
|
||||
|
||||
Handle<ulong, byte>((a, b) => a == b);
|
||||
//Handle<ulong, sbyte>((a, b) => a == b);
|
||||
//Handle<ulong, short>((a, b) => a == b);
|
||||
Handle<ulong, ushort>((a, b) => a == b);
|
||||
//Handle<ulong, int>((a, b) => a == b);
|
||||
Handle<ulong, uint>((a, b) => a == b);
|
||||
//Handle<ulong, long>((a, b) => a == b);
|
||||
Handle<ulong, ulong>((a, b) => a == b);
|
||||
Handle<ulong, float>((a, b) => a == b);
|
||||
Handle<ulong, decimal>((a, b) => a == b);
|
||||
Handle<ulong, double>((a, b) => a == b);
|
||||
|
||||
Handle<float, byte>((a, b) => a == b);
|
||||
Handle<float, sbyte>((a, b) => a == b);
|
||||
Handle<float, short>((a, b) => a == b);
|
||||
Handle<float, ushort>((a, b) => a == b);
|
||||
Handle<float, int>((a, b) => a == b);
|
||||
Handle<float, uint>((a, b) => a == b);
|
||||
Handle<float, long>((a, b) => a == b);
|
||||
Handle<float, ulong>((a, b) => a == b);
|
||||
Handle<float, float>((a, b) => Mathf.Approximately(a, b));
|
||||
//Handle<float, decimal>((a, b) => a == b);
|
||||
Handle<float, double>((a, b) => a == b);
|
||||
|
||||
Handle<decimal, byte>((a, b) => a == b);
|
||||
Handle<decimal, sbyte>((a, b) => a == b);
|
||||
Handle<decimal, short>((a, b) => a == b);
|
||||
Handle<decimal, ushort>((a, b) => a == b);
|
||||
Handle<decimal, int>((a, b) => a == b);
|
||||
Handle<decimal, uint>((a, b) => a == b);
|
||||
Handle<decimal, long>((a, b) => a == b);
|
||||
Handle<decimal, ulong>((a, b) => a == b);
|
||||
//Handle<decimal, float>((a, b) => a == b);
|
||||
Handle<decimal, decimal>((a, b) => a == b);
|
||||
//Handle<decimal, double>((a, b) => a == b);
|
||||
|
||||
Handle<double, byte>((a, b) => a == b);
|
||||
Handle<double, sbyte>((a, b) => a == b);
|
||||
Handle<double, short>((a, b) => a == b);
|
||||
Handle<double, ushort>((a, b) => a == b);
|
||||
Handle<double, int>((a, b) => a == b);
|
||||
Handle<double, uint>((a, b) => a == b);
|
||||
Handle<double, long>((a, b) => a == b);
|
||||
Handle<double, ulong>((a, b) => a == b);
|
||||
Handle<double, float>((a, b) => a == b);
|
||||
//Handle<double, decimal>((a, b) => a == b);
|
||||
Handle<double, double>((a, b) => a == b);
|
||||
}
|
||||
|
||||
protected override object BothNullHandling()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override object SingleNullHandling()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override object CustomHandling(object leftOperand, object rightOperand)
|
||||
{
|
||||
return Equals(leftOperand, rightOperand);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c5ed0c2a9c9654c51b429eb5ed2eed36
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,82 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public class ExclusiveOrHandler : BinaryOperatorHandler
|
||||
{
|
||||
public ExclusiveOrHandler() : base("Exclusive Or", "Exclusive Or", "^", "op_ExclusiveOr")
|
||||
{
|
||||
Handle<bool, bool>((a, b) => a ^ b);
|
||||
|
||||
Handle<byte, byte>((a, b) => a ^ b);
|
||||
Handle<byte, sbyte>((a, b) => a ^ b);
|
||||
Handle<byte, short>((a, b) => a ^ b);
|
||||
Handle<byte, ushort>((a, b) => a ^ b);
|
||||
Handle<byte, int>((a, b) => a ^ b);
|
||||
Handle<byte, uint>((a, b) => a ^ b);
|
||||
Handle<byte, long>((a, b) => a ^ b);
|
||||
Handle<byte, ulong>((a, b) => a ^ b);
|
||||
|
||||
Handle<sbyte, byte>((a, b) => a ^ b);
|
||||
Handle<sbyte, sbyte>((a, b) => a ^ b);
|
||||
Handle<sbyte, short>((a, b) => a ^ b);
|
||||
Handle<sbyte, ushort>((a, b) => a ^ b);
|
||||
Handle<sbyte, int>((a, b) => a ^ b);
|
||||
Handle<sbyte, uint>((a, b) => a ^ b);
|
||||
Handle<sbyte, long>((a, b) => a ^ b);
|
||||
//Handle<sbyte, ulong>((a, b) => a ^ b);
|
||||
|
||||
Handle<short, byte>((a, b) => a ^ b);
|
||||
Handle<short, sbyte>((a, b) => a ^ b);
|
||||
Handle<short, short>((a, b) => a ^ b);
|
||||
Handle<short, ushort>((a, b) => a ^ b);
|
||||
Handle<short, int>((a, b) => a ^ b);
|
||||
Handle<short, uint>((a, b) => a ^ b);
|
||||
Handle<short, long>((a, b) => a ^ b);
|
||||
//Handle<short, ulong>((a, b) => a ^ b);
|
||||
|
||||
Handle<ushort, byte>((a, b) => a ^ b);
|
||||
Handle<ushort, sbyte>((a, b) => a ^ b);
|
||||
Handle<ushort, short>((a, b) => a ^ b);
|
||||
Handle<ushort, ushort>((a, b) => a ^ b);
|
||||
Handle<ushort, int>((a, b) => a ^ b);
|
||||
Handle<ushort, uint>((a, b) => a ^ b);
|
||||
Handle<ushort, long>((a, b) => a ^ b);
|
||||
Handle<ushort, ulong>((a, b) => a ^ b);
|
||||
|
||||
Handle<int, byte>((a, b) => a ^ b);
|
||||
Handle<int, sbyte>((a, b) => a ^ b);
|
||||
Handle<int, short>((a, b) => a ^ b);
|
||||
Handle<int, ushort>((a, b) => a ^ b);
|
||||
Handle<int, int>((a, b) => a ^ b);
|
||||
Handle<int, uint>((a, b) => a ^ b);
|
||||
Handle<int, long>((a, b) => a ^ b);
|
||||
//Handle<int, ulong>((a, b) => a ^ b);
|
||||
|
||||
Handle<uint, byte>((a, b) => a ^ b);
|
||||
Handle<uint, sbyte>((a, b) => a ^ b);
|
||||
Handle<uint, short>((a, b) => a ^ b);
|
||||
Handle<uint, ushort>((a, b) => a ^ b);
|
||||
Handle<uint, int>((a, b) => a ^ b);
|
||||
Handle<uint, uint>((a, b) => a ^ b);
|
||||
Handle<uint, long>((a, b) => a ^ b);
|
||||
Handle<uint, ulong>((a, b) => a ^ b);
|
||||
|
||||
Handle<long, byte>((a, b) => a ^ b);
|
||||
Handle<long, sbyte>((a, b) => a ^ b);
|
||||
Handle<long, short>((a, b) => a ^ b);
|
||||
Handle<long, ushort>((a, b) => a ^ b);
|
||||
Handle<long, int>((a, b) => a ^ b);
|
||||
Handle<long, uint>((a, b) => a ^ b);
|
||||
Handle<long, long>((a, b) => a ^ b);
|
||||
//Handle<long, ulong>((a, b) => a ^ b);
|
||||
|
||||
Handle<ulong, byte>((a, b) => a ^ b);
|
||||
//Handle<ulong, sbyte>((a, b) => a ^ b);
|
||||
//Handle<ulong, short>((a, b) => a ^ b);
|
||||
Handle<ulong, ushort>((a, b) => a ^ b);
|
||||
//Handle<ulong, int>((a, b) => a ^ b);
|
||||
Handle<ulong, uint>((a, b) => a ^ b);
|
||||
//Handle<ulong, long>((a, b) => a ^ b);
|
||||
Handle<ulong, ulong>((a, b) => a ^ b);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d605072279c64478ab714dca21521800
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,140 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public class GreaterThanHandler : BinaryOperatorHandler
|
||||
{
|
||||
public GreaterThanHandler() : base("Greather Than", "Greather Than", ">", "op_GreaterThan")
|
||||
{
|
||||
Handle<byte, byte>((a, b) => a > b);
|
||||
Handle<byte, sbyte>((a, b) => a > b);
|
||||
Handle<byte, short>((a, b) => a > b);
|
||||
Handle<byte, ushort>((a, b) => a > b);
|
||||
Handle<byte, int>((a, b) => a > b);
|
||||
Handle<byte, uint>((a, b) => a > b);
|
||||
Handle<byte, long>((a, b) => a > b);
|
||||
Handle<byte, ulong>((a, b) => a > b);
|
||||
Handle<byte, float>((a, b) => a > b);
|
||||
Handle<byte, decimal>((a, b) => a > b);
|
||||
Handle<byte, double>((a, b) => a > b);
|
||||
|
||||
Handle<sbyte, byte>((a, b) => a > b);
|
||||
Handle<sbyte, sbyte>((a, b) => a > b);
|
||||
Handle<sbyte, short>((a, b) => a > b);
|
||||
Handle<sbyte, ushort>((a, b) => a > b);
|
||||
Handle<sbyte, int>((a, b) => a > b);
|
||||
Handle<sbyte, uint>((a, b) => a > b);
|
||||
Handle<sbyte, long>((a, b) => a > b);
|
||||
//Handle<sbyte, ulong>((a, b) => a > b);
|
||||
Handle<sbyte, float>((a, b) => a > b);
|
||||
Handle<sbyte, decimal>((a, b) => a > b);
|
||||
Handle<sbyte, double>((a, b) => a > b);
|
||||
|
||||
Handle<short, byte>((a, b) => a > b);
|
||||
Handle<short, sbyte>((a, b) => a > b);
|
||||
Handle<short, short>((a, b) => a > b);
|
||||
Handle<short, ushort>((a, b) => a > b);
|
||||
Handle<short, int>((a, b) => a > b);
|
||||
Handle<short, uint>((a, b) => a > b);
|
||||
Handle<short, long>((a, b) => a > b);
|
||||
//Handle<short, ulong>((a, b) => a > b);
|
||||
Handle<short, float>((a, b) => a > b);
|
||||
Handle<short, decimal>((a, b) => a > b);
|
||||
Handle<short, double>((a, b) => a > b);
|
||||
|
||||
Handle<ushort, byte>((a, b) => a > b);
|
||||
Handle<ushort, sbyte>((a, b) => a > b);
|
||||
Handle<ushort, short>((a, b) => a > b);
|
||||
Handle<ushort, ushort>((a, b) => a > b);
|
||||
Handle<ushort, int>((a, b) => a > b);
|
||||
Handle<ushort, uint>((a, b) => a > b);
|
||||
Handle<ushort, long>((a, b) => a > b);
|
||||
Handle<ushort, ulong>((a, b) => a > b);
|
||||
Handle<ushort, float>((a, b) => a > b);
|
||||
Handle<ushort, decimal>((a, b) => a > b);
|
||||
Handle<ushort, double>((a, b) => a > b);
|
||||
|
||||
Handle<int, byte>((a, b) => a > b);
|
||||
Handle<int, sbyte>((a, b) => a > b);
|
||||
Handle<int, short>((a, b) => a > b);
|
||||
Handle<int, ushort>((a, b) => a > b);
|
||||
Handle<int, int>((a, b) => a > b);
|
||||
Handle<int, uint>((a, b) => a > b);
|
||||
Handle<int, long>((a, b) => a > b);
|
||||
//Handle<int, ulong>((a, b) => a > b);
|
||||
Handle<int, float>((a, b) => a > b);
|
||||
Handle<int, decimal>((a, b) => a > b);
|
||||
Handle<int, double>((a, b) => a > b);
|
||||
|
||||
Handle<uint, byte>((a, b) => a > b);
|
||||
Handle<uint, sbyte>((a, b) => a > b);
|
||||
Handle<uint, short>((a, b) => a > b);
|
||||
Handle<uint, ushort>((a, b) => a > b);
|
||||
Handle<uint, int>((a, b) => a > b);
|
||||
Handle<uint, uint>((a, b) => a > b);
|
||||
Handle<uint, long>((a, b) => a > b);
|
||||
Handle<uint, ulong>((a, b) => a > b);
|
||||
Handle<uint, float>((a, b) => a > b);
|
||||
Handle<uint, decimal>((a, b) => a > b);
|
||||
Handle<uint, double>((a, b) => a > b);
|
||||
|
||||
Handle<long, byte>((a, b) => a > b);
|
||||
Handle<long, sbyte>((a, b) => a > b);
|
||||
Handle<long, short>((a, b) => a > b);
|
||||
Handle<long, ushort>((a, b) => a > b);
|
||||
Handle<long, int>((a, b) => a > b);
|
||||
Handle<long, uint>((a, b) => a > b);
|
||||
Handle<long, long>((a, b) => a > b);
|
||||
//Handle<long, ulong>((a, b) => a > b);
|
||||
Handle<long, float>((a, b) => a > b);
|
||||
Handle<long, decimal>((a, b) => a > b);
|
||||
Handle<long, double>((a, b) => a > b);
|
||||
|
||||
Handle<ulong, byte>((a, b) => a > b);
|
||||
//Handle<ulong, sbyte>((a, b) => a > b);
|
||||
//Handle<ulong, short>((a, b) => a > b);
|
||||
Handle<ulong, ushort>((a, b) => a > b);
|
||||
//Handle<ulong, int>((a, b) => a > b);
|
||||
Handle<ulong, uint>((a, b) => a > b);
|
||||
//Handle<ulong, long>((a, b) => a > b);
|
||||
Handle<ulong, ulong>((a, b) => a > b);
|
||||
Handle<ulong, float>((a, b) => a > b);
|
||||
Handle<ulong, decimal>((a, b) => a > b);
|
||||
Handle<ulong, double>((a, b) => a > b);
|
||||
|
||||
Handle<float, byte>((a, b) => a > b);
|
||||
Handle<float, sbyte>((a, b) => a > b);
|
||||
Handle<float, short>((a, b) => a > b);
|
||||
Handle<float, ushort>((a, b) => a > b);
|
||||
Handle<float, int>((a, b) => a > b);
|
||||
Handle<float, uint>((a, b) => a > b);
|
||||
Handle<float, long>((a, b) => a > b);
|
||||
Handle<float, ulong>((a, b) => a > b);
|
||||
Handle<float, float>((a, b) => a > b);
|
||||
//Handle<float, decimal>((a, b) => a > b);
|
||||
Handle<float, double>((a, b) => a > b);
|
||||
|
||||
Handle<decimal, byte>((a, b) => a > b);
|
||||
Handle<decimal, sbyte>((a, b) => a > b);
|
||||
Handle<decimal, short>((a, b) => a > b);
|
||||
Handle<decimal, ushort>((a, b) => a > b);
|
||||
Handle<decimal, int>((a, b) => a > b);
|
||||
Handle<decimal, uint>((a, b) => a > b);
|
||||
Handle<decimal, long>((a, b) => a > b);
|
||||
Handle<decimal, ulong>((a, b) => a > b);
|
||||
//Handle<decimal, float>((a, b) => a > b);
|
||||
Handle<decimal, decimal>((a, b) => a > b);
|
||||
//Handle<decimal, double>((a, b) => a > b);
|
||||
|
||||
Handle<double, byte>((a, b) => a > b);
|
||||
Handle<double, sbyte>((a, b) => a > b);
|
||||
Handle<double, short>((a, b) => a > b);
|
||||
Handle<double, ushort>((a, b) => a > b);
|
||||
Handle<double, int>((a, b) => a > b);
|
||||
Handle<double, uint>((a, b) => a > b);
|
||||
Handle<double, long>((a, b) => a > b);
|
||||
Handle<double, ulong>((a, b) => a > b);
|
||||
Handle<double, float>((a, b) => a > b);
|
||||
//Handle<double, decimal>((a, b) => a > b);
|
||||
Handle<double, double>((a, b) => a > b);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0257df31bc561468aa180247d70ae0fe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,142 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public class GreaterThanOrEqualHandler : BinaryOperatorHandler
|
||||
{
|
||||
public GreaterThanOrEqualHandler() : base("Greater Than Or Equal", "Greater Than Or Equal", ">=", "op_GreaterThanOrEqual")
|
||||
{
|
||||
Handle<byte, byte>((a, b) => a >= b);
|
||||
Handle<byte, sbyte>((a, b) => a >= b);
|
||||
Handle<byte, short>((a, b) => a >= b);
|
||||
Handle<byte, ushort>((a, b) => a >= b);
|
||||
Handle<byte, int>((a, b) => a >= b);
|
||||
Handle<byte, uint>((a, b) => a >= b);
|
||||
Handle<byte, long>((a, b) => a >= b);
|
||||
Handle<byte, ulong>((a, b) => a >= b);
|
||||
Handle<byte, float>((a, b) => a >= b);
|
||||
Handle<byte, decimal>((a, b) => a >= b);
|
||||
Handle<byte, double>((a, b) => a >= b);
|
||||
|
||||
Handle<sbyte, byte>((a, b) => a >= b);
|
||||
Handle<sbyte, sbyte>((a, b) => a >= b);
|
||||
Handle<sbyte, short>((a, b) => a >= b);
|
||||
Handle<sbyte, ushort>((a, b) => a >= b);
|
||||
Handle<sbyte, int>((a, b) => a >= b);
|
||||
Handle<sbyte, uint>((a, b) => a >= b);
|
||||
Handle<sbyte, long>((a, b) => a >= b);
|
||||
//Handle<sbyte, ulong>((a, b) => a >= b);
|
||||
Handle<sbyte, float>((a, b) => a >= b);
|
||||
Handle<sbyte, decimal>((a, b) => a >= b);
|
||||
Handle<sbyte, double>((a, b) => a >= b);
|
||||
|
||||
Handle<short, byte>((a, b) => a >= b);
|
||||
Handle<short, sbyte>((a, b) => a >= b);
|
||||
Handle<short, short>((a, b) => a >= b);
|
||||
Handle<short, ushort>((a, b) => a >= b);
|
||||
Handle<short, int>((a, b) => a >= b);
|
||||
Handle<short, uint>((a, b) => a >= b);
|
||||
Handle<short, long>((a, b) => a >= b);
|
||||
//Handle<short, ulong>((a, b) => a >= b);
|
||||
Handle<short, float>((a, b) => a >= b);
|
||||
Handle<short, decimal>((a, b) => a >= b);
|
||||
Handle<short, double>((a, b) => a >= b);
|
||||
|
||||
Handle<ushort, byte>((a, b) => a >= b);
|
||||
Handle<ushort, sbyte>((a, b) => a >= b);
|
||||
Handle<ushort, short>((a, b) => a >= b);
|
||||
Handle<ushort, ushort>((a, b) => a >= b);
|
||||
Handle<ushort, int>((a, b) => a >= b);
|
||||
Handle<ushort, uint>((a, b) => a >= b);
|
||||
Handle<ushort, long>((a, b) => a >= b);
|
||||
Handle<ushort, ulong>((a, b) => a >= b);
|
||||
Handle<ushort, float>((a, b) => a >= b);
|
||||
Handle<ushort, decimal>((a, b) => a >= b);
|
||||
Handle<ushort, double>((a, b) => a >= b);
|
||||
|
||||
Handle<int, byte>((a, b) => a >= b);
|
||||
Handle<int, sbyte>((a, b) => a >= b);
|
||||
Handle<int, short>((a, b) => a >= b);
|
||||
Handle<int, ushort>((a, b) => a >= b);
|
||||
Handle<int, int>((a, b) => a >= b);
|
||||
Handle<int, uint>((a, b) => a >= b);
|
||||
Handle<int, long>((a, b) => a >= b);
|
||||
//Handle<int, ulong>((a, b) => a >= b);
|
||||
Handle<int, float>((a, b) => a >= b);
|
||||
Handle<int, decimal>((a, b) => a >= b);
|
||||
Handle<int, double>((a, b) => a >= b);
|
||||
|
||||
Handle<uint, byte>((a, b) => a >= b);
|
||||
Handle<uint, sbyte>((a, b) => a >= b);
|
||||
Handle<uint, short>((a, b) => a >= b);
|
||||
Handle<uint, ushort>((a, b) => a >= b);
|
||||
Handle<uint, int>((a, b) => a >= b);
|
||||
Handle<uint, uint>((a, b) => a >= b);
|
||||
Handle<uint, long>((a, b) => a >= b);
|
||||
Handle<uint, ulong>((a, b) => a >= b);
|
||||
Handle<uint, float>((a, b) => a >= b);
|
||||
Handle<uint, decimal>((a, b) => a >= b);
|
||||
Handle<uint, double>((a, b) => a >= b);
|
||||
|
||||
Handle<long, byte>((a, b) => a >= b);
|
||||
Handle<long, sbyte>((a, b) => a >= b);
|
||||
Handle<long, short>((a, b) => a >= b);
|
||||
Handle<long, ushort>((a, b) => a >= b);
|
||||
Handle<long, int>((a, b) => a >= b);
|
||||
Handle<long, uint>((a, b) => a >= b);
|
||||
Handle<long, long>((a, b) => a >= b);
|
||||
//Handle<long, ulong>((a, b) => a >= b);
|
||||
Handle<long, float>((a, b) => a >= b);
|
||||
Handle<long, decimal>((a, b) => a >= b);
|
||||
Handle<long, double>((a, b) => a >= b);
|
||||
|
||||
Handle<ulong, byte>((a, b) => a >= b);
|
||||
//Handle<ulong, sbyte>((a, b) => a >= b);
|
||||
//Handle<ulong, short>((a, b) => a >= b);
|
||||
Handle<ulong, ushort>((a, b) => a >= b);
|
||||
//Handle<ulong, int>((a, b) => a >= b);
|
||||
Handle<ulong, uint>((a, b) => a >= b);
|
||||
//Handle<ulong, long>((a, b) => a >= b);
|
||||
Handle<ulong, ulong>((a, b) => a >= b);
|
||||
Handle<ulong, float>((a, b) => a >= b);
|
||||
Handle<ulong, decimal>((a, b) => a >= b);
|
||||
Handle<ulong, double>((a, b) => a >= b);
|
||||
|
||||
Handle<float, byte>((a, b) => a >= b);
|
||||
Handle<float, sbyte>((a, b) => a >= b);
|
||||
Handle<float, short>((a, b) => a >= b);
|
||||
Handle<float, ushort>((a, b) => a >= b);
|
||||
Handle<float, int>((a, b) => a >= b);
|
||||
Handle<float, uint>((a, b) => a >= b);
|
||||
Handle<float, long>((a, b) => a >= b);
|
||||
Handle<float, ulong>((a, b) => a >= b);
|
||||
Handle<float, float>((a, b) => a >= b || Mathf.Approximately(a, b));
|
||||
//Handle<float, decimal>((a, b) => a >= b);
|
||||
Handle<float, double>((a, b) => a >= b);
|
||||
|
||||
Handle<decimal, byte>((a, b) => a >= b);
|
||||
Handle<decimal, sbyte>((a, b) => a >= b);
|
||||
Handle<decimal, short>((a, b) => a >= b);
|
||||
Handle<decimal, ushort>((a, b) => a >= b);
|
||||
Handle<decimal, int>((a, b) => a >= b);
|
||||
Handle<decimal, uint>((a, b) => a >= b);
|
||||
Handle<decimal, long>((a, b) => a >= b);
|
||||
Handle<decimal, ulong>((a, b) => a >= b);
|
||||
//Handle<decimal, float>((a, b) => a >= b);
|
||||
Handle<decimal, decimal>((a, b) => a >= b);
|
||||
//Handle<decimal, double>((a, b) => a >= b);
|
||||
|
||||
Handle<double, byte>((a, b) => a >= b);
|
||||
Handle<double, sbyte>((a, b) => a >= b);
|
||||
Handle<double, short>((a, b) => a >= b);
|
||||
Handle<double, ushort>((a, b) => a >= b);
|
||||
Handle<double, int>((a, b) => a >= b);
|
||||
Handle<double, uint>((a, b) => a >= b);
|
||||
Handle<double, long>((a, b) => a >= b);
|
||||
Handle<double, ulong>((a, b) => a >= b);
|
||||
Handle<double, float>((a, b) => a >= b);
|
||||
//Handle<double, decimal>((a, b) => a >= b);
|
||||
Handle<double, double>((a, b) => a >= b);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4bda3e694712447948a1601c78b37920
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,20 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public sealed class IncrementHandler : UnaryOperatorHandler
|
||||
{
|
||||
public IncrementHandler() : base("Increment", "Increment", "++", "op_Increment")
|
||||
{
|
||||
Handle<byte>(a => ++a);
|
||||
Handle<sbyte>(a => ++a);
|
||||
Handle<short>(a => ++a);
|
||||
Handle<ushort>(a => ++a);
|
||||
Handle<int>(a => ++a);
|
||||
Handle<uint>(a => ++a);
|
||||
Handle<long>(a => ++a);
|
||||
Handle<ulong>(a => ++a);
|
||||
Handle<float>(a => ++a);
|
||||
Handle<decimal>(a => ++a);
|
||||
Handle<double>(a => ++a);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d3b2c06caaabe42a392f285017f17cc4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,157 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public class InequalityHandler : BinaryOperatorHandler
|
||||
{
|
||||
public InequalityHandler() : base("Inequality", "Not Equal", "!=", "op_Inequality")
|
||||
{
|
||||
Handle<byte, byte>((a, b) => a != b);
|
||||
Handle<byte, sbyte>((a, b) => a != b);
|
||||
Handle<byte, short>((a, b) => a != b);
|
||||
Handle<byte, ushort>((a, b) => a != b);
|
||||
Handle<byte, int>((a, b) => a != b);
|
||||
Handle<byte, uint>((a, b) => a != b);
|
||||
Handle<byte, long>((a, b) => a != b);
|
||||
Handle<byte, ulong>((a, b) => a != b);
|
||||
Handle<byte, float>((a, b) => a != b);
|
||||
Handle<byte, decimal>((a, b) => a != b);
|
||||
Handle<byte, double>((a, b) => a != b);
|
||||
|
||||
Handle<sbyte, byte>((a, b) => a != b);
|
||||
Handle<sbyte, sbyte>((a, b) => a != b);
|
||||
Handle<sbyte, short>((a, b) => a != b);
|
||||
Handle<sbyte, ushort>((a, b) => a != b);
|
||||
Handle<sbyte, int>((a, b) => a != b);
|
||||
Handle<sbyte, uint>((a, b) => a != b);
|
||||
Handle<sbyte, long>((a, b) => a != b);
|
||||
//Handle<sbyte, ulong>((a, b) => a != b);
|
||||
Handle<sbyte, float>((a, b) => a != b);
|
||||
Handle<sbyte, decimal>((a, b) => a != b);
|
||||
Handle<sbyte, double>((a, b) => a != b);
|
||||
|
||||
Handle<short, byte>((a, b) => a != b);
|
||||
Handle<short, sbyte>((a, b) => a != b);
|
||||
Handle<short, short>((a, b) => a != b);
|
||||
Handle<short, ushort>((a, b) => a != b);
|
||||
Handle<short, int>((a, b) => a != b);
|
||||
Handle<short, uint>((a, b) => a != b);
|
||||
Handle<short, long>((a, b) => a != b);
|
||||
//Handle<short, ulong>((a, b) => a != b);
|
||||
Handle<short, float>((a, b) => a != b);
|
||||
Handle<short, decimal>((a, b) => a != b);
|
||||
Handle<short, double>((a, b) => a != b);
|
||||
|
||||
Handle<ushort, byte>((a, b) => a != b);
|
||||
Handle<ushort, sbyte>((a, b) => a != b);
|
||||
Handle<ushort, short>((a, b) => a != b);
|
||||
Handle<ushort, ushort>((a, b) => a != b);
|
||||
Handle<ushort, int>((a, b) => a != b);
|
||||
Handle<ushort, uint>((a, b) => a != b);
|
||||
Handle<ushort, long>((a, b) => a != b);
|
||||
Handle<ushort, ulong>((a, b) => a != b);
|
||||
Handle<ushort, float>((a, b) => a != b);
|
||||
Handle<ushort, decimal>((a, b) => a != b);
|
||||
Handle<ushort, double>((a, b) => a != b);
|
||||
|
||||
Handle<int, byte>((a, b) => a != b);
|
||||
Handle<int, sbyte>((a, b) => a != b);
|
||||
Handle<int, short>((a, b) => a != b);
|
||||
Handle<int, ushort>((a, b) => a != b);
|
||||
Handle<int, int>((a, b) => a != b);
|
||||
Handle<int, uint>((a, b) => a != b);
|
||||
Handle<int, long>((a, b) => a != b);
|
||||
//Handle<int, ulong>((a, b) => a != b);
|
||||
Handle<int, float>((a, b) => a != b);
|
||||
Handle<int, decimal>((a, b) => a != b);
|
||||
Handle<int, double>((a, b) => a != b);
|
||||
|
||||
Handle<uint, byte>((a, b) => a != b);
|
||||
Handle<uint, sbyte>((a, b) => a != b);
|
||||
Handle<uint, short>((a, b) => a != b);
|
||||
Handle<uint, ushort>((a, b) => a != b);
|
||||
Handle<uint, int>((a, b) => a != b);
|
||||
Handle<uint, uint>((a, b) => a != b);
|
||||
Handle<uint, long>((a, b) => a != b);
|
||||
Handle<uint, ulong>((a, b) => a != b);
|
||||
Handle<uint, float>((a, b) => a != b);
|
||||
Handle<uint, decimal>((a, b) => a != b);
|
||||
Handle<uint, double>((a, b) => a != b);
|
||||
|
||||
Handle<long, byte>((a, b) => a != b);
|
||||
Handle<long, sbyte>((a, b) => a != b);
|
||||
Handle<long, short>((a, b) => a != b);
|
||||
Handle<long, ushort>((a, b) => a != b);
|
||||
Handle<long, int>((a, b) => a != b);
|
||||
Handle<long, uint>((a, b) => a != b);
|
||||
Handle<long, long>((a, b) => a != b);
|
||||
//Handle<long, ulong>((a, b) => a != b);
|
||||
Handle<long, float>((a, b) => a != b);
|
||||
Handle<long, decimal>((a, b) => a != b);
|
||||
Handle<long, double>((a, b) => a != b);
|
||||
|
||||
Handle<ulong, byte>((a, b) => a != b);
|
||||
//Handle<ulong, sbyte>((a, b) => a != b);
|
||||
//Handle<ulong, short>((a, b) => a != b);
|
||||
Handle<ulong, ushort>((a, b) => a != b);
|
||||
//Handle<ulong, int>((a, b) => a != b);
|
||||
Handle<ulong, uint>((a, b) => a != b);
|
||||
//Handle<ulong, long>((a, b) => a != b);
|
||||
Handle<ulong, ulong>((a, b) => a != b);
|
||||
Handle<ulong, float>((a, b) => a != b);
|
||||
Handle<ulong, decimal>((a, b) => a != b);
|
||||
Handle<ulong, double>((a, b) => a != b);
|
||||
|
||||
Handle<float, byte>((a, b) => a != b);
|
||||
Handle<float, sbyte>((a, b) => a != b);
|
||||
Handle<float, short>((a, b) => a != b);
|
||||
Handle<float, ushort>((a, b) => a != b);
|
||||
Handle<float, int>((a, b) => a != b);
|
||||
Handle<float, uint>((a, b) => a != b);
|
||||
Handle<float, long>((a, b) => a != b);
|
||||
Handle<float, ulong>((a, b) => a != b);
|
||||
Handle<float, float>((a, b) => !Mathf.Approximately(a, b));
|
||||
//Handle<float, decimal>((a, b) => a != b);
|
||||
Handle<float, double>((a, b) => a != b);
|
||||
|
||||
Handle<decimal, byte>((a, b) => a != b);
|
||||
Handle<decimal, sbyte>((a, b) => a != b);
|
||||
Handle<decimal, short>((a, b) => a != b);
|
||||
Handle<decimal, ushort>((a, b) => a != b);
|
||||
Handle<decimal, int>((a, b) => a != b);
|
||||
Handle<decimal, uint>((a, b) => a != b);
|
||||
Handle<decimal, long>((a, b) => a != b);
|
||||
Handle<decimal, ulong>((a, b) => a != b);
|
||||
//Handle<decimal, float>((a, b) => a != b);
|
||||
Handle<decimal, decimal>((a, b) => a != b);
|
||||
//Handle<decimal, double>((a, b) => a != b);
|
||||
|
||||
Handle<double, byte>((a, b) => a != b);
|
||||
Handle<double, sbyte>((a, b) => a != b);
|
||||
Handle<double, short>((a, b) => a != b);
|
||||
Handle<double, ushort>((a, b) => a != b);
|
||||
Handle<double, int>((a, b) => a != b);
|
||||
Handle<double, uint>((a, b) => a != b);
|
||||
Handle<double, long>((a, b) => a != b);
|
||||
Handle<double, ulong>((a, b) => a != b);
|
||||
Handle<double, float>((a, b) => a != b);
|
||||
//Handle<double, decimal>((a, b) => a != b);
|
||||
Handle<double, double>((a, b) => a != b);
|
||||
}
|
||||
|
||||
protected override object BothNullHandling()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override object SingleNullHandling()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override object Operate(object leftOperand, object rightOperand)
|
||||
{
|
||||
return !Equals(leftOperand, rightOperand);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d0aa0da2ce60d44ceaeb7718d323010d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,10 @@
|
|||
using System;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public sealed class InvalidOperatorException : OperatorException
|
||||
{
|
||||
public InvalidOperatorException(string symbol, Type type) : base($"Operator '{symbol}' cannot be applied to operand of type '{type?.ToString() ?? "null"}'.") { }
|
||||
public InvalidOperatorException(string symbol, Type leftType, Type rightType) : base($"Operator '{symbol}' cannot be applied to operands of type '{leftType?.ToString() ?? "null"}' and '{rightType?.ToString() ?? "null"}'.") { }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4a6c6829dd03e4750a1bd7107faa4730
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,56 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public class LeftShiftHandler : BinaryOperatorHandler
|
||||
{
|
||||
public LeftShiftHandler() : base("Left Shift", "Left Shift", "<<", "op_LeftShift")
|
||||
{
|
||||
Handle<byte, byte>((a, b) => a << b);
|
||||
Handle<byte, sbyte>((a, b) => a << b);
|
||||
Handle<byte, short>((a, b) => a << b);
|
||||
Handle<byte, ushort>((a, b) => a << b);
|
||||
Handle<byte, int>((a, b) => a << b);
|
||||
|
||||
Handle<sbyte, byte>((a, b) => a << b);
|
||||
Handle<sbyte, sbyte>((a, b) => a << b);
|
||||
Handle<sbyte, short>((a, b) => a << b);
|
||||
Handle<sbyte, ushort>((a, b) => a << b);
|
||||
Handle<sbyte, int>((a, b) => a << b);
|
||||
|
||||
Handle<short, byte>((a, b) => a << b);
|
||||
Handle<short, sbyte>((a, b) => a << b);
|
||||
Handle<short, short>((a, b) => a << b);
|
||||
Handle<short, ushort>((a, b) => a << b);
|
||||
Handle<short, int>((a, b) => a << b);
|
||||
|
||||
Handle<ushort, byte>((a, b) => a << b);
|
||||
Handle<ushort, sbyte>((a, b) => a << b);
|
||||
Handle<ushort, short>((a, b) => a << b);
|
||||
Handle<ushort, ushort>((a, b) => a << b);
|
||||
Handle<ushort, int>((a, b) => a << b);
|
||||
|
||||
Handle<int, byte>((a, b) => a << b);
|
||||
Handle<int, sbyte>((a, b) => a << b);
|
||||
Handle<int, short>((a, b) => a << b);
|
||||
Handle<int, ushort>((a, b) => a << b);
|
||||
Handle<int, int>((a, b) => a << b);
|
||||
|
||||
Handle<uint, byte>((a, b) => a << b);
|
||||
Handle<uint, sbyte>((a, b) => a << b);
|
||||
Handle<uint, short>((a, b) => a << b);
|
||||
Handle<uint, ushort>((a, b) => a << b);
|
||||
Handle<uint, int>((a, b) => a << b);
|
||||
|
||||
Handle<long, byte>((a, b) => a << b);
|
||||
Handle<long, sbyte>((a, b) => a << b);
|
||||
Handle<long, short>((a, b) => a << b);
|
||||
Handle<long, ushort>((a, b) => a << b);
|
||||
Handle<long, int>((a, b) => a << b);
|
||||
|
||||
Handle<ulong, byte>((a, b) => a << b);
|
||||
Handle<ulong, sbyte>((a, b) => a << b);
|
||||
Handle<ulong, short>((a, b) => a << b);
|
||||
Handle<ulong, ushort>((a, b) => a << b);
|
||||
Handle<ulong, int>((a, b) => a << b);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 24bb3f6ea82ae4d6d85ca2b5aa7fd992
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,140 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public class LessThanHandler : BinaryOperatorHandler
|
||||
{
|
||||
public LessThanHandler() : base("Less Than", "Less Than", "<", "op_LessThan")
|
||||
{
|
||||
Handle<byte, byte>((a, b) => a < b);
|
||||
Handle<byte, sbyte>((a, b) => a < b);
|
||||
Handle<byte, short>((a, b) => a < b);
|
||||
Handle<byte, ushort>((a, b) => a < b);
|
||||
Handle<byte, int>((a, b) => a < b);
|
||||
Handle<byte, uint>((a, b) => a < b);
|
||||
Handle<byte, long>((a, b) => a < b);
|
||||
Handle<byte, ulong>((a, b) => a < b);
|
||||
Handle<byte, float>((a, b) => a < b);
|
||||
Handle<byte, decimal>((a, b) => a < b);
|
||||
Handle<byte, double>((a, b) => a < b);
|
||||
|
||||
Handle<sbyte, byte>((a, b) => a < b);
|
||||
Handle<sbyte, sbyte>((a, b) => a < b);
|
||||
Handle<sbyte, short>((a, b) => a < b);
|
||||
Handle<sbyte, ushort>((a, b) => a < b);
|
||||
Handle<sbyte, int>((a, b) => a < b);
|
||||
Handle<sbyte, uint>((a, b) => a < b);
|
||||
Handle<sbyte, long>((a, b) => a < b);
|
||||
//Handle<sbyte, ulong>((a, b) => a < b);
|
||||
Handle<sbyte, float>((a, b) => a < b);
|
||||
Handle<sbyte, decimal>((a, b) => a < b);
|
||||
Handle<sbyte, double>((a, b) => a < b);
|
||||
|
||||
Handle<short, byte>((a, b) => a < b);
|
||||
Handle<short, sbyte>((a, b) => a < b);
|
||||
Handle<short, short>((a, b) => a < b);
|
||||
Handle<short, ushort>((a, b) => a < b);
|
||||
Handle<short, int>((a, b) => a < b);
|
||||
Handle<short, uint>((a, b) => a < b);
|
||||
Handle<short, long>((a, b) => a < b);
|
||||
//Handle<short, ulong>((a, b) => a < b);
|
||||
Handle<short, float>((a, b) => a < b);
|
||||
Handle<short, decimal>((a, b) => a < b);
|
||||
Handle<short, double>((a, b) => a < b);
|
||||
|
||||
Handle<ushort, byte>((a, b) => a < b);
|
||||
Handle<ushort, sbyte>((a, b) => a < b);
|
||||
Handle<ushort, short>((a, b) => a < b);
|
||||
Handle<ushort, ushort>((a, b) => a < b);
|
||||
Handle<ushort, int>((a, b) => a < b);
|
||||
Handle<ushort, uint>((a, b) => a < b);
|
||||
Handle<ushort, long>((a, b) => a < b);
|
||||
Handle<ushort, ulong>((a, b) => a < b);
|
||||
Handle<ushort, float>((a, b) => a < b);
|
||||
Handle<ushort, decimal>((a, b) => a < b);
|
||||
Handle<ushort, double>((a, b) => a < b);
|
||||
|
||||
Handle<int, byte>((a, b) => a < b);
|
||||
Handle<int, sbyte>((a, b) => a < b);
|
||||
Handle<int, short>((a, b) => a < b);
|
||||
Handle<int, ushort>((a, b) => a < b);
|
||||
Handle<int, int>((a, b) => a < b);
|
||||
Handle<int, uint>((a, b) => a < b);
|
||||
Handle<int, long>((a, b) => a < b);
|
||||
//Handle<int, ulong>((a, b) => a < b);
|
||||
Handle<int, float>((a, b) => a < b);
|
||||
Handle<int, decimal>((a, b) => a < b);
|
||||
Handle<int, double>((a, b) => a < b);
|
||||
|
||||
Handle<uint, byte>((a, b) => a < b);
|
||||
Handle<uint, sbyte>((a, b) => a < b);
|
||||
Handle<uint, short>((a, b) => a < b);
|
||||
Handle<uint, ushort>((a, b) => a < b);
|
||||
Handle<uint, int>((a, b) => a < b);
|
||||
Handle<uint, uint>((a, b) => a < b);
|
||||
Handle<uint, long>((a, b) => a < b);
|
||||
Handle<uint, ulong>((a, b) => a < b);
|
||||
Handle<uint, float>((a, b) => a < b);
|
||||
Handle<uint, decimal>((a, b) => a < b);
|
||||
Handle<uint, double>((a, b) => a < b);
|
||||
|
||||
Handle<long, byte>((a, b) => a < b);
|
||||
Handle<long, sbyte>((a, b) => a < b);
|
||||
Handle<long, short>((a, b) => a < b);
|
||||
Handle<long, ushort>((a, b) => a < b);
|
||||
Handle<long, int>((a, b) => a < b);
|
||||
Handle<long, uint>((a, b) => a < b);
|
||||
Handle<long, long>((a, b) => a < b);
|
||||
//Handle<long, ulong>((a, b) => a < b);
|
||||
Handle<long, float>((a, b) => a < b);
|
||||
Handle<long, decimal>((a, b) => a < b);
|
||||
Handle<long, double>((a, b) => a < b);
|
||||
|
||||
Handle<ulong, byte>((a, b) => a < b);
|
||||
//Handle<ulong, sbyte>((a, b) => a < b);
|
||||
//Handle<ulong, short>((a, b) => a < b);
|
||||
Handle<ulong, ushort>((a, b) => a < b);
|
||||
//Handle<ulong, int>((a, b) => a < b);
|
||||
Handle<ulong, uint>((a, b) => a < b);
|
||||
//Handle<ulong, long>((a, b) => a < b);
|
||||
Handle<ulong, ulong>((a, b) => a < b);
|
||||
Handle<ulong, float>((a, b) => a < b);
|
||||
Handle<ulong, decimal>((a, b) => a < b);
|
||||
Handle<ulong, double>((a, b) => a < b);
|
||||
|
||||
Handle<float, byte>((a, b) => a < b);
|
||||
Handle<float, sbyte>((a, b) => a < b);
|
||||
Handle<float, short>((a, b) => a < b);
|
||||
Handle<float, ushort>((a, b) => a < b);
|
||||
Handle<float, int>((a, b) => a < b);
|
||||
Handle<float, uint>((a, b) => a < b);
|
||||
Handle<float, long>((a, b) => a < b);
|
||||
Handle<float, ulong>((a, b) => a < b);
|
||||
Handle<float, float>((a, b) => a < b);
|
||||
//Handle<float, decimal>((a, b) => a < b);
|
||||
Handle<float, double>((a, b) => a < b);
|
||||
|
||||
Handle<decimal, byte>((a, b) => a < b);
|
||||
Handle<decimal, sbyte>((a, b) => a < b);
|
||||
Handle<decimal, short>((a, b) => a < b);
|
||||
Handle<decimal, ushort>((a, b) => a < b);
|
||||
Handle<decimal, int>((a, b) => a < b);
|
||||
Handle<decimal, uint>((a, b) => a < b);
|
||||
Handle<decimal, long>((a, b) => a < b);
|
||||
Handle<decimal, ulong>((a, b) => a < b);
|
||||
//Handle<decimal, float>((a, b) => a < b);
|
||||
Handle<decimal, decimal>((a, b) => a < b);
|
||||
//Handle<decimal, double>((a, b) => a < b);
|
||||
|
||||
Handle<double, byte>((a, b) => a < b);
|
||||
Handle<double, sbyte>((a, b) => a < b);
|
||||
Handle<double, short>((a, b) => a < b);
|
||||
Handle<double, ushort>((a, b) => a < b);
|
||||
Handle<double, int>((a, b) => a < b);
|
||||
Handle<double, uint>((a, b) => a < b);
|
||||
Handle<double, long>((a, b) => a < b);
|
||||
Handle<double, ulong>((a, b) => a < b);
|
||||
Handle<double, float>((a, b) => a < b);
|
||||
//Handle<double, decimal>((a, b) => a < b);
|
||||
Handle<double, double>((a, b) => a < b);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: be0be1dccfccc4cef9ffc756df949339
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,142 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public class LessThanOrEqualHandler : BinaryOperatorHandler
|
||||
{
|
||||
public LessThanOrEqualHandler() : base("Less Than Or Equal", "Less Than Or Equal", ">=", "op_LessThanOrEqual")
|
||||
{
|
||||
Handle<byte, byte>((a, b) => a <= b);
|
||||
Handle<byte, sbyte>((a, b) => a <= b);
|
||||
Handle<byte, short>((a, b) => a <= b);
|
||||
Handle<byte, ushort>((a, b) => a <= b);
|
||||
Handle<byte, int>((a, b) => a <= b);
|
||||
Handle<byte, uint>((a, b) => a <= b);
|
||||
Handle<byte, long>((a, b) => a <= b);
|
||||
Handle<byte, ulong>((a, b) => a <= b);
|
||||
Handle<byte, float>((a, b) => a <= b);
|
||||
Handle<byte, decimal>((a, b) => a <= b);
|
||||
Handle<byte, double>((a, b) => a <= b);
|
||||
|
||||
Handle<sbyte, byte>((a, b) => a <= b);
|
||||
Handle<sbyte, sbyte>((a, b) => a <= b);
|
||||
Handle<sbyte, short>((a, b) => a <= b);
|
||||
Handle<sbyte, ushort>((a, b) => a <= b);
|
||||
Handle<sbyte, int>((a, b) => a <= b);
|
||||
Handle<sbyte, uint>((a, b) => a <= b);
|
||||
Handle<sbyte, long>((a, b) => a <= b);
|
||||
//Handle<sbyte, ulong>((a, b) => a <= b);
|
||||
Handle<sbyte, float>((a, b) => a <= b);
|
||||
Handle<sbyte, decimal>((a, b) => a <= b);
|
||||
Handle<sbyte, double>((a, b) => a <= b);
|
||||
|
||||
Handle<short, byte>((a, b) => a <= b);
|
||||
Handle<short, sbyte>((a, b) => a <= b);
|
||||
Handle<short, short>((a, b) => a <= b);
|
||||
Handle<short, ushort>((a, b) => a <= b);
|
||||
Handle<short, int>((a, b) => a <= b);
|
||||
Handle<short, uint>((a, b) => a <= b);
|
||||
Handle<short, long>((a, b) => a <= b);
|
||||
//Handle<short, ulong>((a, b) => a <= b);
|
||||
Handle<short, float>((a, b) => a <= b);
|
||||
Handle<short, decimal>((a, b) => a <= b);
|
||||
Handle<short, double>((a, b) => a <= b);
|
||||
|
||||
Handle<ushort, byte>((a, b) => a <= b);
|
||||
Handle<ushort, sbyte>((a, b) => a <= b);
|
||||
Handle<ushort, short>((a, b) => a <= b);
|
||||
Handle<ushort, ushort>((a, b) => a <= b);
|
||||
Handle<ushort, int>((a, b) => a <= b);
|
||||
Handle<ushort, uint>((a, b) => a <= b);
|
||||
Handle<ushort, long>((a, b) => a <= b);
|
||||
Handle<ushort, ulong>((a, b) => a <= b);
|
||||
Handle<ushort, float>((a, b) => a <= b);
|
||||
Handle<ushort, decimal>((a, b) => a <= b);
|
||||
Handle<ushort, double>((a, b) => a <= b);
|
||||
|
||||
Handle<int, byte>((a, b) => a <= b);
|
||||
Handle<int, sbyte>((a, b) => a <= b);
|
||||
Handle<int, short>((a, b) => a <= b);
|
||||
Handle<int, ushort>((a, b) => a <= b);
|
||||
Handle<int, int>((a, b) => a <= b);
|
||||
Handle<int, uint>((a, b) => a <= b);
|
||||
Handle<int, long>((a, b) => a <= b);
|
||||
//Handle<int, ulong>((a, b) => a <= b);
|
||||
Handle<int, float>((a, b) => a <= b);
|
||||
Handle<int, decimal>((a, b) => a <= b);
|
||||
Handle<int, double>((a, b) => a <= b);
|
||||
|
||||
Handle<uint, byte>((a, b) => a <= b);
|
||||
Handle<uint, sbyte>((a, b) => a <= b);
|
||||
Handle<uint, short>((a, b) => a <= b);
|
||||
Handle<uint, ushort>((a, b) => a <= b);
|
||||
Handle<uint, int>((a, b) => a <= b);
|
||||
Handle<uint, uint>((a, b) => a <= b);
|
||||
Handle<uint, long>((a, b) => a <= b);
|
||||
Handle<uint, ulong>((a, b) => a <= b);
|
||||
Handle<uint, float>((a, b) => a <= b);
|
||||
Handle<uint, decimal>((a, b) => a <= b);
|
||||
Handle<uint, double>((a, b) => a <= b);
|
||||
|
||||
Handle<long, byte>((a, b) => a <= b);
|
||||
Handle<long, sbyte>((a, b) => a <= b);
|
||||
Handle<long, short>((a, b) => a <= b);
|
||||
Handle<long, ushort>((a, b) => a <= b);
|
||||
Handle<long, int>((a, b) => a <= b);
|
||||
Handle<long, uint>((a, b) => a <= b);
|
||||
Handle<long, long>((a, b) => a <= b);
|
||||
//Handle<long, ulong>((a, b) => a <= b);
|
||||
Handle<long, float>((a, b) => a <= b);
|
||||
Handle<long, decimal>((a, b) => a <= b);
|
||||
Handle<long, double>((a, b) => a <= b);
|
||||
|
||||
Handle<ulong, byte>((a, b) => a <= b);
|
||||
//Handle<ulong, sbyte>((a, b) => a <= b);
|
||||
//Handle<ulong, short>((a, b) => a <= b);
|
||||
Handle<ulong, ushort>((a, b) => a <= b);
|
||||
//Handle<ulong, int>((a, b) => a <= b);
|
||||
Handle<ulong, uint>((a, b) => a <= b);
|
||||
//Handle<ulong, long>((a, b) => a <= b);
|
||||
Handle<ulong, ulong>((a, b) => a <= b);
|
||||
Handle<ulong, float>((a, b) => a <= b);
|
||||
Handle<ulong, decimal>((a, b) => a <= b);
|
||||
Handle<ulong, double>((a, b) => a <= b);
|
||||
|
||||
Handle<float, byte>((a, b) => a <= b);
|
||||
Handle<float, sbyte>((a, b) => a <= b);
|
||||
Handle<float, short>((a, b) => a <= b);
|
||||
Handle<float, ushort>((a, b) => a <= b);
|
||||
Handle<float, int>((a, b) => a <= b);
|
||||
Handle<float, uint>((a, b) => a <= b);
|
||||
Handle<float, long>((a, b) => a <= b);
|
||||
Handle<float, ulong>((a, b) => a <= b);
|
||||
Handle<float, float>((a, b) => a <= b || Mathf.Approximately(a, b));
|
||||
//Handle<float, decimal>((a, b) => a <= b);
|
||||
Handle<float, double>((a, b) => a <= b);
|
||||
|
||||
Handle<decimal, byte>((a, b) => a <= b);
|
||||
Handle<decimal, sbyte>((a, b) => a <= b);
|
||||
Handle<decimal, short>((a, b) => a <= b);
|
||||
Handle<decimal, ushort>((a, b) => a <= b);
|
||||
Handle<decimal, int>((a, b) => a <= b);
|
||||
Handle<decimal, uint>((a, b) => a <= b);
|
||||
Handle<decimal, long>((a, b) => a <= b);
|
||||
Handle<decimal, ulong>((a, b) => a <= b);
|
||||
//Handle<decimal, float>((a, b) => a <= b);
|
||||
Handle<decimal, decimal>((a, b) => a <= b);
|
||||
//Handle<decimal, double>((a, b) => a <= b);
|
||||
|
||||
Handle<double, byte>((a, b) => a <= b);
|
||||
Handle<double, sbyte>((a, b) => a <= b);
|
||||
Handle<double, short>((a, b) => a <= b);
|
||||
Handle<double, ushort>((a, b) => a <= b);
|
||||
Handle<double, int>((a, b) => a <= b);
|
||||
Handle<double, uint>((a, b) => a <= b);
|
||||
Handle<double, long>((a, b) => a <= b);
|
||||
Handle<double, ulong>((a, b) => a <= b);
|
||||
Handle<double, float>((a, b) => a <= b);
|
||||
//Handle<double, decimal>((a, b) => a <= b);
|
||||
Handle<double, double>((a, b) => a <= b);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c955172d57ffa4ea89294770ef02caef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,18 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public sealed class LogicalNegationHandler : UnaryOperatorHandler
|
||||
{
|
||||
public LogicalNegationHandler() : base("Logical Negation", "Not", "~", "op_OnesComplement")
|
||||
{
|
||||
Handle<bool>(a => !a);
|
||||
Handle<byte>(a => ~a);
|
||||
Handle<sbyte>(a => ~a);
|
||||
Handle<short>(a => ~a);
|
||||
Handle<ushort>(a => ~a);
|
||||
Handle<int>(a => ~a);
|
||||
Handle<uint>(a => ~a);
|
||||
Handle<long>(a => ~a);
|
||||
Handle<ulong>(a => ~a);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e14630a9514064be79c5de1ca7565cbe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,140 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public sealed class ModuloHandler : BinaryOperatorHandler
|
||||
{
|
||||
public ModuloHandler() : base("Modulo", "Modulo", "%", "op_Modulus")
|
||||
{
|
||||
Handle<byte, byte>((a, b) => a % b);
|
||||
Handle<byte, sbyte>((a, b) => a % b);
|
||||
Handle<byte, short>((a, b) => a % b);
|
||||
Handle<byte, ushort>((a, b) => a % b);
|
||||
Handle<byte, int>((a, b) => a % b);
|
||||
Handle<byte, uint>((a, b) => a % b);
|
||||
Handle<byte, long>((a, b) => a % b);
|
||||
Handle<byte, ulong>((a, b) => a % b);
|
||||
Handle<byte, float>((a, b) => a % b);
|
||||
Handle<byte, decimal>((a, b) => a % b);
|
||||
Handle<byte, double>((a, b) => a % b);
|
||||
|
||||
Handle<sbyte, byte>((a, b) => a % b);
|
||||
Handle<sbyte, sbyte>((a, b) => a % b);
|
||||
Handle<sbyte, short>((a, b) => a % b);
|
||||
Handle<sbyte, ushort>((a, b) => a % b);
|
||||
Handle<sbyte, int>((a, b) => a % b);
|
||||
Handle<sbyte, uint>((a, b) => a % b);
|
||||
Handle<sbyte, long>((a, b) => a % b);
|
||||
//Handle<sbyte, ulong>((a, b) => a % b);
|
||||
Handle<sbyte, float>((a, b) => a % b);
|
||||
Handle<sbyte, decimal>((a, b) => a % b);
|
||||
Handle<sbyte, double>((a, b) => a % b);
|
||||
|
||||
Handle<short, byte>((a, b) => a % b);
|
||||
Handle<short, sbyte>((a, b) => a % b);
|
||||
Handle<short, short>((a, b) => a % b);
|
||||
Handle<short, ushort>((a, b) => a % b);
|
||||
Handle<short, int>((a, b) => a % b);
|
||||
Handle<short, uint>((a, b) => a % b);
|
||||
Handle<short, long>((a, b) => a % b);
|
||||
//Handle<short, ulong>((a, b) => a % b);
|
||||
Handle<short, float>((a, b) => a % b);
|
||||
Handle<short, decimal>((a, b) => a % b);
|
||||
Handle<short, double>((a, b) => a % b);
|
||||
|
||||
Handle<ushort, byte>((a, b) => a % b);
|
||||
Handle<ushort, sbyte>((a, b) => a % b);
|
||||
Handle<ushort, short>((a, b) => a % b);
|
||||
Handle<ushort, ushort>((a, b) => a % b);
|
||||
Handle<ushort, int>((a, b) => a % b);
|
||||
Handle<ushort, uint>((a, b) => a % b);
|
||||
Handle<ushort, long>((a, b) => a % b);
|
||||
Handle<ushort, ulong>((a, b) => a % b);
|
||||
Handle<ushort, float>((a, b) => a % b);
|
||||
Handle<ushort, decimal>((a, b) => a % b);
|
||||
Handle<ushort, double>((a, b) => a % b);
|
||||
|
||||
Handle<int, byte>((a, b) => a % b);
|
||||
Handle<int, sbyte>((a, b) => a % b);
|
||||
Handle<int, short>((a, b) => a % b);
|
||||
Handle<int, ushort>((a, b) => a % b);
|
||||
Handle<int, int>((a, b) => a % b);
|
||||
Handle<int, uint>((a, b) => a % b);
|
||||
Handle<int, long>((a, b) => a % b);
|
||||
//Handle<int, ulong>((a, b) => a % b);
|
||||
Handle<int, float>((a, b) => a % b);
|
||||
Handle<int, decimal>((a, b) => a % b);
|
||||
Handle<int, double>((a, b) => a % b);
|
||||
|
||||
Handle<uint, byte>((a, b) => a % b);
|
||||
Handle<uint, sbyte>((a, b) => a % b);
|
||||
Handle<uint, short>((a, b) => a % b);
|
||||
Handle<uint, ushort>((a, b) => a % b);
|
||||
Handle<uint, int>((a, b) => a % b);
|
||||
Handle<uint, uint>((a, b) => a % b);
|
||||
Handle<uint, long>((a, b) => a % b);
|
||||
Handle<uint, ulong>((a, b) => a % b);
|
||||
Handle<uint, float>((a, b) => a % b);
|
||||
Handle<uint, decimal>((a, b) => a % b);
|
||||
Handle<uint, double>((a, b) => a % b);
|
||||
|
||||
Handle<long, byte>((a, b) => a % b);
|
||||
Handle<long, sbyte>((a, b) => a % b);
|
||||
Handle<long, short>((a, b) => a % b);
|
||||
Handle<long, ushort>((a, b) => a % b);
|
||||
Handle<long, int>((a, b) => a % b);
|
||||
Handle<long, uint>((a, b) => a % b);
|
||||
Handle<long, long>((a, b) => a % b);
|
||||
//Handle<long, ulong>((a, b) => a % b);
|
||||
Handle<long, float>((a, b) => a % b);
|
||||
Handle<long, decimal>((a, b) => a % b);
|
||||
Handle<long, double>((a, b) => a % b);
|
||||
|
||||
Handle<ulong, byte>((a, b) => a % b);
|
||||
//Handle<ulong, sbyte>((a, b) => a % b);
|
||||
//Handle<ulong, short>((a, b) => a % b);
|
||||
Handle<ulong, ushort>((a, b) => a % b);
|
||||
//Handle<ulong, int>((a, b) => a % b);
|
||||
Handle<ulong, uint>((a, b) => a % b);
|
||||
//Handle<ulong, long>((a, b) => a % b);
|
||||
Handle<ulong, ulong>((a, b) => a % b);
|
||||
Handle<ulong, float>((a, b) => a % b);
|
||||
Handle<ulong, decimal>((a, b) => a % b);
|
||||
Handle<ulong, double>((a, b) => a % b);
|
||||
|
||||
Handle<float, byte>((a, b) => a % b);
|
||||
Handle<float, sbyte>((a, b) => a % b);
|
||||
Handle<float, short>((a, b) => a % b);
|
||||
Handle<float, ushort>((a, b) => a % b);
|
||||
Handle<float, int>((a, b) => a % b);
|
||||
Handle<float, uint>((a, b) => a % b);
|
||||
Handle<float, long>((a, b) => a % b);
|
||||
Handle<float, ulong>((a, b) => a % b);
|
||||
Handle<float, float>((a, b) => a % b);
|
||||
//Handle<float, decimal>((a, b) => a % b);
|
||||
Handle<float, double>((a, b) => a % b);
|
||||
|
||||
Handle<decimal, byte>((a, b) => a % b);
|
||||
Handle<decimal, sbyte>((a, b) => a % b);
|
||||
Handle<decimal, short>((a, b) => a % b);
|
||||
Handle<decimal, ushort>((a, b) => a % b);
|
||||
Handle<decimal, int>((a, b) => a % b);
|
||||
Handle<decimal, uint>((a, b) => a % b);
|
||||
Handle<decimal, long>((a, b) => a % b);
|
||||
Handle<decimal, ulong>((a, b) => a % b);
|
||||
//Handle<decimal, float>((a, b) => a % b);
|
||||
Handle<decimal, decimal>((a, b) => a % b);
|
||||
//Handle<decimal, double>((a, b) => a % b);
|
||||
|
||||
Handle<double, byte>((a, b) => a % b);
|
||||
Handle<double, sbyte>((a, b) => a % b);
|
||||
Handle<double, short>((a, b) => a % b);
|
||||
Handle<double, ushort>((a, b) => a % b);
|
||||
Handle<double, int>((a, b) => a % b);
|
||||
Handle<double, uint>((a, b) => a % b);
|
||||
Handle<double, long>((a, b) => a % b);
|
||||
Handle<double, ulong>((a, b) => a % b);
|
||||
Handle<double, float>((a, b) => a % b);
|
||||
//Handle<double, decimal>((a, b) => a % b);
|
||||
Handle<double, double>((a, b) => a % b);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 951eec3420d7c48d2b7f8cd764b18650
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,140 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public sealed class MultiplicationHandler : BinaryOperatorHandler
|
||||
{
|
||||
public MultiplicationHandler() : base("Multiplication", "Multiply", "*", "op_Multiply")
|
||||
{
|
||||
Handle<byte, byte>((a, b) => a * b);
|
||||
Handle<byte, sbyte>((a, b) => a * b);
|
||||
Handle<byte, short>((a, b) => a * b);
|
||||
Handle<byte, ushort>((a, b) => a * b);
|
||||
Handle<byte, int>((a, b) => a * b);
|
||||
Handle<byte, uint>((a, b) => a * b);
|
||||
Handle<byte, long>((a, b) => a * b);
|
||||
Handle<byte, ulong>((a, b) => a * b);
|
||||
Handle<byte, float>((a, b) => a * b);
|
||||
Handle<byte, decimal>((a, b) => a * b);
|
||||
Handle<byte, double>((a, b) => a * b);
|
||||
|
||||
Handle<sbyte, byte>((a, b) => a * b);
|
||||
Handle<sbyte, sbyte>((a, b) => a * b);
|
||||
Handle<sbyte, short>((a, b) => a * b);
|
||||
Handle<sbyte, ushort>((a, b) => a * b);
|
||||
Handle<sbyte, int>((a, b) => a * b);
|
||||
Handle<sbyte, uint>((a, b) => a * b);
|
||||
Handle<sbyte, long>((a, b) => a * b);
|
||||
//Handle<sbyte, ulong>((a, b) => a * b);
|
||||
Handle<sbyte, float>((a, b) => a * b);
|
||||
Handle<sbyte, decimal>((a, b) => a * b);
|
||||
Handle<sbyte, double>((a, b) => a * b);
|
||||
|
||||
Handle<short, byte>((a, b) => a * b);
|
||||
Handle<short, sbyte>((a, b) => a * b);
|
||||
Handle<short, short>((a, b) => a * b);
|
||||
Handle<short, ushort>((a, b) => a * b);
|
||||
Handle<short, int>((a, b) => a * b);
|
||||
Handle<short, uint>((a, b) => a * b);
|
||||
Handle<short, long>((a, b) => a * b);
|
||||
//Handle<short, ulong>((a, b) => a * b);
|
||||
Handle<short, float>((a, b) => a * b);
|
||||
Handle<short, decimal>((a, b) => a * b);
|
||||
Handle<short, double>((a, b) => a * b);
|
||||
|
||||
Handle<ushort, byte>((a, b) => a * b);
|
||||
Handle<ushort, sbyte>((a, b) => a * b);
|
||||
Handle<ushort, short>((a, b) => a * b);
|
||||
Handle<ushort, ushort>((a, b) => a * b);
|
||||
Handle<ushort, int>((a, b) => a * b);
|
||||
Handle<ushort, uint>((a, b) => a * b);
|
||||
Handle<ushort, long>((a, b) => a * b);
|
||||
Handle<ushort, ulong>((a, b) => a * b);
|
||||
Handle<ushort, float>((a, b) => a * b);
|
||||
Handle<ushort, decimal>((a, b) => a * b);
|
||||
Handle<ushort, double>((a, b) => a * b);
|
||||
|
||||
Handle<int, byte>((a, b) => a * b);
|
||||
Handle<int, sbyte>((a, b) => a * b);
|
||||
Handle<int, short>((a, b) => a * b);
|
||||
Handle<int, ushort>((a, b) => a * b);
|
||||
Handle<int, int>((a, b) => a * b);
|
||||
Handle<int, uint>((a, b) => a * b);
|
||||
Handle<int, long>((a, b) => a * b);
|
||||
//Handle<int, ulong>((a, b) => a * b);
|
||||
Handle<int, float>((a, b) => a * b);
|
||||
Handle<int, decimal>((a, b) => a * b);
|
||||
Handle<int, double>((a, b) => a * b);
|
||||
|
||||
Handle<uint, byte>((a, b) => a * b);
|
||||
Handle<uint, sbyte>((a, b) => a * b);
|
||||
Handle<uint, short>((a, b) => a * b);
|
||||
Handle<uint, ushort>((a, b) => a * b);
|
||||
Handle<uint, int>((a, b) => a * b);
|
||||
Handle<uint, uint>((a, b) => a * b);
|
||||
Handle<uint, long>((a, b) => a * b);
|
||||
Handle<uint, ulong>((a, b) => a * b);
|
||||
Handle<uint, float>((a, b) => a * b);
|
||||
Handle<uint, decimal>((a, b) => a * b);
|
||||
Handle<uint, double>((a, b) => a * b);
|
||||
|
||||
Handle<long, byte>((a, b) => a * b);
|
||||
Handle<long, sbyte>((a, b) => a * b);
|
||||
Handle<long, short>((a, b) => a * b);
|
||||
Handle<long, ushort>((a, b) => a * b);
|
||||
Handle<long, int>((a, b) => a * b);
|
||||
Handle<long, uint>((a, b) => a * b);
|
||||
Handle<long, long>((a, b) => a * b);
|
||||
//Handle<long, ulong>((a, b) => a * b);
|
||||
Handle<long, float>((a, b) => a * b);
|
||||
Handle<long, decimal>((a, b) => a * b);
|
||||
Handle<long, double>((a, b) => a * b);
|
||||
|
||||
Handle<ulong, byte>((a, b) => a * b);
|
||||
//Handle<ulong, sbyte>((a, b) => a * b);
|
||||
//Handle<ulong, short>((a, b) => a * b);
|
||||
Handle<ulong, ushort>((a, b) => a * b);
|
||||
//Handle<ulong, int>((a, b) => a * b);
|
||||
Handle<ulong, uint>((a, b) => a * b);
|
||||
//Handle<ulong, long>((a, b) => a * b);
|
||||
Handle<ulong, ulong>((a, b) => a * b);
|
||||
Handle<ulong, float>((a, b) => a * b);
|
||||
Handle<ulong, decimal>((a, b) => a * b);
|
||||
Handle<ulong, double>((a, b) => a * b);
|
||||
|
||||
Handle<float, byte>((a, b) => a * b);
|
||||
Handle<float, sbyte>((a, b) => a * b);
|
||||
Handle<float, short>((a, b) => a * b);
|
||||
Handle<float, ushort>((a, b) => a * b);
|
||||
Handle<float, int>((a, b) => a * b);
|
||||
Handle<float, uint>((a, b) => a * b);
|
||||
Handle<float, long>((a, b) => a * b);
|
||||
Handle<float, ulong>((a, b) => a * b);
|
||||
Handle<float, float>((a, b) => a * b);
|
||||
//Handle<float, decimal>((a, b) => a * b);
|
||||
Handle<float, double>((a, b) => a * b);
|
||||
|
||||
Handle<decimal, byte>((a, b) => a * b);
|
||||
Handle<decimal, sbyte>((a, b) => a * b);
|
||||
Handle<decimal, short>((a, b) => a * b);
|
||||
Handle<decimal, ushort>((a, b) => a * b);
|
||||
Handle<decimal, int>((a, b) => a * b);
|
||||
Handle<decimal, uint>((a, b) => a * b);
|
||||
Handle<decimal, long>((a, b) => a * b);
|
||||
Handle<decimal, ulong>((a, b) => a * b);
|
||||
//Handle<decimal, float>((a, b) => a * b);
|
||||
Handle<decimal, decimal>((a, b) => a * b);
|
||||
//Handle<decimal, double>((a, b) => a * b);
|
||||
|
||||
Handle<double, byte>((a, b) => a * b);
|
||||
Handle<double, sbyte>((a, b) => a * b);
|
||||
Handle<double, short>((a, b) => a * b);
|
||||
Handle<double, ushort>((a, b) => a * b);
|
||||
Handle<double, int>((a, b) => a * b);
|
||||
Handle<double, uint>((a, b) => a * b);
|
||||
Handle<double, long>((a, b) => a * b);
|
||||
Handle<double, ulong>((a, b) => a * b);
|
||||
Handle<double, float>((a, b) => a * b);
|
||||
//Handle<double, decimal>((a, b) => a * b);
|
||||
Handle<double, double>((a, b) => a * b);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b7e750bab85614562acb6c17af1874fa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,20 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public sealed class NumericNegationHandler : UnaryOperatorHandler
|
||||
{
|
||||
public NumericNegationHandler() : base("Numeric Negation", "Negate", "-", "op_UnaryNegation")
|
||||
{
|
||||
Handle<byte>(a => -a);
|
||||
Handle<sbyte>(a => -a);
|
||||
Handle<short>(a => -a);
|
||||
Handle<ushort>(a => -a);
|
||||
Handle<int>(a => -a);
|
||||
Handle<uint>(a => -a);
|
||||
Handle<long>(a => -a);
|
||||
//Handle<ulong>(a => -a);
|
||||
Handle<float>(a => -a);
|
||||
Handle<decimal>(a => -a);
|
||||
Handle<double>(a => -a);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6ac39bd0abb61457399c6377fe2cdcc2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public abstract class OperatorException : InvalidCastException
|
||||
{
|
||||
protected OperatorException() : base() { }
|
||||
protected OperatorException(string message) : base(message) { }
|
||||
protected OperatorException(string message, Exception innerException) : base(message, innerException) { }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 46d4b046e765e4eeb8d73bbf9f5470ec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,22 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public abstract class OperatorHandler
|
||||
{
|
||||
protected OperatorHandler(string name, string verb, string symbol, string customMethodName)
|
||||
{
|
||||
Ensure.That(nameof(name)).IsNotNull(name);
|
||||
Ensure.That(nameof(verb)).IsNotNull(verb);
|
||||
Ensure.That(nameof(symbol)).IsNotNull(symbol);
|
||||
|
||||
this.name = name;
|
||||
this.verb = verb;
|
||||
this.symbol = symbol;
|
||||
this.customMethodName = customMethodName;
|
||||
}
|
||||
|
||||
public string name { get; }
|
||||
public string verb { get; }
|
||||
public string symbol { get; }
|
||||
public string customMethodName { get; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fc755412ef51440c086b9a82a3eb1e97
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,311 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public static class OperatorUtility
|
||||
{
|
||||
static OperatorUtility()
|
||||
{
|
||||
unaryOperatorHandlers.Add(UnaryOperator.LogicalNegation, logicalNegationHandler);
|
||||
unaryOperatorHandlers.Add(UnaryOperator.NumericNegation, numericNegationHandler);
|
||||
unaryOperatorHandlers.Add(UnaryOperator.Increment, incrementHandler);
|
||||
unaryOperatorHandlers.Add(UnaryOperator.Decrement, decrementHandler);
|
||||
unaryOperatorHandlers.Add(UnaryOperator.Plus, plusHandler);
|
||||
|
||||
binaryOpeatorHandlers.Add(BinaryOperator.Addition, additionHandler);
|
||||
binaryOpeatorHandlers.Add(BinaryOperator.Subtraction, subtractionHandler);
|
||||
binaryOpeatorHandlers.Add(BinaryOperator.Multiplication, multiplicationHandler);
|
||||
binaryOpeatorHandlers.Add(BinaryOperator.Division, divisionHandler);
|
||||
binaryOpeatorHandlers.Add(BinaryOperator.Modulo, moduloHandler);
|
||||
binaryOpeatorHandlers.Add(BinaryOperator.And, andHandler);
|
||||
binaryOpeatorHandlers.Add(BinaryOperator.Or, orHandler);
|
||||
binaryOpeatorHandlers.Add(BinaryOperator.ExclusiveOr, exclusiveOrHandler);
|
||||
binaryOpeatorHandlers.Add(BinaryOperator.Equality, equalityHandler);
|
||||
binaryOpeatorHandlers.Add(BinaryOperator.Inequality, inequalityHandler);
|
||||
binaryOpeatorHandlers.Add(BinaryOperator.GreaterThan, greaterThanHandler);
|
||||
binaryOpeatorHandlers.Add(BinaryOperator.LessThan, lessThanHandler);
|
||||
binaryOpeatorHandlers.Add(BinaryOperator.GreaterThanOrEqual, greaterThanOrEqualHandler);
|
||||
binaryOpeatorHandlers.Add(BinaryOperator.LessThanOrEqual, lessThanOrEqualHandler);
|
||||
binaryOpeatorHandlers.Add(BinaryOperator.LeftShift, leftShiftHandler);
|
||||
binaryOpeatorHandlers.Add(BinaryOperator.RightShift, rightShiftHandler);
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/2sk3x8a7(v=vs.71).aspx
|
||||
public static readonly Dictionary<string, string> operatorNames = new Dictionary<string, string>
|
||||
{
|
||||
{ "op_Addition", "+" },
|
||||
{ "op_Subtraction", "-" },
|
||||
{ "op_Multiply", "*" },
|
||||
{ "op_Division", "/" },
|
||||
{ "op_Modulus", "%" },
|
||||
{ "op_ExclusiveOr", "^" },
|
||||
{ "op_BitwiseAnd", "&" },
|
||||
{ "op_BitwiseOr", "|" },
|
||||
{ "op_LogicalAnd", "&&" },
|
||||
{ "op_LogicalOr", "||" },
|
||||
{ "op_Assign", "=" },
|
||||
{ "op_LeftShift", "<<" },
|
||||
{ "op_RightShift", ">>" },
|
||||
{ "op_Equality", "==" },
|
||||
{ "op_GreaterThan", ">" },
|
||||
{ "op_LessThan", "<" },
|
||||
{ "op_Inequality", "!=" },
|
||||
{ "op_GreaterThanOrEqual", ">=" },
|
||||
{ "op_LessThanOrEqual", "<=" },
|
||||
{ "op_MultiplicationAssignment", "*=" },
|
||||
{ "op_SubtractionAssignment", "-=" },
|
||||
{ "op_ExclusiveOrAssignment", "^=" },
|
||||
{ "op_LeftShiftAssignment", "<<=" },
|
||||
{ "op_ModulusAssignment", "%=" },
|
||||
{ "op_AdditionAssignment", "+=" },
|
||||
{ "op_BitwiseAndAssignment", "&=" },
|
||||
{ "op_BitwiseOrAssignment", "|=" },
|
||||
{ "op_Comma", "," },
|
||||
{ "op_DivisionAssignment", "/=" },
|
||||
{ "op_Decrement", "--" },
|
||||
{ "op_Increment", "++" },
|
||||
{ "op_UnaryNegation", "-" },
|
||||
{ "op_UnaryPlus", "+" },
|
||||
{ "op_OnesComplement", "~" },
|
||||
};
|
||||
|
||||
public static readonly Dictionary<string, int> operatorRanks = new Dictionary<string, int>
|
||||
{
|
||||
{ "op_Addition", 2 },
|
||||
{ "op_Subtraction", 2 },
|
||||
{ "op_Multiply", 2 },
|
||||
{ "op_Division", 2 },
|
||||
{ "op_Modulus", 2 },
|
||||
{ "op_ExclusiveOr", 2 },
|
||||
{ "op_BitwiseAnd", 2 },
|
||||
{ "op_BitwiseOr", 2 },
|
||||
{ "op_LogicalAnd", 2 },
|
||||
{ "op_LogicalOr", 2 },
|
||||
{ "op_Assign", 2 },
|
||||
{ "op_LeftShift", 2 },
|
||||
{ "op_RightShift", 2 },
|
||||
{ "op_Equality", 2 },
|
||||
{ "op_GreaterThan", 2 },
|
||||
{ "op_LessThan", 2 },
|
||||
{ "op_Inequality", 2 },
|
||||
{ "op_GreaterThanOrEqual", 2 },
|
||||
{ "op_LessThanOrEqual", 2 },
|
||||
{ "op_MultiplicationAssignment", 2 },
|
||||
{ "op_SubtractionAssignment", 2 },
|
||||
{ "op_ExclusiveOrAssignment", 2 },
|
||||
{ "op_LeftShiftAssignment", 2 },
|
||||
{ "op_ModulusAssignment", 2 },
|
||||
{ "op_AdditionAssignment", 2 },
|
||||
{ "op_BitwiseAndAssignment", 2 },
|
||||
{ "op_BitwiseOrAssignment", 2 },
|
||||
{ "op_Comma", 2 },
|
||||
{ "op_DivisionAssignment", 2 },
|
||||
{ "op_Decrement", 1 },
|
||||
{ "op_Increment", 1 },
|
||||
{ "op_UnaryNegation", 1 },
|
||||
{ "op_UnaryPlus", 1 },
|
||||
{ "op_OnesComplement", 1 },
|
||||
};
|
||||
|
||||
private static readonly Dictionary<UnaryOperator, UnaryOperatorHandler> unaryOperatorHandlers = new Dictionary<UnaryOperator, UnaryOperatorHandler>();
|
||||
private static readonly Dictionary<BinaryOperator, BinaryOperatorHandler> binaryOpeatorHandlers = new Dictionary<BinaryOperator, BinaryOperatorHandler>();
|
||||
|
||||
private static readonly LogicalNegationHandler logicalNegationHandler = new LogicalNegationHandler();
|
||||
private static readonly NumericNegationHandler numericNegationHandler = new NumericNegationHandler();
|
||||
private static readonly IncrementHandler incrementHandler = new IncrementHandler();
|
||||
private static readonly DecrementHandler decrementHandler = new DecrementHandler();
|
||||
private static readonly PlusHandler plusHandler = new PlusHandler();
|
||||
|
||||
private static readonly AdditionHandler additionHandler = new AdditionHandler();
|
||||
private static readonly SubtractionHandler subtractionHandler = new SubtractionHandler();
|
||||
private static readonly MultiplicationHandler multiplicationHandler = new MultiplicationHandler();
|
||||
private static readonly DivisionHandler divisionHandler = new DivisionHandler();
|
||||
private static readonly ModuloHandler moduloHandler = new ModuloHandler();
|
||||
private static readonly AndHandler andHandler = new AndHandler();
|
||||
private static readonly OrHandler orHandler = new OrHandler();
|
||||
private static readonly ExclusiveOrHandler exclusiveOrHandler = new ExclusiveOrHandler();
|
||||
private static readonly EqualityHandler equalityHandler = new EqualityHandler();
|
||||
private static readonly InequalityHandler inequalityHandler = new InequalityHandler();
|
||||
private static readonly GreaterThanHandler greaterThanHandler = new GreaterThanHandler();
|
||||
private static readonly LessThanHandler lessThanHandler = new LessThanHandler();
|
||||
private static readonly GreaterThanOrEqualHandler greaterThanOrEqualHandler = new GreaterThanOrEqualHandler();
|
||||
private static readonly LessThanOrEqualHandler lessThanOrEqualHandler = new LessThanOrEqualHandler();
|
||||
private static readonly LeftShiftHandler leftShiftHandler = new LeftShiftHandler();
|
||||
private static readonly RightShiftHandler rightShiftHandler = new RightShiftHandler();
|
||||
|
||||
public static UnaryOperatorHandler GetHandler(UnaryOperator @operator)
|
||||
{
|
||||
if (unaryOperatorHandlers.ContainsKey(@operator))
|
||||
{
|
||||
return unaryOperatorHandlers[@operator];
|
||||
}
|
||||
|
||||
throw new UnexpectedEnumValueException<UnaryOperator>(@operator);
|
||||
}
|
||||
|
||||
public static BinaryOperatorHandler GetHandler(BinaryOperator @operator)
|
||||
{
|
||||
if (binaryOpeatorHandlers.ContainsKey(@operator))
|
||||
{
|
||||
return binaryOpeatorHandlers[@operator];
|
||||
}
|
||||
|
||||
throw new UnexpectedEnumValueException<BinaryOperator>(@operator);
|
||||
}
|
||||
|
||||
public static string Symbol(this UnaryOperator @operator)
|
||||
{
|
||||
return GetHandler(@operator).symbol;
|
||||
}
|
||||
|
||||
public static string Symbol(this BinaryOperator @operator)
|
||||
{
|
||||
return GetHandler(@operator).symbol;
|
||||
}
|
||||
|
||||
public static string Name(this UnaryOperator @operator)
|
||||
{
|
||||
return GetHandler(@operator).name;
|
||||
}
|
||||
|
||||
public static string Name(this BinaryOperator @operator)
|
||||
{
|
||||
return GetHandler(@operator).name;
|
||||
}
|
||||
|
||||
public static string Verb(this UnaryOperator @operator)
|
||||
{
|
||||
return GetHandler(@operator).verb;
|
||||
}
|
||||
|
||||
public static string Verb(this BinaryOperator @operator)
|
||||
{
|
||||
return GetHandler(@operator).verb;
|
||||
}
|
||||
|
||||
public static object Operate(UnaryOperator @operator, object x)
|
||||
{
|
||||
if (!unaryOperatorHandlers.ContainsKey(@operator))
|
||||
{
|
||||
throw new UnexpectedEnumValueException<UnaryOperator>(@operator);
|
||||
}
|
||||
|
||||
return unaryOperatorHandlers[@operator].Operate(x);
|
||||
}
|
||||
|
||||
public static object Operate(BinaryOperator @operator, object a, object b)
|
||||
{
|
||||
if (!binaryOpeatorHandlers.ContainsKey(@operator))
|
||||
{
|
||||
throw new UnexpectedEnumValueException<BinaryOperator>(@operator);
|
||||
}
|
||||
|
||||
return binaryOpeatorHandlers[@operator].Operate(a, b);
|
||||
}
|
||||
|
||||
public static object Negate(object x)
|
||||
{
|
||||
return numericNegationHandler.Operate(x);
|
||||
}
|
||||
|
||||
public static object Not(object x)
|
||||
{
|
||||
return logicalNegationHandler.Operate(x);
|
||||
}
|
||||
|
||||
public static object UnaryPlus(object x)
|
||||
{
|
||||
return plusHandler.Operate(x);
|
||||
}
|
||||
|
||||
public static object Increment(object x)
|
||||
{
|
||||
return incrementHandler.Operate(x);
|
||||
}
|
||||
|
||||
public static object Decrement(object x)
|
||||
{
|
||||
return decrementHandler.Operate(x);
|
||||
}
|
||||
|
||||
public static object And(object a, object b)
|
||||
{
|
||||
return andHandler.Operate(a, b);
|
||||
}
|
||||
|
||||
public static object Or(object a, object b)
|
||||
{
|
||||
return orHandler.Operate(a, b);
|
||||
}
|
||||
|
||||
public static object ExclusiveOr(object a, object b)
|
||||
{
|
||||
return exclusiveOrHandler.Operate(a, b);
|
||||
}
|
||||
|
||||
public static object Add(object a, object b)
|
||||
{
|
||||
return additionHandler.Operate(a, b);
|
||||
}
|
||||
|
||||
public static object Subtract(object a, object b)
|
||||
{
|
||||
return subtractionHandler.Operate(a, b);
|
||||
}
|
||||
|
||||
public static object Multiply(object a, object b)
|
||||
{
|
||||
return multiplicationHandler.Operate(a, b);
|
||||
}
|
||||
|
||||
public static object Divide(object a, object b)
|
||||
{
|
||||
return divisionHandler.Operate(a, b);
|
||||
}
|
||||
|
||||
public static object Modulo(object a, object b)
|
||||
{
|
||||
return moduloHandler.Operate(a, b);
|
||||
}
|
||||
|
||||
public static bool Equal(object a, object b)
|
||||
{
|
||||
return (bool)equalityHandler.Operate(a, b);
|
||||
}
|
||||
|
||||
public static bool NotEqual(object a, object b)
|
||||
{
|
||||
return (bool)inequalityHandler.Operate(a, b);
|
||||
}
|
||||
|
||||
public static bool GreaterThan(object a, object b)
|
||||
{
|
||||
return (bool)greaterThanHandler.Operate(a, b);
|
||||
}
|
||||
|
||||
public static bool LessThan(object a, object b)
|
||||
{
|
||||
return (bool)lessThanHandler.Operate(a, b);
|
||||
}
|
||||
|
||||
public static bool GreaterThanOrEqual(object a, object b)
|
||||
{
|
||||
return (bool)greaterThanOrEqualHandler.Operate(a, b);
|
||||
}
|
||||
|
||||
public static bool LessThanOrEqual(object a, object b)
|
||||
{
|
||||
return (bool)lessThanOrEqualHandler.Operate(a, b);
|
||||
}
|
||||
|
||||
public static object LeftShift(object a, object b)
|
||||
{
|
||||
return leftShiftHandler.Operate(a, b);
|
||||
}
|
||||
|
||||
public static object RightShift(object a, object b)
|
||||
{
|
||||
return rightShiftHandler.Operate(a, b);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 893d8390fbd9c404e974184b2cb93bf9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,84 @@
|
|||
#pragma warning disable 675
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public class OrHandler : BinaryOperatorHandler
|
||||
{
|
||||
public OrHandler() : base("Or", "Or", "|", "op_BitwiseOr")
|
||||
{
|
||||
Handle<bool, bool>((a, b) => a | b);
|
||||
|
||||
Handle<byte, byte>((a, b) => a | b);
|
||||
Handle<byte, sbyte>((a, b) => a | b);
|
||||
Handle<byte, short>((a, b) => a | b);
|
||||
Handle<byte, ushort>((a, b) => a | b);
|
||||
Handle<byte, int>((a, b) => a | b);
|
||||
Handle<byte, uint>((a, b) => a | b);
|
||||
Handle<byte, long>((a, b) => a | b);
|
||||
Handle<byte, ulong>((a, b) => a | b);
|
||||
|
||||
Handle<sbyte, byte>((a, b) => a | b);
|
||||
Handle<sbyte, sbyte>((a, b) => a | b);
|
||||
Handle<sbyte, short>((a, b) => a | b);
|
||||
Handle<sbyte, ushort>((a, b) => a | b);
|
||||
Handle<sbyte, int>((a, b) => a | b);
|
||||
Handle<sbyte, uint>((a, b) => a | b);
|
||||
Handle<sbyte, long>((a, b) => a | b);
|
||||
//Handle<sbyte, ulong>((a, b) => a | b);
|
||||
|
||||
Handle<short, byte>((a, b) => a | b);
|
||||
Handle<short, sbyte>((a, b) => a | b);
|
||||
Handle<short, short>((a, b) => a | b);
|
||||
Handle<short, ushort>((a, b) => a | b);
|
||||
Handle<short, int>((a, b) => a | b);
|
||||
Handle<short, uint>((a, b) => a | b);
|
||||
Handle<short, long>((a, b) => a | b);
|
||||
//Handle<short, ulong>((a, b) => a | b);
|
||||
|
||||
Handle<ushort, byte>((a, b) => a | b);
|
||||
Handle<ushort, sbyte>((a, b) => a | b);
|
||||
Handle<ushort, short>((a, b) => a | b);
|
||||
Handle<ushort, ushort>((a, b) => a | b);
|
||||
Handle<ushort, int>((a, b) => a | b);
|
||||
Handle<ushort, uint>((a, b) => a | b);
|
||||
Handle<ushort, long>((a, b) => a | b);
|
||||
Handle<ushort, ulong>((a, b) => a | b);
|
||||
|
||||
Handle<int, byte>((a, b) => a | b);
|
||||
Handle<int, sbyte>((a, b) => a | b);
|
||||
Handle<int, short>((a, b) => a | b);
|
||||
Handle<int, ushort>((a, b) => a | b);
|
||||
Handle<int, int>((a, b) => a | b);
|
||||
Handle<int, uint>((a, b) => a | b);
|
||||
Handle<int, long>((a, b) => a | b);
|
||||
//Handle<int, ulong>((a, b) => a | b);
|
||||
|
||||
Handle<uint, byte>((a, b) => a | b);
|
||||
Handle<uint, sbyte>((a, b) => a | b);
|
||||
Handle<uint, short>((a, b) => a | b);
|
||||
Handle<uint, ushort>((a, b) => a | b);
|
||||
Handle<uint, int>((a, b) => a | b);
|
||||
Handle<uint, uint>((a, b) => a | b);
|
||||
Handle<uint, long>((a, b) => a | b);
|
||||
Handle<uint, ulong>((a, b) => a | b);
|
||||
|
||||
Handle<long, byte>((a, b) => a | b);
|
||||
Handle<long, sbyte>((a, b) => a | b);
|
||||
Handle<long, short>((a, b) => a | b);
|
||||
Handle<long, ushort>((a, b) => a | b);
|
||||
Handle<long, int>((a, b) => a | b);
|
||||
Handle<long, uint>((a, b) => a | b);
|
||||
Handle<long, long>((a, b) => a | b);
|
||||
//Handle<long, ulong>((a, b) => a | b);
|
||||
|
||||
Handle<ulong, byte>((a, b) => a | b);
|
||||
//Handle<ulong, sbyte>((a, b) => a | b);
|
||||
//Handle<ulong, short>((a, b) => a | b);
|
||||
Handle<ulong, ushort>((a, b) => a | b);
|
||||
//Handle<ulong, int>((a, b) => a | b);
|
||||
Handle<ulong, uint>((a, b) => a | b);
|
||||
//Handle<ulong, long>((a, b) => a | b);
|
||||
Handle<ulong, ulong>((a, b) => a | b);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8357065a14e1d47138e7d19e3a5ac7fa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,20 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public sealed class PlusHandler : UnaryOperatorHandler
|
||||
{
|
||||
public PlusHandler() : base("Plus", "Plus", "+", "op_UnaryPlus")
|
||||
{
|
||||
Handle<byte>(a => +a);
|
||||
Handle<sbyte>(a => +a);
|
||||
Handle<short>(a => +a);
|
||||
Handle<ushort>(a => +a);
|
||||
Handle<int>(a => +a);
|
||||
Handle<uint>(a => +a);
|
||||
Handle<long>(a => +a);
|
||||
Handle<ulong>(a => +a);
|
||||
Handle<float>(a => +a);
|
||||
Handle<decimal>(a => +a);
|
||||
Handle<double>(a => +a);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 74765ebacef5c4d3796689d3fdbfb3ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,56 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public class RightShiftHandler : BinaryOperatorHandler
|
||||
{
|
||||
public RightShiftHandler() : base("Right Shift", "Right Shift", ">>", "op_RightShift")
|
||||
{
|
||||
Handle<byte, byte>((a, b) => a >> b);
|
||||
Handle<byte, sbyte>((a, b) => a >> b);
|
||||
Handle<byte, short>((a, b) => a >> b);
|
||||
Handle<byte, ushort>((a, b) => a >> b);
|
||||
Handle<byte, int>((a, b) => a >> b);
|
||||
|
||||
Handle<sbyte, byte>((a, b) => a >> b);
|
||||
Handle<sbyte, sbyte>((a, b) => a >> b);
|
||||
Handle<sbyte, short>((a, b) => a >> b);
|
||||
Handle<sbyte, ushort>((a, b) => a >> b);
|
||||
Handle<sbyte, int>((a, b) => a >> b);
|
||||
|
||||
Handle<short, byte>((a, b) => a >> b);
|
||||
Handle<short, sbyte>((a, b) => a >> b);
|
||||
Handle<short, short>((a, b) => a >> b);
|
||||
Handle<short, ushort>((a, b) => a >> b);
|
||||
Handle<short, int>((a, b) => a >> b);
|
||||
|
||||
Handle<ushort, byte>((a, b) => a >> b);
|
||||
Handle<ushort, sbyte>((a, b) => a >> b);
|
||||
Handle<ushort, short>((a, b) => a >> b);
|
||||
Handle<ushort, ushort>((a, b) => a >> b);
|
||||
Handle<ushort, int>((a, b) => a >> b);
|
||||
|
||||
Handle<int, byte>((a, b) => a >> b);
|
||||
Handle<int, sbyte>((a, b) => a >> b);
|
||||
Handle<int, short>((a, b) => a >> b);
|
||||
Handle<int, ushort>((a, b) => a >> b);
|
||||
Handle<int, int>((a, b) => a >> b);
|
||||
|
||||
Handle<uint, byte>((a, b) => a >> b);
|
||||
Handle<uint, sbyte>((a, b) => a >> b);
|
||||
Handle<uint, short>((a, b) => a >> b);
|
||||
Handle<uint, ushort>((a, b) => a >> b);
|
||||
Handle<uint, int>((a, b) => a >> b);
|
||||
|
||||
Handle<long, byte>((a, b) => a >> b);
|
||||
Handle<long, sbyte>((a, b) => a >> b);
|
||||
Handle<long, short>((a, b) => a >> b);
|
||||
Handle<long, ushort>((a, b) => a >> b);
|
||||
Handle<long, int>((a, b) => a >> b);
|
||||
|
||||
Handle<ulong, byte>((a, b) => a >> b);
|
||||
Handle<ulong, sbyte>((a, b) => a >> b);
|
||||
Handle<ulong, short>((a, b) => a >> b);
|
||||
Handle<ulong, ushort>((a, b) => a >> b);
|
||||
Handle<ulong, int>((a, b) => a >> b);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 72025ee3eb5ee41eebfffa6066a9ff95
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,140 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public sealed class SubtractionHandler : BinaryOperatorHandler
|
||||
{
|
||||
public SubtractionHandler() : base("Subtraction", "Subtract", "-", "op_Subtraction")
|
||||
{
|
||||
Handle<byte, byte>((a, b) => a - b);
|
||||
Handle<byte, sbyte>((a, b) => a - b);
|
||||
Handle<byte, short>((a, b) => a - b);
|
||||
Handle<byte, ushort>((a, b) => a - b);
|
||||
Handle<byte, int>((a, b) => a - b);
|
||||
Handle<byte, uint>((a, b) => a - b);
|
||||
Handle<byte, long>((a, b) => a - b);
|
||||
Handle<byte, ulong>((a, b) => a - b);
|
||||
Handle<byte, float>((a, b) => a - b);
|
||||
Handle<byte, decimal>((a, b) => a - b);
|
||||
Handle<byte, double>((a, b) => a - b);
|
||||
|
||||
Handle<sbyte, byte>((a, b) => a - b);
|
||||
Handle<sbyte, sbyte>((a, b) => a - b);
|
||||
Handle<sbyte, short>((a, b) => a - b);
|
||||
Handle<sbyte, ushort>((a, b) => a - b);
|
||||
Handle<sbyte, int>((a, b) => a - b);
|
||||
Handle<sbyte, uint>((a, b) => a - b);
|
||||
Handle<sbyte, long>((a, b) => a - b);
|
||||
//Handle<sbyte, ulong>((a, b) => a - b);
|
||||
Handle<sbyte, float>((a, b) => a - b);
|
||||
Handle<sbyte, decimal>((a, b) => a - b);
|
||||
Handle<sbyte, double>((a, b) => a - b);
|
||||
|
||||
Handle<short, byte>((a, b) => a - b);
|
||||
Handle<short, sbyte>((a, b) => a - b);
|
||||
Handle<short, short>((a, b) => a - b);
|
||||
Handle<short, ushort>((a, b) => a - b);
|
||||
Handle<short, int>((a, b) => a - b);
|
||||
Handle<short, uint>((a, b) => a - b);
|
||||
Handle<short, long>((a, b) => a - b);
|
||||
//Handle<short, ulong>((a, b) => a - b);
|
||||
Handle<short, float>((a, b) => a - b);
|
||||
Handle<short, decimal>((a, b) => a - b);
|
||||
Handle<short, double>((a, b) => a - b);
|
||||
|
||||
Handle<ushort, byte>((a, b) => a - b);
|
||||
Handle<ushort, sbyte>((a, b) => a - b);
|
||||
Handle<ushort, short>((a, b) => a - b);
|
||||
Handle<ushort, ushort>((a, b) => a - b);
|
||||
Handle<ushort, int>((a, b) => a - b);
|
||||
Handle<ushort, uint>((a, b) => a - b);
|
||||
Handle<ushort, long>((a, b) => a - b);
|
||||
Handle<ushort, ulong>((a, b) => a - b);
|
||||
Handle<ushort, float>((a, b) => a - b);
|
||||
Handle<ushort, decimal>((a, b) => a - b);
|
||||
Handle<ushort, double>((a, b) => a - b);
|
||||
|
||||
Handle<int, byte>((a, b) => a - b);
|
||||
Handle<int, sbyte>((a, b) => a - b);
|
||||
Handle<int, short>((a, b) => a - b);
|
||||
Handle<int, ushort>((a, b) => a - b);
|
||||
Handle<int, int>((a, b) => a - b);
|
||||
Handle<int, uint>((a, b) => a - b);
|
||||
Handle<int, long>((a, b) => a - b);
|
||||
//Handle<int, ulong>((a, b) => a - b);
|
||||
Handle<int, float>((a, b) => a - b);
|
||||
Handle<int, decimal>((a, b) => a - b);
|
||||
Handle<int, double>((a, b) => a - b);
|
||||
|
||||
Handle<uint, byte>((a, b) => a - b);
|
||||
Handle<uint, sbyte>((a, b) => a - b);
|
||||
Handle<uint, short>((a, b) => a - b);
|
||||
Handle<uint, ushort>((a, b) => a - b);
|
||||
Handle<uint, int>((a, b) => a - b);
|
||||
Handle<uint, uint>((a, b) => a - b);
|
||||
Handle<uint, long>((a, b) => a - b);
|
||||
Handle<uint, ulong>((a, b) => a - b);
|
||||
Handle<uint, float>((a, b) => a - b);
|
||||
Handle<uint, decimal>((a, b) => a - b);
|
||||
Handle<uint, double>((a, b) => a - b);
|
||||
|
||||
Handle<long, byte>((a, b) => a - b);
|
||||
Handle<long, sbyte>((a, b) => a - b);
|
||||
Handle<long, short>((a, b) => a - b);
|
||||
Handle<long, ushort>((a, b) => a - b);
|
||||
Handle<long, int>((a, b) => a - b);
|
||||
Handle<long, uint>((a, b) => a - b);
|
||||
Handle<long, long>((a, b) => a - b);
|
||||
//Handle<long, ulong>((a, b) => a - b);
|
||||
Handle<long, float>((a, b) => a - b);
|
||||
Handle<long, decimal>((a, b) => a - b);
|
||||
Handle<long, double>((a, b) => a - b);
|
||||
|
||||
Handle<ulong, byte>((a, b) => a - b);
|
||||
//Handle<ulong, sbyte>((a, b) => a - b);
|
||||
//Handle<ulong, short>((a, b) => a - b);
|
||||
Handle<ulong, ushort>((a, b) => a - b);
|
||||
//Handle<ulong, int>((a, b) => a - b);
|
||||
Handle<ulong, uint>((a, b) => a - b);
|
||||
//Handle<ulong, long>((a, b) => a - b);
|
||||
Handle<ulong, ulong>((a, b) => a - b);
|
||||
Handle<ulong, float>((a, b) => a - b);
|
||||
Handle<ulong, decimal>((a, b) => a - b);
|
||||
Handle<ulong, double>((a, b) => a - b);
|
||||
|
||||
Handle<float, byte>((a, b) => a - b);
|
||||
Handle<float, sbyte>((a, b) => a - b);
|
||||
Handle<float, short>((a, b) => a - b);
|
||||
Handle<float, ushort>((a, b) => a - b);
|
||||
Handle<float, int>((a, b) => a - b);
|
||||
Handle<float, uint>((a, b) => a - b);
|
||||
Handle<float, long>((a, b) => a - b);
|
||||
Handle<float, ulong>((a, b) => a - b);
|
||||
Handle<float, float>((a, b) => a - b);
|
||||
//Handle<float, decimal>((a, b) => a - b);
|
||||
Handle<float, double>((a, b) => a - b);
|
||||
|
||||
Handle<decimal, byte>((a, b) => a - b);
|
||||
Handle<decimal, sbyte>((a, b) => a - b);
|
||||
Handle<decimal, short>((a, b) => a - b);
|
||||
Handle<decimal, ushort>((a, b) => a - b);
|
||||
Handle<decimal, int>((a, b) => a - b);
|
||||
Handle<decimal, uint>((a, b) => a - b);
|
||||
Handle<decimal, long>((a, b) => a - b);
|
||||
Handle<decimal, ulong>((a, b) => a - b);
|
||||
//Handle<decimal, float>((a, b) => a - b);
|
||||
Handle<decimal, decimal>((a, b) => a - b);
|
||||
//Handle<decimal, double>((a, b) => a - b);
|
||||
|
||||
Handle<double, byte>((a, b) => a - b);
|
||||
Handle<double, sbyte>((a, b) => a - b);
|
||||
Handle<double, short>((a, b) => a - b);
|
||||
Handle<double, ushort>((a, b) => a - b);
|
||||
Handle<double, int>((a, b) => a - b);
|
||||
Handle<double, uint>((a, b) => a - b);
|
||||
Handle<double, long>((a, b) => a - b);
|
||||
Handle<double, ulong>((a, b) => a - b);
|
||||
Handle<double, float>((a, b) => a - b);
|
||||
//Handle<double, decimal>((a, b) => a - b);
|
||||
Handle<double, double>((a, b) => a - b);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c3dfdf79906724bf2bf0dcff5b0f4d04
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,11 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public enum UnaryOperator
|
||||
{
|
||||
LogicalNegation,
|
||||
NumericNegation,
|
||||
Increment,
|
||||
Decrement,
|
||||
Plus
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e2aa84da762494bc8b88aa8674bed044
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public abstract class UnaryOperatorHandler : OperatorHandler
|
||||
{
|
||||
protected UnaryOperatorHandler(string name, string verb, string symbol, string customMethodName)
|
||||
: base(name, verb, symbol, customMethodName) { }
|
||||
|
||||
private readonly Dictionary<Type, Func<object, object>> manualHandlers = new Dictionary<Type, Func<object, object>>();
|
||||
private readonly Dictionary<Type, IOptimizedInvoker> userDefinedOperators = new Dictionary<Type, IOptimizedInvoker>();
|
||||
private readonly Dictionary<Type, Type> userDefinedOperandTypes = new Dictionary<Type, Type>();
|
||||
|
||||
public object Operate(object operand)
|
||||
{
|
||||
Ensure.That(nameof(operand)).IsNotNull(operand);
|
||||
|
||||
var type = operand.GetType();
|
||||
|
||||
if (manualHandlers.ContainsKey(type))
|
||||
{
|
||||
return manualHandlers[type](operand);
|
||||
}
|
||||
|
||||
if (customMethodName != null)
|
||||
{
|
||||
if (!userDefinedOperators.ContainsKey(type))
|
||||
{
|
||||
var method = type.GetMethod(customMethodName, BindingFlags.Public | BindingFlags.Static);
|
||||
|
||||
if (method != null)
|
||||
{
|
||||
userDefinedOperandTypes.Add(type, ResolveUserDefinedOperandType(method));
|
||||
}
|
||||
|
||||
userDefinedOperators.Add(type, method?.Prewarm());
|
||||
}
|
||||
|
||||
if (userDefinedOperators[type] != null)
|
||||
{
|
||||
operand = ConversionUtility.Convert(operand, userDefinedOperandTypes[type]);
|
||||
|
||||
return userDefinedOperators[type].Invoke(null, operand);
|
||||
}
|
||||
}
|
||||
|
||||
return CustomHandling(operand);
|
||||
}
|
||||
|
||||
protected virtual object CustomHandling(object operand)
|
||||
{
|
||||
throw new InvalidOperatorException(symbol, operand.GetType());
|
||||
}
|
||||
|
||||
protected void Handle<T>(Func<T, object> handler)
|
||||
{
|
||||
manualHandlers.Add(typeof(T), operand => handler((T)operand));
|
||||
}
|
||||
|
||||
private static Type ResolveUserDefinedOperandType(MethodInfo userDefinedOperator)
|
||||
{
|
||||
// See comment in BinaryOperatorHandler
|
||||
return userDefinedOperator.GetParameters()[0].ParameterType;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d53a8293d351f4cf582ec062d60728a0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a5260e1cbe5b7460198b99b38fd2739e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,4 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public delegate void Action<T1, T2, T3, T4, T5>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 565487a8cc7c148b39f203b04f54ccd2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,4 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public delegate void Action<T1, T2, T3, T4, T5, T6>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 637699a0545ee4284830c7149ad3bcf7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,4 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public delegate TResult Func<T1, T2, T3, T4, T5, TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4c10c0720a81448b5b614a4611eee79b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,4 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public delegate TResult Func<T1, T2, T3, T4, T5, T6, TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 20e8a9131c09f44bba4bc995a46bf45b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public interface IOptimizedAccessor
|
||||
{
|
||||
void Compile();
|
||||
object GetValue(object target);
|
||||
void SetValue(object target, object value);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 31e550d17f6264ba68218683267984df
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,14 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public interface IOptimizedInvoker
|
||||
{
|
||||
void Compile();
|
||||
object Invoke(object target);
|
||||
object Invoke(object target, object arg0);
|
||||
object Invoke(object target, object arg0, object arg1);
|
||||
object Invoke(object target, object arg0, object arg1, object arg2);
|
||||
object Invoke(object target, object arg0, object arg1, object arg2, object arg3);
|
||||
object Invoke(object target, object arg0, object arg1, object arg2, object arg3, object arg4);
|
||||
object Invoke(object target, params object[] args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c48adaa9f604d4ecf8326fb23b1333c3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
using System.Reflection;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public abstract class InstanceActionInvokerBase<TTarget> : InstanceInvokerBase<TTarget>
|
||||
{
|
||||
protected InstanceActionInvokerBase(MethodInfo methodInfo) : base(methodInfo) { }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 683e53d1471354951b0723bdbae66000
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue