コード例 #1
0
ファイル: UserType.cs プロジェクト: weimingtom/IronPythonMod
        object ICallableWithCallerContext.Call(ICallerContext context, object[] args)
        {
            object newMethod, newObject;


            newMethod = Ops.GetAttr(context, this, SymbolTable.NewInst);
            newObject = Ops.CallWithContext(context, newMethod, PrependThis(args));

            if (newObject == null)
            {
                return(null);
            }

            if (Ops.GetDynamicType(newObject).IsSubclassOf(this))
            {
                object init;
                if (PythonType.TryLookupSpecialMethod(DefaultContext.Default, newObject, SymbolTable.Init, out init))
                {
                    switch (args.Length)
                    {
                    case 0: Ops.CallWithContext(context, init); break;

                    case 1: Ops.CallWithContext(context, init, args[0]); break;

                    case 2: Ops.CallWithContext(context, init, args[0], args[1]); break;

                    default: Ops.CallWithContext(context, init, args); break;
                    }
                }
            }

            return(newObject);
        }
コード例 #2
0
ファイル: Importer.cs プロジェクト: weimingtom/IronPythonMod
        /// <summary>
        /// Gateway into importing ... called from Ops.  Performs the initial import of
        /// a module and returns the module.
        /// </summary>
        internal static object Import(PythonModule mod, string fullName, List from)
        {
            object importFunction = FindImportFunction(mod);

            return(Ops.CallWithContext(mod, importFunction, fullName, null, null, from));
        }