Skip to content

Commit 4733196

Browse files
authored
Merge pull request #676 from nasa/tumbar-fix-string-aliases
Fix string alias codegen
2 parents 152e16c + 6d345b4 commit 4733196

File tree

183 files changed

+989
-831
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+989
-831
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ case class TypeCppWriter(
1818
s.writeSymbol(Symbol.AbsType(t.node))
1919

2020
override def aliasType(s: CppWriterState, t: Type.AliasType) =
21-
(stringTypeName, t.getUnderlyingType) match {
22-
case ("Fw::StringBase", Type.String(_)) => stringTypeName
21+
t.getUnderlyingType match {
22+
// String aliases are represented as `Fw::String` in C++ code
23+
// Because string types in code generated by FPP depends on the
24+
// context in the which the string appears, aliases will maintain
25+
// the same behavior as their underlying string types wherever used in
26+
// the FPP model.
27+
case Type.String(_) => stringTypeName
2328
case _ => s.writeSymbol(Symbol.AliasType(t.node))
2429
}
2530

compiler/tools/fpp-to-cpp/test/alias/BasicSerializableAc.ref.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ class Basic :
3131
SERIALIZED_SIZE =
3232
sizeof(TU32) +
3333
sizeof(TF32) +
34-
TString::SERIALIZED_SIZE +
35-
TStringSize::SERIALIZED_SIZE
34+
Fw::StringBase::STATIC_SERIALIZED_SIZE(80) +
35+
Fw::StringBase::STATIC_SERIALIZED_SIZE(2)
3636
};
3737

3838
public:

compiler/tools/fpp-to-cpp/test/component/base/ActiveAsyncProductsComponentAc.ref.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2526,7 +2526,7 @@ void ActiveAsyncProductsComponentBase ::
25262526
);
25272527
}
25282528

2529-
AliasString ActiveAsyncProductsComponentBase ::
2529+
Fw::String ActiveAsyncProductsComponentBase ::
25302530
noArgsAliasStringReturnSync_handlerBase(FwIndexType portNum)
25312531
{
25322532
// Make sure port number is valid
@@ -2535,7 +2535,7 @@ AliasString ActiveAsyncProductsComponentBase ::
25352535
static_cast<FwAssertArgType>(portNum)
25362536
);
25372537

2538-
AliasString retVal;
2538+
Fw::String retVal;
25392539

25402540
// Call handler function
25412541
retVal = this->noArgsAliasStringReturnSync_handler(portNum);
@@ -2744,7 +2744,7 @@ AliasPrim2 ActiveAsyncProductsComponentBase ::
27442744
return retVal;
27452745
}
27462746

2747-
AliasString ActiveAsyncProductsComponentBase ::
2747+
Fw::String ActiveAsyncProductsComponentBase ::
27482748
typedAliasStringReturnSync_handlerBase(
27492749
FwIndexType portNum,
27502750
AliasPrim1 u32,
@@ -2762,7 +2762,7 @@ AliasString ActiveAsyncProductsComponentBase ::
27622762
static_cast<FwAssertArgType>(portNum)
27632763
);
27642764

2765-
AliasString retVal;
2765+
Fw::String retVal;
27662766

27672767
// Call handler function
27682768
retVal = this->typedAliasStringReturnSync_handler(
@@ -3625,7 +3625,7 @@ AliasPrim2 ActiveAsyncProductsComponentBase ::
36253625
);
36263626
}
36273627

3628-
AliasString ActiveAsyncProductsComponentBase ::
3628+
Fw::String ActiveAsyncProductsComponentBase ::
36293629
typedAliasReturnStringOut_out(
36303630
FwIndexType portNum,
36313631
AliasPrim1 u32,
@@ -4318,7 +4318,7 @@ void ActiveAsyncProductsComponentBase ::
43184318
);
43194319
}
43204320

4321-
AliasString ActiveAsyncProductsComponentBase ::
4321+
Fw::String ActiveAsyncProductsComponentBase ::
43224322
m_p_noArgsAliasStringReturnSync_in(
43234323
Fw::PassiveComponentBase* callComp,
43244324
FwIndexType portNum
@@ -4449,7 +4449,7 @@ AliasPrim2 ActiveAsyncProductsComponentBase ::
44494449
);
44504450
}
44514451

