Skip to content

Commit

Permalink
fix: return methods lost during integration of binding generation API
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaiR committed Aug 19, 2024
1 parent 9fbffdd commit 8f76b20
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 8 deletions.
8 changes: 4 additions & 4 deletions buildSrc/src/main/kotlin/tool/generator/api/jni_content.kt
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ private fun createFieldGetContent(field: CtField<*>): List<String> {
getArray.setType<Nothing>(f.createTypeParam("$arrayType[]"))

when (arrayType) {
"boolean", "short", "int", "float", "double", "long" -> {
"boolean", "byte", "short", "int", "float", "double", "long" -> {
getArray.setBody<Nothing>(
f.createCodeSnippet(
"""
Expand Down Expand Up @@ -569,7 +569,7 @@ private fun createFieldGetContent(field: CtField<*>): List<String> {
result += getArray.prettyprint(false)

when (arrayType) {
"boolean", "short", "int", "float", "double", "long" -> {
"boolean", "byte", "short", "int", "float", "double", "long" -> {
val getArrayIdx = getArray.clone()
getArrayIdx.addParameter<Nothing>(f.createParameter<Nothing>().apply {
setType<Nothing>(f.createTypeParam("int"))
Expand Down Expand Up @@ -625,7 +625,7 @@ private fun createFieldSetContent(field: CtField<*>): List<String> {
setArray.setSimpleName<Nothing>("nSet${field.simpleName}")

when (arrayType) {
"boolean", "short", "int", "float", "double", "long" -> {
"boolean", "byte", "short", "int", "float", "double", "long" -> {
setArray.setBody<Nothing>(
f.createCodeSnippet(
"""
Expand All @@ -649,7 +649,7 @@ private fun createFieldSetContent(field: CtField<*>): List<String> {
result += setArray.prettyprint(false)

when (arrayType) {
"boolean", "short", "int", "float", "double", "long" -> {
"boolean", "byte", "short", "int", "float", "double", "long" -> {
val setArrayIdx = setArray.clone()
setArrayIdx.parameters.clear()
setArrayIdx.addParameter<Nothing>(f.createParameter<Nothing>().apply {
Expand Down
40 changes: 38 additions & 2 deletions imgui-binding/src/generated/java/imgui/ImFontConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,22 @@ protected long create() {
return (intptr_t)cfg;
*/

// TODO: FontData
/**
* TTF/OTF data
*/
public native byte[] getFontData(); /*
int size = THIS->FontDataSize;
jbyteArray jBuf = env->NewByteArray(size);
env->SetByteArrayRegion(jBuf, 0, size, (jbyte*)THIS->FontData);
return jBuf;
*/

/**
* TTF/OTF data
*/
public native void setFontData(byte[] fontData); /*
THIS->FontData = &fontData[0];
*/

/**
* TTF/OTF data size
Expand Down Expand Up @@ -313,7 +328,28 @@ public void setGlyphOffset(final float valueX, final float valueY) {
THIS->GlyphOffset = value;
*/

// TODO: GlyphRanges
private short[] glyphRanges;

/**
* Pointer to a user-provided list of Unicode range (2 value per range, values are inclusive, zero-terminated list).
* THE ARRAY DATA NEEDS TO PERSIST AS LONG AS THE FONT IS ALIVE.
*/
public short[] getGlyphRanges() {
return glyphRanges;
}

/**
* Pointer to a user-provided list of Unicode range (2 value per range, values are inclusive, zero-terminated list).
* THE ARRAY DATA NEEDS TO PERSIST AS LONG AS THE FONT IS ALIVE.
*/
public void setGlyphRanges(final short[] glyphRanges) {
this.glyphRanges = glyphRanges;
nSetGlyphRanges(glyphRanges);
}

private native void nSetGlyphRanges(short[] glyphRanges); /*
THIS->GlyphRanges = glyphRanges != NULL ? (ImWchar*)&glyphRanges[0] : NULL;
*/

/**
* Minimum AdvanceX for glyphs, set Min to align font icons, set both Min/Max to enforce mono-space font
Expand Down
40 changes: 38 additions & 2 deletions imgui-binding/src/main/java/imgui/ImFontConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,22 @@ protected long create() {
return (intptr_t)cfg;
*/

// TODO: FontData
/**
* TTF/OTF data
*/
public native byte[] getFontData(); /*
int size = THIS->FontDataSize;
jbyteArray jBuf = env->NewByteArray(size);
env->SetByteArrayRegion(jBuf, 0, size, (jbyte*)THIS->FontData);
return jBuf;
*/

/**
* TTF/OTF data
*/
public native void setFontData(byte[] fontData); /*
THIS->FontData = &fontData[0];
*/

/**
* TTF/OTF data size
Expand Down Expand Up @@ -90,7 +105,28 @@ protected long create() {
@BindingField
public ImVec2 GlyphOffset;

// TODO: GlyphRanges
private short[] glyphRanges;

/**
* Pointer to a user-provided list of Unicode range (2 value per range, values are inclusive, zero-terminated list).
* THE ARRAY DATA NEEDS TO PERSIST AS LONG AS THE FONT IS ALIVE.
*/
public short[] getGlyphRanges() {
return glyphRanges;
}

/**
* Pointer to a user-provided list of Unicode range (2 value per range, values are inclusive, zero-terminated list).
* THE ARRAY DATA NEEDS TO PERSIST AS LONG AS THE FONT IS ALIVE.
*/
public void setGlyphRanges(final short[] glyphRanges) {
this.glyphRanges = glyphRanges;
nSetGlyphRanges(glyphRanges);
}

private native void nSetGlyphRanges(short[] glyphRanges); /*
THIS->GlyphRanges = glyphRanges != NULL ? (ImWchar*)&glyphRanges[0] : NULL;
*/

/**
* Minimum AdvanceX for glyphs, set Min to align font icons, set both Min/Max to enforce mono-space font
Expand Down

0 comments on commit 8f76b20

Please sign in to comment.