[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43887] trunk/blender/source/blender/ python: Code Cleanup: line length and use Py_ssize_t for PyC_AsArray utility function.

Campbell Barton ideasman42 at gmail.com
Sun Feb 5 03:04:40 CET 2012


Revision: 43887
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43887
Author:   campbellbarton
Date:     2012-02-05 02:04:26 +0000 (Sun, 05 Feb 2012)
Log Message:
-----------
Code Cleanup: line length and use Py_ssize_t for PyC_AsArray utility function.

Modified Paths:
--------------
    trunk/blender/source/blender/python/generic/py_capi_utils.c
    trunk/blender/source/blender/python/generic/py_capi_utils.h
    trunk/blender/source/blender/python/intern/bpy_operator_wrap.c
    trunk/blender/source/blender/python/intern/bpy_rna.c

Modified: trunk/blender/source/blender/python/generic/py_capi_utils.c
===================================================================
--- trunk/blender/source/blender/python/generic/py_capi_utils.c	2012-02-04 19:58:09 UTC (rev 43886)
+++ trunk/blender/source/blender/python/generic/py_capi_utils.c	2012-02-05 02:04:26 UTC (rev 43887)
@@ -35,18 +35,20 @@
 
 #include "py_capi_utils.h"
 
-#include "BLI_string_utf8.h" /* only for BLI_strncpy_wchar_from_utf8, should replace with py funcs but too late in release now */
+/* only for BLI_strncpy_wchar_from_utf8, should replace with py funcs but too late in release now */
+#include "BLI_string_utf8.h"
 
 #ifdef _WIN32 /* BLI_setenv */
 #include "BLI_path_util.h"
 #endif
 
 /* array utility function */