4452-
AliasString ActiveAsyncProductsComponentBase ::
4452+
Fw::String ActiveAsyncProductsComponentBase ::
44534453
m_p_typedAliasStringReturnSync_in(
44544454
Fw::PassiveComponentBase* callComp,
44554455
FwIndexType portNum,

compiler/tools/fpp-to-cpp/test/component/base/ActiveAsyncProductsComponentAc.ref.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ class ActiveAsyncProductsComponentBase :
10581058
) = 0;
10591059

10601060
//! Handler for input port noArgsAliasStringReturnSync
1061-
virtual AliasString noArgsAliasStringReturnSync_handler(
1061+
virtual Fw::String noArgsAliasStringReturnSync_handler(
10621062
FwIndexType portNum //!< The port number
10631063
) = 0;
10641064

@@ -1117,7 +1117,7 @@ class ActiveAsyncProductsComponentBase :
11171117
) = 0;
11181118

11191119
//! Handler for input port typedAliasStringReturnSync
1120-
virtual AliasString typedAliasStringReturnSync_handler(
1120+
virtual Fw::String typedAliasStringReturnSync_handler(
11211121
FwIndexType portNum, //!< The port number
11221122
AliasPrim1 u32, //!< A primitive
11231123
AliasPrim2 f32, //!< Another primtive
@@ -1245,7 +1245,7 @@ class ActiveAsyncProductsComponentBase :
12451245
);
12461246

12471247
//! Handler base-class function for input port noArgsAliasStringReturnSync
1248-
AliasString noArgsAliasStringReturnSync_handlerBase(
1248+
Fw::String noArgsAliasStringReturnSync_handlerBase(
12491249
FwIndexType portNum //!< The port number
12501250
);
12511251

@@ -1304,7 +1304,7 @@ class ActiveAsyncProductsComponentBase :
13041304
);
13051305

13061306
//! Handler base-class function for input port typedAliasStringReturnSync
1307-
AliasString typedAliasStringReturnSync_handlerBase(
1307+
Fw::String typedAliasStringReturnSync_handlerBase(
13081308
FwIndexType portNum, //!< The port number
13091309
AliasPrim1 u32, //!< A primitive
13101310
AliasPrim2 f32, //!< Another primtive
@@ -1570,7 +1570,7 @@ class ActiveAsyncProductsComponentBase :
15701570
);
15711571

15721572
//! Invoke output port typedAliasReturnStringOut
1573-
AliasString typedAliasReturnStringOut_out(
1573+
Fw::String typedAliasReturnStringOut_out(
15741574
FwIndexType portNum, //!< The port number
15751575
AliasPrim1 u32, //!< A primitive
15761576
AliasPrim2 f32, //!< Another primtive
@@ -1767,7 +1767,7 @@ class ActiveAsyncProductsComponentBase :
17671767
);
17681768

17691769
//! Callback for port noArgsAliasStringReturnSync
1770-
static AliasString m_p_noArgsAliasStringReturnSync_in(
1770+
static Fw::String m_p_noArgsAliasStringReturnSync_in(
17711771
Fw::PassiveComponentBase* callComp, //!< The component instance
17721772
FwIndexType portNum //!< The port number
17731773
);
@@ -1835,7 +1835,7 @@ class ActiveAsyncProductsComponentBase :
18351835
);
18361836

18371837
//! Callback for port typedAliasStringReturnSync
1838-
static AliasString m_p_typedAliasStringReturnSync_in(
1838+
static Fw::String m_p_typedAliasStringReturnSync_in(
18391839
Fw::PassiveComponentBase* callComp, //!< The component instance
18401840
FwIndexType portNum, //!< The port number
18411841
AliasPrim1 u32, //!< A primitive

compiler/tools/fpp-to-cpp/test/component/base/ActiveCommandsComponentAc.ref.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,7 +2140,7 @@ void ActiveCommandsComponentBase ::
21402140
);
21412141
}
21422142

2143-
AliasString ActiveCommandsComponentBase ::
2143+
Fw::String ActiveCommandsComponentBase ::
21442144
noArgsAliasStringReturnSync_handlerBase(FwIndexType portNum)
21452145
{
21462146
// Make sure port number is valid
@@ -2149,7 +2149,7 @@ AliasString ActiveCommandsComponentBase ::
21492149
static_cast<FwAssertArgType>(portNum)
21502150
);
21512151

2152-
AliasString retVal;
2152+
Fw::String retVal;
21532153

21542154
// Call handler function
21552155
retVal = this->noArgsAliasStringReturnSync_handler(portNum);
@@ -2358,7 +2358,7 @@ AliasPrim2 ActiveCommandsComponentBase ::
23582358
return retVal;
23592359
}
23602360

2361-
AliasString ActiveCommandsComponentBase ::
2361+
Fw::String ActiveCommandsComponentBase ::
23622362
typedAliasStringReturnSync_handlerBase(
23632363
FwIndexType portNum,
23642364
AliasPrim1 u32,
@@ -2376,7 +2376,7 @@ AliasString ActiveCommandsComponentBase ::
23762376
static_cast<FwAssertArgType>(portNum)
23772377
);
23782378

2379-
AliasString retVal;
2379+
Fw::String retVal;
23802380

23812381
// Call handler function
23822382
retVal = this->typedAliasStringReturnSync_handler(
@@ -3172,7 +3172,7 @@ AliasPrim2 ActiveCommandsComponentBase ::
31723172
);
31733173
}
31743174

3175-
AliasString ActiveCommandsComponentBase ::
3175+
Fw::String ActiveCommandsComponentBase ::
31763176
typedAliasReturnStringOut_out(
31773177
FwIndexType portNum,
31783178
AliasPrim1 u32,
@@ -5223,7 +5223,7 @@ void ActiveCommandsComponentBase ::
52235223
);
52245224
}
52255225

