Merged changes in the trunk up to revision 27647.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* $Id:
|
||||
* $Id$
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
@@ -25,7 +25,6 @@
|
||||
/* This file defines the '_bpy' module which is used by python's 'bpy' package.
|
||||
* a script writer should never directly access this module */
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#include "bpy_util.h"
|
||||
#include "bpy_rna.h"
|
||||
@@ -36,7 +35,6 @@
|
||||
#include "BLI_path_util.h"
|
||||
|
||||
/* external util modules */
|
||||
#include "../generic/Mathutils.h"
|
||||
#include "../generic/Geometry.h"
|
||||
#include "../generic/bgl.h"
|
||||
#include "../generic/blf.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* $Id:
|
||||
* $Id$
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* $Id:
|
||||
* $Id$
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
@@ -23,7 +23,6 @@
|
||||
*/
|
||||
|
||||
#include "bpy_app.h"
|
||||
#include "bpy_util.h"
|
||||
|
||||
#include "BLI_path_util.h"
|
||||
|
||||
@@ -32,11 +31,11 @@
|
||||
#include "structseq.h"
|
||||
|
||||
#ifdef BUILD_DATE
|
||||
extern const char * build_date;
|
||||
extern const char * build_time;
|
||||
extern const char * build_rev;
|
||||
extern const char * build_platform;
|
||||
extern const char * build_type;
|
||||
extern char build_date[];
|
||||
extern char build_time[];
|
||||
extern char build_rev[];
|
||||
extern char build_platform[];
|
||||
extern char build_type[];
|
||||
#endif
|
||||
|
||||
static PyTypeObject BlenderAppType;
|
||||
@@ -64,24 +63,9 @@ static PyStructSequence_Desc app_info_desc = {
|
||||
10
|
||||
};
|
||||
|
||||
static char *strip_quotes(char *buf, const char *input)
|
||||
{
|
||||
int i;
|
||||
strcpy(buf, input);
|
||||
if(buf[0]=='\0') return buf;
|
||||
while(buf[1] && (buf[0]=='"' || buf[0]=='\'')) buf++;
|
||||
if(buf[0]=='\0') return buf;
|
||||
i= strlen(buf) - 1;
|
||||
while(i>=0 && (buf[i]=='"' || buf[i]=='\'')) i--;
|
||||
buf[i+1]= '\0';
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
static PyObject *make_app_info(void)
|
||||
{
|
||||
extern char bprogname[]; /* argv[0] from creator.c */
|
||||
char buf[256];
|
||||
|
||||
PyObject *app_info;
|
||||
int pos = 0;
|
||||
@@ -106,17 +90,17 @@ static PyObject *make_app_info(void)
|
||||
|
||||
/* build info */
|
||||
#ifdef BUILD_DATE
|
||||
SetStrItem(strip_quotes(buf, build_date));
|
||||
SetStrItem(strip_quotes(buf, build_time));
|
||||
SetStrItem(strip_quotes(buf, build_rev));
|
||||
SetStrItem(strip_quotes(buf, build_platform));
|
||||
SetStrItem(strip_quotes(buf, build_type));
|
||||
SetStrItem(build_date);
|
||||
SetStrItem(build_time);
|
||||
SetStrItem(build_rev);
|
||||
SetStrItem(build_platform);
|
||||
SetStrItem(build_type);
|
||||
#else
|
||||
SetStrItem(strip_quotes(buf, "Unknown"));
|
||||
SetStrItem(strip_quotes(buf, "Unknown"));
|
||||
SetStrItem(strip_quotes(buf, "Unknown"));
|
||||
SetStrItem(strip_quotes(buf, "Unknown"));
|
||||
SetStrItem(strip_quotes(buf, "Unknown"));
|
||||
SetStrItem("Unknown");
|
||||
SetStrItem("Unknown");
|
||||
SetStrItem("Unknown");
|
||||
SetStrItem("Unknown");
|
||||
SetStrItem("Unknown");
|
||||
#endif
|
||||
|
||||
#undef SetIntItem
|
||||
|
||||
@@ -22,14 +22,7 @@
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
#include "bpy_rna.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "BLI_string.h"
|
||||
|
||||
#include "BKE_global.h"
|
||||
|
||||
#define MAX_ARRAY_DIMENSION 10
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* $Id:
|
||||
* $Id$
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
@@ -27,8 +27,8 @@
|
||||
#include "DNA_anim_types.h"
|
||||
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_math_base.h"
|
||||
|
||||
#include "BPY_extern.h"
|
||||
#include "BKE_fcurve.h"
|
||||
#include "BKE_global.h"
|
||||
|
||||
@@ -153,22 +153,19 @@ float BPY_pydriver_eval (ChannelDriver *driver)
|
||||
PyGILState_STATE gilstate;
|
||||
|
||||
DriverVar *dvar;
|
||||
float result = 0.0f; /* default return */
|
||||
double result = 0.0; /* default return */
|
||||
char *expr = NULL;
|
||||
short targets_ok= 1;
|
||||
int i;
|
||||
|
||||
/* sanity checks - should driver be executed? */
|
||||
/*if (G.f & G_SCRIPT_AUTOEXEC)==0) return result; */
|
||||
|
||||
/* get the py expression to be evaluated */
|
||||
expr = driver->expression;
|
||||
if ((expr == NULL) || (expr[0]=='\0'))
|
||||
return result;
|
||||
return 0.0f;
|
||||
|
||||
if(!(G.f & G_SCRIPT_AUTOEXEC)) {
|
||||
printf("skipping driver '%s', automatic scripts are disabled\n", driver->expression);
|
||||
return result;
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
gilstate = PyGILState_Ensure();
|
||||
@@ -178,7 +175,7 @@ float BPY_pydriver_eval (ChannelDriver *driver)
|
||||
if (bpy_pydriver_create_dict() != 0) {
|
||||
fprintf(stderr, "Pydriver error: couldn't create Python dictionary");
|
||||
PyGILState_Release(gilstate);
|
||||
return result;
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,7 +236,7 @@ float BPY_pydriver_eval (ChannelDriver *driver)
|
||||
targets_ok= 0;
|
||||
}
|
||||
|
||||
fprintf(stderr, "\tBPY_pydriver_eval() - couldn't add variable '%s' to namespace \n", dvar->name);
|
||||
fprintf(stderr, "\tBPY_pydriver_eval() - couldn't add variable '%s' to namespace\n", dvar->name);
|
||||
// BPy_errors_to_report(NULL); // TODO - reports
|
||||
PyErr_Print();
|
||||
PyErr_Clear();
|
||||
@@ -261,12 +258,10 @@ float BPY_pydriver_eval (ChannelDriver *driver)
|
||||
/* process the result */
|
||||
if (retval == NULL) {
|
||||
pydriver_error(driver);
|
||||
result = 0.0f;
|
||||
} else if((result= (float)PyFloat_AsDouble(retval)) == -1.0f && PyErr_Occurred()) {
|
||||
} else if((result= PyFloat_AsDouble(retval)) == -1.0 && PyErr_Occurred()) {
|
||||
pydriver_error(driver);
|
||||
Py_DECREF(retval);
|
||||
result = 0.0f;
|
||||
|
||||
result = 0.0;
|
||||
}
|
||||
else {
|
||||
/* all fine, make sure the "invalid expression" flag is cleared */
|
||||
@@ -275,5 +270,12 @@ float BPY_pydriver_eval (ChannelDriver *driver)
|
||||
}
|
||||
|
||||
PyGILState_Release(gilstate);
|
||||
return result;
|
||||
|
||||
if(finite(result)) {
|
||||
return (float)result;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "\tBPY_pydriver_eval() - driver '%s' evaluates to '%f'\n", dvar->name, result);
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* $Id:
|
||||
* $Id$
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
@@ -23,10 +23,6 @@
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
|
||||
/* grr, python redefines */
|
||||
@@ -34,33 +30,20 @@
|
||||
#undef _POSIX_C_SOURCE
|
||||
#endif
|
||||
|
||||
#include <Python.h>
|
||||
#include "compile.h" /* for the PyCodeObject */
|
||||
#include "eval.h" /* for PyEval_EvalCode */
|
||||
|
||||
#include "bpy.h"
|
||||
#include "bpy_rna.h"
|
||||
#include "bpy_util.h"
|
||||
|
||||
#ifndef WIN32
|
||||
#include <dirent.h>
|
||||
#else
|
||||
#include "BLI_winstuff.h"
|
||||
#endif
|
||||
|
||||
#include "DNA_space_types.h"
|
||||
#include "DNA_text_types.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_storage.h"
|
||||
#include "BLI_fileops.h"
|
||||
#include "BLI_string.h"
|
||||
#include "BLI_path_util.h"
|
||||
#include "BLI_math_base.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_text.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_global.h" /* only for script checking */
|
||||
|
||||
@@ -544,12 +527,6 @@ int BPY_run_python_script_space(const char *modulename, const char *func)
|
||||
}
|
||||
#endif
|
||||
|
||||
// #define TIME_REGISTRATION
|
||||
|
||||
#ifdef TIME_REGISTRATION
|
||||
#include "PIL_time.h"
|
||||
#endif
|
||||
|
||||
|
||||
int BPY_button_eval(bContext *C, char *expr, double *value)
|
||||
{
|
||||
@@ -604,6 +581,9 @@ int BPY_button_eval(bContext *C, char *expr, double *value)
|
||||
if(val==-1 && PyErr_Occurred()) {
|
||||
error_ret= -1;
|
||||
}
|
||||
else if (!finite(val)) {
|
||||
*value= 0.0;
|
||||
}
|
||||
else {
|
||||
*value= val;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
#include "BKE_report.h"
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
|
||||
static PyObject *pyop_call( PyObject * self, PyObject * args)
|
||||
|
||||
@@ -24,15 +24,12 @@
|
||||
*/
|
||||
|
||||
#include "bpy_operator_wrap.h"
|
||||
#include "BKE_context.h"
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "RNA_define.h"
|
||||
|
||||
#include "bpy_rna.h"
|
||||
#include "bpy_props.h"
|
||||
#include "bpy_util.h"
|
||||
|
||||
static void operator_properties_init(wmOperatorType *ot)
|
||||
{
|
||||
@@ -114,7 +111,7 @@ PyObject *PYOP_wrap_macro_define(PyObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
/* identifiers */
|
||||
srna= srna_from_self(macro);
|
||||
srna= srna_from_self(macro, "Macro Define:");
|
||||
macroname = RNA_struct_identifier(srna);
|
||||
|
||||
ot = WM_operatortype_exists(macroname);
|
||||
|
||||
@@ -26,14 +26,11 @@
|
||||
#include "bpy_rna.h"
|
||||
#include "bpy_util.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_define.h" /* for defining our own rna */
|
||||
#include "RNA_enum_types.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "float.h" /* FLT_MIN/MAX */
|
||||
|
||||
EnumPropertyItem property_flag_items[] = {
|
||||
{PROP_HIDDEN, "HIDDEN", 0, "Hidden", ""},
|
||||
{PROP_ANIMATABLE, "ANIMATABLE", 0, "Animateable", ""},
|
||||
@@ -118,7 +115,7 @@ PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
srna= srna_from_self(self);
|
||||
srna= srna_from_self(self, "BoolProperty(...):");
|
||||
if(srna==NULL && PyErr_Occurred()) {
|
||||
return NULL; /* self's type was compatible but error getting the srna */
|
||||
}
|
||||
@@ -184,7 +181,7 @@ PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
srna= srna_from_self(self);
|
||||
srna= srna_from_self(self, "BoolVectorProperty(...):");
|
||||
if(srna==NULL && PyErr_Occurred()) {
|
||||
return NULL; /* self's type was compatible but error getting the srna */
|
||||
}
|
||||
@@ -261,7 +258,7 @@ PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
srna= srna_from_self(self);
|
||||
srna= srna_from_self(self, "IntProperty(...):");
|
||||
if(srna==NULL && PyErr_Occurred()) {
|
||||
return NULL; /* self's type was compatible but error getting the srna */
|
||||
}
|
||||
@@ -328,7 +325,7 @@ PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
srna= srna_from_self(self);
|
||||
srna= srna_from_self(self, "IntVectorProperty(...):");
|
||||
if(srna==NULL && PyErr_Occurred()) {
|
||||
return NULL; /* self's type was compatible but error getting the srna */
|
||||
}
|
||||
@@ -409,7 +406,7 @@ PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
srna= srna_from_self(self);
|
||||
srna= srna_from_self(self, "FloatProperty(...):");
|
||||
if(srna==NULL && PyErr_Occurred()) {
|
||||
return NULL; /* self's type was compatible but error getting the srna */
|
||||
}
|
||||
@@ -484,7 +481,7 @@ PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
srna= srna_from_self(self);
|
||||
srna= srna_from_self(self, "FloatVectorProperty(...):");
|
||||
if(srna==NULL && PyErr_Occurred()) {
|
||||
return NULL; /* self's type was compatible but error getting the srna */
|
||||
}
|
||||
@@ -562,7 +559,7 @@ PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
srna= srna_from_self(self);
|
||||
srna= srna_from_self(self, "StringProperty(...):");
|
||||
if(srna==NULL && PyErr_Occurred()) {
|
||||
return NULL; /* self's type was compatible but error getting the srna */
|
||||
}
|
||||
@@ -674,7 +671,7 @@ PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
srna= srna_from_self(self);
|
||||
srna= srna_from_self(self, "EnumProperty(...):");
|
||||
if(srna==NULL && PyErr_Occurred()) {
|
||||
return NULL; /* self's type was compatible but error getting the srna */
|
||||
}
|
||||
@@ -719,18 +716,22 @@ PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
}
|
||||
}
|
||||
|
||||
static StructRNA *pointer_type_from_py(PyObject *value)
|
||||
static StructRNA *pointer_type_from_py(PyObject *value, const char *error_prefix)
|
||||
{
|
||||
StructRNA *srna;
|
||||
|
||||
srna= srna_from_self(value);
|
||||
srna= srna_from_self(value, "BoolProperty(...):");
|
||||
if(!srna) {
|
||||
PyErr_SetString(PyExc_SystemError, "expected an RNA type derived from IDPropertyGroup");
|
||||
|
||||
PyObject *msg= BPY_exception_buffer();
|
||||
char *msg_char= _PyUnicode_AsString(msg);
|
||||
PyErr_Format(PyExc_TypeError, "%.200s expected an RNA type derived from IDPropertyGroup, failed with: %s", error_prefix, msg_char);
|
||||
Py_DECREF(msg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!RNA_struct_is_a(srna, &RNA_IDPropertyGroup)) {
|
||||
PyErr_SetString(PyExc_SystemError, "expected an RNA type derived from IDPropertyGroup");
|
||||
PyErr_Format(PyExc_SystemError, "%.200s expected an RNA type derived from IDPropertyGroup", error_prefix);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -755,7 +756,7 @@ PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
srna= srna_from_self(self);
|
||||
srna= srna_from_self(self, "PointerProperty(...):");
|
||||
if(srna==NULL && PyErr_Occurred()) {
|
||||
return NULL; /* self's type was compatible but error getting the srna */
|
||||
}
|
||||
@@ -780,7 +781,7 @@ PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "PointerProperty(options={...}):"))
|
||||
return NULL;
|
||||
|
||||
ptype= pointer_type_from_py(type);
|
||||
ptype= pointer_type_from_py(type, "PointerProperty(...):");
|
||||
if(!ptype)
|
||||
return NULL;
|
||||
|
||||
@@ -816,7 +817,7 @@ PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
srna= srna_from_self(self);
|
||||
srna= srna_from_self(self, "CollectionProperty(...):");
|
||||
if(srna==NULL && PyErr_Occurred()) {
|
||||
return NULL; /* self's type was compatible but error getting the srna */
|
||||
}
|
||||
@@ -841,7 +842,7 @@ PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw)
|
||||
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "CollectionProperty(options={...}):"))
|
||||
return NULL;
|
||||
|
||||
ptype= pointer_type_from_py(type);
|
||||
ptype= pointer_type_from_py(type, "CollectionProperty(...):");
|
||||
if(!ptype)
|
||||
return NULL;
|
||||
|
||||
|
||||
@@ -30,11 +30,8 @@
|
||||
//#include "blendef.h"
|
||||
#include "BLI_dynstr.h"
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_string.h"
|
||||
#include "float.h" /* FLT_MIN/MAX */
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_define.h" /* for defining our own rna */
|
||||
#include "RNA_enum_types.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
@@ -57,7 +54,6 @@
|
||||
#include "../generic/Mathutils.h" /* so we can have mathutils callbacks */
|
||||
#include "../generic/IDProp.h" /* for IDprop lookups */
|
||||
|
||||
#include <string.h>
|
||||
|
||||
static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyRNA *self, PointerRNA *ptr, PropertyRNA *prop, int start, int stop, int length);
|
||||
static Py_ssize_t pyrna_prop_array_length(BPy_PropertyRNA *self);
|
||||
@@ -363,7 +359,7 @@ static PyObject *pyrna_struct_repr( BPy_StructRNA *self )
|
||||
return pyob;
|
||||
}
|
||||
|
||||
return PyUnicode_FromFormat( "<bpy_struct, %.200s>", RNA_struct_identifier(self->ptr.type));
|
||||
return PyUnicode_FromFormat( "<bpy_struct, %.200s at %p>", RNA_struct_identifier(self->ptr.type), self->ptr.data);
|
||||
}
|
||||
|
||||
static PyObject *pyrna_prop_repr( BPy_PropertyRNA *self )
|
||||
@@ -772,7 +768,7 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, v
|
||||
} else /* continue... */
|
||||
#endif
|
||||
if (!PySequence_Check(value)) {
|
||||
PyErr_Format(PyExc_TypeError, "%.200s RNA array assignment expected a sequence instead of %.200s instance.", error_prefix, Py_TYPE(value)->tp_name);
|
||||
PyErr_Format(PyExc_TypeError, "%.200s RNA array assignment to %.200s.%.200s expected a sequence instead of %.200s instance.", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
/* done getting the length */
|
||||
@@ -800,7 +796,7 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, v
|
||||
param = PyLong_AsSsize_t( value );
|
||||
|
||||
if( param < 0 || param > 1) {
|
||||
PyErr_Format(PyExc_TypeError, "%.200s expected True/False or 0/1", error_prefix);
|
||||
PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected True/False or 0/1", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
|
||||
return -1;
|
||||
} else {
|
||||
if(data) *((int*)data)= param;
|
||||
@@ -812,7 +808,7 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, v
|
||||
{
|
||||
int param = PyLong_AsSsize_t(value);
|
||||
if (param==-1 && PyErr_Occurred()) {
|
||||
PyErr_Format(PyExc_TypeError, "%.200s expected an int type", error_prefix);
|
||||
PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected an int type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
|
||||
return -1;
|
||||
} else {
|
||||
RNA_property_int_clamp(ptr, prop, ¶m);
|
||||
@@ -825,7 +821,7 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, v
|
||||
{
|
||||
float param = PyFloat_AsDouble(value);
|
||||
if (PyErr_Occurred()) {
|
||||
PyErr_Format(PyExc_TypeError, "%.200s expected a float type", error_prefix);
|
||||
PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a float type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
|
||||
return -1;
|
||||
} else {
|
||||
RNA_property_float_clamp(ptr, prop, (float *)¶m);
|
||||
@@ -839,7 +835,7 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, v
|
||||
char *param = _PyUnicode_AsString(value);
|
||||
|
||||
if (param==NULL) {
|
||||
PyErr_Format(PyExc_TypeError, "%.200s expected a string type", error_prefix);
|
||||
PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a string type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
|
||||
return -1;
|
||||
} else {
|
||||
if(data) *((char**)data)= param;
|
||||
@@ -868,7 +864,7 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, v
|
||||
}
|
||||
else {
|
||||
char *enum_str= pyrna_enum_as_string(ptr, prop);
|
||||
PyErr_Format(PyExc_TypeError, "%.200s expected a string enum or a set of strings in (%.200s)", error_prefix, enum_str);
|
||||
PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a string enum or a set of strings in (%.2000s)", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), enum_str);
|
||||
MEM_freeN(enum_str);
|
||||
return -1;
|
||||
}
|
||||
@@ -890,13 +886,13 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, v
|
||||
}
|
||||
|
||||
if(!BPy_StructRNA_Check(value) && value != Py_None) {
|
||||
PyErr_Format(PyExc_TypeError, "%.200s expected a %.200s type", error_prefix, RNA_struct_identifier(ptype));
|
||||
PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a %.200s type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), RNA_struct_identifier(ptype));
|
||||
return -1;
|
||||
} else if((flag & PROP_NEVER_NULL) && value == Py_None) {
|
||||
PyErr_Format(PyExc_TypeError, "%.200s does not support a 'None' assignment %.200s type", error_prefix, RNA_struct_identifier(ptype));
|
||||
PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s does not support a 'None' assignment %.200s type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), RNA_struct_identifier(ptype));
|
||||
return -1;
|
||||
} else if(value != Py_None && ((flag & PROP_ID_SELF_CHECK) && ptr->id.data == ((BPy_StructRNA*)value)->ptr.id.data)) {
|
||||
PyErr_Format(PyExc_TypeError, "%.200s ID type does not support assignment to its self", error_prefix);
|
||||
PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s ID type does not support assignment to its self", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
|
||||
return -1;
|
||||
} else {
|
||||
BPy_StructRNA *param= (BPy_StructRNA*)value;
|
||||
@@ -932,7 +928,7 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, v
|
||||
else {
|
||||
PointerRNA tmp;
|
||||
RNA_pointer_create(NULL, ptype, NULL, &tmp);
|
||||
PyErr_Format(PyExc_TypeError, "%.200s expected a %.200s type", error_prefix, RNA_struct_identifier(tmp.type));
|
||||
PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a %.200s type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), RNA_struct_identifier(tmp.type));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -940,7 +936,7 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, v
|
||||
if(raise_error) {
|
||||
PointerRNA tmp;
|
||||
RNA_pointer_create(NULL, ptype, NULL, &tmp);
|
||||
PyErr_Format(PyExc_TypeError, "%.200s expected a %.200s type", error_prefix, RNA_struct_identifier(tmp.type));
|
||||
PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a %.200s type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), RNA_struct_identifier(tmp.type));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -958,15 +954,22 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, v
|
||||
|
||||
/* convert a sequence of dict's into a collection */
|
||||
if(!PySequence_Check(value)) {
|
||||
PyErr_Format(PyExc_TypeError, "%.200s expected a sequence of dicts for an RNA collection", error_prefix);
|
||||
PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a sequence for an RNA collection, found a '%.200s' instead", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
seq_len = PySequence_Length(value);
|
||||
for(i=0; i<seq_len; i++) {
|
||||
item= PySequence_GetItem(value, i);
|
||||
if(item==NULL || PyDict_Check(item)==0) {
|
||||
PyErr_Format(PyExc_TypeError, "%.200s expected a sequence of dicts for an RNA collection", error_prefix);
|
||||
|
||||
if(item==NULL) {
|
||||
PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s failed to get sequence index '%d' for an RNA collection", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), i);
|
||||
Py_XDECREF(item);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(PyDict_Check(item)==0) {
|
||||
PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a each sequence member to be a dict for an RNA collection, found a '%.200s' instead", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), Py_TYPE(item)->tp_name);
|
||||
Py_XDECREF(item);
|
||||
return -1;
|
||||
}
|
||||
@@ -980,7 +983,13 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, v
|
||||
RNA_property_collection_add(ptr, prop, &itemptr);
|
||||
|
||||
if(pyrna_pydict_to_props(&itemptr, item, 1, "Converting a python list to an RNA collection")==-1) {
|
||||
PyObject *msg= BPY_exception_buffer();
|
||||
char *msg_char= _PyUnicode_AsString(msg);
|
||||
|
||||
PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s error converting a member of a collection from a dicts into an RNA collection, failed with: %s", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), msg_char);
|
||||
|
||||
Py_DECREF(item);
|
||||
Py_DECREF(msg);
|
||||
return -1;
|
||||
}
|
||||
Py_DECREF(item);
|
||||
@@ -989,7 +998,7 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, v
|
||||
break;
|
||||
}
|
||||
default:
|
||||
PyErr_Format(PyExc_AttributeError, "%.200s unknown property type (pyrna_py_to_prop)", error_prefix);
|
||||
PyErr_Format(PyExc_AttributeError, "%.200s %.200s.%.200s unknown property type (pyrna_py_to_prop)", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
@@ -1654,8 +1663,9 @@ int pyrna_struct_keyframe_parse(PointerRNA *ptr, PyObject *args, char *error_pre
|
||||
{
|
||||
char *path;
|
||||
PropertyRNA *prop;
|
||||
int array_len;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s|if", &path, &index, &cfra)) {
|
||||
if (!PyArg_ParseTuple(args, "s|if", &path, index, cfra)) {
|
||||
PyErr_Format(PyExc_TypeError, "%.200s expected a string and optionally an int and float arguments", error_prefix);
|
||||
return -1;
|
||||
}
|
||||
@@ -1684,6 +1694,12 @@ int pyrna_struct_keyframe_parse(PointerRNA *ptr, PyObject *args, char *error_pre
|
||||
return -1;
|
||||
}
|
||||
|
||||
array_len= RNA_property_array_length(ptr, prop);
|
||||
if((*index) != -1 && (*index) >= array_len) {
|
||||
PyErr_Format( PyExc_TypeError, "%.200s index out of range \"%s\", given %d, array length is %d", error_prefix, path, *index, array_len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(*cfra==FLT_MAX)
|
||||
*cfra= CTX_data_scene(BPy_GetContext())->r.cfra;
|
||||
|
||||
@@ -1859,7 +1875,7 @@ static PyObject *pyrna_struct_path_to_id(BPy_StructRNA *self, PyObject *args)
|
||||
|
||||
if(path==NULL) {
|
||||
if(name) PyErr_Format(PyExc_TypeError, "%.200s.path_to_id(\"%s\") found but does not support path creation", RNA_struct_identifier(self->ptr.type), name);
|
||||
else PyErr_Format(PyExc_TypeError, "%.200s.path_to_id() does not support path creation for this type", name);
|
||||
else PyErr_Format(PyExc_TypeError, "%.200s.path_to_id() does not support path creation for this type", RNA_struct_identifier(self->ptr.type));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -3528,26 +3544,6 @@ static void pyrna_subtype_set_rna(PyObject *newclass, StructRNA *srna)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
static StructRNA *srna_from_self(PyObject *self);
|
||||
PyObject *BPy_GetStructRNA(PyObject *self)
|
||||
{
|
||||
StructRNA *srna= pyrna_struct_as_srna(self);
|
||||
PointerRNA ptr;
|
||||
PyObject *ret;
|
||||
|
||||
RNA_pointer_create(NULL, &RNA_Struct, srna, &ptr);
|
||||
ret= pyrna_struct_CreatePyObject(&ptr);
|
||||
|
||||
if(ret) {
|
||||
return ret;
|
||||
}
|
||||
else {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
static PyObject* pyrna_srna_Subtype(StructRNA *srna);
|
||||
|
||||
/* return a borrowed reference */
|
||||
@@ -3888,7 +3884,7 @@ PyObject *BPY_rna_types(void)
|
||||
return (PyObject *)self;
|
||||
}
|
||||
|
||||
StructRNA *pyrna_struct_as_srna(PyObject *self)
|
||||
StructRNA *pyrna_struct_as_srna(PyObject *self, int parent, const char *error_prefix)
|
||||
{
|
||||
BPy_StructRNA *py_srna = NULL;
|
||||
StructRNA *srna;
|
||||
@@ -3898,23 +3894,27 @@ StructRNA *pyrna_struct_as_srna(PyObject *self)
|
||||
py_srna = (BPy_StructRNA *)PyDict_GetItemString(((PyTypeObject *)self)->tp_dict, "bl_rna");
|
||||
Py_XINCREF(py_srna);
|
||||
}
|
||||
|
||||
if(py_srna==NULL)
|
||||
py_srna = (BPy_StructRNA*)PyObject_GetAttrString(self, "bl_rna");
|
||||
|
||||
if(parent) {
|
||||
/* be very careful with this since it will return a parent classes srna.
|
||||
* modifying this will do confusing stuff! */
|
||||
if(py_srna==NULL)
|
||||
py_srna = (BPy_StructRNA*)PyObject_GetAttrString(self, "bl_rna");
|
||||
}
|
||||
|
||||
if(py_srna==NULL) {
|
||||
PyErr_SetString(PyExc_SystemError, "internal error, self had no bl_rna attribute, should never happen.");
|
||||
PyErr_Format(PyExc_SystemError, "%.200s internal error, self of type '%.200s' had no bl_rna attribute, should never happen", error_prefix, Py_TYPE(self)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!BPy_StructRNA_Check(py_srna)) {
|
||||
PyErr_Format(PyExc_SystemError, "internal error, bl_rna was of type %.200s, instead of %.200s instance.", Py_TYPE(py_srna)->tp_name, pyrna_struct_Type.tp_name);
|
||||
PyErr_Format(PyExc_SystemError, "%.200s internal error, bl_rna was of type '%.200s', instead of %.200s instance", error_prefix, Py_TYPE(py_srna)->tp_name, pyrna_struct_Type.tp_name);
|
||||
Py_DECREF(py_srna);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(py_srna->ptr.type != &RNA_Struct) {
|
||||
PyErr_SetString(PyExc_SystemError, "internal error, bl_rna was not a RNA_Struct type of rna struct.");
|
||||
PyErr_Format(PyExc_SystemError, "%.200s internal error, bl_rna was not a RNA_Struct type of rna struct", error_prefix);
|
||||
Py_DECREF(py_srna);
|
||||
return NULL;
|
||||
}
|
||||
@@ -3928,7 +3928,7 @@ StructRNA *pyrna_struct_as_srna(PyObject *self)
|
||||
/* Orphan functions, not sure where they should go */
|
||||
/* get the srna for methods attached to types */
|
||||
/* */
|
||||
StructRNA *srna_from_self(PyObject *self)
|
||||
StructRNA *srna_from_self(PyObject *self, const char *error_prefix)
|
||||
{
|
||||
/* a bit sloppy but would cause a very confusing bug if
|
||||
* an error happened to be set here */
|
||||
@@ -3946,7 +3946,7 @@ StructRNA *srna_from_self(PyObject *self)
|
||||
/* These cases above not errors, they just mean the type was not compatible
|
||||
* After this any errors will be raised in the script */
|
||||
|
||||
return pyrna_struct_as_srna(self);
|
||||
return pyrna_struct_as_srna(self, 0, error_prefix);
|
||||
}
|
||||
|
||||
static int deferred_register_prop(StructRNA *srna, PyObject *item, PyObject *key, PyObject *dummy_args)
|
||||
@@ -4442,11 +4442,12 @@ PyObject *pyrna_basetype_register(PyObject *self, PyObject *py_class)
|
||||
const char *identifier= "";
|
||||
|
||||
if(PyDict_GetItemString(((PyTypeObject*)py_class)->tp_dict, "bl_rna")) {
|
||||
PyErr_SetString(PyExc_AttributeError, "bpy.types.register(): already registered as a subclass.");
|
||||
PyErr_SetString(PyExc_AttributeError, "bpy.types.register(...): already registered as a subclass.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
srna= pyrna_struct_as_srna(py_class);
|
||||
/* warning: gets parent classes srna, only for the register function */
|
||||
srna= pyrna_struct_as_srna(py_class, 1, "bpy.types.register(...):");
|
||||
if(srna==NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -4454,7 +4455,7 @@ PyObject *pyrna_basetype_register(PyObject *self, PyObject *py_class)
|
||||
reg= RNA_struct_register(srna);
|
||||
|
||||
if(!reg) {
|
||||
PyErr_SetString(PyExc_ValueError, "bpy.types.register(): expected a Type subclassed from a registerable rna type (no register supported).");
|
||||
PyErr_SetString(PyExc_ValueError, "bpy.types.register(...): expected a Type subclassed from a registerable rna type (no register supported).");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -4517,7 +4518,7 @@ PyObject *pyrna_basetype_unregister(PyObject *self, PyObject *py_class)
|
||||
return NULL;
|
||||
}*/
|
||||
|
||||
srna= pyrna_struct_as_srna(py_class);
|
||||
srna= pyrna_struct_as_srna(py_class, 0, "bpy.types.unregister(...):");
|
||||
if(srna==NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -4525,7 +4526,7 @@ PyObject *pyrna_basetype_unregister(PyObject *self, PyObject *py_class)
|
||||
unreg= RNA_struct_unregister(srna);
|
||||
|
||||
if(!unreg) {
|
||||
PyErr_SetString(PyExc_ValueError, "bpy.types.unregister(): expected a Type subclassed from a registerable rna type (no unregister supported).");
|
||||
PyErr_SetString(PyExc_ValueError, "bpy.types.unregister(...): expected a Type subclassed from a registerable rna type (no unregister supported).");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,8 +64,8 @@ typedef struct {
|
||||
/* cheap trick */
|
||||
#define BPy_BaseTypeRNA BPy_PropertyRNA
|
||||
|
||||
StructRNA *srna_from_self(PyObject *self);
|
||||
StructRNA *pyrna_struct_as_srna(PyObject *self);
|
||||
StructRNA *srna_from_self(PyObject *self, const char *error_prefix);
|
||||
StructRNA *pyrna_struct_as_srna(PyObject *self, int parent, const char *error_prefix);
|
||||
|
||||
void BPY_rna_init( void );
|
||||
PyObject *BPY_rna_module( void );
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* $Id:
|
||||
* $Id$
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
@@ -22,12 +22,10 @@
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
#include "bpy_rna.h"
|
||||
#include "bpy_util.h"
|
||||
|
||||
#include "BLI_path_util.h"
|
||||
#include "DNA_screen_types.h"
|
||||
#include "BKE_context.h"
|
||||
#include "ED_space_api.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* $Id:
|
||||
* $Id$
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include "DNA_listBase.h"
|
||||
#include "RNA_access.h"
|
||||
#include "bpy_util.h"
|
||||
#include "BLI_dynstr.h"
|
||||
#include "MEM_guardedalloc.h"
|
||||
@@ -245,8 +243,8 @@ PyObject *BPY_exception_buffer(void)
|
||||
|
||||
PyErr_Clear();
|
||||
|
||||
/* import StringIO / io
|
||||
* string_io = StringIO.StringIO()
|
||||
/* import io
|
||||
* string_io = io.StringIO()
|
||||
*/
|
||||
|
||||
if(! (string_io_mod= PyImport_ImportModule("io")) ) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* $Id:
|
||||
* $Id$
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user