]> git.buserror.net Git - polintos/scott/priv.git/blobdiff - idlcomp/idlc.h
Random stuff.
[polintos/scott/priv.git] / idlcomp / idlc.h
index e030bbe52ba5dc355b0068c2f9bb5293c249c5e4..56dfefea45e543e6b29657f24257bf7faf14e654 100644 (file)
@@ -30,6 +30,7 @@
 #include <list>
 #include <map>
 #include <vector>
+#include <cstring>
 
 #include "compileddef.h"
 
@@ -447,6 +448,8 @@ typedef Ref<IDList> IDListRef;
 class NameSpace;
 class LangCallback;
 
+typedef Ref<NameSpace> NameSpaceRef;
+
 // This is incremented when a chain of symbols is traversed to reset
 // detection of already-visited symbols.  It is assumed that this
 // will not have to happen billions of times.
@@ -488,9 +491,6 @@ public:
        
        Symbol(const String *_name) : name(_name)
        {
-               if (_name)
-                       name->retain();
-
                init();
        }
 
@@ -585,8 +585,6 @@ struct InvalidArgument {
 struct UserError {
 };
 
-typedef Ref<NameSpace> NameSpaceRef;
-
 class NameSpace : public virtual Symbol {
 protected:
        // Filesystem path to the external symbol storage, or NULL
@@ -617,23 +615,15 @@ protected:
        list<NameSpaceRef> imports;
 
 public:
-       // This is set in the destructor, so the contents of the namespace
-       // don't try to remove themselves from the namespace when destructed
-       // due to the destruction of map.
-       int dying;
-       
        // This is a counter for generating unique names for anonymous
        // members of the namespace.
        int anon;
        
-       NameSpace() : dying(0), anon(0)
+       NameSpace() : anon(0)
        {
        }
        
-       virtual ~NameSpace()
-       {
-               dying = 1;
-       }
+       virtual ~NameSpace();
        
        // Return a description of the type of namespace, for
        // error messages.
@@ -704,13 +694,12 @@ public:
        // SymbolNotFound is thrown if sym is not in this namespace.
        virtual void del(Symbol *sym)
        {
-               fprintf(stderr, "Removing symbol %s\n",
-                       sym->get_fq_name()->flatten()->c_str());
-       
-               if (tbl.erase(sym->name) == 0)
+               if (sym->ns != this)
                        throw SymbolNotFound();
-               
+
                sym->ns = NULL;
+               int ret = tbl.erase(sym->name);
+               assert(ret != 0);
        }
 
 private:       
@@ -836,9 +825,9 @@ protected:
        CompiledDefHeader hdr;
 
        // sym is the symbol from which to get the path/name, and
-       // dir is true if it should be "name/.self" rather than 
+       // is_dir is true if it should be "name/.self" rather than 
        // "name".
-       void output_self(const char *dir, Symbol *sym, bool dir);
+       void output_self(const char *dir, Symbol *sym, bool is_dir);
 
 public:
        Def(const char *self, int self_len, CompiledDefHeader::Type type) :
@@ -978,7 +967,6 @@ class Array : public RefCountable<Array>
 
        // lower is [0], upper is [1]
        StrListRef dcons[2];
-       Con cons[2];
        
        // Strings for error reporting on each constant.  If the constant
        // is symbolic, then this is the fully qualified symbol name. 
@@ -989,6 +977,8 @@ class Array : public RefCountable<Array>
        StringRef strs[2];
        
 public:
+       Con cons[2];
+
        // ca is not valid until after final_analysis() is called.
        CompiledArray ca;
 
@@ -1015,8 +1005,6 @@ class Datum : public Symbol, public Def {
        bool const_init; // Datum's constant has been initialized; this is
                         // true after a successful verify_const().
        CompiledBasicType *cbt;
-       
-       ArrayRef array;
 
        int chain_traversed;
 
@@ -1048,6 +1036,7 @@ class Datum : public Symbol, public Def {
        }
 
 public:
+       ArrayRef array;
        CompiledDatum def;
        TypeRef type;
 
@@ -1280,7 +1269,7 @@ public:
 
 class Struct;
 typedef Ref<Struct> StructRef;
-extern Struct *System_VStruct;
+extern StructRef System_VStruct;
 
 // FIXME: typedefed superstructs
 class Struct : public NameSpace, public Type, public Def {
@@ -1651,7 +1640,7 @@ typedef Ref<Method> MethodRef;
 class Interface;
 typedef Ref<Interface> InterfaceRef;
 
-extern Interface *System_Object;
+extern InterfaceRef System_Object;
 
 // FIXME: typedefed superinterfaces
 class Interface : public NameSpace, public Type, public Def {