public object Invoke(object self) { if (func == null) { throw Ops.AttributeError("{0} not defined on instance of {1}", name, pythonType.__name__); } if (funcAsFunc != null) { return(funcAsFunc.Call(self)); } return(Ops.Call(Ops.GetDescriptor(func, self, pythonType))); }
public object Call(params object[] args) { if (args.Length == 0) { throw Ops.TypeError("descriptor {0} of {1} needs an argument", Ops.Repr(Name), Ops.Repr(DeclaringType.__name__)); } CheckSelf(args[0]); return(template.Call(args)); }
private bool TryOptimizedCall(object[] args, out object ret) { // create the target if it doesn't already exist. We cache the // target incase the user stores the reflected method somewhere // and continues to call the unoptimized version. if (optimizedTarget == null) { OptimizeMethod(); } if (optimizedTarget != null) { BuiltinFunction optimized = optimizedTarget; if (HasInstance) { optimized = optimized.Clone(); optimized.inst = inst; } ret = optimized.Call(args); return(true); } ret = null; return(false); }