Skip to content

Commit b32aa31

Browse files
authored
Merge pull request #356 from LeStarch/fix/template-implementation-paths
Fixing implementation include paths
2 parents 7414644 + 52f7ca8 commit b32aa31

40 files changed

+60
-56
lines changed

compiler/lib/src/main/scala/codegen/CppWriter/ComponentCppWriter/ComponentImplWriter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ case class ComponentImplWriter(
5050
private def getCppIncludes: CppDoc.Member = {
5151
val userHeaders = List(
5252
"FpConfig.hpp",
53-
s"${s.getRelativePath(fileName).toString}.hpp"
53+
s.getIncludePath(symbol, fileName).toString
5454
)
5555
linesMember(
5656
addBlankPrefix(userHeaders.sorted.map(CppWriter.headerString).map(line)),

compiler/lib/src/main/scala/codegen/CppWriter/ComponentCppWriter/TestWriter/ComponentTestImplWriter.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ case class ComponentTestImplWriter(
4040

4141
private def getHppIncludes: CppDoc.Member = {
4242
val headers = List(
43-
s"${s.getRelativePath(ComputeCppFiles.FileNames.getComponentGTestBase(name))}.hpp",
44-
s"${s.getRelativePath(ComputeCppFiles.FileNames.getComponentImpl(name))}.hpp"
45-
)
43+
ComputeCppFiles.FileNames.getComponentGTestBase(name),
44+
ComputeCppFiles.FileNames.getComponentImpl(name)
45+
).map(s.getIncludePath(symbol, _))
4646
linesMember(
4747
addBlankPrefix(headers.map(CppWriter.headerString).map(line))
4848
)

compiler/lib/src/main/scala/codegen/CppWriter/CppWriterState.scala

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,19 @@ case class CppWriterState(
128128
removeComponentQualifiers(psOpt, out1)
129129
}
130130

131-
/** Write include directives as lines */
131+
/** Get an include path for a symbol and a file name base */
132+
def getIncludePath(
133+
sym: Symbol,
134+
fileNameBase: String
135+
): String = {
136+
val loc = sym.getLoc.tuLocation
137+
val fullPath = loc.getNeighborPath(fileNameBase)
138+
val path = removeLongestPathPrefix(fullPath)
139+
s"${path.toString}.hpp"
140+
}
141+
142+
/** Write include directives for autocoded files */
132143
def writeIncludeDirectives(usedSymbols: Iterable[Symbol]): List[String] = {
133-
def getHeaderStr(file: File.JavaPath) =
134-
CppWriter.headerString(s"${file.toString}.hpp")
135144
def getDirectiveForSymbol(sym: Symbol): Option[String] =
136145
for {
137146
fileName <- sym match {
@@ -160,12 +169,7 @@ case class CppWriterState(
160169
case _ => None
161170
}
162171
}
163-
yield {
164-
val loc = sym.getLoc.tuLocation
165-
val fullPath = loc.getNeighborPath(fileName)
166-
val path = removeLongestPathPrefix(fullPath)
167-
getHeaderStr(path)
168-
}
172+
yield CppWriter.headerString(getIncludePath(sym, fileName))
169173

170174
usedSymbols.map(getDirectiveForSymbol).filter(_.isDefined).map(_.get).toList
171175
}

compiler/tools/fpp-to-cpp/test/component/impl/ActiveAsyncProductPortsOnly.template.ref.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// \brief cpp file for ActiveAsyncProductPortsOnly component implementation class
55
// ======================================================================
66

7+
#include "ActiveAsyncProductPortsOnly.hpp"
78
#include "FpConfig.hpp"
8-
#include "impl/ActiveAsyncProductPortsOnly.hpp"
99

1010
// ----------------------------------------------------------------------
1111
// Component construction and destruction

compiler/tools/fpp-to-cpp/test/component/impl/ActiveAsyncProducts.template.ref.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// \brief cpp file for ActiveAsyncProducts component implementation class
55
// ======================================================================
66

7+
#include "ActiveAsyncProducts.hpp"
78
#include "FpConfig.hpp"
8-
#include "impl/ActiveAsyncProducts.hpp"
99

1010
// ----------------------------------------------------------------------
1111
// Component construction and destruction

compiler/tools/fpp-to-cpp/test/component/impl/ActiveCommands.template.ref.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// \brief cpp file for ActiveCommands component implementation class
55
// ======================================================================
66

7+
#include "ActiveCommands.hpp"
78
#include "FpConfig.hpp"
8-
#include "impl/ActiveCommands.hpp"
99

1010
// ----------------------------------------------------------------------
1111
// Component construction and destruction

compiler/tools/fpp-to-cpp/test/component/impl/ActiveEvents.template.ref.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// \brief cpp file for ActiveEvents component implementation class
55
// ======================================================================
66

7+
#include "ActiveEvents.hpp"
78
#include "FpConfig.hpp"
8-
#include "impl/ActiveEvents.hpp"
99

1010
// ----------------------------------------------------------------------
1111
// Component construction and destruction

compiler/tools/fpp-to-cpp/test/component/impl/ActiveGetProducts.template.ref.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// \brief cpp file for ActiveGetProducts component implementation class
55
// ======================================================================
66

7+
#include "ActiveGetProducts.hpp"
78
#include "FpConfig.hpp"
8-
#include "impl/ActiveGetProducts.hpp"
99

1010
// ----------------------------------------------------------------------
1111
// Component construction and destruction

compiler/tools/fpp-to-cpp/test/component/impl/ActiveGuardedProducts.template.ref.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// \brief cpp file for ActiveGuardedProducts component implementation class
55
// ======================================================================
66

7+
#include "ActiveGuardedProducts.hpp"
78
#include "FpConfig.hpp"
8-
#include "impl/ActiveGuardedProducts.hpp"
99

1010
// ----------------------------------------------------------------------
1111
// Component construction and destruction

compiler/tools/fpp-to-cpp/test/component/impl/ActiveParams.template.ref.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// \brief cpp file for ActiveParams component implementation class
55
// ======================================================================
66

7+
#include "ActiveParams.hpp"
78
#include "FpConfig.hpp"
8-
#include "impl/ActiveParams.hpp"
99

1010
// ----------------------------------------------------------------------
1111
// Component construction and destruction

0 commit comments

Comments
 (0)