Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bf0ed04

Browse files
committed
Fs creator keeps lowcase drvname in separated field.
1 parent 246a2b9 commit bf0ed04

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

src/codegen/c-main-generator.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,24 +154,26 @@ void CiMainGenerator::Generate(std::vector<MessageDescriptor_t*>& msgs, const Fs
154154

155155
fwriter->AppendLine(
156156
PrintF("uint32_t Unpack_%s_%s(%s_t* _m, const uint8_t* _d, uint8_t dlc_);",
157-
m.Name.c_str(), fsd.drvname.c_str(), m.Name.c_str()));
157+
m.Name.c_str(), fsd.DrvName_orig.c_str(), m.Name.c_str()));
158158

159159
fwriter->AppendLine(PrintF("#ifdef %s", fsd.usesruct_def.c_str()));
160160

161161
fwriter->AppendLine(
162162
PrintF("uint32_t Pack_%s_%s(const %s_t* _m, __CoderDbcCanFrame_t__* cframe);",
163-
m.Name.c_str(), fsd.drvname.c_str(), m.Name.c_str()));
163+
m.Name.c_str(), fsd.DrvName_orig.c_str(), m.Name.c_str()));
164164

165165
fwriter->AppendLine("#else");
166166

167167
fwriter->AppendLine(
168168
PrintF("uint32_t Pack_%s_%s(const %s_t* _m, uint8_t* _d, uint8_t* _len, uint8_t* _ide);",
169-
m.Name.c_str(), fsd.drvname.c_str(), m.Name.c_str()));
169+
m.Name.c_str(), fsd.DrvName_orig.c_str(), m.Name.c_str()));
170170

171171
fwriter->AppendLine(PrintF("#endif // %s", fsd.usesruct_def.c_str()), 2);
172172
}
173173

174174
fwriter->AppendLine("#ifdef __cplusplus\n}\n#endif");
175+
176+
// save fwrite cached text to file
175177
fwriter->Flush(fsd.core_h.fpath);
176178

177179
// 3 step is to print main source file

src/codegen/fs-creator.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,25 +75,25 @@ bool FsCreator::PrepareDirectory(std::string drvname, std::string basepath, bool
7575
if (ret)
7676
{
7777
// directory valid and exists, set all the values
78-
FS.drvname = drvname;
78+
FS.DrvName_orig = drvname;
7979
FS.DRVNAME = str_toupper(drvname);
80+
FS.drvname = str_tolower(drvname);
8081

81-
std::string ldrvname = str_tolower(drvname);
8282

8383
FS.core_h.dir = work_dir_path;
84-
FS.core_h.fname = ldrvname + ".h";
84+
FS.core_h.fname = FS.drvname + ".h";
8585
FS.core_h.fpath = work_dir_path + "/" + FS.core_h.fname;
8686

8787
FS.core_c.dir = work_dir_path;
88-
FS.core_c.fname = ldrvname + ".c";
88+
FS.core_c.fname = FS.drvname + ".c";
8989
FS.core_c.fpath = work_dir_path + "/" + FS.core_c.fname;
9090

9191
FS.util_h.dir = work_dir_path;
92-
FS.util_h.fname = ldrvname + "_binutil" + ".h";
92+
FS.util_h.fname = FS.drvname + "_binutil" + ".h";
9393
FS.util_h.fpath = work_dir_path + "/" + FS.util_h.fname;
9494

9595
FS.util_c.dir = work_dir_path;
96-
FS.util_c.fname = ldrvname + "_binutil" + ".c";
96+
FS.util_c.fname = FS.drvname + "_binutil" + ".c";
9797
FS.util_c.fpath = work_dir_path + "/" + FS.util_c.fname;
9898

9999
snprintf(_tmpb, kTmpLen, "%s_USE_BITS_SIGNAL", FS.DRVNAME.c_str());

src/codegen/fs-creator.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
typedef struct
88
{
9+
// original driver name view
10+
std::string DrvName_orig;
911
// low case driver name
1012
std::string drvname;
1113
// up case driver name
@@ -26,7 +28,7 @@ typedef struct
2628
// This class is used to build all neccessary string -ed
2729
// value that will be required during code generation
2830
// (paths, file names, drvnames, common defines etc)
29-
// if preparation ends with true, the collection of
31+
// if preparation ends with true, the collection of
3032
// values can be used.
3133
class FsCreator {
3234
public:

0 commit comments

Comments
 (0)