From 4816295820a95b2f83688784477bd71911f56cb9 Mon Sep 17 00:00:00 2001 From: Mathieu Faverge <mathieu.faverge@inria.fr> Date: Mon, 14 May 2018 19:22:47 +0200 Subject: [PATCH] A few update on the wrapper generator for python --- tools/gen_wrappers.py | 8 +++++--- tools/wrappers/wrap_python.py | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/tools/gen_wrappers.py b/tools/gen_wrappers.py index 841177e1..4a5cd72e 100755 --- a/tools/gen_wrappers.py +++ b/tools/gen_wrappers.py @@ -200,6 +200,7 @@ def parse_enums(preprocessed_list): enumname = split_fun[2] enumname = re.sub(r"_e$", "", enumname) enumname = re.sub(r"^pastix_", "", enumname) + enumname = re.sub(r"^spm_", "", enumname) args_string = fun_parts[1]; args_string = re.sub(r"}", "", args_string) @@ -465,9 +466,10 @@ spm_enums = { 'filename' : [ "include/spm_const.h" ], 'python' : { 'filename' : "wrappers/python/spm/enum.py.in", 'description' : "SPM python wrapper to define enums and datatypes", - 'header' : "spm_int = @SPM_PYTHON_INTEGER@", + 'header' : "# Start with __ to prevent broadcast to file importing enum\n__spm_int__ = @SPM_PYTHON_INTEGER@\n", 'footer' : "", - 'enums' : { 'coeftype' : enums_python_coeftype } + 'enums' : { 'coeftype' : enums_python_coeftype, + 'mtxtype' : " SymPosDef = trans.ConjTrans + 1\n HerPosDef = trans.ConjTrans + 2\n" } }, 'fortran' : { 'filename' : "wrappers/fortran90/src/spm_enums.F90", 'description' : "SPM fortran 90 wrapper to define enums and datatypes", @@ -481,7 +483,7 @@ spm = { 'filename' : [ "include/spm.h" ], 'python' : { 'filename' : "wrappers/python/spm/__spm__.py", 'description' : "SPM python wrapper", - 'header' : "from . import libspm\nfrom .enum import spm_int\n", + 'header' : "from . import libspm\nfrom .enum import __spm_int__\n", 'footer' : "", 'enums' : {} }, diff --git a/tools/wrappers/wrap_python.py b/tools/wrappers/wrap_python.py index ed5b79b4..60945858 100644 --- a/tools/wrappers/wrap_python.py +++ b/tools/wrappers/wrap_python.py @@ -38,8 +38,8 @@ types_dict = { "spm_normtype_t": ("c_int"), "spm_rhstype_t": ("c_int"), "spm_mtxtype_t": ("c_int"), - "spm_int_t": ("pastix_int"), - "spmatrix_t": ("pyspmatrix_t"), + "spm_int_t": ("__spm_int__"), + "spmatrix_t": ("pyspm_spmatrix_t"), "size_t": ("c_size_t"), "char": ("c_char"), "double": ("c_double"), @@ -180,9 +180,11 @@ import numpy as np # Remove Pastix from everything param[0] = re.sub(r"Pastix", "", param[0]) + param[0] = re.sub(r"Spm", "", param[0]) if ename == "error": param[0] = re.sub(r"PASTIX_", "", param[0]) + param[0] = re.sub(r"SPM_", "", param[0]) param[0] = re.sub(r"ERR_", "", param[0]) elif ename == "fact_mode" or ename == "factotype" or ename == "solv_mode": param[0] = re.sub(r"Fact", "", param[0]) @@ -202,6 +204,7 @@ import numpy as np param[0] = param[0] elif ename == "mtxtype": param[1] = re.sub(r"Pastix", "trans.", param[1]) + param[1] = re.sub(r"Spm", "trans.", param[1]) elif ename == "normtype": param[0] = re.sub(r"Norm", "", param[0]) else: @@ -232,7 +235,7 @@ import numpy as np s = 0 name = struct[0][2] name = re.sub(r"pastix_", "", name) - py_interface += "class pypastix_" + name + "(Structure):\n" + py_interface += "class pyspm_" + name + "(Structure):\n" s = iindent py_interface += s*" " + "_fields_ = [" -- GitLab