-int PyC_AsArray(void *array, PyObject *value, const int length, const PyTypeObject *type, const short is_double, const char *error_prefix)
+int PyC_AsArray(void *array, PyObject *value, const Py_ssize_t length,
+                const PyTypeObject *type, const short is_double, const char *error_prefix)
 {
 	PyObject *value_fast;
-	int value_len;
-	int i;
+	Py_ssize_t value_len;
+	Py_ssize_t i;
 
 	if (!(value_fast=PySequence_Fast(value, error_prefix))) {
 		return -1;
@@ -463,7 +465,8 @@
 	if (py_path_bundle==NULL) {
 		/* Common enough to have bundled *nix python but complain on OSX/Win */
 #if defined(__APPLE__) || defined(_WIN32)
-		fprintf(stderr, "Warning! bundled python not found and is expected on this platform. (if you built with CMake: 'install' target may have not been built)\n");
+		fprintf(stderr, "Warning! bundled python not found and is expected on this platform. "
+		        "(if you built with CMake: 'install' target may have not been built)\n");
 #endif
 		return;
 	}
@@ -492,7 +495,8 @@
 		/* cant use this, on linux gives bug: #23018, TODO: try LANG="en_US.UTF-8" /usr/bin/blender, suggested 22008 */
 		/* mbstowcs(py_path_bundle_wchar, py_path_bundle, FILE_MAXDIR); */
 
-		BLI_strncpy_wchar_from_utf8(py_path_bundle_wchar, py_path_bundle, sizeof(py_path_bundle_wchar) / sizeof(wchar_t));
+		BLI_strncpy_wchar_from_utf8(py_path_bundle_wchar, py_path_bundle,
+		                            sizeof(py_path_bundle_wchar) / sizeof(wchar_t));
 
 		Py_SetPythonHome(py_path_bundle_wchar);
 		// printf("found python (wchar_t) '%ls'\n", py_path_bundle_wchar);

Modified: trunk/blender/source/blender/python/generic/py_capi_utils.h
===================================================================
--- trunk/blender/source/blender/python/generic/py_capi_utils.h	2012-02-04 19:58:09 UTC (rev 43886)
+++ trunk/blender/source/blender/python/generic/py_capi_utils.h	2012-02-05 02:04:26 UTC (rev 43887)
@@ -35,7 +35,8 @@
 PyObject *		PyC_Err_Format_Prefix(PyObject *exception_type_prefix, const char *format, ...);
 void			PyC_FileAndNum(const char **filename, int *lineno);
 void			PyC_FileAndNum_Safe(const char **filename, int *lineno); /* checks python is running */
-int				PyC_AsArray(void *array, PyObject *value, const int length, const PyTypeObject *type, const short is_double, const char *error_prefix);
+int				PyC_AsArray(void *array, PyObject *value, const Py_ssize_t length,
+                            const PyTypeObject *type, const short is_double, const char *error_prefix);
 
 /* follow http://www.python.org/dev/peps/pep-0383/ */
 PyObject *      PyC_UnicodeFromByte(const char *str);

Modified: trunk/blender/source/blender/python/intern/bpy_operator_wrap.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_operator_wrap.c	2012-02-04 19:58:09 UTC (rev 43886)
+++ trunk/blender/source/blender/python/intern/bpy_operator_wrap.c	2012-02-05 02:04:26 UTC (rev 43887)
@@ -112,7 +112,9 @@
 		return NULL;
 
 	if (WM_operatortype_find(opname, TRUE) == NULL) {
-		PyErr_Format(PyExc_ValueError, "Macro Define: '%s' is not a valid operator id", opname);
+		PyErr_Format(PyExc_ValueError,
+		             "Macro Define: '%s' is not a valid operator id",
+		             opname);
 		return NULL;
 	}
 
@@ -123,7 +125,9 @@
 	ot = WM_operatortype_find(macroname, TRUE);
 
 	if (!ot) {
-		PyErr_Format(PyExc_ValueError, "Macro Define: '%s' is not a valid macro or hasn't been registered yet", macroname);
+		PyErr_Format(PyExc_ValueError,
+		             "Macro Define: '%s' is not a valid macro or hasn't been registered yet",
+		             macroname);
 		return NULL;
 	}
 

Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c	2012-02-04 19:58:09 UTC (rev 43886)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c	2012-02-05 02:04:26 UTC (rev 43887)
@@ -2571,7 +2571,8 @@
 			return NULL;
 		}
 		else if (key_slice->start == Py_None && key_slice->stop == Py_None) {
-			/* note, no significant advantage with optimizing [:] slice as with collections but include here for consistency with collection slice func */
+			/* note, no significant advantage with optimizing [:] slice as with collections
+			 * but include here for consistency with collection slice func */
 			Py_ssize_t len = (Py_ssize_t)pyrna_prop_array_length(self);
 			return pyrna_prop_array_subscript_slice(self, &self->ptr, self->prop, 0, len, len);
 		}
@@ -2834,7 +2835,8 @@
 		const char *keyname = _PyUnicode_AsString(key);
 
 		if (keyname == NULL) {
-			PyErr_SetString(PyExc_TypeError, "bpy_prop_collection.__contains__: expected a string or a typle of strings");
+			PyErr_SetString(PyExc_TypeError,
+			                "bpy_prop_collection.__contains__: expected a string or a typle of strings");
 			return -1;
 		}
 
@@ -5102,7 +5104,14 @@
 
 
 #ifdef DEBUG_STRING_FREE
-	// if (PyList_GET_SIZE(string_free_ls)) printf("%.200s.%.200s():  has %d strings\n", RNA_struct_identifier(self_ptr->type), RNA_function_identifier(self_func), (int)PyList_GET_SIZE(string_free_ls));
+	/*
+	if (PyList_GET_SIZE(string_free_ls)) {
+		printf("%.200s.%.200s():  has %d strings\n",
+		       RNA_struct_identifier(self_ptr->type),
+		       RNA_function_identifier(self_func),
+		       (int)PyList_GET_SIZE(string_free_ls));
+	}
+	 */
 	Py_DECREF(string_free_ls);
 #undef DEBUG_STRING_FREE
 #endif
@@ -5126,7 +5135,10 @@
 PyTypeObject pyrna_struct_meta_idprop_Type = {
 	PyVarObject_HEAD_INIT(NULL, 0)
 	"bpy_struct_meta_idprop",   /* tp_name */
-	sizeof(PyHeapTypeObject),   /* tp_basicsize */ // XXX, would be PyTypeObject, but subtypes of Type must be PyHeapTypeObject's
+
+	/* NOTE! would be PyTypeObject, but subtypes of Type must be PyHeapTypeObject's */
+	sizeof(PyHeapTypeObject),   /* tp_basicsize */
+
 	0,                          /* tp_itemsize */
 	/* methods */
 	NULL,                       /* tp_dealloc */
@@ -5380,16 +5392,16 @@
 
 PyTypeObject pyrna_prop_array_Type = {
 	PyVarObject_HEAD_INIT(NULL, 0)
-	"bpy_prop_array",		/* tp_name */
+	"bpy_prop_array",           /* tp_name */
 	sizeof(BPy_PropertyArrayRNA),			/* tp_basicsize */
-	0,							/* tp_itemsize */
+	0,                          /* tp_itemsize */
 	/* methods */
 	(destructor)pyrna_prop_array_dealloc, /* tp_dealloc */
 	NULL,                       /* printfunc tp_print; */
 	NULL,                       /* getattrfunc tp_getattr; */
 	NULL,                       /* setattrfunc tp_setattr; */
 	NULL,                       /* tp_compare */ /* DEPRECATED in python 3.0! */
-	NULL,/* subclassed */		/* tp_repr */
+	NULL,/* subclassed */       /* tp_repr */
 
 	/* Method suites for standard classes */
 




More information about the Bf-blender-cvs mailing list