summaryrefslogtreecommitdiff
path: root/project2/ice/sliceCompile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'project2/ice/sliceCompile.cpp')
-rw-r--r--project2/ice/sliceCompile.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/project2/ice/sliceCompile.cpp b/project2/ice/sliceCompile.cpp
index f98ecde..32831ac 100644
--- a/project2/ice/sliceCompile.cpp
+++ b/project2/ice/sliceCompile.cpp
@@ -7,8 +7,8 @@ SliceCompile::SliceCompile(const boost::filesystem::path & slice, const IceCompi
{
}
-void
-SliceCompile::Build(const boost::filesystem::path & in, const boost::filesystem::path & outpath) const
+unsigned int
+SliceCompile::build(const boost::filesystem::path & in, FILE * out) const
{
std::vector<std::string> cppArgs;
Slice::PreprocessorPtr icecpp = Slice::Preprocessor::create("slice2project2", in.string(), cppArgs);
@@ -31,19 +31,35 @@ SliceCompile::Build(const boost::filesystem::path & in, const boost::filesystem:
throw std::runtime_error("unit parse failed");
}
+ if (out) {
+ fprintf(out, "#include <%s>\n", (in.filename().replace_extension(".h")).string().c_str());
+ Headers(out);
+ fprintf(out, "\n");
+ }
+ return Body(out, u);
+}
+
+unsigned int
+SliceCompile::Build(const boost::filesystem::path & in, const boost::filesystem::path & outpath) const
+{
FILE * out = fopen(outpath.string().c_str(), "w");
if (!out) {
throw std::runtime_error("failed to open target");
}
- fprintf(out, "#include <%s>\n", (in.filename().replace_extension(".h")).string().c_str());
- Headers(out);
- fprintf(out, "\n");
- Body(out, u);
+ auto components = build(in, out);
if (fclose(out)) {
throw std::runtime_error("failed to close target");
}
+
+ return components;
+}
+
+unsigned int
+SliceCompile::Count(const boost::filesystem::path & in) const
+{
+ return build(in, NULL);
}
void