Skip to content

Commit

Permalink
Added missing annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
squid233 committed Dec 3, 2023
1 parent 5f859a5 commit 6701b9a
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
4 changes: 3 additions & 1 deletion demo/src/main/java/overrun/marshal/test/CMarshalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public interface CMarshalTest {

MemorySegment testWithArgAndReturnValue(MemorySegment segment);

@Custom("""
return testWithArgAndReturnValue(MemorySegment.NULL);""")
MemorySegment testWithCustomBody();

@Native(scope = MarshalScope.PRIVATE)
Expand All @@ -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);

Expand Down
30 changes: 30 additions & 0 deletions src/main/java/overrun/marshal/Custom.java
Original file line number Diff line number Diff line change
@@ -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();
}
30 changes: 30 additions & 0 deletions src/main/java/overrun/marshal/FixedSize.java
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit 6701b9a

Please sign in to comment.