gemini-code-assist[bot] commented on code in PR #117:
URL: https://github.com/apache/tvm-ffi/pull/117#discussion_r2429689010
##########
include/tvm/ffi/function.h:
##########
@@ -512,6 +512,40 @@ class Function : public ObjectRef {
};
return FromPackedInternal(std::move(call_packed));
}
+
+ /*
+ * \brief Directly invoke an extern C TVMFFISafeCallType function via the
ABI convention.
+ *
+ * This function can be useful to turn an existing exported symbol into a
typed function
+ *
+ * \code
+ *
+ * extern "C" __tvm_ffi_add(void* handle, const TVMFFIAny* args, int32_t
num_args, TVMFFIAny*
+ * result);
+ *
+ * // redirect an existing symbol into a typed function
+ * inline int add(int a, int b) {
+ * return tvm::ffi::Function::InvokeExternC(nullptr, __tvm_ffi_add, a,
b).cast<int>();
+ * }
+ *
+ * \endcode
+ *
+ * \param handle The handle argument, for exported symbols this is usually
nullptr.
+ * \param safe_call The safe_call definition in C.
+ * \return The return value.
+ */
Review Comment:

The documentation for `InvokeExternC` can be improved for clarity and
correctness.
1. The `\brief` description can be rephrased to be more accessible.
2. The example function signature is missing its `int` return type and is
formatted awkwardly across two lines. `TVMFFISafeCallType` functions must
return an `int`.
3. The descriptions for the `safe_call` parameter and the return value are a
bit vague and could be more specific.
4. The variadic template arguments `Args...` and `args` are not documented.
```c
/*
* \brief Directly invoke an extern "C" function that follows the TVM FFI
SafeCall convention.
*
* This function can be useful to turn an existing exported symbol into a
typed function.
*
* \code
*
* // An extern "C" function, matching TVMFFISafeCallType
* extern "C" int __tvm_ffi_add(void* handle, const TVMFFIAny* args,
int32_t num_args, TVMFFIAny* result);
*
* // redirect an existing symbol into a typed function
* inline int add(int a, int b) {
* return tvm::ffi::Function::InvokeExternC(nullptr, __tvm_ffi_add, a,
b).cast<int>();
* }
*
* \endcode
*
* \tparam Args The types of the arguments to the extern function.
* \param handle The handle argument, for exported symbols this is usually
nullptr.
* \param safe_call The function pointer to the extern "C" function.
* \param args The arguments to pass to the function.
* \return The return value, wrapped in a tvm::ffi::Any.
*/
```
--
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]