|
Rapicorn - Experimental UI Toolkit - Source Code 10.08.1
|
00001 // plic/runtime.hh - Plic C++ Runtime API 00002 // CC0 Public Domain: http://creativecommons.org/publicdomain/zero/1.0/ 00003 #ifndef __PLIC_RUNTIME_HH__ 00004 #define __PLIC_RUNTIME_HH__ 00005 00006 #include <string> 00007 #include <vector> 00008 #include <memory> // auto_ptr 00009 #include <stdint.h> // uint32_t 00010 #include <stdarg.h> 00011 #include <tr1/memory> // shared_ptr 00012 00013 namespace Plic { 00014 using std::tr1::bad_weak_ptr; 00015 using std::tr1::enable_shared_from_this; 00016 using std::tr1::shared_ptr; 00017 using std::tr1::weak_ptr; 00018 00019 /* === Auxillary macros === */ 00020 #define PLIC_CPP_STRINGIFYi(s) #s // indirection required to expand __LINE__ etc 00021 #define PLIC_CPP_STRINGIFY(s) PLIC_CPP_STRINGIFYi (s) 00022 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) 00023 #define PLIC_UNUSED __attribute__ ((__unused__)) 00024 #define PLIC_DEPRECATED __attribute__ ((__deprecated__)) 00025 #define PLIC_PRINTF(fix, arx) __attribute__ ((__format__ (__printf__, fix, arx))) 00026 #define PLIC_BOOLi(expr) __extension__ ({ bool _plic__bool; if (expr) _plic__bool = 1; else _plic__bool = 0; _plic__bool; }) 00027 #define PLIC_ISLIKELY(expr) __builtin_expect (PLIC_BOOLi (expr), 1) 00028 #define PLIC_UNLIKELY(expr) __builtin_expect (PLIC_BOOLi (expr), 0) 00029 #else /* !__GNUC__ */ 00030 #define PLIC_UNUSED 00031 #define PLIC_DEPRECATED 00032 #define PLIC_PRINTF(fix, arx) 00033 #define PLIC_ISLIKELY(expr) expr 00034 #define PLIC_UNLIKELY(expr) expr 00035 #endif 00036 #define PLIC_LIKELY PLIC_ISLIKELY 00037 00038 // == Standard Types == 00039 using std::vector; 00040 typedef signed long long int int64_t; // libc's int64_t is a long on AMD64 which breaks printf 00041 typedef unsigned long long int uint64_t; // libc's uint64_t is a long on AMD64 which breaks printf 00042 00043 // == TypeKind == 00045 enum TypeKind { 00046 UNTYPED = 0, 00047 VOID = 'v', 00048 INT = 'i', 00049 FLOAT = 'd', 00050 STRING = 's', 00051 ENUM = 'E', 00052 SEQUENCE = 'Q', 00053 RECORD = 'R', 00054 INSTANCE = 'C', 00055 FUNC = 'F', 00056 TYPE_REFERENCE = 'T', 00057 ANY = 'Y', 00058 }; 00059 const char* type_kind_name (TypeKind type_kind); 00060 00061 // == TypeCode == 00062 struct TypeCode 00063 { 00064 typedef std::string String; 00065 TypeKind kind () const; 00066 std::string kind_name () const; 00067 std::string name () const; 00068 size_t aux_count () const; 00069 std::string aux_data (size_t index) const; 00070 std::string aux_value (std::string key) const; 00071 std::string hints () const; 00072 size_t enum_count () const; 00073 std::vector<String> enum_value (size_t index) const; 00074 size_t prerequisite_count () const; 00075 std::string prerequisite (size_t index) const; 00076 size_t field_count () const; 00077 TypeCode field (size_t index) const; 00078 std::string origin () const; 00079 bool untyped () const; 00080 std::string pretty (const std::string &indent = "") const; 00081 bool operator!= (const TypeCode &o) const; 00082 bool operator== (const TypeCode&) const; 00083 /*copy*/ TypeCode (const TypeCode&); 00084 TypeCode& operator= (const TypeCode&); 00085 /*dtor*/ ~TypeCode (); 00086 void swap (TypeCode &other); 00087 class InternalType; class MapHandle; 00088 private: // implementation bits 00089 explicit TypeCode (MapHandle*, InternalType*); 00090 static TypeCode notype (MapHandle*); 00091 friend class TypeMap; 00092 MapHandle *m_handle; 00093 InternalType *m_type; 00094 }; 00095 00096 class TypeMap 00097 { 00098 TypeCode::MapHandle *m_handle; friend class TypeCode::MapHandle; 00099 explicit TypeMap (TypeCode::MapHandle*); 00100 static TypeMap builtins (); 00101 public: 00102 /*copy*/ TypeMap (const TypeMap&); 00103 TypeMap& operator= (const TypeMap&); 00104 /*dtor*/ ~TypeMap (); 00105 size_t type_count () const; 00106 const TypeCode type (size_t index) const; 00107 int error_status (); 00108 static TypeMap load (std::string file_name); 00109 static TypeCode lookup (std::string name); 00110 static TypeMap load_local (std::string file_name); 00111 TypeCode lookup_local (std::string name) const; 00112 static TypeCode notype (); 00113 }; 00114 00115 // == Any Type == 00116 class Any 00117 { 00118 typedef std::string String; 00119 TypeCode type_code; 00120 typedef std::vector<Any> AnyVector; 00121 union { int64_t vint64; uint64_t vuint64; double vdouble; Any *vany; uint64_t qmem[(sizeof (AnyVector) + 7) / 8]; 00122 uint64_t smem[(sizeof (String) + 7) / 8]; uint8_t bytes[8]; } u; 00123 void ensure (TypeKind _kind) { if (PLIC_LIKELY (kind() == _kind)) return; rekind (_kind); } 00124 void rekind (TypeKind _kind); 00125 void reset (); 00126 bool to_int (int64_t &v, char b) const; 00127 public: 00128 /*dtor*/ ~Any (); 00129 explicit Any (); 00130 /*copy*/ Any (const Any &clone); 00131 Any& operator= (const Any &clone); 00132 bool operator== (const Any &clone) const; 00133 bool operator!= (const Any &clone) const; 00134 TypeCode tyoe () const { return type_code; } 00135 TypeKind kind () const { return type_code.kind(); } 00136 void retype (const TypeCode &tc); 00137 void swap (Any &other); 00138 bool operator>>= (bool &v) const { int64_t d; const bool r = to_int (d, 1); v = d; return r; } 00139 bool operator>>= (char &v) const { int64_t d; const bool r = to_int (d, 7); v = d; return r; } 00140 bool operator>>= (unsigned char &v) const { int64_t d; const bool r = to_int (d, 8); v = d; return r; } 00141 bool operator>>= (int &v) const { int64_t d; const bool r = to_int (d, 31); v = d; return r; } 00142 bool operator>>= (unsigned int &v) const { int64_t d; const bool r = to_int (d, 32); v = d; return r; } 00143 bool operator>>= (long &v) const { int64_t d; const bool r = to_int (d, 47); v = d; return r; } 00144 bool operator>>= (unsigned long &v) const { int64_t d; const bool r = to_int (d, 48); v = d; return r; } 00145 bool operator>>= (int64_t &v) const; 00146 bool operator>>= (uint64_t &v) const { int64_t d; const bool r = to_int (d, 64); v = d; return r; } 00147 bool operator>>= (float &v) const { double d; const bool r = operator>>= (d); v = d; return r; } 00148 bool operator>>= (double &v) const; 00149 bool operator>>= (const char *&v) const { String s; const bool r = operator>>= (s); v = s.c_str(); return r; } 00150 bool operator>>= (std::string &v) const; 00151 bool operator>>= (const Any *&v) const; 00152 const Any& as_any () const { return kind() == ANY ? *u.vany : *this; } 00153 double as_float () const; 00154 int64_t as_int () const; 00155 String as_string() const; 00156 // >>= enum 00157 // >>= sequence 00158 // >>= record 00159 // >>= instance 00160 void operator<<= (bool v) { operator<<= (int64_t (v)); } 00161 void operator<<= (char v) { operator<<= (int64_t (v)); } 00162 void operator<<= (unsigned char v) { operator<<= (int64_t (v)); } 00163 void operator<<= (int v) { operator<<= (int64_t (v)); } 00164 void operator<<= (unsigned int v) { operator<<= (int64_t (v)); } 00165 void operator<<= (long v) { operator<<= (int64_t (v)); } 00166 void operator<<= (unsigned long v) { operator<<= (int64_t (v)); } 00167 void operator<<= (uint64_t v); 00168 void operator<<= (int64_t v); 00169 void operator<<= (float v) { operator<<= (double (v)); } 00170 void operator<<= (double v); 00171 void operator<<= (const char *v) { operator<<= (std::string (v)); } 00172 void operator<<= (char *v) { operator<<= (std::string (v)); } 00173 void operator<<= (const String &v); 00174 void operator<<= (const Any &v); 00175 // <<= enum 00176 // <<= sequence 00177 // <<= record 00178 // <<= instance 00179 void resize (size_t n); 00180 }; 00181 00182 // == Type Declarations == 00183 class SimpleServer; 00184 class Connection; 00185 union FieldUnion; 00186 class FieldBuffer; 00187 class FieldReader; 00188 typedef FieldBuffer* (*DispatchFunc) (FieldReader&); 00189 00190 // == Type Hash == 00191 struct TypeHash { 00192 uint64_t typehi, typelo; 00193 explicit TypeHash (uint64_t hi, uint64_t lo) : typehi (hi), typelo (lo) {} 00194 explicit TypeHash () : typehi (0), typelo (0) {} 00195 inline bool operator== (const TypeHash &z) const { return typehi == z.typehi && typelo == z.typelo; } 00196 }; 00197 typedef std::vector<TypeHash> TypeHashList; 00198 00199 // === Utilities === 00200 template<class V> inline 00201 bool atomic_ptr_cas (V* volatile *ptr_adr, V *o, V *n) { return __sync_bool_compare_and_swap (ptr_adr, o, n); } 00202 void error_printf (const char *format, ...) PLIC_PRINTF (1, 2); 00203 void error_vprintf (const char *format, va_list args); 00204 00205 // === Message IDs === 00206 enum MessageId { 00207 MSGID_NONE = 0, 00208 MSGID_ONEWAY = 0x2000000000000000ULL, 00209 MSGID_TWOWAY = 0x3000000000000000ULL, 00210 MSGID_DISCON = 0x4000000000000000ULL, 00211 MSGID_SIGCON = 0x5000000000000000ULL, 00212 MSGID_EVENT = 0x6000000000000000ULL, 00213 // MSGID_SIGNAL = 0x7000000000000000ULL, ///< Two-way signal message ID, returns result message. 00214 }; 00215 inline bool msgid_has_result (MessageId mid) { return (mid & 0x9000000000000000ULL) == 0x1000000000000000ULL; } 00216 inline bool msgid_is_result (MessageId mid) { return (mid & 0x9000000000000000ULL) == 0x9000000000000000ULL; } 00217 inline bool msgid_is_error (MessageId mid) { return (mid & 0xf000000000000000ULL) == 0x8000000000000000ULL; } 00218 inline bool msgid_is_oneway (MessageId mid) { return (mid & 0x7000000000000000ULL) == MSGID_ONEWAY; } 00219 inline bool msgid_is_twoway (MessageId mid) { return (mid & 0x7000000000000000ULL) == MSGID_TWOWAY; } 00220 inline bool msgid_is_discon (MessageId mid) { return (mid & 0x7000000000000000ULL) == MSGID_DISCON; } 00221 inline bool msgid_is_sigcon (MessageId mid) { return (mid & 0x7000000000000000ULL) == MSGID_SIGCON; } 00222 inline bool msgid_is_event (MessageId mid) { return (mid & 0x7000000000000000ULL) == MSGID_EVENT; } 00223 00224 // === NonCopyable === 00225 class NonCopyable { 00226 NonCopyable& operator= (const NonCopyable&); 00227 /*copy*/ NonCopyable (const NonCopyable&); 00228 protected: 00229 /*ctor*/ NonCopyable () {} 00230 /*dtor*/ ~NonCopyable () {} 00231 }; 00232 00233 /* === SmartHandle === */ 00234 class SmartHandle { 00235 uint64_t m_rpc_id; 00236 protected: 00237 typedef bool (SmartHandle::*_UnspecifiedBool) () const; // non-numeric operator bool() result 00238 static inline _UnspecifiedBool _unspecified_bool_true () { return &Plic::SmartHandle::_is_null; } 00239 typedef uint64_t RpcId; 00240 explicit SmartHandle (uint64_t ipcid); 00241 void _reset (); 00242 void* _cast_iface () const; 00243 inline void* _void_iface () const; 00244 void _void_iface (void *rpc_id_ptr); 00245 public: 00246 explicit SmartHandle (); 00247 uint64_t _rpc_id () const; 00248 bool _is_null () const; 00249 virtual ~SmartHandle (); 00250 }; 00251 00252 /* === SimpleServer === */ 00253 class SimpleServer { 00254 public: 00255 explicit SimpleServer (); 00256 virtual ~SimpleServer (); 00257 virtual uint64_t _rpc_id () const; 00258 }; 00259 00260 /* === FieldBuffer === */ 00261 class _FakeFieldBuffer { FieldUnion *u; virtual ~_FakeFieldBuffer() {}; }; 00262 00263 union FieldUnion { 00264 int64_t vint64; 00265 double vdouble; 00266 Any *vany; 00267 uint64_t smem[(sizeof (std::string) + 7) / 8]; // String 00268 uint64_t bmem[(sizeof (_FakeFieldBuffer) + 7) / 8]; // FieldBuffer 00269 uint8_t bytes[8]; // FieldBuffer types 00270 struct { uint32_t capacity, index; }; // FieldBuffer.buffermem[0] 00271 }; 00272 00273 struct EnumValue { int64_t v; EnumValue (int64_t e) : v (e) {} }; 00274 00275 class FieldBuffer { // buffer for marshalling procedure calls 00276 typedef std::string String; 00277 friend class FieldReader; 00278 void check_internal (); 00279 inline FieldUnion& upeek (uint32_t n) const { return buffermem[offset() + n]; } 00280 protected: 00281 FieldUnion *buffermem; 00282 inline void check () { if (PLIC_UNLIKELY (size() > capacity())) check_internal(); } 00283 inline uint32_t offset () const { const uint32_t offs = 1 + (capacity() + 7) / 8; return offs; } 00284 inline TypeKind type_at (uint32_t n) const { return TypeKind (buffermem[1 + n/8].bytes[n%8]); } 00285 inline void set_type (TypeKind ft) { buffermem[1 + size()/8].bytes[size()%8] = ft; } 00286 inline uint32_t capacity () const { return buffermem[0].capacity; } 00287 inline uint32_t size () const { return buffermem[0].index; } 00288 inline FieldUnion& getu () const { return buffermem[offset() + size()]; } 00289 inline FieldUnion& addu (TypeKind ft) { set_type (ft); FieldUnion &u = getu(); buffermem[0].index++; check(); return u; } 00290 inline FieldUnion& uat (uint32_t n) const { return n < size() ? upeek (n) : *(FieldUnion*) NULL; } 00291 explicit FieldBuffer (uint32_t _ntypes); 00292 explicit FieldBuffer (uint32_t, FieldUnion*, uint32_t); 00293 public: 00294 virtual ~FieldBuffer(); 00295 inline uint64_t first_id () const { return buffermem && size() && type_at (0) == INT ? upeek (0).vint64 : 0; } 00296 inline void add_int64 (int64_t vint64) { FieldUnion &u = addu (INT); u.vint64 = vint64; } 00297 inline void add_evalue (int64_t vint64) { FieldUnion &u = addu (ENUM); u.vint64 = vint64; } 00298 inline void add_double (double vdouble) { FieldUnion &u = addu (FLOAT); u.vdouble = vdouble; } 00299 inline void add_string (const String &s) { FieldUnion &u = addu (STRING); new (&u) String (s); } 00300 inline void add_object (uint64_t objid) { FieldUnion &u = addu (INSTANCE); u.vint64 = objid; } 00301 inline void add_any (const Any &vany) { FieldUnion &u = addu (ANY); u.vany = new Any (vany); } 00302 inline void add_msgid (uint64_t h, uint64_t l) { add_int64 (h); add_int64 (l); } 00303 inline FieldBuffer& add_rec (uint32_t nt) { FieldUnion &u = addu (RECORD); return *new (&u) FieldBuffer (nt); } 00304 inline FieldBuffer& add_seq (uint32_t nt) { FieldUnion &u = addu (SEQUENCE); return *new (&u) FieldBuffer (nt); } 00305 inline void reset(); 00306 String first_id_str() const; 00307 String to_string() const; 00308 static String type_name (int field_type); 00309 static FieldBuffer* _new (uint32_t _ntypes); // Heap allocated FieldBuffer 00310 static FieldBuffer* new_error (const String &msg, const String &domain = ""); 00311 static FieldBuffer* new_result (uint32_t n = 1); 00312 inline FieldBuffer& operator<< (size_t v) { FieldUnion &u = addu (INT); u.vint64 = v; return *this; } 00313 inline FieldBuffer& operator<< (uint64_t v) { FieldUnion &u = addu (INT); u.vint64 = v; return *this; } 00314 inline FieldBuffer& operator<< (int64_t v) { FieldUnion &u = addu (INT); u.vint64 = v; return *this; } 00315 inline FieldBuffer& operator<< (uint32_t v) { FieldUnion &u = addu (INT); u.vint64 = v; return *this; } 00316 inline FieldBuffer& operator<< (int v) { FieldUnion &u = addu (INT); u.vint64 = v; return *this; } 00317 inline FieldBuffer& operator<< (bool v) { FieldUnion &u = addu (INT); u.vint64 = v; return *this; } 00318 inline FieldBuffer& operator<< (double v) { FieldUnion &u = addu (FLOAT); u.vdouble = v; return *this; } 00319 inline FieldBuffer& operator<< (EnumValue e) { FieldUnion &u = addu (ENUM); u.vint64 = e.v; return *this; } 00320 inline FieldBuffer& operator<< (const String &s) { FieldUnion &u = addu (STRING); new (&u) String (s); return *this; } 00321 inline FieldBuffer& operator<< (Any v) { FieldUnion &u = addu (ANY); u.vany = new Any (v); return *this; } 00322 inline FieldBuffer& operator<< (const TypeHash &h) { *this << h.typehi; *this << h.typelo; return *this; } 00323 }; 00324 00325 class FieldBuffer8 : public FieldBuffer { // Stack contained buffer for up to 8 fields 00326 FieldUnion bmem[1 + 1 + 8]; 00327 public: 00328 virtual ~FieldBuffer8 () { reset(); buffermem = NULL; } 00329 inline FieldBuffer8 (uint32_t ntypes = 8) : FieldBuffer (ntypes, bmem, sizeof (bmem)) {} 00330 }; 00331 00332 class FieldReader { // read field buffer contents 00333 typedef std::string String; 00334 const FieldBuffer *m_fb; 00335 uint32_t m_nth; 00336 void check_request (int type); 00337 inline void request (int t) { if (PLIC_UNLIKELY (m_nth >= n_types() || get_type() != t)) check_request (t); } 00338 inline FieldUnion& fb_getu (int t) { request (t); return m_fb->upeek (m_nth); } 00339 inline FieldUnion& fb_popu (int t) { request (t); FieldUnion &u = m_fb->upeek (m_nth++); return u; } 00340 public: 00341 explicit FieldReader (const FieldBuffer &fb) : m_fb (&fb), m_nth (0) {} 00342 inline void reset (const FieldBuffer &fb) { m_fb = &fb; m_nth = 0; } 00343 inline void reset () { m_fb = NULL; m_nth = 0; } 00344 inline uint32_t remaining () { return n_types() - m_nth; } 00345 inline void skip () { if (PLIC_UNLIKELY (m_nth >= n_types())) check_request (0); m_nth++; } 00346 inline void skip_msgid () { skip(); skip(); } 00347 inline uint32_t n_types () { return m_fb->size(); } 00348 inline TypeKind get_type () { return m_fb->type_at (m_nth); } 00349 inline int64_t get_int64 () { FieldUnion &u = fb_getu (INT); return u.vint64; } 00350 inline int64_t get_evalue () { FieldUnion &u = fb_getu (ENUM); return u.vint64; } 00351 inline double get_double () { FieldUnion &u = fb_getu (FLOAT); return u.vdouble; } 00352 inline const String& get_string () { FieldUnion &u = fb_getu (STRING); return *(String*) &u; } 00353 inline uint64_t get_object () { FieldUnion &u = fb_getu (INSTANCE); return u.vint64; } 00354 inline const Any& get_any () { FieldUnion &u = fb_getu (ANY); return *u.vany; } 00355 inline const FieldBuffer& get_rec () { FieldUnion &u = fb_getu (RECORD); return *(FieldBuffer*) &u; } 00356 inline const FieldBuffer& get_seq () { FieldUnion &u = fb_getu (SEQUENCE); return *(FieldBuffer*) &u; } 00357 inline int64_t pop_int64 () { FieldUnion &u = fb_popu (INT); return u.vint64; } 00358 inline int64_t pop_evalue () { FieldUnion &u = fb_popu (ENUM); return u.vint64; } 00359 inline double pop_double () { FieldUnion &u = fb_popu (FLOAT); return u.vdouble; } 00360 inline const String& pop_string () { FieldUnion &u = fb_popu (STRING); return *(String*) &u; } 00361 inline uint64_t pop_object () { FieldUnion &u = fb_popu (INSTANCE); return u.vint64; } 00362 inline const Any& pop_any () { FieldUnion &u = fb_popu (ANY); return *u.vany; } 00363 inline const FieldBuffer& pop_rec () { FieldUnion &u = fb_popu (RECORD); return *(FieldBuffer*) &u; } 00364 inline const FieldBuffer& pop_seq () { FieldUnion &u = fb_popu (SEQUENCE); return *(FieldBuffer*) &u; } 00365 inline FieldReader& operator>> (size_t &v) { FieldUnion &u = fb_popu (INT); v = u.vint64; return *this; } 00366 inline FieldReader& operator>> (uint64_t &v) { FieldUnion &u = fb_popu (INT); v = u.vint64; return *this; } 00367 inline FieldReader& operator>> (int64_t &v) { FieldUnion &u = fb_popu (INT); v = u.vint64; return *this; } 00368 inline FieldReader& operator>> (uint32_t &v) { FieldUnion &u = fb_popu (INT); v = u.vint64; return *this; } 00369 inline FieldReader& operator>> (int &v) { FieldUnion &u = fb_popu (INT); v = u.vint64; return *this; } 00370 inline FieldReader& operator>> (bool &v) { FieldUnion &u = fb_popu (INT); v = u.vint64; return *this; } 00371 inline FieldReader& operator>> (double &v) { FieldUnion &u = fb_popu (FLOAT); v = u.vdouble; return *this; } 00372 inline FieldReader& operator>> (EnumValue &e) { FieldUnion &u = fb_popu (ENUM); e.v = u.vint64; return *this; } 00373 inline FieldReader& operator>> (String &s) { FieldUnion &u = fb_popu (STRING); s = *(String*) &u; return *this; } 00374 inline FieldReader& operator>> (Any &v) { FieldUnion &u = fb_popu (ANY); v = *u.vany; return *this; } 00375 inline FieldReader& operator>> (TypeHash &h) { *this >> h.typehi; *this >> h.typelo; return *this; } 00376 inline FieldReader& operator>> (std::vector<bool>::reference v) { bool b; *this >> b; v = b; return *this; } 00377 }; 00378 00379 // === Connection === 00380 class Connection 00381 { 00382 public: 00383 virtual FieldBuffer* call_remote (FieldBuffer*) = 0; 00384 virtual void send_result (FieldBuffer*) = 0; 00385 public: 00386 virtual void send_event (FieldBuffer*) = 0; 00387 virtual int event_inputfd () = 0; 00388 bool has_event (); 00389 FieldBuffer* pop_event (bool blocking = false); 00390 protected: 00391 virtual FieldBuffer* fetch_event (int blockpop) = 0; 00392 public: 00393 struct EventHandler 00394 { 00395 virtual ~EventHandler () {} 00396 virtual FieldBuffer* handle_event (Plic::FieldBuffer &event_fb) = 0; 00397 }; 00398 virtual uint64_t register_event_handler (EventHandler *evh) = 0; 00399 virtual EventHandler* find_event_handler (uint64_t handler_id) = 0; 00400 virtual bool delete_event_handler (uint64_t handler_id) = 0; 00401 public: 00402 struct MethodEntry { uint64_t hashhi, hashlo; DispatchFunc dispatcher; }; 00403 struct MethodRegistry 00404 { 00405 template<class T, size_t S> MethodRegistry (T (&static_const_entries)[S]) 00406 { for (size_t i = 0; i < S; i++) register_method (static_const_entries[i]); } 00407 private: static void register_method (const MethodEntry &mentry); 00408 }; 00409 protected: 00410 static DispatchFunc find_method (uint64_t hashhi, uint64_t hashlow); 00411 }; 00412 00413 /* === inline implementations === */ 00414 inline void* 00415 SmartHandle::_void_iface () const 00416 { 00417 if (PLIC_UNLIKELY (m_rpc_id & 3)) 00418 return _cast_iface(); 00419 return (void*) m_rpc_id; 00420 } 00421 00422 inline void 00423 FieldBuffer::reset() 00424 { 00425 if (!buffermem) 00426 return; 00427 while (size() > 0) 00428 { 00429 buffermem[0].index--; // causes size()-- 00430 switch (type_at (size())) 00431 { 00432 case STRING: { FieldUnion &u = getu(); ((String*) &u)->~String(); }; break; 00433 case ANY: { FieldUnion &u = getu(); delete u.vany; }; break; 00434 case SEQUENCE: 00435 case RECORD: { FieldUnion &u = getu(); ((FieldBuffer*) &u)->~FieldBuffer(); }; break; 00436 default: ; 00437 } 00438 } 00439 } 00440 00441 } // Plic 00442 00443 #endif /* __PLIC_RUNTIME_HH__ */
1.7.4