本文整理汇总了C#中IronPython.Runtime.Types.BuiltinFunction类的典型用法代码示例。如果您正苦于以下问题:C# BuiltinFunction类的具体用法?C# BuiltinFunction怎么用?C# BuiltinFunction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BuiltinFunction类属于IronPython.Runtime.Types命名空间,在下文中一共展示了BuiltinFunction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConstructorFunction
internal ConstructorFunction(BuiltinFunction realTarget, IList<MethodBase> constructors)
: base("__new__", ArrayUtils.ToArray(GetTargetsValidateFunction(realTarget)), realTarget.DeclaringType, FunctionType.Function | FunctionType.AlwaysVisible) {
base.Name = realTarget.Name;
base.FunctionType = realTarget.FunctionType;
this._ctors = ArrayUtils.ToArray(constructors);
}
示例2: GetOverload
private object GetOverload(Type[] sig, IList<MethodBase> targets, bool wrapCtors) {
// We can still end up with more than one target since generic and non-generic
// methods can share the same name and signature. So we'll build up a new
// reflected method with all the candidate targets. A caller can then index this
// reflected method if necessary in order to provide generic type arguments and
// fully disambiguate the target.
// Search for targets with the right number of arguments.
BuiltinFunction bf;
BuiltinFunction.TypeList tl = new BuiltinFunction.TypeList(sig);
lock (_function.OverloadDictionary) {
if (!_function.OverloadDictionary.TryGetValue(tl, out bf)) {
MethodBase[] newTargets = FindMatchingTargets(sig, targets);
if (targets == null)
throw ScriptingRuntimeHelpers.SimpleTypeError(String.Format("No match found for the method signature {0}", sig)); // TODO: Sig to usable display
_function.OverloadDictionary[tl] = bf = new BuiltinFunction(_function.Name, newTargets, Function.DeclaringType, _function.FunctionType);
}
}
if (_instance != null) {
return bf.BindToInstance(_instance);
} else if (wrapCtors) {
return GetTargetFunction(bf);
} else {
return bf;
}
}
示例3: BuiltinFunctionInfo
public BuiltinFunctionInfo(BuiltinFunction function, ProjectState projectState)
: base(ClrModule.GetPythonType(typeof(BuiltinFunction)), projectState)
{
// TODO: get return information, parameters, members
_function = function;
_returnTypes = Utils.GetReturnTypes(function, projectState);
_doc = null;
}
示例4: MakeOrAdd
internal static BuiltinFunction/*!*/ MakeOrAdd(BuiltinFunction existing, string name, MethodBase mi, Type declaringType, FunctionType funcType) {
PythonBinder.AssertNotExtensionType(declaringType);
if (existing != null) {
existing._data.AddMethod(mi);
return existing;
} else {
return MakeMethod(name, mi, declaringType, funcType);
}
}
示例5: CheckSelfWorker
internal static void CheckSelfWorker(CodeContext/*!*/ context, object self, BuiltinFunction template) {
// to a fast check on the CLR types, if they match we can avoid the slower
// check that involves looking up dynamic types. (self can be null on
// calls like set.add(None)
Type selfType = CompilerHelpers.GetType(self);
if (selfType != template.DeclaringType && !template.DeclaringType.IsAssignableFrom(selfType)) {
// if a conversion exists to the type allow the call.
context.LanguageContext.Binder.Convert(self, template.DeclaringType);
}
}
示例6: BuiltinFunctionOverloadResult
internal BuiltinFunctionOverloadResult(ProjectState state, BuiltinFunction overload, int removedParams, string name, params ParameterResult[] extraParams)
: base(null, name)
{
_overload = overload;
_extraParameters = extraParams;
_removedParams = removedParams;
_projectState = state;
CalculateDocumentation();
}
示例7: TryGetStaticFunction
/// <summary>
/// Trys to get the BuiltinFunction for the given name on the type of the provided MetaObject.
///
/// Succeeds if the MetaObject is a BuiltinFunction or BuiltinMethodDescriptor.
/// </summary>
internal static bool TryGetStaticFunction(BinderState/*!*/ state, SymbolId op, DynamicMetaObject/*!*/ mo, out BuiltinFunction function) {
PythonType type = MetaPythonObject.GetPythonType(mo);
function = null;
if (op != SymbolId.Empty) {
PythonTypeSlot xSlot;
object val;
if (type.TryResolveSlot(state.Context, op, out xSlot) &&
xSlot.TryGetValue(state.Context, null, type, out val)) {
function = TryConvertToBuiltinFunction(val);
if (function == null) return false;
}
}
return true;
}
示例8: TryGetStaticFunction
/// <summary>
/// Tries to get the BuiltinFunction for the given name on the type of the provided MetaObject.
///
/// Succeeds if the MetaObject is a BuiltinFunction or BuiltinMethodDescriptor.
/// </summary>
internal static bool TryGetStaticFunction(PythonContext/*!*/ state, string op, DynamicMetaObject/*!*/ mo, out BuiltinFunction function) {
PythonType type = MetaPythonObject.GetPythonType(mo);
function = null;
if (!String.IsNullOrEmpty(op)) {
PythonTypeSlot xSlot;
object val;
if (type.TryResolveSlot(state.SharedContext, op, out xSlot) &&
xSlot.TryGetValue(state.SharedContext, null, type, out val)) {
function = TryConvertToBuiltinFunction(val);
if (function == null) return false;
}
}
return true;
}
示例9: BuiltinCallable
public BuiltinCallable(BinderState/*!*/ binder, string op, BuiltinFunction/*!*/ func)
: base(binder, op) {
Assert.NotNull(func);
_bf = func;
}
示例10: BuiltinInitAdapter
public BuiltinInitAdapter(ArgumentValues/*!*/ ai, BuiltinFunction/*!*/ method, PythonContext/*!*/ state, Expression/*!*/ codeContext)
: base(ai, state, codeContext) {
_method = method;
}
示例11: BuiltinNewAdapter
public BuiltinNewAdapter(ArgumentValues/*!*/ ai, PythonType/*!*/ creating, BuiltinFunction/*!*/ ctor, PythonContext/*!*/ state, Expression/*!*/ codeContext)
: base(ai, state, codeContext) {
_creating = creating;
_ctor = ctor;
}
示例12: CheckAlwaysNotImplemented
private static BuiltinFunction CheckAlwaysNotImplemented(BuiltinFunction xBf) {
if (xBf != null) {
bool returnsValue = false;
foreach (MethodBase mb in xBf.Targets) {
if (mb.GetReturnType() != typeof(NotImplementedType) ||
mb.IsDefined(typeof(Python3WarningAttribute), true)) {
returnsValue = true;
break;
}
}
if (!returnsValue) {
xBf = null;
}
}
return xBf;
}
示例13: SetConstructor
internal void SetConstructor(BuiltinFunction ctor) {
_ctor = ctor;
}
示例14: MakeCallable
/// <summary>
/// Creates a new CallableObject. If BuiltinFunction is available we'll create a BuiltinCallable otherwise
/// we create a SlotCallable.
/// </summary>
public static Callable MakeCallable(PythonContext/*!*/ binder, PythonIndexType op, BuiltinFunction itemFunc, PythonTypeSlot itemSlot) {
if (itemFunc != null) {
// we'll call a builtin function to produce the rule
return new BuiltinCallable(binder, op, itemFunc);
} else if (itemSlot != null) {
// we'll call a PythonTypeSlot to produce the rule
return new SlotCallable(binder, op, itemSlot);
}
return null;
}
示例15: ClassMethodDescriptor
internal ClassMethodDescriptor(BuiltinFunction func) {
this._func = func;
}