C# Class IronPython.Runtime.Binding.PythonProtocol

Afficher le fichier Open project: jschementi/iron Class Usage Examples

Méthodes publiques

Méthode Description
DirectOperation ( PythonOperationKind op ) : PythonOperationKind
Index ( DynamicMetaObjectBinder operation, PythonIndexType index, DynamicMetaObject args ) : DynamicMetaObject
Index ( DynamicMetaObjectBinder operation, PythonIndexType index, DynamicMetaObject args, DynamicMetaObject errorSuggestion ) : DynamicMetaObject
Operation ( BinaryOperationBinder operation, DynamicMetaObject target, DynamicMetaObject arg, DynamicMetaObject errorSuggestion ) : DynamicMetaObject
Operation ( IronPython.Runtime.Binding.PythonOperationBinder operation ) : DynamicMetaObject
Operation ( UnaryOperationBinder operation, DynamicMetaObject arg, DynamicMetaObject errorSuggestion ) : DynamicMetaObject
TypeError ( DynamicMetaObjectBinder action, string message ) : DynamicMetaObject

Produces an error message for the provided message and type names. The error message should contain string formatting characters ({0}, {1}, etc...) for each of the type names.

Private Methods

Méthode Description
CheckMissing ( Expression toCheck ) : Expression
CoerceOne ( System.Linq.Expressions.ParameterExpression coerceTuple ) : MethodCallExpression
CoerceTwo ( System.Linq.Expressions.ParameterExpression coerceTuple ) : MethodCallExpression
ConvertArgs ( DynamicMetaObject types ) : DynamicMetaObject[]

Helper to convert all of the arguments to their known types.

DoCoerce ( PythonContext state, ConditionalBuilder bodyBuilder, PythonOperationKind op, DynamicMetaObject types, bool reverse ) : void
DoCoerce ( PythonContext pyContext, ConditionalBuilder bodyBuilder, PythonOperationKind op, DynamicMetaObject types, bool reverse, Expression>.Func returnTransform ) : void

calls __coerce__ for old-style classes and performs the operation if the coercion is successful.

FastPathCompare ( DynamicMetaObject types ) : DynamicMetaObject
GenericFallback ( DynamicMetaObjectBinder action, DynamicMetaObject types ) : DynamicMetaObject
GetCompareExpression ( PythonOperationKind op, bool reverse, Expression value ) : Expression
GetCompareNode ( PythonOperationKind op, bool reverse, Expression expr ) : Expression
GetCompareTest ( PythonOperationKind op, Expression expr, bool reverse ) : Expression
GetComparisonFallbackMethod ( PythonOperationKind op ) : MethodInfo
GetGetOrDeleteParameter ( DynamicMetaObject args, int index ) : Expression
GetGetOrDeleteSlice ( PythonContext state, DynamicMetaObject args ) : DynamicMetaObject
GetIndexOperators ( PythonIndexType op, string &item, string &slice, int &mandatoryArgs ) : void

Helper to get the symbols for __*item__ and __*slice__ based upon if we're doing a get/set/delete and the minimum number of arguments required for each of those.

GetItemSliceArguments ( PythonContext state, PythonIndexType op, DynamicMetaObject types ) : DynamicMetaObject[]

Gets the arguments that need to be provided to __*item__ when we need to pass a slice object.

