Skip to content

Commit

Permalink
Remove usage of CEnum
Browse files Browse the repository at this point in the history
  • Loading branch information
squid233 committed Aug 29, 2024
1 parent 741e762 commit f55dfae
Show file tree
Hide file tree
Showing 10 changed files with 242 additions and 437 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,15 @@ public record OfObjInt<T>(T x, int y) {
*/
public record OfObjLong<T>(T x, long y) {
}

/**
* A tuple of an int and a long.
*
* @param x the first value.
* @param y the second value.
* @author squid233
* @since 0.1.0
*/
public record OfIntLong(int x, long y) {
}
}
162 changes: 86 additions & 76 deletions modules/overrungl.nfd/src/main/java/overrungl/nfd/NFD.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,23 @@ public String next() {
throw new NoSuchElementException();
}
String[] s = new String[1];
final NFDResult result = switch (kind) {
final int result = switch (kind) {
case N -> nfd.pathSetEnumNextN(segment.segment(), s);
case U8 -> nfd.pathSetEnumNextU8(segment.segment(), s);
};
if (result == NFDResult.ERROR) throw errorIterating(nfd);
if (result == NFD.ERROR) throw errorIterating(nfd);
nextPath = s[0];
return curr;
}
}

private static Tuple2<NFDResult, NFDEnumerator> fromPathSet(Kind kind, SegmentAllocator allocator, MemorySegment pathSet) {
private static Tuple2.OfObjInt<NFDEnumerator> fromPathSet(Kind kind, SegmentAllocator allocator, MemorySegment pathSet) {
final MemorySegment seg = allocator.allocate(ADDRESS);
final NFDResult result = NFD.INSTANCE.pathSetGetEnum(pathSet, seg);
return new Tuple2<>(result,
result == NFDResult.OKAY ?
final int result = NFD.INSTANCE.pathSetGetEnum(pathSet, seg);
return new Tuple2.OfObjInt<>(result == NFD.OKAY ?
new NFDEnumerator(kind, Segment.OF.of(seg)) :
null);
null,
result);
}

/**
Expand All @@ -134,7 +134,7 @@ private static Tuple2<NFDResult, NFDEnumerator> fromPathSet(Kind kind, SegmentAl
* @param pathSet the path set.
* @return the result and the enumerator.
*/
public static Tuple2<NFDResult, NFDEnumerator> fromPathSetN(SegmentAllocator allocator, MemorySegment pathSet) {
public static Tuple2.OfObjInt<NFDEnumerator> fromPathSetN(SegmentAllocator allocator, MemorySegment pathSet) {
return fromPathSet(Kind.N, allocator, pathSet);
}

Expand All @@ -145,7 +145,7 @@ public static Tuple2<NFDResult, NFDEnumerator> fromPathSetN(SegmentAllocator all
* @param pathSet the path set.
* @return the result and the enumerator.
*/
public static Tuple2<NFDResult, NFDEnumerator> fromPathSetU8(SegmentAllocator allocator, MemorySegment pathSet) {
public static Tuple2.OfObjInt<NFDEnumerator> fromPathSetU8(SegmentAllocator allocator, MemorySegment pathSet) {
return fromPathSet(Kind.U8, allocator, pathSet);
}

Expand All @@ -158,13 +158,13 @@ private static IllegalStateException errorIterating(NFD nfd) {
public Iterator<String> iterator() {
// TODO: 2023/7/6 Value object
String[] s = new String[1];
final NFDResult result = switch (kind) {
final int result = switch (kind) {
case N -> nfd.pathSetEnumNextN(segment.segment(), s);
case U8 -> nfd.pathSetEnumNextU8(segment.segment(), s);
};
final String path = s[0];
if (path == null || result != NFDResult.OKAY) {
if (result == NFDResult.ERROR) {
if (path == null || result != NFD.OKAY) {
if (result == NFD.ERROR) {
throw errorIterating(nfd);
}
return EMPTY_ITERATOR;
Expand Down
68 changes: 0 additions & 68 deletions modules/overrungl.nfd/src/main/java/overrungl/nfd/NFDResult.java

This file was deleted.

This file was deleted.

46 changes: 0 additions & 46 deletions modules/overrungl.stb/src/main/java/overrungl/stb/STBIREdge.java

This file was deleted.

71 changes: 0 additions & 71 deletions modules/overrungl.stb/src/main/java/overrungl/stb/STBIRFilter.java

This file was deleted.

Loading

0 comments on commit f55dfae

Please sign in to comment.