tqchen commented on code in PR #32:
URL: https://github.com/apache/tvm-ffi/pull/32#discussion_r2364648313


##########
include/tvm/ffi/reflection/registry.h:
##########
@@ -558,6 +558,34 @@ inline void EnsureTypeAttrColumn(std::string_view name) {
                                                  reinterpret_cast<const 
TVMFFIAny*>(&any_view)));
 }
 
+/*!
+ * \brief Invokes the constructor of a particular object type and returns an 
`ObjectRef`.
+ * \tparam T The object type to be constructed.
+ * \tparam Args The argument types.
+ * \param args The arguments to be passed to the constructor.
+ * \return The constructed object wrapped in an `ObjectRef`.
+ * \note This is usually used in FFI reflection boundary to register 
`__init__` methods.
+ *
+ * Example
+ *
+ * \code
+ *
+ *   class ExampleObject : public Object {
+ *    public:
+ *      int64_t v_i64;
+ *      int32_t v_i32;
+ *
+ *      ExampleObject(int64_t v_i64, int32_t v_i32) : v_i64(v_i64), 
v_i32(v_i32) {}
+ *      TVM_FFI_DECLARE_OBJECT_INFO("example.ExampleObject", ExampleObject, 
Object);
+ *   };
+ *   refl::ObjectDef<ExampleObject>()
+ *      .def_static("__init__", refl::InitOf<ExampleObject, int64_t, int32_t>);
+ */
+template <typename T, typename... Args>
+inline ObjectRef InitOf(Args&&... args) {

Review Comment:
   to align with pybind, let us do `refl::init<FunctionName>`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to