public static bool Equal(RubyContext /*!*/ context, object lhs, object rhs) { return(RubyOps.IsTrue(EqualSharedSite.Target(EqualSharedSite, context, lhs, rhs))); }
public static Single ConvertToSingle(object value) { return(_floatSite.Target(_floatSite, value)); }
public static Char ConvertToChar(object value) { return(_charSite.Target(_charSite, value)); }
public static Boolean ConvertToBoolean(object value) { return(_boolSite.Target(_boolSite, value)); }
public static Int16 ConvertToInt16(object value) { return(_int16Site.Target(_int16Site, value)); }
public static String ConvertToString(object value) { return(_stringSite.Target(_stringSite, value)); }
public static Double ConvertToDouble(object value) { return(_doubleSite.Target(_doubleSite, value)); }
public static uint ConvertToUInt32(object value) { return(_uint32Site.Target(_uint32Site, value)); }
public static Int32 ConvertToInt32(object value) { return(_intSite.Target(_intSite, value)); }
public static long ConvertToInt64(object value) { return(_int64Site.Target(_int64Site, value)); }
public static ushort ConvertToUInt16(object value) { return(_uint16Site.Target(_uint16Site, value)); }
public static double ToF(RubyContext /*!*/ context, object value) { return(_ToFSharedSite.Target(_ToFSharedSite, context, value)); }
public static object ToInt(RubyContext /*!*/ context, object value) { return(_ToIntSharedSite.Target(_ToIntSharedSite, context, value)); }
public static bool RespondTo(RubyContext /*!*/ context, object obj, SymbolId name) { return(RubyOps.IsTrue(RespondToSharedSite.Target(RespondToSharedSite, context, obj, name))); }
public static bool RespondTo(CallSite <Func <CallSite, object, object, object> > /*!*/ respondToSite, RubyContext /*!*/ context, object target, string /*!*/ methodName) { return(IsTrue(respondToSite.Target(respondToSite, target, context.EncodeIdentifier(methodName)))); }
public static IEnumerable ConvertToIEnumerable(object o) { return(_ienumerableSite.Target(_ienumerableSite, o)); }
private void AssignSiteDelegates(CallSite <Func <CallSite, object, int> > hashSite, CallSite <Func <CallSite, object, object, bool> > equalSite) { _hashFunc = (o) => hashSite.Target(hashSite, o); _eqFunc = (o1, o2) => equalSite.Target(equalSite, o1, o2); }
/// <summary> /// Returns indication of field found, plus the value of a field for the object and name supplied. /// </summary> public static Tuple <bool, object> ExtractFieldValue(object SourceObject, string FieldName) { if (SourceObject == null) { throw new UsageAnomaly("Cannot read the member named '" + FieldName + "' from a null object reference."); } FieldInfo FieldData = SourceObject.GetType().GetField(FieldName); Tuple <bool, object> Result = null; /* THIS WAS NOT POSSIBLE * if (SourceObject is DynamicObject) * { * var DynamicSource = SourceObject as DynamicObject; * object Value = null; * var MemberBinder = new GetMemberBinder(); // CANNOT BE PROVIDED. IS ABSTRACT. * MemberBinder.Name = FieldName; * var CanGet = DynamicSource.TryGetMember(MemberBinder, out Value); * Result = new Tuple<bool, object>(CanGet, Value); * } * else */ if (SourceObject is IDynamicMetaObjectProvider) { // EFFECTIVE ALTERNATIVE (ALBEIT SLOW, HENCE THE CACHING) var QualifiedName = SourceObject.GetType().FullName + General.STR_SEPARATOR + FieldName; CallSite <Func <CallSite, object, object> > CallingSite = null; if (CachedCallSites.ContainsKey(QualifiedName)) { CallingSite = CachedCallSites[QualifiedName]; } else { var MemberBinder = Microsoft.CSharp.RuntimeBinder.Binder.GetMember( Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags.None, FieldName, SourceObject.GetType(), Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create( Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags.None, null).IntoArray()); CallingSite = CallSite <Func <CallSite, object, object> > .Create(MemberBinder); CachedCallSites.Add(QualifiedName, CallingSite); } try { Result = Tuple.Create(true, CallingSite.Target(CallingSite, SourceObject)); } catch { Result = Tuple.Create(false, (object)null); } return(Result); } else { Result = (new Tuple <bool, object>(FieldData != null, FieldData != null ? FieldData.GetValue(SourceObject) : null)); } return(Result); }
public static BigInteger ConvertToBigInteger(object value) { return(_bigIntSite.Target(_bigIntSite, value)); }
/// <summary> /// Gets the member name from the object obj. Throws an exception if the member does not exist or is write-only. /// </summary> public object GetMember(object obj, string name, bool ignoreCase) { CallSite <Func <CallSite, object, object> > site = GetOrCreateSite <object, object>(_lc.CreateGetMemberBinder(name, ignoreCase)); return(site.Target(site, obj)); }
public static Complex ConvertToComplex(object value) { return(_complexSite.Target(_complexSite, value)); }
/// <summary> /// Removes the member name from the object obj. Returns true if the member was successfully removed /// or false if the member does not exist. /// </summary> public void RemoveMember(object obj, string name, bool ignoreCase) { CallSite <Action <CallSite, object> > site = GetOrCreateActionSite <object>(_lc.CreateDeleteMemberBinder(name, ignoreCase)); site.Target(site, obj); }
public static SByte ConvertToSByte(object value) { return(_sbyteSite.Target(_sbyteSite, value)); }
/// <summary> /// Sets the member name on object obj to value. This overload can be used to avoid /// boxing and casting of strongly typed members. /// </summary> public void SetMember <T>(object obj, string name, T value, bool ignoreCase) { CallSite <Func <CallSite, object, T, object> > site = GetOrCreateSite <object, T, object>(_lc.CreateSetMemberBinder(name, ignoreCase)); site.Target(site, obj, value); }
public static UInt64 ConvertToUInt64(object value) { return(_uint64Site.Target(_uint64Site, value)); }
/// <summary> /// Convers the object obj to the type T including implicit conversions. /// </summary> public T ImplicitConvertTo <T>(object obj) { CallSite <Func <CallSite, object, T> > site = GetOrCreateSite <object, T>(_lc.CreateConvertBinder(typeof(T), false)); return(site.Target(site, obj)); }
public static Decimal ConvertToDecimal(object value) { return(_decimalSite.Target(_decimalSite, value)); }
/// <summary> /// Converts the object obj to the type type including implicit conversions. /// </summary> public object ImplicitConvertTo(object obj, Type type) { CallSite <Func <CallSite, object, object> > site = GetOrCreateSite <object, object>(_lc.CreateConvertBinder(type, false)); return(site.Target(site, obj)); }
internal static Char ExplicitConvertToChar(object value) { return(_explicitCharSite.Target(_explicitCharSite, value)); }
public static object Allocate(RubyClass /*!*/ classObj) { return(AllocateSharedSite.Target(AllocateSharedSite, classObj.Context, classObj)); }