本文整理汇总了C#中IronPython.Runtime.Types.BuiltinFunction类的典型用法代码示例。如果您正苦于以下问题:C# BuiltinFunction类的具体用法?C# BuiltinFunction怎么用?C# BuiltinFunction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BuiltinFunction类属于IronPython.Runtime.Types命名空间,在下文中一共展示了BuiltinFunction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:jcteague,项目名称:ironruby,代码行数:7,代码来源:ConstructorFunction.cs
示例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;
}
}
开发者ID:jcteague,项目名称:ironruby,代码行数:29,代码来源:BuiltinFunctionOverloadMapper.cs
示例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;
}
开发者ID:TerabyteX,项目名称:main,代码行数:9,代码来源:BuiltinFunctionInfo.cs
示例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);
}
}
开发者ID:octavioh,项目名称:ironruby,代码行数:10,代码来源:BuiltinFunction.cs
示例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);
}
}
开发者ID:octavioh,项目名称:ironruby,代码行数:10,代码来源:BuiltinMethodDescriptor.cs
示例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();
}
开发者ID:TerabyteX,项目名称:main,代码行数:10,代码来源:OverloadResult.cs
示例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;
}
开发者ID:m4dc4p,项目名称:ironruby,代码行数:19,代码来源:BindingHelpers.cs
示例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;
}
开发者ID:jschementi,项目名称:iron,代码行数:19,代码来源:BindingHelpers.cs
示例9: BuiltinCallable
public BuiltinCallable(BinderState/*!*/ binder, string op, BuiltinFunction/*!*/ func)
: base(binder, op) {
Assert.NotNull(func);
_bf = func;
}
开发者ID:octavioh,项目名称:ironruby,代码行数:6,代码来源:PythonProtocol.Operations.cs
示例10: BuiltinInitAdapter
public BuiltinInitAdapter(ArgumentValues/*!*/ ai, BuiltinFunction/*!*/ method, PythonContext/*!*/ state, Expression/*!*/ codeContext)
: base(ai, state, codeContext) {
_method = method;
}
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:4,代码来源:MetaPythonType.Calls.cs
示例11: BuiltinNewAdapter
public BuiltinNewAdapter(ArgumentValues/*!*/ ai, PythonType/*!*/ creating, BuiltinFunction/*!*/ ctor, PythonContext/*!*/ state, Expression/*!*/ codeContext)
: base(ai, state, codeContext) {
_creating = creating;
_ctor = ctor;
}
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:5,代码来源:MetaPythonType.Calls.cs
示例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;
}
开发者ID:jschementi,项目名称:iron,代码行数:17,代码来源:SlotOrFunction.cs
示例13: SetConstructor
internal void SetConstructor(BuiltinFunction ctor) {
_ctor = ctor;
}
开发者ID:octavioh,项目名称:ironruby,代码行数:3,代码来源:PythonType.cs
示例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;
}
开发者ID:jdhardy,项目名称:ironpython,代码行数:15,代码来源:PythonProtocol.Operations.cs
示例15: ClassMethodDescriptor
internal ClassMethodDescriptor(BuiltinFunction func) {
this._func = func;
}
开发者ID:jcteague,项目名称:ironruby,代码行数:3,代码来源:ClassMethodDescriptor.cs
示例16: GetTargetFunction
protected override object GetTargetFunction(BuiltinFunction bf) {
// return a function that's bound to the overloads, we'll
// the user then calls this w/ the dynamic type, and the bound
// function drops the class & calls the overload.
if (bf.Targets[0].DeclaringType != typeof(InstanceOps)) {
return new ConstructorFunction(InstanceOps.OverloadedNew, bf.Targets).BindToInstance(bf);
}
return base.GetTargetFunction(bf);
}
开发者ID:jcteague,项目名称:ironruby,代码行数:10,代码来源:BuiltinFunctionOverloadMapper.cs
示例17: BuiltinFunctionOverloadMapper
private PythonTuple _allOverloads; // overloads are stored here and may be bound to an instance
public BuiltinFunctionOverloadMapper(BuiltinFunction builtinFunction, object instance) {
this._function = builtinFunction;
this._instance = instance;
}
开发者ID:jcteague,项目名称:ironruby,代码行数:6,代码来源:BuiltinFunctionOverloadMapper.cs
示例18: GetBuiltinFunctionOverloads
private static ICollection<OverloadDoc> GetBuiltinFunctionOverloads(BuiltinFunction bf) {
OverloadDoc[] res = new OverloadDoc[bf.Targets.Count];
for (int i = 0; i < bf.Targets.Count; i++) {
res[i] = GetOverloadDoc(bf.__name__, bf.Targets[i]);
}
return res;
}
开发者ID:rudimk,项目名称:dlr-dotnet,代码行数:7,代码来源:PythonDocumentationProvider.cs
示例19: SpecializedBuiltinFunction
public SpecializedBuiltinFunction(ProjectState state, BuiltinFunction function, Func<CallExpression, AnalysisUnit, ISet<Namespace>[], ISet<Namespace>> call)
: base(function, state)
{
_call = call;
}
开发者ID:TerabyteX,项目名称:main,代码行数:5,代码来源:SpecializedBuiltinFunction.cs
示例20: GetTargetsValidateFunction
private static IList<MethodBase> GetTargetsValidateFunction(BuiltinFunction realTarget) {
ContractUtils.RequiresNotNull(realTarget, "realTarget");
return realTarget.Targets;
}
开发者ID:jcteague,项目名称:ironruby,代码行数:4,代码来源:ConstructorFunction.cs
注:本文中的IronPython.Runtime.Types.BuiltinFunction类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论