Template Class ObjectDef#

Inheritance Relationships#

Base Type#

  • public ReflectionDefBase

Class Documentation#

template<typename Class>
class ObjectDef : public ReflectionDefBase#

Helper to register Object’s reflection metadata.

namespace refl = tvm::ffi::reflection;
refl::ObjectDef<MyClass>().def_ro("my_field", &MyClass::my_field);

Template Parameters:

Class – The class type.

Public Functions

template<typename ...ExtraArgs>
inline explicit ObjectDef(ExtraArgs&&... extra_args)#

Constructor.

Template Parameters:

ExtraArgs – The extra arguments.

Parameters:

extra_args – The extra arguments.

template<typename T, typename BaseClass, typename ...Extra>
inline ObjectDef &def_ro(const char *name, T BaseClass::* field_ptr, Extra&&... extra)#

Define a readonly field.

Template Parameters:
  • Class – The class type.

  • T – The field type.

  • Extra – The extra arguments.

Parameters:
  • name – The name of the field.

  • field_ptr – The pointer to the field.

  • extra – The extra arguments that can be docstring or default value.

Returns:

The reflection definition.

template<typename T, typename BaseClass, typename ...Extra>
inline ObjectDef &def_rw(const char *name, T BaseClass::* field_ptr, Extra&&... extra)#

Define a read-write field.

Template Parameters:
  • Class – The class type.

  • T – The field type.

  • Extra – The extra arguments.

Parameters:
  • name – The name of the field.

  • field_ptr – The pointer to the field.

  • extra – The extra arguments that can be docstring or default value.

Returns:

The reflection definition.

template<typename Func, typename ...Extra>
inline ObjectDef &def(const char *name, Func &&func, Extra&&... extra)#

Define a method.

Template Parameters:
  • Func – The function type.

  • Extra – The extra arguments.

Parameters:
  • name – The name of the method.

  • func – The function to be registered.

  • extra – The extra arguments that can be docstring.

Returns:

The reflection definition.

template<typename Func, typename ...Extra>
inline ObjectDef &def_static(const char *name, Func &&func, Extra&&... extra)#

Define a static method.

Template Parameters:
  • Func – The function type.

  • Extra – The extra arguments.

Parameters:
  • name – The name of the method.

  • func – The function to be registered.

  • extra – The extra arguments that can be docstring.

Returns:

The reflection definition.