Skip to content

Commit

Permalink
Merge pull request #75 from ESTOS/feature/BUILDSYS-438
Browse files Browse the repository at this point in the history
Bugfixes
  • Loading branch information
JanFellner authored Sep 12, 2024
2 parents c31ec6f + abf4bbb commit 55b2d34
Show file tree
Hide file tree
Showing 31 changed files with 146 additions and 46 deletions.
2 changes: 1 addition & 1 deletion compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if(WIN32)
else()
file(GLOB src_files core/*.c core/*.cpp back-ends/*.c back-ends/**/*.c)
endif()
file(GLOB header_files core/*.h back-ends/*.h back-ends/**/*.h)
file(GLOB header_files *.h core/*.h back-ends/*.h back-ends/**/*.h)

# Set the compiler (binary) output path
if(COMPILER_OUTPUT_PATH)
Expand Down
26 changes: 25 additions & 1 deletion compiler/back-ends/ts-gen/gen-ts-code.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,6 @@ void PrintTSSeqDefCode(FILE* src, ModuleList* mods, Module* m, TypeDef* td, Type
fprintf(src, "new asn1ts.%s({ name: \"%s\"%s })", GetBERType(e->type->basicType->choiceId), szConverted2, szOptionalParam);
else if (choiceId == BASICTYPE_LOCALTYPEREF || choiceId == BASICTYPE_IMPORTTYPEREF)
{

const char* szModuleName = "";
const char* szModuleNameDelimiter = "";
if (choiceId == BASICTYPE_IMPORTTYPEREF)
Expand Down Expand Up @@ -982,6 +981,31 @@ void PrintTSCode(ModuleList* allMods, long longJmpVal, int genTypes, int genValu
FreeDefinedObjs(&fNames);
}

if (gMajorInterfaceVersion >= 0)
{
FILE* versionFile = NULL;
char* szVersionFile = MakeFileName("Asn1InterfaceVersion.ts", "");
if (fopen_s(&versionFile, szVersionFile, "wt") != 0 || versionFile == NULL)
perror("fopen");
else
{
fprintf(versionFile, "/*\n");
write_snacc_header(versionFile, " * ");
fprintf(versionFile, "*/\n\n");
fprintf(versionFile, "// prettier-ignore\n");
fprintf(versionFile, "/* eslint-disable */\n\n");
long long lMaxMinorVersion = GetMaxModuleMinorVersion();
fprintf(versionFile, "export class Asn1InterfaceVersion {\n");
fprintf(versionFile, "\tpublic static lastChange = \"%s\";\n", ConvertUnixTimeToISO(lMaxMinorVersion));
fprintf(versionFile, "\tpublic static majorVersion = %i;\n", gMajorInterfaceVersion);
fprintf(versionFile, "\tpublic static minorVersion = %lld;\n", lMaxMinorVersion);
fprintf(versionFile, "\tpublic static version = \"%i.%lld.0\";\n", gMajorInterfaceVersion, lMaxMinorVersion);
fprintf(versionFile, "}\n");
fclose(versionFile);
}
free(szVersionFile);
}

FILE* typesFile = NULL;
char* szTypes = MakeFileName("types.ts", "");
if (fopen_s(&typesFile, szTypes, "wt") != 0 || typesFile == NULL)
Expand Down
35 changes: 22 additions & 13 deletions compiler/core/asn_commentparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ extern "C"
}

// std::set SORTIERT, das darf aber bei dem explode nicht sein!
std::vector<std::string> explode(std::string const& s, char delim)
std::vector<std::string> explode(std::string const& s, char delim, const bool bSkipEmpty = true)
{
std::vector<std::string> result;
std::istringstream iss(s);
Expand All @@ -147,7 +147,7 @@ std::vector<std::string> explode(std::string const& s, char delim)
{
// leere tokens auslassen, brauchen wir nicht
auto element = trim(token);
if (element.size())
if (!bSkipEmpty || element.size())
result.push_back(element);
}

Expand Down Expand Up @@ -633,17 +633,19 @@ int EAsnStackElementModule::ProcessLine(const char* szModuleName, const char* sz
{
EAsnStackElementOperation* el = new EAsnStackElementOperation(m_pParser);
el->SetOperationProperties(strType.c_str(), &m_ModuleComment, m_CollectComments);

m_pParser->m_stack.push_back(el);

m_CollectComments.clear();
return 0;
}
else
{
m_strFilteredFileContent += m_strRawSourceFileIncrement;
m_strRawSourceFileIncrement.clear();

ESequenceComment comment;
convertCommentList(m_CollectComments, &comment);
if (!isFiltered(comment))
{
m_strFilteredFileContent += m_strRawSourceFileIncrement;
m_strRawSourceFileIncrement.clear();
}
m_CollectComments.clear();
}

Expand Down Expand Up @@ -937,19 +939,26 @@ int EAsnCommentParser::ParseFileForComments(FILE* fp, const char* szModuleName,
#endif
if (filteredFile)
{
const auto& strData = pFile->m_strFilteredFileContent;
if (type == UTF8WITHBOM)
{
unsigned char bom[] = {0xEF, 0xBB, 0xBF};
fwrite(bom, sizeof(unsigned char), 3, filteredFile);
}
if (type == ASCII)
const auto& strData = pFile->m_strFilteredFileContent;
auto strElements = explode(strData, '\n', false);
for (auto& strElement : strElements)
{
auto strASCII = AsnStringConvert::UTF8ToAscii(strData.c_str());
fwrite(strASCII.c_str(), sizeof(char), strASCII.length(), filteredFile);
if (strElement.length() > 4 && strElement.substr(0, 5) == "-- ~ " || strElement.length() == 4 && strElement.substr(0, 4) == "-- ~")
continue;
strElement += "\n";
if (type == ASCII)
{
auto strASCII = AsnStringConvert::UTF8ToAscii(strElement.c_str());
fwrite(strASCII.c_str(), sizeof(char), strASCII.length(), filteredFile);
}
else
fwrite(strElement.c_str(), sizeof(char), strElement.length(), filteredFile);
}
else
fwrite(strData.c_str(), sizeof(char), strData.length(), filteredFile);
fclose(filteredFile);
}
}
Expand Down
37 changes: 37 additions & 0 deletions compiler/core/snacc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1550,6 +1550,43 @@ void GenCxxCode(ModuleList* allMods, long longJmpVal, int genTypes, int genValue
#endif
}

if (gMajorInterfaceVersion >= 0)
{
FILE* versionFile = NULL;
char* szVersionFile = MakeFileName("Asn1InterfaceVersion.h", "");
if (fopen_s(&versionFile, szVersionFile, "wt") != 0 || versionFile == NULL)
perror("fopen");
else
{
long long lMaxMinorVersion = GetMaxModuleMinorVersion();
write_snacc_header(versionFile, "// ");
fprintf(versionFile, "\n");
fprintf(versionFile, "// clang-format off\n\n");
fprintf(versionFile, "#ifndef ASN1_INTERFACE_VERSION_H\n");
fprintf(versionFile, "#define ASN1_INTERFACE_VERSION_H\n\n");
fprintf(versionFile, "#ifndef NO_NAMESPACE\n");
fprintf(versionFile, "namespace SNACC\n");
fprintf(versionFile, "{\n");
fprintf(versionFile, "#endif\n\n");

fprintf(versionFile, "struct Asn1InterfaceVersion\n");
fprintf(versionFile, "{\n");
fprintf(versionFile, "\tstatic constexpr const char* lastChange = \"%s\";\n", ConvertUnixTimeToISO(lMaxMinorVersion));
fprintf(versionFile, "\tstatic constexpr int majorVersion = %i;\n", gMajorInterfaceVersion);
fprintf(versionFile, "\tstatic constexpr long long minorVersion = %lld;\n", lMaxMinorVersion);
fprintf(versionFile, "\tstatic constexpr const char* version = \"%i.%lld.0\";\n", gMajorInterfaceVersion, lMaxMinorVersion);
fprintf(versionFile, "};\n\n");

fprintf(versionFile, "#ifndef NO_NAMESPACE\n");
fprintf(versionFile, "}\n");
fprintf(versionFile, "#endif\n\n");

fprintf(versionFile, "#endif");
fclose(versionFile);
}
free(szVersionFile);
}

FOR_EACH_LIST_ELMT(currMod, allMods)
{
if (currMod->ImportedFlag == FALSE)
Expand Down
15 changes: 15 additions & 0 deletions samples/ts-microservice/client/src/stub/Asn1InterfaceVersion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* This file was generated by estos esnacc (V6.0.12, 12.09.2024)
* based on Coral WinSnacc written by Deepak Gupta
* NOTE: This is a machine generated file - editing not recommended
*/

// prettier-ignore
/* eslint-disable */

export class Asn1InterfaceVersion {
public static lastChange = "2024-05-06T00:00:00Z";
public static majorVersion = 0;
public static minorVersion = 1714953600;
public static version = "0.1714953600.0";
}
2 changes: 1 addition & 1 deletion samples/ts-microservice/client/src/stub/ENetUC_Common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* ENetUC_Common.ts
* "UC-Server-Access-Protocol-Common" ASN.1 stubs.
* This file was generated by estos esnacc (V6.0.7, 15.05.2024)
* This file was generated by estos esnacc (V6.0.12, 12.09.2024)
* based on Coral WinSnacc written by Deepak Gupta
* NOTE: This is a machine generated file - editing not recommended
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* ENetUC_Common_Converter.ts
* "UC-Server-Access-Protocol-Common" ASN.1 stubs.
* This file was generated by estos esnacc (V6.0.7, 15.05.2024)
* This file was generated by estos esnacc (V6.0.12, 12.09.2024)
* based on Coral WinSnacc written by Deepak Gupta
* NOTE: This is a machine generated file - editing not recommended
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* ENetUC_Event_Manager.ts
* "UC-Server-Access-Protocol-Event-Manager" ASN.1 stubs.
* This file was generated by estos esnacc (V6.0.7, 15.05.2024)
* This file was generated by estos esnacc (V6.0.12, 12.09.2024)
* based on Coral WinSnacc written by Deepak Gupta
* NOTE: This is a machine generated file - editing not recommended
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* ENetUC_Event_ManagerROSE
* "UC-Server-Access-Protocol-Event-Manager" ASN.1 stubs.
* This file was generated by estos esnacc (V6.0.7, 15.05.2024)
* This file was generated by estos esnacc (V6.0.12, 12.09.2024)
* based on Coral WinSnacc written by Deepak Gupta
* NOTE: This is a machine generated file - editing not recommended
*/
Expand All @@ -29,7 +29,7 @@ export const MODULE_MINOR_VERSION = 0;
export const MODULE_VERSION = "0.0.0";

// [PrintTSROSEOperationDefines]
enum OperationIDs {
export enum OperationIDs {
OPID_asnCreateFancyEvents = 4000,
OPID_asnFancyEvent = 4050
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* ENetUC_Event_ManagerROSE_Interface
* "UC-Server-Access-Protocol-Event-Manager" ASN.1 interfaces.
* This file was generated by estos esnacc (V6.0.7, 15.05.2024)
* This file was generated by estos esnacc (V6.0.12, 12.09.2024)
* based on Coral WinSnacc written by Deepak Gupta
* NOTE: This is a machine generated file - editing not recommended
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* ENetUC_Event_Manager_Converter.ts
* "UC-Server-Access-Protocol-Event-Manager" ASN.1 stubs.
* This file was generated by estos esnacc (V6.0.7, 15.05.2024)
* This file was generated by estos esnacc (V6.0.12, 12.09.2024)
* based on Coral WinSnacc written by Deepak Gupta
* NOTE: This is a machine generated file - editing not recommended
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* ENetUC_Settings_Manager.ts
* "UC-Server-Access-Protocol-Settings-Manager" ASN.1 stubs.
* This file was generated by estos esnacc (V6.0.7, 15.05.2024)
* This file was generated by estos esnacc (V6.0.12, 12.09.2024)
* based on Coral WinSnacc written by Deepak Gupta
* NOTE: This is a machine generated file - editing not recommended
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* ENetUC_Settings_ManagerROSE
* "UC-Server-Access-Protocol-Settings-Manager" ASN.1 stubs.
* This file was generated by estos esnacc (V6.0.7, 15.05.2024)
* This file was generated by estos esnacc (V6.0.12, 12.09.2024)
* based on Coral WinSnacc written by Deepak Gupta
* NOTE: This is a machine generated file - editing not recommended
*/
Expand Down Expand Up @@ -30,7 +30,7 @@ export const MODULE_MINOR_VERSION = 1714953600;
export const MODULE_VERSION = "0.1714953600.0";

// [PrintTSROSEOperationDefines]
enum OperationIDs {
export enum OperationIDs {
OPID_asnGetSettings = 4100,
OPID_asnSetSettings = 4101,
OPID_asnGetSettingsOld = 4102,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* ENetUC_Settings_ManagerROSE_Interface
* "UC-Server-Access-Protocol-Settings-Manager" ASN.1 interfaces.
* This file was generated by estos esnacc (V6.0.7, 15.05.2024)
* This file was generated by estos esnacc (V6.0.12, 12.09.2024)
* based on Coral WinSnacc written by Deepak Gupta
* NOTE: This is a machine generated file - editing not recommended
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* ENetUC_Settings_Manager_Converter.ts
* "UC-Server-Access-Protocol-Settings-Manager" ASN.1 stubs.
* This file was generated by estos esnacc (V6.0.7, 15.05.2024)
* This file was generated by estos esnacc (V6.0.12, 12.09.2024)
* based on Coral WinSnacc written by Deepak Gupta
* NOTE: This is a machine generated file - editing not recommended
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/ts-microservice/client/src/stub/methods.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* This file exports all specified ROSE methods as arrays
*
* This file was generated by estos esnacc (V6.0.7, 15.05.2024)
* This file was generated by estos esnacc (V6.0.12, 12.09.2024)
* based on Coral WinSnacc written by Deepak Gupta
* NOTE: This is a machine generated file - editing not recommended
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/ts-microservice/client/src/stub/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* This file combines exports from asn1 files under one name
*
* This file was generated by estos esnacc (V6.0.7, 15.05.2024)
* This file was generated by estos esnacc (V6.0.12, 12.09.2024)
* based on Coral WinSnacc written by Deepak Gupta
* NOTE: This is a machine generated file - editing not recommended
*/
Expand Down
15 changes: 15 additions & 0 deletions samples/ts-microservice/server/src/stub/Asn1InterfaceVersion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* This file was generated by estos esnacc (V6.0.12, 12.09.2024)
* based on Coral WinSnacc written by Deepak Gupta
* NOTE: This is a machine generated file - editing not recommended
*/

// prettier-ignore
/* eslint-disable */

export class Asn1InterfaceVersion {
public static lastChange = "2024-05-06T00:00:00Z";
public static majorVersion = 0;
public static minorVersion = 1714953600;
public static version = "0.1714953600.0";
}
2 changes: 1 addition & 1 deletion samples/ts-microservice/server/src/stub/ENetUC_Common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* ENetUC_Common.ts
* "UC-Server-Access-Protocol-Common" ASN.1 stubs.
* This file was generated by estos esnacc (V6.0.7, 15.05.2024)
* This file was generated by estos esnacc (V6.0.12, 12.09.2024)
* based on Coral WinSnacc written by Deepak Gupta
* NOTE: This is a machine generated file - editing not recommended
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* ENetUC_Common_Converter.ts
* "UC-Server-Access-Protocol-Common" ASN.1 stubs.
* This file was generated by estos esnacc (V6.0.7, 15.05.2024)
* This file was generated by estos esnacc (V6.0.12, 12.09.2024)
* based on Coral WinSnacc written by Deepak Gupta
* NOTE: This is a machine generated file - editing not recommended
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* ENetUC_Event_Manager.ts
* "UC-Server-Access-Protocol-Event-Manager" ASN.1 stubs.
* This file was generated by estos esnacc (V6.0.7, 15.05.2024)
* This file was generated by estos esnacc (V6.0.12, 12.09.2024)
* based on Coral WinSnacc written by Deepak Gupta
* NOTE: This is a machine generated file - editing not recommended
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* ENetUC_Event_ManagerROSE
* "UC-Server-Access-Protocol-Event-Manager" ASN.1 stubs.
* This file was generated by estos esnacc (V6.0.7, 15.05.2024)
* This file was generated by estos esnacc (V6.0.12, 12.09.2024)
* based on Coral WinSnacc written by Deepak Gupta
* NOTE: This is a machine generated file - editing not recommended
*/
Expand All @@ -29,7 +29,7 @@ export const MODULE_MINOR_VERSION = 0;
export const MODULE_VERSION = "0.0.0";

// [PrintTSROSEOperationDefines]
enum OperationIDs {
export enum OperationIDs {
OPID_asnCreateFancyEvents = 4000,
OPID_asnFancyEvent = 4050
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* ENetUC_Event_ManagerROSE_Interface
* "UC-Server-Access-Protocol-Event-Manager" ASN.1 interfaces.
* This file was generated by estos esnacc (V6.0.7, 15.05.2024)
* This file was generated by estos esnacc (V6.0.12, 12.09.2024)
* based on Coral WinSnacc written by Deepak Gupta
* NOTE: This is a machine generated file - editing not recommended
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* ENetUC_Event_Manager_Converter.ts
* "UC-Server-Access-Protocol-Event-Manager" ASN.1 stubs.
* This file was generated by estos esnacc (V6.0.7, 15.05.2024)
* This file was generated by estos esnacc (V6.0.12, 12.09.2024)
* based on Coral WinSnacc written by Deepak Gupta
* NOTE: This is a machine generated file - editing not recommended
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* ENetUC_Settings_Manager.ts
* "UC-Server-Access-Protocol-Settings-Manager" ASN.1 stubs.
* This file was generated by estos esnacc (V6.0.7, 15.05.2024)
* This file was generated by estos esnacc (V6.0.12, 12.09.2024)
* based on Coral WinSnacc written by Deepak Gupta
* NOTE: This is a machine generated file - editing not recommended
*/
Expand Down
Loading

0 comments on commit 55b2d34

Please sign in to comment.