diff options
Diffstat (limited to 'intern/cycles/blender/blender_python.cpp')
-rw-r--r-- | intern/cycles/blender/blender_python.cpp | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp index b756d6acdb2..78a96319163 100644 --- a/intern/cycles/blender/blender_python.cpp +++ b/intern/cycles/blender/blender_python.cpp @@ -53,14 +53,36 @@ void python_thread_state_restore(void **python_thread_state) *python_thread_state = NULL; } +static const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce) +{ +#ifdef WIN32 + /* bug [#31856] oddly enough, Python3.2 --> 3.3 on Windows will throw an + * exception here this needs to be fixed in python: + * see: bugs.python.org/issue15859 */ + if(!PyUnicode_Check(py_str)) { + PyErr_BadArgument(); + return ""; + } +#endif + if((*coerce = PyUnicode_EncodeFSDefault(py_str))) { + return PyBytes_AS_STRING(*coerce); + } + return ""; +} + static PyObject *init_func(PyObject *self, PyObject *args) { - const char *path, *user_path; + PyObject *path, *user_path; - if(!PyArg_ParseTuple(args, "ss", &path, &user_path)) + if(!PyArg_ParseTuple(args, "OO", &path, &user_path)) { return NULL; - - path_init(path, user_path); + } + + PyObject *path_coerce = NULL, *user_path_coerce = NULL; + path_init(PyC_UnicodeAsByte(path, &path_coerce), + PyC_UnicodeAsByte(user_path, &user_path_coerce)); + Py_XDECREF(path_coerce); + Py_XDECREF(user_path_coerce); Py_RETURN_NONE; } @@ -83,7 +105,7 @@ static PyObject *create_func(PyObject *self, PyObject *args) BL::UserPreferences userpref(userprefptr); PointerRNA dataptr; - RNA_id_pointer_create((ID*)PyLong_AsVoidPtr(pydata), &dataptr); + RNA_main_pointer_create((Main*)PyLong_AsVoidPtr(pydata), &dataptr); BL::BlendData data(dataptr); PointerRNA sceneptr; @@ -91,15 +113,15 @@ static PyObject *create_func(PyObject *self, PyObject *args) BL::Scene scene(sceneptr); PointerRNA regionptr; - RNA_id_pointer_create((ID*)pylong_as_voidptr_typesafe(pyregion), ®ionptr); + RNA_pointer_create(NULL, &RNA_Region, pylong_as_voidptr_typesafe(pyregion), ®ionptr); BL::Region region(regionptr); PointerRNA v3dptr; - RNA_id_pointer_create((ID*)pylong_as_voidptr_typesafe(pyv3d), &v3dptr); + RNA_pointer_create(NULL, &RNA_SpaceView3D, pylong_as_voidptr_typesafe(pyv3d), &v3dptr); BL::SpaceView3D v3d(v3dptr); PointerRNA rv3dptr; - RNA_id_pointer_create((ID*)pylong_as_voidptr_typesafe(pyrv3d), &rv3dptr); + RNA_pointer_create(NULL, &RNA_RegionView3D, pylong_as_voidptr_typesafe(pyrv3d), &rv3dptr); BL::RegionView3D rv3d(rv3dptr); /* create session */ @@ -174,7 +196,7 @@ static PyObject *bake_func(PyObject *self, PyObject *args) void *b_result = PyLong_AsVoidPtr(pyresult); PointerRNA bakepixelptr; - RNA_id_pointer_create((ID*)PyLong_AsVoidPtr(pypixel_array), &bakepixelptr); + RNA_pointer_create(NULL, &RNA_BakePixel, PyLong_AsVoidPtr(pypixel_array), &bakepixelptr); BL::BakePixel b_bake_pixel(bakepixelptr); python_thread_state_save(&session->python_thread_state); @@ -216,7 +238,7 @@ static PyObject *reset_func(PyObject *self, PyObject *args) BlenderSession *session = (BlenderSession*)PyLong_AsVoidPtr(pysession); PointerRNA dataptr; - RNA_id_pointer_create((ID*)PyLong_AsVoidPtr(pydata), &dataptr); + RNA_main_pointer_create((Main*)PyLong_AsVoidPtr(pydata), &dataptr); BL::BlendData b_data(dataptr); PointerRNA sceneptr; @@ -363,13 +385,7 @@ static PyObject *osl_update_node_func(PyObject *self, PyObject *args) /* find socket socket */ BL::NodeSocket b_sock(PointerRNA_NULL); if (param->isoutput) { -#if OSL_LIBRARY_VERSION_CODE < 10500 - b_sock = b_node.outputs[param->name]; -#else b_sock = b_node.outputs[param->name.string()]; -#endif - - /* remove if type no longer matches */ if(b_sock && b_sock.bl_idname() != socket_type) { b_node.outputs.remove(b_sock); @@ -377,12 +393,7 @@ static PyObject *osl_update_node_func(PyObject *self, PyObject *args) } } else { -#if OSL_LIBRARY_VERSION_CODE < 10500 - b_sock = b_node.inputs[param->name]; -#else b_sock = b_node.inputs[param->name.string()]; -#endif - /* remove if type no longer matches */ if(b_sock && b_sock.bl_idname() != socket_type) { b_node.inputs.remove(b_sock); |