diff --git a/demo/src/main/java/overrun/marshal/test/CMarshalTest.java b/demo/src/main/java/overrun/marshal/test/CMarshalTest.java index 72abc02..7c5741d 100644 --- a/demo/src/main/java/overrun/marshal/test/CMarshalTest.java +++ b/demo/src/main/java/overrun/marshal/test/CMarshalTest.java @@ -51,6 +51,8 @@ public interface CMarshalTest { MemorySegment testWithArgAndReturnValue(MemorySegment segment); + @Custom(""" + return testWithArgAndReturnValue(MemorySegment.NULL);""") MemorySegment testWithCustomBody(); @Native(scope = MarshalScope.PRIVATE) @@ -64,7 +66,7 @@ public interface CMarshalTest { void testWithRefArray(MemorySegment arr0, MemorySegment arr1, MemorySegment arr2, MemorySegment arr3, MemorySegment arr4, MemorySegment arr5); @Overload - void testWithRefArray(int[] arr0, @Ref int[] arr1, @Ref(nullable = true) int[] arr2, boolean[] arr3, @Ref boolean[] arr4, int[] arr5); + void testWithRefArray(int[] arr0, @Ref int[] arr1, @Ref(nullable = true) int[] arr2, boolean[] arr3, @Ref boolean[] arr4, @FixedSize(3) int[] arr5); void testWithString(MemorySegment str); diff --git a/src/main/java/overrun/marshal/Custom.java b/src/main/java/overrun/marshal/Custom.java new file mode 100644 index 0000000..45966c3 --- /dev/null +++ b/src/main/java/overrun/marshal/Custom.java @@ -0,0 +1,30 @@ +/* + * MIT License + * + * Copyright (c) 2023 Overrun Organization + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + */ + +package overrun.marshal; + +import java.lang.annotation.*; + +/** + * @author squid233 + * @since 0.1.0 + */ +@Documented +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.SOURCE) +public @interface Custom { + String value(); +} diff --git a/src/main/java/overrun/marshal/FixedSize.java b/src/main/java/overrun/marshal/FixedSize.java new file mode 100644 index 0000000..2b6ff9c --- /dev/null +++ b/src/main/java/overrun/marshal/FixedSize.java @@ -0,0 +1,30 @@ +/* + * MIT License + * + * Copyright (c) 2023 Overrun Organization + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + */ + +package overrun.marshal; + +import java.lang.annotation.*; + +/** + * @author squid233 + * @since 0.1.0 + */ +@Documented +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.SOURCE) +public @interface FixedSize { + int value(); +}