Merged changes in the trunk up to revision 43038.

Conflicts resolved:
source/blender/makesdna/DNA_material_types.h
source/blenderplayer/bad_level_call_stubs/stubs.c
This commit is contained in:
2011-12-31 21:09:26 +00:00
273 changed files with 22999 additions and 10038 deletions

View File

@@ -47,5 +47,9 @@ if env['WITH_BF_INTERNATIONAL']:
if env['WITH_BF_CYCLES']:
defs.append('WITH_CYCLES')
if env['WITH_BF_FFMPEG']:
defs.append('WITH_FFMPEG')
incs += ' ' + env['BF_FFMPEG_INC']
sources = env.Glob('intern/*.c')
env.BlenderLib( libname = 'bf_python', sources = Split(sources), includes = Split(incs), defines = defs, libtype = ['core'], priority = [361])

View File

@@ -33,7 +33,7 @@ set(INC
../../makesdna
../../makesrna
../../windowmanager
../../gpu
../../gpu
../../freestyle/intern/python
../../../../intern/guardedalloc
)
@@ -43,9 +43,10 @@ set(INC_SYS
)
set(SRC
gpu.c
gpu.c
bpy.c
bpy_app.c
bpy_app_ffmpeg.c
bpy_app_handlers.c
bpy_driver.c
bpy_interface.c
@@ -63,9 +64,10 @@ set(SRC
bpy_util.c
stubs.c
gpu.h
gpu.h
bpy.h
bpy_app.h
bpy_app_ffmpeg.h
bpy_app_handlers.h
bpy_driver.h
bpy_intern_string.h
@@ -102,7 +104,15 @@ if(WITH_CYCLES)
endif()
if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
if(WITH_CODEC_FFMPEG)
list(APPEND INC_SYS
${FFMPEG_INCLUDE_DIRS}
)
add_definitions(-DWITH_FFMPEG)
endif()
blender_add_lib(bf_python "${SRC}" "${INC}" "${INC_SYS}")

View File

@@ -32,6 +32,9 @@
#include <Python.h>
#include "bpy_app.h"
#include "bpy_app_ffmpeg.h"
#include "bpy_app_handlers.h"
#include "bpy_driver.h"
@@ -79,6 +82,7 @@ static PyStructSequence_Field app_info_fields[] = {
{(char *)"build_system", (char *)"Build system used"},
/* submodules */
{(char *)"ffmpeg", (char *)"FFmpeg library information backend"},
{(char *)"handlers", (char *)"Application handler callbacks"},
{NULL}
};
@@ -147,6 +151,7 @@ static PyObject *make_app_info(void)
SetStrItem("Unknown");
#endif
SetObjItem(BPY_app_ffmpeg_struct());
SetObjItem(BPY_app_handlers_struct());
#undef SetIntItem

View File

@@ -0,0 +1,143 @@
/*
* ***** 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.
*
* Contributor(s): Sergey Sharybin
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file blender/python/intern/bpy_app_ffmpeg.c
* \ingroup pythonintern
*/
#include <Python.h>
#include "BLI_utildefines.h"
#include "BLI_callbacks.h"
#include "RNA_types.h"
#include "RNA_access.h"
#include "bpy_rna.h"
#ifdef WITH_FFMPEG
#include <libavcodec/avcodec.h>
#include <libavdevice/avdevice.h>
#include <libavformat/avformat.h>
#include <libavutil/avutil.h>
#include <libswscale/swscale.h>
#endif
static PyTypeObject BlenderAppFFmpegType;
#define DEF_FFMPEG_LIB_VERSION(lib) \
{(char *)(#lib "_version"), (char *)("The " #lib " version as a tuple of 3 numbers")}, \
{(char *)(#lib "_version_string"), (char *)("The " #lib " version formatted as a string")},
static PyStructSequence_Field app_ffmpeg_info_fields[] = {
{(char *)"supported", (char *)("Boolean, True when Blender is built with FFmpeg support")},
DEF_FFMPEG_LIB_VERSION(avcodec)
DEF_FFMPEG_LIB_VERSION(avdevice)
DEF_FFMPEG_LIB_VERSION(avformat)
DEF_FFMPEG_LIB_VERSION(avutil)
DEF_FFMPEG_LIB_VERSION(swscale)
{NULL}
};
#undef DEF_FFMPEG_LIB_VERSION
static PyStructSequence_Desc app_ffmpeg_info_desc = {
(char *)"bpy.app.ffmpeg", /* name */
(char *)"This module contains information about FFmpeg blender is linked against", /* doc */
app_ffmpeg_info_fields, /* fields */
(sizeof(app_ffmpeg_info_fields) / sizeof(PyStructSequence_Field)) - 1
};
static PyObject *make_ffmpeg_info(void)
{
PyObject *ffmpeg_info;
int pos = 0;
#ifdef WITH_FFMPEG
int curversion;
#endif
ffmpeg_info = PyStructSequence_New(&BlenderAppFFmpegType);
if (ffmpeg_info == NULL) {
return NULL;
}
#define SetIntItem(flag) \
PyStructSequence_SET_ITEM(ffmpeg_info, pos++, PyLong_FromLong(flag))
#define SetStrItem(str) \
PyStructSequence_SET_ITEM(ffmpeg_info, pos++, PyUnicode_FromString(str))
#define SetObjItem(obj) \
PyStructSequence_SET_ITEM(ffmpeg_info, pos++, obj)
#ifdef WITH_FFMPEG
#define FFMPEG_LIB_VERSION(lib) \
curversion = lib ## _version(); \
SetObjItem(Py_BuildValue("(iii)", \
curversion >> 16, (curversion >> 8) % 256, curversion % 256)); \
SetObjItem(PyUnicode_FromFormat("%2d, %2d, %2d", \
curversion >> 16, (curversion >> 8) % 256, curversion % 256));
#else
#define FFMPEG_LIB_VERSION(lib) \
SetStrItem("Unknown"); \
SetStrItem("Unknown");
#endif
#ifdef WITH_FFMPEG
SetObjItem(PyBool_FromLong(1));
#else
SetObjItem(PyBool_FromLong(0));
#endif
FFMPEG_LIB_VERSION(avcodec);
FFMPEG_LIB_VERSION(avdevice);
FFMPEG_LIB_VERSION(avformat);
FFMPEG_LIB_VERSION(avutil);
FFMPEG_LIB_VERSION(swscale);
#undef FFMPEG_LIB_VERSION
if (PyErr_Occurred()) {
Py_CLEAR(ffmpeg_info);
return NULL;
}
#undef SetIntItem
#undef SetStrItem
#undef SetObjItem
return ffmpeg_info;
}
PyObject *BPY_app_ffmpeg_struct(void)
{
PyObject *ret;
PyStructSequence_InitType(&BlenderAppFFmpegType, &app_ffmpeg_info_desc);
ret = make_ffmpeg_info();
/* prevent user from creating new instances */
BlenderAppFFmpegType.tp_init = NULL;
BlenderAppFFmpegType.tp_new = NULL;
BlenderAppFFmpegType.tp_hash = (hashfunc)_Py_HashPointer; /* without this we can't do set(sys.modules) [#29635] */
return ret;
}

View File

@@ -0,0 +1,32 @@
/*
* ***** 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.
*
* Contributor(s): Sergey Sharybin
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file blender/python/intern/bpy_app_ffmpeg.h
* \ingroup pythonintern
*/
#ifndef BPY_APP_FFMPEG_H
#define BPY_APP_FFMPEG_H
PyObject *BPY_app_ffmpeg_struct(void);
#endif // BPY_APP_FFMPEG_H

View File

@@ -395,7 +395,7 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
if (srna) {
static const char *kwlist[] = {"attr", "name", "description", "default",
"options", "subtype", "update", NULL};
const char *id = NULL, *name = "", *description = "";
const char *id = NULL, *name = NULL, *description = "";
int id_len;
int def = 0;
PropertyRNA *prop;
@@ -423,7 +423,7 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
prop = RNA_def_property(srna, id, PROP_BOOLEAN, subtype);
RNA_def_property_boolean_default(prop, def);
RNA_def_property_ui_text(prop, name, description);
RNA_def_property_ui_text(prop, name ? name : id, description);
if (pyopts) {
if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
@@ -463,7 +463,7 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
if (srna) {
static const char *kwlist[] = {"attr", "name", "description", "default",
"options", "subtype", "size", "update", NULL};
const char *id = NULL, *name = "", *description = "";
const char *id = NULL, *name = NULL, *description = "";
int id_len;
int def[PYRNA_STACK_ARRAY] = {0};
int size = 3;
@@ -501,11 +501,11 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
return NULL;
}
// prop = RNA_def_boolean_array(srna, id, size, pydef ? def:NULL, name, description);
// prop = RNA_def_boolean_array(srna, id, size, pydef ? def:NULL, name ? name : id, description);
prop = RNA_def_property(srna, id, PROP_BOOLEAN, subtype);
RNA_def_property_array(prop, size);
if (pydef) RNA_def_property_boolean_array_default(prop, def);
RNA_def_property_ui_text(prop, name, description);
RNA_def_property_ui_text(prop, name ? name : id, description);
if (pyopts) {
if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
@@ -541,7 +541,7 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
if (srna) {
static const char *kwlist[] = {"attr", "name", "description", "default",
"min", "max", "soft_min", "soft_max", "step", "options", "subtype", "update", NULL};
const char *id = NULL, *name = "", *description = "";
const char *id = NULL, *name = NULL, *description = "";
int id_len;
int min = INT_MIN, max = INT_MAX, soft_min = INT_MIN, soft_max = INT_MAX, step = 1, def = 0;
PropertyRNA *prop;
@@ -570,8 +570,8 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
prop = RNA_def_property(srna, id, PROP_INT, subtype);
RNA_def_property_int_default(prop, def);
RNA_def_property_ui_text(prop, name ? name : id, description);
RNA_def_property_range(prop, min, max);
RNA_def_property_ui_text(prop, name, description);
RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, 3);
if (pyopts) {
@@ -612,7 +612,7 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
static const char *kwlist[] = {"attr", "name", "description", "default",
"min", "max", "soft_min", "soft_max",
"step", "options", "subtype", "size", "update", NULL};
const char *id = NULL, *name = "", *description = "";
const char *id = NULL, *name = NULL, *description = "";
int id_len;
int min = INT_MIN, max = INT_MAX, soft_min = INT_MIN, soft_max = INT_MAX, step = 1;
int def[PYRNA_STACK_ARRAY] = {0};
@@ -657,7 +657,7 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
RNA_def_property_array(prop, size);
if (pydef) RNA_def_property_int_array_default(prop, def);
RNA_def_property_range(prop, min, max);
RNA_def_property_ui_text(prop, name, description);
RNA_def_property_ui_text(prop, name ? name : id, description);
RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, 3);
if (pyopts) {
@@ -696,7 +696,7 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
static const char *kwlist[] = {"attr", "name", "description", "default",
"min", "max", "soft_min", "soft_max",
"step", "precision", "options", "subtype", "unit", "update", NULL};
const char *id = NULL, *name = "", *description = "";
const char *id = NULL, *name = NULL, *description = "";
int id_len;
float min = -FLT_MAX, max = FLT_MAX, soft_min = -FLT_MAX, soft_max = FLT_MAX, step = 3, def = 0.0f;
int precision = 2;
@@ -735,7 +735,7 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
prop = RNA_def_property(srna, id, PROP_FLOAT, subtype | unit);
RNA_def_property_float_default(prop, def);
RNA_def_property_range(prop, min, max);
RNA_def_property_ui_text(prop, name, description);
RNA_def_property_ui_text(prop, name ? name : id, description);
RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, precision);
if (pyopts) {
@@ -777,7 +777,7 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
static const char *kwlist[] = {"attr", "name", "description", "default",
"min", "max", "soft_min", "soft_max",
"step", "precision", "options", "subtype", "unit", "size", "update", NULL};
const char *id = NULL, *name = "", *description = "";
const char *id = NULL, *name = NULL, *description = "";
int id_len;
float min = -FLT_MAX, max = FLT_MAX, soft_min = -FLT_MAX, soft_max = FLT_MAX, step = 3, def[PYRNA_STACK_ARRAY] = {0.0f};
int precision = 2, size = 3;
@@ -828,7 +828,7 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
RNA_def_property_array(prop, size);
if (pydef) RNA_def_property_float_array_default(prop, def);
RNA_def_property_range(prop, min, max);
RNA_def_property_ui_text(prop, name, description);
RNA_def_property_ui_text(prop, name ? name : id, description);
RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, precision);
if (pyopts) {
@@ -864,7 +864,7 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw
if (srna) {
static const char *kwlist[] = {"attr", "name", "description", "default",
"maxlen", "options", "subtype", "update", NULL};
const char *id = NULL, *name = "", *description = "", *def = "";
const char *id = NULL, *name = NULL, *description = "", *def = "";
int id_len;
int maxlen = 0;
PropertyRNA *prop;
@@ -893,7 +893,7 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw
prop = RNA_def_property(srna, id, PROP_STRING, subtype);
if (maxlen != 0) RNA_def_property_string_maxlength(prop, maxlen + 1); /* +1 since it includes null terminator */
if (def) RNA_def_property_string_default(prop, def);
RNA_def_property_ui_text(prop, name, description);
RNA_def_property_ui_text(prop, name ? name : id, description);
if (pyopts) {
if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
@@ -1163,7 +1163,7 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
if (srna) {
static const char *kwlist[] = {"attr", "items", "name", "description", "default",
"options", "update", NULL};
const char *id = NULL, *name = "", *description = "";
const char *id = NULL, *name = NULL, *description = "";
PyObject *def = NULL;
int id_len;
int defvalue = 0;
@@ -1227,8 +1227,8 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
}
}
if (opts & PROP_ENUM_FLAG) prop = RNA_def_enum_flag(srna, id, eitems, defvalue, name, description);
else prop = RNA_def_enum(srna, id, eitems, defvalue, name, description);
if (opts & PROP_ENUM_FLAG) prop = RNA_def_enum_flag(srna, id, eitems, defvalue, name ? name : id, description);
else prop = RNA_def_enum(srna, id, eitems, defvalue, name ? name : id, description);
if (is_itemf) {
RNA_def_enum_funcs(prop, bpy_props_enum_itemf);
@@ -1307,7 +1307,7 @@ static PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *k
if (srna) {
static const char *kwlist[] = {"attr", "type", "name", "description", "options", "update", NULL};
const char *id = NULL, *name = "", *description = "";
const char *id = NULL, *name = NULL, *description = "";
int id_len;
PropertyRNA *prop;
StructRNA *ptype;
@@ -1336,7 +1336,7 @@ static PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *k
return NULL;
}
prop = RNA_def_pointer_runtime(srna, id, ptype, name, description);
prop = RNA_def_pointer_runtime(srna, id, ptype, name ? name : id, description);
if (pyopts) {
if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
if ((opts & PROP_ANIMATABLE) == 0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -1368,7 +1368,7 @@ static PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject
if (srna) {
static const char *kwlist[] = {"attr", "type", "name", "description", "options", NULL};
const char *id = NULL, *name = "", *description = "";
const char *id = NULL, *name = NULL, *description = "";
int id_len;
PropertyRNA *prop;
StructRNA *ptype;
@@ -1391,7 +1391,7 @@ static PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject
if (!ptype)
return NULL;
prop = RNA_def_collection_runtime(srna, id, ptype, name, description);
prop = RNA_def_collection_runtime(srna, id, ptype, name ? name : id, description);
if (pyopts) {
if (opts & PROP_HIDDEN) RNA_def_property_flag(prop, PROP_HIDDEN);
if ((opts & PROP_ANIMATABLE) == 0) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);

View File

@@ -1118,12 +1118,10 @@ static int pyrna_string_to_enum(PyObject *item, PointerRNA *ptr, PropertyRNA *pr
const char *param = _PyUnicode_AsString(item);
if (param == NULL) {
const char *enum_str = pyrna_enum_as_string(ptr, prop);
PyErr_Format(PyExc_TypeError,
"%.200s expected a string enum type in (%.200s)",
error_prefix, enum_str);
MEM_freeN((void *)enum_str);
return 0;
"%.200s expected a string enum, not %.200s",
error_prefix, Py_TYPE(item)->tp_name);
return -1;
}
else {
/* hack so that dynamic enums used for operator properties will be able to be built (i.e. context will be supplied to itemf)
@@ -1136,11 +1134,11 @@ static int pyrna_string_to_enum(PyObject *item, PointerRNA *ptr, PropertyRNA *pr
"%.200s enum \"%.200s\" not found in (%.200s)",
error_prefix, param, enum_str);
MEM_freeN((void *)enum_str);
return 0;
return -1;
}
}
return 1;
return 0;
}
/* 'value' _must_ be a set type, error check before calling */
@@ -1652,7 +1650,7 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
}
else {
/* simple enum string */
if (!pyrna_string_to_enum(value, ptr, prop, &val, error_prefix) < 0) {
if (pyrna_string_to_enum(value, ptr, prop, &val, error_prefix) < 0) {
return -1;
}
}

View File

@@ -2075,22 +2075,6 @@ static PyNumberMethods Matrix_NumMethods = {
NULL, /* nb_index */
};
PyDoc_STRVAR(Matrix_row_size_doc,
"The row size of the matrix (readonly).\n\n:type: int"
);
static PyObject *Matrix_row_size_get(MatrixObject *self, void *UNUSED(closure))
{
return PyLong_FromLong((long) self->num_col);
}
PyDoc_STRVAR(Matrix_col_size_doc,
"The column size of the matrix (readonly).\n\n:type: int"
);
static PyObject *Matrix_col_size_get(MatrixObject *self, void *UNUSED(closure))
{
return PyLong_FromLong((long) self->num_row);
}
PyDoc_STRVAR(Matrix_translation_doc,
"The translation component of the matrix.\n\n:type: Vector"
);
@@ -2225,8 +2209,6 @@ static PyObject *Matrix_is_orthogonal_get(MatrixObject *self, void *UNUSED(closu
/* Python attributes get/set structure: */
/*****************************************************************************/
static PyGetSetDef Matrix_getseters[] = {
{(char *)"row_size", (getter)Matrix_row_size_get, (setter)NULL, Matrix_row_size_doc, NULL},
{(char *)"col_size", (getter)Matrix_col_size_get, (setter)NULL, Matrix_col_size_doc, NULL},
{(char *)"median_scale", (getter)Matrix_median_scale_get, (setter)NULL, Matrix_median_scale_doc, NULL},
{(char *)"translation", (getter)Matrix_translation_get, (setter)Matrix_translation_set, Matrix_translation_doc, NULL},
{(char *)"row", (getter)Matrix_row_get, (setter)NULL, Matrix_row_doc, NULL},