Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/python/BPY_extern.h67
-rw-r--r--source/blender/python/BPY_interface.c1238
-rw-r--r--source/blender/python/BPY_menus.c769
-rw-r--r--source/blender/python/BPY_menus.h35
-rw-r--r--source/blender/python/api2_2x/Armature.c1
-rw-r--r--source/blender/python/api2_2x/Armature.h5
-rw-r--r--source/blender/python/api2_2x/BGL.c1
-rw-r--r--source/blender/python/api2_2x/BGL.h1
-rw-r--r--source/blender/python/api2_2x/BezTriple.c2
-rw-r--r--source/blender/python/api2_2x/BezTriple.h7
-rw-r--r--source/blender/python/api2_2x/Blender.c4
-rw-r--r--source/blender/python/api2_2x/Blender.h4
-rw-r--r--source/blender/python/api2_2x/Bone.c2
-rw-r--r--source/blender/python/api2_2x/Build.h12
-rw-r--r--source/blender/python/api2_2x/Camera.c4
-rw-r--r--source/blender/python/api2_2x/Camera.h20
-rw-r--r--source/blender/python/api2_2x/CurNurb.c6
-rw-r--r--source/blender/python/api2_2x/CurNurb.h29
-rw-r--r--source/blender/python/api2_2x/Curve.c14
-rw-r--r--source/blender/python/api2_2x/Curve.h24
-rw-r--r--source/blender/python/api2_2x/Draw.h8
-rw-r--r--source/blender/python/api2_2x/EXPP_interface.c4
-rw-r--r--source/blender/python/api2_2x/Effect.h16
-rw-r--r--source/blender/python/api2_2x/Ipo.c5
-rw-r--r--source/blender/python/api2_2x/Ipo.h14
-rw-r--r--source/blender/python/api2_2x/Ipocurve.c4
-rw-r--r--source/blender/python/api2_2x/Ipocurve.h8
-rw-r--r--source/blender/python/api2_2x/Lamp.c10
-rw-r--r--source/blender/python/api2_2x/Lamp.h27
-rw-r--r--source/blender/python/api2_2x/Lattice.c176
-rw-r--r--source/blender/python/api2_2x/Lattice.h168
-rw-r--r--source/blender/python/api2_2x/Library.c3
-rw-r--r--source/blender/python/api2_2x/MTex.c1
-rw-r--r--source/blender/python/api2_2x/Material.c3
-rw-r--r--source/blender/python/api2_2x/Material.h7
-rw-r--r--source/blender/python/api2_2x/Mathutils.c176
-rw-r--r--source/blender/python/api2_2x/Mathutils.h181
-rw-r--r--source/blender/python/api2_2x/Metaball.c183
-rw-r--r--source/blender/python/api2_2x/Metaball.h191
-rw-r--r--source/blender/python/api2_2x/NLA.c2
-rw-r--r--source/blender/python/api2_2x/NMesh.c48
-rw-r--r--source/blender/python/api2_2x/NMesh.h50
-rw-r--r--source/blender/python/api2_2x/Object.c6
-rw-r--r--source/blender/python/api2_2x/Object.h9
-rw-r--r--source/blender/python/api2_2x/Particle.h13
-rw-r--r--source/blender/python/api2_2x/Registry.c57
-rw-r--r--source/blender/python/api2_2x/Registry.h56
-rw-r--r--source/blender/python/api2_2x/Scene.c1
-rw-r--r--source/blender/python/api2_2x/Scene.h3
-rw-r--r--source/blender/python/api2_2x/Sys.c2
-rw-r--r--source/blender/python/api2_2x/Sys.h2
-rw-r--r--source/blender/python/api2_2x/Text.c2
-rw-r--r--source/blender/python/api2_2x/Text.h6
-rw-r--r--source/blender/python/api2_2x/Texture.c3
-rw-r--r--source/blender/python/api2_2x/Types.c15
-rw-r--r--source/blender/python/api2_2x/Types.h3
-rw-r--r--source/blender/python/api2_2x/Wave.h15
-rw-r--r--source/blender/python/api2_2x/Window.c3
-rw-r--r--source/blender/python/api2_2x/Window.h3
-rw-r--r--source/blender/python/api2_2x/World.c146
-rw-r--r--source/blender/python/api2_2x/World.h147
-rw-r--r--source/blender/python/api2_2x/bpy_types.h126
-rw-r--r--source/blender/python/api2_2x/modules.h213
-rw-r--r--source/blender/python/api2_2x/sceneRender.c2
-rw-r--r--source/blender/python/api2_2x/windowTheme.h2
65 files changed, 2314 insertions, 2051 deletions
diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h
index 32d2d9180c4..54d9c0e1aef 100644
--- a/source/blender/python/BPY_extern.h
+++ b/source/blender/python/BPY_extern.h
@@ -1,4 +1,4 @@
-/**
+/*
* $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
@@ -30,15 +30,15 @@
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
-extern char bprogname[]; /* holds a copy of argv[0], from creator.c */
+extern char bprogname[]; /* holds a copy of argv[0], from creator.c */
-struct Text; /* defined in DNA_text_types.h */
-struct ID; /* defined in DNA_ID.h */
-struct ScriptLink; /* defined in DNA_scriptlink_types.h */
-struct ListBase; /* defined in DNA_listBase.h */
-struct SpaceText; /* defined in DNA_space_types.h */
-struct SpaceScript;/* defined in DNA_space_types.h */
-struct Script; /* defined in BPI_script.h */
+struct Text; /* defined in DNA_text_types.h */
+struct ID; /* defined in DNA_ID.h */
+struct ScriptLink; /* defined in DNA_scriptlink_types.h */
+struct ListBase; /* defined in DNA_listBase.h */
+struct SpaceText; /* defined in DNA_space_types.h */
+struct SpaceScript; /* defined in DNA_space_types.h */
+struct Script; /* defined in BPI_script.h */
/*
struct _object; // forward declaration for PyObject !
*/
@@ -46,38 +46,39 @@ struct _object; // forward declaration for PyObject !
extern "C" {
#endif
-void BPY_start_python(void);
-void BPY_end_python(void);
-void BPY_post_start_python(void);
-int BPY_Err_getLinenumber(void);
-const char *BPY_Err_getFilename(void);
+ void BPY_start_python( void );
+ void BPY_end_python( void );
+ void BPY_post_start_python( void );
+ int BPY_Err_getLinenumber( void );
+ const char *BPY_Err_getFilename( void );
/* void BPY_Err_Handle(struct Text *text); */
-int BPY_txt_do_python(struct SpaceText* st);
-int BPY_menu_do_python(short menutype, int event);
-void BPY_run_python_script(char *filename);
-void BPY_free_compiled_text(struct Text* text);
+ int BPY_txt_do_python( struct SpaceText *st );
+ int BPY_menu_do_python( short menutype, int event );
+ void BPY_run_python_script( char *filename );
+ void BPY_free_compiled_text( struct Text *text );
/*void BPY_clear_bad_scriptlink(struct ID *id, struct Text *byebye); */
-void BPY_clear_bad_scriptlinks(struct Text *byebye);
+ void BPY_clear_bad_scriptlinks( struct Text *byebye );
/*void BPY_clear_bad_scriptlist(struct ListBase *, struct Text *byebye); */
-int BPY_has_onload_script(void);
-void BPY_do_all_scripts(short event);
-void BPY_do_pyscript(struct ID *id, short event);
-void BPY_free_scriptlink(struct ScriptLink *slink);
-void BPY_copy_scriptlink(struct ScriptLink *scriptlink);
+ int BPY_has_onload_script( void );
+ void BPY_do_all_scripts( short event );
+ void BPY_do_pyscript( struct ID *id, short event );
+ void BPY_free_scriptlink( struct ScriptLink *slink );
+ void BPY_copy_scriptlink( struct ScriptLink *scriptlink );
/* format importer hook */
-int BPY_call_importloader(char *name);
+ int BPY_call_importloader( char *name );
//int BPY_spacetext_is_pywin(struct SpaceText *st);
-void BPY_spacescript_do_pywin_draw(struct SpaceScript *sc);
-void BPY_spacescript_do_pywin_event(struct SpaceScript *sc, unsigned short event, short val);
-void BPY_clear_script(struct Script *script);
-void BPY_free_finished_script(struct Script *script);
+ void BPY_spacescript_do_pywin_draw( struct SpaceScript *sc );
+ void BPY_spacescript_do_pywin_event( struct SpaceScript *sc,
+ unsigned short event, short val );
+ void BPY_clear_script( struct Script *script );
+ void BPY_free_finished_script( struct Script *script );
-void init_syspath(void);
-void syspath_append(char *dir);
-char *bpy_gethome(void);
+ void init_syspath( void );
+ void syspath_append( char *dir );
+ char *bpy_gethome( void );
#ifdef __cplusplus
-} /* extern "C" */
+} /* extern "C" */
#endif
diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c
index b571b0af5eb..6ce4b969d8a 100644
--- a/source/blender/python/BPY_interface.c
+++ b/source/blender/python/BPY_interface.c
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -34,22 +35,22 @@
#endif
#include <Python.h>
-#include "compile.h" /* for the PyCodeObject */
-#include "eval.h" /* for PyEval_EvalCode */
+#include "compile.h" /* for the PyCodeObject */
+#include "eval.h" /* for PyEval_EvalCode */
#include <stdio.h>
#include <MEM_guardedalloc.h>
-#include <BLI_blenlib.h> /* for BLI_last_slash() */
+#include <BLI_blenlib.h> /* for BLI_last_slash() */
-#include <BIF_interface.h> /* for pupmenu() */
+#include <BIF_interface.h> /* for pupmenu() */
#include <BIF_space.h>
#include <BIF_screen.h>
#include <BIF_toolbox.h>
#include <BKE_global.h>
#include <BKE_library.h>
#include <BKE_main.h>
-#include <BKE_object.h> /* during_scriptlink() */
+#include <BKE_object.h> /* during_scriptlink() */
#include <BKE_text.h>
#include <BKE_utildefines.h>
#include <BPI_script.h>
@@ -65,60 +66,63 @@
#include <DNA_space_types.h>
#include <DNA_text_types.h>
#include <DNA_world_types.h>
-#include <DNA_userdef_types.h> /* for U.pythondir */
+#include <DNA_userdef_types.h> /* for U.pythondir */
#include "BPY_extern.h"
#include "BPY_menus.h"
#include "api2_2x/EXPP_interface.h"
#include "api2_2x/constant.h"
+
#include "api2_2x/modules.h"
/* bpy_registryDict is declared in api2_2x/Registry.h and defined
- * here. This Python dictionary will be used to store data that scripts
+ * in api2_2x/Registry.c
+ * This Python dictionary will be used to store data that scripts
* choose to preserve after they are executed, so user changes can be
- * restored next time the script is used. Check the Blender.Registry module. */
-extern PyObject *bpy_registryDict;
+ * restored next time the script is used. Check the Blender.Registry module.
+ */
+#include "api2_2x/Registry.h"
-/*****************************************************************************/
-/* Structure definitions */
-/*****************************************************************************/
+/*************************************************************************
+* Structure definitions
+**************************************************************************/
#define FILENAME_LENGTH 24
typedef struct _ScriptError {
char filename[FILENAME_LENGTH];
int lineno;
} ScriptError;
-/*****************************************************************************/
-/* Global variables */
-/*****************************************************************************/
+/****************************************************************************
+* Global variables
+****************************************************************************/
ScriptError g_script_error;
-/*****************************************************************************/
-/* Function prototypes */
-/*****************************************************************************/
-PyObject *RunPython(Text *text, PyObject *globaldict);
-char *GetName(Text *text);
-PyObject *CreateGlobalDictionary (void);
-void ReleaseGlobalDictionary (PyObject * dict);
-void DoAllScriptsFromList (ListBase * list, short event);
-PyObject *importText(char *name);
-void init_ourImport(void);
-PyObject *blender_import(PyObject *self, PyObject *args);
-
-/*****************************************************************************/
-/* Description: This function will initialise Python and all the implemented */
-/* api variations. */
-/* Notes: Currently only the api for 2.2x will be initialised. */
-/*****************************************************************************/
-void BPY_start_python(void)
+/***************************************************************************
+* Function prototypes
+***************************************************************************/
+PyObject *RunPython( Text * text, PyObject * globaldict );
+char *GetName( Text * text );
+PyObject *CreateGlobalDictionary( void );
+void ReleaseGlobalDictionary( PyObject * dict );
+void DoAllScriptsFromList( ListBase * list, short event );
+PyObject *importText( char *name );
+void init_ourImport( void );
+PyObject *blender_import( PyObject * self, PyObject * args );
+
+/****************************************************************************
+* Description: This function will initialise Python and all the implemented
+* api variations.
+* Notes: Currently only the api for 2.2x will be initialised.
+****************************************************************************/
+void BPY_start_python( void )
{
- bpy_registryDict = PyDict_New(); /* check comment at start of this file */
+ bpy_registryDict = PyDict_New( ); /* check comment at start of this file */
- if (!bpy_registryDict)
- printf("Error: Couldn't create the Registry Python Dictionary!");
+ if( !bpy_registryDict )
+ printf( "Error: Couldn't create the Registry Python Dictionary!" );
/* TODO: Shouldn't "blender" be replaced by PACKAGE ?? (config.h) */
- Py_SetProgramName("blender");
+ Py_SetProgramName( "blender" );
/*
* Py_Initialize() will attempt to import the site module and
@@ -126,138 +130,139 @@ void BPY_start_python(void)
* rest of our init msgs.
*/
- printf("Checking for Python install...\n");
+ printf( "Checking for Python install...\n" );
fflush( stdout );
-
- Py_Initialize ();
- init_ourImport ();
+ Py_Initialize( );
+
+ init_ourImport( );
- initBlenderApi2_2x ();
+ initBlenderApi2_2x( );
- init_syspath();
+ init_syspath( );
return;
}
/*****************************************************************************/
-/* Description: This function will terminate the Python interpreter */
+/* Description: This function will terminate the Python interpreter */
/*****************************************************************************/
-void BPY_end_python(void)
+void BPY_end_python( void )
{
- if (bpy_registryDict) {
- Py_DECREF (bpy_registryDict);
+ if( bpy_registryDict ) {
+ Py_DECREF( bpy_registryDict );
bpy_registryDict = NULL;
}
- Py_Finalize();
+ Py_Finalize( );
- BPyMenu_RemoveAllEntries(); /* freeing bpymenu mem */
+ BPyMenu_RemoveAllEntries( ); /* freeing bpymenu mem */
/* a script might've opened a .blend file but didn't close it, so: */
- EXPP_Library_Close();
+ EXPP_Library_Close( );
return;
}
-void syspath_append(char *dirname)
+void syspath_append( char *dirname )
{
PyObject *mod_sys, *dict, *path, *dir;
- PyErr_Clear();
+ PyErr_Clear( );
- dir = Py_BuildValue("s", dirname);
+ dir = Py_BuildValue( "s", dirname );
- mod_sys = PyImport_ImportModule("sys"); /* new ref */
- dict = PyModule_GetDict(mod_sys); /* borrowed ref */
- path = PyDict_GetItemString(dict, "path"); /* borrowed ref */
+ mod_sys = PyImport_ImportModule( "sys" ); /* new ref */
+ dict = PyModule_GetDict( mod_sys ); /* borrowed ref */
+ path = PyDict_GetItemString( dict, "path" ); /* borrowed ref */
- if (!PyList_Check(path)) return;
+ if( !PyList_Check( path ) )
+ return;
- PyList_Append(path, dir);
+ PyList_Append( path, dir );
- if (PyErr_Occurred()) Py_FatalError("could not build sys.path");
+ if( PyErr_Occurred( ) )
+ Py_FatalError( "could not build sys.path" );
- Py_DECREF(mod_sys);
+ Py_DECREF( mod_sys );
}
-void init_syspath(void)
+void init_syspath( void )
{
PyObject *path;
PyObject *mod, *d;
PyObject *p;
char *c, *progname;
- char execdir[FILE_MAXDIR + FILE_MAXFILE];/*defines from DNA_space_types.h*/
+ char execdir[FILE_MAXDIR + FILE_MAXFILE]; /*defines from DNA_space_types.h */
int n;
- path = Py_BuildValue("s", bprogname);
+ path = Py_BuildValue( "s", bprogname );
- mod = PyImport_ImportModule("Blender.sys");
+ mod = PyImport_ImportModule( "Blender.sys" );
- if (mod) {
- d = PyModule_GetDict(mod);
- PyDict_SetItemString(d, "progname", path);
- Py_DECREF(mod);
- }
- else
- printf("Warning: could not set Blender.sys.progname\n");
+ if( mod ) {
+ d = PyModule_GetDict( mod );
+ PyDict_SetItemString( d, "progname", path );
+ Py_DECREF( mod );
+ } else
+ printf( "Warning: could not set Blender.sys.progname\n" );
- progname = BLI_last_slash(bprogname); /* looks for the last dir separator */
+ progname = BLI_last_slash( bprogname ); /* looks for the last dir separator */
- c = Py_GetPath(); /* get python system path */
- PySys_SetPath(c); /* initialize */
+ c = Py_GetPath( ); /* get python system path */
+ PySys_SetPath( c ); /* initialize */
n = progname - bprogname;
- if (n > 0) {
- strncpy(execdir, bprogname, n);
- if (execdir[n-1] == '.') n--; /*fix for when run as ./blender */
+ if( n > 0 ) {
+ strncpy( execdir, bprogname, n );
+ if( execdir[n - 1] == '.' )
+ n--; /*fix for when run as ./blender */
execdir[n] = '\0';
- syspath_append(execdir); /* append to module search path */
+ syspath_append( execdir ); /* append to module search path */
/* set Blender.sys.progname */
- }
- else
- printf ("Warning: could not determine argv[0] path\n");
+ } else
+ printf( "Warning: could not determine argv[0] path\n" );
/*
* bring in the site module so we can add
* site-package dirs to sys.path
*/
- mod = PyImport_ImportModule("site"); /* new ref */
+ mod = PyImport_ImportModule( "site" ); /* new ref */
- if (mod) {
- PyObject* item;
+ if( mod ) {
+ PyObject *item;
int size = 0;
int index;
- printf("Installed Python found!\n");
+ printf( "Installed Python found!\n" );
/* get the value of 'sitedirs' from the module */
/* the ref man says GetDict() never fails!!! */
- d = PyModule_GetDict (mod); /* borrowed ref */
- p = PyDict_GetItemString (d, "sitedirs"); /* borrowed ref */
+ d = PyModule_GetDict( mod ); /* borrowed ref */
+ p = PyDict_GetItemString( d, "sitedirs" ); /* borrowed ref */
- if( p ) { /* we got our string */
+ if( p ) { /* we got our string */
/* append each item in sitedirs list to path */
- size = PyList_Size (p);
+ size = PyList_Size( p );
- for (index = 0; index < size; index++) {
- item = PySequence_GetItem (p, index); /* new ref */
- if( item )
- syspath_append (PyString_AsString(item));
+ for( index = 0; index < size; index++ ) {
+ item = PySequence_GetItem( p, index ); /* new ref */
+ if( item )
+ syspath_append( PyString_AsString
+ ( item ) );
}
}
- Py_DECREF(mod);
- }
- else { /* import 'site' failed */
- PyErr_Clear();
- printf("No installed Python found.\n");
- printf("Only built-in modules are available. Some scripts may not run.\n");
- printf("Continuing happily.\n");
+ Py_DECREF( mod );
+ } else { /* import 'site' failed */
+ PyErr_Clear( );
+ printf( "No installed Python found.\n" );
+ printf( "Only built-in modules are available. Some scripts may not run.\n" );
+ printf( "Continuing happily.\n" );
}
/*
@@ -266,54 +271,57 @@ void init_syspath(void)
* set argv[0] to the Blender exe
*/
- mod = PyImport_ImportModule("sys"); /* new ref */
+ mod = PyImport_ImportModule( "sys" ); /* new ref */
- if (mod) {
- d = PyModule_GetDict(mod); /* borrowed ref */
- PyDict_SetItemString(d, "executable", Py_BuildValue("s", bprogname));
+ if( mod ) {
+ d = PyModule_GetDict( mod ); /* borrowed ref */
+ PyDict_SetItemString( d, "executable",
+ Py_BuildValue( "s", bprogname ) );
/* in the future this can be extended to have more argv's if needed: */
- PyDict_SetItemString(d, "argv", Py_BuildValue("[s]", bprogname));
- Py_DECREF(mod);
+ PyDict_SetItemString( d, "argv",
+ Py_BuildValue( "[s]", bprogname ) );
+ Py_DECREF( mod );
}
}
-/*****************************************************************************/
-/* Description: This function finishes Python initialization in Blender. */
-/* Because U.pythondir (user defined dir for scripts) isn't */
-/* initialized when BPY_start_Python needs to be executed, we */
-/* postpone adding U.pythondir to sys.path and also BPyMenus */
-/* (mechanism to register scripts in Blender menus) for when */
-/* that dir info is available. */
-/*****************************************************************************/
-void BPY_post_start_python(void)
+/****************************************************************************
+* Description: This function finishes Python initialization in Blender.
+
+Because U.pythondir (user defined dir for scripts) isn't
+initialized when BPY_start_Python needs to be executed, we
+postpone adding U.pythondir to sys.path and also BPyMenus
+(mechanism to register scripts in Blender menus) for when
+that dir info is available.
+****************************************************************************/
+void BPY_post_start_python( void )
{
PyObject *result, *dict;
- if (U.pythondir && U.pythondir[0] != '\0')
- syspath_append(U.pythondir); /* append to module search path */
+ if( U.pythondir && U.pythondir[0] != '\0' )
+ syspath_append( U.pythondir ); /* append to module search path */
- BPyMenu_Init(0); /* get dynamic menus (registered scripts) data */
+ BPyMenu_Init( 0 ); /* get dynamic menus (registered scripts) data */
- dict = PyDict_New();
+ dict = PyDict_New( );
/* here we check if the user has (some of) the expected modules */
- if (dict) {
+ if( dict ) {
char *s = "import chunk, gzip, math, os, struct, string";
- result = PyRun_String(s, Py_eval_input, dict, dict);
- if (!result) {
- PyErr_Clear();
+ result = PyRun_String( s, Py_eval_input, dict, dict );
+ if( !result ) {
+ PyErr_Clear( );
/*XXX print msg about this, point to readme.html */
- }
- else Py_DECREF(result);
- Py_DECREF(dict);
+ } else
+ Py_DECREF( result );
+ Py_DECREF( dict );
}
}
-/*****************************************************************************/
-/* Description: This function will return the linenumber on which an error */
-/* has occurred in the Python script. */
-/*****************************************************************************/
-int BPY_Err_getLinenumber(void)
+/****************************************************************************
+* Description: This function will return the linenumber on which an error
+* has occurred in the Python script.
+****************************************************************************/
+int BPY_Err_getLinenumber( void )
{
return g_script_error.lineno;
}
@@ -321,126 +329,136 @@ int BPY_Err_getLinenumber(void)
/*****************************************************************************/
/* Description: This function will return the filename of the python script. */
/*****************************************************************************/
-const char *BPY_Err_getFilename(void)
+const char *BPY_Err_getFilename( void )
{
return g_script_error.filename;
}
/*****************************************************************************/
-/* Description: Return PyString filename from a traceback object */
+/* Description: Return PyString filename from a traceback object */
/*****************************************************************************/
-PyObject *traceback_getFilename(PyObject *tb)
+PyObject *traceback_getFilename( PyObject * tb )
{
PyObject *v;
/* co_filename is in f_code, which is in tb_frame, which is in tb */
- v = PyObject_GetAttrString(tb, "tb_frame"); Py_XDECREF(v);
- v = PyObject_GetAttrString(v, "f_code"); Py_XDECREF(v);
- v = PyObject_GetAttrString(v, "co_filename");
+ v = PyObject_GetAttrString( tb, "tb_frame" );
+ Py_XDECREF( v );
+ v = PyObject_GetAttrString( v, "f_code" );
+ Py_XDECREF( v );
+ v = PyObject_GetAttrString( v, "co_filename" );
return v;
}
-/*****************************************************************************/
-/* Description: Blender Python error handler. This catches the error and */
-/* stores filename and line number in a global */
-/*****************************************************************************/
-void BPY_Err_Handle(char *script_name)
+/****************************************************************************
+* Description: Blender Python error handler. This catches the error and
+* stores filename and line number in a global
+*****************************************************************************/
+void BPY_Err_Handle( char *script_name )
{
PyObject *exception, *err, *tb, *v;
- if (!script_name) {
- printf("Error: script has NULL name\n");
+ if( !script_name ) {
+ printf( "Error: script has NULL name\n" );
return;
}
- PyErr_Fetch(&exception, &err, &tb);
+ PyErr_Fetch( &exception, &err, &tb );
- if (!exception && !tb) {
- printf("FATAL: spurious exception\n");
+ if( !exception && !tb ) {
+ printf( "FATAL: spurious exception\n" );
return;
}
- strcpy(g_script_error.filename, script_name);
+ strcpy( g_script_error.filename, script_name );
- if (exception && PyErr_GivenExceptionMatches(exception, PyExc_SyntaxError)) {
+ if( exception
+ && PyErr_GivenExceptionMatches( exception, PyExc_SyntaxError ) ) {
/* no traceback available when SyntaxError */
- PyErr_Restore(exception, err, tb); /* takes away reference! */
- PyErr_Print();
- v = PyObject_GetAttrString(err, "lineno");
- if (v) {
- g_script_error.lineno = PyInt_AsLong(v);
- Py_DECREF(v);
+ PyErr_Restore( exception, err, tb ); /* takes away reference! */
+ PyErr_Print( );
+ v = PyObject_GetAttrString( err, "lineno" );
+ if( v ) {
+ g_script_error.lineno = PyInt_AsLong( v );
+ Py_DECREF( v );
} else {
g_script_error.lineno = -1;
}
/* this avoids an abort in Python 2.3's garbage collecting: */
- PyErr_Clear();
+ PyErr_Clear( );
return;
} else {
- PyErr_NormalizeException(&exception, &err, &tb);
- PyErr_Restore(exception, err, tb); // takes away reference!
- PyErr_Print();
- tb = PySys_GetObject("last_traceback");
+ PyErr_NormalizeException( &exception, &err, &tb );
+ PyErr_Restore( exception, err, tb ); /* takes away reference! */
+ PyErr_Print( );
+ tb = PySys_GetObject( "last_traceback" );
- if (!tb) {
- printf("\nCan't get traceback\n");
+ if( !tb ) {
+ printf( "\nCan't get traceback\n" );
return;
}
- Py_INCREF(tb);
+ Py_INCREF( tb );
/* From old bpython BPY_main.c:
* 'check traceback objects and look for last traceback in the
* same text file. This is used to jump to the line of where the
* error occured. "If the error occured in another text file or module,
- * the last frame in the current file is adressed."' */
+ * the last frame in the current file is adressed."'
+ */
- while (1) {
- v = PyObject_GetAttrString(tb, "tb_next");
+ while( 1 ) {
+ v = PyObject_GetAttrString( tb, "tb_next" );
- if (v == Py_None || strcmp(PyString_AsString(traceback_getFilename(v)),
- script_name)) {
+ if( v == Py_None
+ ||
+ strcmp( PyString_AsString
+ ( traceback_getFilename( v ) ),
+ script_name ) ) {
break;
}
- Py_DECREF(tb);
+ Py_DECREF( tb );
tb = v;
}
- v = PyObject_GetAttrString(tb, "tb_lineno");
- g_script_error.lineno = PyInt_AsLong(v);
- Py_XDECREF(v);
- v = traceback_getFilename(tb);
- strncpy(g_script_error.filename, PyString_AsString(v), FILENAME_LENGTH);
- Py_XDECREF(v);
- Py_DECREF(tb);
+ v = PyObject_GetAttrString( tb, "tb_lineno" );
+ g_script_error.lineno = PyInt_AsLong( v );
+ Py_XDECREF( v );
+ v = traceback_getFilename( tb );
+ strncpy( g_script_error.filename, PyString_AsString( v ),
+ FILENAME_LENGTH );
+ Py_XDECREF( v );
+ Py_DECREF( tb );
}
return;
}
-/*****************************************************************************/
-/* Description: This function executes the script passed by st. */
-/* Notes: It is called by blender/src/drawtext.c when a Blender user */
-/* presses ALT+PKEY in the script's text window. */
-/*****************************************************************************/
-int BPY_txt_do_python_Text(struct Text* text)
+/****************************************************************************
+* Description: This function executes the script passed by st.
+* Notes: It is called by blender/src/drawtext.c when a Blender user
+* presses ALT+PKEY in the script's text window.
+*****************************************************************************/
+int BPY_txt_do_python_Text( struct Text *text )
{
PyObject *py_dict, *py_result;
BPy_constant *info;
char textname[24];
Script *script = G.main->script.first;
- if (!text) return 0;
+ if( !text )
+ return 0;
/* check if this text is already running */
- while (script) {
- if (!strcmp(script->id.name+2, text->id.name+2)) {
- /* if this text is already a running script, just move to it: */
+ while( script ) {
+ if( !strcmp( script->id.name + 2, text->id.name + 2 ) ) {
+ /* if this text is already a running script,
+ * just move to it: */
SpaceScript *sc;
- newspace(curarea, SPACE_SCRIPT);
+ newspace( curarea, SPACE_SCRIPT );
sc = curarea->spacedata.first;
sc->script = script;
return 1;
@@ -449,17 +467,19 @@ int BPY_txt_do_python_Text(struct Text* text)
}
/* Create a new script structure and initialize it: */
- script = alloc_libblock(&G.main->script, ID_SCRIPT, GetName(text));
+ script = alloc_libblock( &G.main->script, ID_SCRIPT, GetName( text ) );
- if (!script) {
- printf("couldn't allocate memory for Script struct!");
+ if( !script ) {
+ printf( "couldn't allocate memory for Script struct!" );
return 0;
}
/* if in the script Blender.Load(blendfile) is not the last command,
* an error after it will call BPY_Err_Handle below, but the text struct
- * will have been deallocated already, so we need to copy its name here. */
- BLI_strncpy(textname, GetName(text), strlen(GetName(text))+1);
+ * will have been deallocated already, so we need to copy its name here.
+ */
+ BLI_strncpy( textname, GetName( text ),
+ strlen( GetName( text ) ) + 1 );
script->id.us = 1;
script->flags = SCRIPT_RUNNING;
@@ -467,101 +487,105 @@ int BPY_txt_do_python_Text(struct Text* text)
script->py_event = NULL;
script->py_button = NULL;
- py_dict = CreateGlobalDictionary();
+ py_dict = CreateGlobalDictionary( );
script->py_globaldict = py_dict;
- info = (BPy_constant *)M_constant_New();
- if (info) {
- constant_insert(info, "name", PyString_FromString(script->id.name+2));
- Py_INCREF (Py_None);
- constant_insert(info, "arg", Py_None);
- PyDict_SetItemString(py_dict, "__script__", (PyObject *)info);
+ info = ( BPy_constant * ) M_constant_New( );
+ if( info ) {
+ constant_insert( info, "name",
+ PyString_FromString( script->id.name + 2 ) );
+ Py_INCREF( Py_None );
+ constant_insert( info, "arg", Py_None );
+ PyDict_SetItemString( py_dict, "__script__",
+ ( PyObject * ) info );
}
- py_result = RunPython (text, py_dict); /* Run the script */
+ py_result = RunPython( text, py_dict ); /* Run the script */
- if (!py_result) { /* Failed execution of the script */
+ if( !py_result ) { /* Failed execution of the script */
- BPY_Err_Handle(textname);
- ReleaseGlobalDictionary(py_dict);
+ BPY_Err_Handle( textname );
+ ReleaseGlobalDictionary( py_dict );
script->py_globaldict = NULL;
- if (G.main->script.first) free_libblock(&G.main->script, script);
+ if( G.main->script.first )
+ free_libblock( &G.main->script, script );
return 0;
- }
- else {
- Py_DECREF (py_result);
- script->flags &=~SCRIPT_RUNNING;
- if (!script->flags) {
- ReleaseGlobalDictionary(py_dict);
+ } else {
+ Py_DECREF( py_result );
+ script->flags &= ~SCRIPT_RUNNING;
+ if( !script->flags ) {
+ ReleaseGlobalDictionary( py_dict );
script->py_globaldict = NULL;
- free_libblock(&G.main->script, script);
+ free_libblock( &G.main->script, script );
}
}
- return 1; /* normal return */
+ return 1; /* normal return */
}
-/*****************************************************************************/
-/* Description: The original function of this name has been refactored */
-/* into BPY_txt_do_python_Text. That version is needed for the command */
-/* line support for Python. This is here to keep the interface the */
-/* same and reduce code changes elsewhere. */
-/*****************************************************************************/
-int BPY_txt_do_python(struct SpaceText* st)
+/****************************************************************************
+* Description: The original function of this name has been refactored
+* into BPY_txt_do_python_Text. That version is needed for the command
+* line support for Python. This is here to keep the interface the
+* same and reduce code changes elsewhere.
+****************************************************************************/
+int BPY_txt_do_python( struct SpaceText *st )
{
- return BPY_txt_do_python_Text(st->text);
+ return BPY_txt_do_python_Text( st->text );
}
-/*****************************************************************************/
-/* Description: Called from command line to run a Python script
-* automatically. */
-/*****************************************************************************/
-void BPY_run_python_script(char *fn)
+/****************************************************************************
+* Description: Called from command line to run a Python script
+* automatically.
+****************************************************************************/
+void BPY_run_python_script( char *fn )
{
- Text *text = NULL;
+ Text *text = NULL;
int is_blenText = 0;
- if ( !BLI_exists(fn) ) { /* if there's no such filename ...*/
- text = G.main->text.first; /* try an already existing Blender Text */
- while (text) {
- if (!strcmp(fn, text->id.name+2)) break;
+ if( !BLI_exists( fn ) ) { /* if there's no such filename ... */
+ text = G.main->text.first; /* try an already existing Blender Text */
+ while( text ) {
+ if( !strcmp( fn, text->id.name + 2 ) )
+ break;
text = text->id.next;
}
- if (!text) {
- printf("\nError: no such file or Blender text -- %s.\n", fn);
+ if( !text ) {
+ printf( "\nError: no such file or Blender text -- %s.\n", fn );
return;
- }
- else is_blenText = 1; /* fn is already a Blender Text */
+ } else
+ is_blenText = 1; /* fn is already a Blender Text */
}
- if (!is_blenText) text = add_text(fn);
- if (text == NULL) {
- printf("Error in BPY_run_python_script: couldn't create Blender text "
- "from %s\n", fn);
+ if( !is_blenText )
+ text = add_text( fn );
+ if( text == NULL ) {
+ printf( "Error in BPY_run_python_script: couldn't create Blender text " "from %s\n", fn );
// Chris: On Windows if I continue I just get a segmentation
// violation. To get a baseline file I exit here.
- exit(2);
+ exit( 2 );
}
- if (BPY_txt_do_python_Text(text) != 1) {
+ if( BPY_txt_do_python_Text( text ) != 1 ) {
printf( "\nError executing Python script from command-line:\n"
- "%s (at line %d).\n", fn, BPY_Err_getLinenumber());
+ "%s (at line %d).\n", fn, BPY_Err_getLinenumber( ) );
}
- if (!is_blenText) free_libblock(&G.main->text, text);
+ if( !is_blenText )
+ free_libblock( &G.main->text, text );
}
-/*****************************************************************************/
-/* Description: This function executes the script chosen from a menu. */
-/* Notes: It is called by the ui code in src/header_???.c when a user */
-/* clicks on a menu entry that refers to a script. */
-/* Scripts are searched in the BPyMenuTable, using the given */
-/* menutype and event values to know which one was chosen. */
-/*****************************************************************************/
-int BPY_menu_do_python(short menutype, int event)
+/****************************************************************************
+* Description: This function executes the script chosen from a menu.
+* Notes: It is called by the ui code in src/header_???.c when a user
+* clicks on a menu entry that refers to a script.
+* Scripts are searched in the BPyMenuTable, using the given
+* menutype and event values to know which one was chosen.
+*****************************************************************************/
+int BPY_menu_do_python( short menutype, int event )
{
PyObject *py_dict, *py_res, *pyarg = NULL;
BPy_constant *info;
@@ -569,97 +593,109 @@ int BPY_menu_do_python(short menutype, int event)
BPySubMenu *pysm;
FILE *fp = NULL;
char *buffer, *s;
- char filestr[FILE_MAXDIR+FILE_MAXFILE];
+ char filestr[FILE_MAXDIR + FILE_MAXFILE];
char dirname[FILE_MAXDIR];
Script *script = G.main->script.first;
int len;
- pym = BPyMenu_GetEntry(menutype, (short)event);
+ pym = BPyMenu_GetEntry( menutype, ( short ) event );
- if (!pym) return 0;
+ if( !pym )
+ return 0;
- if (pym->version > G.version)
- notice ("Version mismatch: script was written for Blender %d. "
- "It may fail with yours: %d.", pym->version, G.version);
+ if( pym->version > G.version )
+ notice( "Version mismatch: script was written for Blender %d. "
+ "It may fail with yours: %d.", pym->version,
+ G.version );
/* if there are submenus, let the user choose one from a pupmenu that we
* create here.*/
pysm = pym->submenus;
- if (pysm) {
- char *pupstr;
+ if( pysm ) {
+ char *pupstr;
int arg;
- pupstr = BPyMenu_CreatePupmenuStr(pym, menutype);
+ pupstr = BPyMenu_CreatePupmenuStr( pym, menutype );
- if (pupstr) {
- arg = pupmenu(pupstr);
- MEM_freeN(pupstr);
+ if( pupstr ) {
+ arg = pupmenu( pupstr );
+ MEM_freeN( pupstr );
- if (arg >= 0) {
- while (arg--) pysm = pysm->next;
- pyarg = PyString_FromString(pysm->arg);
- }
- else return 0;
+ if( arg >= 0 ) {
+ while( arg-- )
+ pysm = pysm->next;
+ pyarg = PyString_FromString( pysm->arg );
+ } else
+ return 0;
}
}
- if (!pyarg) {/* no submenus */
- Py_INCREF (Py_None);
+ if( !pyarg ) { /* no submenus */
+ Py_INCREF( Py_None );
pyarg = Py_None;
}
- if (pym->dir) /* script is in U.pythondir */
- BLI_make_file_string("/", filestr, U.pythondir, pym->filename);
- else { /* script is in ~/.blender/scripts/ */
- BLI_make_file_string("/", dirname, bpy_gethome(), "scripts");
- BLI_make_file_string("/", filestr, dirname, pym->filename);
+ if( pym->dir ) /* script is in U.pythondir */
+ BLI_make_file_string( "/", filestr, U.pythondir,
+ pym->filename );
+ else { /* script is in ~/.blender/scripts/ */
+ BLI_make_file_string( "/", dirname, bpy_gethome( ),
+ "scripts" );
+ BLI_make_file_string( "/", filestr, dirname, pym->filename );
}
- fp = fopen(filestr, "rb");
- if (!fp) {
- printf("Error loading script: couldn't open file %s\n", filestr);
+ fp = fopen( filestr, "rb" );
+ if( !fp ) {
+ printf( "Error loading script: couldn't open file %s\n",
+ filestr );
return 0;
}
/* Create a new script structure and initialize it: */
- script = alloc_libblock(&G.main->script, ID_SCRIPT, pym->name);
+ script = alloc_libblock( &G.main->script, ID_SCRIPT, pym->name );
- if (!script) {
- printf("couldn't allocate memory for Script struct!");
- fclose(fp);
+ if( !script ) {
+ printf( "couldn't allocate memory for Script struct!" );
+ fclose( fp );
return 0;
}
/* let's find a proper area for an eventual script gui:
* (still experimenting here, need definition on which win
* each group will be put to code this properly) */
- switch (menutype) {
+ switch ( menutype ) {
- case PYMENU_IMPORT: /* first 3 were handled in header_info.c */
- case PYMENU_EXPORT:
- case PYMENU_HELP:
- case PYMENU_WIZARDS:
- break;
+ case PYMENU_IMPORT: /* first 3 were handled in header_info.c */
+ case PYMENU_EXPORT:
+ case PYMENU_HELP:
+ case PYMENU_WIZARDS:
+ break;
- default:
- if (curarea->spacetype != SPACE_SCRIPT) {
- ScrArea *sa = NULL;
+ default:
+ if( curarea->spacetype != SPACE_SCRIPT ) {
+ ScrArea *sa = NULL;
- sa = find_biggest_area_of_type(SPACE_BUTS);
- if (sa) {
- if ((1.5 * sa->winx) < sa->winy) sa = NULL; /* too narrow? */
- }
+ sa = find_biggest_area_of_type( SPACE_BUTS );
+ if( sa ) {
+ if( ( 1.5 * sa->winx ) < sa->winy )
+ sa = NULL; /* too narrow? */
+ }
- if (!sa) sa = find_biggest_area_of_type(SPACE_SCRIPT);
- if (!sa) sa = find_biggest_area_of_type(SPACE_TEXT);
- if (!sa) sa = find_biggest_area_of_type(SPACE_IMAGE); /* group UV */
- if (!sa) sa = find_biggest_area_of_type(SPACE_VIEW3D);
+ if( !sa )
+ sa = find_biggest_area_of_type( SPACE_SCRIPT );
+ if( !sa )
+ sa = find_biggest_area_of_type( SPACE_TEXT );
+ if( !sa )
+ sa = find_biggest_area_of_type( SPACE_IMAGE ); /* group UV */
+ if( !sa )
+ sa = find_biggest_area_of_type( SPACE_VIEW3D );
- if (!sa) sa = find_biggest_area();
+ if( !sa )
+ sa = find_biggest_area( );
- areawinset(sa->win);
- }
- break;
+ areawinset( sa->win );
+ }
+ break;
}
script->id.us = 1;
@@ -668,139 +704,146 @@ int BPY_menu_do_python(short menutype, int event)
script->py_event = NULL;
script->py_button = NULL;
- py_dict = CreateGlobalDictionary();
+ py_dict = CreateGlobalDictionary( );
script->py_globaldict = py_dict;
- info = (BPy_constant *)M_constant_New();
- if (info) {
- constant_insert(info, "name", PyString_FromString(script->id.name+2));
- constant_insert(info, "arg", pyarg);
- PyDict_SetItemString(py_dict, "__script__", (PyObject *)info);
+ info = ( BPy_constant * ) M_constant_New( );
+ if( info ) {
+ constant_insert( info, "name",
+ PyString_FromString( script->id.name + 2 ) );
+ constant_insert( info, "arg", pyarg );
+ PyDict_SetItemString( py_dict, "__script__",
+ ( PyObject * ) info );
}
- /* Previously we used PyRun_File to run directly the code on a FILE object,
- * but as written in the Python/C API Ref Manual, chapter 2,
- * 'FILE structs for different C libraries can be different and incompatible'
- *
+ /* Previously we used PyRun_File to run directly the code on a FILE
+ * object, but as written in the Python/C API Ref Manual, chapter 2,
+ * 'FILE structs for different C libraries can be different and
+ * incompatible'.
* So now we load the script file data to a buffer */
- fseek(fp, 0L, SEEK_END);
- len = ftell(fp);
- fseek(fp, 0L, SEEK_SET);
+ fseek( fp, 0L, SEEK_END );
+ len = ftell( fp );
+ fseek( fp, 0L, SEEK_SET );
- buffer = MEM_mallocN(len+2, "pyfilebuf"); /* len+2 to add '\n\0' */
- len = fread(buffer, 1, len, fp);
+ buffer = MEM_mallocN( len + 2, "pyfilebuf" ); /* len+2 to add '\n\0' */
+ len = fread( buffer, 1, len, fp );
- buffer[len] = '\n'; /* fix syntax error in files w/o eol*/
- buffer[len+1] = '\0';
+ buffer[len] = '\n'; /* fix syntax error in files w/o eol */
+ buffer[len + 1] = '\0';
/* fast clean-up of dos cr/lf line endings: change '\r' to space */
/* we also have to check for line splitters: '\\' */
/* to avoid possible syntax errors on dos files on win */
- /**/
- /* but first make sure we won't disturb memory below &buffer[0]: */
- if (*buffer == '\r') *buffer = ' ';
+ /**/
+ /* but first make sure we won't disturb memory below &buffer[0]: */
+ if( *buffer == '\r' )
+ *buffer = ' ';
/* now handle the whole buffer */
- for (s = buffer + 1; *s != '\0'; s++) {
- if (*s == '\r') {
- if (*(s-1) == '\\') { /* special case: long lines split with '\': */
- *(s-1) = ' '; /* we write ' \', because '\ ' is a syntax error */
+ for( s = buffer + 1; *s != '\0'; s++ ) {
+ if( *s == '\r' ) {
+ if( *( s - 1 ) == '\\' ) { /* special case: long lines split with '\': */
+ *( s - 1 ) = ' '; /* we write ' \', because '\ ' is a syntax error */
*s = '\\';
- }
- else *s = ' '; /* not a split line, just replace '\r' with ' ' */
+ } else
+ *s = ' '; /* not a split line, just replace '\r' with ' ' */
}
}
- fclose(fp);
+ fclose( fp );
/* run the string buffer */
- py_res = PyRun_String(buffer, Py_file_input, py_dict, py_dict);
+ py_res = PyRun_String( buffer, Py_file_input, py_dict, py_dict );
- MEM_freeN(buffer);
+ MEM_freeN( buffer );
- if (!py_res) { /* Failed execution of the script */
+ if( !py_res ) { /* Failed execution of the script */
- BPY_Err_Handle(script->id.name+2);
- PyErr_Print();
- ReleaseGlobalDictionary(py_dict);
- if (G.main->script.first) free_libblock(&G.main->script, script);
- error ("Python script error: check console");
+ BPY_Err_Handle( script->id.name + 2 );
+ PyErr_Print( );
+ ReleaseGlobalDictionary( py_dict );
+ if( G.main->script.first )
+ free_libblock( &G.main->script, script );
+ error( "Python script error: check console" );
return 0;
- }
- else {
- Py_DECREF (py_res);
- script->flags &=~SCRIPT_RUNNING;
+ } else {
+ Py_DECREF( py_res );
+ script->flags &= ~SCRIPT_RUNNING;
- if (!script->flags) {
- ReleaseGlobalDictionary(py_dict);
+ if( !script->flags ) {
+ ReleaseGlobalDictionary( py_dict );
script->py_globaldict = NULL;
- free_libblock(&G.main->script, script);
+ free_libblock( &G.main->script, script );
/* special case: called from the menu in the Scripts window
* we have to change sc->script pointer, since it'll be freed here.*/
- if (curarea->spacetype == SPACE_SCRIPT) {
+ if( curarea->spacetype == SPACE_SCRIPT ) {
SpaceScript *sc = curarea->spacedata.first;
- sc->script = G.main->script.first; /* can be null, which is ok ... */
+ sc->script = G.main->script.first; /* can be null, which is ok ... */
/* ... meaning no other script is running right now. */
}
-
+
}
}
- return 1; /* normal return */
+ return 1; /* normal return */
}
-/*****************************************************************************/
-/* Description: */
-/* Notes: */
-/*****************************************************************************/
-void BPY_free_compiled_text(struct Text* text)
+/*****************************************************************************
+* Description:
+* Notes:
+*****************************************************************************/
+void BPY_free_compiled_text( struct Text *text )
{
- if (!text->compiled) return;
- Py_DECREF((PyObject*) text->compiled);
+ if( !text->compiled )
+ return;
+ Py_DECREF( ( PyObject * ) text->compiled );
text->compiled = NULL;
return;
}
-/*****************************************************************************/
-/* Description: This function frees a finished (flags == 0) script. */
-/*****************************************************************************/
-void BPY_free_finished_script(Script *script)
+/*****************************************************************************
+* Description: This function frees a finished (flags == 0) script.
+*****************************************************************************/
+void BPY_free_finished_script( Script * script )
{
- if (!script) return;
+ if( !script )
+ return;
- if (PyErr_Occurred()) { /* if script ended after filesel */
- PyErr_Print(); /* eventual errors are handled now */
- error ("Python script error: check console");
+ if( PyErr_Occurred( ) ) { /* if script ended after filesel */
+ PyErr_Print( ); /* eventual errors are handled now */
+ error( "Python script error: check console" );
}
- free_libblock(&G.main->script, script);
+ free_libblock( &G.main->script, script );
return;
}
-void unlink_script(Script *script)
-{ /* copied from unlink_text in drawtext.c */
+void unlink_script( Script * script )
+{ /* copied from unlink_text in drawtext.c */
bScreen *scr;
ScrArea *area;
SpaceLink *sl;
- for (scr= G.main->screen.first; scr; scr= scr->id.next) {
- for (area= scr->areabase.first; area; area= area->next) {
- for (sl= area->spacedata.first; sl; sl= sl->next) {
- if (sl->spacetype==SPACE_SCRIPT) {
- SpaceScript *sc= (SpaceScript*) sl;
+ for( scr = G.main->screen.first; scr; scr = scr->id.next ) {
+ for( area = scr->areabase.first; area; area = area->next ) {
+ for( sl = area->spacedata.first; sl; sl = sl->next ) {
+ if( sl->spacetype == SPACE_SCRIPT ) {
+ SpaceScript *sc = ( SpaceScript * ) sl;
- if (sc->script==script) {
- sc->script= NULL;
+ if( sc->script == script ) {
+ sc->script = NULL;
- if (sc==area->spacedata.first) {
- scrarea_queue_redraw(area);
+ if( sc ==
+ area->spacedata.first ) {
+ scrarea_queue_redraw
+ ( area );
}
}
}
@@ -809,36 +852,37 @@ void unlink_script(Script *script)
}
}
-void BPY_clear_script (Script *script)
+void BPY_clear_script( Script * script )
{
PyObject *dict;
- if (!script) return;
+ if( !script )
+ return;
- Py_XDECREF((PyObject *)script->py_draw);
- Py_XDECREF((PyObject *)script->py_event);
- Py_XDECREF((PyObject *)script->py_button);
+ Py_XDECREF( ( PyObject * ) script->py_draw );
+ Py_XDECREF( ( PyObject * ) script->py_event );
+ Py_XDECREF( ( PyObject * ) script->py_button );
dict = script->py_globaldict;
- if (dict) {
- PyDict_Clear (dict);
- Py_DECREF (dict); /* Release dictionary. */
+ if( dict ) {
+ PyDict_Clear( dict );
+ Py_DECREF( dict ); /* Release dictionary. */
script->py_globaldict = NULL;
}
- unlink_script (script);
+ unlink_script( script );
}
/*****************************************************************************/
-/* ScriptLinks */
+/* ScriptLinks */
/*****************************************************************************/
/*****************************************************************************/
-/* Description: */
-/* Notes: Not implemented yet */
+/* Description: */
+/* Notes: Not implemented yet */
/*****************************************************************************/
-void BPY_clear_bad_scriptlinks(struct Text *byebye)
+void BPY_clear_bad_scriptlinks( struct Text *byebye )
{
/*
BPY_clear_bad_scriptlist(getObjectList(), byebye);
@@ -853,397 +897,427 @@ void BPY_clear_bad_scriptlinks(struct Text *byebye)
return;
}
-/*****************************************************************************/
-/* Description: Loop through all scripts of a list of object types, and */
-/* execute these scripts. */
-/* For the scene, only the current active scene the scripts are */
-/* executed (if any). */
-/*****************************************************************************/
-void BPY_do_all_scripts(short event)
+/*****************************************************************************
+* Description: Loop through all scripts of a list of object types, and
+* execute these scripts.
+* For the scene, only the current active scene the scripts are
+* executed (if any).
+*****************************************************************************/
+void BPY_do_all_scripts( short event )
{
- DoAllScriptsFromList (&(G.main->object), event);
- DoAllScriptsFromList (&(G.main->lamp), event);
- DoAllScriptsFromList (&(G.main->camera), event);
- DoAllScriptsFromList (&(G.main->mat), event);
- DoAllScriptsFromList (&(G.main->world), event);
+ DoAllScriptsFromList( &( G.main->object ), event );
+ DoAllScriptsFromList( &( G.main->lamp ), event );
+ DoAllScriptsFromList( &( G.main->camera ), event );
+ DoAllScriptsFromList( &( G.main->mat ), event );
+ DoAllScriptsFromList( &( G.main->world ), event );
- BPY_do_pyscript (&(G.scene->id), event);
+ BPY_do_pyscript( &( G.scene->id ), event );
return;
}
-/*****************************************************************************/
-/* Description: Execute a Python script when an event occurs. The following */
-/* events are possible: frame changed, load script and redraw. */
-/* Only events happening to one of the following object types */
-/* are handled: Object, Lamp, Camera, Material, World and */
-/* Scene. */
-/*****************************************************************************/
+/*****************************************************************************
+* Description: Execute a Python script when an event occurs. The following
+* events are possible: frame changed, load script and redraw.
+* Only events happening to one of the following object types
+* are handled: Object, Lamp, Camera, Material, World and
+* Scene.
+*****************************************************************************/
-static ScriptLink *ID_getScriptlink(ID *id)
+static ScriptLink *ID_getScriptlink( ID * id )
{
- switch (MAKE_ID2 (id->name[0], id->name[1])) {
+ switch ( MAKE_ID2( id->name[0], id->name[1] ) ) {
case ID_OB:
- return &((Object*)id)->scriptlink;
+ return &( ( Object * ) id )->scriptlink;
case ID_LA:
- return &((Lamp*)id)->scriptlink;
+ return &( ( Lamp * ) id )->scriptlink;
case ID_CA:
- return &((Camera*)id)->scriptlink;
+ return &( ( Camera * ) id )->scriptlink;
case ID_MA:
- return &((Material*)id)->scriptlink;
+ return &( ( Material * ) id )->scriptlink;
case ID_WO:
- return &((World*)id)->scriptlink;
+ return &( ( World * ) id )->scriptlink;
case ID_SCE:
- return &((Scene*)id)->scriptlink;
+ return &( ( Scene * ) id )->scriptlink;
default:
return NULL;
}
}
-static PyObject *ID_asPyObject(ID *id)
+static PyObject *ID_asPyObject( ID * id )
{
- switch (MAKE_ID2 (id->name[0], id->name[1])) {
+ switch ( MAKE_ID2( id->name[0], id->name[1] ) ) {
case ID_OB:
- return Object_CreatePyObject((Object*) id);
+ return Object_CreatePyObject( ( Object * ) id );
case ID_LA:
- return Lamp_CreatePyObject((Lamp*) id);
+ return Lamp_CreatePyObject( ( Lamp * ) id );
case ID_CA:
- return Camera_CreatePyObject((Camera*) id);
+ return Camera_CreatePyObject( ( Camera * ) id );
case ID_MA:
- return Material_CreatePyObject((Material*) id);
+ return Material_CreatePyObject( ( Material * ) id );
case ID_WO:
- return World_CreatePyObject((World*) id);
+ return World_CreatePyObject( ( World * ) id );
case ID_SCE:
- return Scene_CreatePyObject((Scene*) id);
+ return Scene_CreatePyObject( ( Scene * ) id );
default:
- Py_INCREF (Py_None);
+ Py_INCREF( Py_None );
return Py_None;
}
}
-int BPY_has_onload_script(void)
+int BPY_has_onload_script( void )
{
ScriptLink *slink = &G.scene->scriptlink;
int i;
- if (!slink || !slink->totscript) return 0;
+ if( !slink || !slink->totscript )
+ return 0;
- for (i = 0; i < slink->totscript; i++) {
- if ((slink->flag[i] == SCRIPT_ONLOAD) && (slink->scripts[i] != NULL))
- return 1;
+ for( i = 0; i < slink->totscript; i++ ) {
+ if( ( slink->flag[i] == SCRIPT_ONLOAD )
+ && ( slink->scripts[i] != NULL ) )
+ return 1;
}
return 0;
}
-void BPY_do_pyscript(ID *id, short event)
+void BPY_do_pyscript( ID * id, short event )
{
- ScriptLink *scriptlink = ID_getScriptlink(id);
+ ScriptLink *scriptlink = ID_getScriptlink( id );
- if (scriptlink && scriptlink->totscript) {
+ if( scriptlink && scriptlink->totscript ) {
PyObject *dict;
PyObject *ret;
- int index, during_slink = during_scriptlink();
+ int index, during_slink = during_scriptlink( );
/* invalid scriptlinks (new .blend was just loaded), return */
- if (during_slink < 0) return;
+ if( during_slink < 0 )
+ return;
/* tell we're running a scriptlink. The sum also tells if this script
* is running nested inside another. Blender.Load needs this info to
* avoid trouble with invalid slink pointers. */
during_slink++;
- disable_where_scriptlink(during_slink);
+ disable_where_scriptlink( during_slink );
/* set globals in Blender module to identify scriptlink */
- Py_INCREF(Py_True);
- PyDict_SetItemString(g_blenderdict, "bylink", Py_True);
- PyDict_SetItemString(g_blenderdict, "link", ID_asPyObject(id));
- PyDict_SetItemString(g_blenderdict, "event",
- PyString_FromString(event_to_name(event)));
-
- for (index = 0; index < scriptlink->totscript; index++) {
- if ((scriptlink->flag[index] == event) &&
- (scriptlink->scripts[index] != NULL)) {
- dict = CreateGlobalDictionary();
- ret = RunPython ((Text*) scriptlink->scripts[index], dict);
- ReleaseGlobalDictionary (dict);
-
- if (!ret) {
+ Py_INCREF( Py_True );
+ PyDict_SetItemString( g_blenderdict, "bylink", Py_True );
+ PyDict_SetItemString( g_blenderdict, "link",
+ ID_asPyObject( id ) );
+ PyDict_SetItemString( g_blenderdict, "event",
+ PyString_FromString( event_to_name
+ ( event ) ) );
+
+ for( index = 0; index < scriptlink->totscript; index++ ) {
+ if( ( scriptlink->flag[index] == event ) &&
+ ( scriptlink->scripts[index] != NULL ) ) {
+ dict = CreateGlobalDictionary( );
+ ret = RunPython( ( Text * ) scriptlink->
+ scripts[index], dict );
+ ReleaseGlobalDictionary( dict );
+
+ if( !ret ) {
/* Failed execution of the script */
- BPY_Err_Handle (scriptlink->scripts[index]->name+2);
+ BPY_Err_Handle( scriptlink->
+ scripts[index]->name +
+ 2 );
//BPY_end_python ();
//BPY_start_python ();
} else {
- Py_DECREF (ret);
+ Py_DECREF( ret );
}
/* If a scriptlink has just loaded a new .blend file, the
* scriptlink pointer became invalid (see api2_2x/Blender.c),
* so we stop here. */
- if (during_scriptlink() == -1) {
+ if( during_scriptlink( ) == -1 ) {
during_slink = 1;
break;
}
}
}
- disable_where_scriptlink(during_slink - 1);
-
- /* cleanup bylink flag and clear link so PyObject can be released */
- Py_INCREF(Py_False);
- PyDict_SetItemString(g_blenderdict, "bylink", Py_False);
- Py_INCREF(Py_None);
- PyDict_SetItemString(g_blenderdict, "link", Py_None);
- PyDict_SetItemString(g_blenderdict, "event", PyString_FromString(""));
+ disable_where_scriptlink( during_slink - 1 );
+
+ /* cleanup bylink flag and clear link so PyObject
+ * can be released
+ */
+ Py_INCREF( Py_False );
+ PyDict_SetItemString( g_blenderdict, "bylink", Py_False );
+ Py_INCREF( Py_None );
+ PyDict_SetItemString( g_blenderdict, "link", Py_None );
+ PyDict_SetItemString( g_blenderdict, "event",
+ PyString_FromString( "" ) );
}
}
-/*****************************************************************************/
-/* Description: */
-/* Notes: */
-/*****************************************************************************/
-void BPY_free_scriptlink(struct ScriptLink *slink)
+/*****************************************************************************
+* Description:
+* Notes:
+*****************************************************************************/
+void BPY_free_scriptlink( struct ScriptLink *slink )
{
- if (slink->totscript) {
- if(slink->flag) MEM_freeN(slink->flag);
- if(slink->scripts) MEM_freeN(slink->scripts);
+ if( slink->totscript ) {
+ if( slink->flag )
+ MEM_freeN( slink->flag );
+ if( slink->scripts )
+ MEM_freeN( slink->scripts );
}
return;
}
-/*****************************************************************************/
-/* Description: */
-/* Notes: */
-/*****************************************************************************/
-void BPY_copy_scriptlink(struct ScriptLink *scriptlink)
+/*****************************************************************************
+* Description:
+* Notes:
+*****************************************************************************/
+void BPY_copy_scriptlink( struct ScriptLink *scriptlink )
{
void *tmp;
- if (scriptlink->totscript) {
+ if( scriptlink->totscript ) {
tmp = scriptlink->scripts;
scriptlink->scripts =
- MEM_mallocN(sizeof(ID*)*scriptlink->totscript, "scriptlistL");
- memcpy(scriptlink->scripts, tmp, sizeof(ID*)*scriptlink->totscript);
+ MEM_mallocN( sizeof( ID * ) * scriptlink->totscript,
+ "scriptlistL" );
+ memcpy( scriptlink->scripts, tmp,
+ sizeof( ID * ) * scriptlink->totscript );
tmp = scriptlink->flag;
scriptlink->flag =
- MEM_mallocN(sizeof(short)*scriptlink->totscript, "scriptlistF");
- memcpy(scriptlink->flag, tmp, sizeof(short)*scriptlink->totscript);
+ MEM_mallocN( sizeof( short ) * scriptlink->totscript,
+ "scriptlistF" );
+ memcpy( scriptlink->flag, tmp,
+ sizeof( short ) * scriptlink->totscript );
}
return;
}
-/*****************************************************************************/
-/* Description: */
-/* Notes: Not implemented yet */
-/*****************************************************************************/
-int BPY_call_importloader(char *name)
-{ /* XXX Should this function go away from Blender? */
- printf ("In BPY_call_importloader(name=%s)\n",name);
- return (0);
+/****************************************************************************
+* Description:
+* Notes: Not implemented yet
+*****************************************************************************/
+int BPY_call_importloader( char *name )
+{ /* XXX Should this function go away from Blender? */
+ printf( "In BPY_call_importloader(name=%s)\n", name );
+ return ( 0 );
}
-/*****************************************************************************/
-/* Private functions */
-/*****************************************************************************/
+/*****************************************************************************
+* Private functions
+*****************************************************************************/
-/*****************************************************************************/
-/* Description: This function executes the python script passed by text. */
-/* The Python dictionary containing global variables needs to */
-/* be passed in globaldict. */
-/*****************************************************************************/
-PyObject * RunPython(Text *text, PyObject *globaldict)
+/*****************************************************************************
+* Description: This function executes the python script passed by text.
+* The Python dictionary containing global variables needs to
+* be passed in globaldict.
+*****************************************************************************/
+PyObject *RunPython( Text * text, PyObject * globaldict )
{
char *buf = NULL;
/* The script text is compiled to Python bytecode and saved at text->compiled
* to speed-up execution if the user executes the script multiple times */
- if (!text->compiled) { /* if it wasn't already compiled, do it now */
- buf = txt_to_buf(text);
+ if( !text->compiled ) { /* if it wasn't already compiled, do it now */
+ buf = txt_to_buf( text );
- text->compiled = Py_CompileString(buf, GetName(text), Py_file_input);
+ text->compiled =
+ Py_CompileString( buf, GetName( text ),
+ Py_file_input );
- MEM_freeN(buf);
+ MEM_freeN( buf );
- if (PyErr_Occurred()) {
- BPY_free_compiled_text(text);
+ if( PyErr_Occurred( ) ) {
+ BPY_free_compiled_text( text );
return NULL;
}
}
- return PyEval_EvalCode(text->compiled, globaldict, globaldict);
+ return PyEval_EvalCode( text->compiled, globaldict, globaldict );
}
-/*****************************************************************************/
-/* Description: This function returns the value of the name field of the */
-/* given Text struct. */
-/*****************************************************************************/
-char * GetName(Text *text)
+/*****************************************************************************
+* Description: This function returns the value of the name field of the
+* given Text struct.
+*****************************************************************************/
+char *GetName( Text * text )
{
- return (text->id.name+2);
+ return ( text->id.name + 2 );
}
-/*****************************************************************************/
-/* Description: This function creates a new Python dictionary object. */
-/*****************************************************************************/
-PyObject * CreateGlobalDictionary (void)
+/*****************************************************************************
+* Description: This function creates a new Python dictionary object.
+*****************************************************************************/
+PyObject *CreateGlobalDictionary( void )
{
- PyObject *dict = PyDict_New();
+ PyObject *dict = PyDict_New( );
- PyDict_SetItemString (dict, "__builtins__", PyEval_GetBuiltins());
- PyDict_SetItemString (dict, "__name__", PyString_FromString("__main__"));
+ PyDict_SetItemString( dict, "__builtins__", PyEval_GetBuiltins( ) );
+ PyDict_SetItemString( dict, "__name__",
+ PyString_FromString( "__main__" ) );
return dict;
}
-/*****************************************************************************/
-/* Description: This function deletes a given Python dictionary object. */
-/*****************************************************************************/
-void ReleaseGlobalDictionary (PyObject * dict)
+/*****************************************************************************
+* Description: This function deletes a given Python dictionary object.
+*****************************************************************************/
+void ReleaseGlobalDictionary( PyObject * dict )
{
- PyDict_Clear (dict);
- Py_DECREF (dict); /* Release dictionary. */
+ PyDict_Clear( dict );
+ Py_DECREF( dict ); /* Release dictionary. */
return;
}
-/*****************************************************************************/
-/* Description: This function runs all scripts (if any) present in the */
-/* list argument. The event by which the function has been */
-/* called, is passed in the event argument. */
-/*****************************************************************************/
-void DoAllScriptsFromList (ListBase *list, short event)
+/***************************************************************************
+* Description: This function runs all scripts (if any) present in the
+* list argument. The event by which the function has been
+* called, is passed in the event argument.
+*****************************************************************************/
+void DoAllScriptsFromList( ListBase * list, short event )
{
ID *id;
id = list->first;
- while (id != NULL) {
- BPY_do_pyscript (id, event);
+ while( id != NULL ) {
+ BPY_do_pyscript( id, event );
id = id->next;
}
return;
}
-PyObject *importText(char *name)
+PyObject *importText( char *name )
{
Text *text;
char *txtname;
char *buf = NULL;
- int namelen = strlen(name);
+ int namelen = strlen( name );
- txtname = malloc(namelen+3+1);
- if (!txtname) return NULL;
+ txtname = malloc( namelen + 3 + 1 );
+ if( !txtname )
+ return NULL;
- memcpy(txtname, name, namelen);
- memcpy(&txtname[namelen], ".py", 4);
+ memcpy( txtname, name, namelen );
+ memcpy( &txtname[namelen], ".py", 4 );
- text = (Text*) &(G.main->text.first);
+ text = ( Text * ) & ( G.main->text.first );
- while(text) {
- if (!strcmp (txtname, GetName(text)))
+ while( text ) {
+ if( !strcmp( txtname, GetName( text ) ) )
break;
text = text->id.next;
}
- if (!text) {
- free(txtname);
+ if( !text ) {
+ free( txtname );
return NULL;
}
- if (!text->compiled) {
- buf = txt_to_buf(text);
- text->compiled = Py_CompileString(buf, GetName(text), Py_file_input);
- MEM_freeN(buf);
-
- if (PyErr_Occurred()) {
- PyErr_Print();
- BPY_free_compiled_text(text);
- free(txtname);
+ if( !text->compiled ) {
+ buf = txt_to_buf( text );
+ text->compiled =
+ Py_CompileString( buf, GetName( text ),
+ Py_file_input );
+ MEM_freeN( buf );
+
+ if( PyErr_Occurred( ) ) {
+ PyErr_Print( );
+ BPY_free_compiled_text( text );
+ free( txtname );
return NULL;
}
}
- free(txtname);
- return PyImport_ExecCodeModule(name, text->compiled);
+ free( txtname );
+ return PyImport_ExecCodeModule( name, text->compiled );
}
static PyMethodDef bimport[] = {
- { "blimport", blender_import, METH_VARARGS, "our own import"}
+ {"blimport", blender_import, METH_VARARGS, "our own import"}
};
-PyObject *blender_import(PyObject *self, PyObject *args)
+PyObject *blender_import( PyObject * self, PyObject * args )
{
PyObject *exception, *err, *tb;
char *name;
PyObject *globals = NULL, *locals = NULL, *fromlist = NULL;
PyObject *m;
- if (!PyArg_ParseTuple(args, "s|OOO:bimport",
- &name, &globals, &locals, &fromlist))
- return NULL;
+ if( !PyArg_ParseTuple( args, "s|OOO:bimport",
+ &name, &globals, &locals, &fromlist ) )
+ return NULL;
- m = PyImport_ImportModuleEx(name, globals, locals, fromlist);
+ m = PyImport_ImportModuleEx( name, globals, locals, fromlist );
- if (m)
+ if( m )
return m;
else
- PyErr_Fetch(&exception, &err, &tb); /*restore for probable later use*/
-
- m = importText(name);
- if (m) { /* found module, ignore above exception*/
- PyErr_Clear();
- Py_XDECREF(exception); Py_XDECREF(err); Py_XDECREF(tb);
- printf("imported from text buffer...\n");
+ PyErr_Fetch( &exception, &err, &tb ); /*restore for probable later use */
+
+ m = importText( name );
+ if( m ) { /* found module, ignore above exception */
+ PyErr_Clear( );
+ Py_XDECREF( exception );
+ Py_XDECREF( err );
+ Py_XDECREF( tb );
+ printf( "imported from text buffer...\n" );
} else {
- PyErr_Restore(exception, err, tb);
+ PyErr_Restore( exception, err, tb );
}
return m;
}
-void init_ourImport(void)
+void init_ourImport( void )
{
PyObject *m, *d;
- PyObject *import = PyCFunction_New(bimport, NULL);
+ PyObject *import = PyCFunction_New( bimport, NULL );
- m = PyImport_AddModule("__builtin__");
- d = PyModule_GetDict(m);
- PyDict_SetItemString(d, "__import__", import);
+ m = PyImport_AddModule( "__builtin__" );
+ d = PyModule_GetDict( m );
+ PyDict_SetItemString( d, "__import__", import );
}
/* this makes sure BLI_gethome() returns a path with '.blender' appended
* Besides, this function now either returns userhome/.blender (if it exists)
- * or blenderInstallDir/.blender/ otherwise */
-char *bpy_gethome()
+ * or blenderInstallDir/.blender/ otherwise
+*/
+char *bpy_gethome( )
{
static char homedir[FILE_MAXDIR];
char bprogdir[FILE_MAXDIR];
char *s;
int i;
- if (homedir[0] != '\0') return homedir; /* no need to search twice */
+ if( homedir[0] != '\0' )
+ return homedir; /* no need to search twice */
- s = BLI_gethome();
+ s = BLI_gethome( );
- if (strstr(s, ".blender")) PyOS_snprintf(homedir, FILE_MAXDIR, s);
- else BLI_make_file_string ("/", homedir, s, ".blender/");
+ if( strstr( s, ".blender" ) )
+ PyOS_snprintf( homedir, FILE_MAXDIR, s );
+ else
+ BLI_make_file_string( "/", homedir, s, ".blender/" );
/* if userhome/.blender/ exists, return it */
- if (BLI_exists(homedir)) return homedir;
+ if( BLI_exists( homedir ) )
+ return homedir;
/* otherwise, use argv[0] (bprogname) to get .blender/ in
* Blender's installation dir */
- s = BLI_last_slash(bprogname);
+ s = BLI_last_slash( bprogname );
i = s - bprogname + 1;
- PyOS_snprintf(bprogdir, i, bprogname);
- BLI_make_file_string ("/", homedir, bprogdir, ".blender/");
+ PyOS_snprintf( bprogdir, i, bprogname );
+ BLI_make_file_string( "/", homedir, bprogdir, ".blender/" );
return homedir;
}
diff --git a/source/blender/python/BPY_menus.c b/source/blender/python/BPY_menus.c
index 1dbbbfed9a4..07ce418fc9a 100644
--- a/source/blender/python/BPY_menus.c
+++ b/source/blender/python/BPY_menus.c
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -29,9 +30,10 @@
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
-/* This is the main file responsible for having bpython scripts accessible
+/*
+ *This is the main file responsible for having bpython scripts accessible
* from Blender menus. To know more, please start with its header file.
-*/
+ */
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -50,14 +52,14 @@
#include "BLI_winstuff.h"
#include <io.h>
#include <direct.h>
-#endif
+#endif
#include "BKE_global.h"
#include "BKE_utildefines.h"
#include "BLI_blenlib.h"
#include "MEM_guardedalloc.h"
-#include <DNA_userdef_types.h> /* for U.pythondir */
+#include <DNA_userdef_types.h> /* for U.pythondir */
#include "BPY_extern.h"
#include "BPY_menus.h"
@@ -73,68 +75,79 @@ static int DEBUG;
*/
BPyMenu *BPyMenuTable[PYMENU_TOTAL];
-static int bpymenu_group_atoi (char *str)
+static int bpymenu_group_atoi( char *str )
{
- if (!strcmp(str, "Import")) return PYMENU_IMPORT;
- else if (!strcmp(str, "Export")) return PYMENU_EXPORT;
- else if (!strcmp(str, "Help")) return PYMENU_HELP;
- else if (!strcmp(str, "Websites") || !strcmp(str, "HelpWebsites"))
+ if( !strcmp( str, "Import" ) )
+ return PYMENU_IMPORT;
+ else if( !strcmp( str, "Export" ) )
+ return PYMENU_EXPORT;
+ else if( !strcmp( str, "Help" ) )
+ return PYMENU_HELP;
+ else if( !strcmp( str, "Websites" ) || !strcmp( str, "HelpWebsites" ) )
return PYMENU_HELPWEBSITES;
- else if (!strcmp(str, "System") || !strcmp(str, "HelpSystem"))
+ else if( !strcmp( str, "System" ) || !strcmp( str, "HelpSystem" ) )
return PYMENU_HELPSYSTEM;
- else if (!strcmp(str, "Add")) return PYMENU_ADD;
- else if (!strcmp(str, "Mesh")) return PYMENU_MESH;
- else if (!strcmp(str, "Wizards")) return PYMENU_WIZARDS;
- else if (!strcmp(str, "Animation")) return PYMENU_ANIMATION;
- else if (!strcmp(str, "Materials")) return PYMENU_MATERIALS;
- else if (!strcmp(str, "UV")) return PYMENU_UV;
- else if (!strcmp(str, "Object")) return PYMENU_OBJECT;
+ else if( !strcmp( str, "Add" ) )
+ return PYMENU_ADD;
+ else if( !strcmp( str, "Mesh" ) )
+ return PYMENU_MESH;
+ else if( !strcmp( str, "Wizards" ) )
+ return PYMENU_WIZARDS;
+ else if( !strcmp( str, "Animation" ) )
+ return PYMENU_ANIMATION;
+ else if( !strcmp( str, "Materials" ) )
+ return PYMENU_MATERIALS;
+ else if( !strcmp( str, "UV" ) )
+ return PYMENU_UV;
+ else if( !strcmp( str, "Object" ) )
+ return PYMENU_OBJECT;
/* "Misc" or an inexistent group name: use misc */
- else return PYMENU_MISC;
+ else
+ return PYMENU_MISC;
}
-char *BPyMenu_group_itoa (short menugroup)
+char *BPyMenu_group_itoa( short menugroup )
{
- switch (menugroup) {
- case PYMENU_IMPORT:
- return "Import";
- break;
- case PYMENU_EXPORT:
- return "Export";
- break;
- case PYMENU_ADD:
- return "Add";
- break;
- case PYMENU_HELP:
- return "Help";
- break;
- case PYMENU_HELPWEBSITES:
- return "Websites";
- break;
- case PYMENU_HELPSYSTEM:
- return "System";
- break;
- case PYMENU_MESH:
- return "Mesh";
- break;
- case PYMENU_WIZARDS:
- return "Wizards";
- break;
- case PYMENU_ANIMATION:
- return "Animation";
- break;
- case PYMENU_MATERIALS:
- return "Materials";
- break;
- case PYMENU_UV:
- return "UV";
- break;
- case PYMENU_OBJECT:
- return "Object";
- break;
- case PYMENU_MISC:
- return "Misc";
- break;
+ switch ( menugroup ) {
+ case PYMENU_IMPORT:
+ return "Import";
+ break;
+ case PYMENU_EXPORT:
+ return "Export";
+ break;
+ case PYMENU_ADD:
+ return "Add";
+ break;
+ case PYMENU_HELP:
+ return "Help";
+ break;
+ case PYMENU_HELPWEBSITES:
+ return "Websites";
+ break;
+ case PYMENU_HELPSYSTEM:
+ return "System";
+ break;
+ case PYMENU_MESH:
+ return "Mesh";
+ break;
+ case PYMENU_WIZARDS:
+ return "Wizards";
+ break;
+ case PYMENU_ANIMATION:
+ return "Animation";
+ break;
+ case PYMENU_MATERIALS:
+ return "Materials";
+ break;
+ case PYMENU_UV:
+ return "UV";
+ break;
+ case PYMENU_OBJECT:
+ return "Object";
+ break;
+ case PYMENU_MISC:
+ return "Misc";
+ break;
}
return NULL;
}
@@ -144,59 +157,68 @@ char *BPyMenu_group_itoa (short menugroup)
* string is made of a bpymenu name as title and its submenus as possible
* choices for the user.
*/
-char *BPyMenu_CreatePupmenuStr(BPyMenu *pym, short menugroup)
+char *BPyMenu_CreatePupmenuStr( BPyMenu * pym, short menugroup )
{
BPySubMenu *pysm = pym->submenus;
char str[1024], str2[100];
int i = 0, rlen;
- if (!pym || !pysm) return NULL;
+ if( !pym || !pysm )
+ return NULL;
str[0] = '\0';
- PyOS_snprintf(str2, sizeof(str2), "%s: %s%%t",
- BPyMenu_group_itoa(menugroup), pym->name);
- strcat(str, str2);
+ PyOS_snprintf( str2, sizeof( str2 ), "%s: %s%%t",
+ BPyMenu_group_itoa( menugroup ), pym->name );
+ strcat( str, str2 );
- while (pysm) {
- PyOS_snprintf(str2, sizeof(str2), "|%s%%x%d", pysm->name, i);
- rlen = sizeof(str) - strlen(str);
- strncat(str, str2, rlen);
+ while( pysm ) {
+ PyOS_snprintf( str2, sizeof( str2 ), "|%s%%x%d", pysm->name,
+ i );
+ rlen = sizeof( str ) - strlen( str );
+ strncat( str, str2, rlen );
i++;
pysm = pysm->next;
}
- return BLI_strdup(str);
+ return BLI_strdup( str );
}
-static void bpymenu_RemoveAllSubEntries (BPySubMenu *smenu)
+static void bpymenu_RemoveAllSubEntries( BPySubMenu * smenu )
{
BPySubMenu *tmp;
- while (smenu) {
+ while( smenu ) {
tmp = smenu->next;
- if (smenu->name) MEM_freeN(smenu->name);
- if (smenu->arg) MEM_freeN(smenu->arg);
- MEM_freeN(smenu);
+ if( smenu->name )
+ MEM_freeN( smenu->name );
+ if( smenu->arg )
+ MEM_freeN( smenu->arg );
+ MEM_freeN( smenu );
smenu = tmp;
}
return;
}
-void BPyMenu_RemoveAllEntries (void)
+void BPyMenu_RemoveAllEntries( void )
{
BPyMenu *tmp, *pymenu;
int i;
- for (i = 0; i < PYMENU_TOTAL; i++) {
+ for( i = 0; i < PYMENU_TOTAL; i++ ) {
pymenu = BPyMenuTable[i];
- while (pymenu) {
+ while( pymenu ) {
tmp = pymenu->next;
- if (pymenu->name) MEM_freeN(pymenu->name);
- if (pymenu->filename) MEM_freeN(pymenu->filename);
- if (pymenu->tooltip) MEM_freeN(pymenu->tooltip);
- if (pymenu->submenus) bpymenu_RemoveAllSubEntries(pymenu->submenus);
- MEM_freeN(pymenu);
+ if( pymenu->name )
+ MEM_freeN( pymenu->name );
+ if( pymenu->filename )
+ MEM_freeN( pymenu->filename );
+ if( pymenu->tooltip )
+ MEM_freeN( pymenu->tooltip );
+ if( pymenu->submenus )
+ bpymenu_RemoveAllSubEntries( pymenu->
+ submenus );
+ MEM_freeN( pymenu );
pymenu = tmp;
}
BPyMenuTable[i] = NULL;
@@ -204,16 +226,18 @@ void BPyMenu_RemoveAllEntries (void)
return;
}
-static BPyMenu *bpymenu_FindEntry (short group, char *name)
+static BPyMenu *bpymenu_FindEntry( short group, char *name )
{
BPyMenu *pymenu;
- if ((group <0) || (group >= PYMENU_TOTAL)) return NULL;
+ if( ( group < 0 ) || ( group >= PYMENU_TOTAL ) )
+ return NULL;
pymenu = BPyMenuTable[group];
- while (pymenu) {
- if (!strcmp(pymenu->name, name)) return pymenu;
+ while( pymenu ) {
+ if( !strcmp( pymenu->name, name ) )
+ return pymenu;
pymenu = pymenu->next;
}
@@ -223,29 +247,34 @@ static BPyMenu *bpymenu_FindEntry (short group, char *name)
/* BPyMenu_GetEntry:
* given a group and a position, return the entry in that position from
* that group.
-*/
-BPyMenu *BPyMenu_GetEntry (short group, short pos)
+*/
+BPyMenu *BPyMenu_GetEntry( short group, short pos )
{
BPyMenu *pym = NULL;
- if ((group < 0) || (group >= PYMENU_TOTAL)) return NULL;
+ if( ( group < 0 ) || ( group >= PYMENU_TOTAL ) )
+ return NULL;
pym = BPyMenuTable[group];
- while (pos--) {
- if (pym) pym = pym->next;
- else break;
+ while( pos-- ) {
+ if( pym )
+ pym = pym->next;
+ else
+ break;
}
- return pym; /* found entry or NULL */
+ return pym; /* found entry or NULL */
}
-
-static void bpymenu_set_tooltip (BPyMenu *pymenu, char *tip)
+
+static void bpymenu_set_tooltip( BPyMenu * pymenu, char *tip )
{
- if (!pymenu) return;
+ if( !pymenu )
+ return;
- if (pymenu->tooltip) MEM_freeN(pymenu->tooltip);
- pymenu->tooltip = BLI_strdup(tip);
+ if( pymenu->tooltip )
+ MEM_freeN( pymenu->tooltip );
+ pymenu->tooltip = BLI_strdup( tip );
return;
}
@@ -254,73 +283,82 @@ static void bpymenu_set_tooltip (BPyMenu *pymenu, char *tip)
* try to find an existing pymenu entry with the given type and name;
* if found, update it with new info, otherwise create a new one and fill it.
*/
-static BPyMenu *bpymenu_AddEntry (short group, short version, char *name,
- char *fname, int whichdir, char *tooltip)
+static BPyMenu *bpymenu_AddEntry( short group, short version, char *name,
+ char *fname, int whichdir, char *tooltip )
{
BPyMenu *menu, *next = NULL, **iter;
int nameclash = 0;
- if ((group < 0) || (group >= PYMENU_TOTAL)) return NULL;
- if (!name || !fname) return NULL;
+ if( ( group < 0 ) || ( group >= PYMENU_TOTAL ) )
+ return NULL;
+ if( !name || !fname )
+ return NULL;
- menu = bpymenu_FindEntry (group, name); /* already exists? */
+ menu = bpymenu_FindEntry( group, name ); /* already exists? */
/* if a menu with this name already exists in the same group:
* - if one script is in the default dir and the other in U.pythondir,
* accept and let the new one override the other.
* - otherwise, report the error and return NULL. */
- if (menu) {
- if (menu->dir < whichdir) { /* new one is in U.pythondir */
+ if( menu ) {
+ if( menu->dir < whichdir ) { /* new one is in U.pythondir */
nameclash = 1;
- if (menu->name) MEM_freeN(menu->name);
- if (menu->filename) MEM_freeN(menu->filename);
- if (menu->tooltip) MEM_freeN(menu->tooltip);
- if (menu->submenus) bpymenu_RemoveAllSubEntries(menu->submenus);
+ if( menu->name )
+ MEM_freeN( menu->name );
+ if( menu->filename )
+ MEM_freeN( menu->filename );
+ if( menu->tooltip )
+ MEM_freeN( menu->tooltip );
+ if( menu->submenus )
+ bpymenu_RemoveAllSubEntries( menu->submenus );
next = menu->next;
- }
- else { /* they are in the same dir */
- if (DEBUG) {
- printf("\nWarning: script %s's menu name is already in use.\n", fname);
- printf ("Edit the script and change its Name: '%s' field, please.\n"
- "Note: if you really want two scripts in the same menu with\n"
- "the same name, keep one in the default dir and the other in\n"
- "the user defined dir, where it will take precedence.\n", name);
+ } else { /* they are in the same dir */
+ if( DEBUG ) {
+ printf( "\nWarning: script %s's menu name is already in use.\n", fname );
+ printf( "Edit the script and change its Name: '%s' field, please.\n" "Note: if you really want two scripts in the same menu with\n" "the same name, keep one in the default dir and the other in\n" "the user defined dir, where it will take precedence.\n", name );
}
return NULL;
}
- }
- else menu = MEM_mallocN(sizeof(BPyMenu), "pymenu");
+ } else
+ menu = MEM_mallocN( sizeof( BPyMenu ), "pymenu" );
- if (!menu) return NULL;
+ if( !menu )
+ return NULL;
- menu->name = BLI_strdup(name);
+ menu->name = BLI_strdup( name );
menu->version = version;
- menu->filename = BLI_strdup(fname);
+ menu->filename = BLI_strdup( fname );
menu->tooltip = NULL;
- if (tooltip) menu->tooltip = BLI_strdup(tooltip);
+ if( tooltip )
+ menu->tooltip = BLI_strdup( tooltip );
menu->dir = whichdir;
menu->submenus = NULL;
- menu->next = next; /* non-NULL if menu already existed */
+ menu->next = next; /* non-NULL if menu already existed */
- if (nameclash) return menu; /* no need to place it, it's already at the list*/
- else { /* insert the new entry in its correct position at the table */
+ if( nameclash )
+ return menu; /* no need to place it, it's already at the list */
+ else { /* insert the new entry in its correct position at the table */
BPyMenu *prev = NULL;
char *s = NULL;
iter = &BPyMenuTable[group];
- while (*iter) {
- s = (*iter)->name;
- if (s) if (strcmp(menu->name, s) < 0) break; /* sort by names */
+ while( *iter ) {
+ s = ( *iter )->name;
+ if( s )
+ if( strcmp( menu->name, s ) < 0 )
+ break; /* sort by names */
prev = *iter;
- iter = &((*iter)->next);
+ iter = &( ( *iter )->next );
}
- if (*iter) { /* prepend */
+ if( *iter ) { /* prepend */
menu->next = *iter;
- if (prev) prev->next = menu;
- else BPyMenuTable[group] = menu; /* is first entry */
- }
- else *iter = menu; /* append */
+ if( prev )
+ prev->next = menu;
+ else
+ BPyMenuTable[group] = menu; /* is first entry */
+ } else
+ *iter = menu; /* append */
}
return menu;
@@ -329,21 +367,24 @@ static BPyMenu *bpymenu_AddEntry (short group, short version, char *name,
/* bpymenu_AddSubEntry:
* add a submenu to an existing python menu.
*/
-static int bpymenu_AddSubEntry (BPyMenu *mentry, char *name, char *arg)
+static int bpymenu_AddSubEntry( BPyMenu * mentry, char *name, char *arg )
{
BPySubMenu *smenu, **iter;
- smenu = MEM_mallocN(sizeof(BPySubMenu), "pysubmenu");
- if (!smenu) return -1;
+ smenu = MEM_mallocN( sizeof( BPySubMenu ), "pysubmenu" );
+ if( !smenu )
+ return -1;
- smenu->name = BLI_strdup(name);
- smenu->arg = BLI_strdup(arg);
+ smenu->name = BLI_strdup( name );
+ smenu->arg = BLI_strdup( arg );
smenu->next = NULL;
- if (!smenu->name || !smenu->arg) return -1;
+ if( !smenu->name || !smenu->arg )
+ return -1;
- iter = &(mentry->submenus);
- while (*iter) iter = &((*iter)->next);
+ iter = &( mentry->submenus );
+ while( *iter )
+ iter = &( ( *iter )->next );
*iter = smenu;
@@ -354,7 +395,7 @@ static int bpymenu_AddSubEntry (BPyMenu *mentry, char *name, char *arg)
* parse the bpymenus data file where Python menu data is stored;
* based on this data, create and fill the pymenu structs.
*/
-static int bpymenu_CreateFromFile (void)
+static int bpymenu_CreateFromFile( void )
{
FILE *fp;
char line[255], w1[255], w2[255], tooltip[255], *tip;
@@ -364,82 +405,92 @@ static int bpymenu_CreateFromFile (void)
/* init global bpymenu table (it is a list of pointers to struct BPyMenus
* for each available cathegory: import, export, etc.) */
- for (group = 0; group < PYMENU_TOTAL; group++)
+ for( group = 0; group < PYMENU_TOTAL; group++ )
BPyMenuTable[group] = NULL;
/* let's try to open the file with bpymenu data */
- BLI_make_file_string ("/", line, bpy_gethome(), BPYMENU_DATAFILE);
+ BLI_make_file_string( "/", line, bpy_gethome( ), BPYMENU_DATAFILE );
- fp = fopen(line, "rb");
+ fp = fopen( line, "rb" );
- if (!fp) {
- if (DEBUG) printf("BPyMenus error: couldn't open config file %s.\n", line);
+ if( !fp ) {
+ if( DEBUG )
+ printf( "BPyMenus error: couldn't open config file %s.\n", line );
return -1;
}
- fgets(line, 255, fp); /* header */
+ fgets( line, 255, fp ); /* header */
/* check if the U.pythondir we saved at the file is different from the
* current one. If so, return to force updating from dirs */
w1[0] = '\0';
- fscanf(fp, "# User defined scripts dir: %[^\n]\n", w1);
- if (w1) {
- if (strcmp(w1, U.pythondir) != 0) return -1;
+ fscanf( fp, "# User defined scripts dir: %[^\n]\n", w1 );
+ if( w1 ) {
+ if( strcmp( w1, U.pythondir ) != 0 )
+ return -1;
w1[0] = '\0';
}
- while (fgets(line, 255, fp)) { /* parsing file lines */
+ while( fgets( line, 255, fp ) ) { /* parsing file lines */
- switch (line[0]) { /* check first char */
- case '#': /* comment */
- continue;
- break;
- case '\n':
- continue;
- break;
- default:
- parsing = sscanf(line, "%s {\n", w1); /* menu group */
- break;
+ switch ( line[0] ) { /* check first char */
+ case '#': /* comment */
+ continue;
+ break;
+ case '\n':
+ continue;
+ break;
+ default:
+ parsing = sscanf( line, "%s {\n", w1 ); /* menu group */
+ break;
}
- if (parsing == 1) { /* got menu group string */
- group = bpymenu_group_atoi(w1);
- if (group < 0 && DEBUG) { /* invalid type */
- printf("BPyMenus error parsing config file: wrong group: %s, "
- "will use 'Misc'.\n", w1);
+ if( parsing == 1 ) { /* got menu group string */
+ group = bpymenu_group_atoi( w1 );
+ if( group < 0 && DEBUG ) { /* invalid type */
+ printf( "BPyMenus error parsing config file: wrong group: %s, " "will use 'Misc'.\n", w1 );
}
- }
- else continue;
-
- while (1) {
- tip = NULL; /* optional tooltip */
- fgets(line, 255, fp);
- if (line[0] == '}') break;
- else if (line[0] == '\n') continue;
- else if (line[0] == '\'') { /* menu entry */
- parsing = sscanf(line, "'%[^']' %d %s %d '%[^']'\n", w1, &version, w2, &whichdir, tooltip);
-
- if (parsing <= 0) { /* invalid line, get rid of it */
- fgets(line, 255, fp);
- }
- else if (parsing == 5) tip = tooltip; /* has tooltip */
+ } else
+ continue;
- pymenu = bpymenu_AddEntry(group, (short)version, w1, w2, whichdir, tip);
- if (!pymenu) {
- puts("BPyMenus error: couldn't create bpymenu entry.\n");
- fclose(fp);
+ while( 1 ) {
+ tip = NULL; /* optional tooltip */
+ fgets( line, 255, fp );
+ if( line[0] == '}' )
+ break;
+ else if( line[0] == '\n' )
+ continue;
+ else if( line[0] == '\'' ) { /* menu entry */
+ parsing =
+ sscanf( line,
+ "'%[^']' %d %s %d '%[^']'\n",
+ w1, &version, w2, &whichdir,
+ tooltip );
+
+ if( parsing <= 0 ) { /* invalid line, get rid of it */
+ fgets( line, 255, fp );
+ } else if( parsing == 5 )
+ tip = tooltip; /* has tooltip */
+
+ pymenu = bpymenu_AddEntry( group,
+ ( short ) version,
+ w1, w2, whichdir,
+ tip );
+ if( !pymenu ) {
+ puts( "BPyMenus error: couldn't create bpymenu entry.\n" );
+ fclose( fp );
return -1;
}
- }
- else if (line[0] == '|' && line[1] == '_') { /* menu sub-entry */
- if (!pymenu) continue; /* no menu yet, skip this line */
- sscanf(line, "|_%[^:]: %s\n", w1, w2);
- bpymenu_AddSubEntry(pymenu, w1, w2);
+ } else if( line[0] == '|' && line[1] == '_' ) { /* menu sub-entry */
+ if( !pymenu )
+ continue; /* no menu yet, skip this line */
+ sscanf( line, "|_%[^:]: %s\n", w1, w2 );
+ bpymenu_AddSubEntry( pymenu, w1, w2 );
}
}
}
- fclose(fp);
+ fclose( fp );
return 0;
}
@@ -447,75 +498,88 @@ static int bpymenu_CreateFromFile (void)
* writes the registered scripts info to the user's home dir, for faster
* access when the scripts dir hasn't changed.
*/
-static void bpymenu_WriteDataFile(void)
+static void bpymenu_WriteDataFile( void )
{
BPyMenu *pymenu;
BPySubMenu *smenu;
FILE *fp;
- char fname[FILE_MAXDIR+FILE_MAXFILE];
+ char fname[FILE_MAXDIR + FILE_MAXFILE];
int i;
- BLI_make_file_string("/", fname, bpy_gethome(), BPYMENU_DATAFILE);
+ BLI_make_file_string( "/", fname, bpy_gethome( ), BPYMENU_DATAFILE );
- fp = fopen(fname, "w");
- if (!fp) {
- if (DEBUG) printf("BPyMenus error: couldn't write %s file.", fname);
+ fp = fopen( fname, "w" );
+ if( !fp ) {
+ if( DEBUG )
+ printf( "BPyMenus error: couldn't write %s file.",
+ fname );
return;
}
- fprintf(fp, "# Blender: registered menu entries for bpython scripts\n");
+ fprintf( fp,
+ "# Blender: registered menu entries for bpython scripts\n" );
- if (U.pythondir[0] != '\0')
- fprintf(fp, "# User defined scripts dir: %s\n", U.pythondir);
+ if( U.pythondir[0] != '\0' )
+ fprintf( fp, "# User defined scripts dir: %s\n", U.pythondir );
- for (i = 0; i < PYMENU_TOTAL; i++) {
+ for( i = 0; i < PYMENU_TOTAL; i++ ) {
pymenu = BPyMenuTable[i];
- if (!pymenu) continue;
- fprintf(fp, "\n%s {\n", BPyMenu_group_itoa(i));
- while (pymenu) {
- fprintf(fp,"'%s' %d %s %d", pymenu->name, pymenu->version, pymenu->filename, pymenu->dir);
- if (pymenu->tooltip) fprintf(fp, " '%s'\n", pymenu->tooltip);
- else fprintf(fp, "\n");
+ if( !pymenu )
+ continue;
+ fprintf( fp, "\n%s {\n", BPyMenu_group_itoa( i ) );
+ while( pymenu ) {
+ fprintf( fp, "'%s' %d %s %d", pymenu->name,
+ pymenu->version, pymenu->filename,
+ pymenu->dir );
+ if( pymenu->tooltip )
+ fprintf( fp, " '%s'\n", pymenu->tooltip );
+ else
+ fprintf( fp, "\n" );
smenu = pymenu->submenus;
- while (smenu) {
- fprintf(fp, "|_%s: %s\n", smenu->name, smenu->arg);
+ while( smenu ) {
+ fprintf( fp, "|_%s: %s\n", smenu->name,
+ smenu->arg );
smenu = smenu->next;
}
pymenu = pymenu->next;
}
- fprintf(fp, "}\n");
+ fprintf( fp, "}\n" );
}
- fclose(fp);
+ fclose( fp );
return;
}
/* BPyMenu_PrintAllEntries:
* useful for debugging.
-*/
-void BPyMenu_PrintAllEntries(void)
+ */
+void BPyMenu_PrintAllEntries( void )
{
BPyMenu *pymenu;
BPySubMenu *smenu;
int i;
- printf("# Blender: registered menu entries for bpython scripts\n");
+ printf( "# Blender: registered menu entries for bpython scripts\n" );
- for (i = 0; i < PYMENU_TOTAL; i++) {
+ for( i = 0; i < PYMENU_TOTAL; i++ ) {
pymenu = BPyMenuTable[i];
- printf("\n%s {\n", BPyMenu_group_itoa(i));
- while (pymenu) {
- printf("'%s' %d %s %d", pymenu->name, pymenu->version, pymenu->filename, pymenu->dir);
- if (pymenu->tooltip) printf(" '%s'\n", pymenu->tooltip);
- else printf("\n");
+ printf( "\n%s {\n", BPyMenu_group_itoa( i ) );
+ while( pymenu ) {
+ printf( "'%s' %d %s %d", pymenu->name, pymenu->version,
+ pymenu->filename, pymenu->dir );
+ if( pymenu->tooltip )
+ printf( " '%s'\n", pymenu->tooltip );
+ else
+ printf( "\n" );
smenu = pymenu->submenus;
- while (smenu) {
- printf("|_%s: %s\n", smenu->name, smenu->arg);
+ while( smenu ) {
+ printf( "|_%s: %s\n", smenu->name,
+ smenu->arg );
smenu = smenu->next;
}
pymenu = pymenu->next;
}
- printf("}\n");
+ printf( "}\n" );
}
}
@@ -526,62 +590,72 @@ void BPyMenu_PrintAllEntries(void)
* user defined one (U.pythondir: whichdir == 1).
* Speed is important.
*/
-static int bpymenu_CreateFromDir (char *dirname, int whichdir)
+static int bpymenu_CreateFromDir( char *dirname, int whichdir )
{
DIR *dir;
FILE *fp;
struct stat st;
struct dirent *dir_entry;
BPyMenu *pymenu;
- char *s, *fname, str[FILE_MAXFILE+FILE_MAXDIR];
+ char *s, *fname, str[FILE_MAXFILE + FILE_MAXDIR];
char line[100], w[100];
char name[100], submenu[100], subarg[100], tooltip[100];
int res = 0, version = 0;
- dir = opendir(dirname);
+ dir = opendir( dirname );
- if (!dir) return -1;
+ if( !dir )
+ return -1;
/* we scan the dir for filenames ending with .py and starting with the
* right 'magic number': '#!BPY'. All others are ignored. */
- while ((dir_entry = readdir(dir)) != NULL) {
+ while( ( dir_entry = readdir( dir ) ) != NULL ) {
fname = dir_entry->d_name;
/* ignore anything starting with a dot */
- if (fname[0] == '.') continue; /* like . and .. */
+ if( fname[0] == '.' )
+ continue; /* like . and .. */
/* also skip filenames whose extension isn't '.py' */
- s = strstr(fname, ".py");
- if (!s || *(s+3) != '\0') continue;
+ s = strstr( fname, ".py" );
+ if( !s || *( s + 3 ) != '\0' )
+ continue;
- BLI_make_file_string("/", str, dirname, fname);
+ BLI_make_file_string( "/", str, dirname, fname );
/* paranoia: check if this is really a file and not a disguised dir */
- if ((stat(str, &st) == -1) || !S_ISREG(st.st_mode)) continue;
+ if( ( stat( str, &st ) == -1 ) || !S_ISREG( st.st_mode ) )
+ continue;
- fp = fopen(str, "rb");
+ fp = fopen( str, "rb" );
- if (!fp) {
- if (DEBUG) printf("BPyMenus error: couldn't open %s.\n", str);
+ if( !fp ) {
+ if( DEBUG )
+ printf( "BPyMenus error: couldn't open %s.\n",
+ str );
continue;
}
/* finally, look for the start string '#!BPY', with
* or w/o white space(s) between #! and BPY */
- fgets(line, 100, fp);
- if (line[0] != '#' || line[1] != '!') goto discard;
+ fgets( line, 100, fp );
+ if( line[0] != '#' || line[1] != '!' )
+ goto discard;
- if (!strstr (line, "BPY")) goto discard;
+ if( !strstr( line, "BPY" ) )
+ goto discard;
/* file passed the tests, look for the three double-quotes */
- while (fgets(line, 100, fp)) {
- if (line[0] == '"' && line[1] == '"' && line[2] == '"') {
- res = 1; /* found */
+ while( fgets( line, 100, fp ) ) {
+ if( line[0] == '"' && line[1] == '"'
+ && line[2] == '"' ) {
+ res = 1; /* found */
break;
}
}
- if (!res) goto discard;
+ if( !res )
+ goto discard;
/* Now we're ready to get the registration info. A little more structure
* was imposed to their format, for speed. The registration
@@ -601,78 +675,90 @@ static int bpymenu_CreateFromDir (char *dirname, int whichdir)
* Blender.Get('version') in BPython or G.version in C;
* - only the first letter of each token is checked, both lower
* and upper cases, so that's all that matters for recognition:
- * n 'script name' is enough for the name line, for example. */
+ * n 'script name' is enough for the name line, for example. */
/* first the name: */
- res = fscanf(fp, "%[^']'%[^'\r\n]'\n", w, name);
- if ((res != 2) || (w[0] != 'n' && w[0] != 'N')) {
- if (DEBUG) printf("BPyMenus error: wrong 'name' line in %s.\n", str);
+ res = fscanf( fp, "%[^']'%[^'\r\n]'\n", w, name );
+ if( ( res != 2 ) || ( w[0] != 'n' && w[0] != 'N' ) ) {
+ if( DEBUG )
+ printf( "BPyMenus error: wrong 'name' line in %s.\n", str );
goto discard;
}
- line[0] = '\0'; /* used as group for this part */
+ line[0] = '\0'; /* used as group for this part */
/* minimal Blender version: */
- res = fscanf(fp, "%s %d\n", w, &version);
- if ((res != 2) || (w[0] != 'b' && w[0] != 'B')) {
- if (DEBUG) printf("BPyMenus error: wrong 'blender' line in %s.\n", str);
+ res = fscanf( fp, "%s %d\n", w, &version );
+ if( ( res != 2 ) || ( w[0] != 'b' && w[0] != 'B' ) ) {
+ if( DEBUG )
+ printf( "BPyMenus error: wrong 'blender' line in %s.\n", str );
goto discard;
}
/* the group: */
- res = fscanf(fp, "%[^']'%[^'\r\n]'\n", w, line);
- if ((res != 2) || (w[0] != 'g' && w[0] != 'G')) {
- if (DEBUG) printf("BPyMenus error: wrong 'group' line in %s.\n", str);
+ res = fscanf( fp, "%[^']'%[^'\r\n]'\n", w, line );
+ if( ( res != 2 ) || ( w[0] != 'g' && w[0] != 'G' ) ) {
+ if( DEBUG )
+ printf( "BPyMenus error: wrong 'group' line in %s.\n", str );
goto discard;
}
- res = bpymenu_group_atoi(line);
- if (res < 0) {
- if (DEBUG) printf("BPyMenus error: unknown 'group' %s in %s.\n", line, str);
+ res = bpymenu_group_atoi( line );
+ if( res < 0 ) {
+ if( DEBUG )
+ printf( "BPyMenus error: unknown 'group' %s in %s.\n", line, str );
goto discard;
}
- pymenu = bpymenu_AddEntry(res, (short)version, name, fname, whichdir, NULL);
- if (!pymenu) {
- if (DEBUG) printf("BPyMenus error: couldn't create entry for %s.\n", str);
- fclose(fp);
- closedir(dir);
+ pymenu = bpymenu_AddEntry( res, ( short ) version, name, fname,
+ whichdir, NULL );
+ if( !pymenu ) {
+ if( DEBUG )
+ printf( "BPyMenus error: couldn't create entry for %s.\n", str );
+ fclose( fp );
+ closedir( dir );
return -2;
}
/* the (optional) submenu(s): */
- while (fgets (line, 100, fp)) {
- res = sscanf(line, "%[^']'%[^'\r\n]'%s\n", w, submenu, subarg);
- if ((res != 3) || (w[0] != 's' && w[0] != 'S')) break;
- bpymenu_AddSubEntry(pymenu, submenu, subarg);
- }
+ while( fgets( line, 100, fp ) ) {
+ res = sscanf( line, "%[^']'%[^'\r\n]'%s\n", w, submenu,
+ subarg );
+ if( ( res != 3 ) || ( w[0] != 's' && w[0] != 'S' ) )
+ break;
+ bpymenu_AddSubEntry( pymenu, submenu, subarg );
+ }
/* the (optional) tooltip: */
- res = sscanf(line, "%[^']'%[^'\r\n]'\n", w, tooltip);
- if ((res == 2) && (w[0] == 't' || w[0] == 'T')) {
- bpymenu_set_tooltip (pymenu, tooltip);
+ res = sscanf( line, "%[^']'%[^'\r\n]'\n", w, tooltip );
+ if( ( res == 2 ) && ( w[0] == 't' || w[0] == 'T' ) ) {
+ bpymenu_set_tooltip( pymenu, tooltip );
}
-discard:
- fclose (fp);
+ discard:
+ fclose( fp );
continue;
}
- closedir(dir);
+ closedir( dir );
return 0;
}
-static int bpymenu_GetStatMTime(char *name, int is_file, time_t* mtime)
+static int bpymenu_GetStatMTime( char *name, int is_file, time_t * mtime )
{
struct stat st;
int result;
- result = stat(name, &st);
+ result = stat( name, &st );
- if (result == -1) return -1;
+ if( result == -1 )
+ return -1;
- if (is_file) { if (!S_ISREG(st.st_mode)) return -2; }
- else if (!S_ISDIR(st.st_mode)) return -2;
+ if( is_file ) {
+ if( !S_ISREG( st.st_mode ) )
+ return -2;
+ } else if( !S_ISDIR( st.st_mode ) )
+ return -2;
*mtime = st.st_mtime;
@@ -686,100 +772,107 @@ static int bpymenu_GetStatMTime(char *name, int is_file, time_t* mtime)
* then fill the bpymenu table with this data.
* if param usedir != 0, then the data is recreated from the dir(s) anyway.
*/
-int BPyMenu_Init(int usedir)
+int BPyMenu_Init( int usedir )
{
- char fname[FILE_MAXDIR+FILE_MAXFILE];
+ char fname[FILE_MAXDIR + FILE_MAXFILE];
char dirname[FILE_MAXDIR];
char *upydir = U.pythondir;
time_t tdir1 = 0, tdir2 = 0, tfile = 0;
int res1 = 0, res2 = 0, resf = 0;
- DEBUG = G.f & G_DEBUG; /* is Blender in debug mode (started with -d) ? */
+ DEBUG = G.f & G_DEBUG; /* is Blender in debug mode (started with -d) ? */
/* init global bpymenu table (it is a list of pointers to struct BPyMenus
* for each available group: import, export, etc.) */
- for (res1 = 0; res1 < PYMENU_TOTAL; res1++)
+ for( res1 = 0; res1 < PYMENU_TOTAL; res1++ )
BPyMenuTable[res1] = NULL;
- if (U.pythondir[0] == '\0') upydir = NULL;
+ if( U.pythondir[0] == '\0' )
+ upydir = NULL;
- BLI_make_file_string ("/", dirname, bpy_gethome(), "scripts");
+ BLI_make_file_string( "/", dirname, bpy_gethome( ), "scripts" );
- res1 = bpymenu_GetStatMTime(dirname, 0, &tdir1);
+ res1 = bpymenu_GetStatMTime( dirname, 0, &tdir1 );
- if (res1 < 0) {
+ if( res1 < 0 ) {
tdir1 = 0;
- if (DEBUG) {
- printf ("\nDefault scripts dir: %s:\n%s\n", dirname, strerror(errno));
- if (upydir)
- printf("Getting scripts menu data from user defined dir: %s.\n",upydir);
+ if( DEBUG ) {
+ printf( "\nDefault scripts dir: %s:\n%s\n", dirname,
+ strerror( errno ) );
+ if( upydir )
+ printf( "Getting scripts menu data from user defined dir: %s.\n", upydir );
}
+ } else {
+ syspath_append( dirname );
}
- else { syspath_append(dirname); }
- if (upydir) {
- res2 = bpymenu_GetStatMTime(U.pythondir, 0, &tdir2);
+ if( upydir ) {
+ res2 = bpymenu_GetStatMTime( U.pythondir, 0, &tdir2 );
- if (res2 < 0) {
+ if( res2 < 0 ) {
tdir2 = 0;
- if (DEBUG) printf("\nUser defined scripts dir: %s:\n%s.\n", upydir, strerror(errno));
- if (res1 < 0) {
- if (DEBUG) printf ("To have scripts in menus, please add them to the"
- "default scripts dir: %s\n"
- "and/or go to 'Info window -> File Paths tab' and set a valid\n"
- "path for the user defined scripts dir.\n", dirname);
- return -1;
+ if( DEBUG )
+ printf( "\nUser defined scripts dir: %s:\n%s.\n", upydir, strerror( errno ) );
+ if( res1 < 0 ) {
+ if( DEBUG )
+ printf( "To have scripts in menus, please add them to the" "default scripts dir: %s\n" "and/or go to 'Info window -> File Paths tab' and set a valid\n" "path for the user defined scripts dir.\n", dirname );
+ return -1;
}
}
- }
- else res2 = -1;
+ } else
+ res2 = -1;
- if ((res1 < 0) && (res2 < 0)) {
- if (DEBUG) {
- printf ("\nCannot register scripts in menus, no scripts dir"
- " available.\nExpected default dir in %s .\n", dirname);
+ if( ( res1 < 0 ) && ( res2 < 0 ) ) {
+ if( DEBUG ) {
+ printf( "\nCannot register scripts in menus, no scripts dir" " available.\nExpected default dir in %s .\n", dirname );
}
return -1;
}
- if (DEBUG) printf("\nRegistering scripts in Blender menus ...\n\n");
+ if( DEBUG )
+ printf( "\nRegistering scripts in Blender menus ...\n\n" );
- if (!usedir) { /* if we're not forced to use the dir */
- BLI_make_file_string("/", fname, bpy_gethome(), BPYMENU_DATAFILE);
- resf = bpymenu_GetStatMTime(fname, 1, &tfile);
- if (resf < 0) tfile = 0;
+ if( !usedir ) { /* if we're not forced to use the dir */
+ BLI_make_file_string( "/", fname, bpy_gethome( ),
+ BPYMENU_DATAFILE );
+ resf = bpymenu_GetStatMTime( fname, 1, &tfile );
+ if( resf < 0 )
+ tfile = 0;
}
/* comparing dates */
- if ((tfile > tdir1) && (tfile > tdir2) && !resf) { /* file is newer */
- resf = bpymenu_CreateFromFile(); /* -1 if an error occurred */
- if (!resf && DEBUG)
- printf("Getting menu data for scripts from file: %s\n\n", fname);
- }
- else resf = -1; /* -1 to use dirs: didn't use file or it was corrupted */
-
- if (resf == -1) { /* use dirs */
- if (DEBUG) {
- printf("Getting menu data for scripts from dir(s):\n%s\n", dirname);
- if (upydir) printf("%s\n", upydir);
+ if( ( tfile > tdir1 ) && ( tfile > tdir2 ) && !resf ) { /* file is newer */
+ resf = bpymenu_CreateFromFile( ); /* -1 if an error occurred */
+ if( !resf && DEBUG )
+ printf( "Getting menu data for scripts from file: %s\n\n", fname );
+ } else
+ resf = -1; /* -1 to use dirs: didn't use file or it was corrupted */
+
+ if( resf == -1 ) { /* use dirs */
+ if( DEBUG ) {
+ printf( "Getting menu data for scripts from dir(s):\n%s\n", dirname );
+ if( upydir )
+ printf( "%s\n", upydir );
}
- if (res1 == 0) bpymenu_CreateFromDir(dirname, 0);
- if (res2 == 0) bpymenu_CreateFromDir(U.pythondir, 1);
+ if( res1 == 0 )
+ bpymenu_CreateFromDir( dirname, 0 );
+ if( res2 == 0 )
+ bpymenu_CreateFromDir( U.pythondir, 1 );
/* check if we got any data */
- for (res1 = 0; res1 < PYMENU_TOTAL; res1++)
- if (BPyMenuTable[res1]) break;
+ for( res1 = 0; res1 < PYMENU_TOTAL; res1++ )
+ if( BPyMenuTable[res1] )
+ break;
/* if we got, recreate the file */
- if (res1 < PYMENU_TOTAL) bpymenu_WriteDataFile();
- else if (DEBUG) {
- printf ("\nWarning: Registering scripts in menus -- no info found.\n"
- "Either your scripts dirs have no .py scripts or the scripts\n"
- "don't have a header with registration data.\n"
- "Default scripts dir is: %s\n", dirname);
- if (upydir)
- printf("User defined scripts dir is: %s\n", upydir);
+ if( res1 < PYMENU_TOTAL )
+ bpymenu_WriteDataFile( );
+ else if( DEBUG ) {
+ printf( "\nWarning: Registering scripts in menus -- no info found.\n" "Either your scripts dirs have no .py scripts or the scripts\n" "don't have a header with registration data.\n" "Default scripts dir is: %s\n", dirname );
+ if( upydir )
+ printf( "User defined scripts dir is: %s\n",
+ upydir );
}
return 0;
diff --git a/source/blender/python/BPY_menus.h b/source/blender/python/BPY_menus.h
index 35ac71d14d1..08fbfcf7d16 100644
--- a/source/blender/python/BPY_menus.h
+++ b/source/blender/python/BPY_menus.h
@@ -1,4 +1,5 @@
/*
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -61,8 +62,8 @@ typedef struct BPyMenu {
char *name;
char *filename;
char *tooltip;
- short version; /* Blender version */
- int dir; /* 0: default, 1: U.pythondir */
+ short version; /* Blender version */
+ int dir; /* 0: default, 1: U.pythondir */
struct BPySubMenu *submenus;
struct BPyMenu *next;
} BPyMenu;
@@ -75,35 +76,35 @@ typedef struct BPyMenu {
* BPY_menus.c;
* - add the necessary code to the header_***.c file in
* source/blender/src/, like done in header_info.c for import/export;
-*/
+*/
typedef enum {
- PYMENU_WIZARDS, /* complex 'app' scripts */
- PYMENU_UV, /* UV editing tools, to go in UV/Image editor space, 'UV' menu */
+ PYMENU_WIZARDS, /* complex 'app' scripts */
+ PYMENU_UV, /* UV editing tools, to go in UV/Image editor space, 'UV' menu */
PYMENU_OBJECT,
PYMENU_MISC,
PYMENU_MESH,
PYMENU_MATERIALS,
- PYMENU_HELP, /* Main Help menu items - prob best to leave for 'official' ones */
- PYMENU_HELPSYSTEM, /* Resources, troubleshooting, system tools */
- PYMENU_HELPWEBSITES, /* Help -> Websites submenu */
+ PYMENU_HELP, /* Main Help menu items - prob best to leave for 'official' ones */
+ PYMENU_HELPSYSTEM, /* Resources, troubleshooting, system tools */
+ PYMENU_HELPWEBSITES, /* Help -> Websites submenu */
PYMENU_IMPORT,
PYMENU_EXPORT,
PYMENU_ANIMATION,
- PYMENU_ADD, /* creates new objects */
+ PYMENU_ADD, /* creates new objects */
PYMENU_TOTAL
} PYMENUHOOKS;
/* BPyMenuTable holds all registered pymenus, as linked lists for each menu
* where they can appear (see PYMENUHOOKS enum above).
*/
-extern BPyMenu *BPyMenuTable[]; /* defined in BPY_menus.c */
+extern BPyMenu *BPyMenuTable[]; /* defined in BPY_menus.c */
/* public functions: */
-int BPyMenu_Init(int usedir);
-void BPyMenu_RemoveAllEntries(void);
-void BPyMenu_PrintAllEntries(void);
-char *BPyMenu_CreatePupmenuStr(BPyMenu *pym, short group);
-char *BPyMenu_group_itoa (short group);
-struct BPyMenu *BPyMenu_GetEntry (short group, short pos);
+int BPyMenu_Init( int usedir );
+void BPyMenu_RemoveAllEntries( void );
+void BPyMenu_PrintAllEntries( void );
+char *BPyMenu_CreatePupmenuStr( BPyMenu * pym, short group );
+char *BPyMenu_group_itoa( short group );
+struct BPyMenu *BPyMenu_GetEntry( short group, short pos );
-#endif /* BPY_MENUS_H */
+#endif /* BPY_MENUS_H */
diff --git a/source/blender/python/api2_2x/Armature.c b/source/blender/python/api2_2x/Armature.c
index 29875d3644e..a1c0e5eea9a 100644
--- a/source/blender/python/api2_2x/Armature.c
+++ b/source/blender/python/api2_2x/Armature.c
@@ -44,7 +44,6 @@
#include <BLI_arithb.h>
#include "constant.h"
#include "gen_utils.h"
-#include "modules.h"
#include "Types.h"
//---------------- Python API function prototypes for the Armature module---
diff --git a/source/blender/python/api2_2x/Armature.h b/source/blender/python/api2_2x/Armature.h
index c96736b4c5e..4787c00921e 100644
--- a/source/blender/python/api2_2x/Armature.h
+++ b/source/blender/python/api2_2x/Armature.h
@@ -42,6 +42,11 @@ typedef struct {
} BPy_Armature;
//--------------------visible prototypes------------------------------
+
PyObject *Armature_Init( void );
+PyObject *Armature_CreatePyObject( bArmature * armature );
+bArmature *Armature_FromPyObject( PyObject * py_obj );
+int Armature_CheckPyObject( PyObject * py_obj );
+
#endif /* EXPP_ARMATURE_H */
diff --git a/source/blender/python/api2_2x/BGL.c b/source/blender/python/api2_2x/BGL.c
index 31f54902419..32007267d67 100644
--- a/source/blender/python/api2_2x/BGL.c
+++ b/source/blender/python/api2_2x/BGL.c
@@ -37,6 +37,7 @@
#include "BGL.h"
+
static int type_size(int type)
{
switch (type) {
diff --git a/source/blender/python/api2_2x/BGL.h b/source/blender/python/api2_2x/BGL.h
index c5b2d9df85c..7a09925f2b4 100644
--- a/source/blender/python/api2_2x/BGL.h
+++ b/source/blender/python/api2_2x/BGL.h
@@ -66,7 +66,6 @@
#include "Python.h"
#include "gen_utils.h"
-#include "modules.h"
/*@ Buffer Object */
/*@ For Python access to OpenGL functions requiring a pointer. */
diff --git a/source/blender/python/api2_2x/BezTriple.c b/source/blender/python/api2_2x/BezTriple.c
index 23cd7d50d22..a6a020b0537 100644
--- a/source/blender/python/api2_2x/BezTriple.c
+++ b/source/blender/python/api2_2x/BezTriple.c
@@ -42,7 +42,7 @@
#include "constant.h"
#include "gen_utils.h"
-#include "modules.h"
+
/*****************************************************************************/
/* Python API function prototypes for the BezTriple module. */
diff --git a/source/blender/python/api2_2x/BezTriple.h b/source/blender/python/api2_2x/BezTriple.h
index e4795b4ff07..f865fa73646 100644
--- a/source/blender/python/api2_2x/BezTriple.h
+++ b/source/blender/python/api2_2x/BezTriple.h
@@ -45,5 +45,12 @@ typedef struct {
BezTriple * beztriple;
} C_BezTriple;
+/*
+ * prototypes
+ */
+
+PyObject *BezTriple_CreatePyObject( BezTriple * bzt );
+int BezTriple_CheckPyObject( PyObject * pyobj );
+BezTriple *BezTriple_FromPyObject( PyObject * pyobj );
#endif /* EXPP_BEZTRIPLE_H */
diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c
index 9e0c513f8b1..d9b4151388d 100644
--- a/source/blender/python/api2_2x/Blender.c
+++ b/source/blender/python/api2_2x/Blender.c
@@ -60,12 +60,12 @@
#include <BKE_ipo.h>
#include <blendef.h>
+
+
#include "gen_utils.h"
#include "modules.h"
#include "../BPY_extern.h" /* for bpy_gethome() */
-/* From Window.h, used here by Blender_Redraw */
-PyObject *M_Window_Redraw( PyObject * self, PyObject * args );
/**********************************************************/
/* Python API function prototypes for the Blender module. */
diff --git a/source/blender/python/api2_2x/Blender.h b/source/blender/python/api2_2x/Blender.h
index af7fa7c1056..52e447834c3 100644
--- a/source/blender/python/api2_2x/Blender.h
+++ b/source/blender/python/api2_2x/Blender.h
@@ -32,4 +32,8 @@
#ifndef EXPP_BLENDER_H
#define EXPP_BLENDER_H
+
+extern PyObject *g_blenderdict;
+void M_Blender_Init( void );
+
#endif /* EXPP_BLENDER_H */
diff --git a/source/blender/python/api2_2x/Bone.c b/source/blender/python/api2_2x/Bone.c
index 0367fa99a65..ddca513c1aa 100644
--- a/source/blender/python/api2_2x/Bone.c
+++ b/source/blender/python/api2_2x/Bone.c
@@ -40,6 +40,7 @@
#include <BLI_blenlib.h>
#include <DNA_action_types.h>
#include <DNA_armature_types.h>
+#include <DNA_ipo_types.h>
#include <BIF_poseobject.h>
#include <BKE_action.h>
#include <BSE_editaction.h>
@@ -47,7 +48,6 @@
#include <MEM_guardedalloc.h>
#include "constant.h"
#include "gen_utils.h"
-#include "modules.h"
#include "NLA.h"
#include "quat.h"
#include "matrix.h"
diff --git a/source/blender/python/api2_2x/Build.h b/source/blender/python/api2_2x/Build.h
index d98155d7269..cd0f99d61a3 100644
--- a/source/blender/python/api2_2x/Build.h
+++ b/source/blender/python/api2_2x/Build.h
@@ -34,14 +34,20 @@
#define EXPP_BUILD_H
#include <Python.h>
+#include <DNA_effect_types.h>
+#include "Effect.h"
+extern PyTypeObject Build_Type;
-#include <DNA_effect_types.h>
+#define BPy_Build_Check(v) ((v)->ob_type==&Build_Type)
+/* Python BPy_Build structure definition */
+typedef struct {
+ PyObject_HEAD /* required py macro */
+ Effect * build;
+} BPy_Build;
-#include "bpy_types.h"
-#include "Effect.h"
/*****************************************************************************/
/* Python API function prototypes for the Build module. */
diff --git a/source/blender/python/api2_2x/Camera.c b/source/blender/python/api2_2x/Camera.c
index 69e0152cb4c..b0a3ebc76d9 100644
--- a/source/blender/python/api2_2x/Camera.c
+++ b/source/blender/python/api2_2x/Camera.c
@@ -37,12 +37,12 @@
#include <BLI_blenlib.h>
#include <Python.h>
-#include <DNA_camera_types.h>
+
#include "constant.h"
#include "gen_utils.h"
-#include "modules.h"
#include "Camera.h"
+#include "Ipo.h"
/*****************************************************************************/
diff --git a/source/blender/python/api2_2x/Camera.h b/source/blender/python/api2_2x/Camera.h
index 4d69017122f..81457e12878 100644
--- a/source/blender/python/api2_2x/Camera.h
+++ b/source/blender/python/api2_2x/Camera.h
@@ -33,7 +33,20 @@
#ifndef EXPP_CAMERA_H
#define EXPP_CAMERA_H
-#include "bpy_types.h" /* where the BPy_Camera struct is declared */
+#include <Python.h>
+#include <DNA_camera_types.h>
+
+extern PyTypeObject Camera_Type;
+
+#define BPy_Camera_Check(v) \
+ ((v)->ob_type == &Camera_Type) /* for type checking */
+
+/* Python BPy_Camera structure definition */
+typedef struct {
+ PyObject_HEAD /* required py macro */
+ Camera * camera;
+
+} BPy_Camera;
/*****************************************************************************/
/* Python BPy_Camera defaults: */
@@ -60,6 +73,9 @@
#define EXPP_CAM_DRAWSIZE_MIN 0.1
#define EXPP_CAM_DRAWSIZE_MAX 10.0
-
+PyObject *Camera_Init( void );
+PyObject *Camera_CreatePyObject( Camera * cam );
+int Camera_CheckPyObject( PyObject * pyobj );
+Camera *Camera_FromPyObject( PyObject * pyobj );
#endif /* EXPP_CAMERA_H */
diff --git a/source/blender/python/api2_2x/CurNurb.c b/source/blender/python/api2_2x/CurNurb.c
index d49c6121190..e04204be07f 100644
--- a/source/blender/python/api2_2x/CurNurb.c
+++ b/source/blender/python/api2_2x/CurNurb.c
@@ -33,10 +33,10 @@
#include "DNA_curve_types.h"
#include "BKE_curve.h"
#include "MEM_guardedalloc.h"
-#include "bpy_types.h"
-#include "modules.h"
+
#include "gen_utils.h"
#include "CurNurb.h"
+#include "BezTriple.h"
/*-------------------------------------------------------------
@@ -675,7 +675,7 @@ PyObject *CurNurb_Init( void )
{
PyObject *submodule;
- Curve_Type.ob_type = &PyType_Type;
+ CurNurb_Type.ob_type = &PyType_Type;
submodule =
Py_InitModule3( "Blender.CurNurb", M_CurNurb_methods,
diff --git a/source/blender/python/api2_2x/CurNurb.h b/source/blender/python/api2_2x/CurNurb.h
index f0a90f28888..437069982a9 100644
--- a/source/blender/python/api2_2x/CurNurb.h
+++ b/source/blender/python/api2_2x/CurNurb.h
@@ -32,6 +32,35 @@
#ifndef EXPP_NURB_H
#define EXPP_NURB_H
+#include <DNA_curve_types.h>
+
+extern PyTypeObject CurNurb_Type;
+
+#define BPy_CurNurb_Check(v) ((v)->ob_type == &CurNurb_Type) /* for type checking */
+
+/* Python BPy_CurNurb structure definition */
+typedef struct {
+ PyObject_HEAD /* required py macro */
+ Nurb * nurb; /* pointer to Blender data */
+
+ /* iterator stuff */
+ /* internal ptrs to point data. do not free */
+ BPoint *bp;
+ BezTriple *bezt;
+ int atEnd; /* iter exhausted flag */
+ int nextPoint;
+
+} BPy_CurNurb;
+
+
+/*
+ * prototypes
+ */
+
+PyObject *CurNurb_Init( void );
+PyObject *CurNurb_CreatePyObject( Nurb * bzt );
+int CurNurb_CheckPyObject( PyObject * pyobj );
+Nurb *CurNurb_FromPyObject( PyObject * pyobj );
PyObject *CurNurb_getPoint( BPy_CurNurb * self, int index );
PyObject *CurNurb_pointAtIndex( Nurb * nurb, int index );
diff --git a/source/blender/python/api2_2x/Curve.c b/source/blender/python/api2_2x/Curve.c
index 36370ec6077..2f19ffb261a 100644
--- a/source/blender/python/api2_2x/Curve.c
+++ b/source/blender/python/api2_2x/Curve.c
@@ -36,15 +36,18 @@
#include <BLI_arithb.h>
#include <BLI_blenlib.h>
#include <BKE_main.h>
+#include <BKE_displist.h>
#include <BKE_global.h>
#include <BKE_object.h>
#include <BKE_library.h>
#include <BKE_curve.h>
#include <BKE_utildefines.h>
#include <MEM_guardedalloc.h> /* because we wil be mallocing memory */
+
#include "CurNurb.h"
+#include "Material.h"
#include "gen_utils.h"
-#include "modules.h"
+
/*****************************************************************************/
/* The following string definitions are used for documentation strings. */
@@ -1156,7 +1159,8 @@ static PyObject *Curve_appendNurb( BPy_Curve * self, PyObject * args )
static PyObject *Curve_update( BPy_Curve * self )
{
- update_displists( ( void * ) self->curve );
+/* update_displists( ( void * ) self->curve ); */
+ freedisplist( &self->curve->disp );
Py_INCREF( Py_None );
return Py_None;
@@ -1451,12 +1455,16 @@ struct Curve *Curve_FromPyObject( PyObject * py_obj )
/*
+ * NOTE: this func has been replaced by freedisplist() in the recent
+ * display list refactoring.
+ *
* walk across all objects looking for curves
* so we can update their ob's disp list
*/
void update_displists( void *data )
{
+#if 0
Base *base;
Object *ob;
unsigned int layer;
@@ -1492,4 +1500,6 @@ void update_displists( void *data )
else
base = base->next;
}
+#endif
}
+
diff --git a/source/blender/python/api2_2x/Curve.h b/source/blender/python/api2_2x/Curve.h
index ab5e1961b25..206165e88bb 100644
--- a/source/blender/python/api2_2x/Curve.h
+++ b/source/blender/python/api2_2x/Curve.h
@@ -33,6 +33,28 @@
#ifndef EXPP_CURVE_H
#define EXPP_CURVE_H
-#include "bpy_types.h"
+#include <DNA_curve_types.h>
+
+extern PyTypeObject Curve_Type;
+
+#define BPy_Curve_Check(v) ((v)->ob_type==&Curve_Type)
+
+/* Python BPy_Curve structure definition */
+typedef struct {
+ PyObject_HEAD /* required py macro */
+ Curve * curve;
+ /* pointer for iterator: does not point to owned memory */
+ Nurb *iter_pointer;
+} BPy_Curve;
+
+
+/*
+ * protoypes
+ */
+
+PyObject *Curve_Init( void );
+PyObject *Curve_CreatePyObject( struct Curve * curve );
+int Curve_CheckPyObject( PyObject * py_obj );
+struct Curve *Curve_FromPyObject( PyObject * py_obj );
#endif /* EXPP_CURVE_H */
diff --git a/source/blender/python/api2_2x/Draw.h b/source/blender/python/api2_2x/Draw.h
index 7ec1c886849..9f1d7eb19fe 100644
--- a/source/blender/python/api2_2x/Draw.h
+++ b/source/blender/python/api2_2x/Draw.h
@@ -38,15 +38,12 @@
#define EXPP_DRAW_H_
#include "DNA_space_types.h"
+#include "DNA_text_types.h"
#include "Python.h"
#include "gen_utils.h"
-#include "modules.h"
-
-/* From Window.h, used here by py_slider_update() */
-PyObject *M_Window_Redraw( PyObject * self, PyObject * args );
-
+#include "Window.h"
void initDraw( void );
@@ -76,5 +73,6 @@ void BPY_spacescript_do_pywin_event( SpaceScript * sc,
void BPY_free_compiled_text( Text * text );
PyObject *M_Draw_Init( void );
+PyObject *Draw_Init( void );
#endif /* EXPP_DRAW_H */
diff --git a/source/blender/python/api2_2x/EXPP_interface.c b/source/blender/python/api2_2x/EXPP_interface.c
index 6c836ab9eac..2a03936c3f7 100644
--- a/source/blender/python/api2_2x/EXPP_interface.c
+++ b/source/blender/python/api2_2x/EXPP_interface.c
@@ -39,8 +39,10 @@
#include <BKE_main.h>
#include "EXPP_interface.h"
+#include "Blender.h"
+#include "Registry.h"
#include "gen_utils.h"
-#include "modules.h"
+
void initBlenderApi2_2x( void )
{
diff --git a/source/blender/python/api2_2x/Effect.h b/source/blender/python/api2_2x/Effect.h
index 9546acdbfd3..0d56ea391a8 100644
--- a/source/blender/python/api2_2x/Effect.h
+++ b/source/blender/python/api2_2x/Effect.h
@@ -44,8 +44,20 @@
#include <BKE_library.h>
#include <BKE_effect.h>
+#include <DNA_effect_types.h>
+
#include"gen_utils.h"
-#include "bpy_types.h"
+
+extern PyTypeObject Effect_Type;
+
+#define BPy_Effect_Check(v) ((v)->ob_type==&Effect_Type)
+
+/* Python BPy_Effect structure definition */
+typedef struct {
+ PyObject_HEAD /* required py macro */
+ Effect * effect;
+} BPy_Effect;
+
/*****************************************************************************/
/* Python API function prototypes for the Effect module. */
@@ -64,6 +76,8 @@ PyObject *M_Effect_Get( PyObject * self, PyObject * args );
/*****************************************************************************/
/* Python Effect_Type callback function prototypes: */
/*****************************************************************************/
+
+PyObject *Effect_Init( void );
void EffectDeAlloc( BPy_Effect * msh );
//int EffectPrint (BPy_Effect *msh, FILE *fp, int flags);
int EffectSetAttr( BPy_Effect * msh, char *name, PyObject * v );
diff --git a/source/blender/python/api2_2x/Ipo.c b/source/blender/python/api2_2x/Ipo.c
index 4a5b245e352..b155e2a12e3 100644
--- a/source/blender/python/api2_2x/Ipo.c
+++ b/source/blender/python/api2_2x/Ipo.c
@@ -39,9 +39,12 @@
#include <BSE_editipo.h>
#include <BLI_blenlib.h>
+#include <DNA_curve_types.h>
+
+#include "Ipocurve.h"
#include "constant.h"
#include "gen_utils.h"
-#include "modules.h"
+
/* forward declarations */
diff --git a/source/blender/python/api2_2x/Ipo.h b/source/blender/python/api2_2x/Ipo.h
index 3974df722f0..07e3c8f546f 100644
--- a/source/blender/python/api2_2x/Ipo.h
+++ b/source/blender/python/api2_2x/Ipo.h
@@ -44,5 +44,19 @@ typedef struct {
Ipo * ipo;
} BPy_Ipo;
+extern PyTypeObject Ipo_Type;
+
+#define BPy_Ipo_Check(v) ((v)->ob_type == &Ipo_Type) /* for type checking */
+
+
+/*
+ * prototypes
+ */
+
+PyObject *Ipo_Init( void );
+PyObject *Ipo_CreatePyObject( struct Ipo *ipo );
+Ipo *Ipo_FromPyObject( PyObject * py_obj );
+int Ipo_CheckPyObject( PyObject * py_obj );
+
#endif /* EXPP_IPO_H */
diff --git a/source/blender/python/api2_2x/Ipocurve.c b/source/blender/python/api2_2x/Ipocurve.c
index 6a9cc243c39..9a50345fb39 100644
--- a/source/blender/python/api2_2x/Ipocurve.c
+++ b/source/blender/python/api2_2x/Ipocurve.c
@@ -40,9 +40,11 @@
#include <BLI_blenlib.h>
#include <BSE_editipo.h>
+#include <DNA_ipo_types.h>
+
#include "constant.h"
#include "gen_utils.h"
-#include "modules.h"
+#include "BezTriple.h"
/*****************************************************************************/
/* Python API function prototypes for the IpoCurve module. */
diff --git a/source/blender/python/api2_2x/Ipocurve.h b/source/blender/python/api2_2x/Ipocurve.h
index 4cac8796277..fcfb5fcb551 100644
--- a/source/blender/python/api2_2x/Ipocurve.h
+++ b/source/blender/python/api2_2x/Ipocurve.h
@@ -45,4 +45,12 @@ typedef struct {
} C_IpoCurve;
+
+PyObject *IpoCurve_Init( void );
+PyObject *IpoCurve_CreatePyObject( IpoCurve * ipo );
+int IpoCurve_CheckPyObject( PyObject * pyobj );
+IpoCurve *IpoCurve_FromPyObject( PyObject * pyobj );
+
+
+
#endif /* EXPP_IPOCURVE_H */
diff --git a/source/blender/python/api2_2x/Lamp.c b/source/blender/python/api2_2x/Lamp.c
index dc4e6f17159..3a8888b7e9f 100644
--- a/source/blender/python/api2_2x/Lamp.c
+++ b/source/blender/python/api2_2x/Lamp.c
@@ -29,7 +29,7 @@
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
-#include <Python.h>
+
#include <stdio.h>
#include <BKE_main.h>
@@ -37,13 +37,15 @@
#include <BKE_object.h>
#include <BKE_library.h>
#include <BLI_blenlib.h>
-#include <DNA_lamp_types.h>
+
+#include "Lamp.h"
+#include "Ipo.h"
#include "constant.h"
#include "rgbTuple.h"
#include "gen_utils.h"
-#include "modules.h"
-#include "bpy_types.h" /* for the BPy_Lamp declaration */
+
+
/*****************************************************************************/
/* Python BPy_Lamp defaults: */
diff --git a/source/blender/python/api2_2x/Lamp.h b/source/blender/python/api2_2x/Lamp.h
index d1cc0b33262..fac10ad4fc3 100644
--- a/source/blender/python/api2_2x/Lamp.h
+++ b/source/blender/python/api2_2x/Lamp.h
@@ -33,4 +33,31 @@
#ifndef EXPP_LAMP_H
#define EXPP_LAMP_H
+#include <Python.h>
+#include <DNA_lamp_types.h>
+#include "rgbTuple.h"
+
+extern PyTypeObject Lamp_Type;
+
+#define BPy_Lamp_Check(v) \
+ ((v)->ob_type == &Lamp_Type) /* for type checking */
+
+/* Python BPy_Lamp structure definition */
+typedef struct {
+ PyObject_HEAD /* required py macro */
+ Lamp * lamp;
+ BPy_rgbTuple *color;
+} BPy_Lamp;
+
+
+/*
+ * prototypes
+ */
+
+PyObject *Lamp_Init( void );
+PyObject *Lamp_CreatePyObject( struct Lamp *lamp );
+Lamp *Lamp_FromPyObject( PyObject * pyobj );
+int Lamp_CheckPyObject( PyObject * pyobj );
+Lamp *GetLampByName( char *name );
+
#endif /* EXPP_LAMP_H */
diff --git a/source/blender/python/api2_2x/Lattice.c b/source/blender/python/api2_2x/Lattice.c
index d2b3bc84115..e10755f28ec 100644
--- a/source/blender/python/api2_2x/Lattice.c
+++ b/source/blender/python/api2_2x/Lattice.c
@@ -32,6 +32,182 @@
#include "Lattice.h"
+
+#include <BKE_main.h>
+#include <BKE_global.h>
+#include <BKE_library.h>
+#include <BKE_lattice.h>
+#include <BKE_utildefines.h>
+#include <BKE_key.h>
+#include <BLI_blenlib.h>
+
+#include <DNA_key_types.h>
+#include <DNA_curve_types.h>
+#include <DNA_scene_types.h>
+#include <BIF_editlattice.h>
+#include <BIF_editkey.h>
+#include "blendef.h"
+#include "mydevice.h"
+#include "constant.h"
+#include "gen_utils.h"
+
+
+/*****************************************************************************/
+/* Python API function prototypes for the Lattice module. */
+/*****************************************************************************/
+static PyObject *M_Lattice_New( PyObject * self, PyObject * args );
+static PyObject *M_Lattice_Get( PyObject * self, PyObject * args );
+
+/*****************************************************************************/
+/* Lattice Module strings */
+/* The following string definitions are used for documentation strings. */
+/* In Python these will be written to the console when doing a */
+/* Blender.Lattice.__doc__ */
+/*****************************************************************************/
+static char M_Lattice_doc[] = "The Blender Lattice module\n\n";
+
+static char M_Lattice_New_doc[] = "() - return a new Lattice object";
+
+static char M_Lattice_Get_doc[] = "() - geta a Lattice from blender";
+
+/*****************************************************************************/
+/* Python method structure definition for Blender.Lattice module: */
+/*****************************************************************************/
+struct PyMethodDef M_Lattice_methods[] = {
+ {"New", ( PyCFunction ) M_Lattice_New, METH_VARARGS,
+ M_Lattice_New_doc},
+ {"Get", ( PyCFunction ) M_Lattice_Get, METH_VARARGS,
+ M_Lattice_Get_doc},
+ {NULL, NULL, 0, NULL}
+};
+
+
+
+/*****************************************************************************/
+/* Python BPy_Lattice methods declarations: */
+/*****************************************************************************/
+static PyObject *Lattice_getName( BPy_Lattice * self );
+static PyObject *Lattice_setName( BPy_Lattice * self, PyObject * args );
+static PyObject *Lattice_setPartitions( BPy_Lattice * self, PyObject * args );
+static PyObject *Lattice_getPartitions( BPy_Lattice * self, PyObject * args );
+static PyObject *Lattice_setKeyTypes( BPy_Lattice * self, PyObject * args );
+static PyObject *Lattice_getKeyTypes( BPy_Lattice * self, PyObject * args );
+static PyObject *Lattice_setMode( BPy_Lattice * self, PyObject * args );
+static PyObject *Lattice_getMode( BPy_Lattice * self, PyObject * args );
+static PyObject *Lattice_setPoint( BPy_Lattice * self, PyObject * args );
+static PyObject *Lattice_getPoint( BPy_Lattice * self, PyObject * args );
+static PyObject *Lattice_applyDeform( BPy_Lattice * self );
+static PyObject *Lattice_insertKey( BPy_Lattice * self, PyObject * args );
+
+/*****************************************************************************/
+/* Lattice Strings */
+/* The following string definitions are used for documentation strings. */
+/* In Python these will be written to the console when doing a */
+/* Blender.Lattice.__doc__ */
+/*****************************************************************************/
+static char Lattice_getName_doc[] = "() - Return Lattice Object name";
+
+static char Lattice_setName_doc[] = "(str) - Change Lattice Object name";
+
+static char Lattice_setPartitions_doc[] =
+ "(str) - Set the number of Partitions in x,y,z";
+
+static char Lattice_getPartitions_doc[] =
+ "(str) - Get the number of Partitions in x,y,z";
+
+static char Lattice_setKeyTypes_doc[] =
+ "(str) - Set the key types for x,y,z dimensions";
+
+static char Lattice_getKeyTypes_doc[] =
+ "(str) - Get the key types for x,y,z dimensions";
+
+static char Lattice_setMode_doc[] = "(str) - Make an outside or grid lattice";
+
+static char Lattice_getMode_doc[] = "(str) - Get lattice mode type";
+
+static char Lattice_setPoint_doc[] =
+ "(str) - Set the coordinates of a point on the lattice";
+
+static char Lattice_getPoint_doc[] =
+ "(str) - Get the coordinates of a point on the lattice";
+
+static char Lattice_applyDeform_doc[] =
+ "(str) - Apply the new lattice deformation to children";
+
+static char Lattice_insertKey_doc[] =
+ "(str) - Set a new key for the lattice at specified frame";
+
+/*****************************************************************************/
+/* Python BPy_Lattice methods table: */
+/*****************************************************************************/
+static PyMethodDef BPy_Lattice_methods[] = {
+ /* name, method, flags, doc */
+ {"getName", ( PyCFunction ) Lattice_getName, METH_NOARGS,
+ Lattice_getName_doc},
+ {"setName", ( PyCFunction ) Lattice_setName, METH_VARARGS,
+ Lattice_setName_doc},
+ {"setPartitions", ( PyCFunction ) Lattice_setPartitions, METH_VARARGS,
+ Lattice_setPartitions_doc},
+ {"getPartitions", ( PyCFunction ) Lattice_getPartitions, METH_NOARGS,
+ Lattice_getPartitions_doc},
+ {"setKeyTypes", ( PyCFunction ) Lattice_setKeyTypes, METH_VARARGS,
+ Lattice_setKeyTypes_doc},
+ {"getKeyTypes", ( PyCFunction ) Lattice_getKeyTypes, METH_NOARGS,
+ Lattice_getKeyTypes_doc},
+ {"setMode", ( PyCFunction ) Lattice_setMode, METH_VARARGS,
+ Lattice_setMode_doc},
+ {"getMode", ( PyCFunction ) Lattice_getMode, METH_NOARGS,
+ Lattice_getMode_doc},
+ {"setPoint", ( PyCFunction ) Lattice_setPoint, METH_VARARGS,
+ Lattice_setPoint_doc},
+ {"getPoint", ( PyCFunction ) Lattice_getPoint, METH_VARARGS,
+ Lattice_getPoint_doc},
+ {"applyDeform", ( PyCFunction ) Lattice_applyDeform, METH_NOARGS,
+ Lattice_applyDeform_doc},
+ {"insertKey", ( PyCFunction ) Lattice_insertKey, METH_VARARGS,
+ Lattice_insertKey_doc},
+ {NULL, NULL, 0, NULL}
+};
+
+/*****************************************************************************/
+/* Python Lattice_Type callback function prototypes: */
+/*****************************************************************************/
+static void Lattice_dealloc( BPy_Lattice * self );
+static int Lattice_setAttr( BPy_Lattice * self, char *name, PyObject * v );
+static PyObject *Lattice_getAttr( BPy_Lattice * self, char *name );
+static PyObject *Lattice_repr( BPy_Lattice * self );
+
+/*****************************************************************************/
+/* Python Lattice_Type structure definition: */
+/*****************************************************************************/
+PyTypeObject Lattice_Type = {
+ PyObject_HEAD_INIT( NULL )
+ 0, /* ob_size */
+ "Blender Lattice", /* tp_name */
+ sizeof( BPy_Lattice ), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ ( destructor ) Lattice_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ ( getattrfunc ) Lattice_getAttr, /* tp_getattr */
+ ( setattrfunc ) Lattice_setAttr, /* tp_setattr */
+ 0, /* tp_compare */
+ ( reprfunc ) Lattice_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_as_hash */
+ 0, 0, 0, 0, 0, 0,
+ 0, /* tp_doc */
+ 0, 0, 0, 0, 0, 0,
+ BPy_Lattice_methods, /* tp_methods */
+ 0, /* tp_members */
+};
+
+static int Lattice_InLatList( BPy_Lattice * self );
+static int Lattice_IsLinkedToObject( BPy_Lattice * self );
+
+
//***************************************************************************
// Function: Lattice_CreatePyObject
//***************************************************************************
diff --git a/source/blender/python/api2_2x/Lattice.h b/source/blender/python/api2_2x/Lattice.h
index a7acc79515d..09ba1b421b6 100644
--- a/source/blender/python/api2_2x/Lattice.h
+++ b/source/blender/python/api2_2x/Lattice.h
@@ -34,51 +34,9 @@
#define EXPP_Lattice_H
#include <Python.h>
-#include <BKE_main.h>
-#include <BKE_global.h>
-#include <BKE_library.h>
-#include <BKE_lattice.h>
-#include <BKE_utildefines.h>
-#include <BKE_key.h>
-#include <BLI_blenlib.h>
#include <DNA_lattice_types.h>
-#include <DNA_key_types.h>
-#include <BIF_editlattice.h>
-#include <BIF_editkey.h>
-#include "blendef.h"
-#include "mydevice.h"
-#include "constant.h"
-#include "gen_utils.h"
-#include "modules.h"
-/*****************************************************************************/
-/* Python API function prototypes for the Lattice module. */
-/*****************************************************************************/
-static PyObject *M_Lattice_New( PyObject * self, PyObject * args );
-static PyObject *M_Lattice_Get( PyObject * self, PyObject * args );
-
-/*****************************************************************************/
-/* Lattice Module strings */
-/* The following string definitions are used for documentation strings. */
-/* In Python these will be written to the console when doing a */
-/* Blender.Lattice.__doc__ */
-/*****************************************************************************/
-static char M_Lattice_doc[] = "The Blender Lattice module\n\n";
-
-static char M_Lattice_New_doc[] = "() - return a new Lattice object";
-static char M_Lattice_Get_doc[] = "() - geta a Lattice from blender";
-
-/*****************************************************************************/
-/* Python method structure definition for Blender.Lattice module: */
-/*****************************************************************************/
-struct PyMethodDef M_Lattice_methods[] = {
- {"New", ( PyCFunction ) M_Lattice_New, METH_VARARGS,
- M_Lattice_New_doc},
- {"Get", ( PyCFunction ) M_Lattice_Get, METH_VARARGS,
- M_Lattice_Get_doc},
- {NULL, NULL, 0, NULL}
-};
/*****************************************************************************/
/* Python BPy_Lattice structure definition: */
@@ -87,128 +45,16 @@ typedef struct {
PyObject_HEAD Lattice * Lattice;
} BPy_Lattice;
-/*****************************************************************************/
-/* Python BPy_Lattice methods declarations: */
-/*****************************************************************************/
-static PyObject *Lattice_getName( BPy_Lattice * self );
-static PyObject *Lattice_setName( BPy_Lattice * self, PyObject * args );
-static PyObject *Lattice_setPartitions( BPy_Lattice * self, PyObject * args );
-static PyObject *Lattice_getPartitions( BPy_Lattice * self, PyObject * args );
-static PyObject *Lattice_setKeyTypes( BPy_Lattice * self, PyObject * args );
-static PyObject *Lattice_getKeyTypes( BPy_Lattice * self, PyObject * args );
-static PyObject *Lattice_setMode( BPy_Lattice * self, PyObject * args );
-static PyObject *Lattice_getMode( BPy_Lattice * self, PyObject * args );
-static PyObject *Lattice_setPoint( BPy_Lattice * self, PyObject * args );
-static PyObject *Lattice_getPoint( BPy_Lattice * self, PyObject * args );
-static PyObject *Lattice_applyDeform( BPy_Lattice * self );
-static PyObject *Lattice_insertKey( BPy_Lattice * self, PyObject * args );
-
-/*****************************************************************************/
-/* Lattice Strings */
-/* The following string definitions are used for documentation strings. */
-/* In Python these will be written to the console when doing a */
-/* Blender.Lattice.__doc__ */
-/*****************************************************************************/
-static char Lattice_getName_doc[] = "() - Return Lattice Object name";
-
-static char Lattice_setName_doc[] = "(str) - Change Lattice Object name";
-
-static char Lattice_setPartitions_doc[] =
- "(str) - Set the number of Partitions in x,y,z";
-static char Lattice_getPartitions_doc[] =
- "(str) - Get the number of Partitions in x,y,z";
-static char Lattice_setKeyTypes_doc[] =
- "(str) - Set the key types for x,y,z dimensions";
+/*
+ * prototypes
+ */
-static char Lattice_getKeyTypes_doc[] =
- "(str) - Get the key types for x,y,z dimensions";
-
-static char Lattice_setMode_doc[] = "(str) - Make an outside or grid lattice";
-
-static char Lattice_getMode_doc[] = "(str) - Get lattice mode type";
-
-static char Lattice_setPoint_doc[] =
- "(str) - Set the coordinates of a point on the lattice";
-
-static char Lattice_getPoint_doc[] =
- "(str) - Get the coordinates of a point on the lattice";
-
-static char Lattice_applyDeform_doc[] =
- "(str) - Apply the new lattice deformation to children";
-
-static char Lattice_insertKey_doc[] =
- "(str) - Set a new key for the lattice at specified frame";
-
-/*****************************************************************************/
-/* Python BPy_Lattice methods table: */
-/*****************************************************************************/
-static PyMethodDef BPy_Lattice_methods[] = {
- /* name, method, flags, doc */
- {"getName", ( PyCFunction ) Lattice_getName, METH_NOARGS,
- Lattice_getName_doc},
- {"setName", ( PyCFunction ) Lattice_setName, METH_VARARGS,
- Lattice_setName_doc},
- {"setPartitions", ( PyCFunction ) Lattice_setPartitions, METH_VARARGS,
- Lattice_setPartitions_doc},
- {"getPartitions", ( PyCFunction ) Lattice_getPartitions, METH_NOARGS,
- Lattice_getPartitions_doc},
- {"setKeyTypes", ( PyCFunction ) Lattice_setKeyTypes, METH_VARARGS,
- Lattice_setKeyTypes_doc},
- {"getKeyTypes", ( PyCFunction ) Lattice_getKeyTypes, METH_NOARGS,
- Lattice_getKeyTypes_doc},
- {"setMode", ( PyCFunction ) Lattice_setMode, METH_VARARGS,
- Lattice_setMode_doc},
- {"getMode", ( PyCFunction ) Lattice_getMode, METH_NOARGS,
- Lattice_getMode_doc},
- {"setPoint", ( PyCFunction ) Lattice_setPoint, METH_VARARGS,
- Lattice_setPoint_doc},
- {"getPoint", ( PyCFunction ) Lattice_getPoint, METH_VARARGS,
- Lattice_getPoint_doc},
- {"applyDeform", ( PyCFunction ) Lattice_applyDeform, METH_NOARGS,
- Lattice_applyDeform_doc},
- {"insertKey", ( PyCFunction ) Lattice_insertKey, METH_VARARGS,
- Lattice_insertKey_doc},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python Lattice_Type callback function prototypes: */
-/*****************************************************************************/
-static void Lattice_dealloc( BPy_Lattice * self );
-static int Lattice_setAttr( BPy_Lattice * self, char *name, PyObject * v );
-static PyObject *Lattice_getAttr( BPy_Lattice * self, char *name );
-static PyObject *Lattice_repr( BPy_Lattice * self );
-
-/*****************************************************************************/
-/* Python Lattice_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject Lattice_Type = {
- PyObject_HEAD_INIT( NULL )
- 0, /* ob_size */
- "Blender Lattice", /* tp_name */
- sizeof( BPy_Lattice ), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- ( destructor ) Lattice_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- ( getattrfunc ) Lattice_getAttr, /* tp_getattr */
- ( setattrfunc ) Lattice_setAttr, /* tp_setattr */
- 0, /* tp_compare */
- ( reprfunc ) Lattice_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_as_hash */
- 0, 0, 0, 0, 0, 0,
- 0, /* tp_doc */
- 0, 0, 0, 0, 0, 0,
- BPy_Lattice_methods, /* tp_methods */
- 0, /* tp_members */
-};
+PyObject *Lattice_Init( void );
+PyObject *Lattice_CreatePyObject( Lattice * lt );
+Lattice *Lattice_FromPyObject( PyObject * pyobj );
+int Lattice_CheckPyObject( PyObject * pyobj );
-static int Lattice_InLatList( BPy_Lattice * self );
-static int Lattice_IsLinkedToObject( BPy_Lattice * self );
#endif /* EXPP_LATTICE_H */
diff --git a/source/blender/python/api2_2x/Library.c b/source/blender/python/api2_2x/Library.c
index 09d7424b708..a8edd6c147b 100644
--- a/source/blender/python/api2_2x/Library.c
+++ b/source/blender/python/api2_2x/Library.c
@@ -37,6 +37,7 @@
#include <stdio.h>
#include <DNA_ID.h>
+#include <DNA_curve_types.h>
#include <BKE_library.h> /* for all_local */
#include "BKE_displist.h" /* for set_displist_onlyzero */
#include "BKE_font.h" /* for text_to_curve */
@@ -45,7 +46,7 @@
#include <MEM_guardedalloc.h>
#include "gen_utils.h"
-#include "modules.h"
+
/**
* Global variables.
diff --git a/source/blender/python/api2_2x/MTex.c b/source/blender/python/api2_2x/MTex.c
index 0e870cd385f..0f1d77cf209 100644
--- a/source/blender/python/api2_2x/MTex.c
+++ b/source/blender/python/api2_2x/MTex.c
@@ -42,7 +42,6 @@
#include "Texture.h"
#include "constant.h"
#include "gen_utils.h"
-#include "modules.h"
/*****************************************************************************/
diff --git a/source/blender/python/api2_2x/Material.c b/source/blender/python/api2_2x/Material.c
index 6b0b7f35c42..833bd16a008 100644
--- a/source/blender/python/api2_2x/Material.c
+++ b/source/blender/python/api2_2x/Material.c
@@ -39,13 +39,12 @@
#include "constant.h"
#include "gen_utils.h"
-#include "bpy_types.h"
-#include "modules.h"
#include "MTex.h"
#include "Texture.h"
#include "Material.h"
+#include "Ipo.h"
/*****************************************************************************/
/* Python BPy_Material defaults: */
diff --git a/source/blender/python/api2_2x/Material.h b/source/blender/python/api2_2x/Material.h
index c9591c42271..58f2862112b 100644
--- a/source/blender/python/api2_2x/Material.h
+++ b/source/blender/python/api2_2x/Material.h
@@ -57,14 +57,19 @@ extern PyTypeObject Material_Type; /* The Material PyType Object */
/* Module Blender.Material - public functions */
/*****************************************************************************/
PyObject *M_Material_Init( void );
+
+PyObject *Material_Init( void );
PyObject *Material_CreatePyObject( Material * mat );
Material *Material_FromPyObject( PyObject * pyobj );
int Material_CheckPyObject( PyObject * pyobj );
-/* Some functions needed by NMesh.c */
+/* Some functions needed by NMesh, Curve and friends */
PyObject *EXPP_PyList_fromMaterialList( Material ** matlist, int len,
int all );
Material **EXPP_newMaterialList_fromPyList( PyObject * list );
Material **EXPP_newMaterialList( int len );
+void EXPP_incr_mats_us( Material ** matlist, int len );
+int EXPP_synchronizeMaterialLists( Object * object );
+int EXPP_releaseMaterialList( Material ** matlist, int len );
#endif /* EXPP_MATERIAL_H */
diff --git a/source/blender/python/api2_2x/Mathutils.c b/source/blender/python/api2_2x/Mathutils.c
index 5f5664bf706..dc6c6a5194b 100644
--- a/source/blender/python/api2_2x/Mathutils.c
+++ b/source/blender/python/api2_2x/Mathutils.c
@@ -30,8 +30,184 @@
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
+#include <Python.h>
+#include <BKE_main.h>
+#include <BKE_global.h>
+#include <BKE_library.h>
+#include <BKE_utildefines.h>
+#include <BLI_blenlib.h>
+#include <BLI_arithb.h>
+#include <PIL_time.h>
+#include <BLI_rand.h>
+#include <math.h>
+#include "vector.h"
+#include "euler.h"
+#include "quat.h"
+#include "matrix.h"
+#include "blendef.h"
+#include "mydevice.h"
+#include "constant.h"
+#include "gen_utils.h"
#include "Mathutils.h"
+
+/*****************************************************************************/
+// Python API function prototypes for the Mathutils module.
+/*****************************************************************************/
+static PyObject *M_Mathutils_Rand( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_Vector( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_CrossVecs( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_DotVecs( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_AngleBetweenVecs( PyObject * self,
+ PyObject * args );
+static PyObject *M_Mathutils_MidpointVecs( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_VecMultMat( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_ProjectVecs( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_CopyVec( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_Matrix( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_RotationMatrix( PyObject * self,
+ PyObject * args );
+static PyObject *M_Mathutils_ScaleMatrix( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_OrthoProjectionMatrix( PyObject * self,
+ PyObject * args );
+static PyObject *M_Mathutils_ShearMatrix( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_TranslationMatrix( PyObject * self,
+ PyObject * args );
+static PyObject *M_Mathutils_MatMultVec( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_CopyMat( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_Quaternion( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_CrossQuats( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_DotQuats( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_CopyQuat( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_DifferenceQuats( PyObject * self,
+ PyObject * args );
+static PyObject *M_Mathutils_Slerp( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_Euler( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_CopyEuler( PyObject * self, PyObject * args );
+static PyObject *M_Mathutils_RotateEuler( PyObject * self, PyObject * args );
+
+/*****************************************************************************/
+// The following string definitions are used for documentation strings.
+// In Python these will be written to the console when doing a
+// Blender.Mathutils.__doc__
+/* Mathutils Module strings */
+/****************************************************************************/
+static char M_Mathutils_doc[] = "The Blender Mathutils module\n\n";
+static char M_Mathutils_Vector_doc[] =
+ "() - create a new vector object from a list of floats";
+static char M_Mathutils_Matrix_doc[] =
+ "() - create a new matrix object from a list of floats";
+static char M_Mathutils_Quaternion_doc[] =
+ "() - create a quaternion from a list or an axis of rotation and an angle";
+static char M_Mathutils_Euler_doc[] =
+ "() - create and return a new euler object";
+static char M_Mathutils_Rand_doc[] = "() - return a random number";
+static char M_Mathutils_CrossVecs_doc[] =
+ "() - returns a vector perpedicular to the 2 vectors crossed";
+static char M_Mathutils_CopyVec_doc[] = "() - create a copy of vector";
+static char M_Mathutils_DotVecs_doc[] =
+ "() - return the dot product of two vectors";
+static char M_Mathutils_AngleBetweenVecs_doc[] =
+ "() - returns the angle between two vectors in degrees";
+static char M_Mathutils_MidpointVecs_doc[] =
+ "() - return the vector to the midpoint between two vectors";
+static char M_Mathutils_MatMultVec_doc[] =
+ "() - multiplies a matrix by a column vector";
+static char M_Mathutils_VecMultMat_doc[] =
+ "() - multiplies a row vector by a matrix";
+static char M_Mathutils_ProjectVecs_doc[] =
+ "() - returns the projection vector from the projection of vecA onto vecB";
+static char M_Mathutils_RotationMatrix_doc[] =
+ "() - construct a rotation matrix from an angle and axis of rotation";
+static char M_Mathutils_ScaleMatrix_doc[] =
+ "() - construct a scaling matrix from a scaling factor";
+static char M_Mathutils_OrthoProjectionMatrix_doc[] =
+ "() - construct a orthographic projection matrix from a selected plane";
+static char M_Mathutils_ShearMatrix_doc[] =
+ "() - construct a shearing matrix from a plane of shear and a shear factor";
+static char M_Mathutils_CopyMat_doc[] = "() - create a copy of a matrix";
+static char M_Mathutils_TranslationMatrix_doc[] =
+ "() - create a translation matrix from a vector";
+static char M_Mathutils_CopyQuat_doc[] = "() - copy quatB to quatA";
+static char M_Mathutils_CopyEuler_doc[] = "() - copy eulB to eultA";
+static char M_Mathutils_CrossQuats_doc[] =
+ "() - return the mutliplication of two quaternions";
+static char M_Mathutils_DotQuats_doc[] =
+ "() - return the dot product of two quaternions";
+static char M_Mathutils_Slerp_doc[] =
+ "() - returns the interpolation between two quaternions";
+static char M_Mathutils_DifferenceQuats_doc[] =
+ "() - return the angular displacment difference between two quats";
+static char M_Mathutils_RotateEuler_doc[] =
+ "() - rotate euler by an axis and angle";
+
+
+/****************************************************************************/
+// Python method structure definition for Blender.Mathutils module:
+/****************************************************************************/
+struct PyMethodDef M_Mathutils_methods[] = {
+ {"Rand", ( PyCFunction ) M_Mathutils_Rand, METH_VARARGS,
+ M_Mathutils_Rand_doc},
+ {"Vector", ( PyCFunction ) M_Mathutils_Vector, METH_VARARGS,
+ M_Mathutils_Vector_doc},
+ {"CrossVecs", ( PyCFunction ) M_Mathutils_CrossVecs, METH_VARARGS,
+ M_Mathutils_CrossVecs_doc},
+ {"DotVecs", ( PyCFunction ) M_Mathutils_DotVecs, METH_VARARGS,
+ M_Mathutils_DotVecs_doc},
+ {"AngleBetweenVecs", ( PyCFunction ) M_Mathutils_AngleBetweenVecs,
+ METH_VARARGS,
+ M_Mathutils_AngleBetweenVecs_doc},
+ {"MidpointVecs", ( PyCFunction ) M_Mathutils_MidpointVecs,
+ METH_VARARGS,
+ M_Mathutils_MidpointVecs_doc},
+ {"VecMultMat", ( PyCFunction ) M_Mathutils_VecMultMat, METH_VARARGS,
+ M_Mathutils_VecMultMat_doc},
+ {"ProjectVecs", ( PyCFunction ) M_Mathutils_ProjectVecs, METH_VARARGS,
+ M_Mathutils_ProjectVecs_doc},
+ {"CopyVec", ( PyCFunction ) M_Mathutils_CopyVec, METH_VARARGS,
+ M_Mathutils_CopyVec_doc},
+ {"Matrix", ( PyCFunction ) M_Mathutils_Matrix, METH_VARARGS,
+ M_Mathutils_Matrix_doc},
+ {"RotationMatrix", ( PyCFunction ) M_Mathutils_RotationMatrix,
+ METH_VARARGS,
+ M_Mathutils_RotationMatrix_doc},
+ {"ScaleMatrix", ( PyCFunction ) M_Mathutils_ScaleMatrix, METH_VARARGS,
+ M_Mathutils_ScaleMatrix_doc},
+ {"ShearMatrix", ( PyCFunction ) M_Mathutils_ShearMatrix, METH_VARARGS,
+ M_Mathutils_ShearMatrix_doc},
+ {"TranslationMatrix", ( PyCFunction ) M_Mathutils_TranslationMatrix,
+ METH_VARARGS,
+ M_Mathutils_TranslationMatrix_doc},
+ {"CopyMat", ( PyCFunction ) M_Mathutils_CopyMat, METH_VARARGS,
+ M_Mathutils_CopyMat_doc},
+ {"OrthoProjectionMatrix",
+ ( PyCFunction ) M_Mathutils_OrthoProjectionMatrix, METH_VARARGS,
+ M_Mathutils_OrthoProjectionMatrix_doc},
+ {"MatMultVec", ( PyCFunction ) M_Mathutils_MatMultVec, METH_VARARGS,
+ M_Mathutils_MatMultVec_doc},
+ {"Quaternion", ( PyCFunction ) M_Mathutils_Quaternion, METH_VARARGS,
+ M_Mathutils_Quaternion_doc},
+ {"CopyQuat", ( PyCFunction ) M_Mathutils_CopyQuat, METH_VARARGS,
+ M_Mathutils_CopyQuat_doc},
+ {"CrossQuats", ( PyCFunction ) M_Mathutils_CrossQuats, METH_VARARGS,
+ M_Mathutils_CrossQuats_doc},
+ {"DotQuats", ( PyCFunction ) M_Mathutils_DotQuats, METH_VARARGS,
+ M_Mathutils_DotQuats_doc},
+ {"DifferenceQuats", ( PyCFunction ) M_Mathutils_DifferenceQuats,
+ METH_VARARGS,
+ M_Mathutils_DifferenceQuats_doc},
+ {"Slerp", ( PyCFunction ) M_Mathutils_Slerp, METH_VARARGS,
+ M_Mathutils_Slerp_doc},
+ {"Euler", ( PyCFunction ) M_Mathutils_Euler, METH_VARARGS,
+ M_Mathutils_Euler_doc},
+ {"CopyEuler", ( PyCFunction ) M_Mathutils_CopyEuler, METH_VARARGS,
+ M_Mathutils_CopyEuler_doc},
+ {"RotateEuler", ( PyCFunction ) M_Mathutils_RotateEuler, METH_VARARGS,
+ M_Mathutils_RotateEuler_doc},
+ {NULL, NULL, 0, NULL}
+};
+
+
//***************************************************************************
// Function: M_Mathutils_Rand
//***************************************************************************
diff --git a/source/blender/python/api2_2x/Mathutils.h b/source/blender/python/api2_2x/Mathutils.h
index 9a0e30b2eaf..7d34187656e 100644
--- a/source/blender/python/api2_2x/Mathutils.h
+++ b/source/blender/python/api2_2x/Mathutils.h
@@ -1,4 +1,7 @@
-/* * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -30,182 +33,10 @@
#ifndef EXPP_Mathutils_H
#define EXPP_Mathutils_H
-#include <Python.h>
-#include <BKE_main.h>
-#include <BKE_global.h>
-#include <BKE_library.h>
-#include <BKE_utildefines.h>
-#include <BLI_blenlib.h>
-#include <BLI_arithb.h>
-#include <PIL_time.h>
-#include <BLI_rand.h>
-#include <math.h>
-#include "vector.h"
-#include "euler.h"
-#include "quat.h"
-#include "matrix.h"
-#include "blendef.h"
-#include "mydevice.h"
-#include "constant.h"
-#include "gen_utils.h"
-#include "modules.h"
-#include "Types.h"
-
-/*****************************************************************************/
-// Python API function prototypes for the Mathutils module.
-/*****************************************************************************/
-static PyObject *M_Mathutils_Rand( PyObject * self, PyObject * args );
-static PyObject *M_Mathutils_Vector( PyObject * self, PyObject * args );
-static PyObject *M_Mathutils_CrossVecs( PyObject * self, PyObject * args );
-static PyObject *M_Mathutils_DotVecs( PyObject * self, PyObject * args );
-static PyObject *M_Mathutils_AngleBetweenVecs( PyObject * self,
- PyObject * args );
-static PyObject *M_Mathutils_MidpointVecs( PyObject * self, PyObject * args );
-static PyObject *M_Mathutils_VecMultMat( PyObject * self, PyObject * args );
-static PyObject *M_Mathutils_ProjectVecs( PyObject * self, PyObject * args );
-static PyObject *M_Mathutils_CopyVec( PyObject * self, PyObject * args );
-static PyObject *M_Mathutils_Matrix( PyObject * self, PyObject * args );
-static PyObject *M_Mathutils_RotationMatrix( PyObject * self,
- PyObject * args );
-static PyObject *M_Mathutils_ScaleMatrix( PyObject * self, PyObject * args );
-static PyObject *M_Mathutils_OrthoProjectionMatrix( PyObject * self,
- PyObject * args );
-static PyObject *M_Mathutils_ShearMatrix( PyObject * self, PyObject * args );
-static PyObject *M_Mathutils_TranslationMatrix( PyObject * self,
- PyObject * args );
-static PyObject *M_Mathutils_MatMultVec( PyObject * self, PyObject * args );
-static PyObject *M_Mathutils_CopyMat( PyObject * self, PyObject * args );
-static PyObject *M_Mathutils_Quaternion( PyObject * self, PyObject * args );
-static PyObject *M_Mathutils_CrossQuats( PyObject * self, PyObject * args );
-static PyObject *M_Mathutils_DotQuats( PyObject * self, PyObject * args );
-static PyObject *M_Mathutils_CopyQuat( PyObject * self, PyObject * args );
-static PyObject *M_Mathutils_DifferenceQuats( PyObject * self,
- PyObject * args );
-static PyObject *M_Mathutils_Slerp( PyObject * self, PyObject * args );
-static PyObject *M_Mathutils_Euler( PyObject * self, PyObject * args );
-static PyObject *M_Mathutils_CopyEuler( PyObject * self, PyObject * args );
-static PyObject *M_Mathutils_RotateEuler( PyObject * self, PyObject * args );
-
-/*****************************************************************************/
-// The following string definitions are used for documentation strings.
-// In Python these will be written to the console when doing a
-// Blender.Mathutils.__doc__
-/* Mathutils Module strings */
-/****************************************************************************/
-static char M_Mathutils_doc[] = "The Blender Mathutils module\n\n";
-static char M_Mathutils_Vector_doc[] =
- "() - create a new vector object from a list of floats";
-static char M_Mathutils_Matrix_doc[] =
- "() - create a new matrix object from a list of floats";
-static char M_Mathutils_Quaternion_doc[] =
- "() - create a quaternion from a list or an axis of rotation and an angle";
-static char M_Mathutils_Euler_doc[] =
- "() - create and return a new euler object";
-static char M_Mathutils_Rand_doc[] = "() - return a random number";
-static char M_Mathutils_CrossVecs_doc[] =
- "() - returns a vector perpedicular to the 2 vectors crossed";
-static char M_Mathutils_CopyVec_doc[] = "() - create a copy of vector";
-static char M_Mathutils_DotVecs_doc[] =
- "() - return the dot product of two vectors";
-static char M_Mathutils_AngleBetweenVecs_doc[] =
- "() - returns the angle between two vectors in degrees";
-static char M_Mathutils_MidpointVecs_doc[] =
- "() - return the vector to the midpoint between two vectors";
-static char M_Mathutils_MatMultVec_doc[] =
- "() - multiplies a matrix by a column vector";
-static char M_Mathutils_VecMultMat_doc[] =
- "() - multiplies a row vector by a matrix";
-static char M_Mathutils_ProjectVecs_doc[] =
- "() - returns the projection vector from the projection of vecA onto vecB";
-static char M_Mathutils_RotationMatrix_doc[] =
- "() - construct a rotation matrix from an angle and axis of rotation";
-static char M_Mathutils_ScaleMatrix_doc[] =
- "() - construct a scaling matrix from a scaling factor";
-static char M_Mathutils_OrthoProjectionMatrix_doc[] =
- "() - construct a orthographic projection matrix from a selected plane";
-static char M_Mathutils_ShearMatrix_doc[] =
- "() - construct a shearing matrix from a plane of shear and a shear factor";
-static char M_Mathutils_CopyMat_doc[] = "() - create a copy of a matrix";
-static char M_Mathutils_TranslationMatrix_doc[] =
- "() - create a translation matrix from a vector";
-static char M_Mathutils_CopyQuat_doc[] = "() - copy quatB to quatA";
-static char M_Mathutils_CopyEuler_doc[] = "() - copy eulB to eultA";
-static char M_Mathutils_CrossQuats_doc[] =
- "() - return the mutliplication of two quaternions";
-static char M_Mathutils_DotQuats_doc[] =
- "() - return the dot product of two quaternions";
-static char M_Mathutils_Slerp_doc[] =
- "() - returns the interpolation between two quaternions";
-static char M_Mathutils_DifferenceQuats_doc[] =
- "() - return the angular displacment difference between two quats";
-static char M_Mathutils_RotateEuler_doc[] =
- "() - rotate euler by an axis and angle";
+#include "Types.h"
-/****************************************************************************/
-// Python method structure definition for Blender.Mathutils module:
-/****************************************************************************/
-struct PyMethodDef M_Mathutils_methods[] = {
- {"Rand", ( PyCFunction ) M_Mathutils_Rand, METH_VARARGS,
- M_Mathutils_Rand_doc},
- {"Vector", ( PyCFunction ) M_Mathutils_Vector, METH_VARARGS,
- M_Mathutils_Vector_doc},
- {"CrossVecs", ( PyCFunction ) M_Mathutils_CrossVecs, METH_VARARGS,
- M_Mathutils_CrossVecs_doc},
- {"DotVecs", ( PyCFunction ) M_Mathutils_DotVecs, METH_VARARGS,
- M_Mathutils_DotVecs_doc},
- {"AngleBetweenVecs", ( PyCFunction ) M_Mathutils_AngleBetweenVecs,
- METH_VARARGS,
- M_Mathutils_AngleBetweenVecs_doc},
- {"MidpointVecs", ( PyCFunction ) M_Mathutils_MidpointVecs,
- METH_VARARGS,
- M_Mathutils_MidpointVecs_doc},
- {"VecMultMat", ( PyCFunction ) M_Mathutils_VecMultMat, METH_VARARGS,
- M_Mathutils_VecMultMat_doc},
- {"ProjectVecs", ( PyCFunction ) M_Mathutils_ProjectVecs, METH_VARARGS,
- M_Mathutils_ProjectVecs_doc},
- {"CopyVec", ( PyCFunction ) M_Mathutils_CopyVec, METH_VARARGS,
- M_Mathutils_CopyVec_doc},
- {"Matrix", ( PyCFunction ) M_Mathutils_Matrix, METH_VARARGS,
- M_Mathutils_Matrix_doc},
- {"RotationMatrix", ( PyCFunction ) M_Mathutils_RotationMatrix,
- METH_VARARGS,
- M_Mathutils_RotationMatrix_doc},
- {"ScaleMatrix", ( PyCFunction ) M_Mathutils_ScaleMatrix, METH_VARARGS,
- M_Mathutils_ScaleMatrix_doc},
- {"ShearMatrix", ( PyCFunction ) M_Mathutils_ShearMatrix, METH_VARARGS,
- M_Mathutils_ShearMatrix_doc},
- {"TranslationMatrix", ( PyCFunction ) M_Mathutils_TranslationMatrix,
- METH_VARARGS,
- M_Mathutils_TranslationMatrix_doc},
- {"CopyMat", ( PyCFunction ) M_Mathutils_CopyMat, METH_VARARGS,
- M_Mathutils_CopyMat_doc},
- {"OrthoProjectionMatrix",
- ( PyCFunction ) M_Mathutils_OrthoProjectionMatrix, METH_VARARGS,
- M_Mathutils_OrthoProjectionMatrix_doc},
- {"MatMultVec", ( PyCFunction ) M_Mathutils_MatMultVec, METH_VARARGS,
- M_Mathutils_MatMultVec_doc},
- {"Quaternion", ( PyCFunction ) M_Mathutils_Quaternion, METH_VARARGS,
- M_Mathutils_Quaternion_doc},
- {"CopyQuat", ( PyCFunction ) M_Mathutils_CopyQuat, METH_VARARGS,
- M_Mathutils_CopyQuat_doc},
- {"CrossQuats", ( PyCFunction ) M_Mathutils_CrossQuats, METH_VARARGS,
- M_Mathutils_CrossQuats_doc},
- {"DotQuats", ( PyCFunction ) M_Mathutils_DotQuats, METH_VARARGS,
- M_Mathutils_DotQuats_doc},
- {"DifferenceQuats", ( PyCFunction ) M_Mathutils_DifferenceQuats,
- METH_VARARGS,
- M_Mathutils_DifferenceQuats_doc},
- {"Slerp", ( PyCFunction ) M_Mathutils_Slerp, METH_VARARGS,
- M_Mathutils_Slerp_doc},
- {"Euler", ( PyCFunction ) M_Mathutils_Euler, METH_VARARGS,
- M_Mathutils_Euler_doc},
- {"CopyEuler", ( PyCFunction ) M_Mathutils_CopyEuler, METH_VARARGS,
- M_Mathutils_CopyEuler_doc},
- {"RotateEuler", ( PyCFunction ) M_Mathutils_RotateEuler, METH_VARARGS,
- M_Mathutils_RotateEuler_doc},
- {NULL, NULL, 0, NULL}
-};
+PyObject *Mathutils_Init( void );
#endif /* EXPP_Mathutils_H */
diff --git a/source/blender/python/api2_2x/Metaball.c b/source/blender/python/api2_2x/Metaball.c
index 6c55dddfc4d..9a64820cd07 100644
--- a/source/blender/python/api2_2x/Metaball.c
+++ b/source/blender/python/api2_2x/Metaball.c
@@ -32,10 +32,185 @@
#include "Metaball.h"
-PyObject *Metaball_Init( void );
-PyObject *Metaball_CreatePyObject( MetaBall * metaball );
-MetaBall *Metaball_FromPyObject( PyObject * py_obj );
-int Metaball_CheckPyObject( PyObject * py_obj );
+#include <BKE_main.h>
+#include <BKE_global.h>
+#include <BKE_mball.h>
+#include <BKE_object.h>
+#include <BKE_library.h>
+#include <BLI_blenlib.h>
+
+#include "constant.h"
+#include "gen_utils.h"
+
+
+
+/*****************************************************************************/
+/* Python API function prototypes for the Metaball module. */
+/*****************************************************************************/
+static PyObject *M_Metaball_New( PyObject * self, PyObject * args );
+static PyObject *M_Metaball_Get( PyObject * self, PyObject * args );
+
+/*****************************************************************************/
+/* The following string definitions are used for documentation strings. */
+/* In Python these will be written to the console when doing a */
+/* Blender.Metaball.__doc__ */
+/*****************************************************************************/
+static char M_Metaball_doc[] =
+ "The Blender Metaball module\n\n\nMetaballs are spheres\
+ that can join each other to create smooth,\
+ organic volumes\n. The spheres themseves are called\
+ 'Metaelements' and can be accessed from the Metaball module.";
+
+static char M_Metaball_New_doc[] = "Creates a new metaball";
+
+static char M_Metaball_Get_doc[] = "Retreives an existing metaball";
+
+/*****************************************************************************/
+/* Python method structure definition for Blender.Metaball module: */
+/*****************************************************************************/
+struct PyMethodDef M_Metaball_methods[] = {
+ {"New", M_Metaball_New, METH_VARARGS, M_Metaball_New_doc},
+ {"Get", M_Metaball_Get, METH_VARARGS, M_Metaball_Get_doc},
+ {"get", M_Metaball_Get, METH_VARARGS, M_Metaball_Get_doc},
+ {NULL, NULL, 0, NULL}
+};
+
+
+/*****************************************************************************/
+/* Python BPy_Metaball methods declarations: */
+/*****************************************************************************/
+static PyObject *Metaball_getMetaElemList( BPy_Metaball * self );
+static PyObject *Metaball_addMetaelem( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_getBbox( BPy_Metaball * self );
+static PyObject *Metaball_getName( BPy_Metaball * self );
+static PyObject *Metaball_setName( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_getWiresize( BPy_Metaball * self );
+static PyObject *Metaball_setWiresize( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_getRendersize( BPy_Metaball * self );
+static PyObject *Metaball_setRendersize( BPy_Metaball * self,
+ PyObject * args );
+static PyObject *Metaball_getThresh( BPy_Metaball * self );
+static PyObject *Metaball_setThresh( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_getNMetaElems( BPy_Metaball * self );
+static PyObject *Metaball_getMetatype( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_setMetatype( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_getMetadata( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_setMetadata( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_getMetax( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_setMetax( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_getMetay( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_setMetay( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_getMetaz( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_setMetaz( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_getMetas( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_setMetas( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_getMetalen( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_setMetalen( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_getloc( BPy_Metaball * self );
+static PyObject *Metaball_setloc( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_getrot( BPy_Metaball * self );
+static PyObject *Metaball_setrot( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_getsize( BPy_Metaball * self );
+static PyObject *Metaball_setsize( BPy_Metaball * self, PyObject * args );
+
+/*****************************************************************************/
+/* Python BPy_Metaball methods table: */
+/*****************************************************************************/
+static PyMethodDef BPy_Metaball_methods[] = {
+ /* name, method, flags, doc */
+ {"getName", ( PyCFunction ) Metaball_getName,
+ METH_NOARGS, "() - Return Metaball name"},
+
+ {"getMetaElemList", ( PyCFunction ) Metaball_getMetaElemList,
+ METH_NOARGS, "() - Return Metaelems list"},
+
+ {"addMetaelem", ( PyCFunction ) Metaball_addMetaelem,
+ METH_VARARGS, "() -Adds a metaelem to the metaball"},
+ {"setName", ( PyCFunction ) Metaball_setName,
+ METH_VARARGS, "() - Sets Metaball name"},
+ {"getWiresize", ( PyCFunction ) Metaball_getWiresize,
+ METH_NOARGS, "() - Return Metaball wire size"},
+ {"setWiresize", ( PyCFunction ) Metaball_setWiresize,
+ METH_VARARGS, "() - Sets Metaball wire size"},
+ {"getRendersize", ( PyCFunction ) Metaball_getRendersize,
+ METH_NOARGS, "() - Return Metaball render size"},
+ {"setRendersize", ( PyCFunction ) Metaball_setRendersize,
+ METH_VARARGS, "() - Sets Metaball render size"},
+ {"getThresh", ( PyCFunction ) Metaball_getThresh,
+ METH_NOARGS, "() - Return Metaball threshold"},
+ {"setThresh", ( PyCFunction ) Metaball_setThresh,
+ METH_VARARGS, "() - Sets Metaball threshold"},
+ {"getBbox", ( PyCFunction ) Metaball_getBbox,
+ METH_NOARGS, "() - Return Metaball bounding box"},
+ {"getNMetaElems", ( PyCFunction ) Metaball_getNMetaElems,
+ METH_NOARGS, "() Returns the number of Spheres "},
+ {"getMetatype", ( PyCFunction ) Metaball_getMetatype,
+ METH_VARARGS, "() - "},
+ {"setMetatype", ( PyCFunction ) Metaball_setMetatype,
+ METH_VARARGS, "() - "},
+ {"getMetadata", ( PyCFunction ) Metaball_getMetadata,
+ METH_VARARGS, "() - Gets Metaball MetaData "},
+ {"setMetadata", ( PyCFunction ) Metaball_setMetadata,
+ METH_VARARGS, "() - "},
+ {"getMetax", ( PyCFunction ) Metaball_getMetax,
+ METH_VARARGS, "() - gets the x coordinate of the metaelement "},
+ {"setMetax", ( PyCFunction ) Metaball_setMetax,
+ METH_VARARGS, "() -sets the x coordinate of the metaelement "},
+ {"getMetay", ( PyCFunction ) Metaball_getMetay,
+ METH_VARARGS, "() - gets the y coordinate of the metaelement"},
+ {"setMetay", ( PyCFunction ) Metaball_setMetay,
+ METH_VARARGS, "() - sets the y coordinate of the metaelement"},
+ {"getMetaz", ( PyCFunction ) Metaball_getMetaz,
+ METH_VARARGS, "() - gets the z coordinate of the metaelement"},
+ {"setMetaz", ( PyCFunction ) Metaball_setMetaz,
+ METH_VARARGS, "() - sets the z coordinate of the metaelement"},
+ {"getMetas", ( PyCFunction ) Metaball_getMetas,
+ METH_VARARGS, "() - gets the s coordinate of the metaelement"},
+ {"setMetas", ( PyCFunction ) Metaball_setMetas,
+ METH_VARARGS, "() - sets the s coordinate of the metaelement"},
+ {"getMetalen", ( PyCFunction ) Metaball_getMetalen,
+ METH_VARARGS, "() - gets the length of the metaelement."},
+ {"setMetalen", ( PyCFunction ) Metaball_setMetalen,
+ METH_VARARGS, "() - sets the length of the metaelement."},
+ {"getloc", ( PyCFunction ) Metaball_getloc,
+ METH_NOARGS, "() - Gets Metaball loc values"},
+ {"setloc", ( PyCFunction ) Metaball_setloc,
+ METH_VARARGS, "(f f f) - Sets Metaball loc values"},
+ {"getrot", ( PyCFunction ) Metaball_getrot,
+ METH_NOARGS, "() - Gets Metaball rot values"},
+ {"setrot", ( PyCFunction ) Metaball_setrot,
+ METH_VARARGS, "(f f f) - Sets Metaball rot values"},
+ {"getsize", ( PyCFunction ) Metaball_getsize,
+ METH_NOARGS, "() - Gets Metaball size values"},
+ {"setsize", ( PyCFunction ) Metaball_setsize,
+ METH_VARARGS, "(f f f) - Sets Metaball size values"},
+ {NULL, NULL, 0, NULL}
+};
+
+/*****************************************************************************/
+/* Python BPy_Metaelem methods table: */
+/*****************************************************************************/
+static PyMethodDef BPy_Metaelem_methods[] = {
+ {NULL, NULL, 0, NULL}
+};
+
+/*****************************************************************************/
+/* Python Metaball_Type callback function prototypes: */
+/*****************************************************************************/
+static void MetaballDeAlloc( BPy_Metaball * self );
+static int MetaballSetAttr( BPy_Metaball * self, char *name, PyObject * v );
+static PyObject *MetaballGetAttr( BPy_Metaball * self, char *name );
+static PyObject *MetaballRepr( BPy_Metaball * self );
+
+/*****************************************************************************/
+/* Python Metaelem_Type callback function prototypes: */
+/*****************************************************************************/
+static void MetaelemDeAlloc( BPy_Metaelem * self );
+static int MetaelemSetAttr( BPy_Metaelem * self, char *name, PyObject * v );
+static PyObject *MetaelemGetAttr( BPy_Metaelem * self, char *name );
+static PyObject *MetaelemRepr( BPy_Metaelem * self );
+
+
/*****************************************************************************/
/* Python Metaball_Type structure definition: */
diff --git a/source/blender/python/api2_2x/Metaball.h b/source/blender/python/api2_2x/Metaball.h
index 2d91cdc2dd7..b190b53dce3 100644
--- a/source/blender/python/api2_2x/Metaball.h
+++ b/source/blender/python/api2_2x/Metaball.h
@@ -34,185 +34,38 @@
#define EXPP_METABALL_H
#include <Python.h>
+#include <DNA_meta_types.h>
-#include <BKE_main.h>
-#include <BKE_global.h>
-#include <BKE_mball.h>
-#include <BKE_object.h>
-#include <BKE_library.h>
-#include <BLI_blenlib.h>
-#include "constant.h"
-#include "gen_utils.h"
-#include "modules.h"
-#include "bpy_types.h"
+extern PyTypeObject Metaball_Type;
+#define BPy_Metaball_Check(v) ((v)->ob_type==&Metaball_Type)
-/*****************************************************************************/
-/* Python API function prototypes for the Metaball module. */
-/*****************************************************************************/
-static PyObject *M_Metaball_New( PyObject * self, PyObject * args );
-static PyObject *M_Metaball_Get( PyObject * self, PyObject * args );
+/* Python BPy_Metaball structure definition */
+typedef struct {
+ PyObject_HEAD /* required py macro */
+ MetaBall * metaball;
+} BPy_Metaball;
-/*****************************************************************************/
-/* The following string definitions are used for documentation strings. */
-/* In Python these will be written to the console when doing a */
-/* Blender.Metaball.__doc__ */
-/*****************************************************************************/
-static char M_Metaball_doc[] =
- "The Blender Metaball module\n\n\nMetaballs are spheres\
- that can join each other to create smooth,\
- organic volumes\n. The spheres themseves are called\
- 'Metaelements' and can be accessed from the Metaball module.";
-static char M_Metaball_New_doc[] = "Creates a new metaball";
+extern PyTypeObject Metaelem_Type;
-static char M_Metaball_Get_doc[] = "Retreives an existing metaball";
+#define BPy_Metaelem_Check(v) ((v)->ob_type==&Metaelem_Type)
-/*****************************************************************************/
-/* Python method structure definition for Blender.Metaball module: */
-/*****************************************************************************/
-struct PyMethodDef M_Metaball_methods[] = {
- {"New", M_Metaball_New, METH_VARARGS, M_Metaball_New_doc},
- {"Get", M_Metaball_Get, METH_VARARGS, M_Metaball_Get_doc},
- {"get", M_Metaball_Get, METH_VARARGS, M_Metaball_Get_doc},
- {NULL, NULL, 0, NULL}
-};
+/* Python BPy_Metaelem structure definition */
+typedef struct {
+ PyObject_HEAD /* required py macro */
+ MetaElem * metaelem;
+} BPy_Metaelem;
-/*****************************************************************************/
-/* Python BPy_Metaball methods declarations: */
-/*****************************************************************************/
-static PyObject *Metaball_getMetaElemList( BPy_Metaball * self );
-static PyObject *Metaball_addMetaelem( BPy_Metaball * self, PyObject * args );
-static PyObject *Metaball_getBbox( BPy_Metaball * self );
-static PyObject *Metaball_getName( BPy_Metaball * self );
-static PyObject *Metaball_setName( BPy_Metaball * self, PyObject * args );
-static PyObject *Metaball_getWiresize( BPy_Metaball * self );
-static PyObject *Metaball_setWiresize( BPy_Metaball * self, PyObject * args );
-static PyObject *Metaball_getRendersize( BPy_Metaball * self );
-static PyObject *Metaball_setRendersize( BPy_Metaball * self,
- PyObject * args );
-static PyObject *Metaball_getThresh( BPy_Metaball * self );
-static PyObject *Metaball_setThresh( BPy_Metaball * self, PyObject * args );
-static PyObject *Metaball_getNMetaElems( BPy_Metaball * self );
-static PyObject *Metaball_getMetatype( BPy_Metaball * self, PyObject * args );
-static PyObject *Metaball_setMetatype( BPy_Metaball * self, PyObject * args );
-static PyObject *Metaball_getMetadata( BPy_Metaball * self, PyObject * args );
-static PyObject *Metaball_setMetadata( BPy_Metaball * self, PyObject * args );
-static PyObject *Metaball_getMetax( BPy_Metaball * self, PyObject * args );
-static PyObject *Metaball_setMetax( BPy_Metaball * self, PyObject * args );
-static PyObject *Metaball_getMetay( BPy_Metaball * self, PyObject * args );
-static PyObject *Metaball_setMetay( BPy_Metaball * self, PyObject * args );
-static PyObject *Metaball_getMetaz( BPy_Metaball * self, PyObject * args );
-static PyObject *Metaball_setMetaz( BPy_Metaball * self, PyObject * args );
-static PyObject *Metaball_getMetas( BPy_Metaball * self, PyObject * args );
-static PyObject *Metaball_setMetas( BPy_Metaball * self, PyObject * args );
-static PyObject *Metaball_getMetalen( BPy_Metaball * self, PyObject * args );
-static PyObject *Metaball_setMetalen( BPy_Metaball * self, PyObject * args );
-static PyObject *Metaball_getloc( BPy_Metaball * self );
-static PyObject *Metaball_setloc( BPy_Metaball * self, PyObject * args );
-static PyObject *Metaball_getrot( BPy_Metaball * self );
-static PyObject *Metaball_setrot( BPy_Metaball * self, PyObject * args );
-static PyObject *Metaball_getsize( BPy_Metaball * self );
-static PyObject *Metaball_setsize( BPy_Metaball * self, PyObject * args );
-
-/*****************************************************************************/
-/* Python BPy_Metaball methods table: */
-/*****************************************************************************/
-static PyMethodDef BPy_Metaball_methods[] = {
- /* name, method, flags, doc */
- {"getName", ( PyCFunction ) Metaball_getName,
- METH_NOARGS, "() - Return Metaball name"},
-
- {"getMetaElemList", ( PyCFunction ) Metaball_getMetaElemList,
- METH_NOARGS, "() - Return Metaelems list"},
-
- {"addMetaelem", ( PyCFunction ) Metaball_addMetaelem,
- METH_VARARGS, "() -Adds a metaelem to the metaball"},
- {"setName", ( PyCFunction ) Metaball_setName,
- METH_VARARGS, "() - Sets Metaball name"},
- {"getWiresize", ( PyCFunction ) Metaball_getWiresize,
- METH_NOARGS, "() - Return Metaball wire size"},
- {"setWiresize", ( PyCFunction ) Metaball_setWiresize,
- METH_VARARGS, "() - Sets Metaball wire size"},
- {"getRendersize", ( PyCFunction ) Metaball_getRendersize,
- METH_NOARGS, "() - Return Metaball render size"},
- {"setRendersize", ( PyCFunction ) Metaball_setRendersize,
- METH_VARARGS, "() - Sets Metaball render size"},
- {"getThresh", ( PyCFunction ) Metaball_getThresh,
- METH_NOARGS, "() - Return Metaball threshold"},
- {"setThresh", ( PyCFunction ) Metaball_setThresh,
- METH_VARARGS, "() - Sets Metaball threshold"},
- {"getBbox", ( PyCFunction ) Metaball_getBbox,
- METH_NOARGS, "() - Return Metaball bounding box"},
- {"getNMetaElems", ( PyCFunction ) Metaball_getNMetaElems,
- METH_NOARGS, "() Returns the number of Spheres "},
- {"getMetatype", ( PyCFunction ) Metaball_getMetatype,
- METH_VARARGS, "() - "},
- {"setMetatype", ( PyCFunction ) Metaball_setMetatype,
- METH_VARARGS, "() - "},
- {"getMetadata", ( PyCFunction ) Metaball_getMetadata,
- METH_VARARGS, "() - Gets Metaball MetaData "},
- {"setMetadata", ( PyCFunction ) Metaball_setMetadata,
- METH_VARARGS, "() - "},
- {"getMetax", ( PyCFunction ) Metaball_getMetax,
- METH_VARARGS, "() - gets the x coordinate of the metaelement "},
- {"setMetax", ( PyCFunction ) Metaball_setMetax,
- METH_VARARGS, "() -sets the x coordinate of the metaelement "},
- {"getMetay", ( PyCFunction ) Metaball_getMetay,
- METH_VARARGS, "() - gets the y coordinate of the metaelement"},
- {"setMetay", ( PyCFunction ) Metaball_setMetay,
- METH_VARARGS, "() - sets the y coordinate of the metaelement"},
- {"getMetaz", ( PyCFunction ) Metaball_getMetaz,
- METH_VARARGS, "() - gets the z coordinate of the metaelement"},
- {"setMetaz", ( PyCFunction ) Metaball_setMetaz,
- METH_VARARGS, "() - sets the z coordinate of the metaelement"},
- {"getMetas", ( PyCFunction ) Metaball_getMetas,
- METH_VARARGS, "() - gets the s coordinate of the metaelement"},
- {"setMetas", ( PyCFunction ) Metaball_setMetas,
- METH_VARARGS, "() - sets the s coordinate of the metaelement"},
- {"getMetalen", ( PyCFunction ) Metaball_getMetalen,
- METH_VARARGS, "() - gets the length of the metaelement."},
- {"setMetalen", ( PyCFunction ) Metaball_setMetalen,
- METH_VARARGS, "() - sets the length of the metaelement."},
- {"getloc", ( PyCFunction ) Metaball_getloc,
- METH_NOARGS, "() - Gets Metaball loc values"},
- {"setloc", ( PyCFunction ) Metaball_setloc,
- METH_VARARGS, "(f f f) - Sets Metaball loc values"},
- {"getrot", ( PyCFunction ) Metaball_getrot,
- METH_NOARGS, "() - Gets Metaball rot values"},
- {"setrot", ( PyCFunction ) Metaball_setrot,
- METH_VARARGS, "(f f f) - Sets Metaball rot values"},
- {"getsize", ( PyCFunction ) Metaball_getsize,
- METH_NOARGS, "() - Gets Metaball size values"},
- {"setsize", ( PyCFunction ) Metaball_setsize,
- METH_VARARGS, "(f f f) - Sets Metaball size values"},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python BPy_Metaelem methods table: */
-/*****************************************************************************/
-static PyMethodDef BPy_Metaelem_methods[] = {
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python Metaball_Type callback function prototypes: */
-/*****************************************************************************/
-static void MetaballDeAlloc( BPy_Metaball * self );
-static int MetaballSetAttr( BPy_Metaball * self, char *name, PyObject * v );
-static PyObject *MetaballGetAttr( BPy_Metaball * self, char *name );
-static PyObject *MetaballRepr( BPy_Metaball * self );
-
-/*****************************************************************************/
-/* Python Metaelem_Type callback function prototypes: */
-/*****************************************************************************/
-static void MetaelemDeAlloc( BPy_Metaelem * self );
-static int MetaelemSetAttr( BPy_Metaelem * self, char *name, PyObject * v );
-static PyObject *MetaelemGetAttr( BPy_Metaelem * self, char *name );
-static PyObject *MetaelemRepr( BPy_Metaelem * self );
+/*
+ * prototypes
+ */
+PyObject *Metaball_Init( void );
+PyObject *Metaball_CreatePyObject( MetaBall * metaball );
+MetaBall *Metaball_FromPyObject( PyObject * py_obj );
+int Metaball_CheckPyObject( PyObject * py_obj );
#endif /* EXPP_METABALL_H */
diff --git a/source/blender/python/api2_2x/NLA.c b/source/blender/python/api2_2x/NLA.c
index dce9db31a6e..088d6a5d0c7 100644
--- a/source/blender/python/api2_2x/NLA.c
+++ b/source/blender/python/api2_2x/NLA.c
@@ -35,6 +35,8 @@
#include <BKE_action.h>
#include <BKE_global.h>
#include <BKE_main.h>
+
+#include "Ipo.h"
#include "Types.h"
/*****************************************************************************/
diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c
index e172c30c394..541638c86e1 100644
--- a/source/blender/python/api2_2x/NMesh.c
+++ b/source/blender/python/api2_2x/NMesh.c
@@ -33,6 +33,39 @@
#include "NMesh.h"
+#include "DNA_key_types.h"
+#include "DNA_listBase.h"
+#include "DNA_object_types.h"
+#include "DNA_material_types.h"
+#include "DNA_armature_types.h"
+#include "DNA_scene_types.h"
+
+#include "BDR_editface.h" /* make_tfaces */
+#include "BIF_editdeform.h"
+#include "BIF_editkey.h" /* insert_meshkey */
+#include "BIF_editmesh.h" /* vertexnormals_mesh() : still needed???*/
+#include "BIF_meshtools.h" /* current loc of vertexnormals_mesh() */
+#include "BIF_space.h"
+#include "BKE_mesh.h"
+#include "BKE_main.h"
+#include "BKE_global.h"
+#include "BKE_library.h"
+#include "BKE_displist.h"
+#include "BKE_screen.h"
+#include "BKE_object.h"
+#include "BLI_blenlib.h"
+#include "BLI_arithb.h"
+#include "MEM_guardedalloc.h"
+
+#include "blendef.h"
+#include "mydevice.h"
+
+#include "Object.h"
+#include "vector.h"
+#include "constant.h"
+#include "gen_utils.h"
+
+
/* EXPP Mesh defines */
#define EXPP_NMESH_MODE_NOPUNOFLIP ME_NOPUNOFLIP
@@ -49,6 +82,21 @@
#define NMESH_SUBDIV_MIN 1
#define NMESH_SUBDIV_MAX 6
+/* Globals */
+static PyObject *g_nmeshmodule = NULL;
+
+static int unlink_existingMeshData( Mesh * mesh );
+static int convert_NMeshToMesh( Mesh * mesh, BPy_NMesh * nmesh );
+static PyObject *NMesh_addVertGroup( PyObject * self, PyObject * args );
+static PyObject *NMesh_removeVertGroup( PyObject * self, PyObject * args );
+static PyObject *NMesh_assignVertsToGroup( PyObject * self, PyObject * args );
+static PyObject *NMesh_removeVertsFromGroup( PyObject * self,
+ PyObject * args );
+static PyObject *NMesh_getVertsFromGroup( PyObject * self, PyObject * args );
+static PyObject *NMesh_renameVertGroup( PyObject * self, PyObject * args );
+static PyObject *NMesh_getVertGroupNames( PyObject * self, PyObject * args );
+
+
static char NMesh_addVertGroup_doc[] =
"add a named and empty vertex(deform) Group to a mesh that has been linked\n\
to an object. ";
diff --git a/source/blender/python/api2_2x/NMesh.h b/source/blender/python/api2_2x/NMesh.h
index 1d9b3386dc8..a9c21ac23b2 100644
--- a/source/blender/python/api2_2x/NMesh.h
+++ b/source/blender/python/api2_2x/NMesh.h
@@ -43,37 +43,9 @@
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
-#include "DNA_key_types.h"
-#include "DNA_listBase.h"
-#include "DNA_object_types.h"
-#include "DNA_material_types.h"
-#include "DNA_armature_types.h"
-
-#include "BDR_editface.h" /* make_tfaces */
-#include "BIF_editdeform.h"
-#include "BIF_editkey.h" /* insert_meshkey */
-#include "BIF_editmesh.h" /* vertexnormals_mesh() */
-#include "BIF_space.h"
-#include "BKE_mesh.h"
-#include "BKE_main.h"
-#include "BKE_global.h"
-#include "BKE_library.h"
-#include "BKE_displist.h"
-#include "BKE_screen.h"
-#include "BKE_object.h"
-#include "BLI_blenlib.h"
-#include "BLI_arithb.h"
-#include "MEM_guardedalloc.h"
-
-#include "blendef.h"
-#include "mydevice.h"
#include "Material.h"
#include "Image.h"
-#include "vector.h"
-#include "constant.h"
-#include "gen_utils.h"
-#include "modules.h"
/* EXPP PyType Objects */
PyTypeObject NMesh_Type;
@@ -81,19 +53,18 @@ PyTypeObject NMFace_Type;
PyTypeObject NMVert_Type;
PyTypeObject NMCol_Type;
-extern PyTypeObject Image_Type;
struct BPy_Object;
/* These are from blender/src/editdeform.c, should be declared elsewhere,
* maybe in BIF_editdeform.h, after proper testing of vgrouping methods XXX */
+
void create_dverts( Mesh * me );
void add_vert_defnr( Object * ob, int def_nr, int vertnum, float weight,
int assignmode );
void remove_vert_def_nr( Object * ob, int def_nr, int vertnum );
-/* Globals */
-static PyObject *g_nmeshmodule = NULL;
+
/* Type checking for EXPP PyTypes */
#define BPy_NMesh_Check(v) ((v)->ob_type == &NMesh_Type)
@@ -150,8 +121,13 @@ typedef struct {
/* PROTOS */
extern void test_object_materials( ID * id ); /* declared in BKE_material.h */
-static int unlink_existingMeshData( Mesh * mesh );
-static int convert_NMeshToMesh( Mesh * mesh, BPy_NMesh * nmesh );
+
+PyObject *NMesh_Init( void );
+PyObject *NMesh_CreatePyObject( Mesh * me, Object * ob );
+Mesh *Mesh_FromPyObject( PyObject * pyobj, Object * ob );
+int NMesh_CheckPyObject( PyObject * pyobj );
+
+
void mesh_update( Mesh * mesh );
PyObject *new_NMesh( Mesh * oldmesh );
Mesh *Mesh_fromNMesh( BPy_NMesh * nmesh );
@@ -159,14 +135,6 @@ PyObject *NMesh_assignMaterials_toObject( BPy_NMesh * nmesh, Object * ob );
Material **nmesh_updateMaterials( BPy_NMesh * nmesh );
Material **newMaterialList_fromPyList( PyObject * list );
void mesh_update( Mesh * mesh );
-static PyObject *NMesh_addVertGroup( PyObject * self, PyObject * args );
-static PyObject *NMesh_removeVertGroup( PyObject * self, PyObject * args );
-static PyObject *NMesh_assignVertsToGroup( PyObject * self, PyObject * args );
-static PyObject *NMesh_removeVertsFromGroup( PyObject * self,
- PyObject * args );
-static PyObject *NMesh_getVertsFromGroup( PyObject * self, PyObject * args );
-static PyObject *NMesh_renameVertGroup( PyObject * self, PyObject * args );
-static PyObject *NMesh_getVertGroupNames( PyObject * self, PyObject * args );
#endif /* EXPP_NMESH_H */
diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c
index ba5a757a3c6..f094b141fb0 100644
--- a/source/blender/python/api2_2x/Object.c
+++ b/source/blender/python/api2_2x/Object.c
@@ -39,12 +39,18 @@
#include "logic.h"
#include <blendef.h>
#include <DNA_scene_types.h>
+#include <DNA_mesh_types.h>
+#include <DNA_curve_types.h>
#include <DNA_property_types.h>
#include <BSE_edit.h>
#include <BKE_property.h>
#include <BKE_mball.h>
#include <BIF_editview.h>
+#include "Ipo.h"
+#include "Lattice.h"
+#include "modules.h"
+
/*****************************************************************************/
/* Python API function prototypes for the Blender module. */
diff --git a/source/blender/python/api2_2x/Object.h b/source/blender/python/api2_2x/Object.h
index e96ecca241e..c1b3025a386 100644
--- a/source/blender/python/api2_2x/Object.h
+++ b/source/blender/python/api2_2x/Object.h
@@ -59,9 +59,7 @@
#include <DNA_view3d_types.h>
#include <DNA_action_types.h>
-#include "bpy_types.h"
#include "gen_utils.h"
-#include "modules.h"
#include "vector.h"
#include "matrix.h"
#include "euler.h"
@@ -80,6 +78,13 @@ typedef struct {
PyObject_HEAD struct Object *object;
} BPy_Object;
+
+PyObject *Object_Init( void );
+PyObject *Object_CreatePyObject( struct Object *obj );
+Object *Object_FromPyObject( PyObject * py_obj );
+int Object_CheckPyObject( PyObject * py_obj );
+Object *GetObjectByName( char *name );
+
int EXPP_add_obdata( struct Object *object );
#endif /* EXPP_OBJECT_H */
diff --git a/source/blender/python/api2_2x/Particle.h b/source/blender/python/api2_2x/Particle.h
index 8a91f4ef9af..9010c50f70d 100644
--- a/source/blender/python/api2_2x/Particle.h
+++ b/source/blender/python/api2_2x/Particle.h
@@ -45,7 +45,18 @@
#include <DNA_effect_types.h>
#include "gen_utils.h"
-#include "bpy_types.h"
+
+extern PyTypeObject Particle_Type;
+
+#define BPy_Particle_Check(v) ((v)->ob_type==&Particle_Type)
+
+/* Python BPy_Particle structure definition */
+typedef struct {
+ PyObject_HEAD /* required py macro */
+ Effect * particle;
+} BPy_Particle;
+
+
/*****************************************************************************/
/* Python API function prototypes for the Particle module. */
diff --git a/source/blender/python/api2_2x/Registry.c b/source/blender/python/api2_2x/Registry.c
index c4de504451e..e0ba81b1029 100644
--- a/source/blender/python/api2_2x/Registry.c
+++ b/source/blender/python/api2_2x/Registry.c
@@ -32,6 +32,63 @@
#include "Registry.h"
+#include <stdio.h>
+
+#include "gen_utils.h"
+
+
+
+/* the Registry dictionary */
+PyObject *bpy_registryDict = NULL;
+
+/*****************************************************************************/
+/* Python API function prototypes for the Registry module. */
+/*****************************************************************************/
+static PyObject *M_Registry_Keys( PyObject * self );
+static PyObject *M_Registry_GetKey( PyObject * self, PyObject * args );
+static PyObject *M_Registry_SetKey( PyObject * self, PyObject * args );
+static PyObject *M_Registry_RemoveKey( PyObject * self, PyObject * args );
+
+/*****************************************************************************/
+/* The following string definitions are used for documentation strings. */
+/* In Python these will be written to the console when doing a */
+/* Blender.Registry.__doc__ */
+/*****************************************************************************/
+char M_Registry_doc[] =
+ "The Blender Registry module (persistent data cache)\n\n\
+ Use this module to store configuration data that a script can reload\n\
+ when it is executed again.\n";
+
+char M_Registry_Keys_doc[] =
+ "() - Get all keys in the Registry dictionary.\n\n\
+ Each key references another dict with saved data from a specific script.\n";
+
+char M_Registry_GetKey_doc[] =
+ "(name) - Get a specific entry (dict) from the Registry dictionary\n\
+ (name) - a string that references a specific script.\n";
+
+char M_Registry_SetKey_doc[] =
+ "(key, dict) - Store an entry in the Registry dictionary.\n\
+ If an entry with the same 'key' already exists, it is substituted.\n\
+ (key) - the string to use as a key for the dict being saved.\n\
+ (dict) - a dictionary with the data to be stored.\n";
+
+char M_Registry_RemoveKey_doc[] =
+ "(key) - Remove the dict with key 'key' from the Registry.\n";
+
+/*****************************************************************************/
+/* Python method structure definition for Blender.Registry module: */
+/*****************************************************************************/
+struct PyMethodDef M_Registry_methods[] = {
+ {"Keys", ( PyCFunction ) M_Registry_Keys, METH_VARARGS,
+ M_Registry_Keys_doc},
+ {"GetKey", M_Registry_GetKey, METH_VARARGS, M_Registry_GetKey_doc},
+ {"SetKey", M_Registry_SetKey, METH_VARARGS, M_Registry_SetKey_doc},
+ {"RemoveKey", M_Registry_RemoveKey, METH_VARARGS,
+ M_Registry_RemoveKey_doc},
+ {NULL, NULL, 0, NULL}
+};
+
/*****************************************************************************/
/* Function: M_Registry_Keys */
/* Python equivalent: Blender.Registry.Keys */
diff --git a/source/blender/python/api2_2x/Registry.h b/source/blender/python/api2_2x/Registry.h
index 1853b957413..4383d63e0bc 100644
--- a/source/blender/python/api2_2x/Registry.h
+++ b/source/blender/python/api2_2x/Registry.h
@@ -43,60 +43,8 @@
#define EXPP_REGISTRY_H
#include <Python.h>
-#include <stdio.h>
-#include "gen_utils.h"
-#include "modules.h"
-
-/* the Registry dictionary, declare here, defined in ../BPY_interface.c */
-PyObject *bpy_registryDict = NULL;
-
-/*****************************************************************************/
-/* Python API function prototypes for the Registry module. */
-/*****************************************************************************/
-static PyObject *M_Registry_Keys( PyObject * self );
-static PyObject *M_Registry_GetKey( PyObject * self, PyObject * args );
-static PyObject *M_Registry_SetKey( PyObject * self, PyObject * args );
-static PyObject *M_Registry_RemoveKey( PyObject * self, PyObject * args );
-
-/*****************************************************************************/
-/* The following string definitions are used for documentation strings. */
-/* In Python these will be written to the console when doing a */
-/* Blender.Registry.__doc__ */
-/*****************************************************************************/
-char M_Registry_doc[] =
- "The Blender Registry module (persistent data cache)\n\n\
- Use this module to store configuration data that a script can reload\n\
- when it is executed again.\n";
-
-char M_Registry_Keys_doc[] =
- "() - Get all keys in the Registry dictionary.\n\n\
- Each key references another dict with saved data from a specific script.\n";
-
-char M_Registry_GetKey_doc[] =
- "(name) - Get a specific entry (dict) from the Registry dictionary\n\
- (name) - a string that references a specific script.\n";
-
-char M_Registry_SetKey_doc[] =
- "(key, dict) - Store an entry in the Registry dictionary.\n\
- If an entry with the same 'key' already exists, it is substituted.\n\
- (key) - the string to use as a key for the dict being saved.\n\
- (dict) - a dictionary with the data to be stored.\n";
-
-char M_Registry_RemoveKey_doc[] =
- "(key) - Remove the dict with key 'key' from the Registry.\n";
-
-/*****************************************************************************/
-/* Python method structure definition for Blender.Registry module: */
-/*****************************************************************************/
-struct PyMethodDef M_Registry_methods[] = {
- {"Keys", ( PyCFunction ) M_Registry_Keys, METH_VARARGS,
- M_Registry_Keys_doc},
- {"GetKey", M_Registry_GetKey, METH_VARARGS, M_Registry_GetKey_doc},
- {"SetKey", M_Registry_SetKey, METH_VARARGS, M_Registry_SetKey_doc},
- {"RemoveKey", M_Registry_RemoveKey, METH_VARARGS,
- M_Registry_RemoveKey_doc},
- {NULL, NULL, 0, NULL}
-};
+extern PyObject *bpy_registryDict;
+PyObject *Registry_Init( void );
#endif /* EXPP_REGISTRY_H */
diff --git a/source/blender/python/api2_2x/Scene.c b/source/blender/python/api2_2x/Scene.c
index b6d7a5fe358..99d07986d01 100644
--- a/source/blender/python/api2_2x/Scene.c
+++ b/source/blender/python/api2_2x/Scene.c
@@ -46,7 +46,6 @@
#include <mydevice.h> /* for #define REDRAW */
#include "Object.h"
-#include "bpy_types.h"
#include "constant.h"
#include "gen_utils.h"
#include "sceneRender.h"
diff --git a/source/blender/python/api2_2x/Scene.h b/source/blender/python/api2_2x/Scene.h
index ca0775dc6f8..c6905d56be2 100644
--- a/source/blender/python/api2_2x/Scene.h
+++ b/source/blender/python/api2_2x/Scene.h
@@ -48,9 +48,12 @@ typedef struct {
} BPy_Scene;
//---------------------------Python BPy_Scene visible prototypes-----------
// Python Scene_Type helper functions needed by Blender (the Init function) and Object modules.
+
+
PyObject *Scene_Init( void );
PyObject *Scene_CreatePyObject( Scene * cam );
Scene *Scene_FromPyObject( PyObject * pyobj );
int Scene_CheckPyObject( PyObject * pyobj );
+Scene *GetSceneByName( char *name );
#endif /* EXPP_SCENE_H */
diff --git a/source/blender/python/api2_2x/Sys.c b/source/blender/python/api2_2x/Sys.c
index 56b80f7b79e..708c9c8fbb1 100644
--- a/source/blender/python/api2_2x/Sys.c
+++ b/source/blender/python/api2_2x/Sys.c
@@ -36,7 +36,7 @@
#include <Python.h>
#include <sys/stat.h>
#include "gen_utils.h"
-#include "modules.h"
+
/*****************************************************************************/
/* Python API function prototypes for the sys module. */
diff --git a/source/blender/python/api2_2x/Sys.h b/source/blender/python/api2_2x/Sys.h
index 7817fff1fdc..46f3017111d 100644
--- a/source/blender/python/api2_2x/Sys.h
+++ b/source/blender/python/api2_2x/Sys.h
@@ -33,4 +33,6 @@
#ifndef EXPP_sys_H
#define EXPP_sys_H
+PyObject *sys_Init( void );
+
#endif /* EXPP_sys_H */
diff --git a/source/blender/python/api2_2x/Text.c b/source/blender/python/api2_2x/Text.c
index 029b53f2664..55304588515 100644
--- a/source/blender/python/api2_2x/Text.c
+++ b/source/blender/python/api2_2x/Text.c
@@ -42,8 +42,8 @@
#include <BLI_blenlib.h>
#include <DNA_text_types.h>
+#include "Text.h"
#include "gen_utils.h"
-#include "modules.h"
#include "../BPY_extern.h"
#define EXPP_TEXT_MODE_FOLLOW TXT_FOLLOW
diff --git a/source/blender/python/api2_2x/Text.h b/source/blender/python/api2_2x/Text.h
index 01203ba1246..cf2b29986b4 100644
--- a/source/blender/python/api2_2x/Text.h
+++ b/source/blender/python/api2_2x/Text.h
@@ -32,4 +32,10 @@
#ifndef EXPP_TEXT_H
#define EXPP_TEXT_H
+
+#include <DNA_text_types.h>
+
+PyObject *Text_Init( void );
+PyObject *Text_CreatePyObject( Text * txt );
+
#endif /* EXPP_TEXT_H */
diff --git a/source/blender/python/api2_2x/Texture.c b/source/blender/python/api2_2x/Texture.c
index 839a804017f..144f200f045 100644
--- a/source/blender/python/api2_2x/Texture.c
+++ b/source/blender/python/api2_2x/Texture.c
@@ -40,9 +40,10 @@
#include "MTex.h"
#include "Texture.h"
#include "Image.h"
+#include "Ipo.h"
#include "constant.h"
#include "gen_utils.h"
-#include "modules.h"
+
/*****************************************************************************/
diff --git a/source/blender/python/api2_2x/Types.c b/source/blender/python/api2_2x/Types.c
index 6647071013f..930ecc7c270 100644
--- a/source/blender/python/api2_2x/Types.c
+++ b/source/blender/python/api2_2x/Types.c
@@ -36,14 +36,17 @@ This module is a dictionary of all Blender Python types";
struct PyMethodDef Null_methods[] = { {NULL, NULL, 0, NULL} };
+
+
+/* The internal types (lowercase first letter, like constant_Type) are only
+ * set when some object initializes them. But unless we do it early, we get
+ * some easy and unpredictable (varies with platform, even distro) ways to
+ * crash Blender. Some modules also need this early up, so let's generalize
+ * and init all our pytypes here.
+ */
+
void types_InitAll( void )
{
- /* The internal types (lowercase first letter, like constant_Type) are only
- * set when some object initializes them. But unless we do it early, we get
- * some easy and unpredictable (varies with platform, even distro) ways to
- * crash Blender. Some modules also need this early up, so let's generalize
- * and init all our pytypes here. */
-
Action_Type.ob_type = &PyType_Type;
Armature_Type.ob_type = &PyType_Type;
BezTriple_Type.ob_type = &PyType_Type;
diff --git a/source/blender/python/api2_2x/Types.h b/source/blender/python/api2_2x/Types.h
index 73b7209e4f9..a73a89a6cb1 100644
--- a/source/blender/python/api2_2x/Types.h
+++ b/source/blender/python/api2_2x/Types.h
@@ -54,4 +54,7 @@ extern PyTypeObject property_Type;
extern PyTypeObject buffer_Type, constant_Type, euler_Type;
extern PyTypeObject matrix_Type, quaternion_Type, rgbTuple_Type, vector_Type;
+PyObject *Types_Init( void );
+void types_InitAll( void );
+
#endif /* EXPP_TYPES_H */
diff --git a/source/blender/python/api2_2x/Wave.h b/source/blender/python/api2_2x/Wave.h
index 2fb5810ba47..91daf22c0fd 100644
--- a/source/blender/python/api2_2x/Wave.h
+++ b/source/blender/python/api2_2x/Wave.h
@@ -44,8 +44,21 @@
#include <BKE_library.h>
#include <DNA_effect_types.h>
+#include"Effect.h"
#include "gen_utils.h"
+
+extern PyTypeObject Wave_Type;
+
+#define BPy_Wave_Check(v) ((v)->ob_type==&Wave_Type)
+
+/* Python BPy_Wave structure definition */
+typedef struct {
+ PyObject_HEAD /* required py macro */
+ Effect * wave;
+} BPy_Wave;
+
+
/*****************************************************************************/
/* Python API function prototypes for the Wave module. */
/*****************************************************************************/
@@ -53,7 +66,7 @@ PyObject *M_Wave_New( PyObject * self, PyObject * args );
PyObject *M_Wave_Get( PyObject * self, PyObject * args );
-#include"Effect.h"
+
/*****************************************************************************/
/* Python BPy_Wave methods declarations: */
/*****************************************************************************/
diff --git a/source/blender/python/api2_2x/Window.c b/source/blender/python/api2_2x/Window.c
index 85dbbadcebd..84b3a5974bb 100644
--- a/source/blender/python/api2_2x/Window.c
+++ b/source/blender/python/api2_2x/Window.c
@@ -52,11 +52,12 @@
#include <DNA_view3d_types.h>
#include <DNA_screen_types.h>
#include <DNA_space_types.h>
+#include <DNA_scene_types.h>
#include <DNA_text_types.h>
#include <DNA_vec_types.h> /* for rcti struct */
+#include "windowTheme.h"
#include "gen_utils.h"
-#include "modules.h"
#include "matrix.h"
#include "vector.h"
#include "constant.h"
diff --git a/source/blender/python/api2_2x/Window.h b/source/blender/python/api2_2x/Window.h
index a615f408b42..25250724e83 100644
--- a/source/blender/python/api2_2x/Window.h
+++ b/source/blender/python/api2_2x/Window.h
@@ -35,4 +35,7 @@
#ifndef EXPP_WINDOW_H
#define EXPP_WINDOW_H
+PyObject *Window_Init( void );
+PyObject *M_Window_Redraw( PyObject * self, PyObject * args );
+
#endif /* EXPP_WINDOW_H */
diff --git a/source/blender/python/api2_2x/World.c b/source/blender/python/api2_2x/World.c
index 4f1c20d851d..89af766c354 100644
--- a/source/blender/python/api2_2x/World.c
+++ b/source/blender/python/api2_2x/World.c
@@ -36,7 +36,7 @@
* \brief Blender.World Module and World Data PyObject implementation.
*
* Note: Parameters between "<" and ">" are optional. But if one of them is
- * given, all preceding ones must be given, too. Of course, this only relates
+ * given, all preceding ones must be given, too. Of course, this only relates
* to the Python functions and methods described here and only inside Python
* code. [ This will go to another file later, probably the main exppython
* doc file]. XXX Better: put optional args with their default value:
@@ -49,7 +49,52 @@
#include <BKE_library.h>
#include <BLI_blenlib.h>
+#include <DNA_scene_types.h> /* for G.scene */
+
#include "World.h"
+#include "Ipo.h"
+
+#include "constant.h"
+#include "gen_utils.h"
+
+
+/*****************************************************************************/
+/* Python BPy_World methods declarations: */
+/*****************************************************************************/
+static PyObject *World_getRange( BPy_World * self );
+static PyObject *World_setRange( BPy_World * self, PyObject * args );
+static PyObject *World_getIpo( BPy_World * self );
+static PyObject *World_setIpo( BPy_World * self, PyObject * args );
+static PyObject *World_clearIpo( BPy_World * self );
+static PyObject *World_getName( BPy_World * self );
+static PyObject *World_setName( BPy_World * self, PyObject * args );
+static PyObject *World_getSkytype( BPy_World * self );
+static PyObject *World_setSkytype( BPy_World * self, PyObject * args );
+static PyObject *World_getMistype( BPy_World * self );
+static PyObject *World_setMistype( BPy_World * self, PyObject * args );
+static PyObject *World_getHor( BPy_World * self );
+static PyObject *World_setHor( BPy_World * self, PyObject * args );
+static PyObject *World_getZen( BPy_World * self );
+static PyObject *World_setZen( BPy_World * self, PyObject * args );
+static PyObject *World_getAmb( BPy_World * self );
+static PyObject *World_setAmb( BPy_World * self, PyObject * args );
+static PyObject *World_getStar( BPy_World * self );
+static PyObject *World_setStar( BPy_World * self, PyObject * args );
+static PyObject *World_getMist( BPy_World * self );
+static PyObject *World_setMist( BPy_World * self, PyObject * args );
+static PyObject *World_getScriptLinks( BPy_World * self, PyObject * args );
+static PyObject *World_addScriptLink( BPy_World * self, PyObject * args );
+static PyObject *World_clearScriptLinks( BPy_World * self );
+static PyObject *World_makeActive( BPy_World * self );
+
+
+/*****************************************************************************/
+/* Python API function prototypes for the World module. */
+/*****************************************************************************/
+static PyObject *M_World_New( PyObject * self, PyObject * args,
+ PyObject * keywords );
+static PyObject *M_World_Get( PyObject * self, PyObject * args );
+static PyObject *M_World_GetActive( PyObject * self );
/*****************************************************************************/
@@ -62,6 +107,105 @@ static int World_Compare( BPy_World * a, BPy_World * b );
static PyObject *World_GetAttr( BPy_World * self, char *name );
static PyObject *World_Repr( BPy_World * self );
+
+
+/*****************************************************************************/
+/* The following string definitions are used for documentation strings. */
+/* In Python these will be written to the console when doing a */
+/* Blender.World.__doc__ */
+/*****************************************************************************/
+static char M_World_doc[] = "The Blender World module\n\n\
+This module provides access to **World Data** objects in Blender\n\n";
+
+static char M_World_New_doc[] = "() - return a new World object";
+
+static char M_World_Get_doc[] =
+ "(name) - return the world with the name 'name', \
+returns None if not found.\n If 'name' is not specified, \
+it returns a list of all worlds in the\ncurrent scene.";
+static char M_World_GetActive_doc[] = "() - returns the current world, or \
+None if the Scene has no world";
+
+
+
+/*****************************************************************************/
+/* Python method structure definition for Blender.World module: */
+/*****************************************************************************/
+struct PyMethodDef M_World_methods[] = {
+ {"New", ( PyCFunction ) M_World_New, METH_VARARGS | METH_KEYWORDS,
+ M_World_New_doc},
+ {"Get", M_World_Get, METH_VARARGS, M_World_Get_doc},
+ {"GetActive", ( PyCFunction ) M_World_GetActive, METH_NOARGS,
+ M_World_GetActive_doc},
+ {"get", M_World_Get, METH_VARARGS, M_World_Get_doc},
+ {NULL, NULL, 0, NULL}
+};
+
+
+
+/*****************************************************************************/
+/* Python BPy_World methods table: */
+/*****************************************************************************/
+static PyMethodDef BPy_World_methods[] = {
+ {"getRange", ( PyCFunction ) World_getRange, METH_NOARGS,
+ "() - Return World Range"},
+ {"setRange", ( PyCFunction ) World_setRange, METH_VARARGS,
+ "() - Change this World's range"},
+ {"getIpo", ( PyCFunction ) World_getIpo, METH_NOARGS,
+ "() - Return World Ipo"},
+ {"setIpo", ( PyCFunction ) World_setIpo, METH_VARARGS,
+ "() - Change this World's ipo"},
+ {"clearIpo", ( PyCFunction ) World_clearIpo, METH_VARARGS,
+ "() - Unlink Ipo from this World"},
+ {"getName", ( PyCFunction ) World_getName, METH_NOARGS,
+ "() - Return World Data name"},
+ {"setName", ( PyCFunction ) World_setName, METH_VARARGS,
+ "() - Return World Data name"},
+ {"getSkytype", ( PyCFunction ) World_getSkytype, METH_NOARGS,
+ "() - Return World Data skytype"},
+ {"setSkytype", ( PyCFunction ) World_setSkytype, METH_VARARGS,
+ "() - Return World Data skytype"},
+ {"getMistype", ( PyCFunction ) World_getMistype, METH_NOARGS,
+ "() - Return World Data mistype"},
+ {"setMistype", ( PyCFunction ) World_setMistype, METH_VARARGS,
+ "() - Return World Data mistype"},
+ {"getHor", ( PyCFunction ) World_getHor, METH_NOARGS,
+ "() - Return World Data hor"},
+ {"setHor", ( PyCFunction ) World_setHor, METH_VARARGS,
+ "() - Return World Data hor"},
+ {"getZen", ( PyCFunction ) World_getZen, METH_NOARGS,
+ "() - Return World Data zen"},
+ {"setZen", ( PyCFunction ) World_setZen, METH_VARARGS,
+ "() - Return World Data zen"},
+ {"getAmb", ( PyCFunction ) World_getAmb, METH_NOARGS,
+ "() - Return World Data amb"},
+ {"setAmb", ( PyCFunction ) World_setAmb, METH_VARARGS,
+ "() - Return World Data amb"},
+ {"getStar", ( PyCFunction ) World_getStar, METH_NOARGS,
+ "() - Return World Data star"},
+ {"setStar", ( PyCFunction ) World_setStar, METH_VARARGS,
+ "() - Return World Data star"},
+ {"getMist", ( PyCFunction ) World_getMist, METH_NOARGS,
+ "() - Return World Data mist"},
+ {"setMist", ( PyCFunction ) World_setMist, METH_VARARGS,
+ "() - Return World Data mist"},
+ {"getScriptLinks", ( PyCFunction ) World_getScriptLinks, METH_VARARGS,
+ "(eventname) - Get a list of this world's scriptlinks (Text names) "
+ "of the given type\n"
+ "(eventname) - string: FrameChanged or Redraw."},
+ {"addScriptLink", ( PyCFunction ) World_addScriptLink, METH_VARARGS,
+ "(text, evt) - Add a new world scriptlink.\n"
+ "(text) - string: an existing Blender Text name;\n"
+ "(evt) string: FrameChanged or Redraw."},
+ {"clearScriptLinks", ( PyCFunction ) World_clearScriptLinks,
+ METH_NOARGS,
+ "() - Delete all scriptlinks from this world :)."},
+ {"makeActive", ( PyCFunction ) World_makeActive, METH_NOARGS,
+ "() - Makes this world the active world for the current scene."},
+ {NULL, NULL, 0, NULL}
+};
+
+
/*****************************************************************************/
/* Python World_Type structure definition: */
/*****************************************************************************/
diff --git a/source/blender/python/api2_2x/World.h b/source/blender/python/api2_2x/World.h
index ed9968480d7..81d38f68545 100644
--- a/source/blender/python/api2_2x/World.h
+++ b/source/blender/python/api2_2x/World.h
@@ -35,154 +35,29 @@
#include <Python.h>
+#include <DNA_world_types.h>
+//#include "bpy_types.h"
-#include "constant.h"
-#include "gen_utils.h"
-#include "bpy_types.h"
-#include "modules.h"
+#define BPy_World_Check(v) ((v)->ob_type==&World_Type)
-/*****************************************************************************/
-/* Python API function prototypes for the World module. */
-/*****************************************************************************/
-static PyObject *M_World_New( PyObject * self, PyObject * args,
- PyObject * keywords );
-static PyObject *M_World_Get( PyObject * self, PyObject * args );
-static PyObject *M_World_GetActive( PyObject * self );
+/* Python BPy_World structure definition */
+typedef struct {
+ PyObject_HEAD /* required py macro */
+ World * world;
+} BPy_World;
-
-/*****************************************************************************/
-/* The following string definitions are used for documentation strings. */
-/* In Python these will be written to the console when doing a */
-/* Blender.World.__doc__ */
-/*****************************************************************************/
-static char M_World_doc[] = "The Blender World module\n\n\
-This module provides access to **World Data** objects in Blender\n\n";
-
-static char M_World_New_doc[] = "() - return a new World object";
-
-static char M_World_Get_doc[] =
- "(name) - return the world with the name 'name', \
-returns None if not found.\n If 'name' is not specified, \
-it returns a list of all worlds in the\ncurrent scene.";
-static char M_World_GetActive_doc[] = "() - returns the current world, or \
-None if the Scene has no world";
-
-
-
-/*****************************************************************************/
-/* Python method structure definition for Blender.World module: */
-/*****************************************************************************/
-struct PyMethodDef M_World_methods[] = {
- {"New", ( PyCFunction ) M_World_New, METH_VARARGS | METH_KEYWORDS,
- M_World_New_doc},
- {"Get", M_World_Get, METH_VARARGS, M_World_Get_doc},
- {"GetActive", ( PyCFunction ) M_World_GetActive, METH_NOARGS,
- M_World_GetActive_doc},
- {"get", M_World_Get, METH_VARARGS, M_World_Get_doc},
- {NULL, NULL, 0, NULL}
-};
-
-
-/*****************************************************************************/
-/* Python BPy_World methods declarations: */
-/*****************************************************************************/
-static PyObject *World_getRange( BPy_World * self );
-static PyObject *World_setRange( BPy_World * self, PyObject * args );
-static PyObject *World_getIpo( BPy_World * self );
-static PyObject *World_setIpo( BPy_World * self, PyObject * args );
-static PyObject *World_clearIpo( BPy_World * self );
-static PyObject *World_getName( BPy_World * self );
-static PyObject *World_setName( BPy_World * self, PyObject * args );
-static PyObject *World_getSkytype( BPy_World * self );
-static PyObject *World_setSkytype( BPy_World * self, PyObject * args );
-static PyObject *World_getMistype( BPy_World * self );
-static PyObject *World_setMistype( BPy_World * self, PyObject * args );
-static PyObject *World_getHor( BPy_World * self );
-static PyObject *World_setHor( BPy_World * self, PyObject * args );
-static PyObject *World_getZen( BPy_World * self );
-static PyObject *World_setZen( BPy_World * self, PyObject * args );
-static PyObject *World_getAmb( BPy_World * self );
-static PyObject *World_setAmb( BPy_World * self, PyObject * args );
-static PyObject *World_getStar( BPy_World * self );
-static PyObject *World_setStar( BPy_World * self, PyObject * args );
-static PyObject *World_getMist( BPy_World * self );
-static PyObject *World_setMist( BPy_World * self, PyObject * args );
-static PyObject *World_getScriptLinks( BPy_World * self, PyObject * args );
-static PyObject *World_addScriptLink( BPy_World * self, PyObject * args );
-static PyObject *World_clearScriptLinks( BPy_World * self );
-static PyObject *World_makeActive( BPy_World * self );
-
-/*****************************************************************************/
-/* Python BPy_World methods table: */
-/*****************************************************************************/
-static PyMethodDef BPy_World_methods[] = {
- {"getRange", ( PyCFunction ) World_getRange, METH_NOARGS,
- "() - Return World Range"},
- {"setRange", ( PyCFunction ) World_setRange, METH_VARARGS,
- "() - Change this World's range"},
- {"getIpo", ( PyCFunction ) World_getIpo, METH_NOARGS,
- "() - Return World Ipo"},
- {"setIpo", ( PyCFunction ) World_setIpo, METH_VARARGS,
- "() - Change this World's ipo"},
- {"clearIpo", ( PyCFunction ) World_clearIpo, METH_VARARGS,
- "() - Unlink Ipo from this World"},
- {"getName", ( PyCFunction ) World_getName, METH_NOARGS,
- "() - Return World Data name"},
- {"setName", ( PyCFunction ) World_setName, METH_VARARGS,
- "() - Return World Data name"},
- {"getSkytype", ( PyCFunction ) World_getSkytype, METH_NOARGS,
- "() - Return World Data skytype"},
- {"setSkytype", ( PyCFunction ) World_setSkytype, METH_VARARGS,
- "() - Return World Data skytype"},
- {"getMistype", ( PyCFunction ) World_getMistype, METH_NOARGS,
- "() - Return World Data mistype"},
- {"setMistype", ( PyCFunction ) World_setMistype, METH_VARARGS,
- "() - Return World Data mistype"},
- {"getHor", ( PyCFunction ) World_getHor, METH_NOARGS,
- "() - Return World Data hor"},
- {"setHor", ( PyCFunction ) World_setHor, METH_VARARGS,
- "() - Return World Data hor"},
- {"getZen", ( PyCFunction ) World_getZen, METH_NOARGS,
- "() - Return World Data zen"},
- {"setZen", ( PyCFunction ) World_setZen, METH_VARARGS,
- "() - Return World Data zen"},
- {"getAmb", ( PyCFunction ) World_getAmb, METH_NOARGS,
- "() - Return World Data amb"},
- {"setAmb", ( PyCFunction ) World_setAmb, METH_VARARGS,
- "() - Return World Data amb"},
- {"getStar", ( PyCFunction ) World_getStar, METH_NOARGS,
- "() - Return World Data star"},
- {"setStar", ( PyCFunction ) World_setStar, METH_VARARGS,
- "() - Return World Data star"},
- {"getMist", ( PyCFunction ) World_getMist, METH_NOARGS,
- "() - Return World Data mist"},
- {"setMist", ( PyCFunction ) World_setMist, METH_VARARGS,
- "() - Return World Data mist"},
- {"getScriptLinks", ( PyCFunction ) World_getScriptLinks, METH_VARARGS,
- "(eventname) - Get a list of this world's scriptlinks (Text names) "
- "of the given type\n"
- "(eventname) - string: FrameChanged or Redraw."},
- {"addScriptLink", ( PyCFunction ) World_addScriptLink, METH_VARARGS,
- "(text, evt) - Add a new world scriptlink.\n"
- "(text) - string: an existing Blender Text name;\n"
- "(evt) string: FrameChanged or Redraw."},
- {"clearScriptLinks", ( PyCFunction ) World_clearScriptLinks,
- METH_NOARGS,
- "() - Delete all scriptlinks from this world :)."},
- {"makeActive", ( PyCFunction ) World_makeActive, METH_NOARGS,
- "() - Makes this world the active world for the current scene."},
- {NULL, NULL, 0, NULL}
-};
+extern PyTypeObject World_Type;
/*****************************************************************************/
/* Python World_Type helper functions needed by Blender (the Init function) */
/* and Object modules. */
/*****************************************************************************/
+
PyObject *World_Init( void );
PyObject *World_CreatePyObject( World * world );
World *World_FromPyObject( PyObject * pyobj );
int World_CheckPyObject( PyObject * pyobj );
-
+World *GetWorldByName( char *name );
#endif /* EXPP_WORLD_H */
diff --git a/source/blender/python/api2_2x/bpy_types.h b/source/blender/python/api2_2x/bpy_types.h
index 2c409d4ab78..d8144de5bb7 100644
--- a/source/blender/python/api2_2x/bpy_types.h
+++ b/source/blender/python/api2_2x/bpy_types.h
@@ -34,186 +34,68 @@
#include <Python.h>
-#include <DNA_camera_types.h>
-#include <DNA_lamp_types.h>
-#include <DNA_ipo_types.h>
-#include <DNA_meta_types.h>
-#include <DNA_effect_types.h>
+
+
+
#include <DNA_curve_types.h>
-#include <DNA_world_types.h>
-#include "rgbTuple.h" /* for BPy_rgbTuple */
+
/*****************************************************************************/
/* Camera Data */
/*****************************************************************************/
-extern PyTypeObject Camera_Type;
-
-#define BPy_Camera_Check(v) \
- ((v)->ob_type == &Camera_Type) /* for type checking */
-
-/* Python BPy_Camera structure definition */
-typedef struct {
- PyObject_HEAD /* required py macro */
- Camera * camera;
-} BPy_Camera;
/*****************************************************************************/
/* Lamp Data */
/*****************************************************************************/
-extern PyTypeObject Lamp_Type;
-
-#define BPy_Lamp_Check(v) \
- ((v)->ob_type == &Lamp_Type) /* for type checking */
-
-/* Python BPy_Lamp structure definition */
-typedef struct {
- PyObject_HEAD /* required py macro */
- Lamp * lamp;
- BPy_rgbTuple *color;
-} BPy_Lamp;
/*****************************************************************************/
/* Ipo Data */
/*****************************************************************************/
-extern PyTypeObject Ipo_Type;
-#define BPy_Ipo_Check(v) ((v)->ob_type == &Ipo_Type) /* for type checking */
-/* Python BPy_Ipo structure definition */
-typedef struct {
- PyObject_HEAD /* required py macro */
- Ipo * ipo;
-} BPy_Ipo;
/*****************************************************************************/
/* Metaball Data */
/*****************************************************************************/
-extern PyTypeObject Metaball_Type;
-
-#define BPy_Metaball_Check(v) ((v)->ob_type==&Metaball_Type)
-/* Python BPy_Metaball structure definition */
-typedef struct {
- PyObject_HEAD /* required py macro */
- MetaBall * metaball;
-} BPy_Metaball;
/*****************************************************************************/
/* Metaelem Data */
/*****************************************************************************/
-extern PyTypeObject Metaelem_Type;
-#define BPy_Metaelem_Check(v) ((v)->ob_type==&Metaelem_Type)
-
-/* Python BPy_Metaelem structure definition */
-typedef struct {
- PyObject_HEAD /* required py macro */
- MetaElem * metaelem;
-} BPy_Metaelem;
/*****************************************************************************/
/* Effect Data */
/*****************************************************************************/
-extern PyTypeObject Effect_Type;
-
-#define BPy_Effect_Check(v) ((v)->ob_type==&Effect_Type)
-
-/* Python BPy_Effect structure definition */
-typedef struct {
- PyObject_HEAD /* required py macro */
- Effect * effect;
-} BPy_Effect;
/*****************************************************************************/
/* Wave Data */
/*****************************************************************************/
-extern PyTypeObject Wave_Type;
-#define BPy_Wave_Check(v) ((v)->ob_type==&Wave_Type)
-
-/* Python BPy_Wave structure definition */
-typedef struct {
- PyObject_HEAD /* required py macro */
- Effect * wave;
-} BPy_Wave;
/*****************************************************************************/
/* Build Data */
/*****************************************************************************/
-extern PyTypeObject Build_Type;
-
-#define BPy_Build_Check(v) ((v)->ob_type==&Build_Type)
-/* Python BPy_Build structure definition */
-typedef struct {
- PyObject_HEAD /* required py macro */
- Effect * build;
-} BPy_Build;
/*****************************************************************************/
/* Particle Data */
/*****************************************************************************/
-extern PyTypeObject Particle_Type;
-
-#define BPy_Particle_Check(v) ((v)->ob_type==&Particle_Type)
-
-/* Python BPy_Particle structure definition */
-typedef struct {
- PyObject_HEAD /* required py macro */
- Effect * particle;
-} BPy_Particle;
/*****************************************************************************/
/* Curve Data */
/*****************************************************************************/
-extern PyTypeObject Curve_Type;
-
-#define BPy_Curve_Check(v) ((v)->ob_type==&Curve_Type)
-
-/* Python BPy_Curve structure definition */
-typedef struct {
- PyObject_HEAD /* required py macro */
- Curve * curve;
- /* pointer for iterator: does not point to owned memory */
- Nurb *iter_pointer;
-} BPy_Curve;
/**********
CurNurb data
***********/
-extern PyTypeObject CurNurb_Type;
-
-#define BPy_CurNurb_Check(v) ((v)->ob_type == &CurNurb_Type) /* for type checking */
-
-/* Python BPy_CurNurb structure definition */
-typedef struct {
- PyObject_HEAD /* required py macro */
- Nurb * nurb; /* pointer to Blender data */
-
- /* iterator stuff */
- /* internal ptrs to point data. do not free */
- BPoint *bp;
- BezTriple *bezt;
- int atEnd; /* iter exhausted flag */
- int nextPoint;
-
-} BPy_CurNurb;
-
/*****************************************************************************/
/* World Data */
/*****************************************************************************/
-extern PyTypeObject World_Type;
-
-#define BPy_World_Check(v) ((v)->ob_type==&World_Type)
-/* Python BPy_World structure definition */
-typedef struct {
- PyObject_HEAD /* required py macro */
- World * world;
-} BPy_World;
#endif /* EXPP_bpy_types_h */
diff --git a/source/blender/python/api2_2x/modules.h b/source/blender/python/api2_2x/modules.h
index 6d021ebb0b3..1c6cba453e6 100644
--- a/source/blender/python/api2_2x/modules.h
+++ b/source/blender/python/api2_2x/modules.h
@@ -25,7 +25,8 @@
*
* This is a new part of Blender.
*
- * Contributor(s): Michel Selten, Willian P. Germano, Nathan Letwory
+ * Contributor(s): Michel Selten, Willian P. Germano, Nathan Letwory,
+ * Stephen Swaney
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
@@ -33,179 +34,61 @@
#ifndef EXPP_modules_h
#define EXPP_modules_h
-#include <Python.h>
-
-#include <DNA_scene_types.h>
-#include <DNA_object_types.h>
-#include <DNA_mesh_types.h>
-#include <DNA_camera_types.h>
-#include <DNA_lamp_types.h>
-#include <DNA_lattice_types.h>
-#include <DNA_curve_types.h>
-#include <DNA_armature_types.h>
-#include <DNA_ipo_types.h>
-#include <DNA_effect_types.h>
-#include <DNA_meta_types.h>
-#include <DNA_image_types.h>
-#include <DNA_texture_types.h>
-#include <DNA_text_types.h>
-#include <DNA_world_types.h>
-#include <DNA_key_types.h>
-#include <DNA_sequence_types.h>
-#include <DNA_action_types.h>
-#include <DNA_constraint_types.h>
+/************************************************************
+Certain bpy module files ( BPY_interface.c, Blender.c, and Object.c )
+need to know about almost every other module. This file is a
+convenient way to include almost all the necessary declarations.
+
+The #includes commented out below currently do not exist.
+Their *_Init() method declarations are hacked in down below.
+************************************************************/
+
+
+#include "Armature.h"
+/* #include "BGL.h" */
+#include "Blender.h"
+#include "Camera.h"
+#include "Curve.h"
+#include "CurNurb.h"
+#include "Draw.h"
+#include "Effect.h"
+#include "Ipo.h"
+#include "Ipocurve.h"
+#include "Lamp.h"
+#include "Lattice.h"
+/* #include "Library.h" */
+#include "Material.h"
+#include "Mathutils.h"
+#include "Metaball.h"
+#include "NLA.h"
+#include "NMesh.h"
+/* #include "Noise.h" */
+#include "Object.h"
+#include "Registry.h"
+#include "Scene.h"
+#include "Sound.h"
+#include "Sys.h"
+#include "Text.h"
+#include "Texture.h"
+#include "Types.h"
+#include "Window.h"
+#include "World.h"
/*****************************************************************************/
/* Global variables */
/*****************************************************************************/
-extern PyObject *g_blenderdict;
-
-
-/*****************************************************************************/
-/* Module Init functions and Data Object helper functions (used by the */
-/* Object module to work with its .data field for the various Data objs */
-/*****************************************************************************/
-void M_Blender_Init( void );
-
-void types_InitAll( void ); /* in Types.c */
-
-/* sys */
-PyObject *sys_Init( void );
-
-/* Registry */
-PyObject *Registry_Init( void );
-
-/* Object itself */
-PyObject *Object_Init( void );
-PyObject *Object_CreatePyObject( struct Object *obj );
-Object *Object_FromPyObject( PyObject * py_obj );
-int Object_CheckPyObject( PyObject * py_obj );
-Object *GetObjectByName( char *name );
-
-/* Scene */
-PyObject *Scene_Init( void );
-PyObject *Scene_CreatePyObject( struct Scene *sce );
-Scene *Scene_FromPyObject( PyObject * pyobj );
-int Scene_CheckPyObject( PyObject * pyobj );
-Scene *GetSceneByName( char *name );
-
-/* Types */
-PyObject *Types_Init( void );
-
-/* NMesh Data */
-PyObject *NMesh_Init( void );
-PyObject *NMesh_CreatePyObject( Mesh * me, Object * ob );
-Mesh *Mesh_FromPyObject( PyObject * pyobj, Object * ob );
-int NMesh_CheckPyObject( PyObject * pyobj );
-
-/* Material */
-PyObject *Material_Init( void );
-PyObject *Material_CreatePyObject( struct Material *mat );
-int Material_CheckPyObject( PyObject * pyobj );
-Material **EXPP_newMaterialList_fromPyList( PyObject * list );
-Material **EXPP_newMaterialList( int len );
-int EXPP_releaseMaterialList( Material ** matlist, int len );
-int EXPP_synchronizeMaterialLists( Object * object );
-void EXPP_incr_mats_us( Material ** matlist, int len );
-PyObject *EXPP_PyList_fromMaterialList( Material ** matlist, int len,
- int all );
-Material *GetMaterialByName( char *name );
-
-/* Texture */
-PyObject *Texture_Init( void );
-
-/* Camera Data */
-PyObject *Camera_Init( void );
-PyObject *Camera_CreatePyObject( struct Camera *cam );
-Camera *Camera_FromPyObject( PyObject * pyobj );
-int Camera_CheckPyObject( PyObject * pyobj );
-Camera *GetCameraByName( char *name );
-/* Lamp Data */
-PyObject *Lamp_Init( void );
-PyObject *Lamp_CreatePyObject( struct Lamp *lamp );
-Lamp *Lamp_FromPyObject( PyObject * pyobj );
-int Lamp_CheckPyObject( PyObject * pyobj );
-Lamp *GetLampByName( char *name );
+/****************************************************************************
+Module Init functions for modules without a .h file.
+BGL is a special case. It still has data declarations in the .h file
+and cannot be #included until it is cleaned up.
+****************************************************************************/
-/* Curve Data */
-PyObject *Curve_Init( void );
-PyObject *Curve_CreatePyObject( struct Curve *curve );
-Curve *Curve_FromPyObject( PyObject * py_obj );
-int Curve_CheckPyObject( PyObject * py_obj );
-
-/* Armature Data */
-PyObject *Armature_Init( void );
-PyObject *Armature_CreatePyObject( bArmature * armature );
-bArmature *Armature_FromPyObject( PyObject * py_obj );
-int Armature_CheckPyObject( PyObject * py_obj );
-
-/* Ipo Data */
-PyObject *BezTriple_CreatePyObject( BezTriple * bzt );
-int BezTriple_CheckPyObject( PyObject * pyobj );
-BezTriple *BezTriple_FromPyObject( PyObject * pyobj );
-
-PyObject *IpoCurve_Init( void );
-PyObject *IpoCurve_CreatePyObject( IpoCurve * ipo );
-int IpoCurve_CheckPyObject( PyObject * pyobj );
-IpoCurve *IpoCurve_FromPyObject( PyObject * pyobj );
-
-PyObject *Ipo_Init( void );
-PyObject *Ipo_CreatePyObject( struct Ipo *ipo );
-Ipo *Ipo_FromPyObject( PyObject * py_obj );
-int Ipo_CheckPyObject( PyObject * py_obj );
-
-/* Metaball Data */
-PyObject *Metaball_Init( void );
-PyObject *Metaball_CreatePyObject( MetaBall * metaball );
-MetaBall *Metaball_FromPyObject( PyObject * py_obj );
-int Metaball_CheckPyObject( PyObject * py_obj );
-
-/* Particle Effects Data */
-PyObject *Effect_Init( void );
-PyObject *Effect_CreatePyObject( struct Effect *effect );
-Effect *Effect_FromPyObject( PyObject * py_obj );
-int Effect_CheckPyObject( PyObject * py_obj );
-
-/* Image */
-PyObject *Image_Init( void );
-PyObject *Image_CreatePyObject( Image * image );
-int Image_CheckPyObject( PyObject * pyobj );
-
-/* Text */
-PyObject *Text_Init( void );
-PyObject *Text_CreatePyObject( Text * txt );
-
-/* World */
-PyObject *World_Init( void );
-PyObject *World_CreatePyObject( struct World *world );
-int World_CheckPyObject( PyObject * py_obj );
-World *World_FromPyObject( PyObject * py_obj );
-World *GetWorldByName( char *name );
-
-/* Lattice */
-PyObject *Lattice_Init( void );
-PyObject *Lattice_CreatePyObject( Lattice * lt );
-Lattice *Lattice_FromPyObject( PyObject * pyobj );
-int Lattice_CheckPyObject( PyObject * pyobj );
+PyObject *BGL_Init( void );
-/* Noise */
+PyObject *Library_Init( void );
PyObject *Noise_Init( void );
-/* CurNurb */
-PyObject *CurNurb_Init( void );
-PyObject *CurNurb_CreatePyObject( Nurb * bzt );
-int CurNurb_CheckPyObject( PyObject * pyobj );
-Nurb *CurNurb_FromPyObject( PyObject * pyobj );
-/* Init functions for other modules */
-PyObject *Window_Init( void );
-PyObject *Draw_Init( void );
-PyObject *BGL_Init( void );
-PyObject *Mathutils_Init( void );
-PyObject *NLA_Init( void );
-PyObject *Library_Init( void );
-PyObject *Sound_Init( void );
-PyObject *Theme_Init( void ); /* Window.Theme */
#endif /* EXPP_modules_h */
diff --git a/source/blender/python/api2_2x/sceneRender.c b/source/blender/python/api2_2x/sceneRender.c
index 8b2f55a3398..7d6ba0cb7f7 100644
--- a/source/blender/python/api2_2x/sceneRender.c
+++ b/source/blender/python/api2_2x/sceneRender.c
@@ -48,7 +48,7 @@
#include "blendef.h"
#include "Scene.h"
#include "gen_utils.h"
-#include "modules.h"
+
#ifdef HAVE_CONFIG_H
#include <config.h>
diff --git a/source/blender/python/api2_2x/windowTheme.h b/source/blender/python/api2_2x/windowTheme.h
index 22ae4a1ff00..83f338da95b 100644
--- a/source/blender/python/api2_2x/windowTheme.h
+++ b/source/blender/python/api2_2x/windowTheme.h
@@ -54,4 +54,6 @@ typedef struct {
} BPy_Theme;
+PyObject *Theme_Init( void );
+
#endif /* EXPP_WINDOWTHEME_H */