X-Git-Url: http://git.buserror.net/cgi-bin/gitweb.cgi?p=polintos%2Fscott%2Fpriv.git;a=blobdiff_plain;f=idlcomp%2Flanguages%2Fc%2B%2B%2Fmarshall.cc;h=46621fed92db8b5e371042d83961a3cdb43f5821;hp=bd1f4286f0f6a6ceb84278f60bf45f42449e7e35;hb=39d6852ead7a839f9e15e21e517dfd7a795e5cdd;hpb=cc1bee96fd874ff2c85c765f81ec2f4ba4584b9d diff --git a/idlcomp/languages/c++/marshall.cc b/idlcomp/languages/c++/marshall.cc index bd1f428..46621fe 100644 --- a/idlcomp/languages/c++/marshall.cc +++ b/idlcomp/languages/c++/marshall.cc @@ -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 &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 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; } }