diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/uscxml/transform/ChartToJava.cpp | 55 | ||||
-rw-r--r-- | src/uscxml/transform/ChartToVHDL.cpp | 4 | ||||
-rw-r--r-- | src/uscxml/transform/Transformer.h | 2 | ||||
-rw-r--r-- | src/uscxml/util/String.cpp | 5 |
4 files changed, 60 insertions, 6 deletions
diff --git a/src/uscxml/transform/ChartToJava.cpp b/src/uscxml/transform/ChartToJava.cpp index da9c4d6..f31db71 100644 --- a/src/uscxml/transform/ChartToJava.cpp +++ b/src/uscxml/transform/ChartToJava.cpp @@ -42,6 +42,59 @@ ChartToJava::~ChartToJava() { } void ChartToJava::writeTo(std::ostream& stream) { + std::string className; + std::string packageName = "org.uscxml.gen"; + + if (_extensions.find("packageName") != _extensions.end()) { + packageName = _extensions.equal_range("packageName").first->second; + } + + if (_extensions.find("outputFile") != _extensions.end()) { + URL outputFileURL(_extensions.equal_range("outputFile").first->second); + className = outputFileURL.pathComponents().back(); + } else if (_baseURL.pathComponents().size() > 0) { + className = _baseURL.pathComponents().back(); + } else { + className = "StateChartBase"; + } + + std::string javaVersion = "5"; + if (_extensions.find("javaVersion") != _extensions.end()) { + javaVersion = _extensions.equal_range("javaVersion").first->second; + } + std::string baseClass = "StateChartJava" + javaVersion + "Impl"; + + + size_t dotPos = std::string::npos; + if ((dotPos = className.find(".")) != std::string::npos) { + className = className.substr(0, dotPos); + } + + stream << "package " << packageName << ";" << std::endl; + stream << std::endl; + + stream << "/**" << std::endl; + stream << " Generated from source:" << std::endl; + stream << " " << (std::string)_baseURL << std::endl; + stream << "*/" << std::endl; + stream << std::endl; + + + stream << std::endl; + stream << "import java.util.ArrayList;" << std::endl; + stream << "import java.util.HashMap;" << std::endl; + stream << "import org.uscxml.*;" << std::endl; + stream << std::endl; + stream << "public abstract class " << className << " extends " << baseClass << " {" << std::endl; + stream << std::endl; + stream << " public " << className << "() {" << std::endl; + stream << " transitions = new ArrayList<Transition>();" << std::endl; + stream << " states = new ArrayList<State>();" << std::endl; + stream << " stateNamesToIndex = new HashMap<String, Integer>();" << std::endl; + stream << " /* TODO: initialize all members */" << std::endl; + stream << " }" << std::endl; + stream << "}" << std::endl; + } -}
\ No newline at end of file +} diff --git a/src/uscxml/transform/ChartToVHDL.cpp b/src/uscxml/transform/ChartToVHDL.cpp index cbd46ef..9ef2f75 100644 --- a/src/uscxml/transform/ChartToVHDL.cpp +++ b/src/uscxml/transform/ChartToVHDL.cpp @@ -90,7 +90,7 @@ void ChartToVHDL::findEvents() { // Calculate needed bit size for the event fifo // --> |log2(n)| +1 with n is number of events // we do not add +1 because the std_logic_vector startes with 0 - _eventBitSize = ceil(abs(log2(_eventNames.size()))); + _eventBitSize = ceil(std::abs(log2(_eventNames.size()))); _execContent = DOMUtils::inDocumentOrder({ XML_PREFIX(_scxml).str() + "raise", @@ -1605,4 +1605,4 @@ void ChartToVHDL::writeSystemSignalMapping(std::ostream &stream) { } -}
\ No newline at end of file +} diff --git a/src/uscxml/transform/Transformer.h b/src/uscxml/transform/Transformer.h index 6a9f2f3..d3c60e8 100644 --- a/src/uscxml/transform/Transformer.h +++ b/src/uscxml/transform/Transformer.h @@ -31,7 +31,7 @@ class USCXML_API TransformerImpl { public: TransformerImpl(const Interpreter& other) { interpreter = other; // we need to keep a reference to retain the document! - other.getImpl()->init(); + other.getImpl()->setupDOM(); _document = other.getImpl()->_document; _baseURL = other.getImpl()->_baseURL; _scxml = other.getImpl()->_scxml; diff --git a/src/uscxml/util/String.cpp b/src/uscxml/util/String.cpp index 95d69e9..7334d73 100644 --- a/src/uscxml/util/String.cpp +++ b/src/uscxml/util/String.cpp @@ -90,7 +90,8 @@ std::list<std::string> tokenize(const std::string &line, const char sep, bool tr i++; // skip multiple occurences of seperator and whitespaces } start = i; - } else if (i + 1 == line.size()) { + } + if (i + 1 == line.size()) { tokens.push_back(line.substr(start, i + 1 - start)); } } @@ -224,4 +225,4 @@ NEXT_DESC: } -}
\ No newline at end of file +} |