Skip to content

Commit

Permalink
Support the specification of an include file to be used in all
Browse files Browse the repository at this point in the history
Generated C++ files.  Support enabling/disabling chained exceptions
in C++.

[git-p4: depot-paths = "//open/mondrian/": change = 1365]
  • Loading branch information
Stephan Zuercher committed Feb 14, 2004
1 parent 8ed5fbb commit b583845
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 43 deletions.
14 changes: 14 additions & 0 deletions src/main/mondrian/resource/Resource.xml
Expand Up @@ -49,6 +49,12 @@ version="1.0"
classes are assumed to be in the same namespace.
</Doc>
</Attribute>
<Attribute name="cppCommonInclude" required="false">
<Doc>
C++ common include file. Included at the
start of all generated C++ class implementations.
</Doc>
</Attribute>
<Attribute name="cppExceptionClassName" required="false">
<Doc>
Default class for exceptions in generated C++.
Expand Down Expand Up @@ -131,6 +137,14 @@ A message.
exception class is given.
</Doc>
</Attribute>
<Attribute name="cppChainExceptions" required="false">
<Doc>
Set to true if the C++ exception classes support
being chained together. The default is false.
If true, an extra method will be generated for
that takes a const pointer to the C++ exception class.
</Doc>
</Attribute>
<Code>
mondrian.xom.DOMWrapper getDef() { return _def; }
</Code>
Expand Down
2 changes: 2 additions & 0 deletions src/main/mondrian/resource/ResourceGen.java
Expand Up @@ -80,6 +80,8 @@ static ResourceGenTask parse(String[] args) throws IOException
rootArgs.setSrcdir(new File(args[++i]));
} else if (arg.equals("-destdir") && i + 1 < args.length) {
rootArgs.setDestdir(new File(args[++i]));
} else if (arg.equals("-locales") && i + 1 < args.length) {
rootArgs.setLocales(args[++i]);
} else {
ResourceGenTask.Include resourceArgs =
new ResourceGenTask.Include();
Expand Down
108 changes: 65 additions & 43 deletions src/main/mondrian/resource/XmlFileTask.java
Expand Up @@ -601,24 +601,31 @@ private void generateCppHeader(ResourceGen generator,
pw.println(" " + exceptionClass
+ " new" + resourceInitCap + "("
+ parameterList + ") const;");
if (parameterList.length() > 0) {
pw.println(" "
+ exceptionClass
+ " new"
+ resourceInitCap
+ "("
+ parameterList
+ ", const "
+ exceptionClass
+ " * const prev) const;");
} else {
pw.println(" "
+ exceptionClass
+ " new"
+ resourceInitCap + "("
+ "const "
+ exceptionClass
+ " * const prev) const;");

boolean chainExceptions =
(exception.cppChainExceptions != null &&
exception.cppChainExceptions.equalsIgnoreCase("true"));

if (chainExceptions) {
if (parameterList.length() > 0) {
pw.println(" "
+ exceptionClass
+ " new"
+ resourceInitCap
+ "("
+ parameterList
+ ", const "
+ exceptionClass
+ " * const prev) const;");
} else {
pw.println(" "
+ exceptionClass
+ " new"
+ resourceInitCap + "("
+ "const "
+ exceptionClass
+ " * const prev) const;");
}
}
}

Expand Down Expand Up @@ -690,6 +697,12 @@ private void generateCpp(ResourceGen generator,
? cppBaseClassName
: "ResourceBundle");

if (resourceList.cppCommonInclude != null) {
pw.println("// begin common include specified by " + getFile());
pw.println("#include \"" + resourceList.cppCommonInclude + "\"");
pw.println("// end common include specified by " + getFile());
}

pw.println("#include \"" + headerFilename + "\"");
pw.println("#include \"ResourceBundle.h\"");
pw.println("#include \"Locale.h\"");
Expand Down Expand Up @@ -803,33 +816,42 @@ private void generateCpp(ResourceGen generator,
pw.println("}");
pw.println();

if (parameterList.length() > 0) {
pw.println(exceptionClass
+ " "
+ resourceInitCap
+ "::new"
+ resourceInitCap
+ "("
+ parameterList
+ ", const "
boolean chainExceptions =
(exception.cppChainExceptions != null &&
exception.cppChainExceptions.equalsIgnoreCase("true"));

if (chainExceptions) {
if (parameterList.length() > 0) {
pw.println(exceptionClass
+ " "
+ resourceInitCap
+ "::new"
+ resourceInitCap
+ "("
+ parameterList
+ ", const "
+ exceptionClass
+ " * const prev) const");
} else {
pw.println(exceptionClass
+ " "
+ resourceInitCap
+ "::new"
+ resourceInitCap
+ "(const "
+ exceptionClass
+ " * const prev) const");
}
pw.println("{");

pw.println(" return "
+ exceptionClass
+ " * const prev) const");
} else {
pw.println(exceptionClass
+ " "
+ resourceInitCap
+ "::new"
+ resourceInitCap
+ "(const "
+ exceptionClass
+ " * const prev) const");
+ "(this->operator()("
+ argumentList
+ "), prev);");
pw.println("}");
pw.println();
}
pw.println("{");

pw.println(" return " + exceptionClass + "(this->operator()("
+ argumentList + "), prev);");
pw.println("}");
pw.println();
}
}

Expand Down

0 comments on commit b583845

Please sign in to comment.