mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 15:37:52 +01:00
use constants for annotations
This commit is contained in:
parent
01c469247e
commit
0227137e2e
@ -48,8 +48,21 @@ public class JWebAssembly {
|
|||||||
|
|
||||||
private final HashMap<String, String> properties = new HashMap<>();
|
private final HashMap<String, String> properties = new HashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Property for adding debug names to the output if true.
|
||||||
|
*/
|
||||||
public static final String DEBUG_NAMES = "DebugNames";
|
public static final String DEBUG_NAMES = "DebugNames";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the annotation for import functions.
|
||||||
|
*/
|
||||||
|
public static final String IMPORT_ANNOTATION = "de.inetsoftware.jwebassembly.api.annotation.Import";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the annotation for export functions.
|
||||||
|
*/
|
||||||
|
public static final String EXPORT_ANNOTATION = "de.inetsoftware.jwebassembly.api.annotation.Export";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a instance.
|
* Create a instance.
|
||||||
*/
|
*/
|
||||||
|
@ -28,6 +28,7 @@ import de.inetsoftware.classparser.Code;
|
|||||||
import de.inetsoftware.classparser.CodeInputStream;
|
import de.inetsoftware.classparser.CodeInputStream;
|
||||||
import de.inetsoftware.classparser.LocalVariableTable;
|
import de.inetsoftware.classparser.LocalVariableTable;
|
||||||
import de.inetsoftware.classparser.MethodInfo;
|
import de.inetsoftware.classparser.MethodInfo;
|
||||||
|
import de.inetsoftware.jwebassembly.JWebAssembly;
|
||||||
import de.inetsoftware.jwebassembly.WasmException;
|
import de.inetsoftware.jwebassembly.WasmException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -118,7 +119,7 @@ public class ModuleGenerator {
|
|||||||
private void prepareMethod( MethodInfo method ) throws WasmException {
|
private void prepareMethod( MethodInfo method ) throws WasmException {
|
||||||
try {
|
try {
|
||||||
FunctionName name = new FunctionName( method );
|
FunctionName name = new FunctionName( method );
|
||||||
Map<String,Object> annotationValues = method.getAnnotation( "de.inetsoftware.jwebassembly.api.annotation.Import" );
|
Map<String,Object> annotationValues = method.getAnnotation( JWebAssembly.IMPORT_ANNOTATION );
|
||||||
if( annotationValues != null ) {
|
if( annotationValues != null ) {
|
||||||
String impoarModule = (String)annotationValues.get( "module" );
|
String impoarModule = (String)annotationValues.get( "module" );
|
||||||
String importName = (String)annotationValues.get( "name" );
|
String importName = (String)annotationValues.get( "name" );
|
||||||
@ -143,8 +144,11 @@ public class ModuleGenerator {
|
|||||||
private void writeMethod( MethodInfo method ) throws WasmException {
|
private void writeMethod( MethodInfo method ) throws WasmException {
|
||||||
CodeInputStream byteCode = null;
|
CodeInputStream byteCode = null;
|
||||||
try {
|
try {
|
||||||
|
if( method.getAnnotation( JWebAssembly.IMPORT_ANNOTATION ) != null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Code code = method.getCode();
|
Code code = method.getCode();
|
||||||
if( code != null && method.getAnnotation( "de.inetsoftware.jwebassembly.api.annotation.Import" ) == null ) { // abstract methods and interface methods does not have code
|
if( code != null ) { // abstract methods and interface methods does not have code
|
||||||
FunctionName name = new FunctionName( method );
|
FunctionName name = new FunctionName( method );
|
||||||
writeExport( name, method );
|
writeExport( name, method );
|
||||||
writer.writeMethodStart( name );
|
writer.writeMethodStart( name );
|
||||||
@ -175,7 +179,7 @@ public class ModuleGenerator {
|
|||||||
* if any IOException occur
|
* if any IOException occur
|
||||||
*/
|
*/
|
||||||
private void writeExport( FunctionName name, MethodInfo method ) throws IOException {
|
private void writeExport( FunctionName name, MethodInfo method ) throws IOException {
|
||||||
Map<String,Object> export = method.getAnnotation( "de.inetsoftware.jwebassembly.api.annotation.Export" );
|
Map<String,Object> export = method.getAnnotation( JWebAssembly.EXPORT_ANNOTATION );
|
||||||
if( export != null ) {
|
if( export != null ) {
|
||||||
String exportName = (String)export.get( "name" );
|
String exportName = (String)export.get( "name" );
|
||||||
if( exportName == null ) {
|
if( exportName == null ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user