Skip to content

Commit

Permalink
C++: add missing export macro to 'CppEnumeration.mustache'
Browse files Browse the repository at this point in the history
Generated files for C++ did not contain export macro
for enumerations. That was not the case of structs and
classes. The reason for that was missing inclusion of
'CppExportMacro' in 'CppEnumeration.mustache'.

Note: the change in logic is only a single line.
      The remaining changes in the commit are related
      to smoke tests -- the expected generated files
      with enumerations have been adjusted.

Signed-off-by: Patryk Wrobel <[email protected]>
  • Loading branch information
pwrobeldev committed Oct 30, 2024
1 parent 1506145 commit fb2fc62
Show file tree
Hide file tree
Showing 35 changed files with 209 additions and 36 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased
### Bug fixes:
* C++: Added generation of missing export macro for enumerations.
* C++: Fixed generation of getters and setters for accessors attribute -- non-trivial types use references now.
* Added missing generation of conversion functions for lambdas defined in structs for Swift.
* Fixed a bug related to exporting nested types defined in a type annotated as internal.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{!!
!
! Copyright (C) 2016-2020 HERE Europe B.V.
! Copyright (C) 2016-2024 HERE Europe B.V.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
Expand All @@ -20,7 +20,7 @@
!}}
{{#unless external.cpp}}
{{>cpp/CppDocComment}}
enum class {{>cpp/CppAttributesInline}}{{resolveName}} {
enum class {{>cpp/CppExportMacro}}{{>cpp/CppAttributesInline}}{{resolveName}} {
{{#enumerators}}
{{prefixPartial "cpp/CppDocComment" " "}}{{prefixPartial "cpp/CppAttributes" " "}}{{!!
}} {{resolveName}}{{#explicitValue}} = {{resolveName}}{{/explicitValue}}{{#if iter.hasNext}},{{/if}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
// -------------------------------------------------------------------------------------------------
//

//
// -------------------------------------------------------------------------------------------------

#pragma once

#include "gluecodium/ExportGluecodiumCpp.h"
#include <cstdint>

namespace smoke {
enum class [[OnEnumeration]] AttributesEnum {
enum class _GLUECODIUM_CPP_EXPORT [[OnEnumeration]] AttributesEnum {
[[OnEnumerator]]
NOPE
};



}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class _GLUECODIUM_CPP_EXPORT CppRefReturnType {


public:
enum class InternalError {
enum class _GLUECODIUM_CPP_EXPORT InternalError {
FOO,
BAR
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class _GLUECODIUM_CPP_EXPORT Comments {
* This is some very useful enum.
*/
enum class SomeEnum {
enum class _GLUECODIUM_CPP_EXPORT SomeEnum {
/**
* Not quite useful
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class _GLUECODIUM_CPP_EXPORT DeprecationComments {
* This is some very useful enum.
* \deprecated Unfortunately, this enum is deprecated. Use ::smoke::Comments::SomeEnum instead.
*/
enum class SomeEnum {
enum class _GLUECODIUM_CPP_EXPORT SomeEnum {
/**
* Not quite useful
* \deprecated Unfortunately, this item is deprecated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class _GLUECODIUM_CPP_EXPORT DeprecationCommentsOnly {
/**
* \deprecated Unfortunately, this enum is deprecated.
*/
enum class SomeEnum {
enum class _GLUECODIUM_CPP_EXPORT SomeEnum {
/**
* \deprecated Unfortunately, this item is deprecated.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class _GLUECODIUM_CPP_EXPORT ExcludedComments {
* \private
*/
enum class SomeEnum {
enum class _GLUECODIUM_CPP_EXPORT SomeEnum {
/**
* Not quite useful
* \private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class _GLUECODIUM_CPP_EXPORT ExcludedCommentsOnly {
* \private
*/
enum class SomeEnum {
enum class _GLUECODIUM_CPP_EXPORT SomeEnum {
/**
* \private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class _GLUECODIUM_CPP_EXPORT PlatformComments {
* An error code when something goes wrong.
*/
enum class SomeEnum {
enum class _GLUECODIUM_CPP_EXPORT SomeEnum {
USELESS,
USEFUL
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
// -------------------------------------------------------------------------------------------------
//

//
// -------------------------------------------------------------------------------------------------

#pragma once

#include "gluecodium/ExportGluecodiumCpp.h"
#include <cstdint>
#include <string>

namespace smoke {
struct _GLUECODIUM_CPP_EXPORT Constants {
static const bool BOOL_CONSTANT;

static const int32_t INT_CONSTANT;

static const uint32_t UINT_CONSTANT;

static const float FLOAT_CONSTANT;

static const double DOUBLE_CONSTANT;

static const ::std::string STRING_CONSTANT;
enum class StateEnum {

enum class _GLUECODIUM_CPP_EXPORT StateEnum {
OFF,
ON
};


static const ::smoke::Constants::StateEnum ENUM_CONSTANT;

};


}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class _GLUECODIUM_CPP_EXPORT Constructors {


public:
enum class ErrorEnum {
enum class _GLUECODIUM_CPP_EXPORT ErrorEnum {
NONE,
CRASHED
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,54 @@
// -------------------------------------------------------------------------------------------------
//

//
// -------------------------------------------------------------------------------------------------

#pragma once

#include "gluecodium/ExportGluecodiumCpp.h"
#include "gluecodium/UnorderedMapHash.h"
#include "gluecodium/VectorHash.h"
#include <cstdint>
#include <string>
#include <unordered_map>
#include <vector>

namespace smoke {
struct _GLUECODIUM_CPP_EXPORT DeclarationOrder {
struct _GLUECODIUM_CPP_EXPORT NestedStruct {
::std::string some_field;

NestedStruct( );
explicit NestedStruct( ::std::string some_field );

};
enum class SomeEnum {

enum class _GLUECODIUM_CPP_EXPORT SomeEnum {
FOO,
BAR = 7
};


using SomeTypeDef = int32_t;

using NestedStructArray = ::std::vector< ::smoke::DeclarationOrder::NestedStruct >;

using ErrorCodeToMessageMap = ::std::unordered_map< int32_t, ::smoke::DeclarationOrder::NestedStructArray >;

struct _GLUECODIUM_CPP_EXPORT MainStruct {
::smoke::DeclarationOrder::NestedStruct struct_field;
::smoke::DeclarationOrder::SomeTypeDef type_def_field;
::smoke::DeclarationOrder::NestedStructArray struct_array_field;
::smoke::DeclarationOrder::ErrorCodeToMessageMap map_field;
::smoke::DeclarationOrder::SomeEnum enum_field;

MainStruct( );
MainStruct( ::smoke::DeclarationOrder::NestedStruct struct_field, ::smoke::DeclarationOrder::SomeTypeDef type_def_field, ::smoke::DeclarationOrder::NestedStructArray struct_array_field, ::smoke::DeclarationOrder::ErrorCodeToMessageMap map_field, ::smoke::DeclarationOrder::SomeEnum enum_field );

};

};


}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class _GLUECODIUM_CPP_EXPORT OrderInClass {


public:
enum class SomeEnum {
enum class _GLUECODIUM_CPP_EXPORT SomeEnum {
FOO,
BAR = 7
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
// -------------------------------------------------------------------------------------------------
//

//
// -------------------------------------------------------------------------------------------------

#pragma once

#include "gluecodium/ExportGluecodiumCpp.h"
#include <cstdint>
#include <string>

namespace smoke {
struct _GLUECODIUM_CPP_EXPORT OrderInStruct {
struct _GLUECODIUM_CPP_EXPORT NestedStruct {
::std::string some_field;

NestedStruct( );
explicit NestedStruct( ::std::string some_field );

};
enum class SomeEnum {

enum class _GLUECODIUM_CPP_EXPORT SomeEnum {
FOO,
BAR = 7
};


::smoke::OrderInStruct::NestedStruct struct_field;
::smoke::OrderInStruct::SomeEnum enum_field;

OrderInStruct( );
OrderInStruct( ::smoke::OrderInStruct::NestedStruct struct_field, ::smoke::OrderInStruct::SomeEnum enum_field );

};


}
Original file line number Diff line number Diff line change
@@ -1,25 +1,39 @@
// -------------------------------------------------------------------------------------------------
//

//
// -------------------------------------------------------------------------------------------------

#pragma once

#include "gluecodium/ExportGluecodiumCpp.h"
#include <cstdint>
#include <string>

namespace smoke {
struct _GLUECODIUM_CPP_EXPORT OrderInStructWithFunctions {
struct _GLUECODIUM_CPP_EXPORT NestedStruct {
::std::string some_field;

NestedStruct( );
explicit NestedStruct( ::std::string some_field );

};
enum class SomeEnum {

enum class _GLUECODIUM_CPP_EXPORT SomeEnum {
FOO,
BAR = 7
};


::std::string some_field;

OrderInStructWithFunctions( );
explicit OrderInStructWithFunctions( ::std::string some_field );

::smoke::OrderInStructWithFunctions::SomeEnum do_stuff( const ::smoke::OrderInStructWithFunctions::NestedStruct& struct_foo ) const;

};


}
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
// -------------------------------------------------------------------------------------------------
//

//
// -------------------------------------------------------------------------------------------------

#pragma once

#include "gluecodium/ExportGluecodiumCpp.h"
#include <cstdint>
#include <system_error>

namespace smoke {
enum class EnumWithAlias {
enum class _GLUECODIUM_CPP_EXPORT EnumWithAlias {
ONE = 2,
TWO,
THREE,
FIRST = ::smoke::EnumWithAlias::ONE,
THE_BEST = ::smoke::EnumWithAlias::FIRST
};



_GLUECODIUM_CPP_EXPORT ::std::error_code make_error_code( ::smoke::EnumWithAlias value ) noexcept;
}

namespace std
{
template <>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
// -------------------------------------------------------------------------------------------------
//

//
// -------------------------------------------------------------------------------------------------

#pragma once

#include "gluecodium/ExportGluecodiumCpp.h"
#include <cstdint>
#include <string_view>

namespace smoke {
enum class EnumWithToStringHelper {
enum class _GLUECODIUM_CPP_EXPORT EnumWithToStringHelper {
FIRST,
SECOND
};

std::string_view
_GLUECODIUM_CPP_EXPORT to_string(EnumWithToStringHelper enumeration);


}
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class _GLUECODIUM_CPP_EXPORT Enums {


public:
enum class SimpleEnum {
enum class _GLUECODIUM_CPP_EXPORT SimpleEnum {
FIRST,
SECOND
};


enum class InternalErrorCode {
enum class _GLUECODIUM_CPP_EXPORT InternalErrorCode {
ERROR_NONE,
ERROR_FATAL = 999
};
Expand Down
Loading

0 comments on commit fb2fc62

Please sign in to comment.