@@ -229,9 +229,9 @@ cdef extern from "parser/tokenizer.h":
229
229
int64_t skip_first_N_rows
230
230
int64_t skipfooter
231
231
# pick one, depending on whether the converter requires GIL
232
- float64_t (* double_converter)(const char * , char ** ,
233
- char , char , char ,
234
- int , int * , int * ) nogil
232
+ double (* double_converter)(const char * , char ** ,
233
+ char , char , char ,
234
+ int , int * , int * ) nogil
235
235
236
236
# error handling
237
237
char * warn_msg
@@ -249,6 +249,16 @@ cdef extern from "parser/tokenizer.h":
249
249
int seen_uint
250
250
int seen_null
251
251
252
+ void COLITER_NEXT(coliter_t, const char * ) nogil
253
+
254
+ cdef extern from " pd_parser.h" :
255
+ void * new_rd_source(object obj) except NULL
256
+
257
+ int del_rd_source(void * src)
258
+
259
+ void * buffer_rd_bytes(void * source, size_t nbytes,
260
+ size_t * bytes_read, int * status, const char * encoding_errors)
261
+
252
262
void uint_state_init(uint_state * self )
253
263
int uint64_conflict(uint_state * self )
254
264
@@ -279,26 +289,49 @@ cdef extern from "parser/tokenizer.h":
279
289
uint64_t str_to_uint64(uint_state * state, char * p_item, int64_t int_max,
280
290
uint64_t uint_max, int * error, char tsep) nogil
281
291
282
- float64_t xstrtod(const char * p, char ** q, char decimal,
292
+ double xstrtod(const char * p, char ** q, char decimal,
293
+ char sci, char tsep, int skip_trailing,
294
+ int * error, int * maybe_int) nogil
295
+ double precise_xstrtod(const char * p, char ** q, char decimal,
296
+ char sci, char tsep, int skip_trailing,
297
+ int * error, int * maybe_int) nogil
298
+ double round_trip(const char * p, char ** q, char decimal,
283
299
char sci, char tsep, int skip_trailing,
284
300
int * error, int * maybe_int) nogil
285
- float64_t precise_xstrtod(const char * p, char ** q, char decimal,
286
- char sci, char tsep, int skip_trailing,
287
- int * error, int * maybe_int) nogil
288
- float64_t round_trip(const char * p, char ** q, char decimal,
289
- char sci, char tsep, int skip_trailing,
290
- int * error, int * maybe_int) nogil
291
301
292
302
int to_boolean(const char * item, uint8_t * val) nogil
293
303
304
+ void PandasParser_IMPORT()
294
305
295
- cdef extern from " parser/io.h" :
296
- void * new_rd_source(object obj) except NULL
306
+ PandasParser_IMPORT
297
307
298
- int del_rd_source(void * src)
308
+ # When not invoked directly but rather assigned as a function,
309
+ # cdef extern'ed declarations seem to leave behind an undefined symbol
310
+ cdef double xstrtod_wrapper(const char * p, char ** q, char decimal,
311
+ char sci, char tsep, int skip_trailing,
312
+ int * error, int * maybe_int) nogil:
313
+ return xstrtod(p, q, decimal, sci, tsep, skip_trailing, error, maybe_int)
299
314
300
- void * buffer_rd_bytes(void * source, size_t nbytes,
301
- size_t * bytes_read, int * status, const char * encoding_errors)
315
+
316
+ cdef double precise_xstrtod_wrapper(const char * p, char ** q, char decimal,
317
+ char sci, char tsep, int skip_trailing,
318
+ int * error, int * maybe_int) nogil:
319
+ return precise_xstrtod(p, q, decimal, sci, tsep, skip_trailing, error, maybe_int)
320
+
321
+
322
+ cdef double round_trip_wrapper(const char * p, char ** q, char decimal,
323
+ char sci, char tsep, int skip_trailing,
324
+ int * error, int * maybe_int) nogil:
325
+ return round_trip(p, q, decimal, sci, tsep, skip_trailing, error, maybe_int)
326
+
327
+
328
+ cdef void * buffer_rd_bytes_wrapper(void * source, size_t nbytes,
329
+ size_t * bytes_read, int * status,
330
+ const char * encoding_errors) noexcept:
331
+ return buffer_rd_bytes(source, nbytes, bytes_read, status, encoding_errors)
332
+
333
+ cdef int del_rd_source_wrapper(void * src) noexcept:
334
+ return del_rd_source(src)
302
335
303
336
304
337
cdef class TextReader:
@@ -487,11 +520,11 @@ cdef class TextReader:
487
520
488
521
if float_precision == " round_trip" :
489
522
# see gh-15140
490
- self .parser.double_converter = round_trip
523
+ self .parser.double_converter = round_trip_wrapper
491
524
elif float_precision == " legacy" :
492
- self .parser.double_converter = xstrtod
525
+ self .parser.double_converter = xstrtod_wrapper
493
526
elif float_precision == " high" or float_precision is None :
494
- self .parser.double_converter = precise_xstrtod
527
+ self .parser.double_converter = precise_xstrtod_wrapper
495
528
else :
496
529
raise ValueError (f" Unrecognized float_precision option: "
497
530
f" {float_precision}" )
@@ -610,8 +643,8 @@ cdef class TextReader:
610
643
611
644
ptr = new_rd_source(source)
612
645
self .parser.source = ptr
613
- self .parser.cb_io = & buffer_rd_bytes
614
- self .parser.cb_cleanup = & del_rd_source
646
+ self .parser.cb_io = buffer_rd_bytes_wrapper
647
+ self .parser.cb_cleanup = del_rd_source_wrapper
615
648
616
649
cdef _get_header(self , list prelim_header):
617
650
# header is now a list of lists, so field_count should use header[0]
0 commit comments