Skip to content

Commit d8cddb9

Browse files
committed
Add signature extraction to HelperHandlerRegistry
1 parent 33e18f6 commit d8cddb9

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pythonbpf/helper/helper_registry.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,22 @@ def get_handler(cls, helper_name):
4040
def has_handler(cls, helper_name):
4141
"""Check if a handler function is registered for a helper"""
4242
return helper_name in cls._handlers
43+
44+
@classmethod
45+
def get_signature(cls, helper_name):
46+
"""Get the signature of a helper function"""
47+
return cls._handlers.get(helper_name)
48+
49+
@classmethod
50+
def get_param_type(cls, helper_name, index):
51+
"""Get the type of a parameter of a helper function by the index"""
52+
signature = cls.get_signature(helper_name)
53+
if signature and 0 <= index < len(signature.arg_types):
54+
return signature.arg_types[index]
55+
return None
56+
57+
@classmethod
58+
def get_return_type(cls, helper_name):
59+
"""Get the return type of a helper function"""
60+
signature = cls.get_signature(helper_name)
61+
return signature.return_type if signature else None

0 commit comments

Comments
 (0)