コード例 #1
0
        public static MethodWrapper MakeForObject(PythonType pt, SymbolId name, Delegate func)
        {
            MethodWrapper ret = new MethodWrapper(pt, name);

            ret.isObjectMethod    = true;
            ret.isBuiltinMethod   = true;
            ret.isSuperTypeMethod = false;

            ret.func       = BuiltinFunction.Make((string)SymbolTable.IdToString(name), func, new MethodBase[] { func.Method });
            ret.funcAsFunc = ret.func as BuiltinFunction;

            //pt.dict[name] = ret;

            return(ret);
        }
コード例 #2
0
ファイル: UserType.cs プロジェクト: weimingtom/IronPythonMod
        protected UserType(string name, Tuple bases, IDictionary <object, object> dict)
            : base(NewTypeMaker.GetNewType(name, bases, dict))
        {
            List <MethodInfo> ctors = new List <MethodInfo>();

            foreach (MethodInfo mi in type.GetMethods())
            {
                if (mi.Name == ReflectedType.MakeNewName)
                {
                    ctors.Add(mi);
                }
            }

            if (ctors.Count == 0)
            {
                throw new NotImplementedException("no MakeNew found");
            }

            ctor = BuiltinFunction.Make(name, ctors.ToArray(), ctors.ToArray(), FunctionType.Function);

            IAttributesDictionary fastDict = (IAttributesDictionary)dict;

            this.__name__   = name;
            this.__module__ = fastDict[SymbolTable.Module];   // should always be present...

            if (!fastDict.ContainsKey(SymbolTable.Doc))
            {
                fastDict[SymbolTable.Doc] = null;
            }

            InitializeUserType(bases, false);

            this.dict = CreateNamespaceDictionary(dict);

            AddProtocolWrappers();
        }