swig: improve indentation
[libftdi] / python / ftdi1.i
index 755b6b9..8b179f9 100644 (file)
@@ -19,14 +19,16 @@ inline PyObject* charp2str(const char *v_, long len)
 #endif
 }
 
-inline char * str2charp_size(PyObject* pyObj, int * size)
+char * str2charp_size(PyObject* pyObj, int * size)
 {
   char * v_ = 0;
+  Py_ssize_t len = 0;
 #if PY_MAJOR_VERSION >= 3
-  PyBytes_AsStringAndSize(pyObj, &v_, (Py_ssize_t*)size);
+  PyBytes_AsStringAndSize(pyObj, &v_, &len);
 #else
-  PyString_AsStringAndSize(pyObj, &v_, (Py_ssize_t*)size);
+  PyString_AsStringAndSize(pyObj, &v_, &len);
 #endif
+  *size = len;
   return v_;
 }
 %}
@@ -61,11 +63,13 @@ inline char * str2charp_size(PyObject* pyObj, int * size)
 %enddef
 %feature("autodoc", ftdi_usb_get_strings_docstring) ftdi_usb_get_strings;
 %feature("autodoc", ftdi_usb_get_strings_docstring) ftdi_usb_get_strings2;
+%feature("autodoc", ftdi_usb_get_strings_docstring) ftdi_eeprom_get_strings;
 %apply char *OUTPUT { char * manufacturer, char * description, char * serial };
 %cstring_bounded_output( char * manufacturer, 256 );
 %cstring_bounded_output( char * description, 256 );
+%cstring_bounded_output( char * product, 256 );
 %cstring_bounded_output( char * serial, 256 );
-%typemap(default,noblock=1) int mnf_len, int desc_len, int serial_len { $1 = 256; }
+%typemap(default,noblock=1) int mnf_len, int desc_len, int product_len, int serial_len { $1 = 256; }
     int ftdi_usb_get_strings(struct ftdi_context *ftdi, struct libusb_device *dev,
                              char * manufacturer, int mnf_len,
                              char * description, int desc_len,
@@ -74,15 +78,26 @@ inline char * str2charp_size(PyObject* pyObj, int * size)
                               char * manufacturer, int mnf_len,
                               char * description, int desc_len,
                               char * serial, int serial_len);
+    int ftdi_eeprom_get_strings(struct ftdi_context *ftdi,
+                                char *manufacturer, int mnf_len,
+                                char *product, int product_len,
+                                char *serial, int serial_len);
+
 %clear char * manufacturer, char * description, char * serial;
-%clear int mnf_len, int desc_len, int serial_len;
+%clear char * product;
+%clear int mnf_len, int desc_len, int product_len, int serial_len;
 
 %define ftdi_read_data_docstring
 "read_data(context) -> (return_code, buf)"
 %enddef
 %feature("autodoc", ftdi_read_data_docstring) ftdi_read_data;
 %typemap(in,numinputs=1) (unsigned char *buf, int size) %{ $2 = PyInt_AsLong($input);$1 = (unsigned char*)malloc($2*sizeof(char)); %}
-%typemap(argout) (unsigned char *buf, int size) %{ if(result<0) $2=0; $result = SWIG_Python_AppendOutput($result, charp2str((char*)$1, $2)); free($1); %}
+%typemap(argout) (unsigned char *buf, int size) %{
+        if(result<0)
+                $2=0;
+        $result = SWIG_Python_AppendOutput($result, charp2str((char*)$1, $2));
+        free($1);
+%}
     int ftdi_read_data(struct ftdi_context *ftdi, unsigned char *buf, int size);
 %clear (unsigned char *buf, int size);
 
@@ -122,7 +137,12 @@ inline char * str2charp_size(PyObject* pyObj, int * size)
 %clear int* value;
 
 %typemap(in,numinputs=1) (unsigned char *buf, int size) %{ $2 = PyInt_AsLong($input);$1 = (unsigned char*)malloc($2*sizeof(char)); %}
-%typemap(argout) (unsigned char *buf, int size) %{ if(result<0) $2=0; $result = SWIG_Python_AppendOutput($result, charp2str((char*)$1, $2)); free($1); %}
+%typemap(argout) (unsigned char *buf, int size) %{
+        if(result<0)
+                $2=0;
+        $result = SWIG_Python_AppendOutput($result, charp2str((char*)$1, $2));
+        free($1);
+%}
     int ftdi_get_eeprom_buf(struct ftdi_context *ftdi, unsigned char * buf, int size);
 %clear (unsigned char *buf, int size);