[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36519] trunk/blender/source/blender: Code cleanup: PIL_dynlib, renamed to BLI_dynlib, and other tweaks.

Brecht Van Lommel brechtvanlommel at pandora.be
Fri May 6 17:17:42 CEST 2011


Revision: 36519
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36519
Author:   blendix
Date:     2011-05-06 15:17:42 +0000 (Fri, 06 May 2011)
Log Message:
-----------
Code cleanup: PIL_dynlib, renamed to BLI_dynlib, and other tweaks.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/seqeffects.c
    trunk/blender/source/blender/blenkernel/intern/texture.c
    trunk/blender/source/blender/blenlib/CMakeLists.txt
    trunk/blender/source/blender/blenlib/intern/dynlib.c

Added Paths:
-----------
    trunk/blender/source/blender/blenlib/BLI_dynlib.h

Removed Paths:
-------------
    trunk/blender/source/blender/blenlib/PIL_dynlib.h

Modified: trunk/blender/source/blender/blenkernel/intern/seqeffects.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/seqeffects.c	2011-05-06 14:59:10 UTC (rev 36518)
+++ trunk/blender/source/blender/blenkernel/intern/seqeffects.c	2011-05-06 15:17:42 UTC (rev 36519)
@@ -37,7 +37,7 @@
 #include <stdlib.h>
 
 #include "MEM_guardedalloc.h"
-#include "PIL_dynlib.h"
+#include "BLI_dynlib.h"
 
 #include "BLI_math.h" /* windows needs for M_PI */
 #include "BLI_utildefines.h"
@@ -138,18 +138,18 @@
 	pis->instance_private_data = NULL;
 
 	/* clear the error list */
-	PIL_dynlib_get_error_as_string(NULL);
+	BLI_dynlib_get_error_as_string(NULL);
 
-	/* if(pis->handle) PIL_dynlib_close(pis->handle); */
+	/* if(pis->handle) BLI_dynlib_close(pis->handle); */
 	/* pis->handle= 0; */
 
 	/* open the needed object */
-	pis->handle= PIL_dynlib_open(pis->name);
+	pis->handle= BLI_dynlib_open(pis->name);
 	if(test_dlerr(pis->name, pis->name)) return;
 
 	if (pis->handle != NULL) {
 		/* find the address of the version function */
-		version= (int (*)(void))PIL_dynlib_find_symbol(pis->handle, "plugin_seq_getversion");
+		version= (int (*)(void))BLI_dynlib_find_symbol(pis->handle, "plugin_seq_getversion");
 		if (test_dlerr(pis->name, "plugin_seq_getversion")) return;
 
 		if (version != NULL) {
@@ -158,7 +158,7 @@
 				int (*info_func)(PluginInfo *);
 				PluginInfo *info= (PluginInfo*) MEM_mallocN(sizeof(PluginInfo), "plugin_info");
 
-				info_func= (int (*)(PluginInfo *))PIL_dynlib_find_symbol(pis->handle, "plugin_getinfo");
+				info_func= (int (*)(PluginInfo *))BLI_dynlib_find_symbol(pis->handle, "plugin_getinfo");
 
 				if(info_func == NULL) error("No info func");
 				else {
@@ -176,21 +176,21 @@
 				}
 				MEM_freeN(info);
 
-				cp= PIL_dynlib_find_symbol(pis->handle, "seqname");
+				cp= BLI_dynlib_find_symbol(pis->handle, "seqname");
 				if(cp) strncpy(cp, seqname, 21);
 			} else {
 				printf ("Plugin returned unrecognized version number\n");
 				return;
 			}
 		}
-		alloc_private = (void* (*)(void))PIL_dynlib_find_symbol(
+		alloc_private = (void* (*)(void))BLI_dynlib_find_symbol(
 			pis->handle, "plugin_seq_alloc_private_data");
 		if (alloc_private) {
 			pis->instance_private_data = alloc_private();
 		}
 		
 		pis->current_private_data = (void**) 
-			PIL_dynlib_find_symbol(
+			BLI_dynlib_find_symbol(
 				pis->handle, "plugin_private_data");
 	}
 }
