]> git.buserror.net Git - polintos/scott/priv.git/blobdiff - idlcomp/languages/c++/marshall.cc
Add distributors to liability disclaimer. Need to update file headers.
[polintos/scott/priv.git] / idlcomp / languages / c++ / marshall.cc
index 2391b37980b9e1476e15b6a94e008d918fff415c..46621fed92db8b5e371042d83961a3cdb43f5821 100644 (file)
@@ -18,10 +18,127 @@ void CPPFile::output_ifaceinfo(Interface *iface)
 {
        extra_newline();
 
-       file << indent << "static const __attribute__((unused))\n"
+#if 0
+       file << indent << "void _invoke(::System::RunTime::Array"
+                      << "< ::System::RunTime::ID> objlist,\n"
+            << indent << "             ::System::RunTime::ParamInfoBlock::Segment *segs,\n"
+            << indent << "             int nsegs);\n\n";
+#endif
+
+       file << indent << "__attribute__((weak)) __attribute__((unused))\n"
             << indent << "::System::RunTime::IFaceInfo _info = {\n"
             << indent << "\t&_guid,\n"
             << indent << "};\n";
+}
+
+void CPPFile::output_marshall(CompiledBasicType &cbt, Datum *d)
+{
+       printf("marshall cbt\n");
+}
+
+void CPPFile::align_type(Symbol *sym)
+{
+       file << indent << "_ctx.buf.align_to(__alignof__(";
+       cpp_output_name(file, sym);
+       file << "));\n";
+}
+
+void CPPFile::grow_buf(Symbol *sym)
+{
+       file << indent << "_ptr = _ctx.buf.grow_by(sizeof(";
+       cpp_output_name(file, sym);
+       file << "));\n";
+}
+
+void CPPFile::output_marshall(Struct *sym, Datum *d)
+{
+       bool is_inline = !d || d->is_inline();
+
+       if (d && !d->is_inline())       {
+               extra_newline();
+               file << indent << "if (" << **d->name << ")\n"
+                    << indent << '\t' << **d->name << "->_marshall(_ctx);\n";
+
+               return;
+       }
+
+       if (!d) {
+               extra_newline();
+               align_type(sym);
+               grow_buf(sym);
+               
+               file << indent << "memcpy(_ptr, this, sizeof(*this));\n";
+       }
+       
+       if (sym->is_plain_data()) {
+               printf("plain data\n");
+               return;
+       }
        
-       do_extra_newline = true;
+       for (Struct::entries_iterator i = sym->entries_begin();
+            i != sym->entries_end(); ++i)
+       {
+               extra_newline();
+               Datum *d = *i;
+               
+               if (d->type)
+                       d->type->output_lang(this, trav_marshall, d);
+               else
+                       output_marshall(d->def.basictype, d);
+       }
+}
+
+void CPPFile::output_marshall(Interface *sym, Datum *d)
+{
+       printf("marshall iface\n");
+}
+
+void CPPFile::output_marshall(Enum *sym, Datum *d)
+{
+       printf("marshall enum\n");
+}
+
+void CPPFile::output_marshall(BitField *sym, Datum *d)
+{
+       printf("marshall bitfield\n");
+}
+
+void CPPFile::output_marshall(BasicType *sym, Datum *d)
+{
+       printf("marshall basictype\n");
+}
+
+void CPPFile::output_marshall_pass(Struct *sym, int pass)
+{
+       switch (pass) {
+               case trav_nsdecl:
+                       extra_newline();
+                       
+                       file << indent << "int _marshall(::System::RunTime::MarshCtx &_ctx);\n";
+                       file << indent << "void _unmarshall(::System::RunTime::MarshCtx &_ctx);\n";
+                       break;
+
+               case trav_full:
+                       extra_newline();
+
+                       file << indent << "int _marshall(::System::RunTime::MarshCtx &_ctx)\n"
+                            << indent << "{\n"
+                            << indent << "\tvoid *_ptr;\n";
+
+                       indent.indent_level++;
+                       output_marshall(sym, NULL);
+                       indent.indent_level--;
+
+                       file << indent << "\treturn 0;\n"
+                            << indent << "}\n\n";
+
+                       file << indent << "void _unmarshall(::System::RunTime::Array<uint8_t, ::System::RunTime::ORBMM> buf,\n"
+                            << indent << "                 ::System::RunTime::Array< ::System::_i_Object *, ::System::RunTime::ORBMM> objlist,\n"
+                            << indent << "                 ::System::RunTime::ParamInfoBlock::Segment *segs,\n"
+                            << indent << "                 int nsegs)\n"
+                            << indent << "{\n"
+                            << indent << "}\n";
+
+                       break;
+       }
 }