Skip to content

Commit

Permalink
fix: remove useless magic
Browse files Browse the repository at this point in the history
Because it's breaking introspection for IDEs and GitHub.
  • Loading branch information
pmuller committed Jan 25, 2024
1 parent 53aa8cf commit 4aca585
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,18 @@ void NdefRecord::set_type_name_format(TNF type_name_format)
} \
this->name = pointer;

#define DECLARE_FIELD_SETTER(name, uint32_type) \
int8_t NdefRecord::set_##name(uint8_t *name, uint32_type name##_length) \
{ \
REALLOC_FIELD_OR_FAIL(name, name##_length); \
memcpy(this->name, name, name##_length); \
this->name##_length = name##_length; \
return NDEF_SUCCESS; \
}

DECLARE_FIELD_SETTER(type, uint8_t)
DECLARE_FIELD_SETTER(id, uint8_t)
DECLARE_FIELD_SETTER(payload, uint32_t)
#define SET_FIELD(name) \
REALLOC_FIELD_OR_FAIL(name, name##_length); \
memcpy(this->name, name, name##_length); \
this->name##_length = name##_length; \
return NDEF_SUCCESS;

uint8_t *NdefRecord::get_type() { return type; }

uint8_t NdefRecord::get_type_length() { return type_length; }

int8_t NdefRecord::set_type(uint8_t *type, uint8_t type_length) { SET_FIELD(type); }

int8_t NdefRecord::set_type(RTD type)
{
REALLOC_FIELD_OR_FAIL(type, 1);
Expand All @@ -74,10 +69,17 @@ uint8_t *NdefRecord::get_id() { return id; }

uint8_t NdefRecord::get_id_length() { return id_length; }

int8_t NdefRecord::set_id(uint8_t *id, uint8_t id_length) { SET_FIELD(id); }

uint8_t *NdefRecord::get_payload() { return payload; }

uint32_t NdefRecord::get_payload_length() { return payload_length; }

int8_t NdefRecord::set_payload(uint8_t *payload, uint32_t payload_length)
{
SET_FIELD(payload);
}

uint8_t *NdefRecord::encode()
{
SAFE_MALLOC(
Expand Down

0 comments on commit 4aca585

Please sign in to comment.