[Bf-blender-cvs] [a358a57] object_nodes: API for adding and deleting BVM functions.

Lukas Tönne noreply at git.blender.org
Tue Nov 24 09:42:42 CET 2015


Commit: a358a5734f66b2dedb86c2eed3adbc96f0a3e40c
Author: Lukas Tönne
Date:   Fri Sep 11 14:26:09 2015 +0200
Branches: object_nodes
https://developer.blender.org/rBa358a5734f66b2dedb86c2eed3adbc96f0a3e40c

API for adding and deleting BVM functions.

===================================================================

M	source/blender/blenvm/BVM_module.h
M	source/blender/blenvm/intern/bvm_module.cc

===================================================================

diff --git a/source/blender/blenvm/BVM_module.h b/source/blender/blenvm/BVM_module.h
index 46ccf9a..3e0cdfb 100644
--- a/source/blender/blenvm/BVM_module.h
+++ b/source/blender/blenvm/BVM_module.h
@@ -41,4 +41,7 @@ typedef struct BVMModule {
 void BVM_module_init(struct BVMModule *lib);
 void BVM_module_free(struct BVMModule *lib);
 
+struct BVMFunction *BVM_module_create_function(struct BVMModule *mod, const char *name);
+bool BVM_module_delete_function(struct BVMModule *mod, const char *name);
+
 #endif /* __BVM_MODULE_H__ */
diff --git a/source/blender/blenvm/intern/bvm_module.cc b/source/blender/blenvm/intern/bvm_module.cc
index 53e496c..f7f269e 100644
--- a/source/blender/blenvm/intern/bvm_module.cc
+++ b/source/blender/blenvm/intern/bvm_module.cc
@@ -34,6 +34,7 @@
 extern "C" {
 #include "BLI_utildefines.h"
 #include "BLI_ghash.h"
+#include "BLI_string.h"
 }
 
 #include "MEM_guardedalloc.h"
@@ -55,7 +56,25 @@ void BVM_module_free(BVMModule *lib)
 	BLI_ghash_free(lib->functions, NULL, (GHashValFreeFP)ghash_function_free);
 }
 
+/* ------------------------------------------------------------------------- */
+
 static void ghash_function_free(BVMFunction *fun)
 {
 	MEM_freeN(fun);
 }
+
+struct BVMFunction *BVM_module_create_function(BVMModule *mod, const char *name)
+{
+	BLI_assert(BLI_ghash_lookup(mod->functions, name) == NULL);
+	
+	BVMFunction *fun = MEM_callocN(sizeof(BVMFunction), "BVM function");
+	BLI_strncpy(fun->name, name, sizeof(fun->name));
+	
+	BLI_ghash_insert(mod->functions, fun->name, fun);
+	return fun;
+}
+
+bool BVM_module_delete_function(BVMModule *mod, const char *name)
+{
+	return BLI_ghash_remove(mod->functions, name, NULL, (GHashValFreeFP)ghash_function_free);
+}




More information about the Bf-blender-cvs mailing list