@@ -229,12 +229,12 @@
 {
 	if(pis==NULL) return;
 
-	/* no PIL_dynlib_close: same plugin can be opened multiple times with 1 handle */
+	/* no BLI_dynlib_close: same plugin can be opened multiple times with 1 handle */
 
 	if (pis->instance_private_data) {
 		void (*free_private)(void *);
 
-		free_private = (void (*)(void *))PIL_dynlib_find_symbol(
+		free_private = (void (*)(void *))BLI_dynlib_find_symbol(
 			pis->handle, "plugin_seq_free_private_data");
 		if (free_private) {
 			free_private(pis->instance_private_data);
@@ -301,7 +301,7 @@
 		if(seq->plugin->cfra) 
 			*(seq->plugin->cfra)= cfra;
 		
-		cp = PIL_dynlib_find_symbol(
+		cp = BLI_dynlib_find_symbol(
 			seq->plugin->handle, "seqname");
 
 		if(cp) strncpy(cp, seq->name+2, 22);

Modified: trunk/blender/source/blender/blenkernel/intern/texture.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/texture.c	2011-05-06 14:59:10 UTC (rev 36518)
+++ trunk/blender/source/blender/blenkernel/intern/texture.c	2011-05-06 15:17:42 UTC (rev 36519)
@@ -41,9 +41,8 @@
 
 #include "MEM_guardedalloc.h"
 
-#include "PIL_dynlib.h"
-
 #include "BLI_blenlib.h"
+#include "BLI_dynlib.h"
 #include "BLI_math.h"
 #include "BLI_kdopbvh.h"
 #include "BLI_utildefines.h"
@@ -82,7 +81,7 @@
 {
 	char *err;
 	
-	err= PIL_dynlib_get_error_as_string(NULL);
+	err= BLI_dynlib_get_error_as_string(NULL);
 	if(err) {
 		printf("var1: %s, var2: %s, var3: %s\n", name, symbol, err);
 		return 1;
@@ -108,19 +107,19 @@
 	pit->instance_init= NULL;
 	
 	/* clear the error list */
-	PIL_dynlib_get_error_as_string(NULL);
+	BLI_dynlib_get_error_as_string(NULL);
 
-	/* no PIL_dynlib_close! multiple opened plugins... */
-	/* if(pit->handle) PIL_dynlib_close(pit->handle); */
+	/* no BLI_dynlib_close! multiple opened plugins... */
+	/* if(pit->handle) BLI_dynlib_close(pit->handle); */
 	/* pit->handle= 0; */
 
 	/* open the needed object */
-	pit->handle= PIL_dynlib_open(pit->name);
+	pit->handle= BLI_dynlib_open(pit->name);
 	if(test_dlerr(pit->name, pit->name)) return;
 
 	if (pit->handle != NULL) {
 		/* find the address of the version function */
-		version= (int (*)(void)) PIL_dynlib_find_symbol(pit->handle, "plugin_tex_getversion");
+		version= (int (*)(void)) BLI_dynlib_find_symbol(pit->handle, "plugin_tex_getversion");
 		if (test_dlerr(pit->name, "plugin_tex_getversion")) return;
 		
 		if (version != NULL) {
@@ -129,7 +128,7 @@
 				int (*info_func)(PluginInfo *);
 				PluginInfo *info= (PluginInfo*) MEM_mallocN(sizeof(PluginInfo), "plugin_info"); 
 
-				info_func= (int (*)(PluginInfo *))PIL_dynlib_find_symbol(pit->handle, "plugin_getinfo");
+				info_func= (int (*)(PluginInfo *))BLI_dynlib_find_symbol(pit->handle, "plugin_getinfo");
 				if (!test_dlerr(pit->name, "plugin_getinfo")) {
 					info->instance_init = NULL;
 
@@ -200,7 +199,7 @@
 {
 	if(pit==NULL) return;
 		
-	/* no PIL_dynlib_close: same plugin can be opened multiple times, 1 handle */
+	/* no BLI_dynlib_close: same plugin can be opened multiple times, 1 handle */
 	MEM_freeN(pit);	
 }
 

Copied: trunk/blender/source/blender/blenlib/BLI_dynlib.h (from rev 36512, trunk/blender/source/blender/blenlib/PIL_dynlib.h)
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_dynlib.h	                        (rev 0)
+++ trunk/blender/source/blender/blenlib/BLI_dynlib.h	2011-05-06 15:17:42 UTC (rev 36519)
@@ -0,0 +1,45 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenlib/BLI_dynlib.h
+ *  \ingroup bli
+ */
+
+#ifndef __BLI_DYNLIB_H__
+#define __BLI_DYNLIB_H__
+
+typedef struct DynamicLibrary DynamicLibrary;
+
+DynamicLibrary *BLI_dynlib_open(char *name);
+void *BLI_dynlib_find_symbol(DynamicLibrary* lib, const char *symname);
+char *BLI_dynlib_get_error_as_string(DynamicLibrary* lib);
+void BLI_dynlib_close(DynamicLibrary* lib);
+
+#endif /* __BLI_DYNLIB_H__ */
+

Modified: trunk/blender/source/blender/blenlib/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/blenlib/CMakeLists.txt	2011-05-06 14:59:10 UTC (rev 36518)
+++ trunk/blender/source/blender/blenlib/CMakeLists.txt	2011-05-06 15:17:42 UTC (rev 36519)
@@ -88,6 +88,7 @@
 	BLI_bpath.h
 	BLI_cpu.h
 	BLI_dlrbTree.h
+	BLI_dynlib.h
 	BLI_dynstr.h
 	BLI_edgehash.h
 	BLI_editVert.h
@@ -127,7 +128,6 @@
 	BLI_vfontdata.h
 	BLI_voxel.h
 	BLI_winstuff.h
-	PIL_dynlib.h
 	PIL_time.h
 	intern/BLI_callbacks.h
 	intern/dynamiclist.h

Deleted: trunk/blender/source/blender/blenlib/PIL_dynlib.h
===================================================================
--- trunk/blender/source/blender/blenlib/PIL_dynlib.h	2011-05-06 14:59:10 UTC (rev 36518)
+++ trunk/blender/source/blender/blenlib/PIL_dynlib.h	2011-05-06 15:17:42 UTC (rev 36519)
@@ -1,57 +0,0 @@
-/*
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/blenlib/PIL_dynlib.h
- *  \ingroup bli
- */
-
-#ifndef __PIL_DYNLIB_H__
-#define __PIL_DYNLIB_H__
-
-typedef struct PILdynlib PILdynlib;
-
-	PILdynlib*
-PIL_dynlib_open(
-	char *name);
-
-	void*
-PIL_dynlib_find_symbol(
-	PILdynlib* lib, 
-	const char *symname);
-
-	char*
-PIL_dynlib_get_error_as_string(
-	PILdynlib* lib);
-	
-	void
-PIL_dynlib_close(
-	PILdynlib* lib);
-
-#endif /* __PIL_DYNLIB_H__ */
-

Modified: trunk/blender/source/blender/blenlib/intern/dynlib.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/dynlib.c	2011-05-06 14:59:10 UTC (rev 36518)
+++ trunk/blender/source/blender/blenlib/intern/dynlib.c	2011-05-06 15:17:42 UTC (rev 36519)
@@ -31,110 +31,101 @@
  *  \ingroup bli
  */
 
-
+#include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
-#include "../PIL_dynlib.h"
+#include "MEM_guardedalloc.h"
 
-#if !defined(CHAR_MAX)
-#define CHAR_MAX 255
-#endif
+#include "BLI_dynlib.h"
 
-/*
- * XXX, should use mallocN so we can see
- * handle's not being released. fixme zr
- */
- 
+struct DynamicLibrary {
+	void *handle;
+};
+
 #ifdef WIN32
-#include <string.h>
-#include <stdio.h>
 
 #include <windows.h>
 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list