Skip to content

Commit 98c8eda

Browse files
committed
Added Functions prototypes printing.
1 parent c620841 commit 98c8eda

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

src/codegen/c-main-generator.cpp

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,12 @@ void CiMainGenerator::Generate(std::vector<MessageDescriptor_t*>& msgs,
6666
SetCommonValues(drvname);
6767

6868
// work_dir_path has the base dir path to gen files
69+
// 1 step is to define final directory for source code bunch
6970
mhead.dir = work_dir_path;
7071
mhead.fname = drvname + ".h";
7172
mhead.fpath = mhead.dir + "/" + mhead.fname;
7273

73-
// 1 step is to define final directory for source code bunch
74+
// 2 step is to print main head file
7475
fwriter->AppendLine("#pragma once", 2);
7576
fwriter->AppendLine("#ifdef __cplusplus\nextern \"C\" {\n#endif", 2);
7677
fwriter->AppendLine("#include <stdint.h>", 2);
@@ -178,9 +179,37 @@ void CiMainGenerator::Generate(std::vector<MessageDescriptor_t*>& msgs,
178179
fwriter->AppendLine(wbuff, 2);
179180
}
180181

182+
fwriter->AppendLine("// Function signatures", 2);
183+
184+
for (size_t num = 0; num < sigprt->sigs_expr.size(); num++)
185+
{
186+
// write message typedef s and additional expressions
187+
MessageDescriptor_t& m = sigprt->sigs_expr[num]->msg;
188+
189+
snprintf(wbuff, kWBUFF_len, "uint32_t Unpack_%s_%s(%s_t* _m, const uint8_t* _d, uint8_t dlc_);",
190+
m.Name.c_str(), drvname.c_str(), m.Name.c_str());
191+
192+
fwriter->AppendLine(wbuff);
193+
194+
snprintf(wbuff, kWBUFF_len, "#ifdef %s", usestruct_str.c_str());
195+
fwriter->AppendLine(wbuff);
196+
snprintf(wbuff, kWBUFF_len, "uint32_t Pack_%s_%s(const %s_t* _m, __CoderDbcCanFrame_t__* cframe);",
197+
m.Name.c_str(), drvname.c_str(), m.Name.c_str());
198+
fwriter->AppendLine(wbuff);
199+
200+
fwriter->AppendLine("#else");
201+
202+
snprintf(wbuff, kWBUFF_len,
203+
"uint32_t Pack_%s_%s(const %s_t* _m, uint8_t* _d, uint8_t* _len, uint8_t* _ide);",
204+
m.Name.c_str(), drvname.c_str(), m.Name.c_str());
205+
fwriter->AppendLine(wbuff);
206+
207+
snprintf(wbuff, kWBUFF_len, "#endif // %s", usestruct_str.c_str());
208+
fwriter->AppendLine(wbuff, 2);
209+
}
210+
181211
fwriter->AppendLine("#ifdef __cplusplus\n}\n#endif");
182212
fwriter->Flush(mhead.fpath);
183-
// 2 step is to print main head file
184213

185214
// 3 step is to print main source file
186215

src/codegen/c-main-generator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class CiMainGenerator {
2828

2929
std::string usebits_str;
3030
std::string usediag_str;
31-
std::string canframe_str;
31+
std::string usestruct_str;
3232

3333
std::vector<std::string> tmpvect;
3434

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy