Made the Freestyle Python API compatible with Python 3.
[blender.git] / source / blender / freestyle / intern / python / StrokeShader / BPy_StrokeTextureShader.cpp
1 #include "BPy_StrokeTextureShader.h"
2
3 #include "../../stroke/BasicStrokeShaders.h"
4 #include "../BPy_Convert.h"
5 #include "../BPy_MediumType.h"
6
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10
11 ///////////////////////////////////////////////////////////////////////////////////////////
12
13 /*---------------  Python API function prototypes for StrokeTextureShader instance  -----------*/
14 static int StrokeTextureShader___init__( BPy_StrokeTextureShader* self, PyObject *args);
15
16 /*-----------------------BPy_StrokeTextureShader type definition ------------------------------*/
17
18 PyTypeObject StrokeTextureShader_Type = {
19         PyObject_HEAD_INIT(NULL)
20         "StrokeTextureShader",          /* tp_name */
21         sizeof(BPy_StrokeTextureShader), /* tp_basicsize */
22         0,                              /* tp_itemsize */
23         0,                              /* tp_dealloc */
24         0,                              /* tp_print */
25         0,                              /* tp_getattr */
26         0,                              /* tp_setattr */
27         0,                              /* tp_reserved */
28         0,                              /* tp_repr */
29         0,                              /* tp_as_number */
30         0,                              /* tp_as_sequence */
31         0,                              /* tp_as_mapping */
32         0,                              /* tp_hash  */
33         0,                              /* tp_call */
34         0,                              /* tp_str */
35         0,                              /* tp_getattro */
36         0,                              /* tp_setattro */
37         0,                              /* tp_as_buffer */
38         Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
39         "StrokeTextureShader objects",  /* tp_doc */
40         0,                              /* tp_traverse */
41         0,                              /* tp_clear */
42         0,                              /* tp_richcompare */
43         0,                              /* tp_weaklistoffset */
44         0,                              /* tp_iter */
45         0,                              /* tp_iternext */
46         0,                              /* tp_methods */
47         0,                              /* tp_members */
48         0,                              /* tp_getset */
49         &StrokeShader_Type,             /* tp_base */
50         0,                              /* tp_dict */
51         0,                              /* tp_descr_get */
52         0,                              /* tp_descr_set */
53         0,                              /* tp_dictoffset */
54         (initproc)StrokeTextureShader___init__, /* tp_init */
55         0,                              /* tp_alloc */
56         0,                              /* tp_new */
57 };
58
59 //------------------------INSTANCE METHODS ----------------------------------
60
61 int StrokeTextureShader___init__( BPy_StrokeTextureShader* self, PyObject *args)
62 {
63         const char *s1;
64         PyObject *obj2 = 0, *obj3 = 0;
65         
66         if(!( PyArg_ParseTuple(args, "s|O!O", &s1, &MediumType_Type, &obj2, &obj3) ))
67                 return -1;
68
69         Stroke::MediumType mt = (obj2) ? MediumType_from_BPy_MediumType(obj2) : Stroke::OPAQUE_MEDIUM; 
70         bool b = (obj3) ? bool_from_PyBool(obj3) : true;
71         
72         self->py_ss.ss = new StrokeShaders::StrokeTextureShader(s1,mt,b);
73         return 0;
74 }
75
76 ///////////////////////////////////////////////////////////////////////////////////////////
77
78 #ifdef __cplusplus
79 }
80 #endif