diff options
| author | Nicholas Piper <nicholas@users.sourceforge.net> | 2006-04-25 16:56:03 +0000 |
|---|---|---|
| committer | Nicholas Piper <nicholas@users.sourceforge.net> | 2006-04-25 16:56:03 +0000 |
| commit | faef3e315f9ce360ea660aa9179e7865109fab16 (patch) | |
| tree | 742a3ee422ad1490ccdbe84faf4bd1a1b08520f5 /bindings/python/gpod.i | |
| parent | 5447c8e683e1a2e9577237ddb14bd5664bbf725b (diff) | |
| download | libgpod-faef3e315f9ce360ea660aa9179e7865109fab16.tar.gz libgpod-faef3e315f9ce360ea660aa9179e7865109fab16.tar.xz libgpod-faef3e315f9ce360ea660aa9179e7865109fab16.zip | |
Add sw_get_rule() to extract smart playlist rules from GList*, and hopefully improve the guint8,16,32,64 handling
git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@1249 f01d2545-417e-4e96-918e-98f8d0dbbcb6
Diffstat (limited to 'bindings/python/gpod.i')
| -rw-r--r-- | bindings/python/gpod.i | 68 |
1 files changed, 56 insertions, 12 deletions
diff --git a/bindings/python/gpod.i b/bindings/python/gpod.i index 7103ecf..c6f0bbf 100644 --- a/bindings/python/gpod.i +++ b/bindings/python/gpod.i @@ -59,6 +59,16 @@ PyObject* sw_get_track(GList *list, gint index) { return SWIG_NewPointerObj((void*)(position->data), SWIGTYPE_p__Itdb_Track, 0); } +PyObject* sw_get_rule(GList *list, gint index) { + GList *position; + if ( (index >= g_list_length(list)) || index < 0 ) { + PyErr_SetString(PyExc_IndexError, "Value out of range"); + return NULL; + } + position = g_list_nth(list, index); + return SWIG_NewPointerObj((void*)(position->data), SWIGTYPE_p__SPLRule, 0); + } + PyObject* sw_get_list_len(GList *list) { return PyInt_FromLong(g_list_length(list)); } @@ -92,9 +102,11 @@ PyObject* sw_get_playlists(Itdb_iTunesDB *itdb) { typedef char gchar; %typemap(in) guint8 { - long ival; - ival = PyInt_AsLong($input); - if (( ival > 255 ) || ( ival < 0 )) { + unsigned long ival; + ival = PyInt_AsUnsignedLongMask($input); + if (PyErr_Occurred()) + SWIG_fail; + if (ival > 255) { PyErr_SetString(PyExc_ValueError, "$symname: Value must be between 0 and 255"); SWIG_fail; } else { @@ -102,36 +114,68 @@ typedef char gchar; } } +%typemap(in) guint16 { + unsigned long ival; + ival = PyInt_AsUnsignedLongMask($input); + if (PyErr_Occurred()) + SWIG_fail; + if (ival > 65535) { + PyErr_SetString(PyExc_ValueError, "$symname: Value must be between 0 and 65535"); + SWIG_fail; + } else { + $1 = (guint16) ival; + } +} + +%typemap(in) guint32 { + unsigned long ival; + ival = PyInt_AsUnsignedLongMask($input); + if (PyErr_Occurred()) + SWIG_fail; + $1 = (guint32) ival; +} + +%typemap(in) guint64 { + unsigned long ival; + ival = PyInt_AsUnsignedLongLongMask($input); + if (PyErr_Occurred()) + SWIG_fail; + $1 = (guint64) ival; +} + %typemap(out) guint64 { - $result = PyLong_FromLong($1); + $result = PyLong_FromUnsignedLongLong($1); +} + +%typemap(out) gint64 { + $result = PyLong_FromLongLong($1); } %typemap(out) guint32 { - $result = PyInt_FromLong($1); + $result = PyLong_FromUnsignedLong($1); } -%typemap(out) guint16 { - $result = PyInt_FromLong($1); +%typemap(out) gint32 { + $result = PyLong_FromLong($1); } +%typemap(out) guint16 { + $result = PyLong_FromUnsignedLong($1); +} %typemap(out) guint8 { $result = PyInt_FromLong($1); } typedef int gboolean; -typedef long gint64; -typedef int gint32; -typedef int gint16; typedef int gint; -typedef unsigned int guint32; - #define G_BEGIN_DECLS #define G_END_DECLS PyObject* sw_get_tracks(Itdb_iTunesDB *itdb); PyObject* sw_get_track(GList *list, gint index); +PyObject* sw_get_rule(GList *list, gint index); PyObject* sw_get_list_len(GList *list); PyObject* sw_get_playlists(Itdb_iTunesDB *itdb); PyObject* sw_get_playlist_tracks(Itdb_Playlist *pl); |
