From 0d2d4e0fa47e03eb0b42e2e01fc6378c3382ea3c Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Fri, 3 Jul 2015 01:06:42 -0500 Subject: [PATCH] Wrapp format and yaml_style 'enums' --- doc/reference.rst | 8 ++++++++ gen_wrap.py | 39 ++++++++++++++++++++++++++++++--------- islpy/__init__.py | 2 ++ 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/doc/reference.rst b/doc/reference.rst index bbdb77d..a39faa2 100644 --- a/doc/reference.rst +++ b/doc/reference.rst @@ -131,6 +131,14 @@ Symbolic Constants :members: :undoc-members: +.. autoclass:: format + :members: + :undoc-members: + +.. autoclass:: yaml_style + :members: + :undoc-members: + Basic Building Blocks ^^^^^^^^^^^^^^^^^^^^^ diff --git a/gen_wrap.py b/gen_wrap.py index bf14fa0..fce2083 100644 --- a/gen_wrap.py +++ b/gen_wrap.py @@ -277,10 +277,27 @@ ENUMS = { isl_fold_min, isl_fold_max, isl_fold_list, - """ + """, + + # printer.h + "isl_format": """ + ISL_FORMAT_ISL, + ISL_FORMAT_POLYLIB, + ISL_FORMAT_POLYLIB_CONSTRAINTS, + ISL_FORMAT_OMEGA, + ISL_FORMAT_C, + ISL_FORMAT_LATEX, + ISL_FORMAT_EXT_POLYLIB, + """, + + "isl_yaml_style": """ + ISL_YAML_STYLE_BLOCK, + ISL_YAML_STYLE_FLOW, + """, } TYPEDEFD_ENUMS = ["isl_stat", "isl_bool"] +MACRO_ENUMS = ["isl_format", "isl_yaml_style"] HEADER_PREAMBLE = """ // flow.h @@ -773,15 +790,19 @@ def write_enums_to_header(header_f): for enum_name, value_str in ENUMS.items(): values = [v.strip() for v in value_str.split(",") if v.strip()] - if enum_name in TYPEDEFD_ENUMS: - pattern = "typedef enum {{ {values}, ... }} {name};\n" - else: - pattern = "enum {name} {{ {values}, ... }};\n" + if enum_name not in MACRO_ENUMS: + if enum_name in TYPEDEFD_ENUMS: + pattern = "typedef enum {{ {values}, ... }} {name};\n" + else: + pattern = "enum {name} {{ {values}, ... }};\n" - header_f.write( - pattern.format( - name=enum_name, - values=", ".join(values))) + header_f.write( + pattern.format( + name=enum_name, + values=", ".join(values))) + else: + for v in values: + header_f.write("static const int {name};".format(name=v)) def write_classes_to_header(header_f): diff --git a/islpy/__init__.py b/islpy/__init__.py index 7b3c8ce..2d05572 100644 --- a/islpy/__init__.py +++ b/islpy/__init__.py @@ -104,6 +104,8 @@ ast_expr_type = _isl.ast_expr_type ast_loop_type = _isl.ast_loop_type ast_node_type = _isl.ast_node_type ast_op_type = _isl.ast_op_type +format = _isl.format +yaml_style = _isl.yaml_style ALL_CLASSES = [Options, Context, IdList, ValList, BasicSetList, BasicMapList, SetList, MapList, UnionSetList, ConstraintList, AffList, PwAffList, -- GitLab