This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const SECONDS_IN_A_DAY = 86400.; | |
const UNIX_EPOCH_JULIAN_DAY = 2440587.5; | |
function unix_to_julian(timestamp) { | |
return timestamp / SECONDS_IN_A_DAY + UNIX_EPOCH_JULIAN_DAY; | |
} | |
function julian_to_unix(day) { | |
return ((day - UNIX_EPOCH_JULIAN_DAY) * SECONDS_IN_A_DAY); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.wasmer.Instance; | |
import org.wasmer.Memory; | |
import java.io.IOException; | |
import java.nio.ByteBuffer; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
class MemoryExample { | |
public static void main(String[] args) throws IOException { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[no_mangle] | |
pub extern fn return_hello() -> *const u8 { | |
b"Hello, World!\0".as_ptr() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.wasmer.Instance; | |
import org.wasmer.exports.Function; | |
import java.io.IOException; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
class SimpleExample { | |
public static void main(String[] args) throws IOException { | |
// Read the WebAssembly bytes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.wasmer.Instance; | |
import java.io.IOException; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
class SimpleExample { | |
public static void main(String[] args) throws IOException { | |
// Read the WebAssembly bytes. | |
byte[] bytes = Files.readAllBytes(Paths.get("simple.wasm")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[no_mangle] | |
pub extern fn sum(x: i32, y: i32) -> i32 { | |
x + y | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::{convert::TryFrom, fmt::Debug}; | |
pub trait WitValue | |
where | |
Self: Sized + Debug + Copy, | |
{ | |
} | |
impl WitValue for i32 {} | |
impl WitValue for f32 {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Select all WebAssembly instances. | |
SELECT * FROM wasm.instances; | |
-- id | wasm_file | |
-- --------------------------------------+------------------------------- | |
-- 426e17af-c32f-5027-ad73-239e5450dd91 | /absolute/path/to/simple.wasm | |
-- (1 row) | |
-- Select all exported functions for a specific instance. | |
SELECT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- New instance of the `simple.wasm` WebAssembly module. | |
SELECT wasm_new_instance('/absolute/path/to/simple.wasm', 'ns'); | |
-- Call a WebAssembly exported function! | |
SELECT ns_sum(1, 2); | |
-- ns_sum | |
-- -------- | |
-- 3 | |
-- (1 row) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[no_mangle] | |
pub extern fn sum(x: i32, y: i32) -> i32 { | |
x + y | |
} |
NewerOlder