Merged changes in the trunk up to revision 41225.
Conflicts resolved: source/blender/render/intern/source/pipeline.c
This commit is contained in:
@@ -36,8 +36,6 @@
|
||||
#ifndef BPY_EXTERN_H
|
||||
#define BPY_EXTERN_H
|
||||
|
||||
extern char bprogname[]; /* holds a copy of argv[0], from creator.c */
|
||||
|
||||
struct Text; /* defined in DNA_text_types.h */
|
||||
struct ID; /* DNA_ID.h */
|
||||
struct Object; /* DNA_object_types.h */
|
||||
|
||||
@@ -67,9 +67,9 @@ PyObject *BPy_IDGroup_WrapData( ID *id, IDProperty *prop )
|
||||
switch ( prop->type ) {
|
||||
case IDP_STRING:
|
||||
#ifdef USE_STRING_COERCE
|
||||
return PyC_UnicodeFromByte(IDP_Array(prop));
|
||||
return PyC_UnicodeFromByteAndSize(IDP_Array(prop), prop->len);
|
||||
#else
|
||||
return PyUnicode_FromString(IDP_Array(prop));
|
||||
return PyUnicode_FromStringAndSize(IDP_Array(prop), prop->len);
|
||||
#endif
|
||||
case IDP_INT:
|
||||
return PyLong_FromLong( (long)prop->data.val );
|
||||
@@ -485,9 +485,9 @@ static PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
|
||||
switch (prop->type) {
|
||||
case IDP_STRING:
|
||||
#ifdef USE_STRING_COERCE
|
||||
return PyC_UnicodeFromByte(IDP_Array(prop));
|
||||
return PyC_UnicodeFromByteAndSize(IDP_Array(prop), prop->len);
|
||||
#else
|
||||
return PyUnicode_FromString(IDP_Array(prop));
|
||||
return PyUnicode_FromStringAndSize(IDP_Array(prop), prop->len);
|
||||
#endif
|
||||
break;
|
||||
case IDP_FLOAT:
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
#include "py_capi_utils.h"
|
||||
|
||||
#include "BKE_font.h" /* only for utf8towchar, should replace with py funcs but too late in release now */
|
||||
#include "BLI_string_utf8.h" /* only for BLI_strncpy_wchar_from_utf8, should replace with py funcs but too late in release now */
|
||||
|
||||
#ifdef _WIN32 /* BLI_setenv */
|
||||
#include "BLI_path_util.h"
|
||||
@@ -184,6 +184,15 @@ void PyC_FileAndNum(const char **filename, int *lineno)
|
||||
}
|
||||
}
|
||||
|
||||
void PyC_FileAndNum_Safe(const char **filename, int *lineno)
|
||||
{
|
||||
if(!PYC_INTERPRETER_ACTIVE) {
|
||||
return;
|
||||
}
|
||||
|
||||
PyC_FileAndNum(filename, lineno);
|
||||
}
|
||||
|
||||
/* Would be nice if python had this built in */
|
||||
PyObject *PyC_Object_GetAttrStringArgs(PyObject *o, Py_ssize_t n, ...)
|
||||
{
|
||||
@@ -377,9 +386,9 @@ const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce)
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *PyC_UnicodeFromByte(const char *str)
|
||||
PyObject *PyC_UnicodeFromByteAndSize(const char *str, Py_ssize_t size)
|
||||
{
|
||||
PyObject *result= PyUnicode_FromString(str);
|
||||
PyObject *result= PyUnicode_FromStringAndSize(str, size);
|
||||
if (result) {
|
||||
/* 99% of the time this is enough but we better support non unicode
|
||||
* chars since blender doesnt limit this */
|
||||
@@ -388,11 +397,16 @@ PyObject *PyC_UnicodeFromByte(const char *str)
|
||||
else {
|
||||
PyErr_Clear();
|
||||
/* this means paths will always be accessible once converted, on all OS's */
|
||||
result= PyUnicode_DecodeFSDefault(str);
|
||||
result= PyUnicode_DecodeFSDefaultAndSize(str, size);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *PyC_UnicodeFromByte(const char *str)
|
||||
{
|
||||
return PyC_UnicodeFromByteAndSize(str, strlen(str));
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* Description: This function creates a new Python dictionary object.
|
||||
* note: dict is owned by sys.modules["__main__"] module, reference is borrowed
|
||||
@@ -469,7 +483,7 @@ 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); */
|
||||
|
||||
utf8towchar(py_path_bundle_wchar, py_path_bundle);
|
||||
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);
|
||||
|
||||
@@ -36,11 +36,13 @@ PyObject * PyC_ExceptionBuffer(void);
|
||||
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);
|
||||
|
||||
/* follow http://www.python.org/dev/peps/pep-0383/ */
|
||||
PyObject * PyC_UnicodeFromByte(const char *str);
|
||||
const char * PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce); /* coerce must be NULL */
|
||||
PyObject * PyC_UnicodeFromByte(const char *str);
|
||||
PyObject * PyC_UnicodeFromByteAndSize(const char *str, Py_ssize_t size);
|
||||
const char * PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce); /* coerce must be NULL */
|
||||
|
||||
/* name namespace function for bpy & bge */
|
||||
PyObject * PyC_DefaultNameSpace(const char *filename);
|
||||
|
||||
@@ -93,8 +93,6 @@ static PyStructSequence_Desc app_info_desc= {
|
||||
|
||||
static PyObject *make_app_info(void)
|
||||
{
|
||||
extern char bprogname[]; /* argv[0] from creator.c */
|
||||
|
||||
PyObject *app_info;
|
||||
int pos= 0;
|
||||
|
||||
@@ -118,7 +116,7 @@ static PyObject *make_app_info(void)
|
||||
SetStrItem("");
|
||||
#endif
|
||||
SetStrItem(STRINGIFY(BLENDER_VERSION_CYCLE));
|
||||
SetStrItem(bprogname);
|
||||
SetStrItem(BLI_program_path());
|
||||
SetObjItem(PyBool_FromLong(G.background));
|
||||
|
||||
/* build info */
|
||||
@@ -200,8 +198,7 @@ static int bpy_app_debug_value_set(PyObject *UNUSED(self), PyObject *value, void
|
||||
|
||||
static PyObject *bpy_app_tempdir_get(PyObject *UNUSED(self), void *UNUSED(closure))
|
||||
{
|
||||
extern char btempdir[];
|
||||
return PyC_UnicodeFromByte(btempdir);
|
||||
return PyC_UnicodeFromByte(BLI_temporary_dir());
|
||||
}
|
||||
|
||||
static PyObject *bpy_app_driver_dict_get(PyObject *UNUSED(self), void *UNUSED(closure))
|
||||
|
||||
@@ -52,12 +52,12 @@
|
||||
#include "BLI_path_util.h"
|
||||
#include "BLI_math_base.h"
|
||||
#include "BLI_string.h"
|
||||
#include "BLI_string_utf8.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_text.h"
|
||||
#include "BKE_font.h" /* only for utf8towchar */
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_global.h" /* only for script checking */
|
||||
|
||||
@@ -193,9 +193,9 @@ void BPY_python_start(int argc, const char **argv)
|
||||
PyThreadState *py_tstate= NULL;
|
||||
|
||||
/* not essential but nice to set our name */
|
||||
static wchar_t bprogname_wchar[FILE_MAXDIR+FILE_MAXFILE]; /* python holds a reference */
|
||||
utf8towchar(bprogname_wchar, bprogname);
|
||||
Py_SetProgramName(bprogname_wchar);
|
||||
static wchar_t program_path_wchar[FILE_MAXDIR+FILE_MAXFILE]; /* python holds a reference */
|
||||
BLI_strncpy_wchar_from_utf8(program_path_wchar, BLI_program_path(), sizeof(program_path_wchar) / sizeof(wchar_t));
|
||||
Py_SetProgramName(program_path_wchar);
|
||||
|
||||
/* must run before python initializes */
|
||||
PyImport_ExtendInittab(bpy_internal_modules);
|
||||
@@ -203,9 +203,16 @@ void BPY_python_start(int argc, const char **argv)
|
||||
/* allow to use our own included python */
|
||||
PyC_SetHomePath(BLI_get_folder(BLENDER_SYSTEM_PYTHON, NULL));
|
||||
|
||||
/* Python 3.2 now looks for '2.58/python/include/python3.2d/pyconfig.h' to parse
|
||||
* from the 'sysconfig' module which is used by 'site', so for now disable site.
|
||||
* alternatively we could copy the file. */
|
||||
/* without this the sys.stdout may be set to 'ascii'
|
||||
* (it is on my system at least), where printing unicode values will raise
|
||||
* an error, this is highly annoying, another stumbling block for devs,
|
||||
* so use a more relaxed error handler and enforce utf-8 since the rest of
|
||||
* blender is utf-8 too - campbell */
|
||||
BLI_setenv("PYTHONIOENCODING", "utf-8:surrogateescape");
|
||||
|
||||
/* Python 3.2 now looks for '2.xx/python/include/python3.2d/pyconfig.h' to
|
||||
* parse from the 'sysconfig' module which is used by 'site',
|
||||
* so for now disable site. alternatively we could copy the file. */
|
||||
Py_NoSiteFlag= 1;
|
||||
|
||||
Py_Initialize();
|
||||
@@ -215,8 +222,11 @@ void BPY_python_start(int argc, const char **argv)
|
||||
{
|
||||
int i;
|
||||
PyObject *py_argv= PyList_New(argc);
|
||||
for (i=0; i<argc; i++)
|
||||
PyList_SET_ITEM(py_argv, i, PyC_UnicodeFromByte(argv[i])); /* should fix bug #20021 - utf path name problems, by replacing PyUnicode_FromString */
|
||||
for (i=0; i<argc; i++) {
|
||||
/* should fix bug #20021 - utf path name problems, by replacing
|
||||
* PyUnicode_FromString, with this one */
|
||||
PyList_SET_ITEM(py_argv, i, PyC_UnicodeFromByte(argv[i]));
|
||||
}
|
||||
|
||||
PySys_SetObject("argv", py_argv);
|
||||
Py_DECREF(py_argv);
|
||||
@@ -671,7 +681,7 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
|
||||
|
||||
|
||||
#ifdef WITH_PYTHON_MODULE
|
||||
#include "BLI_storage.h"
|
||||
#include "BLI_fileops.h"
|
||||
/* TODO, reloading the module isnt functional at the moment. */
|
||||
|
||||
static void bpy_module_free(void *mod);
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "../generic/bpy_internal_import.h"
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
#include "BLI_string.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_enum_types.h"
|
||||
|
||||
@@ -810,7 +810,7 @@ static PyObject *pyrna_struct_str(BPy_StructRNA *self)
|
||||
}
|
||||
|
||||
/* print name if available */
|
||||
name= RNA_struct_name_get_alloc(&self->ptr, NULL, FALSE);
|
||||
name= RNA_struct_name_get_alloc(&self->ptr, NULL, 0, NULL);
|
||||
if (name) {
|
||||
ret= PyUnicode_FromFormat("<bpy_struct, %.200s(\"%.200s\")>",
|
||||
RNA_struct_identifier(self->ptr.type),
|
||||
@@ -901,7 +901,7 @@ static PyObject *pyrna_prop_str(BPy_PropertyRNA *self)
|
||||
/* if a pointer, try to print name of pointer target too */
|
||||
if (RNA_property_type(self->prop) == PROP_POINTER) {
|
||||
ptr= RNA_property_pointer_get(&self->ptr, self->prop);
|
||||
name= RNA_struct_name_get_alloc(&ptr, NULL, FALSE);
|
||||
name= RNA_struct_name_get_alloc(&ptr, NULL, 0, NULL);
|
||||
|
||||
if (name) {
|
||||
ret= PyUnicode_FromFormat("<bpy_%.200s, %.200s.%.200s(\"%.200s\")>",
|
||||
@@ -1257,14 +1257,22 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
|
||||
ret= PyUnicode_FromString(enum_item->identifier);
|
||||
}
|
||||
else {
|
||||
const char *ptr_name= RNA_struct_name_get_alloc(ptr, NULL, FALSE);
|
||||
const char *ptr_name= RNA_struct_name_get_alloc(ptr, NULL, 0, NULL);
|
||||
|
||||
/* prefer not fail silently incase of api errors, maybe disable it later */
|
||||
printf("RNA Warning: Current value \"%d\" matches no enum in '%s', '%s', '%s'\n", val, RNA_struct_identifier(ptr->type), ptr_name, RNA_property_identifier(prop));
|
||||
printf("RNA Warning: Current value \"%d\" "
|
||||
"matches no enum in '%s', '%s', '%s'\n",
|
||||
val, RNA_struct_identifier(ptr->type),
|
||||
ptr_name, RNA_property_identifier(prop));
|
||||
|
||||
#if 0 // gives python decoding errors while generating docs :(
|
||||
char error_str[256];
|
||||
BLI_snprintf(error_str, sizeof(error_str), "RNA Warning: Current value \"%d\" matches no enum in '%s', '%s', '%s'", val, RNA_struct_identifier(ptr->type), ptr_name, RNA_property_identifier(prop));
|
||||
BLI_snprintf(error_str, sizeof(error_str),
|
||||
"RNA Warning: Current value \"%d\" "
|
||||
"matches no enum in '%s', '%s', '%s'",
|
||||
val, RNA_struct_identifier(ptr->type),
|
||||
ptr_name, RNA_property_identifier(prop));
|
||||
|
||||
PyErr_Warn(PyExc_RuntimeWarning, error_str);
|
||||
#endif
|
||||
|
||||
@@ -1311,19 +1319,20 @@ PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
|
||||
{
|
||||
int subtype= RNA_property_subtype(prop);
|
||||
const char *buf;
|
||||
int buf_len;
|
||||
char buf_fixed[32];
|
||||
|
||||
buf= RNA_property_string_get_alloc(ptr, prop, buf_fixed, sizeof(buf_fixed));
|
||||
buf= RNA_property_string_get_alloc(ptr, prop, buf_fixed, sizeof(buf_fixed), &buf_len);
|
||||
#ifdef USE_STRING_COERCE
|
||||
/* only file paths get special treatment, they may contain non utf-8 chars */
|
||||
if (ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) {
|
||||
ret= PyC_UnicodeFromByte(buf);
|
||||
ret= PyC_UnicodeFromByteAndSize(buf, buf_len);
|
||||
}
|
||||
else {
|
||||
ret= PyUnicode_FromString(buf);
|
||||
ret= PyUnicode_FromStringAndSize(buf, buf_len);
|
||||
}
|
||||
#else // USE_STRING_COERCE
|
||||
ret= PyUnicode_FromString(buf);
|
||||
ret= PyUnicode_FromStringAndSize(buf, buf_len);
|
||||
#endif // USE_STRING_COERCE
|
||||
if (buf_fixed != buf) {
|
||||
MEM_freeN((void *)buf);
|
||||
@@ -1534,7 +1543,7 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
|
||||
param= _PyUnicode_AsString(value);
|
||||
#ifdef WITH_INTERNATIONAL
|
||||
if (subtype == PROP_TRANSLATE) {
|
||||
param= UI_translate_do_iface(param);
|
||||
param= IFACE_(param);
|
||||
}
|
||||
#endif // WITH_INTERNATIONAL
|
||||
|
||||
@@ -3127,14 +3136,15 @@ static void pyrna_dir_members_rna(PyObject *list, PointerRNA *ptr)
|
||||
* Collect RNA attributes
|
||||
*/
|
||||
char name[256], *nameptr;
|
||||
int namelen;
|
||||
|
||||
iterprop= RNA_struct_iterator_property(ptr->type);
|
||||
|
||||
RNA_PROP_BEGIN(ptr, itemptr, iterprop) {
|
||||
nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name));
|
||||
nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name), &namelen);
|
||||
|
||||
if (nameptr) {
|
||||
pystring= PyUnicode_FromString(nameptr);
|
||||
pystring= PyUnicode_FromStringAndSize(nameptr, namelen);
|
||||
PyList_Append(list, pystring);
|
||||
Py_DECREF(pystring);
|
||||
|
||||
@@ -3716,13 +3726,14 @@ static PyObject *pyrna_prop_collection_keys(BPy_PropertyRNA *self)
|
||||
PyObject *ret= PyList_New(0);
|
||||
PyObject *item;
|
||||
char name[256], *nameptr;
|
||||
int namelen;
|
||||
|
||||
RNA_PROP_BEGIN(&self->ptr, itemptr, self->prop) {
|
||||
nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name));
|
||||
nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name), &namelen);
|
||||
|
||||
if (nameptr) {
|
||||
/* add to python list */
|
||||
item= PyUnicode_FromString(nameptr);
|
||||
item= PyUnicode_FromStringAndSize(nameptr, namelen);
|
||||
PyList_Append(ret, item);
|
||||
Py_DECREF(item);
|
||||
/* done */
|
||||
@@ -3751,15 +3762,16 @@ static PyObject *pyrna_prop_collection_items(BPy_PropertyRNA *self)
|
||||
PyObject *ret= PyList_New(0);
|
||||
PyObject *item;
|
||||
char name[256], *nameptr;
|
||||
int namelen;
|
||||
int i= 0;
|
||||
|
||||
RNA_PROP_BEGIN(&self->ptr, itemptr, self->prop) {
|
||||
if (itemptr.data) {
|
||||
/* add to python list */
|
||||
item= PyTuple_New(2);
|
||||
nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name));
|
||||
nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name), &namelen);
|
||||
if (nameptr) {
|
||||
PyTuple_SET_ITEM(item, 0, PyUnicode_FromString(nameptr));
|
||||
PyTuple_SET_ITEM(item, 0, PyUnicode_FromStringAndSize(nameptr, namelen));
|
||||
if (name != nameptr)
|
||||
MEM_freeN(nameptr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user