//
// Generated by Brutal.Jolt.Generate; do not edit by hand.
#nullable enable
using System.Runtime.CompilerServices;
using Brutal.Interop;
using Brutal.Numerics;
namespace Brutal.JoltApi
{
///
///
/// Light weight runtime type information system. This way we don't need to turn on the default RTTI system of
/// the compiler (introducing a possible overhead for every class)
///
///
/// C++:
/// Jolt/Core/RTTI.h:121
///
/// class RTTI
///
///
///
///
/// Light weight runtime type information system. This way we don't need to turn
/// on the default RTTI system of the compiler (introducing a possible overhead for every
/// class)
///
/// Notes:
/// - An extra virtual member function is added. This adds 8 bytes to the size of
/// an instance of the class (unless you are already using virtual functions).
///
/// To use RTTI on a specific class use:
///
/// Header file:
///
/// class Foo
/// {
/// JPH_DECLARE_RTTI_VIRTUAL_BASE(Foo)
/// }
///
/// class Bar : public Foo
/// {
/// JPH_DECLARE_RTTI_VIRTUAL(Bar)
/// };
///
/// Implementation file:
///
/// JPH_IMPLEMENT_RTTI_VIRTUAL_BASE(Foo)
/// {
/// }
///
/// JPH_IMPLEMENT_RTTI_VIRTUAL(Bar)
/// {
/// JPH_ADD_BASE_CLASS(Bar, Foo) // Multiple inheritance is allowed, just do JPH_ADD_BASE_CLASS for every base class
/// }
///
/// For abstract classes use:
///
/// Header file:
///
/// class Foo
/// {
/// JPH_DECLARE_RTTI_ABSTRACT_BASE(Foo)
///
/// public:
/// virtual void AbstractFunction() = 0;
/// }
///
/// class Bar : public Foo
/// {
/// JPH_DECLARE_RTTI_VIRTUAL(Bar)
///
/// public:
/// virtual void AbstractFunction() { } // Function is now implemented so this class is no longer abstract
/// };
///
/// Implementation file:
///
/// JPH_IMPLEMENT_RTTI_ABSTRACT_BASE(Foo)
/// {
/// }
///
/// JPH_IMPLEMENT_RTTI_VIRTUAL(Bar)
/// {
/// JPH_ADD_BASE_CLASS(Bar, Foo)
/// }
///
/// Example of usage in a program:
///
/// Foo *foo_ptr = new Foo;
/// Foo *bar_ptr = new Bar;
///
/// IsType(foo_ptr, RTTI(Bar)) returns false
/// IsType(bar_ptr, RTTI(Bar)) returns true
///
/// IsKindOf(foo_ptr, RTTI(Bar)) returns false
/// IsKindOf(bar_ptr, RTTI(Foo)) returns true
/// IsKindOf(bar_ptr, RTTI(Bar)) returns true
///
/// StaticCast<Bar>(foo_ptr) asserts and returns foo_ptr casted to Bar *
/// StaticCast<Bar>(bar_ptr) returns bar_ptr casted to Bar *
///
/// DynamicCast<Bar>(foo_ptr) returns nullptr
/// DynamicCast<Bar>(bar_ptr) returns bar_ptr casted to Bar *
///
/// Other feature of DynamicCast:
///
/// class A { int data[5]; };
/// class B { int data[7]; };
/// class C : public A, public B { int data[9]; };
///
/// C *c = new C;
/// A *a = c;
///
/// Note that:
///
/// B *b = (B *)a;
///
/// generates an invalid pointer,
///
/// B *b = StaticCast<B>(a);
///
/// doesn't compile, and
///
/// B *b = DynamicCast<B>(a);
///
/// does the correct cast
///
///
[InteropHandle]
public readonly partial struct RTTI
{
///
///
/// Base class information
///
///
/// C++:
/// Jolt/Core/RTTI.h:174
///
/// struct BaseClass
///
///
[StructLayout(LayoutKind.Explicit, Size = 16)]
public partial struct BaseClass
{
///
///
/// C++:
/// Jolt/Core/RTTI.h:176
///
/// const RTTI * mRTTI
///
///
[FieldOffset(0)]
public RTTI RTTI;
///
///
/// C++:
/// Jolt/Core/RTTI.h:177
///
/// int mOffset
///
///
[FieldOffset(8)]
public int Offset;
}
///
///
/// Properties
///
///
/// C++:
/// Jolt/Core/RTTI.h:138
///
/// inline const char * GetName() const
///
///
public unsafe RefString8 GetName() => (Ptr)Jolt.PInvoke.RTTI_GetName(this);
///
///
/// C++:
/// Jolt/Core/RTTI.h:140
///
/// inline int GetSize() const
///
///
public int GetSize() => Jolt.PInvoke.RTTI_GetSize(this);
///
///
/// C++:
/// Jolt/Core/RTTI.h:141
///
/// bool IsAbstract() const
///
///
public bool IsAbstract() => Jolt.PInvoke.RTTI_IsAbstract(this);
///
///
/// C++:
/// Jolt/Core/RTTI.h:142
///
/// int GetBaseClassCount() const
///
///
public int GetBaseClassCount() => Jolt.PInvoke.RTTI_GetBaseClassCount(this);
///
///
/// C++:
/// Jolt/Core/RTTI.h:143
///
/// const RTTI * GetBaseClass(int inIdx) const
///
///
///
///
/// The returned handle is borrowed from its owner; don't Dispose it.
///
///
public RTTI GetBaseClass(int idx)
{
var _result = Jolt.PInvoke.RTTI_GetBaseClass(this, idx, out var _inRange);
if (_inRange == 0)
throw new ArgumentOutOfRangeException(
nameof(idx),
idx,
"Expected an index below the number of base classes."
);
return _result;
}
///
///
/// C++:
/// Jolt/Core/RTTI.h:144
///
/// uint32 GetHash() const
///
///
public uint GetHash() => Jolt.PInvoke.RTTI_GetHash(this);
///
///
/// Create an object of this type (returns nullptr if the object is abstract)
///
///
/// C++:
/// Jolt/Core/RTTI.h:147
///
/// void * CreateObject() const
///
///
public unsafe Ptr CreateObject() => Jolt.PInvoke.RTTI_CreateObject(this);
///
///
/// Destruct object of this type (does nothing if the object is abstract)
///
///
/// C++:
/// Jolt/Core/RTTI.h:150
///
/// void DestructObject(void *inObject) const
///
///
public unsafe void DestructObject(Ptr @object) => Jolt.PInvoke.RTTI_DestructObject(this, @object);
///
///
/// Add base class
///
///
/// C++:
/// Jolt/Core/RTTI.h:153
///
/// void AddBaseClass(const RTTI *inRTTI, int inOffset)
///
///
public void AddBaseClass(RTTI rtti, int offset) => Jolt.PInvoke.RTTI_AddBaseClass(this, rtti, offset);
///
///
/// Test if this class is derived from class of type inRTTI
///
///
/// C++:
/// Jolt/Core/RTTI.h:160
///
/// bool IsKindOf(const RTTI *inRTTI) const
///
///
public bool IsKindOf(RTTI rtti) => Jolt.PInvoke.RTTI_IsKindOf(this, rtti);
///
///
/// Cast inObject of this type to object of type inRTTI, returns nullptr if the cast is unsuccessful
///
///
/// C++:
/// Jolt/Core/RTTI.h:163
///
/// const void * CastTo(const void *inObject, const RTTI *inRTTI) const
///
///
public unsafe Ptr CastTo(Ptr @object, RTTI rtti) => Jolt.PInvoke.RTTI_CastTo(this, @object, rtti);
}
}