Procházet zdrojové kódy

Check rc for graph iterator creation; some docstrings.

scossu před 13 hodinami
rodič
revize
ee1014d831
3 změnil soubory, kde provedl 39 přidání a 3 odebrání
  1. 1 0
      src/lua_graph.c
  2. 33 3
      src/lua_triple.c
  3. 5 0
      src/lua_volksdata.h

+ 1 - 0
src/lua_graph.c

@@ -202,6 +202,7 @@ static int l_graph_add (lua_State *L)
     VOLK_rc volk_rc= VOLK_NOACTION;
     size_t i = 0, ct = 0;
     VOLK_GraphIterator *it = VOLK_graph_add_init (gr);
+    LUA_NLCHECK (it, "Error creating iterator.");
 
     while ((rc = lua_rawgeti (L, 2, ++i)) != LUA_TNIL) {
         //LOG_DEBUG ("Triple type: %s", lua_typename (L, rc));

+ 33 - 3
src/lua_triple.c

@@ -1,3 +1,11 @@
+/***
+ * Volksdata Triple module.
+ *
+ * this module handles triples, groups of 3 @{volksdata.Term} objects.
+ * @classmod volksdata.Triple
+ */
+
+
 #include "lua_volksdata.h"
 
 
@@ -5,6 +13,17 @@
  * Factory methods.
  */
 
+/***
+ * Create a new triple from existing @{volksdata.Term} objects.
+ *
+ * @function new
+ *
+ * @tparam volksdata.Term s Subject.
+ * @tparam volksdata.Term p Predicate.
+ * @tparam volksdata.Term o Object.
+ *
+ * @treturn volksdata.Triple New triple.
+ */
 static int l_triple_new (lua_State *L)
 {
     VOLK_Triple **trp_p = lua_newuserdatauv (L, sizeof (*trp_p), 1);
@@ -29,6 +48,13 @@ static int l_triple_new (lua_State *L)
  * Class methods.
  */
 
+/***
+ * Garbage-collect a triple.
+ *
+ * @function __gc
+ *
+ * @tparam volksdata.Triple Triple to free.
+ */
 static int l_triple_gc (lua_State *L)
 {
     VOLK_Triple *trp = check_triple (L, 1);
@@ -38,14 +64,18 @@ static int l_triple_gc (lua_State *L)
 }
 
 
-/** @brief Get information about a triple's term.
+/***
+ * Get information about a triple's term.
  *
  * Note that this is only a visual representation, as terms cannot be modified
  * outside of their containing triple (unlike in the C library).
  *
- * @FIXME this doesn't allow chaining access methods, e.g. trp.s.data
+ * FIXME this doesn't allow chaining access methods, e.g. trp.s.data. To get
+ * an independent copy of a triple term, use @{copy_term()}.
  *
- * To get an independent copy of a triple term, use triple.copy_term().
+ * @tparam volksdata.Triple trp Triple to extract the term.
+ * @tparam triple_pos Position of the term in the triple.
+ * @treturn volksdata.Term Copy of the extracted term.
  */
 static int l_triple_get_term (lua_State *L)
 {

+ 5 - 0
src/lua_volksdata.h

@@ -1,3 +1,8 @@
+/***
+ * Volksdata Lua module.
+ * @module volksdata
+ */
+
 #include <lua.h>
 #include <lauxlib.h>