[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/gpetrou/pythonnet/SignKey/src/runtime/modulefunctionobject.cs [Back]  [Original]

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 IntPtr tp_call(IntPtr ob, IntPtr args, IntPtr kw)
        {
            var self = (ModuleFunctionObject)GetManagedObject(ob);
            return self.Invoke(ob, args, kw);
        }

        /// 
        /// __repr__ implementation.
        /// 
        public new static IntPtr tp_repr(IntPtr ob)
        {
            var self = (ModuleFunctionObject)GetManagedObject(ob);
            return Runtime.PyString_FromString($"");
        }
    }
}

Web Proxy Viewer  |  New URL  |  Original Page