]> git.sesse.net Git - vlc/blob - bindings/python/vlc_internal.c
python bindings:
[vlc] / bindings / python / vlc_internal.c
1 /*****************************************************************************
2  * vlc_internal.c: vlcinternal python binding module
3  *****************************************************************************
4  * Copyright (C) 2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Olivier Aubert <oaubert at bat710.univ-lyon1.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #include "vlc_internal.h"
25
26 /**************************************************************************
27  * VLC Module
28  **************************************************************************/
29
30 #ifndef vlcinternalMODINIT_FUNC /* declarations for DLL import/export */
31 #define vlcinternalMODINIT_FUNC void
32 #endif
33
34 static PyMethodDef vlcinternal_methods[] = {
35     { NULL }  /* Sentinel */
36 };
37
38 vlcinternalMODINIT_FUNC
39 initvlcinternal( void )
40 {
41     PyObject* p_module;
42
43     p_module = Py_InitModule3( "vlcinternal", vlcinternal_methods,
44                                "VLC media player internal module" );
45
46     if( !p_module )
47       return;
48
49     if( PyType_Ready( &vlcObject_Type ) < 0 )
50         return;
51
52     /* Types */
53     Py_INCREF( &vlcObject_Type );
54     PyModule_AddObject( p_module, "Object",
55                         ( PyObject * )&vlcObject_Type );
56 }
57
58
59 /* Make libpostproc happy... */
60 void * fast_memcpy( void * to, const void * from, size_t len )
61 {
62   return memcpy( to, from, len );
63 }
64
65 /*****************************************************************************
66  * VLCObject implementation
67  *****************************************************************************/
68
69 static PyObject
70 *vlcObject_new( PyTypeObject *p_type, PyObject *p_args, PyObject *p_kwds )
71 {
72     vlcObject *self;
73     vlc_object_t *p_object;
74     int i_id;
75
76     self = PyObject_New( vlcObject, &vlcObject_Type );
77
78     if( !PyArg_ParseTuple( p_args, "i", &i_id ) )
79       return NULL;
80
81     /* Maybe we were already initialized */
82     p_object = ( vlc_object_t* )vlc_current_object( i_id );
83
84     if( !p_object )
85     {
86         /* Try to initialize */
87         i_id = VLC_Create();
88         if( i_id < 0 )
89         {
90             PyErr_SetString( PyExc_StandardError, "Unable to create a VLC instance." );
91             return NULL;
92         }
93         p_object = ( vlc_object_t* )vlc_current_object( i_id );
94     }
95
96     if( !p_object )
97     {
98         PyErr_SetString( PyExc_StandardError, "Unable to get object." );
99         return NULL;
100     }
101
102     self->p_object = p_object;
103     self->b_released = 0;
104
105     Py_INCREF(  self ); /* Ah bon ? */
106     return ( PyObject * )self;
107 }
108
109 static PyObject *
110 vlcObject_release(  PyObject *self, PyObject *p_args )
111 {
112     if( VLCSELF->b_released == 0 )
113     {
114         vlc_object_release( VLCSELF->p_object );
115         VLCSELF->b_released = 1;
116     }
117     Py_INCREF(  Py_None );
118     return Py_None;
119 }
120
121 static void
122 vlcObject_dealloc( PyObject *self )
123 {
124     vlcObject_release( self, NULL );
125     PyMem_DEL( self );
126 }
127
128 static PyObject *
129 vlcObject_find_object( PyObject *self, PyObject *args )
130 {
131     vlcObject *p_retval;
132     vlc_object_t *p_obj;
133     char *psz_name;
134     int i_object_type;
135
136     if( !PyArg_ParseTuple( args, "s", &psz_name ) )
137         return NULL;
138
139     /* psz_name is in
140        ( aout, decoder, input, httpd, intf, playlist, root, vlc, vout )
141     */
142     if( !strncmp( psz_name, "aout", 4 ) )
143     {
144         i_object_type = VLC_OBJECT_AOUT;
145     }
146     else if (! strncmp( psz_name, "decoder", 7 ) )
147     {
148         i_object_type = VLC_OBJECT_DECODER;
149     }
150     else if (! strncmp( psz_name, "httpd", 5 ) )
151     {
152             i_object_type = VLC_OBJECT_HTTPD;
153     }
154     else if (! strncmp( psz_name, "intf", 4 ) )
155     {
156         i_object_type = VLC_OBJECT_INTF;
157     }
158     else if (! strncmp( psz_name, "input", 5 ) )
159     {
160         i_object_type = VLC_OBJECT_INPUT;
161     }
162     else if (! strncmp( psz_name, "playlist", 8 ) )
163     {
164         i_object_type = VLC_OBJECT_PLAYLIST;
165     }
166     else if (! strncmp( psz_name, "libvlc", 6 ) )
167     {
168         i_object_type = VLC_OBJECT_LIBVLC;
169     }
170     else if (! strncmp( psz_name, "vout", 4 ) )
171     {
172         i_object_type = VLC_OBJECT_VOUT;
173     }
174     else if (! strncmp( psz_name, "sout", 4 ) )
175     {
176         i_object_type = VLC_OBJECT_SOUT;
177     }
178     else if (! strncmp( psz_name, "global", 6 ) )
179     {
180         i_object_type = VLC_OBJECT_GLOBAL;
181     }
182     else if (! strncmp( psz_name, "packetizer", 10 ) )
183     {
184         i_object_type = VLC_OBJECT_PACKETIZER;
185     }
186     else if (! strncmp( psz_name, "encoder", 7 ) )
187     {
188         i_object_type = VLC_OBJECT_ENCODER;
189     }
190     else if (! strncmp( psz_name, "vlm", 3 ) )
191     {
192         i_object_type = VLC_OBJECT_VLM;
193     }
194     else if (! strncmp( psz_name, "announce", 8 ) )
195     {
196         i_object_type = VLC_OBJECT_ANNOUNCE;
197     }
198     else if (! strncmp( psz_name, "demux", 5 ) )
199     {
200         i_object_type = VLC_OBJECT_DEMUX;
201     }
202     else if (! strncmp( psz_name, "access", 6 ) )
203     {
204         i_object_type = VLC_OBJECT_ACCESS;
205     }
206     else if (! strncmp( psz_name, "stream", 6 ) )
207     {
208         i_object_type = VLC_OBJECT_STREAM;
209     }
210     else if (! strncmp( psz_name, "filter", 6 ) )
211     {
212         i_object_type = VLC_OBJECT_FILTER;
213     }
214     else if (! strncmp( psz_name, "vod", 3 ) )
215     {
216         i_object_type = VLC_OBJECT_VOD;
217     }
218     else if (! strncmp( psz_name, "xml", 3 ) )
219     {
220         i_object_type = VLC_OBJECT_XML;
221     }
222     else if (! strncmp( psz_name, "osdmenu", 7 ) )
223     {
224         i_object_type = VLC_OBJECT_OSDMENU;
225     }
226     else if (! strncmp( psz_name, "stats", 5 ) )
227     {
228         i_object_type = VLC_OBJECT_STATS;
229     }
230     else if (! strncmp( psz_name, "metaengine", 10 ) )
231     {
232         i_object_type = VLC_OBJECT_META_ENGINE;
233     }
234     else
235     {
236         /* FIXME: raise an exception ? */
237         Py_INCREF( Py_None );
238         return Py_None;
239     }
240
241     p_obj = vlc_object_find( VLCSELF->p_object, i_object_type, FIND_ANYWHERE );
242
243     if( !p_obj )
244     {
245         Py_INCREF( Py_None );
246         return Py_None;
247     }
248
249     p_retval = PyObject_New( vlcObject, &vlcObject_Type );
250
251     p_retval->p_object = p_obj;
252
253     return ( PyObject * )p_retval;
254 }
255
256 static PyObject *
257 vlcObject_info( PyObject *self, PyObject *args )
258 {
259     PyObject *p_retval;
260     vlc_object_t *p_obj;
261
262     p_obj = VLCSELF->p_object;
263
264     /* Return information about the object as a dict. */
265     p_retval = PyDict_New();
266
267     PyDict_SetItemString( p_retval, "object-id",
268                           Py_BuildValue( "l", p_obj->i_object_id ) );
269     PyDict_SetItemString( p_retval, "object-type",
270                           Py_BuildValue( "s", p_obj->psz_object_type ) );
271     PyDict_SetItemString( p_retval, "object-name",
272                           Py_BuildValue( "s", p_obj->psz_object_name ) );
273     PyDict_SetItemString( p_retval, "thread",
274                           PyBool_FromLong( p_obj->b_thread ) );
275     PyDict_SetItemString( p_retval, "thread-id",
276                           PyLong_FromLongLong( p_obj->thread_id ) );
277     PyDict_SetItemString( p_retval, "refcount",
278                           PyInt_FromLong( p_obj->i_refcount ) );
279
280     return p_retval;
281 }
282
283 static PyObject *
284 vlcObject_find_id( PyObject *self, PyObject *args )
285 {
286     vlcObject *p_retval;
287     vlc_object_t* p_object;
288     int i_id;
289
290     if( !PyArg_ParseTuple( args, "i", &i_id ) )
291         return NULL;
292
293     p_object = ( vlc_object_t* )vlc_current_object( i_id );
294
295     if( !p_object )
296     {
297         Py_INCREF( Py_None );
298         return Py_None;
299     }
300
301     p_retval = PyObject_NEW( vlcObject, &vlcObject_Type );
302
303     p_retval->p_object = p_object;
304
305     return ( PyObject * )p_retval;
306 }
307
308 /* Do a var_Get call on the object. Parameter: the variable name. */
309 static PyObject *
310 vlcObject_var_get( PyObject *self, PyObject *args )
311 {
312     PyObject *p_retval;
313     vlc_value_t value;
314     char *psz_name;
315     int i_type;
316
317     if( !PyArg_ParseTuple( args, "s", &psz_name ) )
318         return NULL;
319
320     if( var_Get( VLCSELF->p_object, psz_name, &value ) != VLC_SUCCESS )
321     {
322         PyErr_SetString( PyExc_StandardError,
323                          "Error: variable does not exist.\n" );
324         return NULL;
325     }
326
327     i_type = var_Type ( VLCSELF->p_object, psz_name );
328
329     switch ( i_type )
330     {
331     case VLC_VAR_VOID      :
332         p_retval = PyString_FromString( "A void variable" );
333         break;
334     case VLC_VAR_BOOL      :
335         p_retval = PyBool_FromLong( value.b_bool );
336         break;
337     case VLC_VAR_INTEGER   :
338         p_retval = PyInt_FromLong( ( long )value.i_int );
339         break;
340     case VLC_VAR_HOTKEY    :
341         p_retval = PyString_FromFormat( "A hotkey variable ( %d )", value.i_int );
342         break;
343     case VLC_VAR_FILE      :
344     case VLC_VAR_STRING    :
345     case VLC_VAR_DIRECTORY :
346     case VLC_VAR_VARIABLE  :
347         p_retval = PyString_FromString( value.psz_string );
348         break;
349     case VLC_VAR_MODULE   :
350         p_retval = ( PyObject* )PyObject_New( vlcObject, &vlcObject_Type );
351         ( ( vlcObject* )p_retval )->p_object = value.p_object;
352         break;
353     case VLC_VAR_FLOAT     :
354         p_retval = PyFloat_FromDouble( ( double )value.f_float );
355         break;
356     case VLC_VAR_TIME      :
357         p_retval = PyLong_FromLongLong( value.i_time );
358         break;
359     case VLC_VAR_ADDRESS   :
360         p_retval = PyString_FromString( "A VLC address ( not handled yet )" );
361         break;
362     case VLC_VAR_LIST      :
363         p_retval = PyString_FromString( "A VLC list ( not handled yet )" );
364         break;
365     case VLC_VAR_MUTEX :
366         p_retval = PyString_FromString( "A mutex" );
367         break;
368     default:
369         p_retval = Py_None;
370     }
371
372     Py_INCREF( p_retval );
373     return p_retval;
374 }
375
376 static PyObject *
377 vlcObject_var_type( PyObject *self, PyObject *args )
378 {
379     char *psz_name;
380     PyObject *p_retval;
381     int i_type;
382
383     if( !PyArg_ParseTuple( args, "s", &psz_name ) )
384         return NULL;
385
386     i_type = var_Type( VLCSELF->p_object, psz_name );
387
388     switch ( i_type )
389     {
390     case VLC_VAR_VOID   :
391         p_retval = PyString_FromString( "Void" );
392         break;
393     case VLC_VAR_BOOL      :
394         p_retval = PyString_FromString( "Boolean" );
395         break;
396     case VLC_VAR_INTEGER   :
397         p_retval = PyString_FromString( "Integer" );
398         break;
399     case VLC_VAR_HOTKEY   :
400         p_retval = PyString_FromString( "Hotkey" );
401         break;
402     case VLC_VAR_FILE      :
403         p_retval = PyString_FromString( "File" );
404         break;
405     case VLC_VAR_STRING    :
406         p_retval = PyString_FromString( "String" );
407         break;
408     case VLC_VAR_DIRECTORY :
409         p_retval = PyString_FromString( "Directory" );
410         break;
411     case VLC_VAR_VARIABLE  :
412         p_retval = PyString_FromString( "Variable" );
413         break;
414     case VLC_VAR_MODULE   :
415         p_retval = PyString_FromString( "Module" );
416         break;
417     case VLC_VAR_FLOAT     :
418         p_retval = PyString_FromString( "Float" );
419         break;
420     case VLC_VAR_TIME      :
421         p_retval = PyString_FromString( "Time" );
422         break;
423     case VLC_VAR_ADDRESS   :
424         p_retval = PyString_FromString( "Address" );
425         break;
426     case VLC_VAR_LIST      :
427         p_retval = PyString_FromString( "List" );
428         break;
429     case VLC_VAR_MUTEX :
430         p_retval = PyString_FromString( "Mutex" );
431         break;
432     default:
433         p_retval = PyString_FromString( "Unknown" );
434     }
435     return p_retval;
436 }
437
438 /* Do a var_Set call on the object. Parameter: the variable name. */
439 static PyObject *
440 vlcObject_var_set( PyObject *self, PyObject *args )
441 {
442     vlc_value_t value;
443     char *psz_name;
444     PyObject *py_value;
445     int i_type;
446     vlc_object_t *p_obj;
447
448     if( !PyArg_ParseTuple( args, "sO", &psz_name, &py_value ) )
449         return NULL;
450
451     p_obj = VLCSELF->p_object;
452     i_type = var_Type( p_obj, psz_name );
453
454     switch ( i_type )
455     {
456     case VLC_VAR_VOID   :
457         break;
458     case VLC_VAR_BOOL      :
459         value.b_bool = PyInt_AsLong( py_value );
460         break;
461     case VLC_VAR_INTEGER   :
462     case VLC_VAR_HOTKEY   :
463         value.i_int = PyInt_AsLong( py_value );
464         break;
465     case VLC_VAR_FILE      :
466     case VLC_VAR_STRING    :
467     case VLC_VAR_DIRECTORY :
468     case VLC_VAR_VARIABLE  :
469         value.psz_string = strdup( PyString_AsString( py_value ) );
470         break;
471     case VLC_VAR_MODULE   :
472         /* FIXME: we should check the PyObject type and get its p_object */
473         value.p_object = ( ( vlcObject* )p_obj )->p_object;
474         break;
475     case VLC_VAR_FLOAT     :
476         value.f_float = PyFloat_AsDouble( py_value );
477         break;
478     case VLC_VAR_TIME      :
479         value.i_time = PyLong_AsLongLong( py_value );
480         break;
481     case VLC_VAR_ADDRESS   :
482         value.p_address = ( char* )PyLong_AsVoidPtr( py_value );
483         break;
484     case VLC_VAR_LIST      :
485         /* FIXME */
486         value.p_list = NULL;
487         break;
488     case VLC_VAR_MUTEX :
489         break;
490     }
491
492     var_Set( p_obj, psz_name, value );
493
494     Py_INCREF( Py_None );
495     return Py_None;
496 }
497
498 static PyObject *
499 vlcObject_var_list( PyObject *self, PyObject *args )
500 {
501     PyObject *p_retval;
502     Py_ssize_t i_size;
503     Py_ssize_t i_index;
504
505     i_size = VLCSELF->p_object->i_vars;
506     p_retval = PyTuple_New( i_size );
507
508     for ( i_index = 0 ; i_index < i_size ; i_index++ )
509     {
510         PyTuple_SetItem( p_retval, i_index,
511                          Py_BuildValue( "s", VLCSELF->p_object->p_vars[i_index].psz_name ) );
512     }
513
514     return p_retval;
515 }
516
517 /* Do a config_Get call on the object. Parameter: the variable name. */
518 static PyObject *
519 vlcObject_config_get( PyObject *self, PyObject *args )
520 {
521     PyObject *p_retval;
522     vlc_value_t value;
523     char *psz_name;
524     module_config_t *p_config;
525
526     if( !PyArg_ParseTuple( args, "s", &psz_name ) )
527         return NULL;
528
529     p_config = config_FindConfig( VLCSELF->p_object, psz_name );
530
531     if( !p_config )
532     {
533         PyErr_SetString( PyExc_StandardError,
534                          "Error: config variable does not exist.\n" );
535         return NULL;
536     }
537
538     switch ( p_config->i_type )
539     {
540     case CONFIG_ITEM_BOOL      :
541         p_retval = PyBool_FromLong( p_config->value.i );
542         break;
543     case CONFIG_ITEM_INTEGER   :
544         p_retval = PyInt_FromLong( ( long )p_config->value.i );
545         break;
546     case CONFIG_ITEM_KEY   :
547         p_retval = PyString_FromFormat( "A hotkey variable ( %d )", p_config->value.i );
548         break;
549     case CONFIG_ITEM_FILE      :
550     case CONFIG_ITEM_STRING    :
551     case CONFIG_ITEM_DIRECTORY :
552     case CONFIG_ITEM_MODULE    :
553         vlc_mutex_lock( p_config->p_lock );
554         if( p_config->value.psz )
555             p_retval = PyString_FromString( p_config->value.psz );
556         else
557             p_retval = PyString_FromString( "" );
558         vlc_mutex_unlock( p_config->p_lock );
559         break;
560         p_retval = ( PyObject* )PyObject_New( vlcObject, &vlcObject_Type );
561         ( ( vlcObject* )p_retval )->p_object = value.p_object;
562         break;
563     case CONFIG_ITEM_FLOAT     :
564         p_retval = PyFloat_FromDouble( ( double )p_config->value.f );
565         break;
566     default:
567         p_retval = Py_None;
568         Py_INCREF( p_retval );
569     }
570
571     return p_retval;
572 }
573
574 /* Do a config_put* call on the object. Parameter: the variable name. */
575 static PyObject *
576 vlcObject_config_set( PyObject *self, PyObject *args )
577 {
578     char *psz_name;
579     PyObject *py_value;
580     vlc_object_t *p_obj;
581     module_config_t *p_config;
582
583
584     if( !PyArg_ParseTuple( args, "sO", &psz_name, &py_value ) )
585         return NULL;
586
587     p_obj = VLCSELF->p_object;
588     p_config = config_FindConfig( p_obj, psz_name );
589     /* sanity checks */
590     if( !p_config )
591     {
592         PyErr_SetString( PyExc_StandardError,
593                          "Error: option does not exist.\n" );
594         return NULL;
595     }
596
597     switch ( p_config->i_type )
598     {
599     case CONFIG_ITEM_BOOL      :
600     case CONFIG_ITEM_INTEGER   :
601     case CONFIG_ITEM_KEY       :
602         config_PutInt( p_obj, psz_name, PyInt_AsLong( py_value ) );
603         break;
604     case CONFIG_ITEM_FILE      :
605     case CONFIG_ITEM_STRING    :
606     case CONFIG_ITEM_DIRECTORY :
607     case CONFIG_ITEM_MODULE   :
608         config_PutPsz( p_obj, psz_name, PyString_AsString( py_value ) );
609         break;
610     case CONFIG_ITEM_FLOAT     :
611         config_PutFloat( p_obj, psz_name, PyFloat_AsDouble( py_value ) );
612         break;
613     }
614     Py_INCREF( Py_None );
615     return Py_None;
616 }
617
618 static PyObject *
619 vlcObject_children( PyObject *self, PyObject *args )
620 {
621     PyObject *p_retval;
622     Py_ssize_t i_size;
623     Py_ssize_t i_index;
624
625     i_size = VLCSELF->p_object->i_children;
626     p_retval = PyTuple_New( i_size );
627
628     for ( i_index = 0 ; i_index < i_size ; i_index++ )
629     {
630         PyTuple_SetItem( p_retval, i_index,
631                          Py_BuildValue( "i",
632                                         VLCSELF->p_object->pp_children[i_index]->i_object_id ) );
633     }
634
635     return p_retval;
636 }
637
638
639 /* Method table */
640 static PyMethodDef vlcObject_methods[] =
641 {
642     { "get", vlcObject_var_get, METH_VARARGS,
643       "get( str ) -> value   Get a variable value."},
644     { "set", vlcObject_var_set, METH_VARARGS,
645       "set( str, value )     Set a variable value" },
646     { "config_get", vlcObject_config_get, METH_VARARGS,
647       "config_get( str ) -> value   Get a configuration option." },
648     { "config_set", vlcObject_config_set, METH_VARARGS,
649       "config_set( str, value )     Set a configuration option" },
650     { "type", vlcObject_var_type, METH_VARARGS,
651       "type( str ) -> str     Get a variable type" },
652     { "list", vlcObject_var_list, METH_NOARGS,
653       "list( )             List the available variables" },
654     { "children", vlcObject_children, METH_NOARGS,
655       "children( )             List the children ids" },
656     { "find_object", vlcObject_find_object, METH_VARARGS,
657       "find_object( str ) -> Object     Find the object of a given type.\n\nAvailable types are : aout, decoder, input, httpd, intf, playlist, root, vlc, vout"},
658     { "find_id", vlcObject_find_id, METH_VARARGS,
659       "find_id( int ) -> Object      Find an object by id" },
660     { "info", vlcObject_info, METH_NOARGS,
661        "info( ) -> dict    Return information about the object" },
662     { "release", vlcObject_release, METH_NOARGS,
663       "release( ) ->     Release the VLC Object" },
664     { NULL, NULL, 0, NULL },
665 };
666
667 static PyTypeObject vlcObject_Type =
668 {
669     PyObject_HEAD_INIT( NULL )
670     0,                         /*ob_size*/
671     "vlc.Object",       /*tp_name*/
672     sizeof( vlcObject_Type ), /*tp_basicsize*/
673     0,                         /*tp_itemsize*/
674     ( destructor )vlcObject_dealloc,      /*tp_dealloc*/
675     0,                         /*tp_print*/
676     0,                         /*tp_getattr*/
677     0,                         /*tp_setattr*/
678     0,                         /*tp_compare*/
679     0,                         /*tp_repr*/
680     0,                         /*tp_as_number*/
681     0,                         /*tp_as_sequence*/
682     0,                         /*tp_as_mapping*/
683     0,                         /*tp_hash */
684     0,                         /*tp_call*/
685     0,                         /*tp_str*/
686     0,                         /*tp_getattro*/
687     0,                         /*tp_setattro*/
688     0,                         /*tp_as_buffer*/
689     Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
690     "Expose VLC object infrastructure.\n\nConstructor: vlc.Object(object_id)",  /* tp_doc */
691     0,                     /* tp_traverse */
692     0,                     /* tp_clear */
693     0,                     /* tp_richcompare */
694     0,                     /* tp_weaklistoffset */
695     0,                     /* tp_iter */
696     0,                     /* tp_iternext */
697     vlcObject_methods,             /* tp_methods */
698     0,             /* tp_members */
699     0,                         /* tp_getset */
700     0,                         /* tp_base */
701     0,                         /* tp_dict */
702     0,                         /* tp_descr_get */
703     0,                         /* tp_descr_set */
704     0,                         /* tp_dictoffset */
705     0,                         /* tp_init */
706     0,                         /* tp_alloc */
707     vlcObject_new,          /* tp_new */
708 };