Add map decorator and simplify type conversion logic

This commit is contained in:
2025-09-08 20:32:51 +05:30
parent 83937dc11a
commit 08ff07641e
4 changed files with 16 additions and 13 deletions

View File

@ -1,12 +1,12 @@
from pythonbpf.decorators import bpf, bpfglobal, section
from pythonbpf.decorators import bpf, map, section, bpfglobal
from ctypes import c_void_p, c_int64, c_int32, c_uint64
from pythonbpf.helpers import bpf_ktime_get_ns
from pythonbpf.maps import HashMap
@bpf
@bpfglobal
def last():
@map
def last() -> HashMap:
return HashMap(key_type=c_uint64, value_type=c_uint64, max_entries=1)
@ -25,5 +25,9 @@ def hello_again(ctx: c_void_p) -> c_int64:
ts = bpf_ktime_get_ns()
return c_int64(0)
# @bpf
# @bpfglobal
# def LICENSE() -> str:
# return "GPL"
LICENSE = "GPL"