5226-
AliasString ActiveCommandsComponentBase ::
5226+
Fw::String ActiveCommandsComponentBase ::
52275227
m_p_noArgsAliasStringReturnSync_in(
52285228
Fw::PassiveComponentBase* callComp,
52295229
FwIndexType portNum
@@ -5354,7 +5354,7 @@ AliasPrim2 ActiveCommandsComponentBase ::
53545354
);
53555355
}
53565356

5357-
AliasString ActiveCommandsComponentBase ::
5357+
Fw::String ActiveCommandsComponentBase ::
53585358
m_p_typedAliasStringReturnSync_in(
53595359
Fw::PassiveComponentBase* callComp,
53605360
FwIndexType portNum,

compiler/tools/fpp-to-cpp/test/component/base/ActiveCommandsComponentAc.ref.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ class ActiveCommandsComponentBase :
873873
) = 0;
874874

875875
//! Handler for input port noArgsAliasStringReturnSync
876-
virtual AliasString noArgsAliasStringReturnSync_handler(
876+
virtual Fw::String noArgsAliasStringReturnSync_handler(
877877
FwIndexType portNum //!< The port number
878878
) = 0;
879879

@@ -932,7 +932,7 @@ class ActiveCommandsComponentBase :
932932
) = 0;
933933

934934
//! Handler for input port typedAliasStringReturnSync
935-
virtual AliasString typedAliasStringReturnSync_handler(
935+
virtual Fw::String typedAliasStringReturnSync_handler(
936936
FwIndexType portNum, //!< The port number
937937
AliasPrim1 u32, //!< A primitive
938938
AliasPrim2 f32, //!< Another primtive
@@ -1060,7 +1060,7 @@ class ActiveCommandsComponentBase :
10601060
);
10611061

10621062
//! Handler base-class function for input port noArgsAliasStringReturnSync
1063-
AliasString noArgsAliasStringReturnSync_handlerBase(
1063+
Fw::String noArgsAliasStringReturnSync_handlerBase(
10641064
FwIndexType portNum //!< The port number
10651065
);
10661066

@@ -1119,7 +1119,7 @@ class ActiveCommandsComponentBase :
11191119
);
11201120

11211121
//! Handler base-class function for input port typedAliasStringReturnSync
1122-
AliasString typedAliasStringReturnSync_handlerBase(
1122+
Fw::String typedAliasStringReturnSync_handlerBase(
11231123
FwIndexType portNum, //!< The port number
11241124
AliasPrim1 u32, //!< A primitive
11251125
AliasPrim2 f32, //!< Another primtive
@@ -1347,7 +1347,7 @@ class ActiveCommandsComponentBase :
13471347
);
13481348

13491349
//! Invoke output port typedAliasReturnStringOut
1350-
AliasString typedAliasReturnStringOut_out(
1350+
Fw::String typedAliasReturnStringOut_out(
13511351
FwIndexType portNum, //!< The port number
13521352
AliasPrim1 u32, //!< A primitive
13531353
AliasPrim2 f32, //!< Another primtive
@@ -1826,7 +1826,7 @@ class ActiveCommandsComponentBase :
18261826
);
18271827

18281828
//! Callback for port noArgsAliasStringReturnSync
1829-
static AliasString m_p_noArgsAliasStringReturnSync_in(
1829+
static Fw::String m_p_noArgsAliasStringReturnSync_in(
18301830
Fw::PassiveComponentBase* callComp, //!< The component instance
18311831
FwIndexType portNum //!< The port number
18321832
);
@@ -1894,7 +1894,7 @@ class ActiveCommandsComponentBase :
18941894
);
18951895

18961896
//! Callback for port typedAliasStringReturnSync
1897-
static AliasString m_p_typedAliasStringReturnSync_in(
1897+
static Fw::String m_p_typedAliasStringReturnSync_in(
18981898
Fw::PassiveComponentBase* callComp, //!< The component instance
18991899
FwIndexType portNum, //!< The port number
19001900
AliasPrim1 u32, //!< A primitive

compiler/tools/fpp-to-cpp/test/component/base/ActiveEventsComponentAc.ref.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,7 +2059,7 @@ void ActiveEventsComponentBase ::
20592059
);
20602060
}
20612061

2062-
AliasString ActiveEventsComponentBase ::
2062+
Fw::String ActiveEventsComponentBase ::
20632063
noArgsAliasStringReturnSync_handlerBase(FwIndexType portNum)
20642064
{
20652065
// Make sure port number is valid
@@ -2068,7 +2068,7 @@ AliasString ActiveEventsComponentBase ::
20682068
static_cast<FwAssertArgType>(portNum)
20692069
);
20702070

2071-
AliasString retVal;
2071+
Fw::String retVal;
20722072

20732073
// Call handler function
20742074
retVal = this->noArgsAliasStringReturnSync_handler(portNum);
@@ -2277,7 +2277,7 @@ AliasPrim2 ActiveEventsComponentBase ::
22772277
return retVal;
22782278
}
22792279

2280-
AliasString ActiveEventsComponentBase ::
2280+
Fw::String ActiveEventsComponentBase ::
22812281
typedAliasStringReturnSync_handlerBase(
22822282
FwIndexType portNum,
22832283
AliasPrim1 u32,
@@ -2295,7 +2295,7 @@ AliasString ActiveEventsComponentBase ::
22952295
static_cast<FwAssertArgType>(portNum)
22962296
);
22972297

2298-
AliasString retVal;
2298+
Fw::String retVal;
22992299

23002300
// Call handler function
23012301
retVal = this->typedAliasStringReturnSync_handler(
@@ -3091,7 +3091,7 @@ AliasPrim2 ActiveEventsComponentBase ::
30913091
);
30923092
}
30933093

3094-
AliasString ActiveEventsComponentBase ::
3094+
Fw::String ActiveEventsComponentBase ::
30953095
typedAliasReturnStringOut_out(
30963096
FwIndexType portNum,
30973097
AliasPrim1 u32,
@@ -4350,7 +4350,7 @@ void ActiveEventsComponentBase ::
43504350
);
43514351
}
43524352

4353-
AliasString ActiveEventsComponentBase ::
4353+
Fw::String ActiveEventsComponentBase ::
43544354
m_p_noArgsAliasStringReturnSync_in(
43554355
Fw::PassiveComponentBase* callComp,
43564356
FwIndexType portNum
@@ -4481,7 +4481,7 @@ AliasPrim2 ActiveEventsComponentBase ::
44814481
);
44824482
}
44834483

4484-
AliasString ActiveEventsComponentBase ::
4484+
Fw::String ActiveEventsComponentBase ::
44854485
m_p_typedAliasStringReturnSync_in(
44864486
Fw::PassiveComponentBase* callComp,
44874487
FwIndexType portNum,

0 commit comments

Comments
 (0)