tuxji commented on a change in pull request #525:
URL: https://github.com/apache/daffodil/pull/525#discussion_r613514920



##########
File path: BUILD.md
##########
@@ -0,0 +1,63 @@
+# Build Requirements
+
+Daffodil's build requirements include:
+
+* JDK 8 or higher
+* SBT 0.13.8 or higher
+* C compiler C99 or higher
+* Mini-XML Version 3.2 or higher
+
+You will need the Java Software Development Kit ([JDK]) and the Scala
+Build Tool ([SBT]) to build Daffodil, run all tests, create packages,
+and more.  The recommended way is to install the latest [Java 11
+LTS][JDK] version and the latest [SBT] version directly from their
+websites.  A package manager on your operating system may be a more
+convenient way, but it may install an older version than what you'd
+prefer.
+
+Since Daffodil now has a C backend as well as a Scala backend, you
+will need a C compiler ([gcc] or [clang]), the [Mini-XML] library, and
+possibly the GNU [argp] library if your system's C library doesn't
+include it already.  The recommended way is to install them using your
+operating system's package manager (for example, `apt` on Debian or
+Ubuntu):
+
+    sudo apt install build-essential curl git libmxml-dev

Review comment:
       Mini-XML is mxml-dev in Fedora and libmxml-dev in Ubuntu; libxml is 
something completely different on both Fedora and Ubuntu.  If Fedora's mxml-dev 
is only 3.1, the API is missing a function which we expect to call so we still 
need to install Mini-XML from source there too.  I'll separate the build 
instructions for Fedora, Ubuntu, and Windows and make them more clear when I 
rebase the runtime2-2204 branch.

