Ejemplo n.º 1
0
        internal IMember MakeObject(ObjectIdentityHandle obj)
        {
            if (obj.IsNull)
            {
                return(null);
            }

            lock (this) {
                IMember res;
                if (_members.TryGetValue(obj, out res))
                {
                    return(res);
                }

                switch (_remote.GetObjectKind(obj))
                {
                case ObjectKind.Module: res = new IronPythonModule(this, obj); break;

                case ObjectKind.Type: res = new IronPythonType(this, obj); break;

                case ObjectKind.ConstructorFunction: res = new IronPythonConstructorFunction(this, _remote.GetConstructorFunctionTargets(obj), GetTypeFromType(_remote.GetConstructorFunctionDeclaringType(obj))); break;

                case ObjectKind.BuiltinFunction: res = new IronPythonBuiltinFunction(this, obj); break;

                case ObjectKind.BuiltinMethodDesc: res = new IronPythonBuiltinMethodDescriptor(this, obj); break;

                case ObjectKind.ReflectedEvent: res = new IronPythonEvent(this, obj); break;

                case ObjectKind.ReflectedExtensionProperty: res = new IronPythonExtensionProperty(this, obj); break;

                case ObjectKind.ReflectedField: res = new IronPythonField(this, obj); break;

                case ObjectKind.ReflectedProperty: res = new IronPythonProperty(this, obj); break;

                case ObjectKind.TypeGroup: res = new IronPythonTypeGroup(this, obj); break;

                case ObjectKind.NamespaceTracker: res = new IronPythonNamespace(this, obj); break;

                case ObjectKind.Constant: res = new IronPythonConstant(this, obj); break;

                case ObjectKind.ClassMethod: res = new IronPythonGenericMember(this, obj, PythonMemberType.Method); break;

                case ObjectKind.Method: res = new IronPythonGenericMember(this, obj, PythonMemberType.Method); break;

                case ObjectKind.PythonTypeSlot: res = new IronPythonGenericMember(this, obj, PythonMemberType.Property); break;

                case ObjectKind.PythonTypeTypeSlot: res = new IronPythonGenericMember(this, obj, PythonMemberType.Property); break;

                case ObjectKind.Unknown: res = new PythonObject(this, obj); break;

                default:
                    throw new InvalidOperationException();
                }
                _members[obj] = res;
                return(res);
            }
        }
Ejemplo n.º 2
0
        internal IMember MakeObject(ObjectIdentityHandle obj) {
            if (obj.IsNull) {
                return null;
            }

            lock (this) {
                IMember res;
                if (_members.TryGetValue(obj, out res)) {
                    return res;
                }

                switch (_remote.GetObjectKind(obj)) {
                    case ObjectKind.Module: res = new IronPythonModule(this, obj); break;
                    case ObjectKind.Type: res = new IronPythonType(this, obj); break;
                    case ObjectKind.BuiltinFunction: res = new IronPythonBuiltinFunction(this, obj); break;
                    case ObjectKind.BuiltinMethodDesc: res = new IronPythonBuiltinMethodDescriptor(this, obj); break;
                    case ObjectKind.ReflectedEvent: res = new IronPythonEvent(this, obj); break;
                    case ObjectKind.ReflectedExtensionProperty: res = new IronPythonExtensionProperty(this, obj); break;
                    case ObjectKind.ReflectedField: res = new IronPythonField(this, obj); break;
                    case ObjectKind.ReflectedProperty: res = new IronPythonProperty(this, obj); break;
                    case ObjectKind.TypeGroup: res = new IronPythonTypeGroup(this, obj); break;
                    case ObjectKind.NamespaceTracker: res = new IronPythonNamespace(this, obj); break;
                    case ObjectKind.Constant: res = new IronPythonConstant(this, obj); break;
                    case ObjectKind.ClassMethod: res = new IronPythonGenericMember(this, obj, PythonMemberType.Method); break;
                    case ObjectKind.Method: res = res = new IronPythonGenericMember(this, obj, PythonMemberType.Method); break;
                    case ObjectKind.PythonTypeSlot: res = new IronPythonGenericMember(this, obj, PythonMemberType.Property); break;
                    case ObjectKind.PythonTypeTypeSlot: res = new IronPythonGenericMember(this, obj, PythonMemberType.Property); break;
                    case ObjectKind.Unknown: res = new PythonObject(this, obj); break;
                    default:
                        throw new InvalidOperationException();
                }
                _members[obj] = res;
                return res;
            }
        }