mirror of https://github.com/ecmwf/eccodes.git
All tests now pass when env var grib_cpp=1
This commit is contained in:
parent
b573592440
commit
fd186fcccf
|
@ -819,7 +819,7 @@ grib_accessor* grib_next_accessor(grib_accessor* a)
|
|||
{
|
||||
if(eccodes::grib_accessor_impl_gen* ga_impl = eccodes::get_grib_accessor_impl(a); ga_impl)
|
||||
{
|
||||
return (grib_accessor*)ga_impl->next_accessor(1);
|
||||
return ga_impl->next_accessor(1);
|
||||
}
|
||||
|
||||
grib_accessor_class* c = a->cclass;
|
||||
|
|
|
@ -15,7 +15,6 @@ namespace eccodes {
|
|||
virtual ~grib_accessor_impl() = default;
|
||||
virtual void init(const long len, grib_arguments* params) = 0;
|
||||
//virtual void destroy(grib_context* ct) = 0;
|
||||
virtual grib_section* sub_section() = 0;
|
||||
virtual int native_type() = 0;
|
||||
virtual int pack_missing() = 0;
|
||||
virtual int is_missing() = 0;
|
||||
|
@ -44,8 +43,8 @@ namespace eccodes {
|
|||
virtual size_t preferred_size(int from_handle) = 0;
|
||||
virtual void resize(size_t new_size) = 0;
|
||||
virtual int nearest_smaller_value(double val, double* nearest) = 0;
|
||||
// Note: Renamed fron next() to avoid clash with member variable of the same name!
|
||||
virtual grib_accessor_impl* next_accessor(int mod) = 0;
|
||||
// Note: Renamed from next() to avoid clash with member variable of the same name!
|
||||
virtual grib_accessor* next_accessor(int mod) = 0;
|
||||
virtual int compare(grib_accessor_impl* ga_impl) = 0;
|
||||
virtual int unpack_double_element(size_t i, double* val) = 0;
|
||||
virtual int unpack_float_element(size_t i, float* val) = 0;
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace eccodes {
|
|||
static cpp_mode grib_cpp_mode = [](){
|
||||
if(const char* env_str = std::getenv(grib_cpp_env)){
|
||||
if(strcmp(env_str, "1") == 0) {
|
||||
fprintf(stderr, "ECCODES DEBUG Using GRIB C++ classes\n");
|
||||
//fprintf(stdout, "ECCODES DEBUG Using GRIB C++ classes\n");
|
||||
return cpp_mode::enabled;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,36 +1,48 @@
|
|||
#include "grib_accessor_impl_gen.h"
|
||||
#include "grib_accessor_impl_factory.h"
|
||||
#include "grib_value.h"
|
||||
|
||||
namespace eccodes {
|
||||
grib_accessor_impl_gen::grib_accessor_impl_gen(grib_section* p, grib_action* creator)
|
||||
grib_accessor_impl_gen::grib_accessor_impl_gen(grib_section* p, grib_action* ga_creator)
|
||||
{
|
||||
name = creator->name;
|
||||
name_space = creator->name_space;
|
||||
// Due to the way we're building this class from an existing grib_accessor struct
|
||||
// we need to manually init all the members...
|
||||
name = ga_creator->name;
|
||||
name_space = ga_creator->name_space;
|
||||
context = p->h->context;
|
||||
h = NULL;
|
||||
creator = ga_creator;
|
||||
length = 0;
|
||||
|
||||
all_names[0] = creator->name;
|
||||
all_name_spaces[0] = creator->name_space;
|
||||
|
||||
creator = creator;
|
||||
context = p->h->context;
|
||||
h = NULL;
|
||||
next = NULL;
|
||||
previous = NULL;
|
||||
parent = p;
|
||||
length = 0;
|
||||
offset = 0;
|
||||
flags = creator->flags;
|
||||
set = creator->set;
|
||||
|
||||
if (p->block->last) {
|
||||
offset = grib_get_next_position_offset(p->block->last);
|
||||
}
|
||||
if (p->block->last) { offset = grib_get_next_position_offset(p->block->last); }
|
||||
else {
|
||||
if (p->owner) {
|
||||
offset = p->owner->offset;
|
||||
}
|
||||
else
|
||||
offset = 0;
|
||||
if (p->owner) { offset = p->owner->offset; }
|
||||
else { offset = 0; }
|
||||
}
|
||||
|
||||
parent = p;
|
||||
next = NULL;
|
||||
previous = NULL;
|
||||
cclass = NULL;
|
||||
flags = ga_creator->flags;
|
||||
sub_section = NULL;
|
||||
|
||||
memset(all_names, 0 , sizeof(all_names));
|
||||
memset(all_name_spaces, 0 , sizeof(all_name_spaces));
|
||||
|
||||
all_names[0] = ga_creator->name;
|
||||
all_name_spaces[0] = ga_creator->name_space;
|
||||
dirty = 0;
|
||||
same = NULL;
|
||||
loop = 0;
|
||||
bufr_subset_number = 0;
|
||||
bufr_group_number = 0;
|
||||
vvalue = NULL;
|
||||
set = ga_creator->set;
|
||||
|
||||
memset(attributes, 0 , sizeof(attributes));
|
||||
|
||||
parent_as_attribute = NULL;
|
||||
}
|
||||
|
||||
grib_accessor_impl_gen::~grib_accessor_impl_gen()
|
||||
|
@ -479,10 +491,26 @@ namespace eccodes {
|
|||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
grib_accessor_impl* grib_accessor_impl_gen::next_accessor(int /* mod */)
|
||||
grib_accessor* grib_accessor_impl_gen::next_accessor(int mod)
|
||||
{
|
||||
Assert(0);
|
||||
return nullptr; // TO DO
|
||||
grib_accessor* ga_next = NULL;
|
||||
|
||||
if (next) {
|
||||
ga_next = next;
|
||||
}
|
||||
else if (parent->owner) {
|
||||
// TODO - Whilst porting the C code there may be instances of parent->owner
|
||||
// that do not have a C++ implementation so we have to support the
|
||||
// 'C' way of doing it too!
|
||||
if(eccodes::grib_accessor_impl_gen* ga_impl = eccodes::get_grib_accessor_impl(parent->owner); ga_impl) {
|
||||
ga_next = ga_impl->next_accessor(0);
|
||||
}
|
||||
else if(parent->owner->cclass) {
|
||||
ga_next = parent->owner->cclass->next(parent->owner, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return ga_next;
|
||||
}
|
||||
|
||||
int grib_accessor_impl_gen::compare(grib_accessor_impl* ga_impl)
|
||||
|
|
|
@ -22,10 +22,9 @@ namespace eccodes {
|
|||
size_t str_len{1024};
|
||||
|
||||
public:
|
||||
grib_accessor_impl_gen(grib_section* p, grib_action* creator);
|
||||
grib_accessor_impl_gen(grib_section* p, grib_action* ga_creator);
|
||||
~grib_accessor_impl_gen();
|
||||
void init(const long len, grib_arguments* params) override;
|
||||
grib_section* sub_section() override { return nullptr; }
|
||||
int native_type() override;
|
||||
int pack_missing() override { return GRIB_INVALID_TYPE; }
|
||||
int is_missing() override;
|
||||
|
@ -54,7 +53,7 @@ namespace eccodes {
|
|||
size_t preferred_size(int from_handle) override;
|
||||
void resize(size_t new_size) override;
|
||||
int nearest_smaller_value (double val, double* nearest) override;
|
||||
grib_accessor_impl* next_accessor(int mod) override;
|
||||
grib_accessor* next_accessor(int mod) override;
|
||||
int compare(grib_accessor_impl* ga_impl) override;
|
||||
int unpack_double_element(size_t i, double* val) override;
|
||||
int unpack_float_element(size_t i, float* val) override;
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
#include "proj_string_helper.h"
|
||||
|
||||
namespace eccodes {
|
||||
grib_accessor_impl_proj_string::grib_accessor_impl_proj_string(grib_section* p, grib_action* creator) :
|
||||
grib_accessor_impl_gen(p, creator)
|
||||
grib_accessor_impl_proj_string::grib_accessor_impl_proj_string(grib_section* p, grib_action* ga_creator) :
|
||||
grib_accessor_impl_gen(p, ga_creator)
|
||||
{
|
||||
// No extra logic here - init() handles this
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace eccodes {
|
|||
int endpoint;
|
||||
|
||||
public:
|
||||
grib_accessor_impl_proj_string(grib_section* p, grib_action* creator);
|
||||
grib_accessor_impl_proj_string(grib_section* p, grib_action* ga_creator);
|
||||
void init(const long len, grib_arguments* params) override;
|
||||
int native_type() override { return GRIB_TYPE_STRING; }
|
||||
int unpack_string(char* val, size_t* len) override;
|
||||
|
|
Loading…
Reference in New Issue