@@ -360,6 +360,7 @@ def get_groups(ast):
360
360
seen = set ()
361
361
groups = {}
362
362
vals = {x for x in lines if "extern GrB_Info GxB" in x } - seen
363
+ vals |= {x for x in lines if "extern " in x and "GxB_Iterator" in x and "GB" not in x } - seen
363
364
seen .update (vals )
364
365
groups ["GxB methods" ] = sorted (vals , key = sort_key )
365
366
@@ -368,6 +369,7 @@ def get_groups(ast):
368
369
groups ["GrB methods" ] = sorted (vals , key = sort_key )
369
370
370
371
vals = {x for x in lines if "extern GrB_Info GB" in x } - seen
372
+ vals |= {x for x in lines if "extern " in x and "GxB_Iterator" in x and "GB" in x } - seen
371
373
seen .update (vals )
372
374
groups ["GB methods" ] = sorted (vals , key = sort_key )
373
375
@@ -427,23 +429,6 @@ def get_groups(ast):
427
429
seen .update (vals )
428
430
groups ["GxB typedef funcs" ] = sorted (vals , key = sort_key )
429
431
430
- vals = []
431
- next_i = - 1
432
- for i , line in enumerate (lines ):
433
- if i < next_i or line in seen :
434
- continue
435
- if "inline static" in line and ("GB" in line or "GrB" in line or "GxB" in line ):
436
- val = [line ]
437
- i += 1
438
- while lines [i ] != "}" :
439
- val .append (lines [i ])
440
- i += 1
441
- val .append (lines [i ])
442
- next_i = i + 1
443
- seen .update (val )
444
- vals .append ("\n " .join (val ))
445
- groups ["static inline" ] = vals
446
-
447
432
vals = {x for x in lines if "typedef" in x and "GrB" in x } - seen
448
433
assert not vals , ", " .join (sorted (vals ))
449
434
groups ["not seen" ] = sorted (set (lines ) - seen , key = sort_key )
@@ -597,21 +582,10 @@ def visit_Decl(self, node):
597
582
if isinstance (node .type , c_ast .FuncDecl ) and node .storage == ["extern" ]:
598
583
self .functions .append (node )
599
584
600
- class FuncDefVisitorStaticInline (c_ast .NodeVisitor ):
601
- def __init__ (self ):
602
- self .functions = []
603
-
604
- def visit_FuncDef (self , node ):
605
- decl = node .decl
606
- if (
607
- isinstance (decl .type , c_ast .FuncDecl )
608
- and decl .storage == ["static" ]
609
- and decl .funcspec == ["inline" ]
610
- ):
611
- self .functions .append (node )
612
-
613
585
def handle_function_node (node ):
614
- if generator .visit (node .type .type ) != "GrB_Info" :
586
+ if generator .visit (node .type .type ) != "GrB_Info" and "GxB_Iterator" not in generator .visit (
587
+ node
588
+ ):
615
589
raise ValueError (generator .visit (node ))
616
590
if node .name in DEPRECATED :
617
591
return
@@ -625,6 +599,8 @@ def handle_function_node(node):
625
599
group = "vector"
626
600
elif "GxB_Scalar" in text or "GrB_Scalar" in text :
627
601
group = "scalar"
602
+ elif "GxB_Iterator" in text :
603
+ group = "iterator"
628
604
else :
629
605
group = node .name .split ("_" , 2 )[1 ]
630
606
group = {
@@ -665,52 +641,26 @@ def handle_function_node(node):
665
641
grb_nodes = [node for node in visitor .functions if node .name .startswith ("GrB_" )]
666
642
gxb_nodes = [node for node in visitor .functions if node .name .startswith ("GxB_" )]
667
643
gb_nodes = [node for node in visitor .functions if node .name .startswith ("GB_" )]
668
- assert len (grb_nodes ) == len (groups ["GrB methods" ])
669
- assert len (gxb_nodes ) == len (groups ["GxB methods" ])
670
- assert len (gb_nodes ) == len (groups ["GB methods" ])
671
-
672
- visitor = FuncDefVisitorStaticInline ()
673
- visitor .visit (ast )
674
- static_inline_nodes = visitor .functions
675
- assert len (static_inline_nodes ) == len (groups ["static inline" ])
676
- for node in static_inline_nodes :
677
- # Sanity check
678
- text = generator .visit (node ).strip ()
679
- assert text in groups ["static inline" ]
680
-
681
- def handle_static_inline (node ):
682
- decl = node .decl
683
- if decl .name in DEPRECATED :
684
- return
685
- # Append "_" to the name that we expose to Python
686
- decl .type .type .declname += "_"
687
- decl .storage = ["extern" ]
688
- decl .funcspec = []
689
- text = generator .visit (node ).strip ()
690
- decl_text = generator .visit (decl ).strip ()
691
- if skip_complex and has_complex (text ):
692
- return
693
- return {
694
- "name" : decl .name ,
695
- "group" : "static inline" ,
696
- "node" : node ,
697
- "text" : text + "\n " ,
698
- "decl_text" : decl_text + ";" ,
699
- }
644
+ assert len (grb_nodes ) == len (groups ["GrB methods" ]), (
645
+ len (grb_nodes ),
646
+ len (groups ["GrB methods" ]),
647
+ )
648
+ assert len (gxb_nodes ) == len (groups ["GxB methods" ]), (
649
+ len (gxb_nodes ),
650
+ len (groups ["GxB methods" ]),
651
+ )
652
+ assert len (gb_nodes ) == len (groups ["GB methods" ]), (len (gb_nodes ), len (groups ["GB methods" ]))
700
653
701
654
grb_funcs = (handle_function_node (node ) for node in grb_nodes )
702
655
gxb_funcs = (handle_function_node (node ) for node in gxb_nodes )
703
656
gb_funcs = (handle_function_node (node ) for node in gb_nodes )
704
- si_funcs = (handle_static_inline (node ) for node in static_inline_nodes )
705
657
grb_funcs = [x for x in grb_funcs if x is not None ]
706
658
gxb_funcs = [x for x in gxb_funcs if x is not None ]
707
659
gb_funcs = [x for x in gb_funcs if x is not None ]
708
- si_funcs = [x for x in si_funcs if x is not None ]
709
660
710
661
rv ["GrB methods" ] = sorted (grb_funcs , key = lambda x : sort_key (x ["text" ]))
711
662
rv ["GxB methods" ] = sorted (gxb_funcs , key = lambda x : sort_key (x ["text" ]))
712
663
rv ["GB methods" ] = sorted (gb_funcs , key = lambda x : sort_key (x ["text" ]))
713
- rv ["static inline" ] = sorted (si_funcs , key = lambda x : sort_key (x ["text" ]))
714
664
for key in groups .keys () - rv .keys ():
715
665
rv [key ] = groups [key ]
716
666
return rv
@@ -797,13 +747,6 @@ def handle_funcs(group):
797
747
text .append ("****************/" )
798
748
text .extend (handle_funcs (groups ["GxB methods" ]))
799
749
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 ))
806
-
807
750
text .append ("" )
808
751
text .append ("/* int DEFINES */" )
809
752
for item in sorted (defines , key = sort_key ):
@@ -825,9 +768,6 @@ def create_source_text(groups, *, char_defines=None):
825
768
]
826
769
for item in sorted (char_defines , key = sort_key ):
827
770
text .append (f"char *{ item } _STR = { item } ;" )
828
- text .append ("" )
829
- for node in groups ["static inline" ]:
830
- text .append (node ["text" ])
831
771
return text
832
772
833
773
@@ -855,7 +795,6 @@ def main():
855
795
final_h = os .path .join (thisdir , "suitesparse_graphblas.h" )
856
796
final_no_complex_h = os .path .join (thisdir , "suitesparse_graphblas_no_complex.h" )
857
797
source_c = os .path .join (thisdir , "source.c" )
858
- source_no_complex_c = os .path .join (thisdir , "source_no_complex.c" )
859
798
860
799
# Copy original file
861
800
print (f"Step 1: copy { args .graphblas } to { graphblas_h } " )
@@ -894,14 +833,8 @@ def main():
894
833
with open (source_c , "w" ) as f :
895
834
f .write ("\n " .join (text ))
896
835
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
-
903
836
# Check defines
904
- print ("Step 7 : check #define definitions" )
837
+ print ("Step 6 : check #define definitions" )
905
838
with open (graphblas_h ) as f :
906
839
text = f .read ()
907
840
define_lines = re .compile (r".*?#define\s+\w+\s+" )
0 commit comments