Swig is unfortunately not an option anymore. This means implementing all
wrapper functionality by hand. * Removed the swig files (*.i and *_wrap.c) * Created initial datablock functionality. Most of it has been copied from the old implementation. * Created some general functions in gen_utils.[ch] * Blender.Get(), Blender.Set() and Blender.Redraw functions should work in a script now. * Started implementation on an Event function call (BPY_do_pyscript) Michel
This commit is contained in:
parent
cf741a99a9
commit
f08719cfc6
@ -36,6 +36,7 @@
|
||||
|
||||
#include <BKE_text.h>
|
||||
#include <DNA_ID.h>
|
||||
#include <DNA_scriptlink_types.h>
|
||||
#include <DNA_space_types.h>
|
||||
#include <DNA_text_types.h>
|
||||
|
||||
@ -43,31 +44,31 @@
|
||||
|
||||
#include "api2_2x/interface.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
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/* Function prototypes */
|
||||
/*****************************************************************************/
|
||||
PyObject * RunPython(Text *text, PyObject *globaldict);
|
||||
char * GetName(Text *text);
|
||||
|
||||
/*
|
||||
* Description: This function will initialise Python and all the implemented
|
||||
* api variations.
|
||||
* Notes: Currently only the api for 2.2x will be initialised.
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/* 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)
|
||||
{
|
||||
printf ("In BPY_start_python\n");
|
||||
@ -81,41 +82,41 @@ void BPY_start_python(void)
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Description:
|
||||
* Notes: Not implemented yet
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/* Description: */
|
||||
/* Notes: Not implemented yet */
|
||||
/*****************************************************************************/
|
||||
void BPY_end_python(void)
|
||||
{
|
||||
printf ("In BPY_end_python\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Description: This function will return the linenumber on which an error
|
||||
* has occurred in the Python script.
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/* Description: This function will return the linenumber on which an error */
|
||||
/* has occurred in the Python script. */
|
||||
/*****************************************************************************/
|
||||
int BPY_Err_getLinenumber(void)
|
||||
{
|
||||
printf ("In BPY_Err_getLinenumber\n");
|
||||
return g_script_error.lineno;
|
||||
}
|
||||
|
||||
/*
|
||||
* Description: This function will return the filename of the python script.
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/* Description: This function will return the filename of the python script. */
|
||||
/*****************************************************************************/
|
||||
const char *BPY_Err_getFilename(void)
|
||||
{
|
||||
printf ("In BPY_Err_getFilename\n");
|
||||
return g_script_error.filename;
|
||||
}
|
||||
|
||||
/*
|
||||
* Description: This function executes the script passed by st.
|
||||
* Notes: Currently, the script is compiled each time it is executed,
|
||||
* This should be optimized to store the compiled bytecode as has
|
||||
* been done by the previous implementation.
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/* Description: This function executes the script passed by st. */
|
||||
/* Notes: Currently, the script is compiled each time it is executed, */
|
||||
/* This should be optimized to store the compiled bytecode as */
|
||||
/* has been done by the previous implementation. */
|
||||
/*****************************************************************************/
|
||||
struct _object *BPY_txt_do_python(struct SpaceText* st)
|
||||
{
|
||||
PyObject * dict;
|
||||
@ -134,30 +135,30 @@ struct _object *BPY_txt_do_python(struct SpaceText* st)
|
||||
return dict;
|
||||
}
|
||||
|
||||
/*
|
||||
* Description:
|
||||
* Notes: Not implemented yet
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/* Description: */
|
||||
/* Notes: Not implemented yet */
|
||||
/*****************************************************************************/
|
||||
void BPY_free_compiled_text(struct Text* text)
|
||||
{
|
||||
printf ("In BPY_free_compiled_text\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Description:
|
||||
* Notes: Not implemented yet
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/* Description: */
|
||||
/* Notes: Not implemented yet */
|
||||
/*****************************************************************************/
|
||||
void BPY_clear_bad_scriptlinks(struct Text *byebye)
|
||||
{
|
||||
printf ("In BPY_clear_bad_scriptlinks\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Description:
|
||||
* Notes: Not implemented yet
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/* Description: */
|
||||
/* Notes: Not implemented yet */
|
||||
/*****************************************************************************/
|
||||
void BPY_do_all_scripts(short event)
|
||||
{
|
||||
printf ("In BPY_do_all_scripts(event=%d)\n",event);
|
||||
@ -165,69 +166,124 @@ void BPY_do_all_scripts(short event)
|
||||
}
|
||||
|
||||
/*
|
||||
* Description:
|
||||
* Notes: Not implemented yet
|
||||
* 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
|
||||
* Notes: The call to BLO_findstruct_offset needs to be removed.
|
||||
* Somehow the object triggered by the event has to be retrieved.
|
||||
*/
|
||||
void BPY_do_pyscript(struct ID *id, short event)
|
||||
{
|
||||
printf ("In BPY_do_pyscript(id=?, event=%d)\n",event);
|
||||
int obj_id;
|
||||
char structname[10];
|
||||
int offset;
|
||||
ScriptLink * scriptlink;
|
||||
|
||||
printf ("In BPY_do_pyscript(id=%s, event=%d)\n",id->name, event);
|
||||
|
||||
/* First get the object type that the script is linked to. */
|
||||
obj_id = MAKE_ID2(id->name[0], id->name[1]);
|
||||
switch (obj_id)
|
||||
{
|
||||
case ID_OB:
|
||||
sprintf (structname, "Object");
|
||||
break;
|
||||
case ID_LA:
|
||||
sprintf (structname, "Lamp");
|
||||
break;
|
||||
case ID_CA:
|
||||
sprintf (structname, "Camera");
|
||||
break;
|
||||
case ID_MA:
|
||||
sprintf (structname, "Material");
|
||||
break;
|
||||
case ID_WO:
|
||||
sprintf (structname, "World");
|
||||
break;
|
||||
case ID_SCE:
|
||||
sprintf (structname, "Scene");
|
||||
break;
|
||||
default:
|
||||
/* TODO: Do we need to generate a nice error message here? */
|
||||
return;
|
||||
}
|
||||
|
||||
/* TODO: Replace the following piece of code. See the Notes for info. */
|
||||
/* Check if a script is provided */
|
||||
offset = BLO_findstruct_offset (structname, "scriptlink");
|
||||
if (offset < 0)
|
||||
{
|
||||
printf ("Internal error, unable to find script link\n");
|
||||
return;
|
||||
}
|
||||
scriptlink = (ScriptLink*) (((char*)id) + offset);
|
||||
|
||||
if (!scriptlink->totscript)
|
||||
{
|
||||
/* no script provided */
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get all links from blender and set them in the Python environment */
|
||||
setScriptLinks (id, event);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Description:
|
||||
* Notes: Not implemented yet
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/* Description: */
|
||||
/* Notes: Not implemented yet */
|
||||
/*****************************************************************************/
|
||||
void BPY_free_scriptlink(struct ScriptLink *slink)
|
||||
{
|
||||
printf ("In BPY_free_scriptlink\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Description:
|
||||
* Notes: Not implemented yet
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/* Description: */
|
||||
/* Notes: Not implemented yet */
|
||||
/*****************************************************************************/
|
||||
void BPY_copy_scriptlink(struct ScriptLink *scriptlink)
|
||||
{
|
||||
printf ("In BPY_copy_scriptlink\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Description:
|
||||
* Notes: Not implemented yet
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/* Description: */
|
||||
/* Notes: Not implemented yet */
|
||||
/*****************************************************************************/
|
||||
int BPY_call_importloader(char *name)
|
||||
{
|
||||
printf ("In BPY_call_importloader(name=%s)\n",name);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Description:
|
||||
* Notes: Not implemented yet
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/* Description: */
|
||||
/* Notes: Not implemented yet */
|
||||
/*****************************************************************************/
|
||||
int BPY_spacetext_is_pywin(struct SpaceText *st)
|
||||
{
|
||||
/* No printf is done here because it is called with every mouse move */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Description:
|
||||
* Notes: Not implemented yet
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/* Description: */
|
||||
/* Notes: Not implemented yet */
|
||||
/*****************************************************************************/
|
||||
void BPY_spacetext_do_pywin_draw(struct SpaceText *st)
|
||||
{
|
||||
printf ("In BPY_spacetext_do_pywin_draw\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Description:
|
||||
* Notes: Not implemented yet
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/* Description: */
|
||||
/* Notes: Not implemented yet */
|
||||
/*****************************************************************************/
|
||||
void BPY_spacetext_do_pywin_event(struct SpaceText *st,
|
||||
unsigned short event,
|
||||
short val)
|
||||
@ -237,15 +293,15 @@ void BPY_spacetext_do_pywin_event(struct SpaceText *st,
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/* 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)
|
||||
{
|
||||
PyObject * ret;
|
||||
@ -259,10 +315,10 @@ PyObject * RunPython(Text *text, PyObject *globaldict)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Description: This function returns the value of the name field of the
|
||||
* given Text struct.
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/* Description: This function returns the value of the name field of the */
|
||||
/* given Text struct. */
|
||||
/*****************************************************************************/
|
||||
char * GetName(Text *text)
|
||||
{
|
||||
return (text->id.name+2);
|
||||
|
@ -29,13 +29,212 @@
|
||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include <Python.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void BlenderCopy (void)
|
||||
#include <BKE_global.h>
|
||||
#include <DNA_ID.h>
|
||||
#include <DNA_scene_types.h>
|
||||
/* #include <DNA_screen_types.h> */
|
||||
#include <DNA_userdef_types.h>
|
||||
|
||||
#include "gen_utils.h"
|
||||
#include "modules.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python API function prototypes for the Blender module. */
|
||||
/*****************************************************************************/
|
||||
PyObject *Blender_Set (PyObject *self, PyObject *args);
|
||||
PyObject *Blender_Get (PyObject *self, PyObject *args);
|
||||
PyObject *Blender_Redraw(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.__doc__ */
|
||||
/*****************************************************************************/
|
||||
char Blender_Set_doc[] =
|
||||
"(request, data) - Update settings in Blender\n\
|
||||
\n\
|
||||
(request) A string indentifying the setting to change\n\
|
||||
'curframe' - Sets the current frame using the number in data";
|
||||
|
||||
char Blender_Get_doc[] =
|
||||
"(request) - Retrieve settings from Blender\n\
|
||||
\n\
|
||||
(request) A string indentifying the data to be returned\n\
|
||||
'curframe' - Returns the current animation frame\n\
|
||||
'curtime' - Returns the current animation time\n\
|
||||
'staframe' - Returns the start frame of the animation\n\
|
||||
'endframe' - Returns the end frame of the animation\n\
|
||||
'filename' - Returns the name of the last file read or written\n\
|
||||
'version' - Returns the Blender version number";
|
||||
|
||||
char Blender_Redraw_doc[] = "() - Redraw all 3D windows";
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python method structure definition. */
|
||||
/*****************************************************************************/
|
||||
struct PyMethodDef Blender_methods[] = {
|
||||
{"Set", &Blender_Set, METH_VARARGS, Blender_Set_doc},
|
||||
{"Get", &Blender_Get, METH_VARARGS, Blender_Get_doc},
|
||||
{"Redraw", &Blender_Redraw, METH_VARARGS, Blender_Redraw_doc},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Blender_Set */
|
||||
/* Python equivalent: Blender.Set */
|
||||
/*****************************************************************************/
|
||||
PyObject *Blender_Set (PyObject *self, PyObject *args)
|
||||
{
|
||||
printf ("self.copy\n");
|
||||
char * name;
|
||||
PyObject * arg;
|
||||
int framenum;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "sO", &name, &arg))
|
||||
{
|
||||
/* TODO: Do we need to generate a nice error message here? */
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (StringEqual (name, "curframe"))
|
||||
{
|
||||
if (!PyArg_Parse(arg, "i", &framenum))
|
||||
{
|
||||
/* TODO: Do we need to generate a nice error message here? */
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
G.scene->r.cfra = framenum;
|
||||
|
||||
update_for_newframe();
|
||||
}
|
||||
else
|
||||
{
|
||||
return (PythonReturnErrorObject (PyExc_AttributeError,
|
||||
"bad request identifier"));
|
||||
}
|
||||
return ( PythonIncRef (Py_None) );
|
||||
}
|
||||
/* The following line has to be copied to Blender_wrap.c each time swig is
|
||||
called to generate new wrapper functions.
|
||||
PyDict_SetItemString (d, "Object", initObject());
|
||||
*/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Blender_Get */
|
||||
/* Python equivalent: Blender.Get */
|
||||
/*****************************************************************************/
|
||||
PyObject *Blender_Get (PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject * object;
|
||||
PyObject * dict;
|
||||
char * str;
|
||||
|
||||
printf ("In Blender_Get()\n");
|
||||
|
||||
if (!PyArg_ParseTuple (args, "O", &object))
|
||||
{
|
||||
/* TODO: Do we need to generate a nice error message here? */
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (PyString_Check (object))
|
||||
{
|
||||
str = PyString_AsString (object);
|
||||
|
||||
if (StringEqual (str, "curframe"))
|
||||
{
|
||||
return ( PyInt_FromLong (G.scene->r.cfra) );
|
||||
}
|
||||
if (StringEqual (str, "curtime"))
|
||||
{
|
||||
return ( PyFloat_FromDouble (frame_to_float (G.scene->r.cfra) ) );
|
||||
}
|
||||
if (StringEqual (str, "staframe"))
|
||||
{
|
||||
return ( PyInt_FromLong (G.scene->r.sfra) );
|
||||
}
|
||||
if (StringEqual (str, "endframe"))
|
||||
{
|
||||
return ( PyInt_FromLong (G.scene->r.efra) );
|
||||
}
|
||||
if (StringEqual (str, "filename"))
|
||||
{
|
||||
return ( PyString_FromString (G.sce) );
|
||||
}
|
||||
/* According to the old file (opy_blender.c), the following if
|
||||
statement is a quick hack and needs some clean up. */
|
||||
if (StringEqual (str, "vrmloptions"))
|
||||
{
|
||||
dict = PyDict_New ();
|
||||
|
||||
PyDict_SetItemString (dict, "twoside",
|
||||
PyInt_FromLong (U.vrmlflag & USERDEF_VRML_TWOSIDED));
|
||||
|
||||
PyDict_SetItemString (dict, "layers",
|
||||
PyInt_FromLong (U.vrmlflag & USERDEF_VRML_LAYERS));
|
||||
|
||||
PyDict_SetItemString (dict, "autoscale",
|
||||
PyInt_FromLong (U.vrmlflag & USERDEF_VRML_AUTOSCALE));
|
||||
|
||||
return (dict);
|
||||
} /* End 'quick hack' part. */
|
||||
if (StringEqual (str, "version"))
|
||||
{
|
||||
return ( PyInt_FromLong (G.version) );
|
||||
}
|
||||
/* TODO: Do we want to display a usefull message here that the
|
||||
requested data is unknown?
|
||||
else
|
||||
{
|
||||
return (PythonReturnErrorObject (..., "message") );
|
||||
}
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
return (PythonReturnErrorObject (PyExc_AttributeError,
|
||||
"expected string argument"));
|
||||
}
|
||||
|
||||
return (PythonReturnErrorObject (PyExc_AttributeError,
|
||||
"bad request identifier"));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Blender_Redraw */
|
||||
/* Python equivalent: Blender.Redraw */
|
||||
/*****************************************************************************/
|
||||
PyObject *Blender_Redraw(PyObject *self, PyObject *args)
|
||||
{
|
||||
/*
|
||||
int wintype = SPACE_VIEW3D;
|
||||
|
||||
printf ("In Blender_Redraw()\n");
|
||||
|
||||
if (!PyArg_ParseTuple (args, "|i", &wintype))
|
||||
{
|
||||
TODO: Do we need to generate a nice error message here?
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
return Windowmodule_Redraw(self, Py_BuildValue("(i)", wintype));
|
||||
*/
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: initBlender */
|
||||
/*****************************************************************************/
|
||||
void initBlender (void)
|
||||
{
|
||||
PyObject * module;
|
||||
PyObject * dict;
|
||||
|
||||
printf ("In initBlender()\n");
|
||||
g_blenderdict = NULL;
|
||||
|
||||
/* TODO: create a docstring for the Blender module */
|
||||
module = Py_InitModule3("Blender", Blender_methods, NULL);
|
||||
|
||||
dict = PyModule_GetDict (module);
|
||||
PyDict_SetItemString (dict, "Object", initObject());
|
||||
}
|
||||
|
||||
|
@ -1,680 +0,0 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 1.3.10u-20030216-1639
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
* changes to this file unless you know what you are doing--modify the SWIG
|
||||
* interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#define SWIGPYTHON
|
||||
/***********************************************************************
|
||||
* common.swg
|
||||
*
|
||||
* This file contains generic SWIG runtime support for pointer
|
||||
* type checking as well as a few commonly used macros to control
|
||||
* external linkage.
|
||||
*
|
||||
* Author : David Beazley (beazley@cs.uchicago.edu)
|
||||
*
|
||||
* Copyright (c) 1999-2000, The University of Chicago
|
||||
*
|
||||
* This file may be freely redistributed without license or fee provided
|
||||
* this copyright message remains intact.
|
||||
************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(_WIN32) || defined(__WIN32__)
|
||||
# if defined(_MSC_VER)
|
||||
# if defined(STATIC_LINKED)
|
||||
# define SWIGEXPORT(a) a
|
||||
# else
|
||||
# define SWIGEXPORT(a) __declspec(dllexport) a
|
||||
# endif
|
||||
# else
|
||||
# if defined(__BORLANDC__)
|
||||
# define SWIGEXPORT(a) a _export
|
||||
# else
|
||||
# define SWIGEXPORT(a) a
|
||||
# endif
|
||||
#endif
|
||||
#else
|
||||
# define SWIGEXPORT(a) a
|
||||
#endif
|
||||
|
||||
#ifdef SWIG_GLOBAL
|
||||
#define SWIGRUNTIME(a) SWIGEXPORT(a)
|
||||
#else
|
||||
#define SWIGRUNTIME(a) static a
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void *(*swig_converter_func)(void *);
|
||||
|
||||
typedef struct swig_type_info {
|
||||
const char *name;
|
||||
swig_converter_func converter;
|
||||
const char *str;
|
||||
struct swig_type_info *next;
|
||||
struct swig_type_info *prev;
|
||||
void *clientdata;
|
||||
} swig_type_info;
|
||||
|
||||
#ifdef SWIG_NOINCLUDE
|
||||
SWIGEXPORT(swig_type_info *) SWIG_TypeRegister(swig_type_info *);
|
||||
SWIGEXPORT(swig_type_info *) SWIG_TypeCheck(char *c, swig_type_info *);
|
||||
SWIGEXPORT(void *) SWIG_TypeCast(swig_type_info *, void *);
|
||||
SWIGEXPORT(swig_type_info *) SWIG_TypeQuery(const char *);
|
||||
SWIGEXPORT(void) SWIG_TypeClientData(swig_type_info *, void *);
|
||||
#else
|
||||
|
||||
static swig_type_info *swig_type_list = 0;
|
||||
|
||||
/* Register a type mapping with the type-checking */
|
||||
SWIGRUNTIME(swig_type_info *)
|
||||
SWIG_TypeRegister(swig_type_info *ti)
|
||||
{
|
||||
swig_type_info *tc, *head, *ret, *next;
|
||||
/* Check to see if this type has already been registered */
|
||||
tc = swig_type_list;
|
||||
while (tc) {
|
||||
if (strcmp(tc->name, ti->name) == 0) {
|
||||
/* Already exists in the table. Just add additional types to the list */
|
||||
head = tc;
|
||||
next = tc->next;
|
||||
goto l1;
|
||||
}
|
||||
tc = tc->prev;
|
||||
}
|
||||
head = ti;
|
||||
next = 0;
|
||||
|
||||
/* Place in list */
|
||||
ti->prev = swig_type_list;
|
||||
swig_type_list = ti;
|
||||
|
||||
/* Build linked lists */
|
||||
l1:
|
||||
ret = head;
|
||||
tc = ti + 1;
|
||||
/* Patch up the rest of the links */
|
||||
while (tc->name) {
|
||||
head->next = tc;
|
||||
tc->prev = head;
|
||||
head = tc;
|
||||
tc++;
|
||||
}
|
||||
head->next = next;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Check the typename */
|
||||
SWIGRUNTIME(swig_type_info *)
|
||||
SWIG_TypeCheck(char *c, swig_type_info *ty)
|
||||
{
|
||||
swig_type_info *s;
|
||||
if (!ty) return 0; /* Void pointer */
|
||||
s = ty->next; /* First element always just a name */
|
||||
while (s) {
|
||||
if (strcmp(s->name,c) == 0) {
|
||||
if (s == ty->next) return s;
|
||||
/* Move s to the top of the linked list */
|
||||
s->prev->next = s->next;
|
||||
if (s->next) {
|
||||
s->next->prev = s->prev;
|
||||
}
|
||||
/* Insert s as second element in the list */
|
||||
s->next = ty->next;
|
||||
if (ty->next) ty->next->prev = s;
|
||||
ty->next = s;
|
||||
return s;
|
||||
}
|
||||
s = s->next;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Cast a pointer (needed for C++ inheritance */
|
||||
SWIGRUNTIME(void *)
|
||||
SWIG_TypeCast(swig_type_info *ty, void *ptr)
|
||||
{
|
||||
if ((!ty) || (!ty->converter)) return ptr;
|
||||
return (*ty->converter)(ptr);
|
||||
}
|
||||
|
||||
/* Search for a swig_type_info structure */
|
||||
SWIGRUNTIME(swig_type_info *)
|
||||
SWIG_TypeQuery(const char *name) {
|
||||
swig_type_info *ty = swig_type_list;
|
||||
while (ty) {
|
||||
if (ty->str && (strcmp(name,ty->str) == 0)) return ty;
|
||||
if (ty->name && (strcmp(name,ty->name) == 0)) return ty;
|
||||
ty = ty->prev;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Set the clientdata field for a type */
|
||||
SWIGRUNTIME(void)
|
||||
SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
|
||||
swig_type_info *tc, *equiv;
|
||||
if (ti->clientdata) return;
|
||||
ti->clientdata = clientdata;
|
||||
equiv = ti->next;
|
||||
while (equiv) {
|
||||
if (!equiv->converter) {
|
||||
tc = swig_type_list;
|
||||
while (tc) {
|
||||
if ((strcmp(tc->name, equiv->name) == 0))
|
||||
SWIG_TypeClientData(tc,clientdata);
|
||||
tc = tc->prev;
|
||||
}
|
||||
}
|
||||
equiv = equiv->next;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* python.swg
|
||||
*
|
||||
* This file contains the runtime support for Python modules
|
||||
* and includes code for managing global variables and pointer
|
||||
* type checking.
|
||||
*
|
||||
* Author : David Beazley (beazley@cs.uchicago.edu)
|
||||
************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "Python.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SWIG_PY_INT 1
|
||||
#define SWIG_PY_FLOAT 2
|
||||
#define SWIG_PY_STRING 3
|
||||
#define SWIG_PY_POINTER 4
|
||||
#define SWIG_PY_BINARY 5
|
||||
|
||||
/* Constant information structure */
|
||||
typedef struct swig_const_info {
|
||||
int type;
|
||||
char *name;
|
||||
long lvalue;
|
||||
double dvalue;
|
||||
void *pvalue;
|
||||
swig_type_info **ptype;
|
||||
} swig_const_info;
|
||||
|
||||
#ifdef SWIG_NOINCLUDE
|
||||
|
||||
SWIGEXPORT(PyObject *) SWIG_newvarlink();
|
||||
SWIGEXPORT(void) SWIG_addvarlink(PyObject *, char *, PyObject *(*)(void), int (*)(PyObject *));
|
||||
SWIGEXPORT(int) SWIG_ConvertPtr(PyObject *, void **, swig_type_info *, int);
|
||||
SWIGEXPORT(int) SWIG_ConvertPacked(PyObject *, void *, int sz, swig_type_info *, int);
|
||||
SWIGEXPORT(char *) SWIG_PackData(char *c, void *, int);
|
||||
SWIGEXPORT(char *) SWIG_UnpackData(char *c, void *, int);
|
||||
SWIGEXPORT(PyObject *) SWIG_NewPointerObj(void *, swig_type_info *,int own);
|
||||
SWIGEXPORT(PyObject *) SWIG_NewPackedObj(void *, int sz, swig_type_info *);
|
||||
SWIGEXPORT(void) SWIG_InstallConstants(PyObject *d, swig_const_info constants[]);
|
||||
SWIGEXPORT(PyObject *) SWIG_MakeShadow(PyObject *robj, swig_type_info *type, int own);
|
||||
#else
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* global variable support code.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
typedef struct swig_globalvar {
|
||||
char *name; /* Name of global variable */
|
||||
PyObject *(*get_attr)(void); /* Return the current value */
|
||||
int (*set_attr)(PyObject *); /* Set the value */
|
||||
struct swig_globalvar *next;
|
||||
} swig_globalvar;
|
||||
|
||||
typedef struct swig_varlinkobject {
|
||||
PyObject_HEAD
|
||||
swig_globalvar *vars;
|
||||
} swig_varlinkobject;
|
||||
|
||||
static PyObject *
|
||||
swig_varlink_repr(swig_varlinkobject *v) {
|
||||
v = v;
|
||||
return PyString_FromString("<Global variables>");
|
||||
}
|
||||
|
||||
static int
|
||||
swig_varlink_print(swig_varlinkobject *v, FILE *fp, int flags) {
|
||||
swig_globalvar *var;
|
||||
flags = flags;
|
||||
fprintf(fp,"Global variables { ");
|
||||
for (var = v->vars; var; var=var->next) {
|
||||
fprintf(fp,"%s", var->name);
|
||||
if (var->next) fprintf(fp,", ");
|
||||
}
|
||||
fprintf(fp," }\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
swig_varlink_getattr(swig_varlinkobject *v, char *n) {
|
||||
swig_globalvar *var = v->vars;
|
||||
while (var) {
|
||||
if (strcmp(var->name,n) == 0) {
|
||||
return (*var->get_attr)();
|
||||
}
|
||||
var = var->next;
|
||||
}
|
||||
PyErr_SetString(PyExc_NameError,"Unknown C global variable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
|
||||
swig_globalvar *var = v->vars;
|
||||
while (var) {
|
||||
if (strcmp(var->name,n) == 0) {
|
||||
return (*var->set_attr)(p);
|
||||
}
|
||||
var = var->next;
|
||||
}
|
||||
PyErr_SetString(PyExc_NameError,"Unknown C global variable");
|
||||
return 1;
|
||||
}
|
||||
|
||||
statichere PyTypeObject varlinktype = {
|
||||
PyObject_HEAD_INIT(0)
|
||||
0,
|
||||
(char *)"swigvarlink", /* Type name */
|
||||
sizeof(swig_varlinkobject), /* Basic size */
|
||||
0, /* Itemsize */
|
||||
0, /* Deallocator */
|
||||
(printfunc) swig_varlink_print, /* Print */
|
||||
(getattrfunc) swig_varlink_getattr, /* get attr */
|
||||
(setattrfunc) swig_varlink_setattr, /* Set attr */
|
||||
0, /* tp_compare */
|
||||
(reprfunc) swig_varlink_repr, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_mapping*/
|
||||
0, /* tp_hash */
|
||||
};
|
||||
|
||||
/* Create a variable linking object for use later */
|
||||
SWIGRUNTIME(PyObject *)
|
||||
SWIG_newvarlink(void) {
|
||||
swig_varlinkobject *result = 0;
|
||||
result = PyMem_NEW(swig_varlinkobject,1);
|
||||
varlinktype.ob_type = &PyType_Type; /* Patch varlinktype into a PyType */
|
||||
result->ob_type = &varlinktype;
|
||||
result->vars = 0;
|
||||
result->ob_refcnt = 0;
|
||||
Py_XINCREF((PyObject *) result);
|
||||
return ((PyObject*) result);
|
||||
}
|
||||
|
||||
SWIGRUNTIME(void)
|
||||
SWIG_addvarlink(PyObject *p, char *name,
|
||||
PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {
|
||||
swig_varlinkobject *v;
|
||||
swig_globalvar *gv;
|
||||
v= (swig_varlinkobject *) p;
|
||||
gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
|
||||
gv->name = (char *) malloc(strlen(name)+1);
|
||||
strcpy(gv->name,name);
|
||||
gv->get_attr = get_attr;
|
||||
gv->set_attr = set_attr;
|
||||
gv->next = v->vars;
|
||||
v->vars = gv;
|
||||
}
|
||||
|
||||
/* Pack binary data into a string */
|
||||
SWIGRUNTIME(char *)
|
||||
SWIG_PackData(char *c, void *ptr, int sz) {
|
||||
static char hex[17] = "0123456789abcdef";
|
||||
int i;
|
||||
unsigned char *u = (unsigned char *) ptr;
|
||||
register unsigned char uu;
|
||||
for (i = 0; i < sz; i++,u++) {
|
||||
uu = *u;
|
||||
*(c++) = hex[(uu & 0xf0) >> 4];
|
||||
*(c++) = hex[uu & 0xf];
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
/* Unpack binary data from a string */
|
||||
SWIGRUNTIME(char *)
|
||||
SWIG_UnpackData(char *c, void *ptr, int sz) {
|
||||
register unsigned char uu;
|
||||
register int d;
|
||||
unsigned char *u = (unsigned char *) ptr;
|
||||
int i;
|
||||
for (i = 0; i < sz; i++, u++) {
|
||||
d = *(c++);
|
||||
if ((d >= '0') && (d <= '9'))
|
||||
uu = ((d - '0') << 4);
|
||||
else if ((d >= 'a') && (d <= 'f'))
|
||||
uu = ((d - ('a'-10)) << 4);
|
||||
d = *(c++);
|
||||
if ((d >= '0') && (d <= '9'))
|
||||
uu |= (d - '0');
|
||||
else if ((d >= 'a') && (d <= 'f'))
|
||||
uu |= (d - ('a'-10));
|
||||
*u = uu;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
/* Convert a pointer value */
|
||||
SWIGRUNTIME(int)
|
||||
SWIG_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags) {
|
||||
swig_type_info *tc;
|
||||
char *c;
|
||||
static PyObject *SWIG_this = 0;
|
||||
int newref = 0;
|
||||
|
||||
if (!obj) return 0;
|
||||
if (obj == Py_None) {
|
||||
*ptr = 0;
|
||||
return 0;
|
||||
}
|
||||
#ifdef SWIG_COBJECT_TYPES
|
||||
if (!(PyCObject_Check(obj))) {
|
||||
if (!SWIG_this)
|
||||
SWIG_this = PyString_InternFromString("this");
|
||||
obj = PyObject_GetAttr(obj,SWIG_this);
|
||||
newref = 1;
|
||||
if (!obj) goto type_error;
|
||||
if (!PyCObject_Check(obj)) {
|
||||
Py_DECREF(obj);
|
||||
goto type_error;
|
||||
}
|
||||
}
|
||||
*ptr = PyCObject_AsVoidPtr(obj);
|
||||
c = (char *) PyCObject_GetDesc(obj);
|
||||
if (newref) Py_DECREF(obj);
|
||||
goto cobject;
|
||||
#else
|
||||
if (!(PyString_Check(obj))) {
|
||||
if (!SWIG_this)
|
||||
SWIG_this = PyString_InternFromString("this");
|
||||
obj = PyObject_GetAttr(obj,SWIG_this);
|
||||
newref = 1;
|
||||
if (!obj) goto type_error;
|
||||
if (!PyString_Check(obj)) {
|
||||
Py_DECREF(obj);
|
||||
goto type_error;
|
||||
}
|
||||
}
|
||||
c = PyString_AsString(obj);
|
||||
/* Pointer values must start with leading underscore */
|
||||
if (*c != '_') {
|
||||
*ptr = (void *) 0;
|
||||
if (strcmp(c,"NULL") == 0) {
|
||||
if (newref) Py_DECREF(obj);
|
||||
return 0;
|
||||
} else {
|
||||
if (newref) Py_DECREF(obj);
|
||||
goto type_error;
|
||||
}
|
||||
}
|
||||
c++;
|
||||
c = SWIG_UnpackData(c,ptr,sizeof(void *));
|
||||
if (newref) Py_DECREF(obj);
|
||||
#endif
|
||||
|
||||
#ifdef SWIG_COBJECT_TYPES
|
||||
cobject:
|
||||
#endif
|
||||
|
||||
if (ty) {
|
||||
tc = SWIG_TypeCheck(c,ty);
|
||||
if (!tc) goto type_error;
|
||||
*ptr = SWIG_TypeCast(tc,(void*) *ptr);
|
||||
}
|
||||
return 0;
|
||||
|
||||
type_error:
|
||||
if (flags) {
|
||||
if (ty) {
|
||||
char *temp = (char *) malloc(64+strlen(ty->name));
|
||||
sprintf(temp,"Type error. Expected %s", ty->name);
|
||||
PyErr_SetString(PyExc_TypeError, temp);
|
||||
free((char *) temp);
|
||||
} else {
|
||||
PyErr_SetString(PyExc_TypeError,"Expected a pointer");
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Convert a packed value value */
|
||||
SWIGRUNTIME(int)
|
||||
SWIG_ConvertPacked(PyObject *obj, void *ptr, int sz, swig_type_info *ty, int flags) {
|
||||
swig_type_info *tc;
|
||||
char *c;
|
||||
|
||||
if ((!obj) || (!PyString_Check(obj))) goto type_error;
|
||||
c = PyString_AsString(obj);
|
||||
/* Pointer values must start with leading underscore */
|
||||
if (*c != '_') goto type_error;
|
||||
c++;
|
||||
c = SWIG_UnpackData(c,ptr,sz);
|
||||
if (ty) {
|
||||
tc = SWIG_TypeCheck(c,ty);
|
||||
if (!tc) goto type_error;
|
||||
}
|
||||
return 0;
|
||||
|
||||
type_error:
|
||||
|
||||
if (flags) {
|
||||
if (ty) {
|
||||
char *temp = (char *) malloc(64+strlen(ty->name));
|
||||
sprintf(temp,"Type error. Expected %s", ty->name);
|
||||
PyErr_SetString(PyExc_TypeError, temp);
|
||||
free((char *) temp);
|
||||
} else {
|
||||
PyErr_SetString(PyExc_TypeError,"Expected a pointer");
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Create a new pointer object */
|
||||
SWIGRUNTIME(PyObject *)
|
||||
SWIG_NewPointerObj(void *ptr, swig_type_info *type, int own) {
|
||||
PyObject *robj;
|
||||
if (!ptr) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
#ifdef SWIG_COBJECT_TYPES
|
||||
robj = PyCObject_FromVoidPtrAndDesc((void *) ptr, (char *) type->name, NULL);
|
||||
#else
|
||||
{
|
||||
char result[512];
|
||||
char *r = result;
|
||||
*(r++) = '_';
|
||||
r = SWIG_PackData(r,&ptr,sizeof(void *));
|
||||
strcpy(r,type->name);
|
||||
robj = PyString_FromString(result);
|
||||
}
|
||||
#endif
|
||||
if (!robj || (robj == Py_None)) return robj;
|
||||
if (type->clientdata) {
|
||||
PyObject *inst;
|
||||
PyObject *args = Py_BuildValue((char*)"(O)", robj);
|
||||
Py_DECREF(robj);
|
||||
inst = PyObject_CallObject((PyObject *) type->clientdata, args);
|
||||
Py_DECREF(args);
|
||||
if (own) {
|
||||
PyObject *n = PyInt_FromLong(1);
|
||||
PyObject_SetAttrString(inst,(char*)"thisown",n);
|
||||
Py_DECREF(n);
|
||||
}
|
||||
robj = inst;
|
||||
}
|
||||
return robj;
|
||||
}
|
||||
|
||||
SWIGRUNTIME(PyObject *)
|
||||
SWIG_MakeShadow(PyObject *robj, swig_type_info *type, int own) {
|
||||
if (!robj || (robj == Py_None)) return robj;
|
||||
if (type->clientdata) {
|
||||
PyInstanceObject *inst;
|
||||
inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type);
|
||||
if (!inst) return robj;
|
||||
inst->in_dict = PyDict_New();
|
||||
inst->in_class = (PyClassObject *) type->clientdata;
|
||||
Py_INCREF(inst->in_class);
|
||||
PyObject_SetAttrString((PyObject *)inst,(char*)"this",robj);
|
||||
Py_DECREF(robj);
|
||||
if (own) {
|
||||
PyObject *n = PyInt_FromLong(1);
|
||||
PyObject_SetAttrString((PyObject *)inst,(char*)"thisown",n);
|
||||
Py_DECREF(n);
|
||||
}
|
||||
robj = (PyObject *) inst;
|
||||
Py_INCREF(robj);
|
||||
}
|
||||
return robj;
|
||||
}
|
||||
|
||||
SWIGRUNTIME(PyObject *)
|
||||
SWIG_NewPackedObj(void *ptr, int sz, swig_type_info *type) {
|
||||
char result[1024];
|
||||
char *r = result;
|
||||
if ((2*sz + 1 + strlen(type->name)) > 1000) return 0;
|
||||
*(r++) = '_';
|
||||
r = SWIG_PackData(r,ptr,sz);
|
||||
strcpy(r,type->name);
|
||||
return PyString_FromString(result);
|
||||
}
|
||||
|
||||
/* Install Constants */
|
||||
SWIGRUNTIME(void)
|
||||
SWIG_InstallConstants(PyObject *d, swig_const_info constants[]) {
|
||||
int i;
|
||||
PyObject *obj;
|
||||
for (i = 0; constants[i].type; i++) {
|
||||
switch(constants[i].type) {
|
||||
case SWIG_PY_INT:
|
||||
obj = PyInt_FromLong(constants[i].lvalue);
|
||||
break;
|
||||
case SWIG_PY_FLOAT:
|
||||
obj = PyFloat_FromDouble(constants[i].dvalue);
|
||||
break;
|
||||
case SWIG_PY_STRING:
|
||||
obj = PyString_FromString((char *) constants[i].pvalue);
|
||||
break;
|
||||
case SWIG_PY_POINTER:
|
||||
obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
|
||||
break;
|
||||
case SWIG_PY_BINARY:
|
||||
obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
|
||||
break;
|
||||
default:
|
||||
obj = 0;
|
||||
break;
|
||||
}
|
||||
if (obj) {
|
||||
PyDict_SetItemString(d,constants[i].name,obj);
|
||||
Py_DECREF(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* -------- TYPES TABLE (BEGIN) -------- */
|
||||
|
||||
static swig_type_info *swig_types[1];
|
||||
|
||||
/* -------- TYPES TABLE (END) -------- */
|
||||
|
||||
#define SWIG_init initBlender
|
||||
|
||||
#define SWIG_name "Blender"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
static PyObject *_wrap_copy(PyObject *self, PyObject *args) {
|
||||
PyObject *resultobj;
|
||||
|
||||
if(!PyArg_ParseTuple(args,(char *)":copy")) return NULL;
|
||||
BlenderCopy();
|
||||
|
||||
Py_INCREF(Py_None); resultobj = Py_None;
|
||||
return resultobj;
|
||||
}
|
||||
|
||||
|
||||
static PyMethodDef SwigMethods[] = {
|
||||
{ (char *)"copy", _wrap_copy, METH_VARARGS },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
|
||||
|
||||
|
||||
static swig_type_info *swig_types_initial[] = {
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
|
||||
|
||||
static swig_const_info swig_const_table[] = {
|
||||
{0}};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
SWIGEXPORT(void) SWIG_init(void) {
|
||||
static PyObject *SWIG_globals = 0;
|
||||
PyObject *m, *d;
|
||||
int i;
|
||||
SWIG_globals = SWIG_newvarlink();
|
||||
m = Py_InitModule((char *) SWIG_name, SwigMethods);
|
||||
d = PyModule_GetDict(m);
|
||||
PyDict_SetItemString (d, "Object", initObject());
|
||||
|
||||
for (i = 0; swig_types_initial[i]; i++) {
|
||||
swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);
|
||||
}
|
||||
SWIG_InstallConstants(d,swig_const_table);
|
||||
|
||||
}
|
||||
|
@ -29,20 +29,90 @@
|
||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include <Python.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void copy (void)
|
||||
/*****************************************************************************/
|
||||
/* Python API function prototypes for the Blender module. */
|
||||
/*****************************************************************************/
|
||||
PyObject *Object_New(PyObject *self, PyObject *args);
|
||||
PyObject *Object_Get(PyObject *self, PyObject *args);
|
||||
PyObject *Object_GetSelected (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.__doc__ */
|
||||
/*****************************************************************************/
|
||||
char Object_New_doc[] =
|
||||
"(type) - Add a new object of type 'type' in the current scene";
|
||||
|
||||
char Object_Get_doc[] =
|
||||
"(name) - return the object with the name 'name', returns None if not\
|
||||
found.\n\
|
||||
If 'name' is not specified, it returns a list of all objects in the\n\
|
||||
current scene.";
|
||||
|
||||
char Object_GetSelected_doc[] =
|
||||
"() - Returns a list of selected Objects in the active layer(s)\n\
|
||||
The active object is the first in the list, if visible";
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python method structure definition. */
|
||||
/*****************************************************************************/
|
||||
struct PyMethodDef Object_methods[] = {
|
||||
{"New", Object_New, METH_VARARGS, Object_New_doc},
|
||||
{"Get", Object_Get, METH_VARARGS, Object_Get_doc},
|
||||
{"get", Object_Get, METH_VARARGS, Object_Get_doc},
|
||||
{"getSelected", Object_GetSelected, METH_VARARGS, Object_GetSelected_doc},
|
||||
{NULL, NULL}
|
||||
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Object_New */
|
||||
/* Python equivalent: Blender.Object.New */
|
||||
/*****************************************************************************/
|
||||
PyObject *Object_New(PyObject *self, PyObject *args)
|
||||
{
|
||||
printf ("Object.copy\n");
|
||||
printf ("In Object_New()\n");
|
||||
return (Py_None);
|
||||
}
|
||||
|
||||
void shareFrom (int object)
|
||||
/*****************************************************************************/
|
||||
/* Function: Object_Get */
|
||||
/* Python equivalent: Blender.Object.Get */
|
||||
/*****************************************************************************/
|
||||
PyObject *Object_Get(PyObject *self, PyObject *args)
|
||||
{
|
||||
printf ("Object.shareFrom(%d)\n", object);
|
||||
printf ("In Object_Get()\n");
|
||||
|
||||
return (Py_None);
|
||||
}
|
||||
|
||||
int getMatrix (void)
|
||||
/*****************************************************************************/
|
||||
/* Function: Object_GetSelected */
|
||||
/* Python equivalent: Blender.Object.getSelected */
|
||||
/*****************************************************************************/
|
||||
PyObject *Object_GetSelected (PyObject *self, PyObject *args)
|
||||
{
|
||||
printf ("Object.getMatrix\n");
|
||||
return (0);
|
||||
printf ("In Object_GetSelected()\n");
|
||||
|
||||
return (Py_None);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: initObject */
|
||||
/*****************************************************************************/
|
||||
PyObject *initObject (void)
|
||||
{
|
||||
PyObject * module;
|
||||
PyObject * dict;
|
||||
|
||||
printf ("In initObject()\n");
|
||||
|
||||
module = Py_InitModule("Blender.Object", Object_methods);
|
||||
|
||||
return (module);
|
||||
}
|
||||
|
||||
|
@ -1,706 +0,0 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 1.3.10u-20030216-1639
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
* changes to this file unless you know what you are doing--modify the SWIG
|
||||
* interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#define SWIGPYTHON
|
||||
/***********************************************************************
|
||||
* common.swg
|
||||
*
|
||||
* This file contains generic SWIG runtime support for pointer
|
||||
* type checking as well as a few commonly used macros to control
|
||||
* external linkage.
|
||||
*
|
||||
* Author : David Beazley (beazley@cs.uchicago.edu)
|
||||
*
|
||||
* Copyright (c) 1999-2000, The University of Chicago
|
||||
*
|
||||
* This file may be freely redistributed without license or fee provided
|
||||
* this copyright message remains intact.
|
||||
************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(_WIN32) || defined(__WIN32__)
|
||||
# if defined(_MSC_VER)
|
||||
# if defined(STATIC_LINKED)
|
||||
# define SWIGEXPORT(a) a
|
||||
# else
|
||||
# define SWIGEXPORT(a) __declspec(dllexport) a
|
||||
# endif
|
||||
# else
|
||||
# if defined(__BORLANDC__)
|
||||
# define SWIGEXPORT(a) a _export
|
||||
# else
|
||||
# define SWIGEXPORT(a) a
|
||||
# endif
|
||||
#endif
|
||||
#else
|
||||
# define SWIGEXPORT(a) a
|
||||
#endif
|
||||
|
||||
#ifdef SWIG_GLOBAL
|
||||
#define SWIGRUNTIME(a) SWIGEXPORT(a)
|
||||
#else
|
||||
#define SWIGRUNTIME(a) static a
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void *(*swig_converter_func)(void *);
|
||||
|
||||
typedef struct swig_type_info {
|
||||
const char *name;
|
||||
swig_converter_func converter;
|
||||
const char *str;
|
||||
struct swig_type_info *next;
|
||||
struct swig_type_info *prev;
|
||||
void *clientdata;
|
||||
} swig_type_info;
|
||||
|
||||
#ifdef SWIG_NOINCLUDE
|
||||
SWIGEXPORT(swig_type_info *) SWIG_TypeRegister(swig_type_info *);
|
||||
SWIGEXPORT(swig_type_info *) SWIG_TypeCheck(char *c, swig_type_info *);
|
||||
SWIGEXPORT(void *) SWIG_TypeCast(swig_type_info *, void *);
|
||||
SWIGEXPORT(swig_type_info *) SWIG_TypeQuery(const char *);
|
||||
SWIGEXPORT(void) SWIG_TypeClientData(swig_type_info *, void *);
|
||||
#else
|
||||
|
||||
static swig_type_info *swig_type_list = 0;
|
||||
|
||||
/* Register a type mapping with the type-checking */
|
||||
SWIGRUNTIME(swig_type_info *)
|
||||
SWIG_TypeRegister(swig_type_info *ti)
|
||||
{
|
||||
swig_type_info *tc, *head, *ret, *next;
|
||||
/* Check to see if this type has already been registered */
|
||||
tc = swig_type_list;
|
||||
while (tc) {
|
||||
if (strcmp(tc->name, ti->name) == 0) {
|
||||
/* Already exists in the table. Just add additional types to the list */
|
||||
head = tc;
|
||||
next = tc->next;
|
||||
goto l1;
|
||||
}
|
||||
tc = tc->prev;
|
||||
}
|
||||
head = ti;
|
||||
next = 0;
|
||||
|
||||
/* Place in list */
|
||||
ti->prev = swig_type_list;
|
||||
swig_type_list = ti;
|
||||
|
||||
/* Build linked lists */
|
||||
l1:
|
||||
ret = head;
|
||||
tc = ti + 1;
|
||||
/* Patch up the rest of the links */
|
||||
while (tc->name) {
|
||||
head->next = tc;
|
||||
tc->prev = head;
|
||||
head = tc;
|
||||
tc++;
|
||||
}
|
||||
head->next = next;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Check the typename */
|
||||
SWIGRUNTIME(swig_type_info *)
|
||||
SWIG_TypeCheck(char *c, swig_type_info *ty)
|
||||
{
|
||||
swig_type_info *s;
|
||||
if (!ty) return 0; /* Void pointer */
|
||||
s = ty->next; /* First element always just a name */
|
||||
while (s) {
|
||||
if (strcmp(s->name,c) == 0) {
|
||||
if (s == ty->next) return s;
|
||||
/* Move s to the top of the linked list */
|
||||
s->prev->next = s->next;
|
||||
if (s->next) {
|
||||
s->next->prev = s->prev;
|
||||
}
|
||||
/* Insert s as second element in the list */
|
||||
s->next = ty->next;
|
||||
if (ty->next) ty->next->prev = s;
|
||||
ty->next = s;
|
||||
return s;
|
||||
}
|
||||
s = s->next;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Cast a pointer (needed for C++ inheritance */
|
||||
SWIGRUNTIME(void *)
|
||||
SWIG_TypeCast(swig_type_info *ty, void *ptr)
|
||||
{
|
||||
if ((!ty) || (!ty->converter)) return ptr;
|
||||
return (*ty->converter)(ptr);
|
||||
}
|
||||
|
||||
/* Search for a swig_type_info structure */
|
||||
SWIGRUNTIME(swig_type_info *)
|
||||
SWIG_TypeQuery(const char *name) {
|
||||
swig_type_info *ty = swig_type_list;
|
||||
while (ty) {
|
||||
if (ty->str && (strcmp(name,ty->str) == 0)) return ty;
|
||||
if (ty->name && (strcmp(name,ty->name) == 0)) return ty;
|
||||
ty = ty->prev;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Set the clientdata field for a type */
|
||||
SWIGRUNTIME(void)
|
||||
SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
|
||||
swig_type_info *tc, *equiv;
|
||||
if (ti->clientdata) return;
|
||||
ti->clientdata = clientdata;
|
||||
equiv = ti->next;
|
||||
while (equiv) {
|
||||
if (!equiv->converter) {
|
||||
tc = swig_type_list;
|
||||
while (tc) {
|
||||
if ((strcmp(tc->name, equiv->name) == 0))
|
||||
SWIG_TypeClientData(tc,clientdata);
|
||||
tc = tc->prev;
|
||||
}
|
||||
}
|
||||
equiv = equiv->next;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* python.swg
|
||||
*
|
||||
* This file contains the runtime support for Python modules
|
||||
* and includes code for managing global variables and pointer
|
||||
* type checking.
|
||||
*
|
||||
* Author : David Beazley (beazley@cs.uchicago.edu)
|
||||
************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "Python.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SWIG_PY_INT 1
|
||||
#define SWIG_PY_FLOAT 2
|
||||
#define SWIG_PY_STRING 3
|
||||
#define SWIG_PY_POINTER 4
|
||||
#define SWIG_PY_BINARY 5
|
||||
|
||||
/* Constant information structure */
|
||||
typedef struct swig_const_info {
|
||||
int type;
|
||||
char *name;
|
||||
long lvalue;
|
||||
double dvalue;
|
||||
void *pvalue;
|
||||
swig_type_info **ptype;
|
||||
} swig_const_info;
|
||||
|
||||
#ifdef SWIG_NOINCLUDE
|
||||
|
||||
SWIGEXPORT(PyObject *) SWIG_newvarlink();
|
||||
SWIGEXPORT(void) SWIG_addvarlink(PyObject *, char *, PyObject *(*)(void), int (*)(PyObject *));
|
||||
SWIGEXPORT(int) SWIG_ConvertPtr(PyObject *, void **, swig_type_info *, int);
|
||||
SWIGEXPORT(int) SWIG_ConvertPacked(PyObject *, void *, int sz, swig_type_info *, int);
|
||||
SWIGEXPORT(char *) SWIG_PackData(char *c, void *, int);
|
||||
SWIGEXPORT(char *) SWIG_UnpackData(char *c, void *, int);
|
||||
SWIGEXPORT(PyObject *) SWIG_NewPointerObj(void *, swig_type_info *,int own);
|
||||
SWIGEXPORT(PyObject *) SWIG_NewPackedObj(void *, int sz, swig_type_info *);
|
||||
SWIGEXPORT(void) SWIG_InstallConstants(PyObject *d, swig_const_info constants[]);
|
||||
SWIGEXPORT(PyObject *) SWIG_MakeShadow(PyObject *robj, swig_type_info *type, int own);
|
||||
#else
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* global variable support code.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
typedef struct swig_globalvar {
|
||||
char *name; /* Name of global variable */
|
||||
PyObject *(*get_attr)(void); /* Return the current value */
|
||||
int (*set_attr)(PyObject *); /* Set the value */
|
||||
struct swig_globalvar *next;
|
||||
} swig_globalvar;
|
||||
|
||||
typedef struct swig_varlinkobject {
|
||||
PyObject_HEAD
|
||||
swig_globalvar *vars;
|
||||
} swig_varlinkobject;
|
||||
|
||||
static PyObject *
|
||||
swig_varlink_repr(swig_varlinkobject *v) {
|
||||
v = v;
|
||||
return PyString_FromString("<Global variables>");
|
||||
}
|
||||
|
||||
static int
|
||||
swig_varlink_print(swig_varlinkobject *v, FILE *fp, int flags) {
|
||||
swig_globalvar *var;
|
||||
flags = flags;
|
||||
fprintf(fp,"Global variables { ");
|
||||
for (var = v->vars; var; var=var->next) {
|
||||
fprintf(fp,"%s", var->name);
|
||||
if (var->next) fprintf(fp,", ");
|
||||
}
|
||||
fprintf(fp," }\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
swig_varlink_getattr(swig_varlinkobject *v, char *n) {
|
||||
swig_globalvar *var = v->vars;
|
||||
while (var) {
|
||||
if (strcmp(var->name,n) == 0) {
|
||||
return (*var->get_attr)();
|
||||
}
|
||||
var = var->next;
|
||||
}
|
||||
PyErr_SetString(PyExc_NameError,"Unknown C global variable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
|
||||
swig_globalvar *var = v->vars;
|
||||
while (var) {
|
||||
if (strcmp(var->name,n) == 0) {
|
||||
return (*var->set_attr)(p);
|
||||
}
|
||||
var = var->next;
|
||||
}
|
||||
PyErr_SetString(PyExc_NameError,"Unknown C global variable");
|
||||
return 1;
|
||||
}
|
||||
|
||||
statichere PyTypeObject varlinktype = {
|
||||
PyObject_HEAD_INIT(0)
|
||||
0,
|
||||
(char *)"swigvarlink", /* Type name */
|
||||
sizeof(swig_varlinkobject), /* Basic size */
|
||||
0, /* Itemsize */
|
||||
0, /* Deallocator */
|
||||
(printfunc) swig_varlink_print, /* Print */
|
||||
(getattrfunc) swig_varlink_getattr, /* get attr */
|
||||
(setattrfunc) swig_varlink_setattr, /* Set attr */
|
||||
0, /* tp_compare */
|
||||
(reprfunc) swig_varlink_repr, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_mapping*/
|
||||
0, /* tp_hash */
|
||||
};
|
||||
|
||||
/* Create a variable linking object for use later */
|
||||
SWIGRUNTIME(PyObject *)
|
||||
SWIG_newvarlink(void) {
|
||||
swig_varlinkobject *result = 0;
|
||||
result = PyMem_NEW(swig_varlinkobject,1);
|
||||
varlinktype.ob_type = &PyType_Type; /* Patch varlinktype into a PyType */
|
||||
result->ob_type = &varlinktype;
|
||||
result->vars = 0;
|
||||
result->ob_refcnt = 0;
|
||||
Py_XINCREF((PyObject *) result);
|
||||
return ((PyObject*) result);
|
||||
}
|
||||
|
||||
SWIGRUNTIME(void)
|
||||
SWIG_addvarlink(PyObject *p, char *name,
|
||||
PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {
|
||||
swig_varlinkobject *v;
|
||||
swig_globalvar *gv;
|
||||
v= (swig_varlinkobject *) p;
|
||||
gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
|
||||
gv->name = (char *) malloc(strlen(name)+1);
|
||||
strcpy(gv->name,name);
|
||||
gv->get_attr = get_attr;
|
||||
gv->set_attr = set_attr;
|
||||
gv->next = v->vars;
|
||||
v->vars = gv;
|
||||
}
|
||||
|
||||
/* Pack binary data into a string */
|
||||
SWIGRUNTIME(char *)
|
||||
SWIG_PackData(char *c, void *ptr, int sz) {
|
||||
static char hex[17] = "0123456789abcdef";
|
||||
int i;
|
||||
unsigned char *u = (unsigned char *) ptr;
|
||||
register unsigned char uu;
|
||||
for (i = 0; i < sz; i++,u++) {
|
||||
uu = *u;
|
||||
*(c++) = hex[(uu & 0xf0) >> 4];
|
||||
*(c++) = hex[uu & 0xf];
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
/* Unpack binary data from a string */
|
||||
SWIGRUNTIME(char *)
|
||||
SWIG_UnpackData(char *c, void *ptr, int sz) {
|
||||
register unsigned char uu;
|
||||
register int d;
|
||||
unsigned char *u = (unsigned char *) ptr;
|
||||
int i;
|
||||
for (i = 0; i < sz; i++, u++) {
|
||||
d = *(c++);
|
||||
if ((d >= '0') && (d <= '9'))
|
||||
uu = ((d - '0') << 4);
|
||||
else if ((d >= 'a') && (d <= 'f'))
|
||||
uu = ((d - ('a'-10)) << 4);
|
||||
d = *(c++);
|
||||
if ((d >= '0') && (d <= '9'))
|
||||
uu |= (d - '0');
|
||||
else if ((d >= 'a') && (d <= 'f'))
|
||||
uu |= (d - ('a'-10));
|
||||
*u = uu;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
/* Convert a pointer value */
|
||||
SWIGRUNTIME(int)
|
||||
SWIG_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags) {
|
||||
swig_type_info *tc;
|
||||
char *c;
|
||||
static PyObject *SWIG_this = 0;
|
||||
int newref = 0;
|
||||
|
||||
if (!obj) return 0;
|
||||
if (obj == Py_None) {
|
||||
*ptr = 0;
|
||||
return 0;
|
||||
}
|
||||
#ifdef SWIG_COBJECT_TYPES
|
||||
if (!(PyCObject_Check(obj))) {
|
||||
if (!SWIG_this)
|
||||
SWIG_this = PyString_InternFromString("this");
|
||||
obj = PyObject_GetAttr(obj,SWIG_this);
|
||||
newref = 1;
|
||||
if (!obj) goto type_error;
|
||||
if (!PyCObject_Check(obj)) {
|
||||
Py_DECREF(obj);
|
||||
goto type_error;
|
||||
}
|
||||
}
|
||||
*ptr = PyCObject_AsVoidPtr(obj);
|
||||
c = (char *) PyCObject_GetDesc(obj);
|
||||
if (newref) Py_DECREF(obj);
|
||||
goto cobject;
|
||||
#else
|
||||
if (!(PyString_Check(obj))) {
|
||||
if (!SWIG_this)
|
||||
SWIG_this = PyString_InternFromString("this");
|
||||
obj = PyObject_GetAttr(obj,SWIG_this);
|
||||
newref = 1;
|
||||
if (!obj) goto type_error;
|
||||
if (!PyString_Check(obj)) {
|
||||
Py_DECREF(obj);
|
||||
goto type_error;
|
||||
}
|
||||
}
|
||||
c = PyString_AsString(obj);
|
||||
/* Pointer values must start with leading underscore */
|
||||
if (*c != '_') {
|
||||
*ptr = (void *) 0;
|
||||
if (strcmp(c,"NULL") == 0) {
|
||||
if (newref) Py_DECREF(obj);
|
||||
return 0;
|
||||
} else {
|
||||
if (newref) Py_DECREF(obj);
|
||||
goto type_error;
|
||||
}
|
||||
}
|
||||
c++;
|
||||
c = SWIG_UnpackData(c,ptr,sizeof(void *));
|
||||
if (newref) Py_DECREF(obj);
|
||||
#endif
|
||||
|
||||
#ifdef SWIG_COBJECT_TYPES
|
||||
cobject:
|
||||
#endif
|
||||
|
||||
if (ty) {
|
||||
tc = SWIG_TypeCheck(c,ty);
|
||||
if (!tc) goto type_error;
|
||||
*ptr = SWIG_TypeCast(tc,(void*) *ptr);
|
||||
}
|
||||
return 0;
|
||||
|
||||
type_error:
|
||||
if (flags) {
|
||||
if (ty) {
|
||||
char *temp = (char *) malloc(64+strlen(ty->name));
|
||||
sprintf(temp,"Type error. Expected %s", ty->name);
|
||||
PyErr_SetString(PyExc_TypeError, temp);
|
||||
free((char *) temp);
|
||||
} else {
|
||||
PyErr_SetString(PyExc_TypeError,"Expected a pointer");
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Convert a packed value value */
|
||||
SWIGRUNTIME(int)
|
||||
SWIG_ConvertPacked(PyObject *obj, void *ptr, int sz, swig_type_info *ty, int flags) {
|
||||
swig_type_info *tc;
|
||||
char *c;
|
||||
|
||||
if ((!obj) || (!PyString_Check(obj))) goto type_error;
|
||||
c = PyString_AsString(obj);
|
||||
/* Pointer values must start with leading underscore */
|
||||
if (*c != '_') goto type_error;
|
||||
c++;
|
||||
c = SWIG_UnpackData(c,ptr,sz);
|
||||
if (ty) {
|
||||
tc = SWIG_TypeCheck(c,ty);
|
||||
if (!tc) goto type_error;
|
||||
}
|
||||
return 0;
|
||||
|
||||
type_error:
|
||||
|
||||
if (flags) {
|
||||
if (ty) {
|
||||
char *temp = (char *) malloc(64+strlen(ty->name));
|
||||
sprintf(temp,"Type error. Expected %s", ty->name);
|
||||
PyErr_SetString(PyExc_TypeError, temp);
|
||||
free((char *) temp);
|
||||
} else {
|
||||
PyErr_SetString(PyExc_TypeError,"Expected a pointer");
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Create a new pointer object */
|
||||
SWIGRUNTIME(PyObject *)
|
||||
SWIG_NewPointerObj(void *ptr, swig_type_info *type, int own) {
|
||||
PyObject *robj;
|
||||
if (!ptr) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
#ifdef SWIG_COBJECT_TYPES
|
||||
robj = PyCObject_FromVoidPtrAndDesc((void *) ptr, (char *) type->name, NULL);
|
||||
#else
|
||||
{
|
||||
char result[512];
|
||||
char *r = result;
|
||||
*(r++) = '_';
|
||||
r = SWIG_PackData(r,&ptr,sizeof(void *));
|
||||
strcpy(r,type->name);
|
||||
robj = PyString_FromString(result);
|
||||
}
|
||||
#endif
|
||||
if (!robj || (robj == Py_None)) return robj;
|
||||
if (type->clientdata) {
|
||||
PyObject *inst;
|
||||
PyObject *args = Py_BuildValue((char*)"(O)", robj);
|
||||
Py_DECREF(robj);
|
||||
inst = PyObject_CallObject((PyObject *) type->clientdata, args);
|
||||
Py_DECREF(args);
|
||||
if (own) {
|
||||
PyObject *n = PyInt_FromLong(1);
|
||||
PyObject_SetAttrString(inst,(char*)"thisown",n);
|
||||
Py_DECREF(n);
|
||||
}
|
||||
robj = inst;
|
||||
}
|
||||
return robj;
|
||||
}
|
||||
|
||||
SWIGRUNTIME(PyObject *)
|
||||
SWIG_MakeShadow(PyObject *robj, swig_type_info *type, int own) {
|
||||
if (!robj || (robj == Py_None)) return robj;
|
||||
if (type->clientdata) {
|
||||
PyInstanceObject *inst;
|
||||
inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type);
|
||||
if (!inst) return robj;
|
||||
inst->in_dict = PyDict_New();
|
||||
inst->in_class = (PyClassObject *) type->clientdata;
|
||||
Py_INCREF(inst->in_class);
|
||||
PyObject_SetAttrString((PyObject *)inst,(char*)"this",robj);
|
||||
Py_DECREF(robj);
|
||||
if (own) {
|
||||
PyObject *n = PyInt_FromLong(1);
|
||||
PyObject_SetAttrString((PyObject *)inst,(char*)"thisown",n);
|
||||
Py_DECREF(n);
|
||||
}
|
||||
robj = (PyObject *) inst;
|
||||
Py_INCREF(robj);
|
||||
}
|
||||
return robj;
|
||||
}
|
||||
|
||||
SWIGRUNTIME(PyObject *)
|
||||
SWIG_NewPackedObj(void *ptr, int sz, swig_type_info *type) {
|
||||
char result[1024];
|
||||
char *r = result;
|
||||
if ((2*sz + 1 + strlen(type->name)) > 1000) return 0;
|
||||
*(r++) = '_';
|
||||
r = SWIG_PackData(r,ptr,sz);
|
||||
strcpy(r,type->name);
|
||||
return PyString_FromString(result);
|
||||
}
|
||||
|
||||
/* Install Constants */
|
||||
SWIGRUNTIME(void)
|
||||
SWIG_InstallConstants(PyObject *d, swig_const_info constants[]) {
|
||||
int i;
|
||||
PyObject *obj;
|
||||
for (i = 0; constants[i].type; i++) {
|
||||
switch(constants[i].type) {
|
||||
case SWIG_PY_INT:
|
||||
obj = PyInt_FromLong(constants[i].lvalue);
|
||||
break;
|
||||
case SWIG_PY_FLOAT:
|
||||
obj = PyFloat_FromDouble(constants[i].dvalue);
|
||||
break;
|
||||
case SWIG_PY_STRING:
|
||||
obj = PyString_FromString((char *) constants[i].pvalue);
|
||||
break;
|
||||
case SWIG_PY_POINTER:
|
||||
obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
|
||||
break;
|
||||
case SWIG_PY_BINARY:
|
||||
obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
|
||||
break;
|
||||
default:
|
||||
obj = 0;
|
||||
break;
|
||||
}
|
||||
if (obj) {
|
||||
PyDict_SetItemString(d,constants[i].name,obj);
|
||||
Py_DECREF(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* -------- TYPES TABLE (BEGIN) -------- */
|
||||
|
||||
static swig_type_info *swig_types[1];
|
||||
|
||||
/* -------- TYPES TABLE (END) -------- */
|
||||
|
||||
#define SWIG_init initObject
|
||||
|
||||
#define SWIG_name "Object"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
static PyObject *_wrap_copy(PyObject *self, PyObject *args) {
|
||||
PyObject *resultobj;
|
||||
|
||||
if(!PyArg_ParseTuple(args,(char *)":copy")) return NULL;
|
||||
copy();
|
||||
|
||||
Py_INCREF(Py_None); resultobj = Py_None;
|
||||
return resultobj;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *_wrap_shareFrom(PyObject *self, PyObject *args) {
|
||||
PyObject *resultobj;
|
||||
int arg1 ;
|
||||
|
||||
if(!PyArg_ParseTuple(args,(char *)"i:shareFrom",&arg1)) return NULL;
|
||||
shareFrom(arg1);
|
||||
|
||||
Py_INCREF(Py_None); resultobj = Py_None;
|
||||
return resultobj;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *_wrap_getMatrix(PyObject *self, PyObject *args) {
|
||||
PyObject *resultobj;
|
||||
int result;
|
||||
|
||||
if(!PyArg_ParseTuple(args,(char *)":getMatrix")) return NULL;
|
||||
result = (int )getMatrix();
|
||||
|
||||
resultobj = PyInt_FromLong((long)result);
|
||||
return resultobj;
|
||||
}
|
||||
|
||||
|
||||
static PyMethodDef SwigMethods[] = {
|
||||
{ (char *)"copy", _wrap_copy, METH_VARARGS },
|
||||
{ (char *)"shareFrom", _wrap_shareFrom, METH_VARARGS },
|
||||
{ (char *)"getMatrix", _wrap_getMatrix, METH_VARARGS },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
|
||||
|
||||
|
||||
static swig_type_info *swig_types_initial[] = {
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
|
||||
|
||||
static swig_const_info swig_const_table[] = {
|
||||
{0}};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
SWIGEXPORT(PyObject*) SWIG_init(void) {
|
||||
static PyObject *SWIG_globals = 0;
|
||||
PyObject *m, *d;
|
||||
int i;
|
||||
SWIG_globals = SWIG_newvarlink();
|
||||
m = Py_InitModule((char *) SWIG_name, SwigMethods);
|
||||
d = PyModule_GetDict(m);
|
||||
|
||||
for (i = 0; swig_types_initial[i]; i++) {
|
||||
swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);
|
||||
}
|
||||
SWIG_InstallConstants(d,swig_const_table);
|
||||
|
||||
return (m);
|
||||
}
|
||||
|
311
source/blender/python/api2_2x/datablock.c
Normal file
311
source/blender/python/api2_2x/datablock.c
Normal file
@ -0,0 +1,311 @@
|
||||
/*
|
||||
*
|
||||
* ***** 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
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version. The Blender
|
||||
* Foundation also sells licenses for use in proprietary software under
|
||||
* the Blender License. See http://www.blender.org/BL/ for information
|
||||
* about this.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This is a new part of Blender.
|
||||
*
|
||||
* Contributor(s): Michel Selten
|
||||
*
|
||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <BKE_global.h>
|
||||
#include <BKE_main.h>
|
||||
#include <DNA_ID.h>
|
||||
|
||||
#include "datablock.h"
|
||||
#include "gen_utils.h"
|
||||
#include "modules.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function prototypes */
|
||||
/*****************************************************************************/
|
||||
void DataBlock_dealloc (PyObject *self);
|
||||
PyObject * DataBlock_getattr (PyObject *self, char *name);
|
||||
int DataBlock_setattr (PyObject *self, char *name, PyObject *ob);
|
||||
PyObject * DataBlock_repr (PyObject *self);
|
||||
|
||||
PyTypeObject DataBlock_Type =
|
||||
{
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
"Block", /* tp_name */
|
||||
sizeof (DataBlock), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
(destructor) DataBlock_dealloc, /* tp_dealloc */
|
||||
(printfunc) NULL, /* tp_print */
|
||||
(getattrfunc) DataBlock_getattr, /* tp_getattr */
|
||||
(setattrfunc) DataBlock_setattr, /* tp_setattr */
|
||||
(cmpfunc) NULL, /* tp_compare */
|
||||
(reprfunc) DataBlock_repr /* tp_repr */
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Description: This function creates a Python datablock descriptor object */
|
||||
/* from the specified data pointer. This pointer must point to */
|
||||
/* a structure with a valid ID header. */
|
||||
/*****************************************************************************/
|
||||
PyObject * DataBlockFromID (ID * data)
|
||||
{
|
||||
DataBlock * new_block;
|
||||
int obj_id;
|
||||
|
||||
if (!data)
|
||||
{
|
||||
return ( PythonIncRef (Py_None) );
|
||||
}
|
||||
|
||||
/* First get the object type. */
|
||||
obj_id = MAKE_ID2(data->name[0], data->name[1]);
|
||||
|
||||
switch (obj_id)
|
||||
{
|
||||
case ID_OB:
|
||||
/* Create a new datablock of type: Object */
|
||||
new_block= PyObject_NEW(DataBlock, &DataBlock_Type);
|
||||
new_block->type= "Object";
|
||||
new_block->type_list= &(G.main->object);
|
||||
new_block->properties= NULL; /* Object_Properties; */
|
||||
break;
|
||||
case ID_ME:
|
||||
/* Create a new datablock of type: Mesh */
|
||||
new_block= PyObject_NEW(DataBlock, &DataBlock_Type);
|
||||
new_block->type= "Mesh";
|
||||
new_block->type_list= &(G.main->mesh);
|
||||
new_block->properties= NULL; /* Mesh_Properties; */
|
||||
break;
|
||||
case ID_LA:
|
||||
/* Create a new datablock of type: Lamp */
|
||||
new_block= PyObject_NEW(DataBlock, &DataBlock_Type);
|
||||
new_block->type= "Lamp";
|
||||
new_block->type_list= &(G.main->lamp);
|
||||
new_block->properties= NULL; /* Lamp_Properties; */
|
||||
break;
|
||||
case ID_CA:
|
||||
/* Create a new datablock of type: Camera */
|
||||
new_block= PyObject_NEW(DataBlock, &DataBlock_Type);
|
||||
new_block->type= "Camera";
|
||||
new_block->type_list= &(G.main->camera);
|
||||
new_block->properties= NULL; /* Camera_Properties; */
|
||||
break;
|
||||
case ID_MA:
|
||||
/* Create a new datablock of type: Material */
|
||||
new_block= PyObject_NEW(DataBlock, &DataBlock_Type);
|
||||
new_block->type= "Material";
|
||||
new_block->type_list= &(G.main->mat);
|
||||
new_block->properties= NULL; /* Material_Properties; */
|
||||
break;
|
||||
case ID_WO:
|
||||
/* Create a new datablock of type: World */
|
||||
new_block= PyObject_NEW(DataBlock, &DataBlock_Type);
|
||||
new_block->type= "World";
|
||||
new_block->type_list= &(G.main->world);
|
||||
new_block->properties= NULL; /* World_Properties; */
|
||||
break;
|
||||
case ID_IP:
|
||||
/* Create a new datablock of type: Ipo */
|
||||
new_block= PyObject_NEW(DataBlock, &DataBlock_Type);
|
||||
new_block->type= "Ipo";
|
||||
new_block->type_list= &(G.main->ipo);
|
||||
new_block->properties= NULL; /* Ipo_Properties; */
|
||||
break;
|
||||
case ID_IM:
|
||||
/* Create a new datablock of type: Image */
|
||||
new_block= PyObject_NEW(DataBlock, &DataBlock_Type);
|
||||
new_block->type= "Image";
|
||||
new_block->type_list= &(G.main->image);
|
||||
new_block->properties= NULL; /* Image_Properties; */
|
||||
break;
|
||||
case ID_TXT:
|
||||
/* Create a new datablock of type: Text */
|
||||
new_block= PyObject_NEW(DataBlock, &DataBlock_Type);
|
||||
new_block->type= "Text";
|
||||
new_block->type_list= &(G.main->text);
|
||||
new_block->properties= NULL; /* Text_Properties; */
|
||||
break;
|
||||
default:
|
||||
return ( PythonReturnErrorObject (PyExc_SystemError,
|
||||
"Unable to create block for data") );
|
||||
}
|
||||
new_block->data = (void*)data;
|
||||
|
||||
return ( (PyObject *) new_block );
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Private functions */
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Description: Deallocates a Python Datablock object. */
|
||||
/*****************************************************************************/
|
||||
void DataBlock_dealloc (PyObject *self)
|
||||
{
|
||||
PyMem_DEL (self);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Description: */
|
||||
/*****************************************************************************/
|
||||
PyObject * DataBlock_getattr (PyObject *self, char *name)
|
||||
{
|
||||
int obj_id;
|
||||
PyObject * ret = NULL;
|
||||
DataBlock * block = (DataBlock*) self;
|
||||
|
||||
if (!block)
|
||||
{
|
||||
return (PythonReturnErrorObject (PyExc_RuntimeError,
|
||||
"Block was deleted!"));
|
||||
}
|
||||
|
||||
/* Check for common attributes. */
|
||||
if (StringEqual (name, "name") )
|
||||
{
|
||||
return (PyString_FromString ((((ID*)block->data)->name)+2));
|
||||
}
|
||||
if (StringEqual (name, "block_type") )
|
||||
{
|
||||
return(PyString_FromString (block->type));
|
||||
}
|
||||
if (StringEqual (name, "users") )
|
||||
{
|
||||
return (PyInt_FromLong (((ID*)block->data)->us));
|
||||
}
|
||||
|
||||
/* The following datablock types have methods: */
|
||||
obj_id = MAKE_ID2 (((ID*)block->data)->name[0],
|
||||
((ID*)block->data)->name[1]);
|
||||
switch (obj_id)
|
||||
{
|
||||
case ID_OB:
|
||||
ret = Py_FindMethod (Object_methods, self, name);
|
||||
break;
|
||||
case ID_IP:
|
||||
ret = Py_None;
|
||||
/* ret = Py_FindMethod (Ipo_methods, self, name); */
|
||||
break;
|
||||
case ID_CA:
|
||||
ret = Py_None;
|
||||
/* ret = Py_FindMethod (Camera_methods, self, name); */
|
||||
break;
|
||||
case ID_MA:
|
||||
ret = Py_None;
|
||||
/* ret = Py_FindMethod (Material_methods, self, name); */
|
||||
break;
|
||||
case ID_LA:
|
||||
ret = Py_None;
|
||||
/* ret = Py_FindMethod (Lamp_methods, self, name); */
|
||||
break;
|
||||
case ID_TXT:
|
||||
ret = Py_None;
|
||||
/* ret = Py_FindMethod (Text_methods, self, name); */
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
/* No method found, clear the error message. */
|
||||
PyErr_Clear ();
|
||||
|
||||
/* Try to find the common datablock methods. */
|
||||
/* ret = Py_FindMethod (commonDataBlock_methods, self, name); */
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
/* No method found, clear the error message. */
|
||||
PyErr_Clear ();
|
||||
|
||||
/* Try to find attributes from property list */
|
||||
/* ret = datablock_getattr (block->properties,
|
||||
block->type, name, block->data); */
|
||||
ret = Py_None;
|
||||
}
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Description: */
|
||||
/*****************************************************************************/
|
||||
int DataBlock_setattr (PyObject *self, char *name, PyObject *ob)
|
||||
{
|
||||
DataBlock * block = (DataBlock*) self;
|
||||
|
||||
if (!block)
|
||||
{
|
||||
PythonReturnErrorObject (PyExc_RuntimeError, "Block was deleted!");
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (StringEqual (name, "name"))
|
||||
{
|
||||
if (!PyArg_Parse (ob, "s", &name))
|
||||
{
|
||||
/* TODO: Do we need to display some sort of error message here? */
|
||||
return (-1);
|
||||
}
|
||||
|
||||
new_id (block->type_list, (ID*)block->data, name);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* return (datablock_setattr (block->properties, block->type, name,
|
||||
block->data, ob)); */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Description: This function prints a sensible string when doing a */
|
||||
/* 'print abc' from Python. Where abc is one of the Blender */
|
||||
/* objects. */
|
||||
/*****************************************************************************/
|
||||
PyObject * DataBlock_repr (PyObject *self)
|
||||
{
|
||||
DataBlock * data_block;
|
||||
ID * id;
|
||||
static char s[256];
|
||||
|
||||
data_block = (DataBlock *)self;
|
||||
if (data_block->data)
|
||||
{
|
||||
/* The object is still available, print the type and name. */
|
||||
id = (ID*)data_block->data;
|
||||
sprintf (s, "[%.32s %.32s]", data_block->type, id->name+2);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The object has been deleted, print the type and <deleted>. */
|
||||
sprintf (s, "[%.32s <deleted>]", data_block->type);
|
||||
}
|
||||
|
||||
return Py_BuildValue("s", s);
|
||||
}
|
||||
|
77
source/blender/python/api2_2x/datablock.h
Normal file
77
source/blender/python/api2_2x/datablock.h
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
*
|
||||
* ***** 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
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version. The Blender
|
||||
* Foundation also sells licenses for use in proprietary software under
|
||||
* the Blender License. See http://www.blender.org/BL/ for information
|
||||
* about this.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This is a new part of Blender.
|
||||
*
|
||||
* Contributor(s): Michel Selten
|
||||
*
|
||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#include <DNA_ID.h>
|
||||
#include <DNA_listBase.h>
|
||||
|
||||
#define DBP_TYPE_NON 0 /* No item */
|
||||
#define DBP_TYPE_CHA 1 /* Char item */
|
||||
#define DBP_TYPE_SHO 2 /* Short item */
|
||||
#define DBP_TYPE_INT 3 /* Int item */
|
||||
#define DBP_TYPE_FLO 4 /* Float item */
|
||||
#define DBP_TYPE_VEC 5 /* Float vector object */
|
||||
#define DBP_TYPE_FUN 6 /* funcPtrToObj hold function to convert ptr->ob */
|
||||
/* funcObjToPtr holds function to convert ob->ptr */
|
||||
|
||||
#define DBP_HANDLING_NONE 0 /* No special handling required */
|
||||
#define DBP_HANDLING_FUNC 1 /* Extra1 is used to retrieve ptr */
|
||||
#define DBP_HANDLING_NENM 2 /* Extra1 holds named enum to resolve */
|
||||
/* values from/to. */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char * public_name;
|
||||
char * struct_name;
|
||||
int type;
|
||||
int stype;
|
||||
float min; /* Minimum allowed value */
|
||||
float max; /* Maximum allowed value */
|
||||
int idx[4];
|
||||
int dlist[4];
|
||||
int handling;
|
||||
void * extra1;
|
||||
void * funcPtrToObj;
|
||||
void * funcObjToPtr;
|
||||
} DataBlockProperty;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PyObject_HEAD
|
||||
void * data;
|
||||
char * type;
|
||||
ListBase * type_list;
|
||||
DataBlockProperty * properties;
|
||||
} DataBlock;
|
||||
|
||||
PyObject * DataBlockFromID (ID * data);
|
||||
|
@ -29,11 +29,41 @@
|
||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
%module Object
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <Python.h>
|
||||
|
||||
#include <DNA_scriptlink_types.h>
|
||||
|
||||
int StringEqual (char * string1, char * string2)
|
||||
{
|
||||
return (strcmp(string1, string2)==0);
|
||||
}
|
||||
|
||||
PyObject * PythonReturnErrorObject (PyObject * type, char * error_msg)
|
||||
{
|
||||
PyErr_SetString (type, error_msg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyObject * PythonIncRef (PyObject *object)
|
||||
{
|
||||
Py_INCREF (object);
|
||||
return (object);
|
||||
}
|
||||
|
||||
char * event_to_name(short event)
|
||||
{
|
||||
switch (event)
|
||||
{
|
||||
case SCRIPT_FRAMECHANGED:
|
||||
return "FrameChanged";
|
||||
case SCRIPT_ONLOAD:
|
||||
return "OnLoad";
|
||||
case SCRIPT_REDRAW:
|
||||
return "Redraw";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
%{
|
||||
#include "modules.h"
|
||||
%}
|
||||
void copy (void);
|
||||
void shareFrom (int object);
|
||||
int getMatrix (void);
|
@ -29,6 +29,8 @@
|
||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
%module Blender
|
||||
int StringEqual (char * string1, char * string2);
|
||||
PyObject * PythonReturnErrorObject (PyObject * type, char * error_msg);
|
||||
PyObject * PythonIncRef (PyObject *object);
|
||||
char * event_to_name(short event);
|
||||
|
||||
void copy (void);
|
@ -29,6 +29,12 @@
|
||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <DNA_ID.h>
|
||||
|
||||
#include "datablock.h"
|
||||
#include "gen_utils.h"
|
||||
#include "modules.h"
|
||||
|
||||
void initBlenderApi2_2x (void)
|
||||
@ -37,3 +43,41 @@ void initBlenderApi2_2x (void)
|
||||
initBlender ();
|
||||
}
|
||||
|
||||
void setScriptLinks(ID *id, short event)
|
||||
{
|
||||
PyObject *link;
|
||||
int obj_id;
|
||||
|
||||
if (!g_blenderdict)
|
||||
{
|
||||
/* Not initialized yet. This can happen at first file load. */
|
||||
return;
|
||||
}
|
||||
|
||||
obj_id = MAKE_ID2 (id->name[0], id->name[1]);
|
||||
if (obj_id == ID_SCE)
|
||||
{
|
||||
Py_INCREF(Py_None);
|
||||
link = Py_None;
|
||||
}
|
||||
else
|
||||
{
|
||||
link = DataBlockFromID(id);
|
||||
}
|
||||
|
||||
if (!link)
|
||||
{
|
||||
printf ("Internal error, unable to create PyBlock for script link\n");
|
||||
printf ("This is a bug; please report to bugs@blender.nl");
|
||||
Py_INCREF(Py_False);
|
||||
PyDict_SetItemString(g_blenderdict, "bylink", Py_False);
|
||||
return;
|
||||
} else {
|
||||
Py_INCREF(Py_True);
|
||||
PyDict_SetItemString(g_blenderdict, "bylink", Py_True);
|
||||
}
|
||||
|
||||
PyDict_SetItemString(g_blenderdict, "link", link);
|
||||
PyDict_SetItemString(g_blenderdict, "event",
|
||||
Py_BuildValue("s", event_to_name(event)));
|
||||
}
|
||||
|
@ -29,5 +29,7 @@
|
||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
void initBlenderApi2_2x (void);
|
||||
#include <DNA_ID.h>
|
||||
|
||||
void initBlenderApi2_2x (void);
|
||||
void setScriptLinks(ID *id, short event);
|
||||
|
@ -30,6 +30,13 @@
|
||||
*/
|
||||
#include <Python.h>
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Global variables */
|
||||
/*****************************************************************************/
|
||||
PyObject *g_blenderdict;
|
||||
|
||||
extern struct PyMethodDef Object_methods[];
|
||||
|
||||
void initBlender (void);
|
||||
PyObject* initObject (void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user