Skip to content

Commit

Permalink
fix special case
Browse files Browse the repository at this point in the history
  • Loading branch information
Zwiterrion committed May 20, 2024
1 parent ecc8d47 commit 5add781
Show file tree
Hide file tree
Showing 8 changed files with 226 additions and 100 deletions.
11 changes: 8 additions & 3 deletions java/src/main/java/org/extism/sdk/HostFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ public HostFunction(String name, LibExtism.ExtismValType[] params, LibExtism.Ext
int nOutputs,
Pointer data) -> {

LibExtism.ExtismVal[] outputs = (LibExtism.ExtismVal []) outs.toArray(nOutputs);
LibExtism.ExtismVal[] outputs = null;

if(outs != null)
outputs = (LibExtism.ExtismVal []) outs.toArray(nOutputs);

f.invoke(
new ExtismCurrentPlugin(currentPlugin),
Expand All @@ -45,8 +48,10 @@ public HostFunction(String name, LibExtism.ExtismValType[] params, LibExtism.Ext
userData
);

for (LibExtism.ExtismVal output : outputs) {
convertOutput(output, output);
if(outputs != null) {
for (LibExtism.ExtismVal output : outputs) {
convertOutput(output, output);
}
}
};

Expand Down
4 changes: 0 additions & 4 deletions java/src/main/java/org/extism/sdk/LibExtism.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ public ByReference(Pointer ptr) {
public ByReference() {}
}

// public static class ByValue extends ExtismVal implements Structure.ByValue {
//
// }

public ExtismVal() {}

public ExtismVal(Pointer p) {
Expand Down
301 changes: 212 additions & 89 deletions java/src/test/java/org/extism/sdk/PluginTests.java

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion java/src/test/java/org/extism/sdk/TestWasmSources.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public Path getWasmWaf() {
}

public Path getLogPath() {
return Paths.get(WASM_LOCATION, "httpwasm/router.wasm");
return Paths.get(WASM_LOCATION, "httpwasm/test.wasm");
}
};

Expand Down
Binary file added java/src/test/resources/httpwasm/redact.wasm
Binary file not shown.
Binary file added java/src/test/resources/httpwasm/test.wasm
Binary file not shown.
4 changes: 3 additions & 1 deletion runtime/src/current_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl wasmtime::ResourceLimiter for MemoryLimiter {
maximum: Option<usize>,
) -> Result<bool> {
if let Some(max) = maximum {
if desired >= max {
if desired > max { // TODO - >= failed comparing 65536 and 65536 value
return Err(Error::msg("oom"));
}
}
Expand Down Expand Up @@ -346,6 +346,8 @@ impl CurrentPlugin {
return mem.data_ptr(store);
}

// let (linker, mut store) = self.linker_and_store();

std::ptr::null_mut()
}

Expand Down
4 changes: 2 additions & 2 deletions runtime/src/sdk.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(clippy::missing_safety_doc)]

use std::os::raw::c_char;
use std::{os::raw::c_char, ptr::null_mut};

use crate::*;

Expand Down Expand Up @@ -221,7 +221,7 @@ pub unsafe extern "C" fn extism_function_new(
plugin,
inputs.as_ptr(),
inputs.len() as Size,
output_tmp.as_mut_ptr(),
if output_types.is_empty() { null_mut() } else { output_tmp.as_mut_ptr()},
output_tmp.len() as Size,
user_data.as_ptr(),
);
Expand Down

0 comments on commit 5add781

Please sign in to comment.