-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add @type annotation based StructType generation
- Loading branch information
1 parent
d08bc28
commit 3bcb531
Showing
11 changed files
with
693 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
annotations/src/main/java/me/bechberger/ebpf/annotations/bpf/Type.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package me.bechberger.ebpf.annotations.bpf; | ||
|
||
import me.bechberger.ebpf.annotations.Size; | ||
import me.bechberger.ebpf.annotations.Unsigned; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Annotates a record for with a BPFStructType is generated | ||
* <p> | ||
* Currently only supported directly inside {@link BPF} annotated classes | ||
* <p> | ||
* Example: | ||
* {@snippet : | ||
* record Event(@Unsigned int pid, @Size(256) String filename, @Size(16) String comm) {} | ||
* } | ||
* <p> | ||
* Members can be one of the following: | ||
* <ul> | ||
* <li>integer types (int, long, ...), optionally annotated with {@link Unsigned} if unsigned</li> | ||
* <li>String types, annotated with {@link Size} to specify the size</li> | ||
* <li>Other {@link Type} annotated types</li> | ||
* <li>{@link Type.Member} annotated member, to specify the BPFType directly</li> | ||
* </ul> | ||
*/ | ||
@Target(ElementType.TYPE) | ||
public @interface Type { | ||
|
||
/** Name of the generated BPFStructType, uses the type as default */ | ||
String name() default ""; | ||
|
||
public @interface Member { | ||
|
||
/** Java statement directly copied into the result at the place of the BPFType */ | ||
String bpfType(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.