]> git.buserror.net Git - polintos/scott/priv.git/blobdiff - idlcomp/types.cc
minor doc updates
[polintos/scott/priv.git] / idlcomp / types.cc
index 5963750260f5c6789979e658800cccc67c3a7e61..623b57607f0937bc96fe3f1842052b3abcee5a92 100644 (file)
@@ -2,23 +2,15 @@
 //
 // This software is copyright (c) 2006 Scott Wood <scott@buserror.net>.
 // 
-// 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 condition:
+// 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.
 // 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// 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.
 
 #include <cfloat>
 #include <sstream>
@@ -328,7 +320,8 @@ void Datum::final_analysis()
                        yyerrorfl(name->file, name->line,
                                  "Explicit size %llu on \"%s\" is too small for "
                                  "type \"%s\", which has a minimum size of %u",
-                                 def.ucon, get_fq_name()->flatten()->c_str(),
+                                 (unsigned long long)def.ucon,
+                                 get_fq_name()->flatten()->c_str(),
                                  type->get_fq_name()->flatten()->c_str(), defsize);
                }
        }
@@ -355,6 +348,45 @@ void Struct::add_elem(Datum *d)
        def.num_entries++;
 }
 
+bool Struct::is_plain_data()
+{
+       if (!plain_data) {
+               plain_data = 1;
+               for (Struct::entries_iterator i = entries_begin(); i != entries_end(); ++i)
+               {
+                       Datum *d = *i;
+                       if (d->is_array() && !d->def.flags.field.Inline)
+                               goto complex;
+
+                       if (!d->type)
+                               continue;
+
+                       Type *type = dynamic_cast<Type *>(d->type->get_concrete_sym());
+                       assert(type);
+
+                       if (dynamic_cast<Interface *>(type))
+                               goto complex;
+
+                       Struct *str = dynamic_cast<Struct *>(type);
+                       if (str) {
+                               if (!d->def.flags.field.Inline)
+                                       goto complex;
+
+                               // FIXME: check for inline struct loops
+                               if (str->is_plain_data())
+                                       goto complex;
+                       }
+               }
+       }
+       
+       assert(plain_data == 1 || plain_data == 2);
+       return plain_data == 1;
+
+complex:
+       plain_data = 2;
+       return false;
+}
+
 Param *Param::declare(const String *name, NameSpace *parent,
                           StrList *TYPE, CompiledParam::Flags flags,
                           Array *array)