@@ -79,16 +79,16 @@ class Atom {
7979};
8080
8181namespace __private__ ::atoms {
82- inline Atom ok (" ok" );
83- inline Atom error (" error" );
84- inline Atom nil (" nil" );
85- inline Atom true_ (" true" );
86- inline Atom false_ (" false" );
87- inline Atom __struct__ (" __struct__" );
88- inline Atom __exception__ (" __exception__" );
89- inline Atom message (" message" );
90- inline Atom ElixirArgumentError (" Elixir.ArgumentError" );
91- inline Atom ElixirRuntimeError (" Elixir.RuntimeError" );
82+ inline auto ok = Atom (" ok" );
83+ inline auto error = Atom (" error" );
84+ inline auto nil = Atom (" nil" );
85+ inline auto true_ = Atom (" true" );
86+ inline auto false_ = Atom (" false" );
87+ inline auto __struct__ = Atom (" __struct__" );
88+ inline auto __exception__ = Atom (" __exception__" );
89+ inline auto message = Atom (" message" );
90+ inline auto ElixirArgumentError = Atom (" Elixir.ArgumentError" );
91+ inline auto ElixirRuntimeError = Atom (" Elixir.RuntimeError" );
9292} // namespace __private__::atoms
9393
9494// Result tagged tuples
@@ -350,7 +350,7 @@ struct Decoder<T, std::void_t<decltype(T::module), decltype(T::fields)>> {
350350private:
351351 template <typename U>
352352 static void set_field (ErlNifEnv *env, ERL_NIF_TERM term, T &ex_struct,
353- Atom *atom, U T::*field_ptr) {
353+ U T::*field_ptr, const Atom *atom ) {
354354 ERL_NIF_TERM value;
355355 if (!enif_get_map_value (env, term, encode (env, *atom), &value)) {
356356 throw std::invalid_argument (
@@ -546,9 +546,9 @@ struct Encoder<T, std::void_t<decltype(T::module), decltype(T::fields)>> {
546546
547547 std::apply (
548548 [&](auto ... field) {
549- ((keys[Indices] = fine::encode (env, *std::get<0 >(field)),
549+ ((keys[Indices] = fine::encode (env, *std::get<1 >(field)),
550550 values[Indices] =
551- fine::encode (env, ex_struct.*(std::get<1 >(field)))),
551+ fine::encode (env, ex_struct.*(std::get<0 >(field)))),
552552 ...);
553553 },
554554 fields);
@@ -846,11 +846,13 @@ inline int load(ErlNifEnv *env, void **priv_data, ERL_NIF_TERM load_info) {
846846 return fine::nif (env, argc, argv, name); \
847847 } \
848848 auto __nif_registration_##name = fine::Registration::register_nif( \
849- {#name, fine::nif_arity (name), name##_nif, flags});
849+ {#name, fine::nif_arity (name), name##_nif, flags}); \
850+ static_assert (true , " require a semicolon after the macro" )
850851
851852#define FINE_RESOURCE (class_name ) \
852853 auto __resource_registration_##class_name = \
853- fine::Registration::register_resource<class_name>(#class_name);
854+ fine::Registration::register_resource<class_name>(#class_name); \
855+ static_assert (true , " require a semicolon after the macro" )
854856
855857// This is a modified version of ERL_NIF_INIT that points to the
856858// registered NIF functions and also sets the load callback.
@@ -865,7 +867,7 @@ inline int load(ErlNifEnv *env, void **priv_data, ERL_NIF_TERM load_info) {
865867 auto load = fine::__private__::load; \
866868 static ErlNifEntry entry = {ERL_NIF_MAJOR_VERSION, \
867869 ERL_NIF_MINOR_VERSION, \
868- # name, \
870+ name, \
869871 num_funcs, \
870872 funcs, \
871873 load, \
@@ -879,7 +881,8 @@ inline int load(ErlNifEnv *env, void **priv_data, ERL_NIF_TERM load_info) {
879881 ERL_NIF_INIT_BODY; \
880882 return &entry; \
881883 } \
882- ERL_NIF_INIT_EPILOGUE
884+ ERL_NIF_INIT_EPILOGUE \
885+ static_assert (true , " require a semicolon after the macro" )
883886
884887} // namespace fine
885888
0 commit comments