public CJFunction(ITypeDatabaseReader typeDb, string name, Dictionary<string, object> functionTable, IMemberContainer declaringType, bool isMethod = false) { _name = name; object doc; if (functionTable.TryGetValue("doc", out doc)) { _doc = doc as string; } object value; if (functionTable.TryGetValue("builtin", out value)) { _isBuiltin = Convert.ToBoolean(value); } else { _isBuiltin = true; } if (functionTable.TryGetValue("static", out value)) { _isStatic = Convert.ToBoolean(value); } else { _isStatic = true; } _hasLocation = JTypeDatabase.TryGetLocation(functionTable, ref _line, ref _column); _declaringModule = CJModule.GetDeclaringModuleFromContainer(declaringType); object overloads; functionTable.TryGetValue("overloads", out overloads); _overloads = LoadOverloads(typeDb, overloads, isMethod); _declaringType = declaringType as IJType; }
public CJType(IMemberContainer parent, ITypeDatabaseReader typeDb, string typeName, Dictionary<string, object> typeTable, BuiltinTypeId typeId) { Debug.Assert(parent is CJType || parent is CJModule); _typeName = typeName; _typeId = typeId; _module = GetDeclaringModule(parent); object value; if (typeTable.TryGetValue("is_hidden", out value)) { _includeInModule = !Convert.ToBoolean(value); } else { _includeInModule = true; } if (typeTable.TryGetValue("doc", out value)) { _doc = value as string; } if (typeTable.TryGetValue("builtin", out value)) { _isBuiltin = Convert.ToBoolean(value); } else { _isBuiltin = true; } if (typeTable.TryGetValue("bases", out value)) { var basesList = value as List<object>; if (basesList != null) { _bases = new List<IJType>(); foreach (var baseType in basesList) { typeDb.LookupType(baseType, StoreBase); } } } if (typeTable.TryGetValue("mro", out value)) { var mroList = value as List<object>; if (mroList != null) { _mro = new List<CJType>(); foreach (var mroType in mroList) { typeDb.LookupType(mroType, StoreMro); } } } object membersData; if (typeTable.TryGetValue("members", out membersData)) { var membersTable = membersData as Dictionary<string, object>; if (membersTable != null) { LoadMembers(typeDb, membersTable); } } _hasLocation = JTypeDatabase.TryGetLocation(typeTable, ref _line, ref _column); }
public CJProperty(ITypeDatabaseReader typeDb, Dictionary<string, object> valueDict, IMemberContainer container) { _declaringModule = CJModule.GetDeclaringModuleFromContainer(container); object value; if (valueDict.TryGetValue("doc", out value)) { _doc = value as string; } object type; valueDict.TryGetValue("type", out type); _hasLocation = JTypeDatabase.TryGetLocation(valueDict, ref _line, ref _column); typeDb.LookupType(type, (typeValue, fromInstanceDb) => _type = typeValue); }
private void InitializeModules(string databaseDirectory, bool is3x) { foreach (var file in Directory.GetFiles(databaseDirectory)) { if (!file.EndsWith(".idb", StringComparison.OrdinalIgnoreCase) || file.IndexOf('$') != -1) { continue; } else if (String.Equals(Path.GetFileName(file), is3x ? "builtins.idb" : "__builtin__.idb", StringComparison.OrdinalIgnoreCase)) { continue; } string modName = Path.GetFileNameWithoutExtension(file); if (is3x && _langVersion != null) { // aliases for 3.x when using the default completion DB switch (modName) { case "cPickle": modName = "_pickle"; break; case "thread": modName = "_thread"; break; } } _modules[modName] = new CJModule(this, modName, file, false); } }