aboutsummaryrefslogtreecommitdiff
path: root/include-priv/trygvis
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2016-08-01 08:20:23 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2016-08-01 08:20:23 +0200
commitbfeeac6e4889d1e9a1083b3c7efc59652981b168 (patch)
treea937d844a59da7c509685dcd1ddd9933772e526f /include-priv/trygvis
parentc307e9f234e544386fa3ae53083c7510668e1716 (diff)
downloadkicad-utils-bfeeac6e4889d1e9a1083b3c7efc59652981b168.tar.gz
kicad-utils-bfeeac6e4889d1e9a1083b3c7efc59652981b168.tar.bz2
kicad-utils-bfeeac6e4889d1e9a1083b3c7efc59652981b168.tar.xz
kicad-utils-bfeeac6e4889d1e9a1083b3c7efc59652981b168.zip
o Moving the generation logic to Python, embedding a Python interpreter with the help of pybind11.
o Adding install configuration to CMake to make it easier to reuse the project later on. o Splitting out the examples into its own project to make it easier to test the whole installation setup and python/template loading. o Trying to reorganize the code a bit, not very much better yet.
Diffstat (limited to 'include-priv/trygvis')
-rw-r--r--include-priv/trygvis/antlr.h67
-rw-r--r--include-priv/trygvis/string_utils.h23
2 files changed, 0 insertions, 90 deletions
diff --git a/include-priv/trygvis/antlr.h b/include-priv/trygvis/antlr.h
deleted file mode 100644
index f5656ea..0000000
--- a/include-priv/trygvis/antlr.h
+++ /dev/null
@@ -1,67 +0,0 @@
-#pragma once
-
-#include "antlr4-runtime.h"
-
-namespace trygvis {
-namespace antlr {
-
-// This namespace is shared copied code
-
-using ParseTree = antlr4::tree::ParseTree;
-
-class MissingParseTreeProperty : public std::out_of_range {
-public:
- explicit MissingParseTreeProperty(const std::string &what) : out_of_range(what) { }
-};
-
-template<typename V, bool debug = false>
-class ParseTreeProperty {
-public:
- virtual V get(Ref<ParseTree> node) {
- return get(node.get());
- }
-
- virtual V get(ParseTree *const node) {
- if (!debug) {
- return _annotations.at(node);
- }
-
- try {
-// cerr << "node = " << node->getText() << endl;
- return _annotations.at(node);
- } catch (std::out_of_range &e) {
- std::cerr << "get(" << node << "), text=" << node->getText() << std::endl;
- std::stringstream buf;
- buf << "out of range: " << node << ", text=" << node->getText();
- auto msg = buf.str();
- std::cerr << msg << std::endl;
- throw MissingParseTreeProperty(msg);
- }
- }
-
- virtual void put(ParseTree *const node, V value) {
- if (debug) {
- std::cerr << "put(" << node << ", " << value << "), text: " << node->getText() << std::endl;
- }
- _annotations[node] = value;
- }
-
- virtual V removeFrom(ParseTree *const node) {
- auto it = _annotations.find(node);
-
- if (it == _annotations.end()) {
- throw MissingParseTreeProperty(node->getText());
- }
-
- return it->second;
- }
-
-protected:
- std::map<ParseTree *, V> _annotations;
-
-private:
-};
-
-} // namespace antlr
-
-}
diff --git a/include-priv/trygvis/string_utils.h b/include-priv/trygvis/string_utils.h
deleted file mode 100644
index 9902a3f..0000000
--- a/include-priv/trygvis/string_utils.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#pragma once
-
-#include <string>
-
-namespace trygvis {
-namespace string_utils {
-
-/**
- * Check if a starts with b.
- */
-static bool startsWith(const std::string &a, const std::string &b) {
- return b.length() <= a.length() && a.compare(0, b.length(), b) == 0;
-}
-
-/**
- * Check if a ends with b.
- */
-static bool endsWith(const std::string &a, const std::string &b) {
- return b.length() <= a.length() && a.compare(a.length() - b.length(), b.length(), b) == 0;
-}
-
-} // namespace string_utils
-} // namespace trygvis