@@ -56,6 +56,8 @@ def groupby(index, seq):
56
56
AUTO = "/* This file is automatically generated */"
57
57
58
58
DEPRECATED = {
59
+ # Strongly deprecated in SuiteSparse:GraphBLAS 10; will be removed in 11
60
+ "GrB_Field" ,
59
61
# enums
60
62
"GxB_IS_HYPER" ,
61
63
"GrB_SCMP" ,
@@ -298,6 +300,7 @@ def groupby(index, seq):
298
300
"GxB_COMPRESSION_LZ4HC" ,
299
301
"GxB_COMPRESSION_ZSTD" ,
300
302
"GxB_COMPRESSION_NONE" ,
303
+ "GxB_USE_VALUES" ,
301
304
}
302
305
303
306
CHAR_DEFINES = {
@@ -354,6 +357,22 @@ def visit_Typedef(self, node):
354
357
return rv
355
358
356
359
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
+
357
376
def get_ast (filename ):
358
377
fake_include = os .path .dirname (pycparser .__file__ ) + "utils/fake_libc_include"
359
378
ast = parse_file (filename , cpp_args = f"-I{ fake_include } " )
@@ -428,6 +447,21 @@ def get_groups(ast):
428
447
seen .update (val .splitlines ())
429
448
groups ["GxB typedef enums" ] = sorted (vals , key = lambda x : sort_key (x .rsplit ("}" , 1 )[- 1 ]))
430
449
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
+
431
465
missing_enums = set (enums ) - set (groups ["GrB typedef enums" ]) - set (groups ["GxB typedef enums" ])
432
466
missing_enums = {x for x in missing_enums if not any (y in x for y in IGNORE_ENUMS )}
433
467
assert not missing_enums , ", " .join (sorted (missing_enums ))
@@ -581,6 +615,12 @@ def handle_typedef_funcs(group):
581
615
582
616
rv ["GxB typedef funcs" ] = list (handle_typedef_funcs (groups ["GxB typedef funcs" ]))
583
617
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
+
584
624
class FuncDeclVisitor (c_ast .NodeVisitor ):
585
625
def __init__ (self ):
586
626
self .functions = []
@@ -628,6 +668,7 @@ def handle_function_node(node):
628
668
"IndexBinaryOp" : "indexbinary" ,
629
669
"Iterator" : "iterator" ,
630
670
"Context" : "context" ,
671
+ "Container" : "container" ,
631
672
# "everything else" is "core"
632
673
"getVersion" : "core" ,
633
674
"Global" : "core" ,
@@ -655,6 +696,13 @@ def handle_function_node(node):
655
696
len (grb_nodes ),
656
697
len (groups ["GrB methods" ]),
657
698
)
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
+
658
706
assert len (gxb_nodes ) == len (groups ["GxB methods" ]), (
659
707
len (gxb_nodes ),
660
708
len (groups ["GxB methods" ]),
@@ -701,6 +749,10 @@ def create_header_text(groups, *, char_defines=None, defines=None):
701
749
for group in groups ["GxB typedef funcs" ]:
702
750
text .append (group ["text" ])
703
751
text .append ("" )
752
+ text .append ("/* GxB structs */" )
753
+ for group in groups ["GxB struct" ]:
754
+ text .append (group ["text" ])
755
+ text .append ("" )
704
756
text .append ("/* GrB enums */" )
705
757
for group in groups ["GrB typedef enums" ]:
706
758
text .append (group ["text" ])
0 commit comments