Skip to content
This repository was archived by the owner on Jun 19, 2024. It is now read-only.

Commit 50d1338

Browse files
authored
Merge pull request #22 from LabyMod/develop
Use real return type for Javascript called methods
2 parents 25697c2 + 6253cb1 commit 50d1338

File tree

4 files changed

+40
-9
lines changed

4 files changed

+40
-9
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3.1
1+
0.3.2

ultralight-java-databind/src/main/java/com/labymedia/ultralight/DatabindJavascriptMethodHandler.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,15 @@ private JavascriptValue onCallAsFunction(
111111
);
112112

113113
try {
114+
Object ret = method.invoke(privateData.instance(), parameters.toArray());
115+
Class<?> suggestedReturnType = method.getReturnType();
116+
117+
if (ret != null) {
118+
suggestedReturnType = ret.getClass();
119+
}
120+
114121
// Invoke method with constructed arguments
115-
return conversionUtils.toJavascript(
116-
context, method.invoke(privateData.instance(), parameters.toArray()), method.getReturnType());
122+
return conversionUtils.toJavascript(context, ret, suggestedReturnType);
117123
} catch (IllegalAccessException exception) {
118124
throw new JavascriptInteropException("Unable to access method: " + method.getName(), exception);
119125
} catch (InvocationTargetException exception) {

ultralight-java-lwjgl3-opengl/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def ultralightOsIdentifier = {
6161

6262
task copyTestResources(type: Copy) {
6363
from new File(project(':ultralight-java-native').buildDir, "cmake-gen-${ultralightOsIdentifier()}/3rdparty/ultralight-${ultralightOsIdentifier()}/bin")
64-
include "**/*.dll", "resources/*"
64+
include "**/*.dll", "**/*.so", "**/*.dylib", "resources/*"
6565
into runDir
6666
}
6767

ultralight-java-lwjgl3-opengl/src/test/java/com/labymedia/ultralight/lwjgl3/opengl/TestApplication.java

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,40 @@ public void run() {
177177
// Update the size
178178
updateSize(window, sizeBuffer.get(0), sizeBuffer.get(1));
179179

180+
/*
181+
* Following snippet disabled due to GLFW bug, glfwGetWindowContentScale returns invalid values!
182+
*
183+
* On a test system
184+
*/
180185
// Update scale for the first time
181-
FloatBuffer scaleBuffer = stack.callocFloat(2);
186+
// FloatBuffer scaleBuffer = stack.callocFloat(2);
182187

183-
// Retrieve the size into the float buffer
184-
glfwGetWindowContentScale(window,
185-
(FloatBuffer) scaleBuffer.slice().position(0), (FloatBuffer) scaleBuffer.slice().position(1));
188+
// Retrieve the scale into the float buffer
189+
// glfwGetWindowContentScale(window,
190+
// (FloatBuffer) scaleBuffer.slice().position(0), (FloatBuffer) scaleBuffer.slice().position(1));
191+
192+
// Retrieve framebuffer size for scale calculation
193+
IntBuffer framebufferSizeBuffer = stack.callocInt(2);
194+
195+
// Retrieve the size into the int buffer
196+
glfwGetFramebufferSize(window,
197+
(IntBuffer) framebufferSizeBuffer.slice().position(0), (IntBuffer) sizeBuffer.slice().position(1));
198+
199+
// Calculate scale
200+
float xScale = ((float) (framebufferSizeBuffer.get(0))) / ((float) (sizeBuffer.get(0)));
201+
float yScale = ((float) (framebufferSizeBuffer.get(1))) / ((float) (sizeBuffer.get(1)));
202+
203+
// Fix up scale in case it gets corrupted... somehow
204+
if(xScale == 0.0f) {
205+
xScale = 1.0f;
206+
}
207+
208+
if(yScale == 0.0f) {
209+
yScale = 1.0f;
210+
}
186211

187212
// Update the scale
188-
inputAdapter.windowContentScaleCallback(window, scaleBuffer.get(0), scaleBuffer.get(1));
213+
inputAdapter.windowContentScaleCallback(window, xScale, yScale);
189214
}
190215

191216
glEnable(GL_MULTISAMPLE);

0 commit comments

Comments
 (0)