File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ import logging
2+ from .pylibbpf import (
3+ BpfObject as _BpfObject , # C++ object (internal)
4+ BpfProgram ,
5+ BpfMap ,
6+ PerfEventArray ,
7+ StructParser ,
8+ BpfException ,
9+ )
10+ from .wrappers import BpfObjectWrapper
11+ from .ir_to_ctypes import convert_structs_to_ctypes , is_pythonbpf_structs
12+
13+ logger = logging .getLogger (__name__ )
14+
15+
16+ class BpfObject (BpfObjectWrapper ):
17+ """BpfObject with automatic struct conversion"""
18+
19+ def __init__ (self , object_path : str , structs = None ):
20+ """Create a BPF object"""
21+ if structs is None :
22+ structs = {}
23+ elif is_pythonbpf_structs (structs ):
24+ logger .info (f"Auto-converting { len (structs )} PythonBPF structs to ctypes" )
25+ structs = convert_structs_to_ctypes (structs )
26+
27+ # Create C++ BpfObject with converted structs
28+ cpp_obj = _BpfObject (object_path , structs )
29+
30+ # Initialize wrapper
31+ super ().__init__ (cpp_obj )
32+
33+
34+ __all__ = [
35+ "BpfObject" ,
36+ "BpfProgram" ,
37+ "BpfMap" ,
38+ "PerfEventArray" ,
39+ "StructParser" ,
40+ "BpfException" ,
41+ ]
You can’t perform that action at this time.
0 commit comments