IClass ReadClass(ClassEntry ce)
 {
     if (datareader == null) {
         datafile = new FileStream (dataFile, FileMode.Open, FileAccess.Read, FileShare.Read);
         datareader = new BinaryReader (datafile);
     }
     datafile.Position = ce.Position;
     datareader.ReadInt32 ();	// Length of data
     return PersistentClass.Read (datareader, parserDatabase.DefaultNameDecoder);
 }
        IClass GetClass(ClassEntry ce)
        {
            ce.LastGetTime = currentGetTime++;
            if (ce.Class != null) return ce.Class;

            // Read the class from the file

            ce.Class = ReadClass (ce);
            return ce.Class;
        }
        public ClassUpdateInformation UpdateClassInformation(ClassCollection newClasses, string fileName)
        {
            lock (rwlock)
            {
                ClassUpdateInformation res = new ClassUpdateInformation ();

                FileEntry fe = files [fileName] as FileEntry;
                if (fe == null) return null;

                bool[] added = new bool [newClasses.Count];
                NamespaceEntry[] newNss = new NamespaceEntry [newClasses.Count];
                for (int n=0; n<newClasses.Count; n++) {
                    string[] path = newClasses[n].Namespace.Split ('.');
                    newNss[n] = GetNamespaceEntry (path, path.Length, true, true);
                }

                ArrayList newFileClasses = new ArrayList ();

                if (fe != null)
                {
                    ClassEntry ce = fe.FirstClass;
                    while (ce != null)
                    {
                        IClass newClass = null;
                        for (int n=0; n<newClasses.Count && newClass == null; n++) {
                            IClass uc = newClasses [n];
                            if (uc.Name == ce.Name && newNss[n] == ce.NamespaceRef) {
                                newClass = uc;
                                added[n] = true;
                            }
                        }

                        if (newClass != null) {
                            // Class found, replace it
                            ce.Class = CopyClass (newClass);
                            ce.LastGetTime = currentGetTime++;
                            newFileClasses.Add (ce);
                            res.Modified.Add (ce.Class);
                        }
                        else {
                            // Class not found, it has to be deleted, unless it has
                            // been added in another file
                            if (ce.FileEntry == fe) {
                                IClass c = ce.Class;
                                if (c == null) c = ReadClass (ce);
                                res.Removed.Add (c);
                                ce.NamespaceRef.Remove (ce.Name);
                            }
                        }
                        ce = ce.NextInFile;
                    }
                }

                if (fe == null) {
                    fe = new FileEntry (fileName);
                    files [fileName] = fe;
                }

                for (int n=0; n<newClasses.Count; n++) {
                    if (!added[n]) {
                        IClass c = CopyClass (newClasses[n]);
                        ClassEntry ce = new ClassEntry (c, fe, newNss[n]);
                        ce.LastGetTime = currentGetTime++;
                        newNss[n].Add (c.Name, ce);
                        newFileClasses.Add (ce);
                        res.Added.Add (c);
                    }
                }

                fe.SetClasses (newFileClasses);
                rootNamespace.Clean ();
                fe.LastParseTime = DateTime.Now;
                modified = true;
                Flush ();

                return res;
            }
        }
Exemplo n.º 4
0
        public void AddClass(ClassEntry ce)
        {
            if (ce.FileEntry != null)
                ce.FileEntry.RemoveClass (ce);

            ce.NextInFile = firstClass;
            firstClass = ce;
        }
Exemplo n.º 5
0
 public void SetClasses(ArrayList list)
 {
     firstClass = null;
     foreach (ClassEntry ce in list)
         AddClass (ce);
 }
Exemplo n.º 6
0
        public void RemoveClass(ClassEntry ce)
        {
            ClassEntry oldent = null;
            ClassEntry curent = firstClass;

            while (curent != null && curent != ce) {
                oldent = curent;
                curent = curent.NextInFile;
            }

            if (curent == null)
                return;
            else if (oldent == null)
                firstClass = curent.NextInFile;
            else
                oldent.NextInFile = curent.NextInFile;

            ce.FileEntry = null;
        }