@@ -127,7 +127,7 @@ class FunctionObjImpl : public FunctionObj {
127127 /* ! \brief The type of derived object class */
128128 using TSelf = FunctionObjImpl<TCallable>;
129129 /* !
130- * \brief Derived object class for constructing PackedFuncObj .
130+ * \brief Derived object class for constructing ffi::FunctionObj .
131131 * \param callable The type-erased callable object.
132132 */
133133 explicit FunctionObjImpl (TCallable callable) : callable_(callable) {
@@ -292,15 +292,15 @@ class PackedArgs {
292292
293293/* !
294294 * \brief ffi::Function is a type-erased function.
295- * The arguments are passed by packed format.
295+ * The arguments are passed by " packed format" via AnyView
296296 */
297297class Function : public ObjectRef {
298298 public:
299299 /* ! \brief Constructor from null */
300300 Function (std::nullptr_t ) : ObjectRef(nullptr ) {} // NOLINT(*)
301301 /* !
302302 * \brief Constructing a packed function from a callable type
303- * whose signature is consistent with `PackedFunc `
303+ * whose signature is consistent with `ffi::Function `
304304 * \param packed_call The packed function signature
305305 * \note legacy purpose, should change to Function::FromPacked for mostfuture use.
306306 */
@@ -310,7 +310,7 @@ class Function : public ObjectRef {
310310 }
311311 /* !
312312 * \brief Constructing a packed function from a callable type
313- * whose signature is consistent with `PackedFunc `
313+ * whose signature is consistent with `ffi::Function `
314314 * \param packed_call The packed function signature
315315 */
316316 template <typename TCallable>
@@ -462,7 +462,7 @@ class Function : public ObjectRef {
462462 * \param callable the internal container of packed function.
463463 */
464464 template <typename TCallable>
465- static Function FromUnpacked (TCallable callable) {
465+ static Function FromTyped (TCallable callable) {
466466 using FuncInfo = details::FunctionInfo<TCallable>;
467467 auto call_packed = [callable](const AnyView* args, int32_t num_args, Any* rv) mutable -> void {
468468 details::unpack_call<typename FuncInfo::RetType>(
@@ -477,7 +477,7 @@ class Function : public ObjectRef {
477477 * \param name optional name attacked to the function.
478478 */
479479 template <typename TCallable>
480- static Function FromUnpacked (TCallable callable, std::string name) {
480+ static Function FromTyped (TCallable callable, std::string name) {
481481 using FuncInfo = details::FunctionInfo<TCallable>;
482482 auto call_packed = [callable, name](const AnyView* args, int32_t num_args,
483483 Any* rv) mutable -> void {
@@ -540,7 +540,7 @@ class Function : public ObjectRef {
540540 private:
541541 /* !
542542 * \brief Constructing a packed function from a callable type
543- * whose signature is consistent with `PackedFunc `
543+ * whose signature is consistent with `ffi::Function `
544544 * \param packed_call The packed function signature
545545 */
546546 template <typename TCallable>
@@ -560,16 +560,16 @@ class TypedFunction;
560560
561561/* !
562562 * \anchor TypedFunctionAnchor
563- * \brief A PackedFunc wrapper to provide typed function signature.
564- * It is backed by a PackedFunc internally.
563+ * \brief A ffi::Function wrapper to provide typed function signature.
564+ * It is backed by a ffi::Function internally.
565565 *
566566 * TypedFunction enables compile time type checking.
567567 * TypedFunction works with the runtime system:
568- * - It can be passed as an argument of PackedFunc .
569- * - It can be assigned to TVMRetValue .
570- * - It can be directly converted to a type-erased PackedFunc .
568+ * - It can be passed as an argument of ffi::Function .
569+ * - It can be assigned to ffi::Any .
570+ * - It can be directly converted to a type-erased ffi::Function .
571571 *
572- * Developers should prefer TypedFunction over PackedFunc in C++ code
572+ * Developers should prefer TypedFunction over ffi::Function in C++ code
573573 * as it enables compile time checking.
574574 * We can construct a TypedFunction from a lambda function
575575 * with the same signature.
@@ -584,8 +584,8 @@ class TypedFunction;
584584 * TypedFunction<int(int)> ftyped(addone);
585585 * // invoke the function.
586586 * int y = ftyped(1);
587- * // Can be directly converted to PackedFunc
588- * PackedFunc packed = ftype;
587+ * // Can be directly converted to ffi::Function
588+ * ffi::Function packed = ftype;
589589 * \endcode
590590 * \tparam R The return value of the function.
591591 * \tparam Args The argument signature of the function.
@@ -623,7 +623,7 @@ class TypedFunction<R(Args...)> {
623623 template <typename FLambda, typename = typename std::enable_if<std::is_convertible<
624624 FLambda, std::function<R(Args...)>>::value>::type>
625625 TypedFunction (FLambda typed_lambda, std::string name) { // NOLINT(*)
626- packed_ = Function::FromUnpacked (typed_lambda, name);
626+ packed_ = Function::FromTyped (typed_lambda, name);
627627 }
628628 /* !
629629 * \brief construct from a lambda function with the same signature.
@@ -646,7 +646,7 @@ class TypedFunction<R(Args...)> {
646646 template <typename FLambda, typename = typename std::enable_if<std::is_convertible<
647647 FLambda, std::function<R(Args...)>>::value>::type>
648648 TypedFunction (const FLambda& typed_lambda) { // NOLINT(*)
649- packed_ = Function::FromUnpacked (typed_lambda);
649+ packed_ = Function::FromTyped (typed_lambda);
650650 }
651651 /* !
652652 * \brief copy assignment operator from typed lambda
@@ -668,11 +668,11 @@ class TypedFunction<R(Args...)> {
668668 std::is_convertible<FLambda,
669669 std::function<R(Args...)>>::value>::type>
670670 TSelf& operator =(FLambda typed_lambda) { // NOLINT(*)
671- packed_ = Function::FromUnpacked (typed_lambda);
671+ packed_ = Function::FromTyped (typed_lambda);
672672 return *this ;
673673 }
674674 /* !
675- * \brief copy assignment operator from PackedFunc .
675+ * \brief copy assignment operator from ffi::Function .
676676 * \param packed The packed function.
677677 * \returns reference to self.
678678 */
@@ -698,16 +698,16 @@ class TypedFunction<R(Args...)> {
698698 }
699699 }
700700 /* !
701- * \brief convert to PackedFunc
702- * \return the internal PackedFunc
701+ * \brief convert to ffi::Function
702+ * \return the internal ffi::Function
703703 */
704704 operator Function () const { return packed (); }
705705 /* !
706- * \return reference the internal PackedFunc
706+ * \return reference the internal ffi::Function
707707 */
708708 const Function& packed () const & { return packed_; }
709709 /* !
710- * \return r-value reference the internal PackedFunc
710+ * \return r-value reference the internal ffi::Function
711711 */
712712 constexpr Function&& packed() && { return std::move (packed_); }
713713 /* ! \return Whether the packed function is nullptr */
@@ -797,7 +797,7 @@ class Function::Registry {
797797 */
798798 template <typename FLambda>
799799 Registry& set_body_typed (FLambda f) {
800- return Register (Function::FromUnpacked (f, name_));
800+ return Register (Function::FromTyped (f, name_));
801801 }
802802
803803 /* !
@@ -838,14 +838,14 @@ class Function::Registry {
838838 // call method pointer
839839 return (target.*f)(params...);
840840 };
841- return Register (ffi::Function::FromUnpacked (fwrap, name_));
841+ return Register (ffi::Function::FromTyped (fwrap, name_));
842842 }
843843 if constexpr (std::is_base_of_v<Object, T>) {
844844 auto fwrap = [f](const T* target, Args... params) -> R {
845845 // call method pointer
846846 return (const_cast <T*>(target)->*f)(params...);
847847 };
848- return Register (ffi::Function::FromUnpacked (fwrap, name_));
848+ return Register (ffi::Function::FromTyped (fwrap, name_));
849849 }
850850 return *this ;
851851 }
@@ -859,14 +859,14 @@ class Function::Registry {
859859 // call method pointer
860860 return (target.*f)(params...);
861861 };
862- return Register (ffi::Function::FromUnpacked (fwrap, name_));
862+ return Register (ffi::Function::FromTyped (fwrap, name_));
863863 }
864864 if constexpr (std::is_base_of_v<Object, T>) {
865865 auto fwrap = [f](const T* target, Args... params) -> R {
866866 // call method pointer
867867 return (target->*f)(params...);
868868 };
869- return Register (ffi::Function::FromUnpacked (fwrap, name_));
869+ return Register (ffi::Function::FromTyped (fwrap, name_));
870870 }
871871 return *this ;
872872 }
0 commit comments