1 // idlcomp/languages/c++/main.cc -- C++ IDL binding
3 // This software is copyright (c) 2006 Scott Wood <scott@buserror.net>.
5 // Permission is hereby granted, free of charge, to any person obtaining a copy of
6 // this software and associated documentation files (the "Software"), to deal with
7 // the Software without restriction, including without limitation the rights to
8 // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9 // of the Software, and to permit persons to whom the Software is furnished to do
10 // so, subject to the following condition:
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
23 // FIXME: escape C++ reserved words
27 #include <sys/types.h>
33 CPPBinding cppbinding;
35 CPPFile::CPPFile(UserNameSpace *NS, const char *dir) :
38 indent.indent_level = 0;
39 indent.align_spaces = 0;
40 do_extra_newline = true;
43 dirname.append(1, '/');
44 dirname.append(ns->name);
45 string headername(dirname);
46 headername.append(".h");
48 file.open(headername.c_str());
49 if (!file.is_open()) {
50 fprintf(stderr, "Could not create output file \"%s\": %s.\n",
51 headername.c_str(), strerror(errno));
56 if (mkdir(dirname.c_str(), 0777) < 0) {
57 fprintf(stderr, "Could not create output directory \"%s\": %s.\n",
58 dir, strerror(errno));
63 file << "// " << *ns->get_fq_name()->flatten(".")
64 << "\n// This is a C++ language binding generated by idlc.\n"
65 << "// Do not modify this file directly.\n\n";
67 fqname = ns->get_fq_name();
68 String *fqname_flat = ns->get_fq_name()->flatten("_IDLNS_");
69 file << "#ifndef IDL_HDR_" << *fqname_flat
70 << "\n#define IDL_HDR_" << *fqname_flat << "\n\n";
72 file << "#include <orb.h>\n";
74 first_traversal = ++traversal;
75 assert(first_traversal >= 0);
77 for (NameSpace::const_iterator i = ns->begin(); i != ns->end(); ++i) {
78 Symbol *sym = (*i).second;
79 UserNameSpace *uns = dynamic_cast<UserNameSpace *>(sym);
82 file << "#include \"" << **ns->name << '/' << **uns->name << ".h\"\n";
84 // Process namespaces first, to minimize duplicate definitions
85 // if this namespace depends on something declared in a sub
92 for (NameSpace::const_iterator i = ns->begin(); i != ns->end(); ++i) {
93 Symbol *sym = (*i).second;
94 UserNameSpace *uns = dynamic_cast<UserNameSpace *>(sym);
97 output_pass(sym, trav_nsdecl);
100 for (NameSpace::const_iterator i = ns->begin(); i != ns->end(); ++i) {
101 Symbol *sym = (*i).second;
102 UserNameSpace *uns = dynamic_cast<UserNameSpace *>(sym);
105 output_pass(sym, trav_full);
113 assert(indent.indent_level == 0);
116 void CPPFile::ifndef_in(Symbol *sym, const char *extra)
118 StrList *fqname = sym->get_fq_name();
119 String *fqname_flat = fqname->flatten("_IDLNS_");
121 assert(indent.indent_level == 0);
123 file << "\n#ifndef IDL_DUP_" << extra << *fqname_flat
124 << "\n#define IDL_DUP_" << extra << *fqname_flat << "\n";
127 void CPPFile::ifndef_out()
129 file << "\n#endif\n";
132 void CPPFile::ns_in(Symbol *sym, const char *extra)
134 // Only output user namespaces here; if we're defining a nested type,
135 // it will have been forward declared already, and thus the
136 // non-user-namespaces can be specified directly in the definition.
138 // For non-forward-declarables such as metadata, use all_ns_in.
140 StrList *ns_fqname = sym->find_toplevel_type()->get_ns()->get_fq_name();
142 ifndef_in(sym, extra);
144 for (StrList::const_iterator i = ns_fqname->begin();
145 i != ns_fqname->end(); ++i) {
146 const String *str = *i;
147 file << "namespace " << *str << " {\n";
153 void CPPFile::ns_out(Symbol *sym)
156 assert(indent.indent_level == 0);
158 for (Symbol *s = sym->find_toplevel_type()->get_ns(); s != toplevel;
165 void CPPFile::all_ns_in(Symbol *sym, bool include_self, const char *extra)
167 NameSpace *ns = sym->find_toplevel_type()->get_ns();
168 StrList *ns_fqname = ns->get_fq_name();
170 ifndef_in(sym, extra);
172 for (StrList::const_iterator i = ns_fqname->begin();
173 i != ns_fqname->end(); ++i) {
174 const String *str = *i;
175 file << "namespace " << *str << " {\n";
178 stack<SymbolRef> typens;
183 for (Symbol *s = sym; s != ns; s = s->get_ns())
186 while (!typens.empty()) {
187 Symbol *s = typens.top();
189 file << "namespace " << **s->name << "_ns {\n";
195 void CPPFile::all_ns_out(Symbol *sym, bool include_self)
198 assert(indent.indent_level == 0);
203 for (Symbol *s = sym; s != toplevel; s = s->get_ns())
209 String &CPPFile::get_definition_name(Symbol *sym, const char *prefix)
211 NameSpace *ns = sym->get_ns();
212 UserNameSpace *uns = dynamic_cast<UserNameSpace *>(ns);
216 str = &get_definition_name(ns);
217 str->append("_ns::");
223 str->append(**sym->name);
227 void cpp_output_name(ostream &file, Symbol *sym, const char *prefix)
229 StrList *sl = sym->get_fq_name("_ns");
232 file << "::" << *sl->flatten("::") << "::" << prefix << **sym->name;
235 void CPPFile::output(UserNameSpace *sym, int pass, void *arg2)
237 assert(indent.indent_level == 0);
238 delete new CPPFile(sym, dirname.c_str());
241 static inline int round_up_bits(int bits)
243 assert(bits >= 1 && bits <= 64);
255 // FIXME: Inline arrays...
256 void cpp_output_type(ostream &file, Type *t, bool array, bool is_mutable)
259 file << "::System::RunTime::";
267 cpp_output_name(file, t);
275 // FIXME: Inline arrays...
276 void cpp_output_type(ostream &file, CompiledBasicType &t, bool is_mutable)
279 file << "::System::RunTime::";
287 if (t.flags.field.Bool) {
288 // Don't rely on C++ to provide any particular representation
291 } else if (t.flags.field.Float) {
297 if (t.flags.field.Unsigned)
300 file << "int" << round_up_bits(t.bits) << "_t";
309 // FIXME: implement padding
310 int CPPFile::output_datum(Struct *ns, Datum *d, int offset)
313 cpp_output_type(file, d->type, is_array(d->def.basictype),
314 !d->def.flags.field.Immutable);
316 Struct *dtype = dynamic_cast<Struct *>(*d->type);
317 if (dtype && !dtype->is_inline())
320 cpp_output_type(file, d->def.basictype,
321 !d->def.flags.field.Immutable);
327 void CPPFile::declare_type_dependency(Type *t, bool need_obj_def)
329 Symbol *toplevel_type = t->find_toplevel_type();
331 assert(indent.indent_level == 0);
333 output_pass(toplevel_type, trav_nsdecl);
335 if (t == toplevel_type)
336 output_pass(t, trav_forward);
338 if (dynamic_cast<Interface *>(t))
339 output_pass(t, need_obj_def ? trav_obj_def : trav_obj_stub);
340 else if (!dynamic_cast<Struct *>(t) || need_obj_def)
341 output_pass(t, trav_full);
344 void CPPFile::declare_dependencies(Interface *iface, bool need_obj_def)
346 for (Interface::methods_iterator i = iface->methods_begin();
347 i != iface->methods_end(); ++i)
350 for (Method::entries_iterator j = m->entries_begin();
351 j != m->entries_end(); ++j)
355 declare_type_dependency(p->type, need_obj_def);
359 for (Interface::supers_iterator i = iface->supers_begin();
360 i != iface->supers_end(); ++i)
362 Interface *super = *i;
363 declare_type_dependency(super);
367 void CPPFile::declare_dependencies(Struct *str)
369 for (NameSpace::const_iterator i = str->begin(); i != str->end(); ++i) {
370 Symbol *sym = (*i).second;
371 Datum *d = dynamic_cast<Datum *>(sym);
374 declare_type_dependency(d->type, d->is_inline());
379 Struct *mstr = dynamic_cast<Struct *>(sym);
381 declare_dependencies(mstr);
385 Interface *miface = dynamic_cast<Interface *>(sym);
387 declare_dependencies(miface);
391 void CPPFile::output_guid(const uint64_t *guid64)
393 const unsigned char *guid = reinterpret_cast<const unsigned char *>(guid64);
396 file << indent << "static const __attribute__((unused)) union {\n"
397 << indent << "\tunsigned char c[16];\n"
398 << indent << "\tunsigned long l[];\n"
399 << indent << "} _guid = {\n"
402 for (int i = 0; i < 16; i++) {
404 file << '\n' << indent << "\t ";
406 sprintf(guidhex, "0x%02x, ", *guid++);
413 do_extra_newline = true;
416 void CPPFile::output_nsdecl(NameSpace *ns, nsdecl_callback cb)
418 // If indent level is not zero, this is a nested struct or interface.
419 if (indent.indent_level == 0)
424 file << indent << "namespace " << **ns->name << "_ns {\n";
430 for (NameSpace::const_iterator i = ns->begin(); i != ns->end(); ++i) {
431 Symbol *sym = (*i).second;
433 assert(pass_needed(sym, trav_forward));
434 assert(pass_needed(sym, trav_nsdecl));
436 // If it's a Method or a non-const Datum, this is a no-op.
437 output_pass(sym, trav_forward);
438 output_pass(sym, trav_nsdecl);
443 file << indent << "}\n";
445 if (indent.indent_level == 1)
449 void CPPFile::output_aliases_and_types(NameSpace *ns)
451 for (NameSpace::const_iterator i = ns->begin(); i != ns->end(); ++i) {
452 Symbol *sym = (*i).second;
453 if (dynamic_cast<Alias *>(sym) || dynamic_cast<Type *>(sym))
454 output_pass(sym, trav_full);
458 void CPPFile::output_vstruct_ns(CPPFile *cpp, NameSpace *sym)
460 Struct *str = dynamic_cast<Struct *>(sym);
462 assert(str->is_virtual());
464 cpp->output_guid(str->def.guid);
467 void CPPFile::output_vstruct_info(Struct *sym)
469 all_ns_in(sym, true, "VINFO_");
471 file << indent << "static const __attribute__((unused)) "
472 "unsigned long *const _guids[] = {\n";
474 stack<StructRef> supers;
477 for (Struct *i = sym; i; i = i->get_super()) {
482 for (int i = 0; i < sym->chainlen; i++) {
483 Struct *super = supers.top();
486 file << indent << '\t';
487 cpp_output_name(file, super);
488 file << "_ns::_guid.l,\n";
491 file << indent << "};\n\n"
492 << indent << "static const __attribute__((unused)) "
493 "::System::RunTime::VStructInfo _info = {\n"
494 << indent << "\t_guids, " << sym->chainlen << '\n'
498 all_ns_out(sym, true);
501 void CPPFile::output_vstruct_main(Struct *sym)
503 assert(sym->is_virtual());
504 Struct *super = sym->get_super();
506 const char *name = sym->name->c_str();
509 assert(sym == System_VStruct);
510 file << indent << "const ::System::RunTime::VStructInfo "
511 "*const _infoptr;\n\n";
514 file << indent << name
515 << "(const ::System::RunTime::VStructInfo *realinfo = &"
516 << name << "_ns::_info) :\n"
522 cpp_output_name(file, super);
524 file << "(realinfo)\n"
530 << indent << "static " << name << " *downcast(::System::VStruct *base)\n"
532 << indent << "\tif (!base)\n"
533 << indent << "\t\treturn NULL;\n\n"
534 << indent << "\tconst ::System::RunTime::VStructInfo *info = base->_infoptr;\n\n"
535 << indent << "\tif (info->chainlen < " << sym->chainlen << ")\n"
536 << indent << "\t\treturn NULL;\n\n"
537 << indent << "\tif (::System::RunTime::guids_equal(info->guids["
538 << sym->chainlen - 1 << "], " << name << "_ns::_guid.l))\n"
539 << indent << "\t\treturn static_cast<" << name << " *>(base);\n\n"
540 << indent << "\treturn NULL;\n"
543 do_extra_newline = true;
546 // Output an init method that initializes all the elements in the
547 // struct; this is useful for throwing exceptions. Due to the
548 // annoying, apparently unwaiveable-by-the-struct requirement that any
549 // struct with a ctor be initialized using the ctor (and thus at
550 // runtime, not statically), this can't be an actual ctor in
551 // non-virtual structs.
553 // In virtual structs, there's already a ctor, so it wouldn't
554 // matter. It'd generally be best to be consistent and use the
555 // init method for both, but the main intended use for this is
556 // throwing exceptions (which are virtual), and it'd be
557 // unfortunate to cripple 99% of the uses with unnecessary
558 // syntactic cruft. The init method will remain available
559 // for vstructs so that things won't break if a non-vstruct
560 // gets made virtual (or if a user really wants to be consistent
561 // between both types in their own code).
563 void CPPFile::output_struct_ctor(Struct *sym, bool extra_vstruct)
565 const char *method_name = extra_vstruct ? sym->name->c_str() : " _init";
567 file << '\n' << indent << **sym->name;
568 indent.align_spaces = sym->name->length() + 1;
570 if (!extra_vstruct) {
572 indent.align_spaces += 7;
576 output_struct_ctor_rec1(sym, 0);
579 Struct *super = sym->get_super();
581 file << ",\n" << indent
582 << "const ::System::RunTime::VStructInfo *_realinfo = &"
583 << **sym->name << "_ns::_info) :\n";
585 indent.align_spaces = 0;
591 cpp_output_name(file, super);
593 file << "(_realinfo";
596 indent.align_spaces = 0;
597 file << ")\n" << indent << "{\n";
599 indent.indent_level++;
601 output_struct_ctor_rec2(sym, 0);
604 file << indent << "return *this;\n";
606 indent.indent_level--;
607 file << indent << "}\n";
610 int CPPFile::output_struct_ctor_rec1(Struct *sym, int num)
612 if (sym->get_super())
613 num = output_struct_ctor_rec1(sym->get_super(), num);
615 for (Struct::entries_iterator i = sym->entries_begin();
616 i != sym->entries_end(); ++i)
619 file << ",\n" << indent;
621 output_datum(sym, *i, -1);
622 file << "_arg" << num;
628 int CPPFile::output_struct_ctor_rec2(Struct *sym, int num)
630 if (sym->get_super())
631 num = output_struct_ctor_rec2(sym->get_super(), num);
633 for (Struct::entries_iterator i = sym->entries_begin();
634 i != sym->entries_end(); ++i)
637 file << indent << **d->name << " = _arg" << ++num << ";\n";
643 void CPPFile::output(Struct *sym, int pass, void *arg2)
647 if (sym->is_virtual()) {
648 output_nsdecl(sym, output_vstruct_ns);
656 bool nested = indent.indent_level != 0;
663 file << indent << "struct " << **sym->name << ";\n";
672 output_pass(sym, trav_nsdecl);
673 Struct *super = sym->get_super();
676 output_pass(super, trav_full);
678 if (sym->is_virtual())
679 output_vstruct_info(sym);
681 declare_dependencies(sym);
684 file << indent << "struct " << get_definition_name(sym);
687 const String *supername = super->get_fq_name("_ns")
689 file << " :\n" << indent << "public ::" << *supername;
692 file << "\n" << indent << "{\n";
695 if (sym->is_virtual())
696 output_vstruct_main(sym);
699 for (Struct::entries_iterator i = sym->entries_begin();
700 i != sym->entries_end(); ++i)
705 offset = output_datum(sym, d, offset);
706 file << **d->name << ";\n";
709 bool empty_struct = true;
710 for (Struct *s = sym; s; s = s->get_super()) {
711 if (s->entries_begin() != s->entries_end()) {
712 empty_struct = false;
718 output_struct_ctor(sym, false);
720 if (sym->is_virtual())
721 output_struct_ctor(sym, true);
725 file << indent << "};\n";
729 output_aliases_and_types(sym);
731 for (NameSpace::const_iterator i = sym->begin(); i != sym->end(); ++i) {
732 Symbol *sym2 = (*i).second;
733 output_pass(sym2, trav_full);
744 void CPPFile::output_iface_ns(CPPFile *file, NameSpace *sym)
746 Interface *i = dynamic_cast<Interface *>(sym);
749 file->output_guid(i->def.guid);
752 void CPPFile::output(Interface *sym, int pass, void *arg2)
756 output_nsdecl(sym, output_iface_ns);
760 bool nested = indent.indent_level != 0;
767 file << indent << "struct " << **sym->name << ";\n"
768 << indent << "struct _i_" << **sym->name << ";\n";
776 case trav_obj_stub: {
777 output_pass(sym, trav_forward);
779 for (Interface::supers_iterator i = sym->supers_begin();
780 i != sym->supers_end(); ++i)
782 Interface *super = *i;
783 output_pass(super, trav_obj_stub);
786 declare_dependencies(sym);
789 file << indent << "struct "
790 << get_definition_name(sym) << " {\n";
797 file << indent << "};\n";
804 output_pass(sym, trav_obj_stub);
806 for (Interface::supers_iterator i = sym->supers_begin();
807 i != sym->supers_end(); ++i)
809 Interface *super = *i;
810 output_pass(super, trav_full);
813 declare_dependencies(sym);
814 ns_in(sym, "OBJDEF_");
816 file << indent << "struct ";
817 file << get_definition_name(sym, "_i_") << " {\n";
821 output_internal(sym);
824 file << indent << "};\n\n";
832 output_pass(sym, trav_obj_def);
834 declare_dependencies(sym, true);
837 output_method_defs(sym);
840 output_aliases_and_types(sym);
842 for (NameSpace::const_iterator i = sym->begin(); i != sym->end(); ++i) {
843 Symbol *sym2 = (*i).second;
844 output_pass(sym2, trav_full);
855 void CPPFile::output_bf_elem(Datum *d, int pos, int bits,
859 BitField *bf = dynamic_cast<BitField *>(t);
860 Enum *en = dynamic_cast<Enum *>(t);
864 if (!d->name->compare(0, 4, "get_") ||
865 !d->name->compare(0, 4, "set_"))
868 fieldname.append(**d->name);
871 string newprefix(prefix);
872 newprefix.append(**d->name);
873 newprefix.append("_IDLNS_");
874 output_bf(bf, d->def.icon, bits, newprefix);
876 // FIXME: getters and setters
877 } else if (en || !t) {
878 file << indent << "uint" << bits << "_t "
879 << prefix << fieldname << ':' << d->def.icon << ";\n";
881 // This is checked here rather than in input.cc, because
884 fprintf(stderr, "idlc: Bad input: \"%s\" cannot be the type of \"%s\"\n",
885 t->get_fq_name()->flatten()->c_str(),
886 d->get_fq_name()->flatten()->c_str());
892 void CPPFile::output_bf(BitField *sym, int bits, int typebits,
897 assert(bits == sym->def.bits || bits == typebits);
899 for (BitField::entries_iterator i = sym->entries_begin();
900 i != sym->entries_end(); ++i)
901 size += (*i)->def.icon;
903 if (size > sym->def.bits) {
904 // FIXME: This isn't detected in the front end,
905 // but even once it is, this should stay as a
906 // replacement for input.cc checking.
908 fprintf(stderr, "idlc: \"%s\" is too small (%d bits) for its "
909 "contents (%d bits)\n",
910 sym->get_fq_name()->flatten()->c_str(),
911 sym->def.bits, size);
916 if (target->bitfield_big_endian) {
918 // The prefix is put at the end, so that we can avoid
919 // consecutive underscores or an underscore followed
920 // by a capital, both of which are reserved in C++.
922 file << indent << "uint" << bits << "_t _pad_" << prefix
923 << ':' << bits - size << ";\n";
926 int pos = sym->def.bits;
928 for (BitField::entries_reverse_iterator i = sym->entries_rbegin();
929 i != sym->entries_rend(); ++i)
933 output_bf_elem(d, pos, typebits, prefix);
938 for (BitField::entries_iterator i = sym->entries_begin();
939 i != sym->entries_end(); ++i)
942 output_bf_elem(d, pos, typebits, prefix);
948 void CPPFile::output(BitField *sym, int pass, void *arg2)
957 file << indent << "union " << **sym->name << ";\n";
961 int bits = round_up_bits(sym->def.bits);
964 file << indent << "union ";
965 file << get_definition_name(sym) << " {\n";
968 file << indent << "struct {\n";
972 output_bf(sym, bits, bits, nullprefix);
975 file << indent << "};\n\n"
976 << indent << "uint" << bits << "_t _raw;\n\n"
977 << indent << **sym->name << "()\n"
979 << indent << "\t_raw = 0;\n"
981 << indent << **sym->name << "(uint" << bits << "_t _init)\n"
983 << indent << "\t_raw = _init;\n"
985 << indent << "operator uint" << bits << "_t()\n"
987 << indent << "\treturn _raw;\n"
991 file << indent << "};\n";
994 output_aliases_and_types(sym);
1004 void CPPFile::output(Enum *sym, int pass, void *arg2)
1011 case trav_forward: {
1012 bool do_ns_out = false;
1014 if (indent.indent_level == 0) {
1021 file << indent << "struct " << **sym->name << " {\n";
1024 for (Enum::entries_iterator i = sym->entries_begin();
1025 i != sym->entries_end(); ++i)
1029 file << indent << "static const uint"
1030 << round_up_bits(sym->def.bits) << "_t "
1031 << **d->name << " = " << d->def.ucon << ";\n";
1034 file << '\n' << indent << "unsigned int _val;\n\n";
1036 file << indent << **sym->name << "()\n"
1038 << indent << "\t_val = 0;\n"
1039 << indent << "}\n\n";
1041 file << indent << **sym->name << "(unsigned int val)\n"
1043 << indent << "\t_val = val;\n"
1044 << indent << "}\n\n";
1046 file << indent << "operator unsigned int()\n"
1048 << indent << "\treturn _val;\n"
1049 << indent << "}\n\n";
1052 file << indent << "};\n";
1061 // Nothing particular to do here, other than to make sure
1062 // that trav_forward has happened (which will always need to
1063 // be done here if it's not a nested type).
1065 output_pass(sym, trav_forward);
1073 void CPPFile::output(BasicType *sym, int pass, void *arg2)
1080 case trav_forward: {
1081 bool do_ns_out = false;
1083 if (indent.indent_level == 0) {
1090 file << indent << "typedef ";
1091 assert(!is_array(sym->def));
1092 cpp_output_type(file, sym->def, false);
1093 file << **sym->name << ";\n";
1102 output_pass(sym, trav_forward);
1110 void CPPFile::output(Alias *sym, int pass, void *arg2)
1117 case trav_forward: {
1118 bool do_ns_out = false;
1120 if (indent.indent_level == 0) {
1127 const String *type = sym->get_concrete_sym()->get_fq_name("_ns")
1130 file << indent << "typedef " << *type << " "
1131 << **sym->name << ";\n";
1140 output_pass(sym, trav_forward);
1148 void CPPFile::output(TypeDef *sym, int pass, void *arg2)
1157 output_pass(sym->get_concrete_sym(), trav_forward);
1159 bool do_ns_out = false;
1161 if (indent.indent_level == 0) {
1168 const String *type = sym->get_concrete_sym()->get_fq_name("_ns")
1171 file << indent << "typedef " << *type << " "
1172 << **sym->name << ";\n";
1185 void CPPFile::output(Datum *sym, int pass, void *arg2)
1187 assert(sym->def.flags.field.Const);
1197 declare_type_dependency(sym->type, false);
1199 bool do_ns_out = false;
1201 if (indent.indent_level == 0) {
1208 file << indent << "static const ";
1210 assert(!is_array(sym->def.basictype));
1213 cpp_output_type(file, sym->type, false, false);
1215 cpp_output_type(file, sym->def.basictype, false);
1217 file << **sym->name << " = ";
1219 CompiledBasicType *def;
1221 Symbol *real_type = sym->type->get_concrete_sym();
1222 BasicType *bt = dynamic_cast<BasicType *>(real_type);
1227 def = &sym->def.basictype;
1230 if (def->flags.field.Float) {
1231 file << sym->def.fcon;
1232 } else if (def->flags.field.Bool) {
1233 if (sym->def.ucon == 0)
1238 if (def->flags.field.Unsigned) {
1239 file << "0x" << std::hex << sym->def.ucon << std::dec << 'U';
1241 file << sym->def.icon;
1260 void CPPBinding::output_root(UserNameSpace *ns, const char *dir)
1262 delete new CPPFile(ns, dir);