Kathryn-cat commented on code in PR #230:
URL: https://github.com/apache/tvm-ffi/pull/230#discussion_r2543260627


##########
include/tvm/ffi/function.h:
##########
@@ -881,22 +932,66 @@ inline int32_t TypeKeyToIndex(std::string_view type_key) {
  * });
  * \endcode
  *
- * \note The final symbol name is `__tvm_ffi_<ExportName>`.
+ * \note The final symbol names are:
+ *       - `__tvm_ffi_<ExportName>` (function)
+ *       - `__tvm_ffi__metadata_<ExportName>` (metadata - only when
+ * TVM_FFI_DLL_EXPORT_INCLUDE_METADATA is defined)
  */
-#define TVM_FFI_DLL_EXPORT_TYPED_FUNC(ExportName, Function)                    
        \
-  extern "C" {                                                                 
        \
-  TVM_FFI_DLL_EXPORT int __tvm_ffi_##ExportName(void* self, const TVMFFIAny* 
args,     \
-                                                int32_t num_args, TVMFFIAny* 
result) { \
-    TVM_FFI_SAFE_CALL_BEGIN();                                                 
        \
-    using FuncInfo = ::tvm::ffi::details::FunctionInfo<decltype(Function)>;    
        \
-    static std::string name = #ExportName;                                     
        \
-    ::tvm::ffi::details::unpack_call<typename FuncInfo::RetType>(              
        \
-        std::make_index_sequence<FuncInfo::num_args>{}, &name, Function,       
        \
-        reinterpret_cast<const ::tvm::ffi::AnyView*>(args), num_args,          
        \
-        reinterpret_cast<::tvm::ffi::Any*>(result));                           
        \
-    TVM_FFI_SAFE_CALL_END();                                                   
        \
-  }                                                                            
        \
-  }
+#define TVM_FFI_DLL_EXPORT_TYPED_FUNC(ExportName, Function) \
+  TVM_FFI_DLL_EXPORT_TYPED_FUNC_IMPL_(ExportName, Function) \
+  TVM_FFI_DLL_EXPORT_TYPED_FUNC_METADATA_IMPL_(ExportName, Function)
+
+/*!
+ * \brief Export typed function with documentation as SafeCallType symbols.
+ *
+ * This is an extended version of TVM_FFI_DLL_EXPORT_TYPED_FUNC that also 
exports
+ * a documentation string. The docstring can be used by stub generators and
+ * documentation tools.
+ *
+ * \param ExportName The symbol name to be exported.
+ * \param Function The typed function.
+ * \param DocString The documentation string (C string literal).
+ *
+ * \sa ffi::TypedFunction, TVM_FFI_DLL_EXPORT_TYPED_FUNC
+ *
+ * \code
+ *
+ * int Add(int a, int b) {
+ *   return a + b;
+ * }
+ *
+ * TVM_FFI_DLL_EXPORT_TYPED_FUNC_WITH_DOC(
+ *     add,

Review Comment:
   resolved



-- 
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