Refactoring: removal of duplicated code (dump)

This commit is contained in:
Shahram Najm 2024-03-07 21:10:30 +00:00
parent 84f23bf502
commit 017794f8e1
14 changed files with 28 additions and 111 deletions

View File

@ -17,7 +17,7 @@
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long;pack_long
IMPLEMENTS = init;dump
IMPLEMENTS = init
MEMBERS = const char* owner
MEMBERS = int bit_index
END_CLASS_DEF
@ -36,7 +36,6 @@ or edit "accessor.class" and rerun ./make_class.pl
static int pack_long(grib_accessor*, const long* val, size_t* len);
static int unpack_long(grib_accessor*, long* val, size_t* len);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_bit
@ -60,7 +59,7 @@ static grib_accessor_class _grib_accessor_class_bit = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
0, /* get number of values */
@ -112,10 +111,6 @@ static void init(grib_accessor* a, const long len, grib_arguments* arg)
self->bit_index = grib_arguments_get_long(grib_handle_of_accessor(a), arg, 1);
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{

View File

@ -24,7 +24,7 @@ CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long
IMPLEMENTS = unpack_string_array
IMPLEMENTS = init;dump;destroy
IMPLEMENTS = init;destroy
IMPLEMENTS = value_count
MEMBERS = const char* expandedDescriptors
MEMBERS = grib_accessor* expandedDescriptorsAccessor
@ -47,7 +47,6 @@ static int unpack_long(grib_accessor*, long* val, size_t* len);
static int unpack_string_array(grib_accessor*, char**, size_t* len);
static int value_count(grib_accessor*, long*);
static void destroy(grib_context*, grib_accessor*);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_bufrdc_expanded_descriptors
@ -71,7 +70,7 @@ static grib_accessor_class _grib_accessor_class_bufrdc_expanded_descriptors = {
&init, /* init */
0, /* post_init */
&destroy, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
&value_count, /* get number of values */
@ -125,11 +124,6 @@ static void init(grib_accessor* a, const long len, grib_arguments* args)
a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY;
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static grib_accessor* get_accessor(grib_accessor* a)
{
grib_accessor_bufrdc_expanded_descriptors* self = (grib_accessor_bufrdc_expanded_descriptors*)a;

View File

@ -26,7 +26,7 @@ SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long;pack_long
IMPLEMENTS = unpack_double
IMPLEMENTS = unpack_string_array
IMPLEMENTS = init;dump;destroy
IMPLEMENTS = init;destroy
IMPLEMENTS = value_count; get_native_type
MEMBERS = const char* unexpandedDescriptors
MEMBERS = const char* sequence
@ -59,7 +59,6 @@ static int unpack_long(grib_accessor*, long* val, size_t* len);
static int unpack_string_array(grib_accessor*, char**, size_t* len);
static int value_count(grib_accessor*, long*);
static void destroy(grib_context*, grib_accessor*);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_expanded_descriptors
@ -90,7 +89,7 @@ static grib_accessor_class _grib_accessor_class_expanded_descriptors = {
&init, /* init */
0, /* post_init */
&destroy, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
&value_count, /* get number of values */
@ -180,11 +179,6 @@ static void init(grib_accessor* a, const long len, grib_arguments* args)
a->length = 0;
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static bufr_descriptors_array* do_expand(grib_accessor* a, bufr_descriptors_array* unexpanded, change_coding_params* ccp, int* err);
#define BUFR_DESCRIPTORS_ARRAY_USED_SIZE(v) ((v)->n)

View File

@ -17,7 +17,7 @@
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long;pack_long;unpack_string
IMPLEMENTS = init;dump;value_count
IMPLEMENTS = init;value_count
MEMBERS=const char* century
MEMBERS=const char* year
MEMBERS=const char* month
@ -40,7 +40,6 @@ static int pack_long(grib_accessor*, const long* val, size_t* len);
static int unpack_long(grib_accessor*, long* val, size_t* len);
static int unpack_string(grib_accessor*, char*, size_t* len);
static int value_count(grib_accessor*, long*);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_g1date
@ -66,7 +65,7 @@ static grib_accessor_class _grib_accessor_class_g1date = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
&value_count, /* get number of values */
@ -122,11 +121,6 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
self->day = grib_arguments_get_name(hand, c, n++);
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
grib_accessor_g1date* self = (grib_accessor_g1date*)a;

View File

@ -22,7 +22,7 @@
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long
IMPLEMENTS = init;dump
IMPLEMENTS = init
MEMBERS=const char* date
END_CLASS_DEF
@ -39,7 +39,6 @@ or edit "accessor.class" and rerun ./make_class.pl
*/
static int unpack_long(grib_accessor*, long* val, size_t* len);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_g1monthlydate
@ -62,7 +61,7 @@ static grib_accessor_class _grib_accessor_class_g1monthlydate = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
0, /* get number of values */
@ -115,11 +114,6 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY;
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
grib_accessor_g1monthlydate* self = (grib_accessor_g1monthlydate*)a;

View File

@ -17,7 +17,7 @@
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long
IMPLEMENTS = init;dump
IMPLEMENTS = init
MEMBERS=const char* date
MEMBERS=const char* time
MEMBERS=const char* step
@ -36,7 +36,6 @@ or edit "accessor.class" and rerun ./make_class.pl
*/
static int unpack_long(grib_accessor*, long* val, size_t* len);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_g1verificationdate
@ -61,7 +60,7 @@ static grib_accessor_class _grib_accessor_class_g1verificationdate = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
0, /* get number of values */
@ -117,11 +116,6 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY;
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
grib_accessor_g1verificationdate* self = (grib_accessor_g1verificationdate*)a;

View File

@ -16,7 +16,7 @@
START_CLASS_DEF
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long;pack_long;init;dump
IMPLEMENTS = unpack_long;pack_long;init
MEMBERS=const char* century
MEMBERS=const char* year
MEMBERS=const char* month
@ -37,7 +37,6 @@ or edit "accessor.class" and rerun ./make_class.pl
static int pack_long(grib_accessor*, const long* val, size_t* len);
static int unpack_long(grib_accessor*, long* val, size_t* len);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_g2date
@ -63,7 +62,7 @@ static grib_accessor_class _grib_accessor_class_g2date = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
0, /* get number of values */
@ -116,11 +115,6 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
self->day = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++);
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
const grib_accessor_g2date* self = (grib_accessor_g2date*)a;

View File

@ -17,7 +17,7 @@
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_double;pack_double
IMPLEMENTS = unpack_long;pack_long;init;dump;is_missing
IMPLEMENTS = unpack_long;pack_long;init;is_missing
MEMBERS=const char* type_first
MEMBERS=const char* scale_first
MEMBERS=const char* value_first
@ -41,7 +41,6 @@ static int pack_double(grib_accessor*, const double* val, size_t* len);
static int pack_long(grib_accessor*, const long* val, size_t* len);
static int unpack_double(grib_accessor*, double* val, size_t* len);
static int unpack_long(grib_accessor*, long* val, size_t* len);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_g2level
@ -67,7 +66,7 @@ static grib_accessor_class _grib_accessor_class_g2level = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
0, /* get number of values */
@ -126,11 +125,6 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
a->flags |= GRIB_ACCESSOR_FLAG_COPY_IF_CHANGING_EDITION;
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static bool is_tigge(grib_handle* h)
{
long productionStatus = 0;

View File

@ -17,7 +17,7 @@
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long;pack_long
IMPLEMENTS = init;dump
IMPLEMENTS = init
MEMBERS=const char* typicalYear
MEMBERS=const char* typicalMonth
MEMBERS=const char* typicalDay
@ -39,7 +39,6 @@ or edit "accessor.class" and rerun ./make_class.pl
static int pack_long(grib_accessor*, const long* val, size_t* len);
static int unpack_long(grib_accessor*, long* val, size_t* len);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_rdbtime_guess_date
@ -66,7 +65,7 @@ static grib_accessor_class _grib_accessor_class_rdbtime_guess_date = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
0, /* get number of values */
@ -124,11 +123,6 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
/* a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; */
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
grib_accessor_rdbtime_guess_date* self = (grib_accessor_rdbtime_guess_date*)a;

View File

@ -16,7 +16,7 @@
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long;pack_long
IMPLEMENTS = init;dump
IMPLEMENTS = init
IMPLEMENTS = next_offset
IMPLEMENTS = byte_count
IMPLEMENTS = value_count
@ -45,7 +45,6 @@ static long byte_count(grib_accessor*);
static long byte_offset(grib_accessor*);
static long next_offset(grib_accessor*);
static int value_count(grib_accessor*, long*);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
static void update_size(grib_accessor*, size_t);
@ -70,7 +69,7 @@ static grib_accessor_class _grib_accessor_class_signed_bits = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
&next_offset, /* next_offset */
0, /* get length of string */
&value_count, /* get number of values */
@ -152,11 +151,6 @@ static void init(grib_accessor* a, const long len, grib_arguments* args)
a->length = compute_byte_count(a);
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
return GRIB_NOT_IMPLEMENTED;

View File

@ -16,7 +16,7 @@
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long;pack_long
IMPLEMENTS = init;dump
IMPLEMENTS = init
IMPLEMENTS = next_offset
IMPLEMENTS = byte_count
IMPLEMENTS = value_count
@ -45,7 +45,6 @@ static long byte_count(grib_accessor*);
static long byte_offset(grib_accessor*);
static long next_offset(grib_accessor*);
static int value_count(grib_accessor*, long*);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
static void update_size(grib_accessor*, size_t);
@ -70,7 +69,7 @@ static grib_accessor_class _grib_accessor_class_spd = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
&next_offset, /* next_offset */
0, /* get length of string */
&value_count, /* get number of values */
@ -153,11 +152,6 @@ static void init(grib_accessor* a, const long len, grib_arguments* args)
a->length = compute_byte_count(a);
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
grib_accessor_spd* self = (grib_accessor_spd*)a;

View File

@ -18,7 +18,7 @@
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long;pack_long
IMPLEMENTS = unpack_string
IMPLEMENTS = init;dump
IMPLEMENTS = init
MEMBERS=const char* hour
MEMBERS=const char* minute
MEMBERS=const char* second
@ -39,7 +39,6 @@ or edit "accessor.class" and rerun ./make_class.pl
static int pack_long(grib_accessor*, const long* val, size_t* len);
static int unpack_long(grib_accessor*, long* val, size_t* len);
static int unpack_string(grib_accessor*, char*, size_t* len);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_time
@ -64,7 +63,7 @@ static grib_accessor_class _grib_accessor_class_time = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
0, /* get number of values */
@ -119,11 +118,6 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
self->second = grib_arguments_get_name(hand, c, n++);
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
const grib_accessor_time* self = (grib_accessor_time*)a;

View File

@ -17,7 +17,7 @@
CLASS = accessor
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long
IMPLEMENTS = init;dump
IMPLEMENTS = init
MEMBERS=const char* date
MEMBERS=const char* time
MEMBERS=const char* step
@ -40,7 +40,6 @@ or edit "accessor.class" and rerun ./make_class.pl
*/
static int unpack_long(grib_accessor*, long* val, size_t* len);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_validity_date
@ -69,7 +68,7 @@ static grib_accessor_class _grib_accessor_class_validity_date = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
0, /* get number of values */
@ -165,11 +164,6 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY;
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
grib_accessor_validity_date* self = (grib_accessor_validity_date*)a;

View File

@ -18,7 +18,7 @@
SUPER = grib_accessor_class_long
IMPLEMENTS = unpack_long
IMPLEMENTS = unpack_string
IMPLEMENTS = init;dump
IMPLEMENTS = init
MEMBERS=const char* date
MEMBERS=const char* time
MEMBERS=const char* step
@ -41,7 +41,6 @@ or edit "accessor.class" and rerun ./make_class.pl
static int unpack_long(grib_accessor*, long* val, size_t* len);
static int unpack_string(grib_accessor*, char*, size_t* len);
static void dump(grib_accessor*, grib_dumper*);
static void init(grib_accessor*, const long, grib_arguments*);
typedef struct grib_accessor_validity_time
@ -69,7 +68,7 @@ static grib_accessor_class _grib_accessor_class_validity_time = {
&init, /* init */
0, /* post_init */
0, /* destroy */
&dump, /* dump */
0, /* dump */
0, /* next_offset */
0, /* get length of string */
0, /* get number of values */
@ -164,11 +163,6 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY;
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper, a, NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
grib_accessor_validity_time* self = (grib_accessor_validity_time*)a;