You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by "mbeckerle (via GitHub)" <gi...@apache.org> on 2023/02/03 22:15:08 UTC

[GitHub] [daffodil] mbeckerle commented on a diff in pull request #948: Refactor how Main calls "generate c"

mbeckerle commented on code in PR #948:
URL: https://github.com/apache/daffodil/pull/948#discussion_r1096333394


##########
daffodil-cli/src/main/scala/org/apache/daffodil/Main.scala:
##########
@@ -454,30 +454,40 @@ class CLIConf(arguments: Array[String]) extends scallop.ScallopConf(arguments) {
     footer("""|
               |Run 'daffodil generate <language> --help' for subcommand specific options""".stripMargin)
 
-    object c extends scallop.Subcommand("c") {
-      banner("""|Usage: daffodil generate c -s <schema> [-r <root>]
-                |                           [-c <file>] [-T<tunable>=<value>...]
-                |                           [outdir]
-                |
-                |Generate C code from a DFDL schema to parse or unparse data
-                |
-                |Generate Options:""".stripMargin)
-
-      descr("Generate C code from a DFDL schema")
+    // Takes language by name so we can pass it to scallop.Subcommand and interpolate it
+    // into strings without getting a puzzling java.lang.ClassCastException at runtime (class
+    // scala.collection.mutable.WrappedArray$ofRef cannot be cast to class java.lang.String)
+    class LanguageConf(languageArg: => String) extends scallop.Subcommand(languageArg) {

Review Comment:
   Unless scallop.Subcommand class also takes a by-name argument there's no point in taking a by-name argument in your LanguageConf class. 
   
   This may be part of the issue. At the time the superclass is constructed it may not have a value for languageArg yet. 



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org