diff options
author | Willian Padovani Germano <wpgermano@gmail.com> | 2003-05-09 08:34:40 +0400 |
---|---|---|
committer | Willian Padovani Germano <wpgermano@gmail.com> | 2003-05-09 08:34:40 +0400 |
commit | 81d2589d6a5af1e59125a7897e70638b420e5dc7 (patch) | |
tree | c5cad60a54161f9f8b8426504efd6003e3652bf5 /source/blender | |
parent | ceeb5e75685be981e206a9cf82568d8ac2459f3a (diff) |
* Implement Blender_Redraw(), minor changes in other files
* Implemented submodule Text
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/python/api2_2x/Blender.c | 13 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Blender.h | 4 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Image.c | 6 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Image.h | 4 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Lamp.c | 6 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Text.c | 436 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Text.h | 178 | ||||
-rw-r--r-- | source/blender/python/api2_2x/modules.h | 1 |
8 files changed, 633 insertions, 15 deletions
diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c index dcc4a0dfe7e..d7a685d131e 100644 --- a/source/blender/python/api2_2x/Blender.c +++ b/source/blender/python/api2_2x/Blender.c @@ -159,20 +159,18 @@ PyObject *Blender_Get (PyObject *self, PyObject *args) /*****************************************************************************/ 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 EXPP_ReturnPyObjError (PyExc_TypeError, + "expected int argument (or nothing)"); } - return Windowmodule_Redraw(self, Py_BuildValue("(i)", wintype)); - */ - return (Py_None); + return M_Window_Redraw(self, Py_BuildValue("(i)", wintype)); } /*****************************************************************************/ @@ -198,5 +196,6 @@ void initBlender (void) PyDict_SetItemString (dict, "Window", M_Window_Init()); PyDict_SetItemString (dict, "Draw", M_Draw_Init()); PyDict_SetItemString (dict, "BGL", M_BGL_Init()); + PyDict_SetItemString (dict, "Text", M_Text_Init()); } diff --git a/source/blender/python/api2_2x/Blender.h b/source/blender/python/api2_2x/Blender.h index 44aa75ea6dc..50afa1053f7 100644 --- a/source/blender/python/api2_2x/Blender.h +++ b/source/blender/python/api2_2x/Blender.h @@ -40,12 +40,16 @@ #include <DNA_ID.h> #include <DNA_object_types.h> #include <DNA_scene_types.h> +#include <DNA_screen_types.h> /* for SPACE_VIEW3D */ #include <DNA_userdef_types.h> #include <BKE_ipo.h> #include "gen_utils.h" #include "modules.h" +/* 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/Image.c b/source/blender/python/api2_2x/Image.c index 03e9557c6e9..2449de31750 100644 --- a/source/blender/python/api2_2x/Image.c +++ b/source/blender/python/api2_2x/Image.c @@ -116,13 +116,13 @@ static PyObject *M_Image_Load(PyObject *self, PyObject *args) /*****************************************************************************/ PyObject *M_Image_Init (void) { - PyObject *module; + PyObject *submodule; printf ("In M_Image_Init()\n"); - module = Py_InitModule3("Image", M_Image_methods, M_Image_doc); + submodule = Py_InitModule3("Blender.Image", M_Image_methods, M_Image_doc); - return (module); + return (submodule); } /*****************************************************************************/ diff --git a/source/blender/python/api2_2x/Image.h b/source/blender/python/api2_2x/Image.h index c92a0f00b0a..4ddffe01356 100644 --- a/source/blender/python/api2_2x/Image.h +++ b/source/blender/python/api2_2x/Image.h @@ -71,9 +71,9 @@ char M_Image_New_doc[] = "() - return a new Image object -- unimplemented"; char M_Image_Get_doc[] = -"(name) - return the camera with the name 'name', \ +"(name) - return the image with the name 'name', \ returns None if not found.\n If 'name' is not specified, \ -it returns a list of all cameras in the\ncurrent scene."; +it returns a list of all images in the\ncurrent scene."; char M_Image_Load_doc[] = "(filename) - return image from file filename as Image Object, \ diff --git a/source/blender/python/api2_2x/Lamp.c b/source/blender/python/api2_2x/Lamp.c index 142323bb994..a1d305692ec 100644 --- a/source/blender/python/api2_2x/Lamp.c +++ b/source/blender/python/api2_2x/Lamp.c @@ -132,13 +132,13 @@ static PyObject *M_Lamp_Get(PyObject *self, PyObject *args) /*****************************************************************************/ PyObject *M_Lamp_Init (void) { - PyObject *module; + PyObject *submodule; printf ("In M_Lamp_Init()\n"); - module = Py_InitModule3("Lamp", M_Lamp_methods, M_Lamp_doc); + submodule = Py_InitModule3("Blender.Lamp", M_Lamp_methods, M_Lamp_doc); - return (module); + return (submodule); } /*****************************************************************************/ diff --git a/source/blender/python/api2_2x/Text.c b/source/blender/python/api2_2x/Text.c new file mode 100644 index 00000000000..216572390ff --- /dev/null +++ b/source/blender/python/api2_2x/Text.c @@ -0,0 +1,436 @@ +/* + * + * ***** 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): Willian P. Germano + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** +*/ + +#include "Text.h" + +/*****************************************************************************/ +/* Function: M_Text_New */ +/* Python equivalent: Blender.Text.New */ +/*****************************************************************************/ +static PyObject *M_Text_New(PyObject *self, PyObject *args, PyObject *keywords) +{ + char *name = NULL; + char buf[21]; + int follow = 0; + Text *bl_text; /* blender text object */ + C_Text *py_text; /* python wrapper */ + + printf ("In Text_New()\n"); + + if (!PyArg_ParseTuple(args, "|si", &name, &follow)) + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected string and int arguments (or nothing)"); + + bl_text = add_empty_text(); + + if (bl_text) + py_text = (C_Text *)PyObject_NEW(C_Text, &Text_Type); + else + return EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't create Text Object in Blender"); + if (!py_text) + return EXPP_ReturnPyObjError (PyExc_MemoryError, + "couldn't create Text Object wrapper"); + + py_text->text = bl_text; + + if (follow) bl_text->flags |= EXPP_TEXT_MODE_FOLLOW; + + if (name) { + PyOS_snprintf(buf, sizeof(buf), "%s", name); + rename_id(&bl_text->id, buf); + } + + return (PyObject *)py_text; +} + +/*****************************************************************************/ +/* Function: M_Text_Get */ +/* Python equivalent: Blender.Text.Get */ +/*****************************************************************************/ +static PyObject *M_Text_Get(PyObject *self, PyObject *args) +{ + char *name; + Text *txt_iter; + C_Text *wanted_txt; + + printf ("In Text_Get()\n"); + if (!PyArg_ParseTuple(args, "s", &name)) + return EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected string argument"); + + /* Use the name to search for the text requested. */ + wanted_txt = NULL; + txt_iter = G.main->text.first; + + while ((txt_iter) && (wanted_txt == NULL)) { + + if (strcmp (name, txt_iter->id.name+2) == 0) { + wanted_txt = (C_Text *)PyObject_NEW(C_Text, &Text_Type); + if (wanted_txt) wanted_txt->text = txt_iter; + } + + txt_iter = txt_iter->id.next; + } + + if (wanted_txt == NULL) { + /* No text exists with the name specified in the argument name. */ + char error_msg[64]; + PyOS_snprintf(error_msg, sizeof(error_msg), + "Text \"%s\" not found", name); + return EXPP_ReturnPyObjError (PyExc_NameError, error_msg); + } + + return (PyObject*)wanted_txt; +} + +static PyObject *M_Text_Load(PyObject *self, PyObject *args) +{ + char *fname; + Text *txt_ptr; + C_Text *txt; + + printf ("In Text_Load()\n"); + + if (!PyArg_ParseTuple(args, "s", &fname)) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected string argument")); + + txt = (C_Text *)PyObject_NEW(C_Text, &Text_Type); + + if (!txt) + return EXPP_ReturnPyObjError (PyExc_MemoryError, + "couldn't create PyObject Text_Type"); + + txt_ptr = add_text(fname); + if (!txt_ptr) + return EXPP_ReturnPyObjError (PyExc_IOError, + "couldn't load text"); + + txt->text = txt_ptr; + + return (PyObject *)txt; +} + +/*@This function removes the text entry from the text editor. + * The text is not freed here, but inside the garbage collector. */ + +/* This function actually makes Blender dump core if the script is repeatedly + * executed, gotta investigate better */ + +static PyObject *M_Text_unlink(PyObject *self, PyObject *args) +{ + C_Text *textobj; + + if (!PyArg_ParseTuple(args, "O!", &Text_Type, &textobj)) + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected a Text object as argument"); + + BPY_clear_bad_scriptlinks(textobj->text); + free_text_controllers(textobj->text); + unlink_text(textobj->text); + /*@We actually should not free the text object here, but let the + * __del__ method of the wrapper do the job. This would require some + * changes in the GUI code though.. + * So we mark the wrapper as invalid by setting wrapper->data = 0 */ + free_libblock(&G.main->text, textobj->text); + + textobj->text = NULL; /* XXX */ + Py_XDECREF(textobj); /* XXX just a guess -- works ? */ + + Py_INCREF(Py_None); + return Py_None; +} + +/*****************************************************************************/ +/* Function: M_Text_Init */ +/*****************************************************************************/ +PyObject *M_Text_Init (void) +{ + PyObject *submodule; + + printf ("In M_Text_Init()\n"); + + submodule = Py_InitModule3("Blender.Text", M_Text_methods, M_Text_doc); + + return (submodule); +} + +/*****************************************************************************/ +/* Python C_Text methods: */ +/*****************************************************************************/ +static PyObject *Text_getName(C_Text *self) +{ + PyObject *attr = PyString_FromString(self->text->id.name+2); + + if (attr) return attr; + + return EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get Text.name attribute"); +} + +static PyObject *Text_getFilename(C_Text *self) +{ + PyObject *attr = PyString_FromString(self->text->name); + + if (attr) return attr; + + return EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get Text.filename attribute"); +} + +static PyObject *Text_getNLines(C_Text *self) +{ /* text->nlines isn't updated in Blender (?) */ + int nlines = 0; + TextLine *line; + PyObject *attr; + + line = self->text->lines.first; + + while (line) { /* so we have to count them ourselves */ + line = line->next; + nlines++; + } + + self->text->nlines = nlines; /* and update Blender, too (should we?) */ + + attr = PyInt_FromLong(nlines); + + if (attr) return attr; + + return EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get Text.nlines attribute"); +} + +static PyObject *Text_rename(C_Text *self, PyObject *args) +{ + char *name; + char buf[21]; + + if (!PyArg_ParseTuple(args, "s", &name)) + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected string argument")); + + PyOS_snprintf(buf, sizeof(buf), "%s", name); + + rename_id(&self->text->id, buf); + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *Text_clear(C_Text *self, PyObject *args) +{ + int oldstate; + + if (!self->text) + return EXPP_ReturnPyObjError (PyExc_RuntimeError, + "This object isn't linked to a Blender Text Object"); + + oldstate = txt_get_undostate(); + txt_set_undostate(1); + txt_sel_all(self->text); + txt_cut_sel(self->text); + txt_set_undostate(oldstate); + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *Text_set(C_Text *self, PyObject *args) +{ + int ival; + char *attr; + + if (!PyArg_ParseTuple(args, "si", &attr, &ival)) + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected a string and an int as arguments"); + + if (strcmp("follow_cursor", attr) == 0) { + if (ival) + self->text->flags |= EXPP_TEXT_MODE_FOLLOW; + else + self->text->flags &= EXPP_TEXT_MODE_FOLLOW; + } + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *Text_write(C_Text *self, PyObject *args) +{ + char *str; + int oldstate; + + if (!self->text) + return EXPP_ReturnPyObjError (PyExc_RuntimeError, + "This object isn't linked to a Blender Text Object"); + + if (!PyArg_ParseTuple(args, "s", &str)) + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected a string argument"); + + oldstate = txt_get_undostate(); + txt_insert_buf(self->text, str); + txt_move_eof(self->text, 0); + txt_set_undostate(oldstate); + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *Text_asLines(C_Text *self, PyObject *args) +{ + TextLine *line; + PyObject *list, *ob; + + if (!self->text) + return EXPP_ReturnPyObjError (PyExc_RuntimeError, + "This object isn't linked to a Blender Text Object"); + + line = self->text->lines.first; + list= PyList_New(0); + + if (!list) + return EXPP_ReturnPyObjError (PyExc_MemoryError, + "couldn't create PyList"); + + while (line) { + ob = Py_BuildValue("s", line->line); + PyList_Append(list, ob); + line = line->next; + } + + return list; +} + +/*****************************************************************************/ +/* Function: TextDeAlloc */ +/* Description: This is a callback function for the C_Text type. It is */ +/* the destructor function. */ +/*****************************************************************************/ +static void TextDeAlloc (C_Text *self) +{ + PyObject_DEL (self); +} + +/*****************************************************************************/ +/* Function: TextGetAttr */ +/* Description: This is a callback function for the C_Text type. It is */ +/* the function that accesses C_Text member variables and */ +/* methods. */ +/*****************************************************************************/ +static PyObject* TextGetAttr (C_Text *self, char *name) +{ + PyObject *attr = Py_None; + + if (strcmp(name, "name") == 0) + attr = PyString_FromString(self->text->id.name+2); + else if (strcmp(name, "filename") == 0) + attr = PyString_FromString(self->text->name); + else if (strcmp(name, "mode") == 0) + attr = PyInt_FromLong(self->text->flags); + else if (strcmp(name, "nlines") == 0) + attr = Text_getNLines(self); + + else if (strcmp(name, "__members__") == 0) + attr = Py_BuildValue("[s,s,s,s]", + "name", "filename", "mode", "nlines"); + + if (!attr) + return (EXPP_ReturnPyObjError (PyExc_MemoryError, + "couldn't create PyObject")); + + if (attr != Py_None) return attr; /* attribute found, return its value */ + + /* not an attribute, search the methods table */ + return Py_FindMethod(C_Text_methods, (PyObject *)self, name); +} + +/*****************************************************************************/ +/* Function: TextSetAttr */ +/* Description: This is a callback function for the C_Text type. It is the */ +/* function that changes Text Data members values. If this */ +/* data is linked to a Blender Text, it also gets updated. */ +/*****************************************************************************/ +static int TextSetAttr (C_Text *self, char *name, PyObject *value) +{ + PyObject *valtuple; + PyObject *error = NULL; + +/* We're playing a trick on the Python API users here. Even if they use + * Text.member = val instead of Text.setMember(value), we end up using the + * function anyway, since it already has error checking, clamps to the right + * interval and updates the Blender Text structure when necessary. */ + + valtuple = Py_BuildValue("(N)", value); /* the set* functions expect a tuple */ + + if (!valtuple) + return EXPP_ReturnIntError(PyExc_MemoryError, + "TextSetAttr: couldn't create PyTuple"); + + if (strcmp (name, "name") == 0) + error = Text_rename (self, valtuple); + else { /* Error: no such member in the Text Data structure */ + Py_DECREF(value); + Py_DECREF(valtuple); + return (EXPP_ReturnIntError (PyExc_KeyError, + "attribute not found or immutable")); + } + + Py_DECREF(valtuple); + + if (error != Py_None) return -1; + + Py_DECREF(Py_None); /* incref'ed by the called set* function */ + return 0; /* normal exit */ +} + +/*****************************************************************************/ +/* Function: TextPrint */ +/* Description: This is a callback function for the C_Text type. It */ +/* builds a meaninful string to 'print' text objects. */ +/*****************************************************************************/ +static int TextPrint(C_Text *self, FILE *fp, int flags) +{ + fprintf(fp, "[Text \"%s\"]", self->text->id.name+2); + return 0; +} + +/*****************************************************************************/ +/* Function: TextRepr */ +/* Description: This is a callback function for the C_Text type. It */ +/* builds a meaninful string to represent text objects. */ +/*****************************************************************************/ +static PyObject *TextRepr (C_Text *self) +{ + return PyString_FromString(self->text->id.name+2); +} diff --git a/source/blender/python/api2_2x/Text.h b/source/blender/python/api2_2x/Text.h new file mode 100644 index 00000000000..5b5d5b149e2 --- /dev/null +++ b/source/blender/python/api2_2x/Text.h @@ -0,0 +1,178 @@ +/* + * + * ***** 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): Willian P. Germano + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** +*/ + +#ifndef EXPP_TEXT_H +#define EXPP_TEXT_H + +#include <Python.h> +#include <stdio.h> + +#include <BKE_main.h> +#include <BKE_global.h> +#include <BKE_library.h> +#include <BKE_sca.h> +#include <BIF_drawtext.h> +#include <BKE_text.h> +#include <DNA_text_types.h> + +#include "gen_utils.h" +#include "modules.h" +#include "../BPY_extern.h" + +#define EXPP_TEXT_MODE_FOLLOW TXT_FOLLOW + +/*****************************************************************************/ +/* Python API function prototypes for the Text module. */ +/*****************************************************************************/ +static PyObject *M_Text_New (PyObject *self, PyObject *args, + PyObject *keywords); +static PyObject *M_Text_Get (PyObject *self, PyObject *args); +static PyObject *M_Text_Load (PyObject *self, PyObject *args); +static PyObject *M_Text_unlink (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.Text.__doc__ */ +/*****************************************************************************/ +static char M_Text_doc[] = +"The Blender Text module\n\n"; + +static char M_Text_New_doc[] = +"() - return a new Text object"; + +static char M_Text_Get_doc[] = +"(name) - return the Text with name 'name', \ +returns None if not found.\n If 'name' is not specified, \ +it returns a list of all Texts in the\ncurrent scene."; + +static char M_Text_Load_doc[] = +"(filename) - return text from file filename as Text Object, \ +returns None if not found.\n"; + +static char M_Text_unlink_doc[] = +"(text) - remove text object 'text' from the text window"; + +/*****************************************************************************/ +/* Python method structure definition for Blender.Text module: */ +/*****************************************************************************/ +struct PyMethodDef M_Text_methods[] = { + {"New",(PyCFunction)M_Text_New, METH_VARARGS|METH_KEYWORDS, + M_Text_New_doc}, + {"Get", M_Text_Get, METH_VARARGS, M_Text_Get_doc}, + {"get", M_Text_Get, METH_VARARGS, M_Text_Get_doc}, + {"Load", M_Text_Load, METH_VARARGS, M_Text_Load_doc}, + {"unlink", M_Text_unlink, METH_VARARGS, M_Text_unlink_doc}, + {NULL, NULL, 0, NULL} +}; + +/*****************************************************************************/ +/* Python C_Text structure definition: */ +/*****************************************************************************/ +typedef struct { + PyObject_HEAD + Text *text; +} C_Text; + +/*****************************************************************************/ +/* Python C_Text methods declarations: */ +/*****************************************************************************/ +static PyObject *Text_getName(C_Text *self); +static PyObject *Text_getFilename(C_Text *self); +static PyObject *Text_getNLines(C_Text *self); +static PyObject *Text_rename(C_Text *self, PyObject *args); +static PyObject *Text_clear(C_Text *self, PyObject *args); +static PyObject *Text_write(C_Text *self, PyObject *args); +static PyObject *Text_set(C_Text *self, PyObject *args); +static PyObject *Text_asLines(C_Text *self, PyObject *args); + +/*****************************************************************************/ +/* Python C_Text methods table: */ +/*****************************************************************************/ +static PyMethodDef C_Text_methods[] = { + /* name, method, flags, doc */ + {"getName", (PyCFunction)Text_getName, METH_NOARGS, + "() - Return Text Object name"}, + {"getFilename", (PyCFunction)Text_getFilename, METH_VARARGS, + "() - Return Text Object filename"}, + {"getNLines", (PyCFunction)Text_getNLines, METH_VARARGS, + "() - Return number of lines in text buffer"}, + {"rename", (PyCFunction)Text_rename, METH_VARARGS, + "(str) - Change Text Object name"}, + {"clear", (PyCFunction)Text_clear, METH_VARARGS, + "() - Clear Text buffer"}, + {"write", (PyCFunction)Text_write, METH_VARARGS, + "(line) - Append string 'str' to Text buffer"}, + {"set", (PyCFunction)Text_set, METH_VARARGS, + "(name, val) - Set attribute 'name' to value 'val'"}, + {"asLines", (PyCFunction)Text_asLines, METH_VARARGS, + "() - Return text buffer as a list of lines"}, + {0} +}; + +/*****************************************************************************/ +/* Python Text_Type callback function prototypes: */ +/*****************************************************************************/ +static void TextDeAlloc (C_Text *cam); +static int TextPrint (C_Text *cam, FILE *fp, int flags); +static int TextSetAttr (C_Text *cam, char *name, PyObject *v); +static PyObject *TextGetAttr (C_Text *cam, char *name); +static PyObject *TextRepr (C_Text *cam); + +/*****************************************************************************/ +/* Python Text_Type structure definition: */ +/*****************************************************************************/ +static PyTypeObject Text_Type = +{ + PyObject_HEAD_INIT(&PyType_Type) + 0, /* ob_size */ + "Text", /* tp_name */ + sizeof (C_Text), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + (destructor)TextDeAlloc, /* tp_dealloc */ + (printfunc)TextPrint, /* tp_print */ + (getattrfunc)TextGetAttr, /* tp_getattr */ + (setattrfunc)TextSetAttr, /* tp_setattr */ + 0, /* tp_compare */ + (reprfunc)TextRepr, /* 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, + C_Text_methods, /* tp_methods */ + 0, /* tp_members */ +}; + +#endif /* EXPP_TEXT_H */ diff --git a/source/blender/python/api2_2x/modules.h b/source/blender/python/api2_2x/modules.h index 20ea92cf2d7..ecf3cad2fc9 100644 --- a/source/blender/python/api2_2x/modules.h +++ b/source/blender/python/api2_2x/modules.h @@ -49,3 +49,4 @@ PyObject *M_Image_Init (void); PyObject *M_Window_Init (void); PyObject *M_Draw_Init (void); PyObject *M_BGL_Init (void); +PyObject *M_Text_Init (void); |