Represents information about a $interface declaration in the Xc++ language.
$struct+ ReflectedInterface
{
$ConstStringZ GetName() const { return m_name; }
$ssize_t GetNumBaseInterfaces() const { return m_numBaseInterfaces; }
$ConstStringZ GetBaseInterfaceName(ssize_t i) const { return m_baseInterfaces[i]; }
$ssize_t GetNumBaseMethods() const { return m_numBaseMethods; }
$ssize_t GetNumMethods() const { return m_numMethods; }
$const ReflectedInterfaceMethod& GetMethod(ssize_t i) const { return m_methods[i]; }
$ssize_t GetNumAttributes() const { return m_numAttributes; }
$const ReflectedAttribute& GetAttribute(ssize_t i) const { return m_attributes[i]; }
//////////////// State //////////////////
ConstStringZ m_name;
const octet_t* m_metaData;
ConstStringZ const* m_baseInterfaces;
ssize_t m_numBaseInterfaces;
ssize_t m_numBaseMethods;
const ReflectedInterfaceMethod* m_methods;
ssize_t m_numMethods;
const ReflectedAttribute* m_attributes;
ssize_t m_numAttributes;
ConstStringZ const* m_stringTable;
};
@api bool InterfaceSubTypesIObject(const ReflectedInterface& ri);
@api void GetInterfaces(const ReflectedClass& rc, xvector<const ReflectedInterface*> v);
@api void GetStrictSubInterfaces(const ReflectedInterface& ri, xvector<const ReflectedInterface*> v);
ConstStringZ m_name
The fully qualified name of the interface represented as a pointer to a UTF-8 encoded null-terminated string (see ConstStringZ).
const octet_t* m_metaData
Pointer to metadata byte code on the interface or null if no metadata declared.
ConstStringZ const* m_baseInterfaces
The address of an array of pointers to UTF-8 encoded null-terminated strings (see ConstStringZ), which are the fully qualified names of the declared base interfaces.
ssize_t m_numBaseInterfaces
The number of elements in the m_baseInterfaces array.
ssize_t m_numBaseMethods
The offset into the FnTable due to the base interfaces.
const ReflectedInterfaceMethod* m_methods
Pointer to an array of ReflectedInterfaceMethod elements. These correspond to the declared methods in the interface (not including inherited methods from any base interfaces).
ssize_t m_numMethods
The number of elements in the m_methods array.
const ReflectedAttribute* m_attributes
Pointer to an array of ReflectedAttribute elements. These correspond to the declared attributes in the interface (not including inherited attributes from any base interfaces).
ssize_t m_numAttributes
The number of elements in the m_attributes array.
ConstStringZ const* m_stringTable
The address of an array of pointers to UTF-8 encoded null-terminated strings (see ConstStringZ), which is the string table associated with the byte code used to represent the types in the method signatures and the attributes. May be null if no string table is required.
The following interface definitions
namespace ns
{
$interface+ Iw : ceda::IObject
{
void f1();
};
$interface+ Ix : ceda::IObject
{
void f2();
};
$interface+ Iy : Iw, Ix
{
void f3();
const int32* const f4(int32 x, float64 y) const;
};
}
cause the following code to be generated to implement interface Iy:
namespace ns
{
struct Iy
{
struct FnTable
{
ns::Iw::FnTable _Iw;
ns::Ix::FnTable _Ix;
void (__stdcall *f3)(void* _self);
ceda::int32 const* const (__stdcall *f4)(void const* _self,ceda::int32 x,ceda::float64 y);
};
Iy(void* _self, const FnTable* table) : m_self(_self), m_table(table) {}
void AssignFrom(Iy& _rhs) { m_self = _rhs.m_self; m_table = _rhs.m_table; }
void AssignFrom(Iy const& _rhs) const { const_cast<Iy*>(this)->m_self = _rhs.m_self; const_cast<Iy*>(this)->m_table = _rhs.m_table; }
template<typename T> struct Stubs
{
static void __stdcall f3(void* _self) { ((T*)_self)->f3(); }
static ceda::int32 const* const __stdcall f4(void const* _self,ceda::int32 x,ceda::float64 y) { return ((const T*)_self)->f4(x,y); }
static const FnTable& GetTable()
{
static const FnTable t =
{
{
{
&ceda::IObject::Stubs<T>::QueryInterface,
&ceda::IObject::Stubs<T>::BindInterface,
&ceda::IObject::Stubs<T>::GetReflectedClass,
&ceda::IObject::Stubs<T>::VisitObjects,
&ceda::IObject::Stubs<T>::OnGarbageCollect,
&ceda::IObject::Stubs<T>::Destroy,
&ceda::IObject::Stubs<T>::GetSysState,
},
&ns::Iw::Stubs<T>::f1,
},
{
{
&ceda::IObject::Stubs<T>::QueryInterface,
&ceda::IObject::Stubs<T>::BindInterface,
&ceda::IObject::Stubs<T>::GetReflectedClass,
&ceda::IObject::Stubs<T>::VisitObjects,
&ceda::IObject::Stubs<T>::OnGarbageCollect,
&ceda::IObject::Stubs<T>::Destroy,
&ceda::IObject::Stubs<T>::GetSysState,
},
&ns::Ix::Stubs<T>::f2,
},
&f3,
&f4
};
return t;
}
};
template<typename T> void CoerceFrom(T* _rhs) { m_self = _rhs; m_table = &Stubs<T>::GetTable(); }
template<typename T> void CoerceFrom(const T* _rhs) const { const_cast<Iy*>(this)->m_self = const_cast<T*>(_rhs); const_cast<Iy*>(this)->m_table = &Stubs<T>::GetTable(); }
ceda::AnyInterface QueryInterface(ceda::ReflectedInterface const& ri) { return m_table->_Iw._IObject.QueryInterface(m_self,ri); }
ceda::AnyInterface BindInterface(ceda::ReflectedInterface const& ri) { return m_table->_Iw._IObject.BindInterface(m_self,ri); }
ceda::ReflectedClass const* GetReflectedClass() const { return m_table->_Iw._IObject.GetReflectedClass(m_self); }
void VisitObjects(ceda::IObjectVisitor& v) const { m_table->_Iw._IObject.VisitObjects(m_self,v); }
void OnGarbageCollect() { m_table->_Iw._IObject.OnGarbageCollect(m_self); }
void Destroy() { m_table->_Iw._IObject.Destroy(m_self); }
ceda::ObjSysState& GetSysState() { return m_table->_Iw._IObject.GetSysState(m_self); }
void f1() { m_table->_Iw.f1(m_self); }
void f2() { m_table->_Ix.f2(m_self); }
void f3() { m_table->f3(m_self); }
ceda::int32 const* const f4(ceda::int32 x,ceda::float64 y) const { return m_table->f4(m_self,x,y); }
operator ceda::IObject() const { return ceda::IObject(m_self, &m_table->_Iw._IObject); }
operator ns::Iw() const { return ns::Iw(m_self, &m_table->_Iw); }
operator ns::Ix() const { return ns::Ix(m_self, &m_table->_Ix); }
union
{
void* m_self;
};
FnTable const* m_table;
};
template <typename BC>
struct IyDelegatorMixin : public BC
{
void f3() { BC::GetIy().f3(); }
ceda::int32 const* const f4(ceda::int32 x,ceda::float64 y) const { return BC::GetIy().f4(x,y); }
};
ceda::ReflectedInterface const& _GetReflected(Iy const*);
} //ns
namespace ceda
{
template<> struct TypeTraits<ns::Iy>
{
static const bool is_exported = 1;
static const bool is_reflected = 1;
static const bool is_registered = 1;
static const ceda::ETypeTraitKind kind = ceda::TTK_interface;
static const bool has_metadata = 0;
};
template<> struct InterfaceTypeTraits<ns::Iy>
{
static const bool is_ipc = 0;
static const bool is_rmi = 0;
};
template<> struct _is_direct_superinterface_of<ns::Iw,ns::Iy> { static const bool value = true; };
template<> struct _is_direct_superinterface_of<ns::Ix,ns::Iy> { static const bool value = true; };
template<> struct _is_indirect_superinterface_of<ceda::IObject,ns::Iy> { static const bool value = true; };
} // namespace ceda
and the following code to be generated to register interface Iy:
//### $interface+ ns::Iy
namespace ceda { XTarget* Ceda_Core_Object_exObject_GetXTarget(); }
namespace ns
{
ceda::ReflectedInterface const& _GetReflected(Iy const*)
{
static ceda::ConstStringZ Iy_bases[] =
{
"ns::Iw",
"ns::Ix",
};
static const ceda::octet_t Iy_f4_return[] =
{
0x31,0x35,0x31,0x04
};
static const ceda::octet_t Iy_f4_x[] =
{
0x04
};
static const ceda::octet_t Iy_f4_y[] =
{
0x0d
};
static const ceda::ReflectedArg Iy_f4_args[] =
{
{ "x", Iy_f4_x },
{ "y", Iy_f4_y },
};
static const ceda::ReflectedInterfaceMethod Iy_methods[] =
{
{"f3",{0},0,0,0},
{"f4",{Iy_f4_return},Iy_f4_args,2,0},
};
static const ceda::ReflectedInterface Iy_interface =
{
"ns::Iy",
0,
Iy_bases,2,
16,
Iy_methods,2,
0,0,
0
};
return Iy_interface;
}
// Registration of $interface+ ns::Iy
void _Register_Iy()
{
cxVerify(ceda::RegisterReflectedInterface(&_GetReflected( (Iy*) 0),ceda::Ceda_Core_Object_exObject_GetXTarget()) == ceda::NSE_OK);
}
} // ns