From aaf243381fee2be988d37d7a170f992fe0fd9745 Mon Sep 17 00:00:00 2001 From: hneemann Date: Sun, 18 Mar 2018 10:34:59 +0100 Subject: [PATCH] added some comments --- .../neemann/digital/hdl/hgs/function/JavaClass.java | 12 +++++++----- .../neemann/digital/hdl/vhdl/lib/VHDLTemplate.java | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/de/neemann/digital/hdl/hgs/function/JavaClass.java b/src/main/java/de/neemann/digital/hdl/hgs/function/JavaClass.java index 58a2e234d..ea8485dfb 100644 --- a/src/main/java/de/neemann/digital/hdl/hgs/function/JavaClass.java +++ b/src/main/java/de/neemann/digital/hdl/hgs/function/JavaClass.java @@ -19,7 +19,10 @@ import java.util.HashMap; /** * Used to call a java function from the template code. - * Uses reflection to invoke the method; + * Uses reflection to invoke the methods. + * All public methods which are declared in the given class are available via a + * {@link HGSMap} instance obtained by calling {@link JavaClass#createMap(Object)}. + * See {@link de.neemann.digital.hdl.vhdl.lib.VHDLTemplate} as an example. * * @param the type of the instance */ @@ -40,7 +43,7 @@ public final class JavaClass { if (methods.containsKey(name)) throw new RuntimeException("Method overloading (" + name + ") is not supported! Try to use the ellipsis (...) instead."); - methods.put(name, new MyMethod<>(m, Modifier.isStatic(mod))); + methods.put(name, new MyMethod<>(m)); } } } @@ -64,9 +67,9 @@ public final class JavaClass { private final boolean isVarArgs; private Class compType; - private MyMethod(Method method, boolean isStatic) { + private MyMethod(Method method) { this.method = method; - this.isStatic = isStatic; + this.isStatic = Modifier.isStatic(method.getModifiers()); Class[] argTypes = method.getParameterTypes(); javaArgCount = argTypes.length; @@ -151,7 +154,6 @@ public final class JavaClass { if (m == null) return null; return new MethodCall<>(m, instance); } - } private static final class MethodCall extends InnerFunction { diff --git a/src/main/java/de/neemann/digital/hdl/vhdl/lib/VHDLTemplate.java b/src/main/java/de/neemann/digital/hdl/vhdl/lib/VHDLTemplate.java index a054fad96..0d8992137 100644 --- a/src/main/java/de/neemann/digital/hdl/vhdl/lib/VHDLTemplate.java +++ b/src/main/java/de/neemann/digital/hdl/vhdl/lib/VHDLTemplate.java @@ -23,7 +23,7 @@ import java.util.HashMap; import static de.neemann.digital.hdl.vhdl.VHDLLibrary.writePort; /** - * Reads a file with the vhdl code to create the entity + * Reads a file with the vhdl code to create the entity. */ public class VHDLTemplate implements VHDLEntity { private static final JavaClass TEMP_FUNCTIONS_CLASS