From 1ead2f659268db4e2772d2aff695b15a63c332f9 Mon Sep 17 00:00:00 2001 From: CHatingPython Date: Sun, 21 Jun 2026 19:45:59 +0200 Subject: [PATCH] docs(furvm): document the function Refs: #12 --- furvm/include/furvm/function.hpp | 33 +++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/furvm/include/furvm/function.hpp b/furvm/include/furvm/function.hpp index 4a729be..89ebd01 100644 --- a/furvm/include/furvm/function.hpp +++ b/furvm/include/furvm/function.hpp @@ -16,8 +16,14 @@ enum class function_t : std::uint8_t { Import, /**< A function imported from another module. */ }; +/** + * @brief A native function. + */ using native_function = std::function; +/** + * @brief A function import. + */ struct import_function { mod_id mod; function_id function; @@ -25,18 +31,39 @@ struct import_function { class function { public: + /** + * @brief Constructs a normal function. + * + * @param name Name of the function. + * @param position Offset in bytecode of the function. + */ template function(Name&& name, bytecode_pos position) : m_name(std::forward(name)), m_type(function_t::Normal), m_value(position) {} + /** + * @brief Constructs a native function. + * + * @param name Name of the function. + * @param native Native function. + */ template function(Name&& name, const native_function& native) : m_name(std::forward(name)), m_type(function_t::Native), m_value(native) {} + /** + * @brief Constructs an import function. + * + * @param name Name of the function. + * @param imp Import function. + */ template function(Name&& name, const import_function& imp) : m_name(std::forward(name)), m_type(function_t::Import), m_value(imp) {} + /** + * @brief Destructs a function. + */ ~function(); /** @@ -74,7 +101,7 @@ public: constexpr function_t type() const { return m_type; } public: /** - * @brief Returns a value for normal function. + * @brief Returns normal function's value. * * @return The value. */ @@ -84,7 +111,7 @@ public: } /** - * @brief Returns a value for native function. + * @brief Returns native function's value. * * @return The value. */ @@ -94,7 +121,7 @@ public: } /** - * @brief Returns a name of the function's module. + * @brief Returns import function's value. * * @return The name. */