]> git.buserror.net Git - polintos/scott/priv.git/blobdiff - idlcomp/types.cc
xfer to loki
[polintos/scott/priv.git] / idlcomp / types.cc
index c22d0bef92240b988a2b3cc6e5a4e1fae461bc8d..623b57607f0937bc96fe3f1842052b3abcee5a92 100644 (file)
@@ -348,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)