changeset 76:1ae2b63e9d65

general: Improve documentation
author Lewin Bormann <lbo@spheniscida.de>
date Sun, 25 Aug 2019 21:44:17 +0200
parents a7569b66b12a
children cc86e400869c
files src/base/str.h src/base/vec.h src/func.h src/types.h src/value.h
diffstat 5 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/base/str.h	Sun Aug 25 18:46:25 2019 +0200
+++ b/src/base/str.h	Sun Aug 25 21:44:17 2019 +0200
@@ -15,6 +15,7 @@
 static const size_t YSTR_SMALL_THRESHOLD = sizeof(yvec_t) - 2;
 
 typedef struct {
+    /// The string value.
     union {
         /// A string in an array, also NULL-terminated for easy conversion to C
         /// strings.
--- a/src/base/vec.h	Sun Aug 25 18:46:25 2019 +0200
+++ b/src/base/vec.h	Sun Aug 25 21:44:17 2019 +0200
@@ -19,7 +19,7 @@
  * into 16 bytes.
  */
 typedef struct {
-    /// Start of field.
+    /// Start of vector.
     void *base;
     /// Total capacity.
     size_t cap : 24;
--- a/src/func.h	Sun Aug 25 18:46:25 2019 +0200
+++ b/src/func.h	Sun Aug 25 21:44:17 2019 +0200
@@ -17,11 +17,15 @@
  * @brief Compiled function code. Functions are usually inserted in the global
  * value table and referenced there.
  *
- * TODO: Extend to allow reference capture for closures.
+ * TODO: Extend to allow reference capture for closures?
  */
 typedef struct {
+    /// Name of a function.
     ystr_t name;
+    /// How many arguments it expects.
     size_t nargs;
+    /// Expressions making up the function. Often a list; the value of the last
+    //expression is the value of the invoked function.
     yexpr_t body;
 } yfunc_t;
 
--- a/src/types.h	Sun Aug 25 18:46:25 2019 +0200
+++ b/src/types.h	Sun Aug 25 21:44:17 2019 +0200
@@ -32,8 +32,11 @@
  * pointer).
  */
 typedef struct {
+    /// The reference.
     union {
+        /// A symbol, i.e. name, of a variable or function.
         ystr_t sym;
+        /// An ID pointing to a slot in the values table (see value.c)
         yvalue_id_t id;
     } ref;
 } yref_t;
@@ -92,6 +95,7 @@
  * of values.
  */
 struct yexpr_t {
+    /// The value of the expression.
     union {
         /// A number.
         long long n;
@@ -106,6 +110,7 @@
         /// A builtin such as `for`, `let`, ...
         YBUILTIN_TYPE builtin;
     } value;
+    /// Type of this expression.
     YEXPR_TYPE typ;
 };
 
--- a/src/value.h	Sun Aug 25 18:46:25 2019 +0200
+++ b/src/value.h	Sun Aug 25 21:44:17 2019 +0200
@@ -28,6 +28,7 @@
 /// Use YVALUE_INSERT in `yvalue_set()` to insert a new value.
 const yref_t YVALUE_INSERT;
 
+/// Type of a `yvalue_t` value.
 enum YVALUE_TYPE {
     YVALUE_UNDEF = 0,
     YVALUE_FUNC = 1,
@@ -90,9 +91,13 @@
  */
 typedef struct {
     union {
+        /// A function to be called. Functions are immutable, they can not be
+        //updated once set.
         yfunc_t func;
+        /// An expression (often a scalar number/string/atom)
         yexpr_t expr;
     } value;
+    /// Type of a value.
     enum YVALUE_TYPE typ;
 } yvalue_t;