home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.3 / 7.3.307 < prev    next >
Encoding:
Internet Message Format  |  2012-11-20  |  5.3 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.3.307
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.3.307
  11. Problem:    Python 3 doesn't support slice assignment.
  12. Solution:   Implement slices. (Brett Overesch, Roland Puntaier)
  13. Files:        src/if_python3.c
  14.  
  15.  
  16. *** ../vim-7.3.306/src/if_python3.c    2011-08-28 16:00:14.000000000 +0200
  17. --- src/if_python3.c    2011-09-14 15:01:26.000000000 +0200
  18. ***************
  19. *** 855,862 ****
  20.   
  21.   static Py_ssize_t BufferLength(PyObject *);
  22.   static PyObject *BufferItem(PyObject *, Py_ssize_t);
  23. ! static PyObject* BufferSubscript(PyObject *self, PyObject* idx);
  24. ! static Py_ssize_t BufferAsSubscript(PyObject *self, PyObject* idx, PyObject* val);
  25.   
  26.   
  27.   /* Line range type - Implementation functions
  28. --- 855,862 ----
  29.   
  30.   static Py_ssize_t BufferLength(PyObject *);
  31.   static PyObject *BufferItem(PyObject *, Py_ssize_t);
  32. ! static PyObject* BufferSubscript(PyObject *self, PyObject *idx);
  33. ! static Py_ssize_t BufferAsSubscript(PyObject *self, PyObject *idx, PyObject *val);
  34.   
  35.   
  36.   /* Line range type - Implementation functions
  37. ***************
  38. *** 865,872 ****
  39.   
  40.   #define RangeType_Check(obj) ((obj)->ob_base.ob_type == &RangeType)
  41.   
  42. ! static PyObject* RangeSubscript(PyObject *self, PyObject* idx);
  43.   static Py_ssize_t RangeAsItem(PyObject *, Py_ssize_t, PyObject *);
  44.   
  45.   /* Current objects type - Implementation functions
  46.    * -----------------------------------------------
  47. --- 865,873 ----
  48.   
  49.   #define RangeType_Check(obj) ((obj)->ob_base.ob_type == &RangeType)
  50.   
  51. ! static PyObject* RangeSubscript(PyObject *self, PyObject *idx);
  52.   static Py_ssize_t RangeAsItem(PyObject *, Py_ssize_t, PyObject *);
  53. + static Py_ssize_t RangeAsSubscript(PyObject *self, PyObject *idx, PyObject *val);
  54.   
  55.   /* Current objects type - Implementation functions
  56.    * -----------------------------------------------
  57. ***************
  58. *** 1035,1041 ****
  59.             &step, &slicelen) < 0) {
  60.           return NULL;
  61.       }
  62. !     return BufferSlice(self,start,stop);
  63.       } else {
  64.       PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
  65.       return NULL;
  66. --- 1036,1042 ----
  67.             &step, &slicelen) < 0) {
  68.           return NULL;
  69.       }
  70. !     return BufferSlice(self, start, stop);
  71.       } else {
  72.       PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
  73.       return NULL;
  74. ***************
  75. *** 1084,1090 ****
  76.   PyMappingMethods RangeAsMapping = {
  77.       /* mp_length    */ (lenfunc)RangeLength,
  78.       /* mp_subscript     */ (binaryfunc)RangeSubscript,
  79. !     /* mp_ass_subscript */ (objobjargproc)0,
  80.   };
  81.   
  82.   /* Line range object - Implementation
  83. --- 1085,1091 ----
  84.   PyMappingMethods RangeAsMapping = {
  85.       /* mp_length    */ (lenfunc)RangeLength,
  86.       /* mp_subscript     */ (binaryfunc)RangeSubscript,
  87. !     /* mp_ass_subscript */ (objobjargproc)RangeAsSubscript,
  88.   };
  89.   
  90.   /* Line range object - Implementation
  91. ***************
  92. *** 1123,1128 ****
  93. --- 1124,1138 ----
  94.               &((RangeObject *)(self))->end);
  95.   }
  96.   
  97. +     static Py_ssize_t
  98. + RangeAsSlice(PyObject *self, Py_ssize_t lo, Py_ssize_t hi, PyObject *val)
  99. + {
  100. +     return RBAsSlice(((RangeObject *)(self))->buf, lo, hi, val,
  101. +             ((RangeObject *)(self))->start,
  102. +             ((RangeObject *)(self))->end,
  103. +             &((RangeObject *)(self))->end);
  104. + }
  105.       static PyObject *
  106.   RangeSubscript(PyObject *self, PyObject* idx)
  107.   {
  108. ***************
  109. *** 1138,1150 ****
  110.           &step, &slicelen) < 0) {
  111.           return NULL;
  112.       }
  113. !     return RangeSlice(self,start,stop+1);
  114.       } else {
  115.       PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
  116.       return NULL;
  117.       }
  118.   }
  119.   
  120.   /* Buffer list object - Definitions
  121.    */
  122.   
  123. --- 1148,1183 ----
  124.           &step, &slicelen) < 0) {
  125.           return NULL;
  126.       }
  127. !     return RangeSlice(self, start, stop);
  128.       } else {
  129.       PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
  130.       return NULL;
  131.       }
  132.   }
  133.   
  134. +     static Py_ssize_t
  135. + RangeAsSubscript(PyObject *self, PyObject *idx, PyObject *val)
  136. + {
  137. +     if (PyLong_Check(idx)) {
  138. +     long n = PyLong_AsLong(idx);
  139. +     return RangeAsItem(self, n, val);
  140. +     } else if (PySlice_Check(idx)) {
  141. +     Py_ssize_t start, stop, step, slicelen;
  142. +     if (PySlice_GetIndicesEx((PySliceObject *)idx,
  143. +         ((RangeObject *)(self))->end-((RangeObject *)(self))->start+1,
  144. +         &start, &stop,
  145. +         &step, &slicelen) < 0) {
  146. +         return -1;
  147. +     }
  148. +     return RangeAsSlice(self, start, stop, val);
  149. +     } else {
  150. +     PyErr_SetString(PyExc_IndexError, "Index must be int or slice");
  151. +     return -1;
  152. +     }
  153. + }
  154.   /* Buffer list object - Definitions
  155.    */
  156.   
  157. *** ../vim-7.3.306/src/version.c    2011-09-14 14:43:21.000000000 +0200
  158. --- src/version.c    2011-09-14 14:58:16.000000000 +0200
  159. ***************
  160. *** 711,712 ****
  161. --- 711,714 ----
  162.   {   /* Add new patch number below this line */
  163. + /**/
  164. +     307,
  165.   /**/
  166.  
  167. -- 
  168. The process for understanding customers primarily involves sitting around with
  169. other marketing people and talking about what you would to if you were dumb
  170. enough to be a customer.
  171.                 (Scott Adams - The Dilbert principle)
  172.  
  173.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  174. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  175. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  176.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  177.