X-Git-Url: http://git.buserror.net/cgi-bin/gitweb.cgi?p=polintos%2Fscott%2Fpriv.git;a=blobdiff_plain;f=idlcomp%2Fidlc.h;h=a4ca39ab0f7ebd7fa12faa4051006dc55d994843;hp=94f7ae22497f34ee7f1cc65fead44ac28b8ceaae;hb=eec2efc14a0d624d475dc89e2bcb962e7c081df5;hpb=7da27a216a7f4bb3331fe315cdbec69bfcf2c762 diff --git a/idlcomp/idlc.h b/idlcomp/idlc.h index 94f7ae2..a4ca39a 100644 --- a/idlcomp/idlc.h +++ b/idlcomp/idlc.h @@ -3,31 +3,15 @@ // // This software is copyright (c) 2006 Scott Wood . // -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal with -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to do -// so, subject to the following conditions: +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors or contributors be held liable for any damages +// arising from the use of this software. // -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimers. -// -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimers in the -// documentation and/or other materials provided with the distribution. -// -// * The names of the Software's authors and/or contributors -// may not be used to endorse or promote products derived from -// this Software without specific prior written permission. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE -// SOFTWARE. +// Permission is hereby granted to everyone, free of charge, to use, copy, +// modify, prepare derivative works of, publish, distribute, perform, +// sublicense, and/or sell copies of the Software, provided that the above +// copyright notice and disclaimer of warranty be included in all copies or +// substantial portions of this software. #ifndef IDLC_H #define IDLC_H @@ -59,7 +43,7 @@ using std::vector; int yylex(); int idl_lex(); #define cdl_lex idl_lex -void idl_error(char *s); +void idl_error(const char *s); #define cdl_error idl_error @@ -463,6 +447,8 @@ typedef Ref IDListRef; class NameSpace; class LangCallback; +typedef Ref 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. @@ -472,6 +458,14 @@ extern int traversal; class Symbol : public RefCountable { NameSpace *ns; + void init() + { + ns = NULL; + external = false; + priv = false; + lang_priv = NULL; + } + public: StringRef name; @@ -486,31 +480,17 @@ public: bool priv; - // This is set to ::traversal when this symbol is visited along a chain. - // If a target needs more than 8 simultaneous chains, increase the size - // of the array. These traversals are reserved for language binding use. - - int traversed[8]; + // Reserved for language binding use. + Releasable *lang_priv; Symbol() { - ns = NULL; - external = false; - priv = false; - - memset(traversed, 0, sizeof(traversed)); + init(); } Symbol(const String *_name) : name(_name) { - if (_name) - name->retain(); - - ns = NULL; - external = false; - priv = false; - - memset(traversed, 0, sizeof(traversed)); + init(); } virtual ~Symbol(); @@ -604,8 +584,6 @@ struct InvalidArgument { struct UserError { }; -typedef Ref NameSpaceRef; - class NameSpace : public virtual Symbol { protected: // Filesystem path to the external symbol storage, or NULL @@ -636,23 +614,15 @@ protected: list 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. @@ -723,13 +693,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: @@ -1299,7 +1268,7 @@ public: class Struct; typedef Ref StructRef; -extern Struct *System_VStruct; +extern StructRef System_VStruct; // FIXME: typedefed superstructs class Struct : public NameSpace, public Type, public Def { @@ -1308,6 +1277,9 @@ class Struct : public NameSpace, public Type, public Def { SymbolRef supersym; StrListRef supername; bool attrs_resolved; + + // 0 = unknown, 1 = yes, 2 = no + int plain_data; void add_elem(Datum *d); @@ -1481,6 +1453,10 @@ public: def.guid[0] = guid[0]; def.guid[1] = guid[1]; } + + // A struct is "plain data" if it contains no object references, + // no non-inline arrays or structs, and no inline non-plain structs. + bool is_plain_data(); }; class Param : public Symbol, public Def { @@ -1663,7 +1639,7 @@ typedef Ref MethodRef; class Interface; typedef Ref InterfaceRef; -extern Interface *System_Object; +extern InterfaceRef System_Object; // FIXME: typedefed superinterfaces class Interface : public NameSpace, public Type, public Def {