3 // This software is copyright (c) 2007 Scott Wood <scott@buserror.net>.
5 // This software is provided 'as-is', without any express or implied warranty.
6 // In no event will the authors or contributors be held liable for any damages
7 // arising from the use of this software.
9 // Permission is hereby granted to everyone, free of charge, to use, copy,
10 // modify, prepare derivative works of, publish, distribute, perform,
11 // sublicense, and/or sell copies of the Software, provided that the above
12 // copyright notice and disclaimer of warranty be included in all copies or
13 // substantial portions of this software.
17 void CPPFile::output_ifaceinfo(Interface *iface)
22 file << indent << "void _invoke(::System::RunTime::Array"
23 << "< ::System::RunTime::ID> objlist,\n"
24 << indent << " ::System::RunTime::ParamInfoBlock::Segment *segs,\n"
25 << indent << " int nsegs);\n\n";
28 file << indent << "__attribute__((weak)) __attribute__((unused))\n"
29 << indent << "::System::RunTime::IFaceInfo _info = {\n"
30 << indent << "\t&_guid,\n"
34 void CPPFile::output_marshall(CompiledBasicType &cbt, Datum *d)
36 printf("marshall cbt\n");
39 void CPPFile::align_type(Symbol *sym)
41 file << indent << "_ctx.buf.align_to(__alignof__(";
42 cpp_output_name(file, sym);
46 void CPPFile::grow_buf(Symbol *sym)
48 file << indent << "_ptr = _ctx.buf.grow_by(sizeof(";
49 cpp_output_name(file, sym);
53 void CPPFile::output_marshall(Struct *sym, Datum *d)
55 bool is_inline = !d || d->is_inline();
57 if (d && !d->is_inline()) {
59 file << indent << "if (" << **d->name << ")\n"
60 << indent << '\t' << **d->name << "->_marshall(_ctx);\n";
70 file << indent << "memcpy(_ptr, this, sizeof(*this));\n";
73 if (sym->is_plain_data()) {
74 printf("plain data\n");
78 for (Struct::entries_iterator i = sym->entries_begin();
79 i != sym->entries_end(); ++i)
85 d->type->output_lang(this, trav_marshall, d);
87 output_marshall(d->def.basictype, d);
91 void CPPFile::output_marshall(Interface *sym, Datum *d)
93 printf("marshall iface\n");
96 void CPPFile::output_marshall(Enum *sym, Datum *d)
98 printf("marshall enum\n");
101 void CPPFile::output_marshall(BitField *sym, Datum *d)
103 printf("marshall bitfield\n");
106 void CPPFile::output_marshall(BasicType *sym, Datum *d)
108 printf("marshall basictype\n");
111 void CPPFile::output_marshall_pass(Struct *sym, int pass)
117 file << indent << "int _marshall(::System::RunTime::MarshCtx &_ctx);\n";
118 file << indent << "void _unmarshall(::System::RunTime::MarshCtx &_ctx);\n";
124 file << indent << "int _marshall(::System::RunTime::MarshCtx &_ctx)\n"
126 << indent << "\tvoid *_ptr;\n";
128 indent.indent_level++;
129 output_marshall(sym, NULL);
130 indent.indent_level--;
132 file << indent << "\treturn 0;\n"
133 << indent << "}\n\n";
135 file << indent << "void _unmarshall(::System::RunTime::Array<uint8_t, ::System::RunTime::ORBMM> buf,\n"
136 << indent << " ::System::RunTime::Array< ::System::_i_Object *, ::System::RunTime::ORBMM> objlist,\n"
137 << indent << " ::System::RunTime::ParamInfoBlock::Segment *segs,\n"
138 << indent << " int nsegs)\n"