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.
<< 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--;
const unsigned char *guid = reinterpret_cast<const unsigned char *>(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++) {
{
Interface *i = dynamic_cast<Interface *>(sym);
assert(i);
-
+
file->output_guid(i->def.guid);
+ file->output_ifaceinfo(i);
}
void CPPFile::output(Interface *sym, int pass, void *arg2)
#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;
+}
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"
+// FIXME: This is out-of-date and incomplete.
+
#include <orb.h>
struct IFaceTable {
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,
};
struct IFaceInfo {
- static const uint8_t *guid;
+ const GUID *guid;
int (*marshall)(GrowableArray<uint8_t> &buf,
GrowableArray<ID> &objlist,
ParamInfoBlock::Segment *segs,
// 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;
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
// 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;
}