8000 MAINT: convert convert_datatype and dtypemeta to c++ · ngoldbaum/numpy@c004fc0 · GitHub
[go: up one dir, main page]

Skip to content

Commit c004fc0

Browse files
committed
MAINT: convert convert_datatype and dtypemeta to c++
1 parent 760dbe9 commit c004fc0

21 files changed

+445
-238
lines changed

numpy/_core/code_generators/genapi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ def get_processor():
5454
join('multiarray', 'common_dtype.c'),
5555
join('multiarray', 'conversion_utils.c'),
5656
join('multiarray', 'convert.c'),
57-
join('multiarray', 'convert_datatype.c'),
57+
join('multiarray', 'convert_datatype.cpp'),
5858
join('multiarray', 'ctors.c'),
5959
join('multiarray', 'datetime.c'),
6060
join('multiarray', 'datetime_busday.c'),
6161
join('multiarray', 'datetime_busdaycal.c'),
6262
join('multiarray', 'datetime_strings.c'),
6363
join('multiarray', 'descriptor.c'),
6464
join('multiarray', 'dlpack.c'),
65-
join('multiarray', 'dtypemeta.c'),
65+
join('multiarray', 'dtypemeta.cpp'),
6666
join('multiarray', 'einsum.c.src'),
6767
join('multiarray', 'public_dtype_api.c'),
6868
join('multiarray', 'flagsobject.c'),

