Skip to content

Commit 3f1a23d

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent a6a4d55 commit 3f1a23d

25 files changed

Lines changed: 825 additions & 623 deletions

src/binding/julia/Access.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
#include "defs.hpp"
44

5-
void define_julia_Access(jlcxx::Module &mod) {
6-
mod.add_bits<Access>("Access", jlcxx::julia_type("CppEnum"));
7-
jlcxx::stl::apply_stl<Access>(mod);
5+
void define_julia_Access(jlcxx::Module &mod)
6+
{
7+
mod.add_bits<Access>("Access", jlcxx::julia_type("CppEnum"));
8+
jlcxx::stl::apply_stl<Access>(mod);
89

9-
mod.set_const("ACCESS_READ_ONLY", Access::READ_ONLY);
10-
mod.set_const("ACCESS_READ_WRITE", Access::READ_WRITE);
11-
mod.set_const("ACCESS_CREATE", Access::CREATE);
10+
mod.set_const("ACCESS_READ_ONLY", Access::READ_ONLY);
11+
mod.set_const("ACCESS_READ_WRITE", Access::READ_WRITE);
12+
mod.set_const("ACCESS_CREATE", Access::CREATE);
1213
}

src/binding/julia/Attributable.cpp

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,26 @@
22

33
#include "defs.hpp"
44

5-
void define_julia_Attributable(jlcxx::Module &mod) {
6-
auto type = mod.add_type<Attributable>("CXX_Attributable");
5+
void define_julia_Attributable(jlcxx::Module &mod)
6+
{
7+
auto type = mod.add_type<Attributable>("CXX_Attributable");
78

89
#define USE_TYPE(NAME, ENUM, TYPE) \
9-
type.method("cxx_set_attribute_" NAME "!", &Attributable::setAttribute<TYPE>);
10-
{ FORALL_OPENPMD_TYPES(USE_TYPE) }
10+
type.method( \
11+
"cxx_set_attribute_" NAME "!", &Attributable::setAttribute<TYPE>);
12+
{
13+
FORALL_OPENPMD_TYPES(USE_TYPE)
14+
}
1115
#undef USE_TYPE
1216

13-
type.method("cxx_get_attribute", &Attributable::getAttribute);
14-
type.method("cxx_delete_attribute!", &Attributable::deleteAttribute);
15-
type.method("cxx_attributes", &Attributable::attributes);
16-
type.method("cxx_num_attributes", &Attributable::numAttributes);
17-
type.method("cxx_contains_attribute", &Attributable::containsAttribute);
18-
type.method("cxx_comment", &Attributable::comment);
19-
type.method("cxx_set_comment!", &Attributable::setComment);
20-
type.method("cxx_series_flush", static_cast<void (Attributable::*)()>(
21-
&Attributable::seriesFlush));
17+
type.method("cxx_get_attribute", &Attributable::getAttribute);
18+
type.method("cxx_delete_attribute!", &Attributable::deleteAttribute);
19+
type.method("cxx_attributes", &Attributable::attributes);
20+
type.method("cxx_num_attributes", &Attributable::numAttributes);
21+
type.method("cxx_contains_attribute", &Attributable::containsAttribute);
22+
type.method("cxx_comment", &Attributable::comment);
23+
type.method("cxx_set_comment!", &Attributable::setComment);
24+
type.method(
25+
"cxx_series_flush",
26+
static_cast<void (Attributable::*)()>(&Attributable::seriesFlush));
2227
}

src/binding/julia/Attribute.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22

33
#include "defs.hpp"
44

5-
void define_julia_Attribute(jlcxx::Module &mod) {
6-
auto type = mod.add_type<Attribute>("CXX_Attribute");
5+
void define_julia_Attribute(jlcxx::Module &mod)
6+
{
7+
auto type = mod.add_type<Attribute>("CXX_Attribute");
78

8-
type.method("cxx_dtype", [](const Attribute &attr) { return attr.dtype; });
9+
type.method("cxx_dtype", [](const Attribute &attr) { return attr.dtype; });
910

1011
#define USE_TYPE(NAME, ENUM, TYPE) \
11-
type.method("cxx_get_" NAME, &Attribute::get<TYPE>);
12-
{ FORALL_OPENPMD_TYPES(USE_TYPE) }
12+
type.method("cxx_get_" NAME, &Attribute::get<TYPE>);
13+
{
14+
FORALL_OPENPMD_TYPES(USE_TYPE)
15+
}
1316
#undef USE_TYPE
1417
}

src/binding/julia/BaseRecordComponent.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,23 @@
33
#include "defs.hpp"
44

55
// Define supertype relationships
6-
namespace jlcxx {
7-
template <> struct SuperType<BaseRecordComponent> {
8-
typedef Attributable type;
6+
namespace jlcxx
7+
{
8+
template <>
9+
struct SuperType<BaseRecordComponent>
10+
{
11+
typedef Attributable type;
912
};
1013
} // namespace jlcxx
1114

12-
void define_julia_BaseRecordComponent(jlcxx::Module &mod) {
13-
auto type = mod.add_type<BaseRecordComponent>(
14-
"CXX_BaseRecordComponent", jlcxx::julia_base_type<Attributable>());
15+
void define_julia_BaseRecordComponent(jlcxx::Module &mod)
16+
{
17+
auto type = mod.add_type<BaseRecordComponent>(
18+
"CXX_BaseRecordComponent", jlcxx::julia_base_type<Attributable>());
1519

16-
type.method("cxx_unit_SI", &BaseRecordComponent::unitSI);
17-
type.method("cxx_reset_datatype!", &BaseRecordComponent::resetDatatype);
18-
type.method("cxx_get_datatype", &BaseRecordComponent::getDatatype);
19-
type.method("cxx_isconstant", &BaseRecordComponent::constant);
20-
type.method("cxx_available_chunks", &BaseRecordComponent::availableChunks);
20+
type.method("cxx_unit_SI", &BaseRecordComponent::unitSI);
21+
type.method("cxx_reset_datatype!", &BaseRecordComponent::resetDatatype);
22+
type.method("cxx_get_datatype", &BaseRecordComponent::getDatatype);
23+
type.method("cxx_isconstant", &BaseRecordComponent::constant);
24+
type.method("cxx_available_chunks", &BaseRecordComponent::availableChunks);
2125
}

src/binding/julia/ChunkInfo.cpp

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,29 @@
33
#include "defs.hpp"
44

55
// Define supertype relationships
6-
namespace jlcxx {
7-
template <> struct SuperType<WrittenChunkInfo> { typedef ChunkInfo type; };
6+
namespace jlcxx
7+
{
8+
template <>
9+
struct SuperType<WrittenChunkInfo>
10+
{
11+
typedef ChunkInfo type;
12+
};
813
} // namespace jlcxx
914

10-
void define_julia_ChunkInfo(jlcxx::Module &mod) {
11-
auto chunkInfo = mod.add_type<ChunkInfo>("CXX_ChunkInfo");
12-
chunkInfo.constructor<>();
13-
chunkInfo.constructor<Offset, Extent>();
14-
chunkInfo.method("cxx_offset", [](const ChunkInfo &chunkInfo_) {
15-
return chunkInfo_.offset;
16-
});
17-
chunkInfo.method("cxx_extent", [](const ChunkInfo &chunkInfo_) {
18-
return chunkInfo_.extent;
19-
});
15+
void define_julia_ChunkInfo(jlcxx::Module &mod)
16+
{
17+
auto chunkInfo = mod.add_type<ChunkInfo>("CXX_ChunkInfo");
18+
chunkInfo.constructor<>();
19+
chunkInfo.constructor<Offset, Extent>();
20+
chunkInfo.method("cxx_offset", [](const ChunkInfo &chunkInfo_) {
21+
return chunkInfo_.offset;
22+
});
23+
chunkInfo.method("cxx_extent", [](const ChunkInfo &chunkInfo_) {
24+
return chunkInfo_.extent;
25+
});
2026

21-
auto writtenChunkInfo = mod.add_type<WrittenChunkInfo>(
22-
"CXX_WrittenChunkInfo", jlcxx::julia_base_type<ChunkInfo>());
23-
writtenChunkInfo.constructor<>();
24-
writtenChunkInfo.constructor<Offset, Extent>();
27+
auto writtenChunkInfo = mod.add_type<WrittenChunkInfo>(
28+
"CXX_WrittenChunkInfo", jlcxx::julia_base_type<ChunkInfo>());
29+
writtenChunkInfo.constructor<>();
30+
writtenChunkInfo.constructor<Offset, Extent>();
2531
}

src/binding/julia/Container.hpp

Lines changed: 65 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99
#include <type_traits>
1010

1111
// Define supertype relationships
12-
namespace jlcxx {
13-
template <typename T, typename K> struct SuperType<Container<T, K>> {
14-
typedef Attributable type;
12+
namespace jlcxx
13+
{
14+
template <typename T, typename K>
15+
struct SuperType<Container<T, K>>
16+
{
17+
typedef Attributable type;
1518
};
1619
} // namespace jlcxx
1720

@@ -22,62 +25,69 @@ typedef jlcxx::TypeWrapper<
2225
extern std::unique_ptr<julia_Container_type_t> julia_Container_type;
2326

2427
template <typename Eltype, typename Keytype>
25-
void define_julia_Container(jlcxx::Module &mod) {
26-
if (!julia_Container_type)
27-
julia_Container_type = std::make_unique<julia_Container_type_t>(
28-
mod.add_type<jlcxx::Parametric<jlcxx::TypeVar<1>, jlcxx::TypeVar<2>>>(
29-
"CXX_Container", jlcxx::julia_base_type<Attributable>()));
28+
void define_julia_Container(jlcxx::Module &mod)
29+
{
30+
if (!julia_Container_type)
31+
julia_Container_type = std::make_unique<julia_Container_type_t>(
32+
mod.add_type<
33+
jlcxx::Parametric<jlcxx::TypeVar<1>, jlcxx::TypeVar<2>>>(
34+
"CXX_Container", jlcxx::julia_base_type<Attributable>()));
3035

31-
julia_Container_type->apply<Container<Eltype, Keytype>>([](auto type) {
32-
using ContainerT = typename decltype(type)::type;
33-
using key_type = typename ContainerT::key_type;
34-
using mapped_type = typename ContainerT::mapped_type;
35-
using size_type = typename ContainerT::size_type;
36-
static_assert(std::is_same_v<Eltype, mapped_type>);
37-
static_assert(std::is_same_v<Keytype, key_type>);
36+
julia_Container_type->apply<Container<Eltype, Keytype>>([](auto type) {
37+
using ContainerT = typename decltype(type)::type;
38+
using key_type = typename ContainerT::key_type;
39+
using mapped_type = typename ContainerT::mapped_type;
40+
using size_type = typename ContainerT::size_type;
41+
static_assert(std::is_same_v<Eltype, mapped_type>);
42+
static_assert(std::is_same_v<Keytype, key_type>);
3843

39-
type.template constructor<const ContainerT &>();
44+
type.template constructor<const ContainerT &>();
4045

41-
type.method("cxx_empty", &ContainerT::empty);
42-
type.method("cxx_length", &ContainerT::size);
43-
type.method("cxx_empty!", &ContainerT::clear);
44-
// type.method("cxx_getindex",
45-
// static_cast<mapped_type &(ContainerT::*)(const key_type &)>(
46-
// &ContainerT::at));
47-
type.method("cxx_getindex",
48-
[](ContainerT &cont, const key_type &key) -> mapped_type & {
49-
return cont[key];
50-
});
51-
type.method("cxx_setindex!",
52-
[](ContainerT &cont, const mapped_type &value,
53-
const key_type &key) { return cont[key] = value; });
54-
type.method("cxx_count", &ContainerT::count);
55-
type.method("cxx_contains", &ContainerT::contains);
56-
type.method("cxx_delete!",
57-
static_cast<size_type (ContainerT::*)(const key_type &)>(
58-
&ContainerT::erase));
59-
type.method("cxx_keys", [](const ContainerT &cont) {
60-
std::vector<key_type> res;
61-
res.reserve(cont.size());
62-
for (auto iter = cont.begin(); iter != cont.end(); ++iter)
63-
res.push_back(iter->first);
64-
return res;
46+
type.method("cxx_empty", &ContainerT::empty);
47+
type.method("cxx_length", &ContainerT::size);
48+
type.method("cxx_empty!", &ContainerT::clear);
49+
// type.method("cxx_getindex",
50+
// static_cast<mapped_type &(ContainerT::*)(const key_type
51+
// &)>(
52+
// &ContainerT::at));
53+
type.method(
54+
"cxx_getindex",
55+
[](ContainerT &cont, const key_type &key) -> mapped_type & {
56+
return cont[key];
57+
});
58+
type.method(
59+
"cxx_setindex!",
60+
[](ContainerT &cont,
61+
const mapped_type &value,
62+
const key_type &key) { return cont[key] = value; });
63+
type.method("cxx_count", &ContainerT::count);
64+
type.method("cxx_contains", &ContainerT::contains);
65+
type.method(
66+
"cxx_delete!",
67+
static_cast<size_type (ContainerT::*)(const key_type &)>(
68+
&ContainerT::erase));
69+
type.method("cxx_keys", [](const ContainerT &cont) {
70+
std::vector<key_type> res;
71+
res.reserve(cont.size());
72+
for (auto iter = cont.begin(); iter != cont.end(); ++iter)
73+
res.push_back(iter->first);
74+
return res;
75+
});
76+
// type.method("cxx_values", [](const ContainerT &cont) {
77+
// std::vector<mapped_type *> res;
78+
// res.reserve(cont.size());
79+
// for (auto iter = cont.begin(); iter != cont.end(); ++iter)
80+
// res.push_back(&iter->second);
81+
// return res;
82+
// });
83+
// type.method("cxx_collect", [](const ContainerT &cont) {
84+
// std::vector<std::pair<key_type, mapped_type *>> res;
85+
// res.reserve(cont.size());
86+
// for (auto iter = cont.begin(); iter != cont.end(); ++iter)
87+
// res.emplace_back(iter->first, &iter->second);
88+
// return res;
89+
// });
6590
});
66-
// type.method("cxx_values", [](const ContainerT &cont) {
67-
// std::vector<mapped_type *> res;
68-
// res.reserve(cont.size());
69-
// for (auto iter = cont.begin(); iter != cont.end(); ++iter)
70-
// res.push_back(&iter->second);
71-
// return res;
72-
// });
73-
// type.method("cxx_collect", [](const ContainerT &cont) {
74-
// std::vector<std::pair<key_type, mapped_type *>> res;
75-
// res.reserve(cont.size());
76-
// for (auto iter = cont.begin(); iter != cont.end(); ++iter)
77-
// res.emplace_back(iter->first, &iter->second);
78-
// return res;
79-
// });
80-
});
8191
}
8292

8393
#endif // #ifndef CONTAINER_HPP

src/binding/julia/Dataset.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22

33
#include "defs.hpp"
44

5-
void define_julia_Dataset(jlcxx::Module &mod) {
6-
auto type = mod.add_type<Dataset>("Dataset");
5+
void define_julia_Dataset(jlcxx::Module &mod)
6+
{
7+
auto type = mod.add_type<Dataset>("Dataset");
78

8-
type.constructor<Datatype, Extent>();
9-
type.constructor<Datatype, Extent, const std::string &>();
10-
type.constructor<Extent>();
9+
type.constructor<Datatype, Extent>();
10+
type.constructor<Datatype, Extent, const std::string &>();
11+
type.constructor<Extent>();
1112

12-
type.method("cxx_extend!", &Dataset::extend);
13-
type.method("cxx_extent", [](const Dataset &d) { return d.extent; });
14-
type.method("cxx_dtype", [](const Dataset &d) { return d.dtype; });
15-
type.method("cxx_rank", [](const Dataset &d) { return d.rank; });
16-
type.method("options", [](const Dataset &d) { return d.options; });
13+
type.method("cxx_extend!", &Dataset::extend);
14+
type.method("cxx_extent", [](const Dataset &d) { return d.extent; });
15+
type.method("cxx_dtype", [](const Dataset &d) { return d.dtype; });
16+
type.method("cxx_rank", [](const Dataset &d) { return d.rank; });
17+
type.method("options", [](const Dataset &d) { return d.options; });
1718
}

src/binding/julia/Datatype.cpp

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,38 @@
22

33
#include "defs.hpp"
44

5-
void define_julia_Datatype(jlcxx::Module &mod) {
6-
mod.add_bits<Datatype>("Datatype", jlcxx::julia_type("CppEnum"));
7-
jlcxx::stl::apply_stl<Datatype>(mod);
5+
void define_julia_Datatype(jlcxx::Module &mod)
6+
{
7+
mod.add_bits<Datatype>("Datatype", jlcxx::julia_type("CppEnum"));
8+
jlcxx::stl::apply_stl<Datatype>(mod);
89

910
#define USE_TYPE(NAME, ENUM, TYPE) mod.set_const(NAME, ENUM);
10-
{ FORALL_OPENPMD_TYPES(USE_TYPE) }
11+
{
12+
FORALL_OPENPMD_TYPES(USE_TYPE)
13+
}
1114
#undef USE_TYPE
12-
mod.set_const("UNDEFINED", Datatype::UNDEFINED);
15+
mod.set_const("UNDEFINED", Datatype::UNDEFINED);
1316

14-
mod.set_const("openPMD_datatypes", openPMD_Datatypes);
15-
// mod.method("determine_datatype", determineDatatype);
16-
mod.method("cxx_to_bytes", toBytes);
17-
mod.method("cxx_to_bits", toBits);
18-
mod.method("cxx_is_vector", isVector);
19-
mod.method("cxx_is_floating_point", (bool (*)(Datatype))isFloatingPoint);
20-
mod.method("cxx_is_complex_floating_point",
21-
static_cast<bool (*)(Datatype)>(isComplexFloatingPoint));
22-
mod.method("cxx_is_integer", (std::tuple<bool, bool>(*)(Datatype))isInteger);
23-
// isSameFloatingPoint
24-
// isSameComplexFloatingPoint
25-
// isSameInteger
26-
mod.method("cxx_is_same", isSame);
27-
mod.method("cxx_basic_datatype", basicDatatype);
28-
mod.method("cxx_to_vector_type", toVectorType);
29-
mod.method("cxx_datatype_to_string", datatypeToString);
30-
mod.method("cxx_string_to_datatype", stringToDatatype);
31-
mod.method("cxx_warn_wrong_datatype", warnWrongDtype);
32-
// mod.method("==", operator==);
33-
// mod.method("!=", operator!=);
17+
mod.set_const("openPMD_datatypes", openPMD_Datatypes);
18+
// mod.method("determine_datatype", determineDatatype);
19+
mod.method("cxx_to_bytes", toBytes);
20+
mod.method("cxx_to_bits", toBits);
21+
mod.method("cxx_is_vector", isVector);
22+
mod.method("cxx_is_floating_point", (bool (*)(Datatype))isFloatingPoint);
23+
mod.method(
24+
"cxx_is_complex_floating_point",
25+
static_cast<bool (*)(Datatype)>(isComplexFloatingPoint));
26+
mod.method(
27+
"cxx_is_integer", (std::tuple<bool, bool>(*)(Datatype))isInteger);
28+
// isSameFloatingPoint
29+
// isSameComplexFloatingPoint
30+
// isSameInteger
31+
mod.method("cxx_is_same", isSame);
32+
mod.method("cxx_basic_datatype", basicDatatype);
33+
mod.method("cxx_to_vector_type", toVectorType);
34+
mod.method("cxx_datatype_to_string", datatypeToString);
35+
mod.method("cxx_string_to_datatype", stringToDatatype);
36+
mod.method("cxx_warn_wrong_datatype", warnWrongDtype);
37+
// mod.method("==", operator==);
38+
// mod.method("!=", operator!=);
3439
}

0 commit comments

Comments
 (0)