From 5adc890ffae4f90536e72bc32ef83e1141689520 Mon Sep 17 00:00:00 2001 From: Scott Wood Date: Sun, 29 Jul 2007 13:41:23 -0500 Subject: [PATCH] Add IFaceInfo. --- idlcomp/languages/c++/c++.h | 5 +++-- idlcomp/languages/c++/interface-caller.cc | 4 ++-- idlcomp/languages/c++/main.cc | 9 ++++----- idlcomp/languages/c++/marshall.cc | 11 +++++++++++ idlcomp/languages/c++/server.cc | 2 +- idlcomp/vtable-sample.h | 2 ++ include/c++/orb.h | 10 ++++++---- lib/c++/orb.cc | 15 +++++++-------- 8 files changed, 36 insertions(+), 22 deletions(-) diff --git a/idlcomp/languages/c++/c++.h b/idlcomp/languages/c++/c++.h index 51ea707..214f2cd 100644 --- a/idlcomp/languages/c++/c++.h +++ b/idlcomp/languages/c++/c++.h @@ -83,12 +83,13 @@ class CPPFile : public LangCallback { void output_one_method_ptr(Method *m, Interface *iface); static void output_iface_ns(CPPFile *file, NameSpace *sym); - + //// Misc members: - // Output the static const guid[] value. + // Output the static const guid[] value, and the IFaceInfo struct. void output_guid(const uint64_t *guid); + void output_ifaceinfo(Interface *iface); // Output a datum in the given struct, along with any necessary // padding. Return the offset of the next datum. diff --git a/idlcomp/languages/c++/interface-caller.cc b/idlcomp/languages/c++/interface-caller.cc index 4d17670..2d8c51d 100644 --- a/idlcomp/languages/c++/interface-caller.cc +++ b/idlcomp/languages/c++/interface-caller.cc @@ -283,8 +283,8 @@ void CPPFile::output_downcast(Interface *iface, Interface *super) << indent << "\treinterpret_cast< ::System::_i_Object *>(oldptr._ptr);\n" << indent << "return " << name << "(reinterpret_cast< " << iname << " *>\n" - << indent << "\t(::System::RunTime::downcast(_llptr, " - << name << "_ns::_guid.l)));\n"; + << indent << "\t(::System::RunTime::downcast(_llptr, &" + << name << "_ns::_guid)));\n"; indent.indent_level--; diff --git a/idlcomp/languages/c++/main.cc b/idlcomp/languages/c++/main.cc index 813bff3..7c6ebe8 100644 --- a/idlcomp/languages/c++/main.cc +++ b/idlcomp/languages/c++/main.cc @@ -385,10 +385,8 @@ void CPPFile::output_guid(const uint64_t *guid64) const unsigned char *guid = reinterpret_cast(guid64); char guidhex[7]; - file << indent << "static const __attribute__((unused)) union {\n" - << indent << "\tunsigned char c[16];\n" - << indent << "\tunsigned long l[];\n" - << indent << "} _guid = {\n" + file << indent << "static const __attribute__((unused))\n" + << indent << "::System::RunTime::GUID _guid = {\n" << indent << "\t{ "; for (int i = 0; i < 16; i++) { @@ -737,8 +735,9 @@ void CPPFile::output_iface_ns(CPPFile *file, NameSpace *sym) { Interface *i = dynamic_cast(sym); assert(i); - + file->output_guid(i->def.guid); + file->output_ifaceinfo(i); } void CPPFile::output(Interface *sym, int pass, void *arg2) diff --git a/idlcomp/languages/c++/marshall.cc b/idlcomp/languages/c++/marshall.cc index 1e0c87a..2391b37 100644 --- a/idlcomp/languages/c++/marshall.cc +++ b/idlcomp/languages/c++/marshall.cc @@ -14,3 +14,14 @@ #include "c++.h" +void CPPFile::output_ifaceinfo(Interface *iface) +{ + extra_newline(); + + file << indent << "static const __attribute__((unused))\n" + << indent << "::System::RunTime::IFaceInfo _info = {\n" + << indent << "\t&_guid,\n" + << indent << "};\n"; + + do_extra_newline = true; +} diff --git a/idlcomp/languages/c++/server.cc b/idlcomp/languages/c++/server.cc index f773e6f..190eb46 100644 --- a/idlcomp/languages/c++/server.cc +++ b/idlcomp/languages/c++/server.cc @@ -288,7 +288,7 @@ void cpp_output_iface_table_entry(Interface *super, void *arg) ctx.f << ctx.indent << "{\n"; ctx.indent.indent_level++; - ctx.f << ctx.indent; + ctx.f << ctx.indent << '&'; cpp_output_name(ctx.f, super); ctx.f << "_ns::_info,\n" diff --git a/idlcomp/vtable-sample.h b/idlcomp/vtable-sample.h index a62633c..bffd75f 100644 --- a/idlcomp/vtable-sample.h +++ b/idlcomp/vtable-sample.h @@ -1,3 +1,5 @@ +// FIXME: This is out-of-date and incomplete. + #include struct IFaceTable { diff --git a/include/c++/orb.h b/include/c++/orb.h index 30c4157..72daad8 100644 --- a/include/c++/orb.h +++ b/include/c++/orb.h @@ -327,10 +327,12 @@ namespace System { const int chainlen; }; - uintptr_t downcast(::System::_i_Object *obj, - const unsigned long *new_guid); + union GUID { + unsigned char c[16]; + unsigned long l[]; + }; - typedef uint64_t GUID[2]; + uintptr_t downcast(::System::_i_Object *obj, const GUID *new_guid); // FIXME: use above typedef static inline bool guids_equal(const unsigned long *guid1, @@ -395,7 +397,7 @@ namespace System { }; struct IFaceInfo { - static const uint8_t *guid; + const GUID *guid; int (*marshall)(GrowableArray &buf, GrowableArray &objlist, ParamInfoBlock::Segment *segs, diff --git a/lib/c++/orb.cc b/lib/c++/orb.cc index a6158bf..a62e91f 100644 --- a/lib/c++/orb.cc +++ b/lib/c++/orb.cc @@ -7,8 +7,7 @@ namespace RunTime { // This function could be made to do a binary search if we can // manage to somehow sort the IFaceTables... - uintptr_t downcast(::System::_i_Object *obj, - const unsigned long *new_guid) + uintptr_t downcast(::System::_i_Object *obj, const GUID *new_guid) { if (!obj) return 0; @@ -19,7 +18,7 @@ namespace RunTime { unsupported_long_size(); IFaceTable *tbl = obj->info->concrete_IFaceTable; - unsigned long new_guid_first = *new_guid; + unsigned long new_guid_first = new_guid->l[0]; // This doesn't use guids_equal(), as that would eliminate the // ability to cache the first word of new_guid. The compiler @@ -29,15 +28,15 @@ namespace RunTime { // behaves. while (true) { - if (tbl->info->guid[0] == new_guid_first && - tbl->info->guid[1] == new_guid[1] && + if (tbl->info->guid->l[0] == new_guid_first && + tbl->info->guid->l[1] == new_guid->l[1] && (sizeof(long) == 8 || - (tbl->info->guid[2] == new_guid[2] && - tbl->info->guid[3] == new_guid[3]))) + (tbl->info->guid->l[2] == new_guid->l[2] && + tbl->info->guid->l[3] == new_guid->l[3]))) break; tbl++; - if (__builtin_expect(!tbl->info->guid, 0)) + if (__builtin_expect(!tbl->info->guid->l[0], 0)) return 0; } -- 2.39.2