@@ -682,14 +682,20 @@ def handle_static_inline(node):
682
682
decl = node .decl
683
683
if decl .name in DEPRECATED :
684
684
return
685
+ # Append "_" to the name that we expose to Python
686
+ decl .type .type .declname += "_"
687
+ decl .storage = ["extern" ]
688
+ decl .funcspec = []
685
689
text = generator .visit (node ).strip ()
690
+ decl_text = generator .visit (decl ).strip ()
686
691
if skip_complex and has_complex (text ):
687
692
return
688
693
return {
689
694
"name" : decl .name ,
690
695
"group" : "static inline" ,
691
696
"node" : node ,
692
697
"text" : text + "\n " ,
698
+ "decl_text" : decl_text + ";" ,
693
699
}
694
700
695
701
grb_funcs = (handle_function_node (node ) for node in grb_nodes )
@@ -791,9 +797,12 @@ def handle_funcs(group):
791
797
text .append ("****************/" )
792
798
text .extend (handle_funcs (groups ["GxB methods" ]))
793
799
794
- # CFFI doesn't like compiling this
795
- # text.append("")
796
- # text.extend(handle_funcs(groups["static inline"]))
800
+ # Declare wrapper functions with '_' appended to the name
801
+ text .append ("" )
802
+ text .append ("/**************************" )
803
+ text .append ("* static inline functions *" )
804
+ text .append ("**************************/" )
805
+ text .extend (sorted ((info ["decl_text" ] for info in groups ["static inline" ]), key = sort_key ))
797
806
798
807
text .append ("" )
799
808
text .append ("/* int DEFINES */" )
@@ -816,6 +825,9 @@ def create_source_text(groups, *, char_defines=None):
816
825
]
817
826
for item in sorted (char_defines , key = sort_key ):
818
827
text .append (f"char *{ item } _STR = { item } ;" )
828
+ text .append ("" )
829
+ for node in groups ["static inline" ]:
830
+ text .append (node ["text" ])
819
831
return text
820
832
821
833
@@ -843,6 +855,7 @@ def main():
843
855
final_h = os .path .join (thisdir , "suitesparse_graphblas.h" )
844
856
final_no_complex_h = os .path .join (thisdir , "suitesparse_graphblas_no_complex.h" )
845
857
source_c = os .path .join (thisdir , "source.c" )
858
+ source_no_complex_c = os .path .join (thisdir , "source_no_complex.c" )
846
859
847
860
# Copy original file
848
861
print (f"Step 1: copy { args .graphblas } to { graphblas_h } " )
@@ -881,8 +894,14 @@ def main():
881
894
with open (source_c , "w" ) as f :
882
895
f .write ("\n " .join (text ))
883
896
897
+ # Create source (no complex)
898
+ print (f"Step 6: create { source_no_complex_c } " )
899
+ text = create_source_text (groups_no_complex )
900
+ with open (source_no_complex_c , "w" ) as f :
901
+ f .write ("\n " .join (text ))
902
+
884
903
# Check defines
885
- print ("Step 6 : check #define definitions" )
904
+ print ("Step 7 : check #define definitions" )
886
905
with open (graphblas_h ) as f :
887
906
text = f .read ()
888
907
define_lines = re .compile (r".*?#define\s+\w+\s+" )
0 commit comments