Browse Source

Move plugin's function prototype definition to ksym

Serj Kalichev 3 years ago
parent
commit
02aebc384f
3 changed files with 11 additions and 11 deletions
  1. 0 4
      klish/kplugin.h
  2. 5 5
      klish/kscheme/ksym.c
  3. 6 2
      klish/ksym.h

+ 0 - 4
klish/kplugin.h

@@ -34,10 +34,6 @@ typedef struct kplugin_s kplugin_t;
 
 typedef faux_list_node_t kplugin_syms_node_t;
 
-// Callback function prototype
-typedef struct kcontext_s kcontext_t;
-typedef int (*kplugin_sym_fn)(kcontext_t *context);
-
 
 C_DECL_BEGIN
 

+ 5 - 5
klish/kscheme/ksym.c

@@ -13,7 +13,7 @@
 
 struct ksym_s {
 	char *name;
-	const void *fn;
+	const ksym_fn *function;
 };
 
 
@@ -23,9 +23,9 @@ struct ksym_s {
 KGET_STR(sym, name);
 KSET_STR_ONCE(sym, name);
 
-// Fn (function)
-KGET(sym, const void *, fn);
-KSET(sym, const void *, fn);
+// Function
+KGET(sym, const ksym_fn *, function);
+KSET(sym, const ksym_fn *, function);
 
 
 ksym_t *ksym_new(const char *name)
@@ -42,7 +42,7 @@ ksym_t *ksym_new(const char *name)
 
 	// Initialize
 	sym->name = faux_str_dup(name);
-	sym->fn = NULL;
+	sym->function = NULL;
 
 	return sym;
 }

+ 6 - 2
klish/ksym.h

@@ -9,6 +9,10 @@
 
 typedef struct ksym_s ksym_t;
 
+// Callback function prototype
+typedef struct kcontext_s kcontext_t; // Redeclaration to don't include kcontext.h
+typedef int (*ksym_fn)(kcontext_t *context);
+
 
 C_DECL_BEGIN
 
@@ -17,8 +21,8 @@ ksym_t *ksym_new(const char *name);
 void ksym_free(ksym_t *sym);
 
 const char *ksym_name(const ksym_t *sym);
-const void *ksym_fn(const ksym_t *sym);
-bool_t ksym_set_fn(ksym_t *sym, const void *fn);
+const ksym_fn *ksym_function(const ksym_t *sym);
+bool_t ksym_set_function(ksym_t *sym, const ksym_fn *fn);
 
 C_DECL_END