Skip to content

Commit fc33130

Browse files
committed
[SwiftKit] Move 'selfPointer' to 'JNISwiftInstance'
`FFMSwiftInstance` doesn't need it.
1 parent 17210b7 commit fc33130

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

SwiftKitCore/src/main/java/org/swift/swiftkit/core/JNISwiftInstance.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,25 @@
1717
import java.util.concurrent.atomic.AtomicBoolean;
1818

1919
public abstract class JNISwiftInstance extends SwiftInstance {
20+
/// Pointer to the "self".
21+
private final long selfPointer;
22+
23+
/**
24+
* The pointer to the instance in memory. I.e. the {@code self} of the Swift object or value.
25+
*/
26+
public final long pointer() {
27+
return this.selfPointer;
28+
}
29+
2030
/**
2131
* The designated constructor of any imported Swift types.
2232
*
2333
* @param pointer a pointer to the memory containing the value
2434
* @param arena the arena this object belongs to. When the arena goes out of scope, this value is destroyed.
2535
*/
2636
protected JNISwiftInstance(long pointer, SwiftArena arena) {
27-
super(pointer, arena);
37+
super(arena);
38+
this.selfPointer = pointer;
2839
}
2940

3041
/**

SwiftKitCore/src/main/java/org/swift/swiftkit/core/SwiftInstance.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@
1717
import java.util.concurrent.atomic.AtomicBoolean;
1818

1919
public abstract class SwiftInstance {
20-
/// Pointer to the "self".
21-
private final long selfPointer;
22-
23-
/**
24-
* The pointer to the instance in memory. I.e. the {@code self} of the Swift object or value.
25-
*/
26-
public final long pointer() {
27-
return this.selfPointer;
28-
}
2920

3021
/**
3122
* Called when the arena has decided the value should be destroyed.
@@ -55,8 +46,7 @@ public final long pointer() {
5546
* @param pointer a pointer to the memory containing the value
5647
* @param arena the arena this object belongs to. When the arena goes out of scope, this value is destroyed.
5748
*/
58-
protected SwiftInstance(long pointer, SwiftArena arena) {
59-
this.selfPointer = pointer;
49+
protected SwiftInstance(SwiftArena arena) {
6050
arena.register(this);
6151
}
6252

SwiftKitFFM/src/main/java/org/swift/swiftkit/ffm/FFMSwiftInstance.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public abstract class FFMSwiftInstance extends SwiftInstance {
4141
* @param arena the arena this object belongs to. When the arena goes out of scope, this value is destroyed.
4242
*/
4343
protected FFMSwiftInstance(MemorySegment segment, AllocatingSwiftArena arena) {
44-
super(segment.address(), arena);
44+
super(arena);
4545
this.memorySegment = segment;
4646
}
4747

0 commit comments

Comments
 (0)