##########
File path: 
daffodil-runtime2/src/main/scala/org/apache/daffodil/runtime2/generators/BinaryAbstractCodeGenerator.scala
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.daffodil.runtime2.generators
+
+import org.apache.daffodil.dsom.ElementBase
+import org.apache.daffodil.schema.annotation.props.gen.BitOrder
+import org.apache.daffodil.schema.annotation.props.gen.ByteOrder
+import org.apache.daffodil.schema.annotation.props.gen.OccursCountKind
+
+trait BinaryAbstractCodeGenerator {
+
+  def binaryAbstractGenerateCode(e: ElementBase, initialValue: String, prim: 
String,
+    parseArgs: String, unparseArgs: String, cgState: CodeGeneratorState): Unit 
= {
+
+    // For the time being this is a very limited back end.
+    // So there are some restrictions to enforce.
+    e.schemaDefinitionUnless(e.bitOrder eq BitOrder.MostSignificantBitFirst, 
"Only dfdl:bitOrder 'mostSignificantBitFirst' is supported.")
+    e.schemaDefinitionUnless(e.byteOrderEv.isConstant, "Runtime dfdl:byteOrder 
expressions not supported.")
+    e.schemaDefinitionUnless(e.elementLengthInBitsEv.isConstant, "Runtime 
dfdl:length expressions not supported.")
+
+    val fieldName = e.namedQName.local
+    val byteOrder = e.byteOrderEv.constValue
+    val conv = if (byteOrder eq ByteOrder.BigEndian) "be" else "le"
+    val arraySize = if (e.occursCountKind == OccursCountKind.Fixed) 
e.maxOccurs else 0
+    val fixed = e.xml.attribute("fixed")
+    val fixedValue = if (fixed.isDefined) fixed.get.text else ""
+
+    def addStatements(deref: String): Unit = {
+      val initStatement = s"    instance->$fieldName$deref = $initialValue;"
+      val parseStatement =
+        s"""    parse_${conv}_$prim(&instance->$fieldName$deref, $parseArgs);
+           |    if (pstate->error) return;""".stripMargin
+      val unparseStatement =
+        s"""    unparse_${conv}_$prim(instance->$fieldName$deref, 
$unparseArgs);
+           |    if (ustate->error) return;""".stripMargin
+      cgState.addSimpleTypeStatements(initStatement, parseStatement, 
unparseStatement)
+
+      if (fixedValue.nonEmpty) {
+        val init2 = ""
+        val parse2 =
+          s"""    parse_validate_fixed(instance->$fieldName$deref == 
$fixedValue, "$fieldName", pstate);

Review comment:
       Runtime2 doesn't support strings yet, and we do need to consider how to 
handle fixed values that are strings (we'd have to SDE or call strcmp instead 
of using value == fixed).  I would expect that strings in binary data could 
have length fields as well as be terminated by a null byte.

##########
File path: BUILD.md
##########
@@ -0,0 +1,63 @@
+# Build Requirements
+
+Daffodil's build requirements include:
+
+* JDK 8 or higher
+* SBT 0.13.8 or higher
+* C compiler C99 or higher
+* Mini-XML Version 3.2 or higher
+
+You will need the Java Software Development Kit ([JDK]) and the Scala
+Build Tool ([SBT]) to build Daffodil, run all tests, create packages,
+and more.  The recommended way is to install the latest [Java 11
+LTS][JDK] version and the latest [SBT] version directly from their
+websites.  A package manager on your operating system may be a more
+convenient way, but it may install an older version than what you'd
+prefer.
+
+Since Daffodil now has a C backend as well as a Scala backend, you
+will need a C compiler ([gcc] or [clang]), the [Mini-XML] library, and
+possibly the GNU [argp] library if your system's C library doesn't
+include it already.  The recommended way is to install them using your
+operating system's package manager (for example, `apt` on Debian or
+Ubuntu):
+
+    sudo apt install build-essential curl git libmxml-dev
+    # Just listing other packages you might need too
+
+Some operating systems don't package the [Mini-XML] library, so you
+may have to build and install it from source on those operating
+systems.  See the Windows commands below for how to do so.
+
+You can set your environment variable "CC" to the appropriate driver
+command (or set it to `true` to disable C compilation altogether) if
+you don't want `sbt compile` to call your C compiler with `cc` as the
+driver command.
+
+On Windows, the easiest way to install gcc and libargp is to install
+[MSYS2]'s collection of free tools and libraries although MSYS2 has no
+package for libmxml which you'll need to build from source.  First
+install [MSYS2] following its website's installation instructions,
+then run the following commands in a "MSYS2 MSYS" window:
+
+    pacman -S gcc git libargp-devel make pkgconf
+    git clone https://github.com/michaelrsweet/mxml.git

Review comment:
       Yes, I will put `-t v3.2` in the git clone command both here and in the 
CI workflow when I rebase the runtime2-2204 branch.

##########
File path: build.sbt
##########
@@ -68,8 +68,8 @@ lazy val runtime2         = Project("daffodil-runtime2", 
file("daffodil-runtime2
                               .settings(commonSettings)
                               .settings(publishArtifact in (Compile, 
packageDoc) := false)
                               .settings(
-                                Compile / cCompiler := "cc",
-                                Compile / ccArchiveCommand := "ar",
+                                Compile / cCompiler := sys.env.getOrElse("CC", 
"cc"),
+                                Compile / ccArchiveCommand := 
sys.env.getOrElse("AR", "ar"),

Review comment:
       Yes, if someone says CC=true, they probably need to say AR=true too.  
I'll mention AR too.  Can you think of a clean way to skip the tests too?

##########
File path: 
daffodil-core/src/main/scala/org/apache/daffodil/dsom/ElementBase.scala
##########
@@ -352,6 +353,38 @@ trait ElementBase
     } else DataValue.NoValue
   }
 
+  /**
+   * Is either None or Some(primTypeValue).

Review comment:
       I had noticed that the comment seemed inaccurate when I copied it too.  
Yes, I'll update both places.

##########
File path: README.md
##########
@@ -45,94 +45,46 @@ For more information about Daffodil, see the [Website].
 * C compiler C99 or higher
 * Mini-XML Version 3.2 or higher
 
-Since Daffodil has a DFDL to C backend, you will need a C compiler
-([gcc] or [clang]), the [Mini-XML] library, and possibly the GNU
-[argp] library if your system's C library doesn't include it.  You can
-install gcc and libmxml as system packages on most Unix based
-platforms with distribution-specific packager commands such as (Debian
-and Ubuntu):
-
-    # Just mentioning all other packages you might need too
-    sudo apt install build-essential curl git libmxml-dev
-
-You will need the Java Software Development Kit ([JDK]) and the Scala
-Build Tool ([SBT]) to build Daffodil, run all tests, create packages,
-and more.  [SDK] offers an easy and uniform way to install both java
-and sbt on any Unix based platform:
-
-    curl -s "https://get.sdkman.io"; | bash
-    sdk install java
-    sdk install sbt
-
-You can edit the Compile / cCompiler setting in build.sbt if you don't
-want sbt to call your C compiler with "cc" as the driver command.
-
-On Windows, the easiest way to install gcc and libargp is to install
-[MSYS2]'s collection of free tools and libraries although MSYS2 has no
-package for libmxml which you'll need to build from source.  First
-install [MSYS2] following its website's installation instructions,
-then run the following commands in a "MSYS2 MSYS" window:
-
-    pacman -S gcc git libargp-devel make pkgconf
-    git clone https://github.com/michaelrsweet/mxml.git
-    cd mxml
-    ./configure --prefix=/usr --disable-shared --disable-threads
-    make
-    make install
-
-You also need to install [JDK} and [SBT] from their Windows
-installation packages and define an environment variable using
-Windows' control panel for editing environment variables.  Define an
-environment variable with the name `MSYS2_PATH_TYPE` and the value
-`inherit`.  Now when you open a new "MSYS2 MSYS" window from the Start
-Menu, you will be able to type your sbt commands in the MSYS2 window
-and both sbt and daffodil will be able to call the C compiler.
+See [BUILD.md](BUILD.md) for more details.
 
 ## Getting Started
 
-Below are some of the more common commands used for Daffodil development.
+[SBT] is the officially supported tool to build Daffodil.  Here are
+some of the more commonly used commands for Daffodil development.
 
-### Compile
+* Compile source code:

Review comment:
       OK, fair enough.  I'll put the ### headings back.

##########
File path: daffodil-runtime2/src/main/resources/c/libruntime/errors.h
##########
@@ -18,8 +18,16 @@
 #ifndef ERRORS_H
 #define ERRORS_H
 
-#include <stdio.h>    // for FILE, size_t
+#include <stdbool.h>  // for bool
 #include <stdint.h>   // for int64_t
+#include <stdio.h>    // for FILE, size_t
+
+enum Limits
+{
+    LIMIT_DIAGNOSTICS = 100,  // limits how many diagnostics can accumulate
+    LIMIT_NAME_LENGTH = 9999, // limits how long infoset names can become

Review comment:
       If you look at infoset.c which uses LIMIT_NAME_LENGTH, it's just a 
couple of functions with static char[9999] buffers and their storage are used 
only temporarily by the callers long enough to hand off to the Mini-XML library 
(which copies the actual, usually less than 20 characters long, strings 
immediately) or compare against strings from the Mini-XML library using strcmp. 
 Setting the limit to 9999 characters only uses static storage in a couple of 
places and reduces the chance that an infoset namespace or name might not fit 
in the static buffer.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to