diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2022-05-13 11:08:38 +0900 |
---|---|---|
committer | 坂本 貴史 <o-takashi@sakamocchi.jp> | 2022-05-20 23:00:30 +0900 |
commit | d4fbe87a4e66847a9232027e4d114927924e99c0 (patch) | |
tree | da3c7ba67951f9069f2a919041cc5e80b5c19b59 | |
parent | 20588d35ee30852e13a828c6639d98cf2bda35ee (diff) | |
download | libhinawa-d4fbe87a4e66847a9232027e4d114927924e99c0.tar.gz |
enums: add Hinawa.FwReqError enumerations according to GNOME convention
In the convention of GNOME project, the name of error domain and its
code enumration should have the same name.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
-rw-r--r-- | src/fw_req.c | 32 | ||||
-rw-r--r-- | src/hinawa.map | 5 | ||||
-rw-r--r-- | src/hinawa_enum_types.h | 31 | ||||
-rw-r--r-- | tests/hinawa-enum | 14 |
4 files changed, 66 insertions, 16 deletions
diff --git a/src/fw_req.c b/src/fw_req.c index 92cbf75..5a98fa9 100644 --- a/src/fw_req.c +++ b/src/fw_req.c @@ -40,25 +40,25 @@ typedef struct { G_DEFINE_TYPE_WITH_PRIVATE(HinawaFwReq, hinawa_fw_req, G_TYPE_OBJECT) static const char *const err_labels[] = { - [RCODE_COMPLETE] = "no error", - [RCODE_CONFLICT_ERROR] = "conflict error", - [RCODE_DATA_ERROR] = "data error", - [RCODE_TYPE_ERROR] = "type error", - [RCODE_ADDRESS_ERROR] = "address error", - [RCODE_SEND_ERROR] = "send error", - [RCODE_CANCELLED] = "timeout", - [RCODE_BUSY] = "busy", - [RCODE_GENERATION] = "bus reset", - [RCODE_NO_ACK] = "no ack", + [HINAWA_FW_REQ_ERROR_CONFLICT_ERROR] = "conflict error", + [HINAWA_FW_REQ_ERROR_DATA_ERROR] = "data error", + [HINAWA_FW_REQ_ERROR_TYPE_ERROR] = "type error", + [HINAWA_FW_REQ_ERROR_ADDRESS_ERROR] = "address error", + [HINAWA_FW_REQ_ERROR_SEND_ERROR] = "send error", + [HINAWA_FW_REQ_ERROR_CANCELLED] = "timeout", + [HINAWA_FW_REQ_ERROR_BUSY] = "busy", + [HINAWA_FW_REQ_ERROR_GENERATION] = "bus reset", + [HINAWA_FW_REQ_ERROR_NO_ACK] = "no ack", + [HINAWA_FW_REQ_ERROR_INVALID] = "invalid", }; -static void generate_fw_req_error_with_errno(GError **error, HinawaFwRcode code, int err_no) +static void generate_fw_req_error_with_errno(GError **error, HinawaFwReqError code, int err_no) { g_set_error(error, HINAWA_FW_REQ_ERROR, code, "%s %d (%s)", err_labels[code], err_no, strerror(err_no)); } -static void generate_fw_req_error_literal(GError **error, HinawaFwRcode code) +static void generate_fw_req_error_literal(GError **error, HinawaFwReqError code) { g_set_error_literal(error, HINAWA_FW_REQ_ERROR, code, err_labels[code]); } @@ -254,7 +254,7 @@ void hinawa_fw_req_transaction_async(HinawaFwReq *self, HinawaFwNode *node, // Send this transaction. err = hinawa_fw_node_ioctl(node, FW_CDEV_IOC_SEND_REQUEST, &req, error); if (*error == NULL && err > 0) - generate_fw_req_error_with_errno(error, HINAWA_FW_RCODE_SEND_ERROR, err); + generate_fw_req_error_with_errno(error, HINAWA_FW_REQ_ERROR_SEND_ERROR, err); } struct waiter { @@ -355,7 +355,7 @@ void hinawa_fw_req_transaction_sync(HinawaFwReq *self, HinawaFwNode *node, g_object_unref(node); if (w.rcode == G_MAXUINT) { - generate_fw_req_error_literal(error, HINAWA_FW_RCODE_CANCELLED); + generate_fw_req_error_literal(error, HINAWA_FW_REQ_ERROR_CANCELLED); return; } @@ -372,10 +372,10 @@ void hinawa_fw_req_transaction_sync(HinawaFwReq *self, HinawaFwNode *node, case RCODE_BUSY: case RCODE_GENERATION: case RCODE_NO_ACK: - generate_fw_req_error_literal(error, w.rcode); + generate_fw_req_error_literal(error, (HinawaFwReqError)w.rcode); break; default: - generate_fw_req_error_literal(error, HINAWA_FW_RCODE_INVALID); + generate_fw_req_error_literal(error, HINAWA_FW_REQ_ERROR_INVALID); break; } } diff --git a/src/hinawa.map b/src/hinawa.map index 967d8f7..34fa3c9 100644 --- a/src/hinawa.map +++ b/src/hinawa.map @@ -153,3 +153,8 @@ HINAWA_2_4_0 { "hinawa_snd_motu_register_dsp_parameter_get_input_gain_and_invert"; "hinawa_snd_motu_register_dsp_parameter_get_input_flag"; } HINAWA_2_3_0; + +HINAWA_2_5_0 { + global: + "hinawa_fw_req_error_get_type"; +} HINAWA_2_3_0; diff --git a/src/hinawa_enum_types.h b/src/hinawa_enum_types.h index 9d95adc..1933d6b 100644 --- a/src/hinawa_enum_types.h +++ b/src/hinawa_enum_types.h @@ -81,6 +81,37 @@ typedef enum { } HinawaFwRcode; /** + * HinawaFwReqError: + * @HINAWA_FW_REQ_ERROR_CONFLICT_ERROR: For error of conflicting. + * @HINAWA_FW_REQ_ERROR_DATA_ERROR: For error of data. + * @HINAWA_FW_REQ_ERROR_TYPE_ERROR: For error of type. + * @HINAWA_FW_REQ_ERROR_ADDRESS_ERROR: For error of address. + * @HINAWA_FW_REQ_ERROR_SEND_ERROR: For error of sending. + * @HINAWA_FW_REQ_ERROR_CANCELLED: For cancellation. + * @HINAWA_FW_REQ_ERROR_BUSY: For busyness. + * @HINAWA_FW_REQ_ERROR_GENERATION: For generation. + * @HINAWA_FW_REQ_ERROR_NO_ACK: For no acknowledge. + * @HINAWA_FW_REQ_ERROR_INVALID: For rcode out of specification. + * + * A set of error code for [class@Hinawa.FwReq]. Each of them has the same value as the + * corresponding enumeration in [enum@Hinawa.FwRcode]. + * + * Since: 2.5. + */ +typedef enum { + HINAWA_FW_REQ_ERROR_CONFLICT_ERROR = HINAWA_FW_RCODE_CONFLICT_ERROR, + HINAWA_FW_REQ_ERROR_DATA_ERROR = HINAWA_FW_RCODE_DATA_ERROR, + HINAWA_FW_REQ_ERROR_TYPE_ERROR = HINAWA_FW_RCODE_TYPE_ERROR, + HINAWA_FW_REQ_ERROR_ADDRESS_ERROR = HINAWA_FW_RCODE_ADDRESS_ERROR, + HINAWA_FW_REQ_ERROR_SEND_ERROR = HINAWA_FW_RCODE_SEND_ERROR, + HINAWA_FW_REQ_ERROR_CANCELLED = HINAWA_FW_RCODE_CANCELLED, + HINAWA_FW_REQ_ERROR_BUSY = HINAWA_FW_RCODE_BUSY, + HINAWA_FW_REQ_ERROR_GENERATION = HINAWA_FW_RCODE_GENERATION, + HINAWA_FW_REQ_ERROR_NO_ACK = HINAWA_FW_RCODE_NO_ACK, + HINAWA_FW_REQ_ERROR_INVALID = HINAWA_FW_RCODE_INVALID, +} HinawaFwReqError; + +/** * HinawaSndUnitType: * @HINAWA_SND_UNIT_TYPE_DICE: The type of DICE ASIC. * @HINAWA_SND_UNIT_TYPE_FIREWORKS: The type of Fireworks board module. diff --git a/tests/hinawa-enum b/tests/hinawa-enum index b54ad96..5c10d7c 100644 --- a/tests/hinawa-enum +++ b/tests/hinawa-enum @@ -43,6 +43,19 @@ fw_rcode_enumerators = ( 'NO_ACK', ) +fw_req_error_enumerations = ( + 'CONFLICT_ERROR', + 'DATA_ERROR', + 'TYPE_ERROR', + 'ADDRESS_ERROR', + 'SEND_ERROR', + 'CANCELLED', + 'BUSY', + 'GENERATION', + 'NO_ACK', + 'INVALID', +) + snd_unit_type_enumerators = ( 'DICE', 'FIREWORKS', @@ -109,6 +122,7 @@ snd_efw_status_enumerators = ( types = { Hinawa.FwTcode: fw_tcode_enumerators, Hinawa.FwRcode: fw_rcode_enumerators, + Hinawa.FwReqError: fw_req_error_enumerations, Hinawa.SndUnitType: snd_unit_type_enumerators, Hinawa.FwNodeError: fw_node_error_enumerators, Hinawa.FwRespError: fw_resp_error_enumerations, |