Explorar o código

Implemented hook_read (triggered after read() method is done).

Sander Mathijs van Veen %!s(int64=14) %!d(string=hai) anos
pai
achega
eb1d1da4c2
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      src/pyrex/bison_.pyx

+ 3 - 0
src/pyrex/bison_.pyx

@@ -128,6 +128,9 @@ cdef public void py_input(object parser, char *buf, int *result, int max_size):
     except KeyboardInterrupt:
         raw = ''
 
+    if hasattr(parser, 'hook_read'):
+        raw = parser.hook_read(raw)
+
     buflen = PyInt_AsLong(len(raw))
     result[0] = buflen
     memcpy(buf, PyString_AsString(raw), buflen)