private int CompareStrings(CallSite site, object arg0, object arg1) { if (arg0 != null && arg0.GetType() == typeof(string) && arg1 != null && arg1.GetType() == typeof(string)) { return(StringOps.Compare((string)arg0, (string)arg1)); } return(((CallSite <Func <CallSite, object, object, int> >)site).Update(site, arg0, arg1)); }
public int __cmp__(object other) { BuiltinMethodDescriptor bmd = other as BuiltinMethodDescriptor; if (bmd == null) { throw PythonOps.TypeError("instancemethod.__cmp__(x,y) requires y to be a 'instancemethod', not a {0}", PythonTypeOps.GetName(other)); } long result = PythonOps.Id(__objclass__) - PythonOps.Id(bmd.__objclass__); if (result != 0) { return (result > 0) ? 1 : -1; } return StringOps.Compare(__name__, bmd.__name__); }