Index: svn_checksum_t.swg =================================================================== --- svn_checksum_t.swg (revision 0) +++ svn_checksum_t.swg (revision 0) @@ -0,0 +1,47 @@ +%module checksum/** + * TYPE: svn_checksum_t.; functions typemapped svn_checksum_t ; svn_checksum_kind_t, svn_checksum_create and avn_checksum_clear + * The input for the function svn_checksum_clear is of the Type svn_check_sum_t so by the typemap rules it maps to the typemap("in") defined here. + */ + +#ifdef SWIGPYTHON +%typemap(in) svn_checksum_t * { + /* check if the input is not a const unsigned char* digest */ + if(!PyBytes_Check($input)){ + PyErr_SetString(PyExc_TypeError, "Not a valid Bit string"); + /* return fail if it isnt*/ + SWIG_fail; + } + /*else , pass is as the required argument for the svn_checksum_Clear function*/ + $1 = svn_checksum_clear(PyBytes_FromString($input)); +} +#endif + +#ifdef SWIGPYTHON +/*here since svn_checksum_kind_t only defines the values returned by the enum function thus it can be treated as a simple int */ +%typemap(in) svn_checksum_kind_t { + $1 = PyInt_AsLong($input); +} +%typemap (out) svnchecksum_kind_t { + $result = PyInt_FromLong($1); +} + +#endif +#ifdef SWIGPYTHON +%typemap(in) svn_checksum_t * { + $1 = svn_checksum_create(PyInt_AsLong($input),_global_pool); +} +/* the out value for svn_checksum_t * will return a string intialized to 0's and the kind returned by svn_checksum_kind for create function tyoemapped here */ +%typemap(out) svn_checksum_t * { + $result = (PyBytes_FromString("0"),PyInt_FromLong($1)); + + + /* (could have been??) PyObject *t; + + t = PyTuple_New(2); + /* refers to the initialized string */ + PyTuple_SetItem(t, 0, PyBytes_FromString("0")); + /* refers to the value taken as an argument by the create function */ + PyTuple_SetItem(t, 1, PyInt_FromLong($1)); */ +} +#endif +