Skip to content

Commit ac9b1e4

Browse files
authored
add test for #78 (#86)
- add enum type to all_datatypes integration test - remove cppcli namespace conversion that replaces . with :: inline.
1 parent 4b2ae74 commit ac9b1e4

32 files changed

+293
-39
lines changed

src/it/resources/all_datatypes.djinni

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
enum_data = enum {
2+
a;
3+
b;
4+
}
5+
16
all_datatypes = record {
27
booleanData: bool;
38
integer8Data: i8;
@@ -13,4 +18,5 @@ all_datatypes = record {
1318
setData: set<bool>;
1419
mapData: map<i8, bool>;
1520
optionalData: optional<bool>;
21+
enum_data: enum_data;
1622
}

src/it/resources/expected/all_datatypes/cpp-headers/all_datatypes.hpp

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

44
#pragma once
55

6+
#include "enum_data.hpp"
67
#include <chrono>
78
#include <cstdint>
89
#include <optional>
@@ -27,6 +28,7 @@ struct AllDatatypes final {
2728
std::unordered_set<bool> setData;
2829
std::unordered_map<int8_t, bool> mapData;
2930
std::optional<bool> optionalData;
31+
EnumData enum_data;
3032

3133
AllDatatypes(bool booleanData_,
3234
int8_t integer8Data_,
@@ -41,7 +43,8 @@ struct AllDatatypes final {
4143
std::vector<bool> listData_,
4244
std::unordered_set<bool> setData_,
4345
std::unordered_map<int8_t, bool> mapData_,
44-
std::optional<bool> optionalData_)
46+
std::optional<bool> optionalData_,
47+
EnumData enum_data_)
4548
: booleanData(std::move(booleanData_))
4649
, integer8Data(std::move(integer8Data_))
4750
, integer16Data(std::move(integer16Data_))
@@ -56,6 +59,7 @@ struct AllDatatypes final {
5659
, setData(std::move(setData_))
5760
, mapData(std::move(mapData_))
5861
, optionalData(std::move(optionalData_))
62+
, enum_data(std::move(enum_data_))
5963
{}
6064

6165
AllDatatypes()
@@ -73,5 +77,6 @@ struct AllDatatypes final {
7377
, setData()
7478
, mapData()
7579
, optionalData()
80+
, enum_data()
7681
{}
7782
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// AUTOGENERATED FILE - DO NOT MODIFY!
2+
// This file was generated by Djinni from all_datatypes.djinni
3+
4+
#pragma once
5+
6+
#include <functional>
7+
8+
enum class EnumData : int {
9+
A,
10+
B,
11+
};
12+
13+
namespace std {
14+
15+
template <>
16+
struct hash<::EnumData> {
17+
size_t operator()(::EnumData type) const {
18+
return std::hash<int>()(static_cast<int>(type));
19+
}
20+
};
21+
22+
} // namespace std

src/it/resources/expected/all_datatypes/cppcli/AllDatatypes.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ AllDatatypes::AllDatatypes(bool booleanData,
1818
System::Collections::Generic::List<bool>^ listData,
1919
System::Collections::Generic::HashSet<bool>^ setData,
2020
System::Collections::Generic::Dictionary<char, bool>^ mapData,
21-
System::Nullable<bool> optionalData)
21+
System::Nullable<bool> optionalData,
22+
::EnumData enumData)
2223
: _booleanData(booleanData)
2324
, _integer8Data(integer8Data)
2425
, _integer16Data(integer16Data)
@@ -33,6 +34,7 @@ AllDatatypes::AllDatatypes(bool booleanData,
3334
, _setData(setData)
3435
, _mapData(mapData)
3536
, _optionalData(optionalData)
37+
, _enumData(enumData)
3638
{}
3739

3840
bool AllDatatypes::BooleanData::get()
@@ -105,9 +107,14 @@ System::Nullable<bool> AllDatatypes::OptionalData::get()
105107
return _optionalData;
106108
}
107109

110+
EnumData AllDatatypes::EnumData::get()
111+
{
112+
return _enumData;
113+
}
114+
108115
System::String^ AllDatatypes::ToString()
109116
{
110-
return System::String::Format("AllDatatypes {{BooleanData{0}, Integer8Data{1}, Integer16Data{2}, Integer32Data{3}, Integer64Data{4}, Float32Data{5}, Float64Data{6}, StringData{7}, BinaryData{8}, DateData{9}, ListData{10}, SetData{11}, MapData{12}, OptionalData{13}}}",
117+
return System::String::Format("AllDatatypes {{BooleanData{0}, Integer8Data{1}, Integer16Data{2}, Integer32Data{3}, Integer64Data{4}, Float32Data{5}, Float64Data{6}, StringData{7}, BinaryData{8}, DateData{9}, ListData{10}, SetData{11}, MapData{12}, OptionalData{13}, EnumData{14}}}",
111118
BooleanData,
112119
Integer8Data,
113120
Integer16Data,
@@ -121,7 +128,8 @@ System::String^ AllDatatypes::ToString()
121128
ListData,
122129
SetData,
123130
MapData,
124-
OptionalData);
131+
OptionalData,
132+
EnumData);
125133
}
126134

127135
AllDatatypes::CppType AllDatatypes::ToCpp(AllDatatypes::CsType cs)
@@ -140,7 +148,8 @@ AllDatatypes::CppType AllDatatypes::ToCpp(AllDatatypes::CsType cs)
140148
::djinni::List<::djinni::Bool>::ToCpp(cs->ListData),
141149
::djinni::Set<::djinni::Bool>::ToCpp(cs->SetData),
142150
::djinni::Map<::djinni::I8, ::djinni::Bool>::ToCpp(cs->MapData),
143-
::djinni::Optional<std::optional, ::djinni::Bool>::ToCpp(cs->OptionalData)};
151+
::djinni::Optional<std::optional, ::djinni::Bool>::ToCpp(cs->OptionalData),
152+
::djinni::Enum<::EnumData, ::EnumData>::ToCpp(cs->EnumData)};
144153
}
145154

