Code Cleanup: line length and use Py_ssize_t for PyC_AsArray utility function.
This commit is contained in:
@@ -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 @@ void PyC_SetHomePath(const char *py_path_bundle)
|
||||
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 @@ void PyC_SetHomePath(const char *py_path_bundle)
|
||||
/* 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);
|
||||
|
@@ -35,7 +35,8 @@ PyObject * PyC_Object_GetAttrStringArgs(PyObject *o, Py_ssize_t n, ...);
|
||||
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);
|
||||
|
@@ -112,7 +112,9 @@ PyObject *PYOP_wrap_macro_define(PyObject *UNUSED(self), PyObject *args)
|
||||
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 @@ PyObject *PYOP_wrap_macro_define(PyObject *UNUSED(self), PyObject *args)
|
||||
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;
|
||||
}
|
||||
|
||||
|
@@ -2571,7 +2571,8 @@ static PyObject *pyrna_prop_array_subscript(BPy_PropertyArrayRNA *self, PyObject
|
||||
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 @@ static int pyrna_prop_collection_contains(BPy_PropertyRNA *self, PyObject *key)
|
||||
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 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
|
||||
|
||||
|
||||
#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 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
|
||||
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_Type = {
|
||||
|
||||
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 */
|
||||
|
||||
|
Reference in New Issue
Block a user