GetOperatorDisplay ( PythonOperationKind op ) : string
GetOpreatorMethods ( DynamicMetaObject types, PythonOperationKind oper, PythonContext state, SlotOrFunction &fbinder, SlotOrFunction &rbinder, PythonTypeSlot &fSlot, PythonTypeSlot &rSlot ) : void
GetSetParameter ( DynamicMetaObject args, int index ) : Expression
GetSetSlice ( PythonContext state, DynamicMetaObject args ) : DynamicMetaObject
HasOnlyNumericTypes ( DynamicMetaObjectBinder action, DynamicMetaObject types, bool skipLast ) : bool
HashBigInt ( IronPython.Runtime.Binding.PythonOperationBinder operation, Expression expression ) : DynamicExpression
HashConvertToInt ( PythonContext state, Expression expression ) : DynamicExpression
IsComparison ( PythonOperationKind op ) : bool
IsComparisonOperator ( PythonOperationKind op ) : bool
IsIndexType ( PythonContext state, DynamicMetaObject obj ) : bool
IsReverseOperator ( PythonOperationKind oper ) : bool
IsSequence ( DynamicMetaObject metaObject ) : bool
IsSlice ( PythonIndexType op ) : bool
MakeBinaryOpErrorMessage ( PythonOperationKind op, string xType, string yType ) : string
MakeBinaryOperation ( DynamicMetaObjectBinder operation, DynamicMetaObject args, PythonOperationKind opStr, DynamicMetaObject errorSuggestion ) : DynamicMetaObject
MakeBinaryOperatorResult ( DynamicMetaObject types, DynamicMetaObjectBinder operation, PythonOperationKind op, SlotOrFunction fCand, SlotOrFunction rCand, PythonTypeSlot fSlot, PythonTypeSlot rSlot, DynamicMetaObject errorSuggestion ) : DynamicMetaObject
MakeBinaryThrow ( DynamicMetaObjectBinder action, PythonOperationKind op, DynamicMetaObject args ) : DynamicMetaObject
MakeCallSignatureOperation ( DynamicMetaObject self, IList targets ) : DynamicMetaObject
MakeCompareReturn ( ConditionalBuilder bodyBuilder, Expression retCondition, Expression retValue, bool isReverse, Type retType ) : void
MakeCompareReverse ( ConditionalBuilder bodyBuilder, Expression retCondition, Expression expr, bool reverse, Type retType ) : void
MakeCompareTest ( PythonOperationKind op, ConditionalBuilder bodyBuilder, Expression retCond, Expression expr, bool reverse, Type retType ) : void
MakeCompareToNegativeOne ( ConditionalBuilder bodyBuilder, Expression retCondition, Expression expr, bool reverse, Type retType ) : void
MakeCompareToOne ( ConditionalBuilder bodyBuilder, Expression retCondition, Expression expr, bool reverse, Type retType ) : void
MakeCompareToZero ( ConditionalBuilder bodyBuilder, Expression retCondition, Expression expr, bool reverse, Type retType ) : void
MakeComparisonOperation ( DynamicMetaObject types, DynamicMetaObjectBinder operation, PythonOperationKind opString, DynamicMetaObject errorSuggestion ) : DynamicMetaObject
MakeContainsOperation ( IronPython.Runtime.Binding.PythonOperationBinder operation, DynamicMetaObject types ) : DynamicMetaObject

Creates a rule for the contains operator. This is exposed via "x in y" in IronPython. It is implemented by calling the __contains__ method on x and passing in y. If a type doesn't define __contains__ but does define __getitem__ then __getitem__ is called repeatedly in order to see if the object is there. For normal .NET enumerables we'll walk the iterator and see if it's present.

MakeDocumentationOperation ( IronPython.Runtime.Binding.PythonOperationBinder operation, DynamicMetaObject args ) : DynamicMetaObject
MakeEnumeratorOperation ( IronPython.Runtime.Binding.PythonOperationBinder operation, DynamicMetaObject self ) : DynamicMetaObject
MakeEnumeratorResult ( Expression tmp ) : NewExpression
MakeFallbackCompare ( DynamicMetaObjectBinder binder, PythonOperationKind op, DynamicMetaObject types ) : Expression
MakeHashOperation ( IronPython.Runtime.Binding.PythonOperationBinder operation, DynamicMetaObject self ) : DynamicMetaObject
MakeIndexerOperation ( DynamicMetaObjectBinder operation, PythonIndexType op, DynamicMetaObject types, DynamicMetaObject errorSuggestion ) : DynamicMetaObject

Python has three protocols for slicing: Simple Slicing x[i:j] Extended slicing x[i,j,k,...] Long Slice x[start:stop:step] The first maps to __*slice__ (get, set, and del). This takes indexes - i, j - which specify the range of elements to be returned. In the slice variants both i, j must be numeric data types. The 2nd and 3rd are both __*item__. This receives a single index which is either a Tuple or a Slice object (which encapsulates the start, stop, and step values) This is in addition to a simple indexing x[y]. For simple slicing and long slicing Python generates Operators.*Slice. For the extended slicing and simple indexing Python generates a Operators.*Item action. Extended slicing maps to the normal .NET multi-parameter input. So our job here is to first determine if we're to call a __*slice__ method or a __*item__ method.

MakeIscallableOperation ( IronPython.Runtime.Binding.PythonOperationBinder operation, DynamicMetaObject args ) : DynamicMetaObject
MakeOneCompareGeneric ( SlotOrFunction target, bool reverse, DynamicMetaObject types, ComparisonHelper returner, ConditionalBuilder bodyBuilder, Type retType ) : bool

Helper to handle a comparison operator call. Checks to see if the call can return NotImplemented and allows the caller to modify the expression that is ultimately returned (e.g. to turn __cmp__ into a bool after a comparison)

