]> git.buserror.net Git - polintos/scott/priv.git/blobdiff - idlcomp/languages/c++/marshall.cc
xfer to loki
[polintos/scott/priv.git] / idlcomp / languages / c++ / marshall.cc
index bd1f4286f0f6a6ceb84278f60bf45f42449e7e35..46621fed92db8b5e371042d83961a3cdb43f5821 100644 (file)
@@ -29,28 +29,116 @@ void CPPFile::output_ifaceinfo(Interface *iface)
             << 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(Struct *sym, int pass)
+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::GrowableArray<uint8_t, ::System::RunTime::ORBMM> &buf,\n"
-                            << indent << "              ::System::RunTime::GrowableArray< ::System::RunTime::ID, ::System::RunTime::ORBMM> &objlist,\n"
-                            << indent << "              ::System::RunTime::GrowableArray< ::System::RunTime::NewObject, ::System::RunTime::ORBMM> &newobjlist,\n"
-                            << indent << "              ::System::RunTime::ParamInfoBlock::Segment *segs,\n"
-                            << indent << "              int nsegs);\n";
+                       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 << "                 int nsegs)\n"
+                            << indent << "{\n"
+                            << indent << "}\n";
 
-                       do_extra_newline = true;
                        break;
        }
 }