146155
AllDatatypes::CsType AllDatatypes::FromCpp(const AllDatatypes::CppType& cpp)
@@ -158,5 +167,6 @@ AllDatatypes::CsType AllDatatypes::FromCpp(const AllDatatypes::CppType& cpp)
158167
::djinni::List<::djinni::Bool>::FromCpp(cpp.listData),
159168
::djinni::Set<::djinni::Bool>::FromCpp(cpp.setData),
160169
::djinni::Map<::djinni::I8, ::djinni::Bool>::FromCpp(cpp.mapData),
161-
::djinni::Optional<std::optional, ::djinni::Bool>::FromCpp(cpp.optionalData));
170+
::djinni::Optional<std::optional, ::djinni::Bool>::FromCpp(cpp.optionalData),
171+
::djinni::Enum<::EnumData, ::EnumData>::FromCpp(cpp.enum_data));
162172
}

src/it/resources/expected/all_datatypes/cppcli/AllDatatypes.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#pragma once
55

66
#include "../cpp-headers/all_datatypes.hpp"
7+
#include "EnumData.hpp"
78

89
[System::Serializable]
910
public ref class AllDatatypes {
@@ -79,6 +80,11 @@ public ref class AllDatatypes {
7980
System::Nullable<bool> get();
8081
}
8182

83+
property ::EnumData EnumData
84+
{
85+
::EnumData get();
86+
}
87+
8288
AllDatatypes(bool booleanData,
8389
char integer8Data,
8490
short integer16Data,
@@ -92,7 +98,8 @@ public ref class AllDatatypes {
9298
System::Collections::Generic::List<bool>^ listData,
9399
System::Collections::Generic::HashSet<bool>^ setData,
94100
System::Collections::Generic::Dictionary<char, bool>^ mapData,
95-
System::Nullable<bool> optionalData);
101+
System::Nullable<bool> optionalData,
102+
::EnumData enumData);
96103

97104
System::String^ ToString() override;
98105

@@ -118,4 +125,5 @@ public ref class AllDatatypes {
118125
System::Collections::Generic::HashSet<bool>^ _setData;
119126
System::Collections::Generic::Dictionary<char, bool>^ _mapData;
120127
System::Nullable<bool> _optionalData;
128+
::EnumData _enumData;
121129
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// AUTOGENERATED FILE - DO NOT MODIFY!
2+
// This file was generated by Djinni from all_datatypes.djinni
3+
4+
#include "EnumData.hpp" // my header
5+
#include "../cpp-headers/enum_data.hpp"
6+
7+
// Empty... making sure the symbols get included in the build.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// AUTOGENERATED FILE - DO NOT MODIFY!
2+
// This file was generated by Djinni from all_datatypes.djinni
3+
4+
#pragma once
5+
6+
#include "../cpp-headers/enum_data.hpp"
7+
8+
public enum class EnumData {
9+
A,
10+
B,
11+
};

src/it/resources/expected/all_datatypes/cwrapper-headers/dh__all_datatypes.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ void all_datatypes_add_callback_get_all_datatypes_f11(struct DjinniObjectHandle
2424
void all_datatypes_add_callback_get_all_datatypes_f12(struct DjinniObjectHandle *( * ptr)(struct DjinniRecordHandle *));
2525
void all_datatypes_add_callback_get_all_datatypes_f13(struct DjinniObjectHandle *( * ptr)(struct DjinniRecordHandle *));
2626
void all_datatypes_add_callback_get_all_datatypes_f14(struct DjinniBoxedBool *( * ptr)(struct DjinniRecordHandle *));
27-
void all_datatypes_add_callback_create_all_datatypes(struct DjinniRecordHandle *( * ptr)(bool, int8_t, int16_t, int32_t, int64_t, float, double, struct DjinniString *, struct DjinniBinary *, uint64_t, struct DjinniObjectHandle *, struct DjinniObjectHandle *, struct DjinniObjectHandle *, struct DjinniBoxedBool *));
27+
void all_datatypes_add_callback_get_all_datatypes_f15(int( * ptr)(struct DjinniRecordHandle *));
28+
void all_datatypes_add_callback_create_all_datatypes(struct DjinniRecordHandle *( * ptr)(bool, int8_t, int16_t, int32_t, int64_t, float, double, struct DjinniString *, struct DjinniBinary *, uint64_t, struct DjinniObjectHandle *, struct DjinniObjectHandle *, struct DjinniObjectHandle *, struct DjinniBoxedBool *, int));
2829
void all_datatypes_add_callback___delete(void( * ptr)(struct DjinniRecordHandle *));
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// AUTOGENERATED FILE - DO NOT MODIFY!
2+
// This file was generated by Djinni from all_datatypes.djinni
3+
4+
#pragma once // python_cdef_ignore
5+
#include <stdbool.h> // python_cdef_ignore
6+

src/it/resources/expected/all_datatypes/cwrapper/dh__all_datatypes.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
#include "../cpp-headers/all_datatypes.hpp"
88

99
#include "dh__all_datatypes.hpp"
10+
#include "dh__enum_data.hpp"
1011
#include "dh__list_bool.hpp"
1112
#include "dh__map_int8_t_bool.hpp"
1213
#include "dh__set_bool.hpp"
14+
#include "enum_data.hpp"
1315
#include <chrono>
1416
#include <optional>
1517
#include <vector>
@@ -109,9 +111,15 @@ void all_datatypes_add_callback_get_all_datatypes_f14(DjinniBoxedBool *( * ptr)(
109111
s_callback_all_datatypes_get_all_datatypes_f14 = ptr;
110112
}
111113

112-
static DjinniRecordHandle * ( * s_callback_all_datatypes_create_all_datatypes)(bool, int8_t, int16_t, int32_t, int64_t, float, double, DjinniString *, DjinniBinary *, uint64_t, DjinniObjectHandle *, DjinniObjectHandle *, DjinniObjectHandle *, DjinniBoxedBool *);
114+
static int ( * s_callback_all_datatypes_get_all_datatypes_f15)(DjinniRecordHandle *);
113115

114-
void all_datatypes_add_callback_create_all_datatypes(DjinniRecordHandle *( * ptr)(bool, int8_t, int16_t, int32_t, int64_t, float, double, DjinniString *, DjinniBinary *, uint64_t, DjinniObjectHandle *, DjinniObjectHandle *, DjinniObjectHandle *, DjinniBoxedBool *)) {
116+
void all_datatypes_add_callback_get_all_datatypes_f15(int( * ptr)(DjinniRecordHandle *)) {
117+
s_callback_all_datatypes_get_all_datatypes_f15 = ptr;
118+
}
119+
120+
static DjinniRecordHandle * ( * s_callback_all_datatypes_create_all_datatypes)(bool, int8_t, int16_t, int32_t, int64_t, float, double, DjinniString *, DjinniBinary *, uint64_t, DjinniObjectHandle *, DjinniObjectHandle *, DjinniObjectHandle *, DjinniBoxedBool *, int);
121+
122+
void all_datatypes_add_callback_create_all_datatypes(DjinniRecordHandle *( * ptr)(bool, int8_t, int16_t, int32_t, int64_t, float, double, DjinniString *, DjinniBinary *, uint64_t, DjinniObjectHandle *, DjinniObjectHandle *, DjinniObjectHandle *, DjinniBoxedBool *, int)) {
115123
s_callback_all_datatypes_create_all_datatypes = ptr;
116124
}
117125

@@ -138,7 +146,8 @@ djinni::Handle<DjinniRecordHandle> DjinniAllDatatypes::fromCpp(const ::AllDataty
138146
_field_listData.release(),
139147
_field_setData.release(),
140148
_field_mapData.release(),
141-
_field_optionalData.release()),
149+
_field_optionalData.release(),
150+
int32_from_enum_enum_data(dr.enum_data)),
142151
all_datatypes___delete);
143152
return _aux;
144153
}
@@ -165,7 +174,8 @@ ::AllDatatypes DjinniAllDatatypes::toCpp(djinni::Handle<DjinniRecordHandle> dh)
165174
DjinniListBool::toCpp(std::move( _field_listData)),
166175
DjinniSetBool::toCpp(std::move( _field_setData)),
167176
DjinniMapInt8TBool::toCpp(std::move( _field_mapData)),
168-
DjinniBoxedBool::toCpp(std::move( _field_optionalData)));
177+
DjinniBoxedBool::toCpp(std::move( _field_optionalData)),
178+
static_cast<::EnumData>(s_callback_all_datatypes_get_all_datatypes_f15(dh.get())));
169179
return _aux;
170180
}
171181

0 commit comments

Comments
 (0)