Hi,
I have generated the attached [PATCH] as a part of the contribution i
wanted to make towards the subversion's swig-py project as a part of the
OPW program.
Having chosen the Python Bindings Problem, i tried learning all the
prerequisites for me to become able to contribute even in the mildest of
substance.
Following a strong support from the mentors and co-mentors i however
managed to grasp many concepts (swig,typemapping,python-c api's,avn) in
the course of last week and am posting the typemap i have written to map
the function svn_checksum_t in /subversion/include/svn_checksum.h , the
typemaps i look to put into the
/subversion/bindings/swig/include/svn_checksum.swg file.
Log Message:
subversion/bindings/swig/include
(svn_checksum_t.swg) : Generated a typemap.
(svn_checksum_kind_t,svn_checksum_create,svn_checksum_clear): typemapped
these functions
Suggested by: Stefan Sperling <[email protected]>
Ben Reser <[email protected]>
Daniel Shahaf <~danielsh@apache>
I hope this PATCH is incorporated and i am able to contribute substantially
to the subversion community.
Regards,
Shivani Poddar
Sophomore,
International Institute of Information Technology, Hyderabad
subversion/bindings/swig/include
(svn_checksum_t.swg) : Generated a typemap.
(svn_checksum_kind_t,svn_checksum_create,svn_checksum_clear): typemapped these
functions
Suggested by: Stefan Sperling <[email protected]>
Ben Reser <[email protected]>
Daniel Shahaf <~danielsh@apache>
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
+