GRIB-588: compile grib_api with a C++ compiler

This commit is contained in:
Shahram Najm 2014-10-02 17:48:41 +01:00
parent 47fff95d0b
commit 45daa319ef
10 changed files with 32 additions and 34 deletions

View File

@ -21,8 +21,8 @@
IMPLEMENTS = create_accessor
IMPLEMENTS = dump
IMPLEMENTS = destroy; xref; compile
MEMBERS = char* old
MEMBERS = char* new
MEMBERS = char* the_old
MEMBERS = char* the_new
END_CLASS_DEF
*/
@ -48,8 +48,8 @@ static int create_accessor(grib_section*,grib_action*,grib_loader*);
typedef struct grib_action_rename {
grib_action act;
/* Members defined in rename */
char* old;
char* new;
char* the_old;
char* the_new;
} grib_action_rename;
@ -80,7 +80,7 @@ static void init_class(grib_action_class* c)
}
/* END_CLASS_IMP */
grib_action* grib_action_create_rename( grib_context* context, char* old, char* new)
grib_action* grib_action_create_rename( grib_context* context, char* the_old, char* the_new)
{
grib_action_rename* a = NULL;
grib_action_class* c = grib_action_class_rename;
@ -91,8 +91,8 @@ grib_action* grib_action_create_rename( grib_context* context, char* old, char*
act->cclass = c;
act->context = context;
a = (grib_action_rename*)act;
a->old=grib_context_strdup_persistent(context,old);
a->new=grib_context_strdup_persistent(context,new);
a->the_old=grib_context_strdup_persistent(context,the_old);
a->the_new=grib_context_strdup_persistent(context,the_new);
return act;
}
@ -103,7 +103,7 @@ static void compile(grib_action* act, grib_compiler* compiler)
static void rename_accessor(grib_accessor *a,char* name){
int id;
char* old=(char*)a->all_names[0];
char* the_old=(char*)a->all_names[0];
if (a->parent->h->use_trie && *(a->all_names[0]) != '_') {
id=grib_hash_keys_get_id(a->parent->h->context->keys,a->all_names[0]);
@ -113,8 +113,8 @@ static void rename_accessor(grib_accessor *a,char* name){
}
a->all_names[0]=grib_context_strdup_persistent(a->parent->h->context,name);
a->name=a->all_names[0];
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG,"Renaming %s to %s",old,name);
/* grib_context_free(a->parent->h->context,old); */
grib_context_log(a->parent->h->context,GRIB_LOG_DEBUG,"Renaming %s to %s",the_old,name);
/* grib_context_free(a->parent->h->context,the_old); */
return;
}
@ -127,12 +127,12 @@ static int create_accessor(grib_section* p, grib_action* act,grib_loader*h)
grib_accessor* ga = NULL;
ga = grib_find_accessor(p->h, a->old);
ga = grib_find_accessor(p->h, a->the_old);
if(ga) {
rename_accessor(ga,a->new);
rename_accessor(ga,a->the_new);
} else{
grib_context_log(act->context, GRIB_LOG_DEBUG, "Action_class_rename : create_accessor_buffer : No accessor named %s to rename ", a->old);
grib_context_log(act->context, GRIB_LOG_DEBUG, "Action_class_rename : create_accessor_buffer : No accessor named %s to rename ", a->the_old);
}
return GRIB_SUCCESS;
@ -147,15 +147,15 @@ static void dump( grib_action* act, FILE* f, int lvl)
for (i=0;i<lvl;i++) grib_context_print(act->context,f," ");
grib_context_print(act->context,f,"rename %s as %s in %s\n",a->old,act->name,a->new);
grib_context_print(act->context,f,"rename %s as %s in %s\n",a->the_old,act->name,a->the_new);
}
static void destroy(grib_context* context, grib_action* act)
{
grib_action_rename* a = ( grib_action_rename*)act;
grib_context_free_persistent(context, a->old);
grib_context_free_persistent(context, a->new);
grib_context_free_persistent(context, a->the_old);
grib_context_free_persistent(context, a->the_new);
grib_context_free_persistent(context, act->name);
grib_context_free_persistent(context, act->op);
}

View File

