internal IMember MakeObject(ObjectIdentityHandle obj) { if (obj.IsNull) { return(null); } lock (this) { if (_members.TryGetValue(obj, out var 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); } }
private void LoadModules() { if (!string.IsNullOrEmpty(_factory.Configuration.GetPrefixPath())) { var dlls = PathUtils.GetAbsoluteDirectoryPath(_factory.Configuration.GetPrefixPath(), "DLLs"); if (Directory.Exists(dlls)) { foreach (var dll in PathUtils.EnumerateFiles(dlls, "*.dll", recurse: false)) { try { var assem = Remote.LoadAssemblyFromFileWithPath(dll); if (assem != null) { Remote.AddAssembly(assem); } } catch (Exception ex) { Debug.Fail(ex.ToString()); } } } } foreach (string modName in Remote.GetBuiltinModuleNames()) { try { ObjectIdentityHandle mod = Remote.ImportBuiltinModule(modName); if (modName != "__builtin__") { _modules[modName] = new IronPythonModule(this, mod, modName); } } catch { // importing can throw, ignore that module continue; } } }