Skip to content

Commit

Permalink
Merge pull request #25 from Over-Run/update
Browse files Browse the repository at this point in the history
  • Loading branch information
squid233 authored Dec 2, 2024
2 parents 21e275a + 93ca089 commit 65fe677
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 303 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ allprojects {
// add your dependencies
compileOnly("org.jetbrains:annotations:25.0.0")
testImplementation("org.junit.jupiter:junit-jupiter:$junitVersion")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testImplementation("io.github.over-run:platform:$platformVersion")
api("io.github.over-run:memstack:$memstackVersion")
}
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ projGroupId=io.github.over-run
projArtifactId=marshal
# The project name should only contain lowercase letters, numbers and hyphen.
projName=marshal
projVersion=0.1.0-alpha.36-jdk23
projDesc=Marshaler of native libraries
projVersion=0.1.0-alpha.37-jdk23
projDesc=Marshal allows you to conveniently create native library bindings with FFM API.
# Uncomment them if you want to publish to maven repository.
projUrl=https://github.com/Over-Run/marshal
projLicenseUrl=https://raw.githubusercontent.com/Over-Run/marshal/main/LICENSE
Expand All @@ -34,6 +34,6 @@ jdkEnablePreview=true
# Uncomment it if you need to use EA build of JDK.
#jdkEarlyAccessDoc=jdk23

junitVersion=5.11.0
junitVersion=5.11.3
memstackVersion=0.3.0
platformVersion=1.0.0
54 changes: 0 additions & 54 deletions src/main/java/overrun/marshal/CanonicalLayouts.java

This file was deleted.

11 changes: 3 additions & 8 deletions src/main/java/overrun/marshal/DowncallFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ private static void popStack(Throwable t) {
/// @param ref ref
/// @param sized sized
/// @param charset charset
/// @param canonicalType canonicalType
/// @return the created [DowncallMethodParameter]
public static DowncallMethodParameter createDowncallMethodParameter(
MethodHandles.Lookup lookup,
Expand All @@ -135,10 +134,9 @@ public static DowncallMethodParameter createDowncallMethodParameter(
boolean byValue,
boolean ref,
long sized,
String charset,
String canonicalType
String charset
) {
return new DowncallMethodParameter(parameterType, byValue, ref, sized, charset, canonicalType);
return new DowncallMethodParameter(parameterType, byValue, ref, sized, charset);
}

/// BSM for [DowncallMethodType]
Expand All @@ -152,7 +150,6 @@ public static DowncallMethodParameter createDowncallMethodParameter(
/// @param criticalAllowHeapAccess criticalAllowHeapAccess
/// @param sized sized
/// @param charset charset
/// @param canonicalType canonicalType
/// @param args parameters
/// @return the created [DowncallMethodType]
public static DowncallMethodType createDowncallMethodType(
Expand All @@ -165,7 +162,6 @@ public static DowncallMethodType createDowncallMethodType(
boolean criticalAllowHeapAccess,
long sized,
String charset,
String canonicalType,
Object... args
) {
return new DowncallMethodType(entrypoint,
Expand All @@ -175,8 +171,7 @@ public static DowncallMethodType createDowncallMethodType(
critical,
criticalAllowHeapAccess,
sized,
charset,
canonicalType);
charset);
}

/// BSM for [ConvertedClassType]
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/overrun/marshal/gen/CType.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @since 0.1.0
*/
@Documented
@Target(ElementType.TYPE_USE)
@Target({ElementType.METHOD, ElementType.PARAMETER})
@Retention(RetentionPolicy.SOURCE)
public @interface CType {
/**
Expand Down
45 changes: 0 additions & 45 deletions src/main/java/overrun/marshal/gen/CanonicalType.java

This file was deleted.

23 changes: 6 additions & 17 deletions src/main/java/overrun/marshal/gen/DowncallMethodParameter.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,37 +31,33 @@
/// @param ref `true` if returns from native function
/// @param sized value of [Sized]
/// @param charset value of [StrCharset]
/// @param canonicalType value of [CanonicalType]
/// @author squid233
/// @since 0.1.0
public record DowncallMethodParameter(
ConvertedClassType type,
boolean byValue,
boolean ref,
long sized,
String charset,
String canonicalType
String charset
) implements Constable {
/// Creates a downcall method parameter from the given parameter.
///
/// @param parameter the parameter
/// @return the downcall method parameter
public static DowncallMethodParameter of(Parameter parameter) {
CanonicalType anCanonicalType = parameter.getDeclaredAnnotation(CanonicalType.class);
Sized anSized = parameter.getDeclaredAnnotation(Sized.class);
StrCharset anStrCharset = parameter.getDeclaredAnnotation(StrCharset.class);

return new DowncallMethodParameter(ConvertedClassType.parameterType(parameter),
parameter.getDeclaredAnnotation(ByValue.class) != null,
parameter.getDeclaredAnnotation(Ref.class) != null,
anSized != null ? anSized.value() : -1,
anStrCharset != null ? anStrCharset.value() : null,
anCanonicalType != null ? anCanonicalType.value() : null);
anStrCharset != null ? anStrCharset.value() : null);
}

@Override
public Optional<Desc> describeConstable() {
return Optional.of(new Desc(type.describeConstable().orElseThrow(), byValue, ref, sized, charset, canonicalType));
return Optional.of(new Desc(type.describeConstable().orElseThrow(), byValue, ref, sized, charset));
}

@Override
Expand All @@ -70,9 +66,6 @@ public String toString() {
if (byValue) {
sb.append("[ByValue]");
}
if (canonicalType != null) {
sb.append("[CanonicalType=").append(canonicalType).append(']');
}
if (ref) {
sb.append("[Ref]");
}
Expand All @@ -93,7 +86,6 @@ public static final class Desc extends DynamicConstantDesc<DowncallMethodParamet
private final boolean ref;
private final long sized;
private final String charset;
private final String canonicalType;

/// constructor
///
Expand All @@ -102,28 +94,25 @@ public static final class Desc extends DynamicConstantDesc<DowncallMethodParamet
/// @param ref ref
/// @param sized sized
/// @param charset charset
/// @param canonicalType canonicalType
public Desc(ConvertedClassType.Desc type, boolean byValue, boolean ref, long sized, String charset, String canonicalType) {
public Desc(ConvertedClassType.Desc type, boolean byValue, boolean ref, long sized, String charset) {
super(Constants.BSM_DowncallFactory_createDowncallMethodParameter,
ConstantDescs.DEFAULT_NAME,
Constants.CD_DowncallMethodParameter,
type,
byValue ? ConstantDescs.TRUE : ConstantDescs.FALSE,
ref ? ConstantDescs.TRUE : ConstantDescs.FALSE,
sized,
charset != null ? charset : ConstantDescs.NULL,
canonicalType != null ? canonicalType : ConstantDescs.NULL);
charset != null ? charset : ConstantDescs.NULL);
this.type = type;
this.byValue = byValue;
this.ref = ref;
this.sized = sized;
this.charset = charset;
this.canonicalType = canonicalType;
}

@Override
public DowncallMethodParameter resolveConstantDesc(MethodHandles.Lookup lookup) throws ReflectiveOperationException {
return new DowncallMethodParameter(type.resolveConstantDesc(lookup), byValue, ref, sized, charset, canonicalType);
return new DowncallMethodParameter(type.resolveConstantDesc(lookup), byValue, ref, sized, charset);
}
}
}
Loading

0 comments on commit 65fe677

Please sign in to comment.