mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
Doku for @Import
This commit is contained in:
parent
24bfe22a51
commit
947ab492fb
18
README.md
18
README.md
@ -34,10 +34,10 @@ JWebAssembly requires Java SE 8 or higher. It is tested with Java SE 8 on [travi
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### Exporting functions
|
### Exporting functions
|
||||||
To export a Java function to make it accessible from JavaScript you need add the annotation org.webassembly.annotation.Export
|
To export a Java function to make it accessible from JavaScript you need add the annotation de.inetsoftware.jwebassembly.api.annotation.Export.
|
||||||
|
|
||||||
```java
|
```java
|
||||||
import org.webassembly.annotation.Export;
|
import de.inetsoftware.jwebassembly.api.annotation.Export;
|
||||||
|
|
||||||
@Export
|
@Export
|
||||||
public static int add( int a, int b ) {
|
public static int add( int a, int b ) {
|
||||||
@ -45,6 +45,20 @@ public static int add( int a, int b ) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### importing functions
|
||||||
|
To import a JavaScript function to make it accessible from Java you need add the annotation de.inetsoftware.jwebassembly.api.annotation.Import.
|
||||||
|
The method can be declared native or can have a Java implementation which will be ignored on compiling.
|
||||||
|
|
||||||
|
```java
|
||||||
|
import de.inetsoftware.jwebassembly.api.annotation.Import;
|
||||||
|
|
||||||
|
@Import( module = "global.Math", name = "max" )
|
||||||
|
static int max( int a, int b) {
|
||||||
|
return Math.max( a, b );
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### Java Limits
|
### Java Limits
|
||||||
In version 1 of WebAssembly you can only compile:
|
In version 1 of WebAssembly you can only compile:
|
||||||
* static methods
|
* static methods
|
||||||
|
Loading…
x
Reference in New Issue
Block a user