diff options
author | Willian Padovani Germano <wpgermano@gmail.com> | 2003-12-14 04:18:09 +0300 |
---|---|---|
committer | Willian Padovani Germano <wpgermano@gmail.com> | 2003-12-14 04:18:09 +0300 |
commit | 49021f7ec4bfc1313c6cdfeae1f9c32e98cc9cdc (patch) | |
tree | 44e7c4c38bc8c26b5efe0b52b846402589a4ca9a /source/blender/python/api2_2x/EXPP_interface.c | |
parent | 6653af79142aa929eb3d131f8fced363b2c4b828 (diff) |
BPython - first step for better integration of Python in Blender:
- add a new space: Space Script
- add a new dna struct: Script
- add these two properly everywhere they are meant to
It's not a tiny commit, but most of it is ground work for what is still to be done.
Right now the benefits should be: freeing the Text Editor to be used in a window even while a script w/ gui in "on" and letting more than one currently running script w/ gui be accessible from each window
Some files are added, so some build systems (not autotools) will need updates
Diffstat (limited to 'source/blender/python/api2_2x/EXPP_interface.c')
-rw-r--r-- | source/blender/python/api2_2x/EXPP_interface.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/source/blender/python/api2_2x/EXPP_interface.c b/source/blender/python/api2_2x/EXPP_interface.c index b93b2f7f2e2..54076e0fce5 100644 --- a/source/blender/python/api2_2x/EXPP_interface.c +++ b/source/blender/python/api2_2x/EXPP_interface.c @@ -33,7 +33,10 @@ #include <Python.h> +#include <BIF_space.h> +#include <BIF_screen.h> #include <BKE_global.h> +#include <BKE_library.h> #include <BKE_main.h> #include <DNA_ID.h> #include <DNA_camera_types.h> @@ -41,7 +44,10 @@ #include <DNA_material_types.h> #include <DNA_object_types.h> #include <DNA_scene_types.h> +#include <DNA_screen_types.h> +#include <DNA_script_types.h> #include <DNA_scriptlink_types.h> +#include <DNA_space_types.h> #include <DNA_world_types.h> #include "EXPP_interface.h" @@ -177,3 +183,42 @@ TODO: Check this */ return (scriptlink); } + +void BPY_clear_script (Script *script) +{ + if (!script) return; + + Py_XDECREF((PyObject *)script->py_globaldict); + Py_XDECREF((PyObject *)script->py_button); + Py_XDECREF((PyObject *)script->py_event); + Py_XDECREF((PyObject *)script->py_draw); +} + +void EXPP_move_to_spacescript (Script *script) +{ /* used by BPY_txt_do_python when a text is already being executed */ + SpaceScript *sc; + newspace(curarea, SPACE_SCRIPT); + sc = curarea->spacedata.first; + sc->script = script; + return; +} + +/*****************************************************************************/ +/* Description: This function frees a finished (flags == 0) script. */ +/*****************************************************************************/ +void BPY_free_finished_script(Script *script) +{ + PyObject *d = script->py_globaldict; + + if (d) { + PyDict_Clear (d); + Py_DECREF (d); /* Release dictionary. */ + script->py_globaldict = NULL; + } + + if (script->lastspace != SPACE_SCRIPT) + newspace (curarea, script->lastspace); + + free_libblock(&G.main->script, script); + return; +} |