aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2024-06-26 13:03:40 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2024-06-26 13:27:41 -0400
commitc5e5ad3f42b16da324cf4cba0ecca2a449f560f0 (patch)
tree977fb33ec4e2bb5d04c7739c5e53fb25793489bf /include
parentebd9d7cc8cb921f1e51187fe5cf7e781edf6f1b2 (diff)
downloadstasis-c5e5ad3f42b16da324cf4cba0ecca2a449f560f0.tar.gz
Fix circular dependency on tplfunc_frame
* Remove predeclaration of tplfunc_frame * tpl_register_func accepts pointer to void instead * tpl_register_func sets maximum number of arguments * Frame is generated within tpl_register_func
Diffstat (limited to 'include')
-rw-r--r--include/template.h21
1 files changed, 17 insertions, 4 deletions
diff --git a/include/template.h b/include/template.h
index ba62667..9a34c6a 100644
--- a/include/template.h
+++ b/include/template.h
@@ -40,9 +40,8 @@ char *tpl_render(char *str);
*/
int tpl_render_to_file(char *str, const char *filename);
-struct tplfunc_frame *tpl_getfunc(char *key);
-struct tplfunc_frame;
-typedef int tplfunc(struct tplfunc_frame *frame, void *result);
+typedef int tplfunc(void *frame, void *result);
+
struct tplfunc_frame {
char *key;
tplfunc *func;
@@ -62,6 +61,20 @@ struct tplfunc_frame {
double t_double;
} argv[10]; // accept up to 10 arguments
};
-void tpl_register_func(char *key, struct tplfunc_frame *frame);
+
+/**
+ * Register a template function
+ * @param key function name to expose to "func:" interface
+ * @param tplfunc_ptr pointer to function of type tplfunc
+ * @param argc number of function arguments to accept
+ */
+void tpl_register_func(char *key, void *tplfunc_ptr, int argc);
+
+/**
+ * Get the function frame associated with a template function
+ * @param key function name
+ * @return tplfunc_frame structure
+ */
+struct tplfunc_frame *tpl_getfunc(char *key);
#endif //STASIS_TEMPLATE_H