From ed997abaa25b6f8363a74ebc3522bdea9d0277b9 Mon Sep 17 00:00:00 2001 From: Brice Videau Date: Mon, 20 May 2024 16:38:42 -0500 Subject: [PATCH] Factored internal object serialization. --- src/binding_internal.h | 4 -- src/cconfigspace_deserialize.h | 20 +++---- src/cconfigspace_internal.h | 97 +++++++++++++++++++++++++++++---- src/configuration.c | 4 -- src/configuration_space.c | 5 -- src/context_internal.h | 4 -- src/distribution_mixture.c | 4 -- src/distribution_multivariate.c | 4 -- src/distribution_normal.c | 6 +- src/distribution_roulette.c | 6 +- src/distribution_space.c | 5 -- src/distribution_uniform.c | 6 +- src/evaluation.c | 4 -- src/expression.c | 12 ---- src/map.c | 6 +- src/objective_space.c | 5 -- src/parameter_categorical.c | 6 +- src/parameter_numerical.c | 6 +- src/parameter_string.c | 6 +- src/rng.c | 6 +- src/tree.c | 4 -- src/tree_configuration.c | 5 -- src/tree_space_dynamic.c | 4 -- src/tree_space_static.c | 4 -- src/tuner_random.c | 4 -- src/tuner_user_defined.c | 4 -- tests/test_rng.c | 1 - 27 files changed, 100 insertions(+), 142 deletions(-) diff --git a/src/binding_internal.h b/src/binding_internal.h index 56d45615..383d7e5c 100644 --- a/src/binding_internal.h +++ b/src/binding_internal.h @@ -172,8 +172,6 @@ _ccs_serialize_bin_ccs_binding_data( static inline ccs_result_t _ccs_serialize_bin_size_ccs_binding(ccs_binding_t binding, size_t *cum_size) { - *cum_size += _ccs_serialize_bin_size_ccs_object_internal( - (_ccs_object_internal_t *)binding); *cum_size += _ccs_serialize_bin_size_ccs_binding_data(binding->data); return CCS_RESULT_SUCCESS; } @@ -184,8 +182,6 @@ _ccs_serialize_bin_ccs_binding( size_t *buffer_size, char **buffer) { - CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( - (_ccs_object_internal_t *)binding, buffer_size, buffer)); CCS_VALIDATE(_ccs_serialize_bin_ccs_binding_data( binding->data, buffer_size, buffer)); return CCS_RESULT_SUCCESS; diff --git a/src/cconfigspace_deserialize.h b/src/cconfigspace_deserialize.h index f207bf60..ff71bdbb 100644 --- a/src/cconfigspace_deserialize.h +++ b/src/cconfigspace_deserialize.h @@ -226,19 +226,13 @@ _ccs_object_deserialize_with_opts( ccs_result_t err = CCS_RESULT_SUCCESS; ccs_object_t obj, handle; _ccs_object_internal_t obj_internal; - switch (format) { - case CCS_SERIALIZE_FORMAT_BINARY: { - CCS_VALIDATE(_ccs_deserialize_bin_ccs_object_internal( - &obj_internal, buffer_size, buffer, &handle)); - CCS_VALIDATE(_ccs_object_deserialize_with_opts_type( - &obj, obj_internal.type, format, version, buffer_size, - buffer, opts)); - } break; - default: - CCS_RAISE( - CCS_RESULT_ERROR_INVALID_VALUE, - "Unsupported serialization format: %d", format); - } + + CCS_VALIDATE(_ccs_deserialize_ccs_object_internal( + &obj_internal, format, version, buffer_size, buffer, opts, + &handle)); + CCS_VALIDATE(_ccs_object_deserialize_with_opts_type( + &obj, obj_internal.type, format, version, buffer_size, buffer, + opts)); CCS_VALIDATE_ERR_GOTO( err, _ccs_object_deserialize_user_data( diff --git a/src/cconfigspace_internal.h b/src/cconfigspace_internal.h index 0bb11d9f..e503162d 100644 --- a/src/cconfigspace_internal.h +++ b/src/cconfigspace_internal.h @@ -1212,6 +1212,26 @@ _ccs_serialize_bin_size_ccs_object_internal(_ccs_object_internal_t *obj) _ccs_serialize_bin_size_ccs_object((ccs_object_t)obj); } +static inline ccs_result_t +_ccs_serialize_size_ccs_object_internal( + _ccs_object_internal_t *obj, + ccs_serialize_format_t format, + size_t *cum_size, + _ccs_object_serialize_options_t *opts) +{ + (void)opts; + switch (format) { + case CCS_SERIALIZE_FORMAT_BINARY: { + *cum_size += _ccs_serialize_bin_size_ccs_object_internal(obj); + } break; + default: + CCS_RAISE( + CCS_RESULT_ERROR_INVALID_VALUE, + "Unsupported serialization format: %d", format); + } + return CCS_RESULT_SUCCESS; +} + static inline ccs_result_t _ccs_serialize_bin_ccs_object_internal( _ccs_object_internal_t *obj, @@ -1225,6 +1245,28 @@ _ccs_serialize_bin_ccs_object_internal( return CCS_RESULT_SUCCESS; } +static inline ccs_result_t +_ccs_serialize_ccs_object_internal( + _ccs_object_internal_t *obj, + ccs_serialize_format_t format, + size_t *buffer_size, + char **buffer, + _ccs_object_serialize_options_t *opts) +{ + (void)opts; + switch (format) { + case CCS_SERIALIZE_FORMAT_BINARY: { + CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( + obj, buffer_size, buffer)); + } break; + default: + CCS_RAISE( + CCS_RESULT_ERROR_INVALID_VALUE, + "Unsupported serialization format: %d", format); + } + return CCS_RESULT_SUCCESS; +} + static inline ccs_result_t _ccs_deserialize_bin_ccs_object_internal( _ccs_object_internal_t *obj, @@ -1253,6 +1295,43 @@ _ccs_peek_bin_ccs_object_internal( return CCS_RESULT_SUCCESS; } +struct _ccs_object_deserialize_options_s { + ccs_map_t handle_map; + ccs_bool_t map_values; + _ccs_file_descriptor_state_t **ppfd_state; + void *vector; + void *data; + ccs_object_deserialize_callback_t deserialize_callback; + void *deserialize_user_data; +}; +typedef struct _ccs_object_deserialize_options_s + _ccs_object_deserialize_options_t; + +static inline ccs_result_t +_ccs_deserialize_ccs_object_internal( + _ccs_object_internal_t *obj, + ccs_serialize_format_t format, + uint32_t version, + size_t *buffer_size, + const char **buffer, + _ccs_object_deserialize_options_t *opts, + ccs_object_t *handle_ret) +{ + (void)version; + (void)opts; + switch (format) { + case CCS_SERIALIZE_FORMAT_BINARY: { + CCS_VALIDATE(_ccs_deserialize_bin_ccs_object_internal( + obj, buffer_size, buffer, handle_ret)); + } break; + default: + CCS_RAISE( + CCS_RESULT_ERROR_INVALID_VALUE, + "Unsupported serialization format: %d", format); + } + return CCS_RESULT_SUCCESS; +} + static inline ccs_result_t _ccs_object_handle_check_add( ccs_map_t map, @@ -1268,18 +1347,6 @@ _ccs_object_handle_check_add( return CCS_RESULT_SUCCESS; } -struct _ccs_object_deserialize_options_s { - ccs_map_t handle_map; - ccs_bool_t map_values; - _ccs_file_descriptor_state_t **ppfd_state; - void *vector; - void *data; - ccs_object_deserialize_callback_t deserialize_callback; - void *deserialize_user_data; -}; -typedef struct _ccs_object_deserialize_options_s - _ccs_object_deserialize_options_t; - static inline ccs_result_t _ccs_object_serialize_user_data_size( ccs_object_t object, @@ -1407,6 +1474,9 @@ _ccs_object_serialize_size_with_opts( _ccs_object_serialize_options_t *opts) { _ccs_object_internal_t *obj = (_ccs_object_internal_t *)object; + + CCS_VALIDATE(_ccs_serialize_size_ccs_object_internal( + obj, format, cum_size, opts)); CCS_VALIDATE(obj->ops->serialize_size(object, format, cum_size, opts)); CCS_VALIDATE(_ccs_object_serialize_user_data_size( object, format, cum_size, opts)); @@ -1422,6 +1492,9 @@ _ccs_object_serialize_with_opts( _ccs_object_serialize_options_t *opts) { _ccs_object_internal_t *obj = (_ccs_object_internal_t *)object; + + CCS_VALIDATE(_ccs_serialize_ccs_object_internal( + obj, format, buffer_size, buffer, opts)); CCS_VALIDATE( obj->ops->serialize(object, format, buffer_size, buffer, opts)); CCS_VALIDATE(_ccs_object_serialize_user_data( diff --git a/src/configuration.c b/src/configuration.c index 43f5aa60..c20af33e 100644 --- a/src/configuration.c +++ b/src/configuration.c @@ -55,8 +55,6 @@ _ccs_serialize_bin_size_ccs_configuration( size_t *cum_size, _ccs_object_serialize_options_t *opts) { - *cum_size += _ccs_serialize_bin_size_ccs_object_internal( - (_ccs_object_internal_t *)configuration); CCS_VALIDATE(_ccs_serialize_bin_size_ccs_configuration_data( configuration->data, cum_size, opts)); return CCS_RESULT_SUCCESS; @@ -69,8 +67,6 @@ _ccs_serialize_bin_ccs_configuration( char **buffer, _ccs_object_serialize_options_t *opts) { - CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( - (_ccs_object_internal_t *)configuration, buffer_size, buffer)); CCS_VALIDATE(_ccs_serialize_bin_ccs_configuration_data( configuration->data, buffer_size, buffer, opts)); return CCS_RESULT_SUCCESS; diff --git a/src/configuration_space.c b/src/configuration_space.c index 58f262a9..700fb154 100644 --- a/src/configuration_space.c +++ b/src/configuration_space.c @@ -179,8 +179,6 @@ _ccs_serialize_bin_size_ccs_configuration_space( { _ccs_configuration_space_data_t *data = (_ccs_configuration_space_data_t *)(configuration_space->data); - *cum_size += _ccs_serialize_bin_size_ccs_object_internal( - (_ccs_object_internal_t *)configuration_space); CCS_VALIDATE(_ccs_serialize_bin_size_ccs_configuration_space_data( data, cum_size, opts)); return CCS_RESULT_SUCCESS; @@ -195,9 +193,6 @@ _ccs_serialize_bin_ccs_configuration_space( { _ccs_configuration_space_data_t *data = (_ccs_configuration_space_data_t *)(configuration_space->data); - CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( - (_ccs_object_internal_t *)configuration_space, buffer_size, - buffer)); CCS_VALIDATE(_ccs_serialize_bin_ccs_configuration_space_data( data, buffer_size, buffer, opts)); return CCS_RESULT_SUCCESS; diff --git a/src/context_internal.h b/src/context_internal.h index ecb43dcc..cb8d562d 100644 --- a/src/context_internal.h +++ b/src/context_internal.h @@ -309,8 +309,6 @@ _ccs_serialize_bin_size_ccs_context( size_t *cum_size, _ccs_object_serialize_options_t *opts) { - *cum_size += _ccs_serialize_bin_size_ccs_object_internal( - (_ccs_object_internal_t *)context); CCS_VALIDATE(_ccs_serialize_bin_size_ccs_context_data( context->data, cum_size, opts)); return CCS_RESULT_SUCCESS; @@ -323,8 +321,6 @@ _ccs_serialize_bin_ccs_context( char **buffer, _ccs_object_serialize_options_t *opts) { - CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( - (_ccs_object_internal_t *)context, buffer_size, buffer)); CCS_VALIDATE(_ccs_serialize_bin_ccs_context_data( context->data, buffer_size, buffer, opts)); return CCS_RESULT_SUCCESS; diff --git a/src/distribution_mixture.c b/src/distribution_mixture.c index 74cfa372..971b45d5 100644 --- a/src/distribution_mixture.c +++ b/src/distribution_mixture.c @@ -76,8 +76,6 @@ _ccs_serialize_bin_size_ccs_distribution_mixture( { _ccs_distribution_mixture_data_t *data = (_ccs_distribution_mixture_data_t *)(distribution->data); - *cum_size += _ccs_serialize_bin_size_ccs_object_internal( - (_ccs_object_internal_t *)distribution); CCS_VALIDATE(_ccs_serialize_bin_size_ccs_distribution_mixture_data( data, cum_size, opts)); return CCS_RESULT_SUCCESS; @@ -92,8 +90,6 @@ _ccs_serialize_bin_ccs_distribution_mixture( { _ccs_distribution_mixture_data_t *data = (_ccs_distribution_mixture_data_t *)(distribution->data); - CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( - (_ccs_object_internal_t *)distribution, buffer_size, buffer)); CCS_VALIDATE(_ccs_serialize_bin_ccs_distribution_mixture_data( data, buffer_size, buffer, opts)); return CCS_RESULT_SUCCESS; diff --git a/src/distribution_multivariate.c b/src/distribution_multivariate.c index 1737f240..b5e070bc 100644 --- a/src/distribution_multivariate.c +++ b/src/distribution_multivariate.c @@ -69,8 +69,6 @@ _ccs_serialize_bin_size_ccs_distribution_multivariate( { _ccs_distribution_multivariate_data_t *data = (_ccs_distribution_multivariate_data_t *)(distribution->data); - *cum_size += _ccs_serialize_bin_size_ccs_object_internal( - (_ccs_object_internal_t *)distribution); CCS_VALIDATE(_ccs_serialize_bin_size_ccs_distribution_multivariate_data( data, cum_size, opts)); return CCS_RESULT_SUCCESS; @@ -85,8 +83,6 @@ _ccs_serialize_bin_ccs_distribution_multivariate( { _ccs_distribution_multivariate_data_t *data = (_ccs_distribution_multivariate_data_t *)(distribution->data); - CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( - (_ccs_object_internal_t *)distribution, buffer_size, buffer)); CCS_VALIDATE(_ccs_serialize_bin_ccs_distribution_multivariate_data( data, buffer_size, buffer, opts)); return CCS_RESULT_SUCCESS; diff --git a/src/distribution_normal.c b/src/distribution_normal.c index 55ca85fd..e84ea3a8 100644 --- a/src/distribution_normal.c +++ b/src/distribution_normal.c @@ -70,9 +70,7 @@ _ccs_serialize_bin_size_ccs_distribution_normal(ccs_distribution_t distribution) { _ccs_distribution_normal_data_t *data = (_ccs_distribution_normal_data_t *)(distribution->data); - return _ccs_serialize_bin_size_ccs_object_internal( - (_ccs_object_internal_t *)distribution) + - _ccs_serialize_bin_size_ccs_distribution_normal_data(data); + return _ccs_serialize_bin_size_ccs_distribution_normal_data(data); } static inline ccs_result_t @@ -83,8 +81,6 @@ _ccs_serialize_bin_ccs_distribution_normal( { _ccs_distribution_normal_data_t *data = (_ccs_distribution_normal_data_t *)(distribution->data); - CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( - (_ccs_object_internal_t *)distribution, buffer_size, buffer)); CCS_VALIDATE(_ccs_serialize_bin_ccs_distribution_normal_data( data, buffer_size, buffer)); return CCS_RESULT_SUCCESS; diff --git a/src/distribution_roulette.c b/src/distribution_roulette.c index 54c2dbf9..cc5e7e23 100644 --- a/src/distribution_roulette.c +++ b/src/distribution_roulette.c @@ -56,9 +56,7 @@ _ccs_serialize_bin_size_ccs_distribution_roulette( { _ccs_distribution_roulette_data_t *data = (_ccs_distribution_roulette_data_t *)(distribution->data); - return _ccs_serialize_bin_size_ccs_object_internal( - (_ccs_object_internal_t *)distribution) + - _ccs_serialize_bin_size_ccs_distribution_roulette_data(data); + return _ccs_serialize_bin_size_ccs_distribution_roulette_data(data); } static inline ccs_result_t @@ -69,8 +67,6 @@ _ccs_serialize_bin_ccs_distribution_roulette( { _ccs_distribution_roulette_data_t *data = (_ccs_distribution_roulette_data_t *)(distribution->data); - CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( - (_ccs_object_internal_t *)distribution, buffer_size, buffer)); CCS_VALIDATE(_ccs_serialize_bin_ccs_distribution_roulette_data( data, buffer_size, buffer)); return CCS_RESULT_SUCCESS; diff --git a/src/distribution_space.c b/src/distribution_space.c index 47c829cd..3d955348 100644 --- a/src/distribution_space.c +++ b/src/distribution_space.c @@ -85,8 +85,6 @@ _ccs_serialize_bin_size_ccs_distribution_space( { _ccs_distribution_space_data_t *data = (_ccs_distribution_space_data_t *)(distribution_space->data); - *cum_size += _ccs_serialize_bin_size_ccs_object_internal( - (_ccs_object_internal_t *)distribution_space); CCS_VALIDATE(_ccs_serialize_bin_size_ccs_distribution_space_data( data, cum_size, opts)); return CCS_RESULT_SUCCESS; @@ -101,9 +99,6 @@ _ccs_serialize_bin_ccs_distribution_space( { _ccs_distribution_space_data_t *data = (_ccs_distribution_space_data_t *)(distribution_space->data); - CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( - (_ccs_object_internal_t *)distribution_space, buffer_size, - buffer)); CCS_VALIDATE(_ccs_serialize_bin_ccs_distribution_space_data( data, buffer_size, buffer, opts)); return CCS_RESULT_SUCCESS; diff --git a/src/distribution_uniform.c b/src/distribution_uniform.c index db7d9560..098b39d6 100644 --- a/src/distribution_uniform.c +++ b/src/distribution_uniform.c @@ -81,9 +81,7 @@ _ccs_serialize_bin_size_ccs_distribution_uniform(ccs_distribution_t distribution { _ccs_distribution_uniform_data_t *data = (_ccs_distribution_uniform_data_t *)(distribution->data); - return _ccs_serialize_bin_size_ccs_object_internal( - (_ccs_object_internal_t *)distribution) + - _ccs_serialize_bin_size_ccs_distribution_uniform_data(data); + return _ccs_serialize_bin_size_ccs_distribution_uniform_data(data); } static inline ccs_result_t @@ -94,8 +92,6 @@ _ccs_serialize_bin_ccs_distribution_uniform( { _ccs_distribution_uniform_data_t *data = (_ccs_distribution_uniform_data_t *)(distribution->data); - CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( - (_ccs_object_internal_t *)distribution, buffer_size, buffer)); CCS_VALIDATE(_ccs_serialize_bin_ccs_distribution_uniform_data( data, buffer_size, buffer)); return CCS_RESULT_SUCCESS; diff --git a/src/evaluation.c b/src/evaluation.c index 1f5bb9b7..968cbb5e 100644 --- a/src/evaluation.c +++ b/src/evaluation.c @@ -59,8 +59,6 @@ _ccs_serialize_bin_size_ccs_evaluation( size_t *cum_size, _ccs_object_serialize_options_t *opts) { - *cum_size += _ccs_serialize_bin_size_ccs_object_internal( - (_ccs_object_internal_t *)evaluation); CCS_VALIDATE(_ccs_serialize_bin_size_ccs_evaluation_data( evaluation->data, cum_size, opts)); return CCS_RESULT_SUCCESS; @@ -73,8 +71,6 @@ _ccs_serialize_bin_ccs_evaluation( char **buffer, _ccs_object_serialize_options_t *opts) { - CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( - (_ccs_object_internal_t *)evaluation, buffer_size, buffer)); CCS_VALIDATE(_ccs_serialize_bin_ccs_evaluation_data( evaluation->data, buffer_size, buffer, opts)); return CCS_RESULT_SUCCESS; diff --git a/src/expression.c b/src/expression.c index eb9697cd..428c02c3 100644 --- a/src/expression.c +++ b/src/expression.c @@ -141,8 +141,6 @@ _ccs_serialize_bin_size_ccs_expression( { _ccs_expression_data_t *data = (_ccs_expression_data_t *)(expression->data); - *cum_size += _ccs_serialize_bin_size_ccs_object_internal( - (_ccs_object_internal_t *)expression); CCS_VALIDATE(_ccs_serialize_bin_size_ccs_expression_data( data, cum_size, opts)); return CCS_RESULT_SUCCESS; @@ -157,8 +155,6 @@ _ccs_serialize_bin_ccs_expression( { _ccs_expression_data_t *data = (_ccs_expression_data_t *)(expression->data); - CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( - (_ccs_object_internal_t *)expression, buffer_size, buffer)); CCS_VALIDATE(_ccs_serialize_bin_ccs_expression_data( data, buffer_size, buffer, opts)); return CCS_RESULT_SUCCESS; @@ -1084,8 +1080,6 @@ _ccs_serialize_bin_size_ccs_expression_literal( { _ccs_expression_literal_data_t *data = (_ccs_expression_literal_data_t *)(expression->data); - *cum_size += _ccs_serialize_bin_size_ccs_object_internal( - (_ccs_object_internal_t *)expression); CCS_VALIDATE(_ccs_serialize_bin_size_ccs_expression_literal_data( data, cum_size, opts)); return CCS_RESULT_SUCCESS; @@ -1100,8 +1094,6 @@ _ccs_serialize_bin_ccs_expression_literal( { _ccs_expression_literal_data_t *data = (_ccs_expression_literal_data_t *)(expression->data); - CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( - (_ccs_object_internal_t *)expression, buffer_size, buffer)); CCS_VALIDATE(_ccs_serialize_bin_ccs_expression_literal_data( data, buffer_size, buffer, opts)); return CCS_RESULT_SUCCESS; @@ -1209,8 +1201,6 @@ _ccs_serialize_bin_size_ccs_expression_variable( { _ccs_expression_variable_data_t *data = (_ccs_expression_variable_data_t *)(expression->data); - *cum_size += _ccs_serialize_bin_size_ccs_object_internal( - (_ccs_object_internal_t *)expression); CCS_VALIDATE(_ccs_serialize_bin_size_ccs_expression_variable_data( data, cum_size, opts)); return CCS_RESULT_SUCCESS; @@ -1225,8 +1215,6 @@ _ccs_serialize_bin_ccs_expression_variable( { _ccs_expression_variable_data_t *data = (_ccs_expression_variable_data_t *)(expression->data); - CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( - (_ccs_object_internal_t *)expression, buffer_size, buffer)); CCS_VALIDATE(_ccs_serialize_bin_ccs_expression_variable_data( data, buffer_size, buffer, opts)); return CCS_RESULT_SUCCESS; diff --git a/src/map.c b/src/map.c index 2a7d009e..64fc6c78 100644 --- a/src/map.c +++ b/src/map.c @@ -83,17 +83,13 @@ static inline size_t _ccs_serialize_bin_size_ccs_map(ccs_map_t map) { _ccs_map_data_t *data = (_ccs_map_data_t *)(map->data); - return _ccs_serialize_bin_size_ccs_object_internal( - (_ccs_object_internal_t *)map) + - _ccs_serialize_bin_size_ccs_map_data(data); + return _ccs_serialize_bin_size_ccs_map_data(data); } static inline ccs_result_t _ccs_serialize_bin_ccs_map(ccs_map_t map, size_t *buffer_size, char **buffer) { _ccs_map_data_t *data = (_ccs_map_data_t *)(map->data); - CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( - (_ccs_object_internal_t *)map, buffer_size, buffer)); CCS_VALIDATE( _ccs_serialize_bin_ccs_map_data(data, buffer_size, buffer)); return CCS_RESULT_SUCCESS; diff --git a/src/objective_space.c b/src/objective_space.c index bfd3a31c..14c5eba7 100644 --- a/src/objective_space.c +++ b/src/objective_space.c @@ -130,8 +130,6 @@ _ccs_serialize_bin_size_ccs_objective_space( { _ccs_objective_space_data_t *data = (_ccs_objective_space_data_t *)(objective_space->data); - *cum_size += _ccs_serialize_bin_size_ccs_object_internal( - (_ccs_object_internal_t *)objective_space); CCS_VALIDATE(_ccs_serialize_bin_size_ccs_objective_space_data( data, cum_size, opts)); return CCS_RESULT_SUCCESS; @@ -146,9 +144,6 @@ _ccs_serialize_bin_ccs_objective_space( { _ccs_objective_space_data_t *data = (_ccs_objective_space_data_t *)(objective_space->data); - CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( - (_ccs_object_internal_t *)objective_space, buffer_size, - buffer)); CCS_VALIDATE(_ccs_serialize_bin_ccs_objective_space_data( data, buffer_size, buffer, opts)); return CCS_RESULT_SUCCESS; diff --git a/src/parameter_categorical.c b/src/parameter_categorical.c index cc56b902..2ef569ab 100644 --- a/src/parameter_categorical.c +++ b/src/parameter_categorical.c @@ -57,9 +57,7 @@ _ccs_serialize_bin_size_ccs_parameter_categorical(ccs_parameter_t parameter) { _ccs_parameter_categorical_data_t *data = (_ccs_parameter_categorical_data_t *)(parameter->data); - return _ccs_serialize_bin_size_ccs_object_internal( - (_ccs_object_internal_t *)parameter) + - _ccs_serialize_bin_size_ccs_parameter_categorical_data(data); + return _ccs_serialize_bin_size_ccs_parameter_categorical_data(data); } static inline ccs_result_t @@ -70,8 +68,6 @@ _ccs_serialize_bin_ccs_parameter_categorical( { _ccs_parameter_categorical_data_t *data = (_ccs_parameter_categorical_data_t *)(parameter->data); - CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( - (_ccs_object_internal_t *)parameter, buffer_size, buffer)); CCS_VALIDATE(_ccs_serialize_bin_ccs_parameter_categorical_data( data, buffer_size, buffer)); return CCS_RESULT_SUCCESS; diff --git a/src/parameter_numerical.c b/src/parameter_numerical.c index c0a86dce..31f3648f 100644 --- a/src/parameter_numerical.c +++ b/src/parameter_numerical.c @@ -14,9 +14,7 @@ _ccs_serialize_bin_size_ccs_parameter_numerical(ccs_parameter_t parameter) { _ccs_parameter_numerical_data_t *data = (_ccs_parameter_numerical_data_t *)(parameter->data); - return _ccs_serialize_bin_size_ccs_object_internal( - (_ccs_object_internal_t *)parameter) + - _ccs_serialize_bin_size_ccs_parameter_numerical_data(data); + return _ccs_serialize_bin_size_ccs_parameter_numerical_data(data); } static inline ccs_result_t @@ -27,8 +25,6 @@ _ccs_serialize_bin_ccs_parameter_numerical( { _ccs_parameter_numerical_data_t *data = (_ccs_parameter_numerical_data_t *)(parameter->data); - CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( - (_ccs_object_internal_t *)parameter, buffer_size, buffer)); CCS_VALIDATE(_ccs_serialize_bin_ccs_parameter_numerical_data( data, buffer_size, buffer)); return CCS_RESULT_SUCCESS; diff --git a/src/parameter_string.c b/src/parameter_string.c index 4510312d..39187cb4 100644 --- a/src/parameter_string.c +++ b/src/parameter_string.c @@ -55,9 +55,7 @@ _ccs_serialize_bin_size_ccs_parameter_string(ccs_parameter_t parameter) { _ccs_parameter_string_data_t *data = (_ccs_parameter_string_data_t *)(parameter->data); - return _ccs_serialize_bin_size_ccs_object_internal( - (_ccs_object_internal_t *)parameter) + - _ccs_serialize_bin_size_ccs_parameter_string_data(data); + return _ccs_serialize_bin_size_ccs_parameter_string_data(data); } static inline ccs_result_t @@ -68,8 +66,6 @@ _ccs_serialize_bin_ccs_parameter_string( { _ccs_parameter_string_data_t *data = (_ccs_parameter_string_data_t *)(parameter->data); - CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( - (_ccs_object_internal_t *)parameter, buffer_size, buffer)); CCS_VALIDATE(_ccs_serialize_bin_ccs_parameter_string_data( data, buffer_size, buffer)); return CCS_RESULT_SUCCESS; diff --git a/src/rng.c b/src/rng.c index 0aeaaba9..44d46a4b 100644 --- a/src/rng.c +++ b/src/rng.c @@ -38,17 +38,13 @@ static inline size_t _ccs_serialize_bin_size_ccs_rng(ccs_rng_t rng) { _ccs_rng_data_t *data = (_ccs_rng_data_t *)(rng->data); - return _ccs_serialize_bin_size_ccs_object_internal( - (_ccs_object_internal_t *)rng) + - _ccs_serialize_bin_size_ccs_rng_data(data); + return _ccs_serialize_bin_size_ccs_rng_data(data); } static inline ccs_result_t _ccs_serialize_bin_ccs_rng(ccs_rng_t rng, size_t *buffer_size, char **buffer) { _ccs_rng_data_t *data = (_ccs_rng_data_t *)(rng->data); - CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( - (_ccs_object_internal_t *)rng, buffer_size, buffer)); CCS_VALIDATE( _ccs_serialize_bin_ccs_rng_data(data, buffer_size, buffer)); return CCS_RESULT_SUCCESS; diff --git a/src/tree.c b/src/tree.c index ff5e51ac..3c91993b 100644 --- a/src/tree.c +++ b/src/tree.c @@ -68,8 +68,6 @@ _ccs_serialize_bin_size_ccs_tree( size_t *cum_size, _ccs_object_serialize_options_t *opts) { - *cum_size += _ccs_serialize_bin_size_ccs_object_internal( - (_ccs_object_internal_t *)tree); CCS_VALIDATE(_ccs_serialize_bin_size_ccs_tree_data( tree->data, cum_size, opts)); return CCS_RESULT_SUCCESS; @@ -82,8 +80,6 @@ _ccs_serialize_bin_ccs_tree( char **buffer, _ccs_object_serialize_options_t *opts) { - CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( - (_ccs_object_internal_t *)tree, buffer_size, buffer)); CCS_VALIDATE(_ccs_serialize_bin_ccs_tree_data( tree->data, buffer_size, buffer, opts)); return CCS_RESULT_SUCCESS; diff --git a/src/tree_configuration.c b/src/tree_configuration.c index 05d62400..7e8b001d 100644 --- a/src/tree_configuration.c +++ b/src/tree_configuration.c @@ -63,8 +63,6 @@ _ccs_serialize_bin_size_ccs_tree_configuration( size_t *cum_size, _ccs_object_serialize_options_t *opts) { - *cum_size += _ccs_serialize_bin_size_ccs_object_internal( - (_ccs_object_internal_t *)tree_configuration); CCS_VALIDATE(_ccs_serialize_bin_size_ccs_tree_configuration_data( tree_configuration->data, cum_size, opts)); return CCS_RESULT_SUCCESS; @@ -77,9 +75,6 @@ _ccs_serialize_bin_ccs_tree_configuration( char **buffer, _ccs_object_serialize_options_t *opts) { - CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( - (_ccs_object_internal_t *)tree_configuration, buffer_size, - buffer)); CCS_VALIDATE(_ccs_serialize_bin_ccs_tree_configuration_data( tree_configuration->data, buffer_size, buffer, opts)); return CCS_RESULT_SUCCESS; diff --git a/src/tree_space_dynamic.c b/src/tree_space_dynamic.c index 53706209..c234dabf 100644 --- a/src/tree_space_dynamic.c +++ b/src/tree_space_dynamic.c @@ -58,8 +58,6 @@ _ccs_serialize_bin_size_ccs_tree_space_dynamic( { _ccs_tree_space_dynamic_data_t *data = (_ccs_tree_space_dynamic_data_t *)tree_space->data; - *cum_size += _ccs_serialize_bin_size_ccs_object_internal( - (_ccs_object_internal_t *)tree_space); CCS_VALIDATE(_ccs_serialize_bin_size_ccs_tree_space_dynamic_data( data, cum_size, opts)); size_t state_size = 0; @@ -80,8 +78,6 @@ _ccs_serialize_bin_ccs_tree_space_dynamic( { _ccs_tree_space_dynamic_data_t *data = (_ccs_tree_space_dynamic_data_t *)tree_space->data; - CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( - (_ccs_object_internal_t *)tree_space, buffer_size, buffer)); CCS_VALIDATE(_ccs_serialize_bin_ccs_tree_space_dynamic_data( data, buffer_size, buffer, opts)); size_t state_size = 0; diff --git a/src/tree_space_static.c b/src/tree_space_static.c index 33953e46..09112075 100644 --- a/src/tree_space_static.c +++ b/src/tree_space_static.c @@ -53,8 +53,6 @@ _ccs_serialize_bin_size_ccs_tree_space_static( { _ccs_tree_space_static_data_t *data = (_ccs_tree_space_static_data_t *)tree_space->data; - *cum_size += _ccs_serialize_bin_size_ccs_object_internal( - (_ccs_object_internal_t *)tree_space); CCS_VALIDATE(_ccs_serialize_bin_size_ccs_tree_space_static_data( data, cum_size, opts)); return CCS_RESULT_SUCCESS; @@ -69,8 +67,6 @@ _ccs_serialize_bin_ccs_tree_space_static( { _ccs_tree_space_static_data_t *data = (_ccs_tree_space_static_data_t *)tree_space->data; - CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( - (_ccs_object_internal_t *)tree_space, buffer_size, buffer)); CCS_VALIDATE(_ccs_serialize_bin_ccs_tree_space_static_data( data, buffer_size, buffer, opts)); return CCS_RESULT_SUCCESS; diff --git a/src/tuner_random.c b/src/tuner_random.c index 7e2c76a0..417c4fe0 100644 --- a/src/tuner_random.c +++ b/src/tuner_random.c @@ -84,8 +84,6 @@ _ccs_serialize_bin_size_ccs_random_tuner( { _ccs_random_tuner_data_t *data = (_ccs_random_tuner_data_t *)(tuner->data); - *cum_size += _ccs_serialize_bin_size_ccs_object_internal( - (_ccs_object_internal_t *)tuner); CCS_VALIDATE(_ccs_serialize_bin_size_ccs_random_tuner_data( data, cum_size, opts)); return CCS_RESULT_SUCCESS; @@ -100,8 +98,6 @@ _ccs_serialize_bin_ccs_random_tuner( { _ccs_random_tuner_data_t *data = (_ccs_random_tuner_data_t *)(tuner->data); - CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( - (_ccs_object_internal_t *)tuner, buffer_size, buffer)); CCS_VALIDATE(_ccs_serialize_bin_ccs_random_tuner_data( data, buffer_size, buffer, opts)); return CCS_RESULT_SUCCESS; diff --git a/src/tuner_user_defined.c b/src/tuner_user_defined.c index d81670c7..3c9000b8 100644 --- a/src/tuner_user_defined.c +++ b/src/tuner_user_defined.c @@ -33,8 +33,6 @@ _ccs_serialize_bin_size_ccs_user_defined_tuner( ccs_result_t res = CCS_RESULT_SUCCESS; _ccs_user_defined_tuner_data_t *data = (_ccs_user_defined_tuner_data_t *)(tuner->data); - *cum_size += _ccs_serialize_bin_size_ccs_object_internal( - (_ccs_object_internal_t *)tuner); CCS_VALIDATE(_ccs_serialize_bin_size_ccs_tuner_common_data( &data->common_data, cum_size, opts)); size_t history_size = 0; @@ -104,8 +102,6 @@ _ccs_serialize_bin_ccs_user_defined_tuner( ccs_result_t res = CCS_RESULT_SUCCESS; _ccs_user_defined_tuner_data_t *data = (_ccs_user_defined_tuner_data_t *)(tuner->data); - CCS_VALIDATE(_ccs_serialize_bin_ccs_object_internal( - (_ccs_object_internal_t *)tuner, buffer_size, buffer)); CCS_VALIDATE(_ccs_serialize_bin_ccs_tuner_common_data( &data->common_data, buffer_size, buffer, opts)); size_t history_size = 0; diff --git a/tests/test_rng.c b/tests/test_rng.c index 861492cb..95d9b2eb 100644 --- a/tests/test_rng.c +++ b/tests/test_rng.c @@ -78,7 +78,6 @@ test_rng_create(void) (ccs_object_t *)&rng2, CCS_SERIALIZE_FORMAT_BINARY, CCS_SERIALIZE_OPERATION_MEMORY, buff_size, buff, CCS_DESERIALIZE_OPTION_END); - print_ccs_error_stack(); assert(err == CCS_RESULT_SUCCESS); free(buff);