File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change 1+ from dataclasses import dataclass
2+ from llvmlite import ir
13from typing import Callable
24
35
6+ @dataclass
7+ class HelperSignature :
8+ """Signature of a BPF helper function"""
9+
10+ arg_types : list [ir .Type ]
11+ return_type : ir .Type
12+ func : Callable
13+
14+
415class HelperHandlerRegistry :
516 """Registry for BPF helpers"""
617
7- _handlers : dict [str , Callable ] = {}
18+ _handlers : dict [str , HelperSignature ] = {}
819
920 @classmethod
10- def register (cls , helper_name ):
21+ def register (cls , helper_name , param_types = None , return_type = None ):
1122 """Decorator to register a handler function for a helper"""
1223
1324 def decorator (func ):
14- cls ._handlers [helper_name ] = func
25+ helper_sig = HelperSignature (
26+ arg_types = param_types , return_type = return_type , func = func
27+ )
28+ cls ._handlers [helper_name ] = helper_sig
1529 return func
1630
1731 return decorator
1832
1933 @classmethod
2034 def get_handler (cls , helper_name ):
2135 """Get the handler function for a helper"""
22- return cls ._handlers .get (helper_name )
36+ handler = cls ._handlers .get (helper_name )
37+ return handler .func if handler else None
2338
2439 @classmethod
2540 def has_handler (cls , helper_name ):
You can’t perform that action at this time.
0 commit comments