PulleyScript: extend squeal API
authorAdriaan de Groot <groot@kde.org>
Sun, 3 Jul 2016 15:27:07 +0000 (17:27 +0200)
committerAdriaan de Groot <groot@kde.org>
Sun, 3 Jul 2016 15:27:07 +0000 (17:27 +0200)
Modify generator_fork() so it can be called from
outside the opaque structures with a gennum_t.
Add it to the API.

src/pulley/pulleyscript/squeal.c
src/pulley/pulleyscript/squeal.h

index 60ca8c8..4b9e0c9 100644 (file)
@@ -432,12 +432,16 @@ static void squeal_produce_output (struct squeal *squeal, int add_not_del,
  * and removing the record to its own gen_xxx table, it will invoke the respective
  * routine to be of use for its future role as a co-generator.
  */
-static void squeal_generator_fork (struct squeal *squeal,
+static void _squeal_generator_fork (struct squeal *squeal,
                        struct s3ins_generator *genfront, int add_not_del,
                        int numrecvars, struct squeal_blob *recvars) {
        int d;
        int i;
        assert (genfront->numrecvars == numrecvars);
+
+       printf("Generator fork @%p add?%d\n", (void *)genfront, add_not_del);
+       printf("  .. adding %d variables.", numrecvars);
+
        //
        // Produce the generator hash over the blobs holding the record variables
        s3key_t genhash = S3KEY_INIT;
@@ -467,6 +471,13 @@ static void squeal_generator_fork (struct squeal *squeal,
 }
 
 
+void squeal_generator_fork(struct squeal *squeal, gennum_t gennum, int add_not_del, int numrecvars, struct squeal_blob *recvars)
+{
+       _squeal_generator_fork(squeal, &(squeal->gens[gennum]), add_not_del, numrecvars, recvars);
+}
+
+
+
 /********** BACKEND STRUCTURE CREATION **********/
 
 
index f8cf143..eca87cd 100644 (file)
@@ -69,8 +69,23 @@ int squeal_have_tables (struct squeal *s3db, struct gentab *gentab, bool may_reu
  */
 int squeal_configure (struct squeal *squeal);
 
+/**
+ * Prepare SQL statements that manipulate the gen_<hash>
+ * tables, (one table for each generator). This should be
+ * called after squeal_configure() and before calling
+ * squeal_generator_fork().
+ */
 int squeal_configure_generators(struct squeal* squeal, struct gentab* gentab);
 
+/**
+ * Run generator @p gennum with a new tuple of variables. The operation
+ * may be an add (@p add_not_del == 1) or delete (@p add_not_del == 0).
+ * The variable tuple is described as an array of squeal_blob structures
+ * in an array starting at @p recvars. There are @p numrecvars blobs
+ * in the array, which must match what the generator expects.
+ */
+void squeal_generator_fork(struct squeal *squeal, gennum_t gennum, int add_not_del, int numrecvars, struct squeal_blob *recvars);
+
 #ifdef __cplusplus
 }
 #endif