10 static const unsigned char guid[];
13 // The concrete field is used by the ORB to locate the
14 // object ID (stored one word before the concrete pointer).
15 // The concrete field is zero except where multiple
16 // inheritance causes there to be multiple table pointers in
17 // the object. When that happens, the concrete field is the
18 // number of bytes (either 0 or negative) to add to the
19 // pointer to yield a pointer to the most derived interface
20 // (of which there can be only one).
24 // This is a pointer to the most derived interface's
25 // interface table, for use by a downcast method that does
26 // not know the real type yet.
28 ::System::RunTime::IFaceTable *concrete_IFaceTable;
30 // A list of interfaces follows. Each entry in the list
31 // consists of a pointer to the GUID for the entry's
32 // interface, followed by an offset to add to a pointer of
33 // this interface to obtain a pointer to this entry's
34 // interface. This list is scanned during downcast()
35 // operations. The entries are used directly (no scanning)
36 // for upcast operations, and the first entry (which must be
37 // the for this interface) is used by the ORB to verify the
38 // GUID of objects passed.
40 // The offsets must be dynamic, because an interface can
41 // only have one pointer regardless of how many times it is
42 // inherited by an interface's parents, and thus the pointer
43 // adjustment will not be the same for all pointers of the
44 // same inner interface.
46 // For now, this table is ordered by the for_all_supers
47 // traversal, but eventually it'd be nice to sort it
48 // by GUID pointer (and yes, that change will break ABI
51 ::System::RunTime::IFaceTable System_IDLIDL_Object;
53 // This is a NULL pointer to mark the end of the GUID
57 // Finally, the method pointers are provided.
58 // There are currently no methods in System::Object.
64 const info_type *info;
76 Object(_i_Object *other)
81 operator _i_Object *()
89 template<typename T> struct Array {
93 bool valid_index(size_t index)
95 return index >= 0 && index < count;
98 T &operator[](size_t index)
100 #ifndef NO_ARRAY_BOUNDS_CHECK
101 if (!valid_index(index))
102 throw SomeException();
109 uintptr_t downcast(::System::_i_Object *obj, unsigned char *new_guid)
111 IFaceTable *tbl = obj->info->concrete_IFaceTable;
112 int index = 0, found_index = -1;
114 while (tbl->guid != new_guid) {
121 uintptr_t ptr = (uintptr_t)obj;
123 ptr += obj->info->concrete;
130 struct NotifierInfo {
136 struct NotifierInfo : public ::System::NotifierInfo {
139 // Yuck. Hack to work around broken enum-scoping and
140 // undefined enum-width.
142 static const uint32_t Success = 0;
143 static const uint32_t NoMoreData = 1;
144 static const uint32_t NoMoreSpace = 2;
145 static const uint32_t IOError = 3;
146 static const uint32_t BadHandle = 4;
147 static const uint32_t PipeClosed = 5;
149 // Double yuck... Is there any sane way to avoid exposing
150 // a leading underscore to the user, without potential conflicts
151 // with enum values? Perhaps "enumval" could be made a reserved
157 // Note the absence of "virtual"... We don't want to use the
158 // compiler's virtual table implementation, as we can't rely on it
159 // to be compatible with any other language or compiler (or even
160 // other versions of itself), and we also need the object ID to be
161 // at a specific offset from the pointer. We manage all virtual
162 // table operations (including RTTI) ourselves. Note that it is
163 // an error if the compiler emits a virtual table (or anything
164 // else not asked for) for any reason.
166 // Unfortunately, this could deprive some compilers of optimization
167 // information (such as for inlining when the concrete type is known
168 // and the implementation is present in the same compilation unit).
169 // A compiler which explicitly supports our standard vtable layout
170 // could use alternate stub code that makes use of such support.
173 static const unsigned char guid[];
176 // The info struct from the closest superinterface
177 // which shares this pointer is included first.
178 ::System::_i_Object::info_type parent;
181 IFaceTable System_IDLIDL_IO_IDLIDL_IStream;
182 IFaceTable System_IDLIDL_Object;
187 void (*read)(::System::IO::_i_IStream *_this,
188 Array<char> *buf, uint64_t *len);
190 void (*read_async)(::System::IO::_i_IStream *_this,
191 Array<unsigned char> *buf,
192 ::System::Notifier *notifier);
201 void read(unsigned char &*buf, size_t &_count_buf, uint64_t &len)
203 _ptr->info->methods.read(this, buf, _count_buf, len);
206 void read_async(unsigned char *buf, size_t _count_buf,
207 ::System::Notifier *notifier)
209 _ptr->info->methods.read_async(this, buf, _count_buf, notifier);
217 IStream(_i_IStream *other)
222 operator _i_IStream *()
227 // Returns NULL if the downcast fails. Upcasts never fail.
228 // "downcast" is (will be) a reserved word in IDL, or at least
229 // in the C++ binding.
231 static IStream downcast(::System::Object oldptr)
233 return IStream(reinterpret_cast<_i_IStream *>
234 (::System::RunTime::downcast(oldptr, _i_IStream::guid)));
237 operator ::System::Object()
239 uintptr_t ptr = reinterpret_cast<uintptr_t>(this);
240 ptr += _ptr->info->System_IDLIDL_Object.offset;
241 return ::System::Object(reinterpret_cast<::System::_i_Object *>(ptr));
246 static const unsigned char guid[];
249 ::System::Object::info parent;
252 unsigned char *System_IDLIDL_IO_IDLIDL_OStream;
253 unsigned char *System_IDLIDL_Object;
258 int32_t System_IDLIDL_IO_IDLIDL_OStream;
259 int32_t System_IDLIDL_Object;
263 void (*write)(::System::IO::_i_OStream *_this, unsigned char *buf,
264 size_t *_count_buf, uint64_t *len);
266 void (*write_async)(::System::IO::_i_OStream *this, unsigned char *buf,
267 size_t count_buf, ::System::Notifier *notifier);
271 const info_type info;
273 void write(unsigned char *buf, size_t _count_buf, uint64_t &len)
275 info->methods.write(this, buf, _count_buf, len);
278 void write_async(unsigned char *buf, size_t _count_buf,
279 ::System::Notifier *notifier)
281 info->methods.write_async(this, buf, _count_buf, notifier);
284 static ::System::IO::OStream *downcast(::System::Object *obj)
286 return (::System::IO::OStream *)
287 ::System::RunTime::downcast(obj, ::System::IO::OStream::guid);
290 ::System::Object *upcast(::System::Object *type)
292 uintptr_t ptr = (uintptr_t)this;
293 ptr += info->casts.System_IDLIDL_Object;
294 return (::System::Object *)ptr;
300 static const unsigned char guid[];
303 // Share a pointer with the left-most superinterface
304 ::System::IO::_i_IStream::info parent;
307 unsigned char *System_IDLIDL_IO_IDLIDL_IOStream;
308 unsigned char *System_IDLIDL_IO_IDLIDL_IStream;
309 unsigned char *System_IDLIDL_IO_IDLIDL_OStream;
310 unsigned char *System_IDLIDL_Object;
315 int32_t System_IDLIDL_IO_IDLIDL_IOStream;
316 int32_t System_IDLIDL_IO_IDLIDL_IStream;
317 int32_t System_IDLIDL_IO_IDLIDL_OStream;
318 int32_t System_IDLIDL_Object;
322 void (*read)(::System::IO::_i_IStream *_this,
323 Array<char> *buf, uint64_t *len);
325 void (*read_async)(::System::IO::_i_IStream *_this,
326 Array<unsigned char> *buf,
327 ::System::Notifier *notifier);
329 void (*write)(::System::IO::_i_OStream *_this, unsigned char *buf,
330 size_t *_count_buf, uint64_t *len);
332 void (*write_async)(::System::IO::_i_OStream *this, unsigned char *buf,
333 size_t count_buf, ::System::Notifier *notifier);
337 const info_type *info;
339 ::System::_i_OStream::info *info_System_IDLIDL_OStream;
346 void read(unsigned char &*buf, size_t &_count_buf, uint64_t &len)
348 info->parent.methods.read(this, buf, _count_buf, len);
351 void read_async(unsigned char *buf, size_t _count_buf,
352 ::System::Notifier *notifier)
354 info->parent.methods.read_async(this, buf, _count_buf, notifier);
357 void write(unsigned char *buf, size_t _count_buf, uint64_t &len)
359 ::System::OStream *thisptr = upcast((::System::Ostream *)NULL);
360 info_System_IDLIDL_OStream.methods.write(this, buf, _count_buf, len);
363 void write_async(unsigned char *buf, size_t _count_buf,
364 ::System::Notifier *notifier)
366 info_System_IDLIDL_OStream.methods.write_async
367 (this, buf, _count_buf, notifier);
370 static ::System::IO::OStream *downcast(::System::Object *obj)
372 return (::System::IO::OStream *)
373 ::System::RunTime::downcast(obj, ::System::IO::OStream::guid);
376 ::System::Object *upcast(::System::Object *type)
378 uintptr_t ptr = (uintptr_t)this;
379 ptr += info->casts.System_IDLIDL_Object;
380 return (::System::Object *)ptr;
389 struct OStream : public ::System::Object {
390 void write(unsigned char *buf, size_t _count_buf, uint64_t &len) = 0;
393 struct IOStream : public IStream, OStream {
396 struct FStream : public IOStream {
397 void set_file(File *f) = 0;
398 void get_file(File &*f) = 0;
411 class PhysAddrSpace {
423 _inproc_MapHandle(void **vtable) : _vtable(vtable)
428 void unmap(Region *regions, size_t count)
433 class _remote_MapHandle : public MapHandle {
435 void unmap(Region *regions, size_t count)
441 // If implemented here, user supplies:
442 class RealMapHandle : public MapHandle {
443 void unmap(Region *regions, size_t count) {
448 // This goes in a footer included in a non-header after the user's
449 // header, or perhaps in an idlc-generated .cc file (which would
450 // then need to know where the user's headers are located).
451 void _entries_RealMapHandle() {
452 // -Wno-pmf-conversions please...
453 typedef void (*unmap)(RealMapHandle *, Region *, size_t);
456 asm volatile(".global _entry_RealMapHandle\n"
457 "_entry_RealMapHandle:"
460 "jmpl %0;" : : "i" ((unmap)&RealMapHandle::MapHandle));
463 // Need to make sure that the branch is within range, or
465 asm volatile(".global _entry_RealMapHandle\n"
466 "_entry_RealMapHandle:"
469 "br %0;" : : "i" ((unmap)&RealMapHandle::MapHandle));
472 // FIXME: probably use sections here instead of a global
473 // constructor. This way, initialization can be ordered,
474 // and it'd be easier to extract a list of implemented
475 // classes from the binary.
477 class _init_RealMapHandle() {
479 _init_RealMapHandle()
484 ~_init_RealMapHandle()
486 // deregister -- or don't bother because it's
487 // the end of the program and it'll be unregistered
488 // automatically anyway?
492 _init_RealMapHandle _initinstance_RealMapHandle;
494 // If not implemented here...
496 class RealMapHandle : public MapHandle {
497 void unmap(Region *regions, size_t count) {
507 uint64_t get_size() = 0;
508 void get_size(uint64_t &size) = 0;
510 uint64_t get_block_size() = 0;
511 void get_block_size(uint64_t &block_size) = 0;