Skip to content

Commit

Permalink
WheelSettings: implement RefTarget
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Oct 13, 2024
1 parent cf4810f commit f8127f4
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions src/main/java/com/github/stephengold/joltjni/WheelSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ of this software and associated documentation files (the "Software"), to deal
import com.github.stephengold.joltjni.readonly.ConstWheelSettings;
import com.github.stephengold.joltjni.readonly.Vec3Arg;
import com.github.stephengold.joltjni.template.Ref;
import com.github.stephengold.joltjni.template.RefTarget;

/**
* Settings used to construct a {@code Wheel}.
Expand All @@ -32,7 +33,7 @@ of this software and associated documentation files (the "Software"), to deal
*/
abstract public class WheelSettings
extends SerializableObject
implements ConstWheelSettings {
implements ConstWheelSettings, RefTarget {
// *************************************************************************
// constructors

Expand Down Expand Up @@ -79,13 +80,6 @@ public void setWidth(float width) {
long settingsVa = va();
setWidth(settingsVa, width);
}

/**
* Create a counted reference to the native {@code WheelSettings}.
*
* @return a new JVM object with a new native object assigned
*/
abstract public Ref toRef();
// *************************************************************************
// ConstWheelSettings methods

Expand Down Expand Up @@ -134,6 +128,31 @@ public float getWidth() {
return result;
}
// *************************************************************************
// RefTarget methods

/**
* Count the active references to the native {@code WheelSettings}. The
* settings are unaffected.
*
* @return the count (≥0)
*/
@Override
abstract public int getRefCount();

/**
* Mark the native {@code WheelSettings} as embedded.
*/
@Override
abstract public void setEmbedded();

/**
* Create a counted reference to the native {@code WheelSettings}.
*
* @return a new JVM object with a new native object assigned
*/
@Override
abstract public Ref toRef();
// *************************************************************************
// native private methods

native private static float getPositionX(long settingsVa);
Expand Down

0 comments on commit f8127f4

Please sign in to comment.