@@ -56,6 +56,8 @@ def groupby(index, seq):
5656AUTO = "/* This file is automatically generated */"
5757
5858DEPRECATED = {
59+ # Strongly deprecated in SuiteSparse:GraphBLAS 10; will be removed in 11
60+ "GrB_Field" ,
5961 # enums
6062 "GxB_IS_HYPER" ,
6163 "GrB_SCMP" ,
@@ -298,6 +300,7 @@ def groupby(index, seq):
298300 "GxB_COMPRESSION_LZ4HC" ,
299301 "GxB_COMPRESSION_ZSTD" ,
300302 "GxB_COMPRESSION_NONE" ,
303+ "GxB_USE_VALUES" ,
301304}
302305
303306CHAR_DEFINES = {
@@ -354,6 +357,22 @@ def visit_Typedef(self, node):
354357 return rv
355358
356359
360+ class VisitStruct (c_generator .CGenerator ):
361+ def __init__ (self , * args , ** kwargs ):
362+ super ().__init__ (* args , ** kwargs )
363+ self .results = []
364+
365+ def visit_Struct (self , node ):
366+ rv = super ().visit_Struct (node )
367+ if (
368+ ("GxB_" in node .name or "GrB_" in node .name )
369+ and "_struct" in node .name
370+ and node .decls is not None
371+ ):
372+ self .results .append (rv + ";" )
373+ return rv
374+
375+
357376def get_ast (filename ):
358377 fake_include = os .path .dirname (pycparser .__file__ ) + "utils/fake_libc_include"
359378 ast = parse_file (filename , cpp_args = f"-I{ fake_include } " )
@@ -428,6 +447,21 @@ def get_groups(ast):
428447 seen .update (val .splitlines ())
429448 groups ["GxB typedef enums" ] = sorted (vals , key = lambda x : sort_key (x .rsplit ("}" , 1 )[- 1 ]))
430449
450+ g = VisitStruct ()
451+ _ = g .visit (ast )
452+ structs = g .results
453+
454+ # No non-opaque GrB structs yet
455+ # vals = {x for x in structs if "struct GrB" in x}
456+ # for val in vals:
457+ # seen.update(val.splitlines())
458+ # groups["GrB struct"] = sorted(vals)
459+
460+ vals = {x for x in structs if "struct GxB" in x }
461+ for val in vals :
462+ seen .update (val .splitlines ())
463+ groups ["GxB struct" ] = sorted (vals )
464+
431465 missing_enums = set (enums ) - set (groups ["GrB typedef enums" ]) - set (groups ["GxB typedef enums" ])
432466 missing_enums = {x for x in missing_enums if not any (y in x for y in IGNORE_ENUMS )}
433467 assert not missing_enums , ", " .join (sorted (missing_enums ))
@@ -581,6 +615,12 @@ def handle_typedef_funcs(group):
581615
582616 rv ["GxB typedef funcs" ] = list (handle_typedef_funcs (groups ["GxB typedef funcs" ]))
583617
618+ def handle_structs (group ):
619+ for text in group :
620+ yield {"text" : text }
621+
622+ rv ["GxB struct" ] = list (handle_structs (groups ["GxB struct" ]))
623+
584624 class FuncDeclVisitor (c_ast .NodeVisitor ):
585625 def __init__ (self ):
586626 self .functions = []
@@ -628,6 +668,7 @@ def handle_function_node(node):
628668 "IndexBinaryOp" : "indexbinary" ,
629669 "Iterator" : "iterator" ,
630670 "Context" : "context" ,
671+ "Container" : "container" ,
631672 # "everything else" is "core"
632673 "getVersion" : "core" ,
633674 "Global" : "core" ,
@@ -655,6 +696,13 @@ def handle_function_node(node):
655696 len (grb_nodes ),
656697 len (groups ["GrB methods" ]),
657698 )
699+
700+ # Temporary hack for v10.0.1, which duplicates `GxB_Serialized_get_Scalar`
701+ temp_seen = set ()
702+ gxb_nodes = [
703+ temp_seen .add (node .name ) or node for node in gxb_nodes if node .name not in temp_seen
704+ ]
705+
658706 assert len (gxb_nodes ) == len (groups ["GxB methods" ]), (
659707 len (gxb_nodes ),
660708 len (groups ["GxB methods" ]),
@@ -701,6 +749,10 @@ def create_header_text(groups, *, char_defines=None, defines=None):
701749 for group in groups ["GxB typedef funcs" ]:
702750 text .append (group ["text" ])
703751 text .append ("" )
752+ text .append ("/* GxB structs */" )
753+ for group in groups ["GxB struct" ]:
754+ text .append (group ["text" ])
755+ text .append ("" )
704756 text .append ("/* GrB enums */" )
705757 for group in groups ["GrB typedef enums" ]:
706758 text .append (group ["text" ])
0 commit comments