summaryrefslogtreecommitdiff
path: root/numpy/random
diff options
context:
space:
mode:
authormckib2 <nicholas.bgp@gmail.com>2021-01-30 20:07:17 -0700
committermckib2 <nicholas.bgp@gmail.com>2021-01-30 20:07:17 -0700
commit5eadc233eafb80706d0f626caa1c68a747f8ce9b (patch)
treec894508978e3b2b35d2b7f0d8002ce54ee81a408 /numpy/random
parentb0f9fccca3c312c7473a638c5aa0a9faa179a95c (diff)
downloadnumpy-5eadc233eafb80706d0f626caa1c68a747f8ce9b.tar.gz
BUG: cffi parser ignores __cplusplus guards
Diffstat (limited to 'numpy/random')
-rw-r--r--numpy/random/_examples/cffi/parse.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/numpy/random/_examples/cffi/parse.py b/numpy/random/_examples/cffi/parse.py
index 73d8646c7..daff6bdec 100644
--- a/numpy/random/_examples/cffi/parse.py
+++ b/numpy/random/_examples/cffi/parse.py
@@ -17,11 +17,20 @@ def parse_distributions_h(ffi, inc_dir):
continue
s.append(line)
ffi.cdef('\n'.join(s))
-
+
with open(os.path.join(inc_dir, 'random', 'distributions.h')) as fid:
s = []
in_skip = 0
+ ignoring = False
for line in fid:
+ # check for and remove extern "C" guards
+ if ignoring:
+ if line.strip().startswith('#endif'):
+ ignoring = False
+ continue
+ if line.strip().startswith('#ifdef __cplusplus'):
+ ignoring = True
+
# massage the include file
if line.strip().startswith('#'):
continue