MakeOneTarget ( PythonContext state, SlotOrFunction target, PythonTypeSlot slotTarget, ConditionalBuilder bodyBuilder, bool reverse, DynamicMetaObject types ) : bool
MakeOperationRule ( IronPython.Runtime.Binding.PythonOperationBinder operation, DynamicMetaObject args ) : DynamicMetaObject
MakeRuleForNoMatch ( DynamicMetaObjectBinder operation, PythonOperationKind op, DynamicMetaObject errorSuggestion ) : DynamicMetaObject
MakeSimpleOperation ( DynamicMetaObject types, DynamicMetaObjectBinder binder, PythonOperationKind operation, DynamicMetaObject errorSuggestion ) : DynamicMetaObject
MakeSlotCall ( PythonContext state, DynamicMetaObject types, ConditionalBuilder bodyBuilder, PythonTypeSlot slotTarget, bool reverse ) : void
MakeSlotCallWorker ( PythonContext state, PythonTypeSlot slotTarget, Expression self, ConditionalBuilder bodyBuilder ) : void
MakeSortComparisonRule ( DynamicMetaObject types, DynamicMetaObjectBinder operation, PythonOperationKind op ) : DynamicMetaObject

Makes the comparison rule which returns an int (-1, 0, 1). TODO: Better name?

MakeUnaryNotOperation ( DynamicMetaObjectBinder operation, DynamicMetaObject self, Type retType, DynamicMetaObject errorSuggestion ) : DynamicMetaObject
MakeUnaryOpErrorMessage ( string op, string xType ) : string
MakeUnaryOperation ( DynamicMetaObjectBinder binder, DynamicMetaObject self, string symbol, DynamicMetaObject errorSuggestion ) : DynamicMetaObject
MakeUnindexableError ( DynamicMetaObjectBinder operation, PythonIndexType op, DynamicMetaObject types, DynamicMetaObject indexedType, PythonContext state ) : DynamicMetaObject
MakeValueCheck ( int val, Expression retValue, ConditionalBuilder bodyBuilder, Expression retCondition ) : void
NormalizeOperator ( PythonOperationKind op ) : PythonOperationKind
OperatorToReverseOperator ( PythonOperationKind op ) : PythonOperationKind
RestrictTypes ( DynamicMetaObject types ) : void
ReverseCompareValue ( Expression retVal ) : BinaryExpression
ShouldCoerce ( PythonContext state, PythonOperationKind operation, DynamicMetaObject x, DynamicMetaObject y, bool isCompare ) : bool

Checks if a coercion check should be performed. We perform coercion under the following situations: 1. Old instances performing a binary operator (excluding rich comparisons) 2. User-defined new instances calling __cmp__ but only if we wouldn't dispatch to a built-in __coerce__ on the parent type This matches the behavior of CPython.

Method Details

DirectOperation() public static méthode

public static DirectOperation ( PythonOperationKind op ) : PythonOperationKind
op PythonOperationKind
Résultat PythonOperationKind

Index() public static méthode

public static Index ( DynamicMetaObjectBinder operation, PythonIndexType index, DynamicMetaObject args ) : DynamicMetaObject
operation DynamicMetaObjectBinder
index PythonIndexType
args DynamicMetaObject
Résultat DynamicMetaObject

Index() public static méthode

public static Index ( DynamicMetaObjectBinder operation, PythonIndexType index, DynamicMetaObject args, DynamicMetaObject errorSuggestion ) : DynamicMetaObject
operation DynamicMetaObjectBinder
index PythonIndexType
args DynamicMetaObject
errorSuggestion DynamicMetaObject
Résultat DynamicMetaObject

Operation() public static méthode

public static Operation ( BinaryOperationBinder operation, DynamicMetaObject target, DynamicMetaObject arg, DynamicMetaObject errorSuggestion ) : DynamicMetaObject
operation BinaryOperationBinder
target DynamicMetaObject
arg DynamicMetaObject
errorSuggestion DynamicMetaObject
Résultat DynamicMetaObject

Operation() public static méthode

public static Operation ( IronPython.Runtime.Binding.PythonOperationBinder operation ) : DynamicMetaObject
operation IronPython.Runtime.Binding.PythonOperationBinder
Résultat DynamicMetaObject

Operation() public static méthode

public static Operation ( UnaryOperationBinder operation, DynamicMetaObject arg, DynamicMetaObject errorSuggestion ) : DynamicMetaObject
operation UnaryOperationBinder
arg DynamicMetaObject
errorSuggestion DynamicMetaObject
Résultat DynamicMetaObject

TypeError() public static méthode

Produces an error message for the provided message and type names. The error message should contain string formatting characters ({0}, {1}, etc...) for each of the type names.
public static TypeError ( DynamicMetaObjectBinder action, string message ) : DynamicMetaObject
action DynamicMetaObjectBinder
message string
Résultat DynamicMetaObject