This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/develop by this push:
     new 0b7605e  fix(plc4j): Made the bacnet RandomPackagesTest.java execute 
on Windows and updated the documentation on setting up libpcap on Windows.
0b7605e is described below

commit 0b7605ef2333781e7d1c38ef94eb7b22834f3491
Author: cdutz <[email protected]>
AuthorDate: Sat Feb 26 19:08:10 2022 +0100

    fix(plc4j): Made the bacnet RandomPackagesTest.java execute on Windows and 
updated the documentation on setting up libpcap on Windows.
---
 .../language/mspec/expression/ExpressionStringListener.java   |  8 +++++++-
 .../language/mspec/parser/MessageFormatParserTest.java        |  1 -
 src/site/asciidoc/developers/preparing/windows.adoc           | 11 +++++++++--
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git 
a/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/expression/ExpressionStringListener.java
 
b/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/expression/ExpressionStringListener.java
index ee558b2..bab9237 100644
--- 
a/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/expression/ExpressionStringListener.java
+++ 
b/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/expression/ExpressionStringListener.java
@@ -116,10 +116,14 @@ public class ExpressionStringListener extends 
ExpressionBaseListener {
         String propertyName = ctx.name.getText();
 
         CompletableFuture<TypeReference> typeReferenceFuture = new 
CompletableFuture<>();
+        // If this is the root of a variable expression, the stack is "null".
         if (futureStack == null) {
             schedulePropertyResolution(propertyName, typeReferenceFuture, 
rootTypeName);
             futureStack = new Stack<>();
-        } else {
+        }
+        // If the stack is not null, we're in one of the children levels. We 
need to wait
+        // till the parent is resolved first. So we delay the resolution till 
that's done.
+        else {
             futureStack.peek().whenComplete((typeReference, throwable) -> {
                 if (throwable != null) {
                     LOGGER.debug("Error processing variables", throwable);
@@ -134,11 +138,13 @@ public class ExpressionStringListener extends 
ExpressionBaseListener {
     }
 
     private void schedulePropertyResolution(String propertyName, 
CompletableFuture<TypeReference> typeReferenceFuture, String typeName) {
+        // As soon as the type with the given name is resolved ...
         
lazyTypeDefinitionConsumer.setOrScheduleTypeDefinitionConsumer(typeName, 
(TypeDefinition typeDefinition) -> {
             if (!typeDefinition.isComplexTypeDefinition()) {
                 typeReferenceFuture.completeExceptionally(new 
RuntimeException("is not a complex type"));
                 return;
             }
+            // Get the definition of the field with the given property name.
             final ComplexTypeDefinition complexTypeDefinition = typeDefinition
                 .asComplexTypeDefinition()
                 .orElseThrow();
diff --git 
a/code-generation/protocol-base-mspec/src/test/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatParserTest.java
 
b/code-generation/protocol-base-mspec/src/test/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatParserTest.java
index 4815cea..049db5d 100644
--- 
a/code-generation/protocol-base-mspec/src/test/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatParserTest.java
+++ 
b/code-generation/protocol-base-mspec/src/test/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatParserTest.java
@@ -30,7 +30,6 @@ import 
org.apache.plc4x.plugins.codegenerator.language.mspec.model.references.*;
 import 
org.apache.plc4x.plugins.codegenerator.language.mspec.model.terms.DefaultBooleanLiteral;
 import 
org.apache.plc4x.plugins.codegenerator.language.mspec.model.terms.DefaultVariableLiteral;
 import org.apache.plc4x.plugins.codegenerator.protocol.TypeContext;
-import org.apache.plc4x.plugins.codegenerator.types.definitions.TypeDefinition;
 import org.apache.plc4x.plugins.codegenerator.types.enums.EnumValue;
 import 
org.apache.plc4x.plugins.codegenerator.types.references.SimpleTypeReference;
 import org.junit.jupiter.api.Test;
diff --git a/src/site/asciidoc/developers/preparing/windows.adoc 
b/src/site/asciidoc/developers/preparing/windows.adoc
index 7d1ed9d..53ce56c 100644
--- a/src/site/asciidoc/developers/preparing/windows.adoc
+++ b/src/site/asciidoc/developers/preparing/windows.adoc
@@ -32,11 +32,18 @@ In order to install it, please download end execute the 
installer from https://g
 A special version of LibPCAP is available for Windows, which is called Npcap.
 It is available from https://npcap.com/[here].
 
-Additional tasks to enable Java to find the pcap executables may need to be 
done.
-Follow the instructions 
https://github.com/kaitoy/pcap4j#about-native-library-loading[here]
+So in order to install things correctly:
+
+1. install the version Npcap from above location.
+2. Add `%SystemRoot%\System32\Npcap\` to your System's `PATH`
+3. Possibly reboot
 
 After this all should be working.
 
+If not, have a look here for possible help: 
https://github.com/kaitoy/pcap4j#about-native-library-loading[here]
+
+NOTE: If you had WinPcap installed, you need to uninstall this and make sure 
the files `Packet.dll` and `wpcap.dll` are deleted in the 
`%SystemRoot%\System32\` directory. Otherwise `pcap4j` will incorrectly detect 
a wrong version.
+
 === gcc
 
 Checking:

Reply via email to