@ -49,7 +49,7 @@ grib_action *grib_action_create_meta(grib_context *context, const char *name, co
grib_action *grib_action_create_remove(grib_context *context, grib_arguments *args);
/* action_class_rename.c */
grib_action *grib_action_create_rename(grib_context *context, char *old, char *new);
grib_action *grib_action_create_rename(grib_context *context, char *the_old, char *the_new);
/* action_class_assert.c */
grib_action *grib_action_create_assert(grib_context *context, grib_expression *expression);
@ -1255,7 +1255,6 @@ double grib_arguments_get_double(grib_handle *h, grib_arguments *args, int n);
grib_expression *grib_arguments_get_expression(grib_handle *h, grib_arguments *args, int n);
/* grib_util.c */
double rint(double x);
grib_handle *grib_util_sections_copy(grib_handle *hfrom, grib_handle *hto, int what, int *err);
grib_string_list *grib_util_get_param_id(const char *mars_param);
grib_string_list *grib_util_get_mars_param(const char *param_id);

View File

@ -61,7 +61,7 @@ bufr_descriptors_array* grib_bufr_descriptors_array_resize_to(bufr_descriptors_a
if (!c) c=grib_context_get_default();
newv=grib_context_malloc_clear(c,newsize*sizeof(bufr_descriptor*));
newv=(bufr_descriptor**)grib_context_malloc_clear(c,newsize*sizeof(bufr_descriptor*));
if (!newv) {
grib_context_log(c,GRIB_LOG_ERROR,
"grib_bufr_descriptors_array_resize unable to allocate %d bytes\n",sizeof(bufr_descriptor*)*newsize);
@ -174,7 +174,7 @@ bufr_descriptor** grib_bufr_descriptors_array_get_array(bufr_descriptors_array*
size_t i;
grib_context* c=grib_context_get_default();
vv=grib_context_malloc_clear(c,sizeof(bufr_descriptor*)*v->n);
vv=(bufr_descriptor**)grib_context_malloc_clear(c,sizeof(bufr_descriptor*)*v->n);
for (i=0;i<v->n;i++) vv[i]=grib_bufr_descriptor_clone(c,v->v[i]);
return vv;

View File

@ -74,7 +74,7 @@ double* grib_darray_get_array(grib_context* c,grib_darray* v) {
double* ret;
int i;
if (!v) return NULL;
ret=grib_context_malloc_clear(c,sizeof(double)*v->n);
ret=(double*)grib_context_malloc_clear(c,sizeof(double)*v->n);
for (i=0;i<v->n;i++) ret[i]=v->v[i];
return ret;
}

View File

@ -13,7 +13,7 @@
grib_hash_array_value* grib_integer_hash_array_value_new(grib_context* c, const char* name,grib_iarray* array)
{
grib_hash_array_value* v = grib_context_malloc_clear_persistent(c,sizeof(grib_hash_array_value));
grib_hash_array_value* v = (grib_hash_array_value*)grib_context_malloc_clear_persistent(c,sizeof(grib_hash_array_value));
v->name = grib_context_strdup_persistent(c,name);
v->type=GRIB_HASH_ARRAY_TYPE_INTEGER;
@ -23,7 +23,7 @@ grib_hash_array_value* grib_integer_hash_array_value_new(grib_context* c, const
grib_hash_array_value* grib_double_hash_array_value_new(grib_context* c,const char* name,grib_darray* array)
{
grib_hash_array_value* v = grib_context_malloc_clear_persistent(c,sizeof(grib_hash_array_value));
grib_hash_array_value* v = (grib_hash_array_value*)grib_context_malloc_clear_persistent(c,sizeof(grib_hash_array_value));
v->name = grib_context_strdup_persistent(c,name);
v->type=GRIB_HASH_ARRAY_TYPE_DOUBLE;

View File

@ -81,7 +81,7 @@ grib_iarray* grib_iarray_resize_to(grib_iarray* v,size_t newsize) {
if (!c) c=grib_context_get_default();
newv=grib_context_malloc_clear(c,newsize*sizeof(long));
newv=(long*)grib_context_malloc_clear(c,newsize*sizeof(long));
if (!newv) {
grib_context_log(c,GRIB_LOG_ERROR,
"grib_iarray_resize unable to allocate %d bytes\n",sizeof(long)*newsize);
@ -193,7 +193,7 @@ long* grib_iarray_get_array(grib_iarray* v) {
size_t i;
grib_context* c=grib_context_get_default();
vv=grib_context_malloc_clear(c,sizeof(long)*v->n);
vv=(long*)grib_context_malloc_clear(c,sizeof(long)*v->n);
for (i=0;i<v->n;i++) vv[i]=v->v[i];
return vv;

View File

@ -42,7 +42,7 @@ grib_sarray* grib_sarray_resize(grib_context* c,grib_sarray* v) {
if (!c) c=grib_context_get_default();
v->v=grib_context_realloc(c,v->v,newsize*sizeof(char*));
v->v=(char**)grib_context_realloc(c,v->v,newsize*sizeof(char*));
v->size=newsize;
if (!v->v) {
grib_context_log(c,GRIB_LOG_ERROR,
@ -81,12 +81,11 @@ void grib_sarray_delete_content(grib_context* c,grib_sarray* v) {
v->n=0;
}
char** grib_sarray_get_array(grib_context* c,grib_sarray* v) {
char** ret;
int i;
if (!v) return NULL;
ret=grib_context_malloc_clear(c,sizeof(char*)*v->n);
ret=(char**)grib_context_malloc_clear(c,sizeof(char*)*v->n);
for (i=0;i<v->n;i++) ret[i]=v->v[i];
return ret;
}

View File

@ -42,7 +42,7 @@ grib_vdarray* grib_vdarray_resize(grib_context* c,grib_vdarray* v) {
if (!c) c=grib_context_get_default();
v->v=grib_context_realloc(c,v->v,newsize*sizeof(grib_darray*));
v->v=(grib_darray**)grib_context_realloc(c,v->v,newsize*sizeof(grib_darray*));
v->size=newsize;
if (!v->v) {
grib_context_log(c,GRIB_LOG_ERROR,
@ -85,7 +85,7 @@ grib_darray** grib_vdarray_get_array(grib_context* c,grib_vdarray* v) {
grib_darray** ret;
int i;
if (!v) return NULL;
ret=grib_context_malloc_clear(c,sizeof(grib_darray*)*v->n);
ret=(grib_darray**)grib_context_malloc_clear(c,sizeof(grib_darray*)*v->n);
for (i=0;i<v->n;i++) ret[i]=v->v[i];
return ret;
}

View File

@ -42,7 +42,7 @@ grib_viarray* grib_viarray_resize(grib_context* c,grib_viarray* v) {
if (!c) c=grib_context_get_default();
v->v=grib_context_realloc(c,v->v,newsize*sizeof(grib_iarray*));
v->v=(grib_iarray**)grib_context_realloc(c,v->v,newsize*sizeof(grib_iarray*));
v->size=newsize;
if (!v->v) {
grib_context_log(c,GRIB_LOG_ERROR,
@ -85,7 +85,7 @@ grib_iarray** grib_viarray_get_array(grib_context* c,grib_viarray* v) {
grib_iarray** ret;
int i;
if (!v) return NULL;
ret=grib_context_malloc_clear(c,sizeof(grib_iarray*)*v->n);
ret=(grib_iarray**)grib_context_malloc_clear(c,sizeof(grib_iarray*)*v->n);
for (i=0;i<v->n;i++) ret[i]=v->v[i];
return ret;
}

View File

@ -42,7 +42,7 @@ grib_vsarray* grib_vsarray_resize(grib_context* c,grib_vsarray* v) {
if (!c) c=grib_context_get_default();
v->v=grib_context_realloc(c,v->v,newsize*sizeof(grib_sarray*));
v->v=(grib_sarray**)grib_context_realloc(c,v->v,newsize*sizeof(grib_sarray*));
v->size=newsize;
if (!v->v) {
grib_context_log(c,GRIB_LOG_ERROR,
@ -86,7 +86,7 @@ grib_sarray** grib_vsarray_get_array(grib_context* c,grib_vsarray* v) {
grib_sarray** ret;
int i;
if (!v) return NULL;
ret=grib_context_malloc_clear(c,sizeof(grib_sarray*)*v->n);
ret=(grib_sarray**)grib_context_malloc_clear(c,sizeof(grib_sarray*)*v->n);
for (i=0;i<v->n;i++) ret[i]=v->v[i];
return ret;
}