Skip to content

Commit fe91a17

Browse files
committed
fix structs_proc
1 parent 083ee21 commit fe91a17

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

pythonbpf/structs_pass.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
from llvmlite import ir
33
from .type_deducer import ctypes_to_ir
44

5-
structs_sym_tab = {}
5+
6+
def is_bpf_struct(cls_node):
7+
return any(
8+
isinstance(decorator, ast.Name) and decorator.id == "struct"
9+
for decorator in cls_node.decorator_list
10+
)
611

712

813
def structs_proc(tree, module, chunks):
914
""" Process all class definitions to find BPF structs """
15+
structs_sym_tab = {}
1016
for cls_node in chunks:
11-
# Check if this class is a struct
12-
is_struct = False
13-
for decorator in cls_node.decorator_list:
14-
if isinstance(decorator, ast.Name) and decorator.id == "struct":
15-
is_struct = True
16-
break
17-
if is_struct:
17+
if is_bpf_struct(cls_node):
1818
print(f"Found BPF struct: {cls_node.name}")
19-
process_bpf_struct(cls_node, module)
20-
continue
19+
struct_info = process_bpf_struct(cls_node, module)
20+
structs_sym_tab[cls_node.name] = struct_info
2121
return structs_sym_tab
2222

2323

0 commit comments

Comments
 (0)