* Merged changes in the trunk up to revision 33492.

* Fixed a bug in listing all style modules in source/blender/blenlib/intern/bpath.c.
This commit is contained in:
2010-12-06 01:23:18 +00:00
584 changed files with 16928 additions and 14704 deletions

View File

@@ -25,6 +25,7 @@
/* This file defines the '_bpy' module which is used by python's 'bpy' package.
* a script writer should never directly access this module */
#define WITH_PYTHON /* for AUD_PyInit.h, possibly others */
#include "bpy_util.h"
#include "bpy_rna.h"
@@ -37,6 +38,8 @@
#include "BKE_utildefines.h"
#include "MEM_guardedalloc.h"
/* external util modules */
#include "../generic/mathutils.h"
#include "../generic/bgl.h"
@@ -79,39 +82,44 @@ static char bpy_blend_paths_doc[] =
" :rtype: list of strigs\n";
static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
{
struct BPathIterator bpi;
PyObject *list = PyList_New(0), *st; /* stupidly big string to be safe */
struct BPathIterator *bpi;
PyObject *list, *st; /* stupidly big string to be safe */
/* be sure there is low chance of the path being too short */
char filepath_expanded[1024];
const char *lib;
int absolute = 0;
static char *kwlist[] = {"absolute", NULL};
static const char *kwlist[] = {"absolute", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kw, "|i:blend_paths", kwlist, &absolute))
if (!PyArg_ParseTupleAndKeywords(args, kw, "|i:blend_paths", (char **)kwlist, &absolute))
return NULL;
for(BLI_bpathIterator_init(&bpi, NULL); !BLI_bpathIterator_isDone(&bpi); BLI_bpathIterator_step(&bpi)) {
BLI_bpathIterator_alloc(&bpi);
list= PyList_New(0);
for(BLI_bpathIterator_init(bpi, NULL); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) {
/* build the list */
if (absolute) {
BLI_bpathIterator_getPathExpanded(&bpi, filepath_expanded);
BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded);
}
else {
lib = BLI_bpathIterator_getLib(&bpi);
if (lib && (strcmp(lib, bpi.base_path))) { /* relative path to the library is NOT the same as our blendfile path, return an absolute path */
BLI_bpathIterator_getPathExpanded(&bpi, filepath_expanded);
lib = BLI_bpathIterator_getLib(bpi);
if (lib && (strcmp(lib, BLI_bpathIterator_getBasePath(bpi)))) { /* relative path to the library is NOT the same as our blendfile path, return an absolute path */
BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded);
}
else {
BLI_bpathIterator_getPath(&bpi, filepath_expanded);
BLI_bpathIterator_getPath(bpi, filepath_expanded);
}
}
st = PyUnicode_FromString(filepath_expanded);
st= PyUnicode_DecodeFSDefault(filepath_expanded);
PyList_Append(list, st);
Py_DECREF(st);
}
BLI_bpathIterator_free(&bpi);
BLI_bpathIterator_free(bpi);
MEM_freeN((void *)bpi);
return list;
}
@@ -133,11 +141,11 @@ static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObj
char *type;
char *subdir= NULL;
int folder_id;
static char *kwlist[] = {"type", "subdir", NULL};
static const char *kwlist[] = {"type", "subdir", NULL};
char *path;
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|s:user_resource", kwlist, &type, &subdir))
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|s:user_resource", (char **)kwlist, &type, &subdir))
return NULL;
/* stupid string compare */
@@ -163,9 +171,9 @@ static PyMethodDef meth_bpy_script_paths = {"script_paths", (PyCFunction)bpy_scr
static PyMethodDef meth_bpy_blend_paths = {"blend_paths", (PyCFunction)bpy_blend_paths, METH_VARARGS|METH_KEYWORDS, bpy_blend_paths_doc};
static PyMethodDef meth_bpy_user_resource = {"user_resource", (PyCFunction)bpy_user_resource, METH_VARARGS|METH_KEYWORDS, bpy_user_resource_doc};
static void bpy_import_test(char *modname)
static void bpy_import_test(const char *modname)
{
PyObject *mod= PyImport_ImportModuleLevel(modname, NULL, NULL, NULL, 0);
PyObject *mod= PyImport_ImportModuleLevel((char *)modname, NULL, NULL, NULL, 0);
if(mod) {
Py_DECREF(mod);
}