Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,25 @@
import java.util.concurrent.atomic.AtomicBoolean;

public abstract class JNISwiftInstance extends SwiftInstance {
/// Pointer to the "self".
private final long selfPointer;

/**
* The pointer to the instance in memory. I.e. the {@code self} of the Swift object or value.
*/
public final long pointer() {
return this.selfPointer;
}

/**
* The designated constructor of any imported Swift types.
*
* @param pointer a pointer to the memory containing the value
* @param arena the arena this object belongs to. When the arena goes out of scope, this value is destroyed.
*/
protected JNISwiftInstance(long pointer, SwiftArena arena) {
super(pointer, arena);
super(arena);
this.selfPointer = pointer;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@
import java.util.concurrent.atomic.AtomicBoolean;

public abstract class SwiftInstance {
/// Pointer to the "self".
private final long selfPointer;

/**
* The pointer to the instance in memory. I.e. the {@code self} of the Swift object or value.
*/
public final long pointer() {
return this.selfPointer;
}

/**
* Called when the arena has decided the value should be destroyed.
Expand Down Expand Up @@ -55,8 +46,7 @@ public final long pointer() {
* @param pointer a pointer to the memory containing the value
* @param arena the arena this object belongs to. When the arena goes out of scope, this value is destroyed.
*/
protected SwiftInstance(long pointer, SwiftArena arena) {
this.selfPointer = pointer;
protected SwiftInstance(SwiftArena arena) {
arena.register(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public abstract class FFMSwiftInstance extends SwiftInstance {
* @param arena the arena this object belongs to. When the arena goes out of scope, this value is destroyed.
*/
protected FFMSwiftInstance(MemorySegment segment, AllocatingSwiftArena arena) {
super(segment.address(), arena);
super(arena);
this.memorySegment = segment;
}

Expand Down
Loading