Skip to content

Commit 244f23a

Browse files
committed
Make a switch to expose isl-internal isl_equalities header
1 parent d81f7dd commit 244f23a

File tree

3 files changed

+41
-11
lines changed

3 files changed

+41
-11
lines changed

gen_wrap.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def __init__(self, name,
117117
class Method:
118118
def __init__(self, cls, name, c_name,
119119
return_semantics, return_base_type, return_ptr,
120-
args, is_exported, is_constructor):
120+
args, is_exported, is_constructor, is_internal):
121121
self.cls = cls
122122
self.name = name
123123
assert name
@@ -128,6 +128,7 @@ def __init__(self, cls, name, c_name,
128128
self.args = args
129129
self.mutator_veto = False
130130
self.is_exported = is_exported
131+
self.is_internal = is_internal
131132
self.is_constructor = is_constructor
132133

133134
if not self.is_static:
@@ -490,7 +491,7 @@ def get_preprocessed_header(self, fname):
490491

491492
# {{{ read_header
492493

493-
def read_header(self, fname):
494+
def read_header(self, fname, is_internal=False):
494495
lines = self.get_preprocessed_header(fname).split("\n")
495496

496497
# heed continuations, split at semicolons
@@ -562,13 +563,13 @@ def read_header(self, fname):
562563
line = lines[i].strip()
563564

564565
if not STRUCT_DECL_RE.search(decl):
565-
self.parse_decl(decl)
566+
self.parse_decl(decl, is_internal)
566567

567568
# }}}
568569

569570
# {{{ parse_decl
570571

571-
def parse_decl(self, decl):
572+
def parse_decl(self, decl, is_internal):
572573
decl_match = DECL_RE.match(decl)
573574
if decl_match is None:
574575
print(f"WARNING: func decl regexp not matched: {decl}")
@@ -702,7 +703,8 @@ def parse_decl(self, decl):
702703
cls_meth_list.append(Method(
703704
class_name, name, c_name,
704705
return_semantics, return_base_type, return_ptr,
705-
args, is_exported=is_exported, is_constructor=is_constructor))
706+
args, is_exported=is_exported, is_constructor=is_constructor,
707+
is_internal=is_internal))
706708

707709
self.seen_c_names.add(c_name)
708710

@@ -1394,10 +1396,18 @@ def write_exposer(outf, meth, arg_names, doc_str):
13941396
# doc_str = "(static method)\n" + doc_str
13951397

13961398
if not meth.is_exported:
1397-
doc_str = doc_str + (
1398-
"\n\n.. warning::\n\n "
1399-
"This function is not part of the officially public isl API. "
1400-
"Use at your own risk.")
1399+
if meth.is_internal:
1400+
doc_str = doc_str + (
1401+
"\n\n.. warning::\n\n "
1402+
"This function is so internal, it is not even exposed in isl's "
1403+
"public headers. We declared it on our own, in hopes that "
1404+
"isl didn't change the functions prototype. "
1405+
"Really, if you have any sense at all, don't use this.")
1406+
else:
1407+
doc_str = doc_str + (
1408+
"\n\n.. warning::\n\n "
1409+
"This function is not part of the officially public isl API. "
1410+
"Use at your own risk.")
14011411

14021412
doc_str_arg = ', "{}"'.format(doc_str.replace("\n", "\\n"))
14031413

@@ -1460,7 +1470,8 @@ def write_wrappers(expf, wrapf, methods):
14601470
}
14611471

14621472

1463-
def gen_wrapper(include_dirs, include_barvinok=False, isl_version=None):
1473+
def gen_wrapper(include_dirs, include_barvinok=False, isl_version=None,
1474+
include_internal=False):
14641475
fdata = FunctionData(["."] + include_dirs)
14651476
fdata.read_header("isl/ctx.h")
14661477
fdata.read_header("isl/id.h")
@@ -1490,6 +1501,12 @@ def gen_wrapper(include_dirs, include_barvinok=False, isl_version=None):
14901501
fdata.read_header("isl/ast_type.h")
14911502
fdata.read_header("isl/ilp.h")
14921503

1504+
if include_internal:
1505+
# We're reaching deep into isl here, to functions that we're not
1506+
# supposed to touch.
1507+
fdata.include_dirs.append("isl")
1508+
fdata.read_header("isl_equalities.h", is_internal=True)
1509+
14931510
if include_barvinok:
14941511
fdata.read_header("barvinok/isl.h")
14951512

setup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ def get_config_schema():
4848
Switch("USE_BARVINOK", False, "Include wrapper for Barvinok"),
4949
Switch("USE_IMATH_SIO", True, "When using imath, use small-integer "
5050
"optimization"),
51+
Switch("INCLUDE_INTERNAL", True, "Expose infuriatingly useful "
52+
"but sadly very internal functionality of isl"),
5153

5254
IncludeDir("GMP", []),
5355
LibraryDir("GMP", []),
@@ -264,7 +266,11 @@ def main():
264266
exec(compile(version_py, init_filename, "exec"), conf)
265267

266268
from gen_wrap import gen_wrapper
267-
gen_wrapper(wrapper_dirs, include_barvinok=conf["USE_BARVINOK"])
269+
gen_wrapper(wrapper_dirs, include_barvinok=conf["USE_BARVINOK"],
270+
include_internal=conf["INCLUDE_INTERNAL"])
271+
272+
if conf["INCLUDE_INTERNAL"]:
273+
EXTRA_DEFINES["ISLPY_INCLUDE_ISL_INTERNAL_HEADERS"] = 1
268274

269275
with open("README.rst") as readme_f:
270276
readme = readme_f.read()

src/wrapper/wrap_isl.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@
2727
#include <barvinok/isl.h>
2828
#endif
2929

30+
#ifdef ISLPY_INCLUDE_ISL_INTERNAL_HEADERS
31+
// Your scientists were so preoccupied with whether or not they could, they
32+
// didn't stop to think if they should.
33+
// -- Dr. Ian Malcolm
34+
#include "../../isl/isl_equalities.h"
35+
#endif
36+
3037
#include <iostream>
3138
#include <stdexcept>
3239
#include <pybind11/pybind11.h>

0 commit comments

Comments
 (0)