numpy/_core/meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,7 @@ src_multiarray = multiarray_gen_headers + [
10961096
'src/multiarray/common.c',
10971097
'src/multiarray/common_dtype.c',
10981098
'src/multiarray/convert.c',
1099-
'src/multiarray/convert_datatype.c',
1099+
'src/multiarray/convert_datatype.cpp',
11001100
'src/multiarray/conversion_utils.c',
11011101
'src/multiarray/ctors.c',
11021102
'src/multiarray/datetime.c',
@@ -1105,7 +1105,7 @@ src_multiarray = multiarray_gen_headers + [
11051105
'src/multiarray/datetime_busdaycal.c',
11061106
'src/multiarray/descriptor.c',
11071107
'src/multiarray/dlpack.c',
1108-
'src/multiarray/dtypemeta.c',
1108+
'src/multiarray/dtypemeta.cpp',
11091109
'src/multiarray/dragon4.c',
11101110
'src/multiarray/dtype_transfer.c',
11111111
'src/multiarray/dtype_traversal.c',

numpy/_core/src/common/lowlevel_strided_loops.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
/* For PyArray_ macros used below */
1111
#include "numpy/ndarrayobject.h"
1212

13+
#ifdef __cplusplus
14+
extern "C" {
15+
#endif
16+
1317
/*
1418
* NOTE: This API should remain private for the time being, to allow
1519
* for further refinement. I think the 'aligned' mechanism
@@ -787,4 +791,8 @@ PyArray_EQUIVALENTLY_ITERABLE_OVERLAP_OK(PyArrayObject *arr1, PyArrayObject *arr
787791
stride2 = PyArray_TRIVIAL_PAIR_ITERATION_STRIDE(size2, arr2); \
788792
}
789793

794+
#ifdef __cplusplus
795+
}
796+
#endif
797+
790798
#endif /* NUMPY_CORE_SRC_COMMON_LOWLEVEL_STRIDED_LOOPS_H_ */

numpy/_core/src/common/npy_import.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
#include "numpy/npy_common.h"
77
#include "npy_atomic.h"
88

9+
#ifdef __cplusplus
10+
extern "C" {
11+
#endif
12+
913
/*
1014
* Cached references to objects obtained via an import. All of these are
1115
* can be initialized at any time by npy_cache_import_runtime.
@@ -111,4 +115,8 @@ npy_cache_import_runtime(const char *module, const char *attr, PyObject **obj) {
111115
NPY_NO_EXPORT int
112116
init_import_mutex(void);
113117

118+
#ifdef __cplusplus
119+
}
120+
#endif
121+
114122
#endif /* NUMPY_CORE_SRC_COMMON_NPY_IMPORT_H_ */

numpy/_core/src/common/templ_common.h.src

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
#include "numpy/npy_common.h"
77
#include <assert.h>
88

9+
#ifdef __cplusplus
10+
extern "C" {
11+
#endif
12+
913
/**begin repeat
1014
* #name = int, uint, long, ulong,
1115
* longlong, ulonglong#
@@ -96,6 +100,9 @@ npy_mul_with_overflow_size_t(size_t * r, size_t a, size_t b)
96100
#endif
97101
}
98102

103+
#ifdef __cplusplus
104+
}
105+
#endif
99106

100107
#endif
101108

numpy/_core/src/multiarray/_datetime.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
extern NPY_NO_EXPORT char const *_datetime_strings[NPY_DATETIME_NUMUNITS];
55
extern NPY_NO_EXPORT int _days_per_month_table[2][12];
66

7+
#ifdef __cplusplus
8+
extern "C" {
9+
#endif
10+
711
NPY_NO_EXPORT void
812
numpy_pydatetime_import(void);
913

@@ -334,4 +338,8 @@ datetime_hash(PyArray_DatetimeMetaData *meta, npy_datetime dt);
334338
NPY_NO_EXPORT npy_hash_t
335339
timedelta_hash(PyArray_DatetimeMetaData *meta, npy_timedelta td);
336340

341+
#ifdef __cplusplus
342+
}
343+
#endif
344+
337345
#endif /* NUMPY_CORE_SRC_MULTIARRAY__DATETIME_H_ */

numpy/_core/src/multiarray/alloc.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
#define NPY_TRACE_DOMAIN 389047
99
#define MEM_HANDLER_CAPSULE_NAME "mem_handler"
1010

11+
#ifdef __cplusplus
12+
extern "C" {
13+
#endif
14+
1115
NPY_NO_EXPORT PyObject *
1216
_get_madvise_hugepage(PyObject *NPY_UNUSED(self), PyObject *NPY_UNUSED(args));
1317

@@ -111,4 +115,8 @@ _npy_free_workspace(void *buf, void *static_buf)
111115
#define npy_free_workspace(NAME) \
112116
_npy_free_workspace(NAME, NAME##_static)
113117

118+
#ifdef __cplusplus
119+
}
120+
#endif
121+
114122
#endif /* NUMPY_CORE_SRC_MULTIARRAY_ALLOC_H_ */

numpy/_core/src/multiarray/array_coercion.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#ifndef NUMPY_CORE_SRC_MULTIARRAY_ARRAY_COERCION_H_
22
#define NUMPY_CORE_SRC_MULTIARRAY_ARRAY_COERCION_H_
33

4+
#ifdef __cplusplus
5+
extern "C" {
6+
#endif
47

58
/*
69
* We do not want to coerce arrays many times unless absolutely necessary.
@@ -58,4 +61,8 @@ npy_unlink_coercion_cache(coercion_cache_obj *current);
5861
NPY_NO_EXPORT int
5962
PyArray_AssignFromCache(PyArrayObject *self, coercion_cache_obj *cache);
6063

64+
#ifdef __cplusplus
65+
}
66+
#endif
67+
6168
#endif /* NUMPY_CORE_SRC_MULTIARRAY_ARRAY_COERCION_H_ */

numpy/_core/src/multiarray/arraytypes.h.src

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
#include "common.h"
55

6+
#ifdef __cplusplus
7+
extern "C" {
8+
#endif
9+
610
NPY_NO_EXPORT int
711
set_typeinfo(PyObject *dict);
812

@@ -164,4 +168,8 @@ NPY_CPU_DISPATCH_DECLARE(NPY_NO_EXPORT int BOOL_argmax,
164168
#undef INT_not_size_named
165169
#undef LONGLONG_not_size_named
166170

171+
#ifdef __cplusplus
172+
}
173+
#endif
174+
167175
#endif /* NUMPY_CORE_SRC_MULTIARRAY_ARRAYTYPES_H_ */

numpy/_core/src/multiarray/can_cast_table.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
#include "numpy/ndarraytypes.h"
1616

17+
#ifdef __cplusplus
18+
extern "C" {
19+
#endif
1720

1821
/* The from type fits into to (it has a smaller or equal number of bits) */
1922
#define FITS(FROM, TO) (NPY_SIZEOF_##FROM <= NPY_SIZEOF_##TO)
@@ -121,4 +124,8 @@ static const npy_bool _npy_can_cast_safely_table[NPY_NTYPES_LEGACY][NPY_NTYPES_L
121124
#undef CASTS_SAFELY_TO_FLOAT
122125
#undef CASTS_SAFELY_TO_CFLOAT
123126

127+
#ifdef __cplusplus
128+
}
129+
#endif
130+
124131
#endif /* NUMPY_CORE_SRC_MULTIARRAY_CAN_CAST_TABLE_H_ */

0 commit comments

Comments
 (0)
0