summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--slicer/db/Jamfile.jam2
-rw-r--r--slicer/slicer/enumMap.cpp1
-rw-r--r--slicer/slicer/enumMap.h1
-rw-r--r--slicer/slicer/hook-test.cpp1
-rw-r--r--slicer/slicer/metadata.cpp1
-rw-r--r--slicer/slicer/metadata.h2
-rw-r--r--slicer/slicer/modelPartsTraits.cpp1
-rw-r--r--slicer/slicer/modelPartsTraits.h4
-rw-r--r--slicer/slicer/modelPartsTypes.impl.cpp1
-rw-r--r--slicer/slicer/modelPartsTypes.impl.h24
-rw-r--r--slicer/test/Jamfile.jam2
-rw-r--r--slicer/test/types.ice4
-rw-r--r--slicer/tool/parser.cpp114
13 files changed, 128 insertions, 30 deletions
diff --git a/slicer/db/Jamfile.jam b/slicer/db/Jamfile.jam
index 7a5de7e..bc43dcb 100644
--- a/slicer/db/Jamfile.jam
+++ b/slicer/db/Jamfile.jam
@@ -47,6 +47,8 @@ lib testCommon :
<library>..//adhocutil
<library>dbicetypes
<implicit-dependency>dbicetypes
+ -<variant>debug\:<warnings-as-errors>on
+ <toolset>tidy:<warnings-as-errors>off
<toolset>gcc:<dependency>../tool//slicer/<toolset>gcc
<toolset>clang:<dependency>../tool//slicer/<toolset>clang
<toolset>tidy:<dependency>../tool//slicer/<toolset>gcc
diff --git a/slicer/slicer/enumMap.cpp b/slicer/slicer/enumMap.cpp
new file mode 100644
index 0000000..8d6b96a
--- /dev/null
+++ b/slicer/slicer/enumMap.cpp
@@ -0,0 +1 @@
+#include "enumMap.h"
diff --git a/slicer/slicer/enumMap.h b/slicer/slicer/enumMap.h
index 72c1511..4c50bd8 100644
--- a/slicer/slicer/enumMap.h
+++ b/slicer/slicer/enumMap.h
@@ -2,6 +2,7 @@
#define SLICER_ENUM_MAP_H
#include <array>
+#include <cstddef>
#include <string>
#include <string_view>
diff --git a/slicer/slicer/hook-test.cpp b/slicer/slicer/hook-test.cpp
index b5b0701..3af28b4 100644
--- a/slicer/slicer/hook-test.cpp
+++ b/slicer/slicer/hook-test.cpp
@@ -5,7 +5,6 @@
#include <iterator>
#include <string>
#include <string_view>
-#include <utility>
namespace test {
struct S {
diff --git a/slicer/slicer/metadata.cpp b/slicer/slicer/metadata.cpp
new file mode 100644
index 0000000..f5a1b66
--- /dev/null
+++ b/slicer/slicer/metadata.cpp
@@ -0,0 +1 @@
+#include "metadata.h"
diff --git a/slicer/slicer/metadata.h b/slicer/slicer/metadata.h
index 455507a..8aa65c9 100644
--- a/slicer/slicer/metadata.h
+++ b/slicer/slicer/metadata.h
@@ -2,9 +2,11 @@
#define SLICER_METADATA_H
#include <array>
+#include <cstddef>
#include <optional>
#include <string_view>
#include <type_traits>
+#include <utility>
#include <vector>
#include <visibility.h>
diff --git a/slicer/slicer/modelPartsTraits.cpp b/slicer/slicer/modelPartsTraits.cpp
new file mode 100644
index 0000000..ca770cd
--- /dev/null
+++ b/slicer/slicer/modelPartsTraits.cpp
@@ -0,0 +1 @@
+#include "modelPartsTraits.h"
diff --git a/slicer/slicer/modelPartsTraits.h b/slicer/slicer/modelPartsTraits.h
index 6213c9c..6b88a57 100644
--- a/slicer/slicer/modelPartsTraits.h
+++ b/slicer/slicer/modelPartsTraits.h
@@ -2,7 +2,11 @@
#define SLICER_MODELPARTSTRAITS_H
#include <Ice/Optional.h>
+#include <cstddef>
#include <functional>
+#include <tuple>
+#include <type_traits>
+#include <utility>
namespace Slicer {
// Function traits helpers
diff --git a/slicer/slicer/modelPartsTypes.impl.cpp b/slicer/slicer/modelPartsTypes.impl.cpp
new file mode 100644
index 0000000..639f718
--- /dev/null
+++ b/slicer/slicer/modelPartsTypes.impl.cpp
@@ -0,0 +1 @@
+#include "modelPartsTypes.impl.h"
diff --git a/slicer/slicer/modelPartsTypes.impl.h b/slicer/slicer/modelPartsTypes.impl.h
index ef07248..5423152 100644
--- a/slicer/slicer/modelPartsTypes.impl.h
+++ b/slicer/slicer/modelPartsTypes.impl.h
@@ -2,14 +2,34 @@
#define SLICER_MODELPARTSTYPES_IMPL_H
#include "common.h"
-#include "enumMap.h"
+#include "enumMap.h" // IWYU pragma: keep
#include "hookMap.h"
+#include "metadata.h"
+#include "modelParts.h"
#include "modelPartsTraits.h"
#include "modelPartsTypes.h"
+#include <Ice/Config.h>
+#include <Ice/InputStream.h>
+#include <Ice/Optional.h>
+#include <Ice/OutputStream.h>
#include <Ice/StreamHelpers.h>
-#include <IceUtil/Optional.h>
+#include <IceUtil/Config.h>
#include <boost/assert.hpp>
#include <c++11Helpers.h>
+#include <cstddef>
+#include <memory>
+#include <optional>
+#include <string>
+#include <string_view>
+#include <type_traits>
+#include <typeinfo>
+#include <utility>
+#include <vector>
+#include <visibility.h>
+// IWYU pragma: no_forward_declare Slicer::EnumMap
+namespace Ice {
+ class Object;
+}
#define CUSTOMMODELPARTFOR(Type, BaseModelPart, ModelPartType) \
template<> DLL_PUBLIC ModelPartPtr ModelPart::Make<ModelPartType>(typename ModelPartType::element_type * t) \
diff --git a/slicer/test/Jamfile.jam b/slicer/test/Jamfile.jam
index 6f27f92..1682b58 100644
--- a/slicer/test/Jamfile.jam
+++ b/slicer/test/Jamfile.jam
@@ -29,6 +29,8 @@ lib types :
<toolset>gcc:<slicerbin>../tool//slicer/<toolset>gcc
<toolset>clang:<slicerbin>../tool//slicer/<toolset>clang
<toolset>tidy:<slicerbin>../tool//slicer/<toolset>gcc
+ -<variant>debug\:<warnings-as-errors>on
+ <toolset>tidy:<warnings-as-errors>off
<include>.
<library>..//adhocutil
<library>boost_date_time
diff --git a/slicer/test/types.ice b/slicer/test/types.ice
index ac3a706..5a8fcba 100644
--- a/slicer/test/types.ice
+++ b/slicer/test/types.ice
@@ -1,9 +1,7 @@
#ifndef SLICER_TEST_TYPES
#define SLICER_TEST_TYPES
-[["cpp:include:boost/date_time/posix_time/posix_time_types.hpp"]]
-[["cpp:include:boost/date_time/posix_time/time_formatters.hpp"]]
-[["cpp:include:boost/date_time/posix_time/time_parsers.hpp"]]
+[["cpp:include:boost/date_time/posix_time/posix_time.hpp"]]
#include <included.ice>
#include <enums.ice>
diff --git a/slicer/tool/parser.cpp b/slicer/tool/parser.cpp
index d0bf601..ec94a43 100644
--- a/slicer/tool/parser.cpp
+++ b/slicer/tool/parser.cpp
@@ -39,29 +39,65 @@
namespace fs = std::filesystem;
namespace Slicer {
+ template<typename TPtr>
+ bool
+ ignoreType(const TPtr & t)
+ {
+ return (!t || t->hasMetaData("slicer:ignore"));
+ }
+
class Count : public Slice::ParserVisitor {
public:
- bool
- visitClassDefStart(const Slice::ClassDefPtr &) override
+ [[nodiscard]] bool
+ visitClassDefStart(const Slice::ClassDefPtr & c) override
{
- classes += 1;
- return true;
+ return countIfUsed(c, classes, !c->isInterface());
}
- bool
- visitStructStart(const Slice::StructPtr &) override
+ [[nodiscard]] bool
+ visitStructStart(const Slice::StructPtr & s) override
{
- structs += 1;
- return true;
+ return countIfUsed(s, structs);
+ }
+ void
+ visitSequence(const Slice::SequencePtr & s) override
+ {
+ countIfUsed(s, sequences);
}
void
- visitEnum(const Slice::EnumPtr &) override
+ visitDictionary(const Slice::DictionaryPtr & d) override
{
- enums += 1;
+ countIfUsed(d, dictionaries);
+ }
+ void
+ visitEnum(const Slice::EnumPtr & e) override
+ {
+ countIfUsed(e, enums);
+ }
+ [[nodiscard]] auto
+ complexes() const
+ {
+ return classes + structs;
}
unsigned int classes {0};
unsigned int structs {0};
unsigned int enums {0};
+ unsigned int sequences {0};
+ unsigned int dictionaries {0};
+ unsigned int total {0};
+
+ private:
+ template<typename TPtr>
+ bool
+ countIfUsed(const TPtr & t, auto & counter, bool condition = true)
+ {
+ if (!condition || ignoreType(t)) {
+ return false;
+ }
+ counter += 1;
+ total += 1;
+ return true;
+ }
};
class ForwardDeclare : public Slice::ParserVisitor {
@@ -82,14 +118,14 @@ namespace Slicer {
bool
visitClassDefStart(const Slice::ClassDefPtr & c) override
{
- fprintbf(cpp, "class ICE_CLASS(JAM_DLL_PUBLIC) %s;\n", c->name());
+ fprintbf(cpp, "class ICE_CLASS(JAM_DLL_PUBLIC) %s; // IWYU pragma: keep\n", c->name());
return false;
};
bool
visitStructStart(const Slice::StructPtr & s) override
{
- fprintbf(cpp, "struct ICE_CLASS(JAM_DLL_PUBLIC) %s;\n", s->name());
+ fprintbf(cpp, "struct ICE_CLASS(JAM_DLL_PUBLIC) %s; // IWYU pragma: keep\n", s->name());
return false;
};
@@ -128,13 +164,6 @@ namespace Slicer {
return o;
}
- template<typename TPtr>
- bool
- ignoreType(const TPtr & t)
- {
- return (!t || t->hasMetaData("slicer:ignore"));
- }
-
Slicer::Slicer() : cpp(nullptr), headerPrefix("slicer"), components(0), classNo(0) { }
void
@@ -221,20 +250,57 @@ namespace Slicer {
if (!cpp) {
return true;
}
-
- fprintbf(cpp, "// Begin Slicer code\n\n");
- fprintbf(cpp, "#include <%s>\n\n", (headerPrefix / "modelPartsTypes.impl.h").string());
+ auto include = [this](const auto & h, bool keep = false) {
+ fprintbf(cpp, "#include <%s>", h);
+ if (keep) {
+ fputs(" // IWYU pragma: keep", cpp);
+ }
+ fputs("\n", cpp);
+ };
Count count;
u->visit(&count, true);
+
+ if (count.total == 0) {
+ return false;
+ }
+
+ fprintbf(cpp, "// Begin Slicer code\n\n");
+ include((headerPrefix / "modelPartsTypes.impl.h").string());
+ include((headerPrefix / "modelPartsTypes.h").string());
+ include((headerPrefix / "modelParts.h").string());
+ include((headerPrefix / "hookMap.h").string());
+ include((headerPrefix / "metadata.h").string(), true);
+
+ include("array");
+ include("optional");
+ include("string");
+ include("string_view");
+ include("visibility.h");
+ if (count.classes) {
+ include("memory", true);
+ include("boost/assert.hpp", true);
+ include("Ice/Config.h", true);
+ }
+ if (count.enums) {
+ include((headerPrefix / "enumMap.h").string());
+ }
+ include("Ice/Optional.h");
+ if (count.complexes() || count.dictionaries) {
+ include("IceUtil/Config.h");
+ }
+ if (count.dictionaries) {
+ include("map", true);
+ include("utility", true);
+ }
ForwardDeclare fd {cpp, count};
u->visit(&fd, true);
- fprintbf(cpp, "#include <%s>\n", fs::path {topLevelFile.filename()}.replace_extension(".h").string());
+ include(fs::path {topLevelFile.filename()}.replace_extension(".h").string());
for (const auto & m : u->modules()) {
IceMetaData md {m->getMetaData()};
for (const auto & i : md.values("slicer:include:")) {
- fprintbf(cpp, "#include <%s>\n", i);
+ include(i);
}
}
fprintbf(cpp, "\n");