X Tutup
using System; using System.Linq; using System.Reflection; namespace Python.Runtime { /// /// Module level functions /// [Serializable] internal class ModuleFunctionObject : MethodObject { public ModuleFunctionObject(Type type, string name, MethodInfo[] info, bool allow_threads) : base(type, name, info, allow_threads) { if (info.Any(item => !item.IsStatic)) { throw new Exception("Module function must be static."); } } /// /// __call__ implementation. /// public static NewReference tp_call(BorrowedReference ob, BorrowedReference args, BorrowedReference kw) { var self = (ModuleFunctionObject)GetManagedObject(ob)!; return self.Invoke(ob, args, kw); } /// /// __repr__ implementation. /// public new static NewReference tp_repr(BorrowedReference ob) { var self = (ModuleFunctionObject)GetManagedObject(ob)!; return Runtime.PyString_FromString($""); } } }
X Tutup