mirror of https://github.com/ecmwf/eccodes.git
ECC-339 and cleaning of compile methods
This commit is contained in:
parent
d82ffbb9e0
commit
ce163ac783
|
@ -9,18 +9,18 @@
|
|||
|
||||
position offsetSection4;
|
||||
section_length[3] section4Length ;
|
||||
unsigned[1] reservedSection4 = 0;
|
||||
unsigned[1] reservedSection4 = 0 : hidden;
|
||||
position offsetBeforeData;
|
||||
|
||||
meta bufrDataEncoded raw(totalLength,section4Length,4) : hidden;
|
||||
|
||||
template dataKeys "bufr/dataKeys.def";
|
||||
|
||||
meta numericValues bufr_data_array(bufrDataEncoded, numberOfSubsets,expandedCodes,expandedFlags, elementsDescriptorsIndex,compressedData,dataKeys) : no_copy;
|
||||
meta stringValues bufr_string_values(numericValues) : no_copy;
|
||||
meta numericValues bufr_data_array(bufrDataEncoded, numberOfSubsets,expandedCodes,expandedFlags, elementsDescriptorsIndex,compressedData,dataKeys) : no_copy,hidden;
|
||||
meta stringValues bufr_string_values(numericValues) : no_copy,hidden;
|
||||
|
||||
meta unpack unpack_bufr_values(numericValues) : no_copy;
|
||||
meta pack pack_bufr_values(numericValues) : no_copy;
|
||||
meta unpack unpack_bufr_values(numericValues) : no_copy,hidden;
|
||||
meta pack pack_bufr_values(numericValues) : no_copy,hidden;
|
||||
|
||||
section_padding section4Padding;
|
||||
position offsetEndSection4;
|
||||
|
|
|
@ -284,7 +284,6 @@ list( APPEND grib_api_srcs
|
|||
grib_dumper_class_bufr_decode_fortran.c
|
||||
grib_dumper_class_bufr_decode_python.c
|
||||
grib_dumper_class_json.c
|
||||
grib_dumper_class_xml.c
|
||||
grib_dumper_class_grib_encode_C.c
|
||||
grib_dumper_class_wmo.c
|
||||
grib_dumper_class.c
|
||||
|
@ -301,6 +300,7 @@ list( APPEND grib_api_srcs
|
|||
grib_itrie.c
|
||||
grib_rules.c
|
||||
grib_keys_iterator.c
|
||||
bufr_keys_iterator.c
|
||||
grib_parse_utils.c
|
||||
grib_query.c
|
||||
grib_scaling.c
|
||||
|
@ -348,7 +348,6 @@ list( APPEND grib_api_srcs
|
|||
grib_iterator_class_regular.c
|
||||
grib_expression.c
|
||||
grib_util.c
|
||||
compile.c
|
||||
functions.c
|
||||
grib_accessor_class.h
|
||||
grib_accessor_factory.h
|
||||
|
|
|
@ -299,7 +299,6 @@ libeccodes_la_prototypes= \
|
|||
grib_dumper_class_bufr_decode_fortran.c \
|
||||
grib_dumper_class_bufr_decode_python.c \
|
||||
grib_dumper_class_json.c \
|
||||
grib_dumper_class_xml.c \
|
||||
grib_dumper_class_grib_encode_C.c \
|
||||
grib_dumper_class_wmo.c \
|
||||
grib_dumper_class.c \
|
||||
|
@ -316,6 +315,7 @@ libeccodes_la_prototypes= \
|
|||
grib_itrie.c \
|
||||
grib_rules.c \
|
||||
grib_keys_iterator.c \
|
||||
bufr_keys_iterator.c \
|
||||
grib_parse_utils.c \
|
||||
grib_query.c \
|
||||
grib_scaling.c \
|
||||
|
@ -363,7 +363,6 @@ libeccodes_la_prototypes= \
|
|||
grib_iterator_class_regular.c \
|
||||
grib_expression.c \
|
||||
grib_util.c \
|
||||
compile.c \
|
||||
functions.c \
|
||||
codes_memfs.c \
|
||||
grib_api_version.c
|
||||
|
|
13
src/action.c
13
src/action.c
|
@ -201,16 +201,3 @@ void grib_xref_action_branch(FILE* out,grib_action* a,const char* path)
|
|||
}
|
||||
}
|
||||
|
||||
void grib_compile(grib_action* a, grib_compiler* compiler)
|
||||
{
|
||||
grib_action_class *c = a->cclass;
|
||||
init(c);
|
||||
if(c->compile) {
|
||||
c->compile(a,compiler);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "NO COMPILE METHOD '%s'\n", c->name);
|
||||
Assert(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ static void init_class (grib_action_class*);
|
|||
static void init (grib_action* d);
|
||||
static void dump (grib_action* d, FILE*,int);
|
||||
static void xref (grib_action* d, FILE* f,const char* path);
|
||||
static void compile (grib_action* a, grib_compiler* compiler);
|
||||
static void destroy (grib_context*,grib_action*);
|
||||
static int create_accessor(grib_section*,grib_action*,grib_loader*);
|
||||
static int notify_change(grib_action* a, grib_accessor* observer,grib_accessor* observed);
|
||||
|
@ -34,7 +33,6 @@ static grib_action_class _grib_action_class_NAME = {
|
|||
¬ify_change, /* notify_change */
|
||||
&reparse, /* reparse */
|
||||
&execute, /* execute */
|
||||
&compile, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_NAME = &_grib_action_class_NAME;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
IMPLEMENTS = create_accessor
|
||||
IMPLEMENTS = dump;xref
|
||||
IMPLEMENTS = destroy
|
||||
IMPLEMENTS = compile
|
||||
MEMBERS = char* target
|
||||
END_CLASS_DEF
|
||||
|
||||
|
@ -41,7 +40,6 @@ or edit "action.class" and rerun ./make_class.pl
|
|||
static void init_class (grib_action_class*);
|
||||
static void dump (grib_action* d, FILE*,int);
|
||||
static void xref (grib_action* d, FILE* f,const char* path);
|
||||
static void compile (grib_action* a, grib_compiler* compiler);
|
||||
static void destroy (grib_context*,grib_action*);
|
||||
static int create_accessor(grib_section*,grib_action*,grib_loader*);
|
||||
|
||||
|
@ -70,7 +68,6 @@ static grib_action_class _grib_action_class_alias = {
|
|||
0, /* notify_change */
|
||||
0, /* reparse */
|
||||
0, /* execute */
|
||||
&compile, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_alias = &_grib_action_class_alias;
|
||||
|
@ -102,30 +99,6 @@ grib_action* grib_action_create_alias(grib_context* context, const char* name, c
|
|||
return act;
|
||||
}
|
||||
|
||||
static void compile(grib_action* act, grib_compiler *compiler)
|
||||
{
|
||||
grib_action_alias* a = (grib_action_alias*)act;
|
||||
fprintf(compiler->out,"%s = grib_action_create_alias(ctx,",compiler->var);
|
||||
fprintf(compiler->out,"\"%s\",",act->name);
|
||||
if(a->target) {
|
||||
fprintf(compiler->out,"\"%s\",",a->target);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(compiler->out,"NULL,");
|
||||
}
|
||||
if(act->name_space) {
|
||||
fprintf(compiler->out,"\"%s\",",act->name_space);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(compiler->out,"NULL,");
|
||||
}
|
||||
grib_compile_flags(compiler, act->flags);
|
||||
fprintf(compiler->out,");");
|
||||
fprintf(compiler->out,"\n");
|
||||
}
|
||||
|
||||
static int same(const char* a,const char* b)
|
||||
{
|
||||
if(a == b) return 1;
|
||||
|
@ -184,7 +157,6 @@ static int create_accessor( grib_section* p, grib_action* act,grib_loader *h)
|
|||
return GRIB_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
/* if(self->target == NULL || (act->flags & GRIB_ACCESSOR_FLAG_OVERRIDE)) */
|
||||
y = grib_find_accessor_fast(p->h,act->name);
|
||||
|
||||
/* delete old alias if already defined */
|
||||
|
|
|
@ -68,7 +68,6 @@ static grib_action_class _grib_action_class_assert = {
|
|||
¬ify_change, /* notify_change */
|
||||
0, /* reparse */
|
||||
&execute, /* execute */
|
||||
0, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_assert = &_grib_action_class_assert;
|
||||
|
|
|
@ -61,7 +61,6 @@ static grib_action_class _grib_action_class_close = {
|
|||
0, /* notify_change */
|
||||
0, /* reparse */
|
||||
&execute, /* execute */
|
||||
0, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_close = &_grib_action_class_close;
|
||||
|
|
|
@ -78,7 +78,6 @@ static grib_action_class _grib_action_class_concept = {
|
|||
0, /* notify_change */
|
||||
0, /* reparse */
|
||||
0, /* execute */
|
||||
0, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_concept = &_grib_action_class_concept;
|
||||
|
@ -90,7 +89,6 @@ static void init_class(grib_action_class* c)
|
|||
c->notify_change = (*(c->super))->notify_change;
|
||||
c->reparse = (*(c->super))->reparse;
|
||||
c->execute = (*(c->super))->execute;
|
||||
c->compile = (*(c->super))->compile;
|
||||
}
|
||||
/* END_CLASS_IMP */
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
IMPLEMENTS = dump;xref
|
||||
IMPLEMENTS = destroy
|
||||
IMPLEMENTS = notify_change
|
||||
IMPLEMENTS = compile
|
||||
MEMBERS = long len
|
||||
MEMBERS = grib_arguments* params
|
||||
END_CLASS_DEF
|
||||
|
@ -43,7 +42,6 @@ or edit "action.class" and rerun ./make_class.pl
|
|||
static void init_class (grib_action_class*);
|
||||
static void dump (grib_action* d, FILE*,int);
|
||||
static void xref (grib_action* d, FILE* f,const char* path);
|
||||
static void compile (grib_action* a, grib_compiler* compiler);
|
||||
static void destroy (grib_context*,grib_action*);
|
||||
static int create_accessor(grib_section*,grib_action*,grib_loader*);
|
||||
static int notify_change(grib_action* a, grib_accessor* observer,grib_accessor* observed);
|
||||
|
@ -74,7 +72,6 @@ static grib_action_class _grib_action_class_gen = {
|
|||
¬ify_change, /* notify_change */
|
||||
0, /* reparse */
|
||||
0, /* execute */
|
||||
&compile, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_gen = &_grib_action_class_gen;
|
||||
|
@ -142,7 +139,6 @@ static void xref( grib_action* act, FILE* f,const char *path)
|
|||
F(GRIB_ACCESSOR_FLAG_CAN_BE_MISSING);
|
||||
F(GRIB_ACCESSOR_FLAG_HIDDEN);
|
||||
F(GRIB_ACCESSOR_FLAG_CONSTRAINT);
|
||||
F(GRIB_ACCESSOR_FLAG_OVERRIDE);
|
||||
F(GRIB_ACCESSOR_FLAG_NO_COPY);
|
||||
F(GRIB_ACCESSOR_FLAG_COPY_OK);
|
||||
F(GRIB_ACCESSOR_FLAG_FUNCTION);
|
||||
|
@ -208,33 +204,3 @@ static void destroy(grib_context* context,grib_action* act)
|
|||
grib_context_free_persistent(context, act->set);
|
||||
|
||||
}
|
||||
|
||||
static void compile(grib_action* act, grib_compiler* compiler)
|
||||
{
|
||||
grib_action_gen* a = (grib_action_gen*)act;
|
||||
fprintf(compiler->out,"%s = grib_action_create_gen(ctx,",compiler->var);
|
||||
fprintf(compiler->out,"\"%s\",",act->name);
|
||||
fprintf(compiler->out,"\"%s\",",act->op);
|
||||
fprintf(compiler->out,"%ld,",a->len);
|
||||
grib_compile_arguments(a->params, compiler);
|
||||
fprintf(compiler->out,",");
|
||||
grib_compile_arguments(act->default_value, compiler);
|
||||
fprintf(compiler->out,",");
|
||||
grib_compile_flags(compiler,act->flags);
|
||||
fprintf(compiler->out,",");
|
||||
if(act->name_space) {
|
||||
fprintf(compiler->out,"\"%s\",",act->name_space);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(compiler->out,"NULL,");
|
||||
}
|
||||
if(act->set) {
|
||||
fprintf(compiler->out,"\"%s\");",act->set);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(compiler->out,"NULL);");
|
||||
}
|
||||
fprintf(compiler->out,"\n");
|
||||
}
|
||||
|
|
|
@ -79,7 +79,6 @@ static grib_action_class _grib_action_class_hash_array = {
|
|||
0, /* notify_change */
|
||||
0, /* reparse */
|
||||
0, /* execute */
|
||||
0, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_hash_array = &_grib_action_class_hash_array;
|
||||
|
@ -91,7 +90,6 @@ static void init_class(grib_action_class* c)
|
|||
c->notify_change = (*(c->super))->notify_change;
|
||||
c->reparse = (*(c->super))->reparse;
|
||||
c->execute = (*(c->super))->execute;
|
||||
c->compile = (*(c->super))->compile;
|
||||
}
|
||||
/* END_CLASS_IMP */
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
IMPLEMENTS = dump
|
||||
IMPLEMENTS = destroy
|
||||
IMPLEMENTS = xref
|
||||
IMPLEMENTS = compile
|
||||
IMPLEMENTS = reparse;execute
|
||||
MEMBERS = grib_expression *expression
|
||||
MEMBERS = grib_action *block_true
|
||||
|
@ -47,7 +46,6 @@ or edit "action.class" and rerun ./make_class.pl
|
|||
static void init_class (grib_action_class*);
|
||||
static void dump (grib_action* d, FILE*,int);
|
||||
static void xref (grib_action* d, FILE* f,const char* path);
|
||||
static void compile (grib_action* a, grib_compiler* compiler);
|
||||
static void destroy (grib_context*,grib_action*);
|
||||
static int create_accessor(grib_section*,grib_action*,grib_loader*);
|
||||
static grib_action* reparse(grib_action* a,grib_accessor* acc,int *doit);
|
||||
|
@ -83,7 +81,6 @@ static grib_action_class _grib_action_class_if = {
|
|||
0, /* notify_change */
|
||||
&reparse, /* reparse */
|
||||
&execute, /* execute */
|
||||
&compile, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_if = &_grib_action_class_if;
|
||||
|
@ -132,27 +129,6 @@ grib_action* grib_action_create_if( grib_context* context,
|
|||
return act;
|
||||
}
|
||||
|
||||
static void compile(grib_action* act, grib_compiler *compiler)
|
||||
{
|
||||
grib_action_if* a = (grib_action_if*)act;
|
||||
char t[80];
|
||||
char f[80];
|
||||
|
||||
if(a->block_true)
|
||||
grib_compile_action_branch(a->block_true, compiler,t);
|
||||
else
|
||||
strcpy(t,"NULL");
|
||||
|
||||
if(a->block_false)
|
||||
grib_compile_action_branch(a->block_false, compiler,f);
|
||||
else
|
||||
strcpy(f,"NULL");
|
||||
|
||||
fprintf(compiler->out,"%s = grib_action_create_if(ctx,",compiler->var);
|
||||
grib_compile_expression(a->expression, compiler);
|
||||
fprintf(compiler->out,",%s,%s,%d);\n", t,f,a->transient);
|
||||
}
|
||||
|
||||
static int create_accessor( grib_section* p, grib_action* act, grib_loader *h)
|
||||
{
|
||||
grib_action_if* a = (grib_action_if*)act;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
CLASS = action
|
||||
SUPER = action_class_section
|
||||
IMPLEMENTS = create_accessor
|
||||
IMPLEMENTS = dump;compile
|
||||
IMPLEMENTS = dump
|
||||
IMPLEMENTS = destroy
|
||||
IMPLEMENTS = reparse
|
||||
MEMBERS = grib_expression *expression
|
||||
|
@ -42,7 +42,6 @@ or edit "action.class" and rerun ./make_class.pl
|
|||
|
||||
static void init_class (grib_action_class*);
|
||||
static void dump (grib_action* d, FILE*,int);
|
||||
static void compile (grib_action* a, grib_compiler* compiler);
|
||||
static void destroy (grib_context*,grib_action*);
|
||||
static int create_accessor(grib_section*,grib_action*,grib_loader*);
|
||||
static grib_action* reparse(grib_action* a,grib_accessor* acc,int *doit);
|
||||
|
@ -75,7 +74,6 @@ static grib_action_class _grib_action_class_list = {
|
|||
0, /* notify_change */
|
||||
&reparse, /* reparse */
|
||||
0, /* execute */
|
||||
&compile, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_list = &_grib_action_class_list;
|
||||
|
@ -160,22 +158,6 @@ grib_action* grib_action_create_list( grib_context* context, const char* name, g
|
|||
return act;
|
||||
}
|
||||
|
||||
static void compile(grib_action* act, grib_compiler *compiler)
|
||||
{
|
||||
grib_action_list* a = (grib_action_list*)act;
|
||||
char b[80];
|
||||
|
||||
if(a->block_list)
|
||||
grib_compile_action_branch(a->block_list, compiler,b);
|
||||
else
|
||||
strcpy(b,"NULL");
|
||||
|
||||
fprintf(compiler->out,"%s = grib_action_create_list(ctx,",compiler->var);
|
||||
fprintf(compiler->out,"\"%s\",", act->name);
|
||||
grib_compile_expression(a->expression, compiler);
|
||||
fprintf(compiler->out,",%s);\n",b);
|
||||
}
|
||||
|
||||
static grib_action* reparse(grib_action* a,grib_accessor* acc,int *doit)
|
||||
{
|
||||
grib_action_list* self = ( grib_action_list*)a;
|
||||
|
|
|
@ -68,7 +68,6 @@ static grib_action_class _grib_action_class_meta = {
|
|||
0, /* notify_change */
|
||||
0, /* reparse */
|
||||
&execute, /* execute */
|
||||
0, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_meta = &_grib_action_class_meta;
|
||||
|
@ -79,7 +78,6 @@ static void init_class(grib_action_class* c)
|
|||
c->create_accessor = (*(c->super))->create_accessor;
|
||||
c->notify_change = (*(c->super))->notify_change;
|
||||
c->reparse = (*(c->super))->reparse;
|
||||
c->compile = (*(c->super))->compile;
|
||||
}
|
||||
/* END_CLASS_IMP */
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
START_CLASS_DEF
|
||||
CLASS = action
|
||||
IMPLEMENTS = dump;xref;compile
|
||||
IMPLEMENTS = dump;xref
|
||||
IMPLEMENTS = create_accessor
|
||||
IMPLEMENTS = destroy
|
||||
MEMBERS = long flags
|
||||
|
@ -40,7 +40,6 @@ or edit "action.class" and rerun ./make_class.pl
|
|||
static void init_class (grib_action_class*);
|
||||
static void dump (grib_action* d, FILE*,int);
|
||||
static void xref (grib_action* d, FILE* f,const char* path);
|
||||
static void compile (grib_action* a, grib_compiler* compiler);
|
||||
static void destroy (grib_context*,grib_action*);
|
||||
static int create_accessor(grib_section*,grib_action*,grib_loader*);
|
||||
|
||||
|
@ -70,7 +69,6 @@ static grib_action_class _grib_action_class_modify = {
|
|||
0, /* notify_change */
|
||||
0, /* reparse */
|
||||
0, /* execute */
|
||||
&compile, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_modify = &_grib_action_class_modify;
|
||||
|
@ -103,15 +101,6 @@ grib_action* grib_action_create_modify( grib_context* context,
|
|||
return act;
|
||||
}
|
||||
|
||||
static void compile(grib_action* act, grib_compiler *compiler)
|
||||
{
|
||||
fprintf(compiler->out,"%s = grib_action_create_modify(ctx,",compiler->var);
|
||||
fprintf(compiler->out,"\"%s\",",act->name);
|
||||
grib_compile_flags(compiler, act->flags);
|
||||
fprintf(compiler->out,");");
|
||||
fprintf(compiler->out,"\n");
|
||||
}
|
||||
|
||||
static void dump(grib_action* act, FILE* f, int lvl)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
START_CLASS_DEF
|
||||
CLASS = action
|
||||
IMPLEMENTS = dump;destroy;xref;execute;compile
|
||||
IMPLEMENTS = dump;destroy;xref;execute
|
||||
END_CLASS_DEF
|
||||
|
||||
*/
|
||||
|
@ -36,7 +36,6 @@ or edit "action.class" and rerun ./make_class.pl
|
|||
static void init_class (grib_action_class*);
|
||||
static void dump (grib_action* d, FILE*,int);
|
||||
static void xref (grib_action* d, FILE* f,const char* path);
|
||||
static void compile (grib_action* a, grib_compiler* compiler);
|
||||
static void destroy (grib_context*,grib_action*);
|
||||
static int execute(grib_action* a,grib_handle* h);
|
||||
|
||||
|
@ -64,7 +63,6 @@ static grib_action_class _grib_action_class_noop = {
|
|||
0, /* notify_change */
|
||||
0, /* reparse */
|
||||
&execute, /* execute */
|
||||
&compile, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_noop = &_grib_action_class_noop;
|
||||
|
@ -94,14 +92,6 @@ grib_action* grib_action_create_noop( grib_context* context,const char* fname)
|
|||
return act;
|
||||
}
|
||||
|
||||
static void compile(grib_action* act, grib_compiler *compiler)
|
||||
{
|
||||
fprintf(compiler->out,"%s = grib_action_create_noop(ctx,",compiler->var);
|
||||
fprintf(compiler->out,"\"%s\"",act->name);
|
||||
fprintf(compiler->out,");");
|
||||
fprintf(compiler->out,"\n");
|
||||
}
|
||||
|
||||
static void dump(grib_action* act, FILE* f, int lvl)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -67,7 +67,6 @@ static grib_action_class _grib_action_class_print = {
|
|||
0, /* notify_change */
|
||||
0, /* reparse */
|
||||
&execute, /* execute */
|
||||
0, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_print = &_grib_action_class_print;
|
||||
|
|
|
@ -67,7 +67,6 @@ static grib_action_class _grib_action_class_put = {
|
|||
0, /* notify_change */
|
||||
0, /* reparse */
|
||||
0, /* execute */
|
||||
0, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_put = &_grib_action_class_put;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
CLASS = action
|
||||
IMPLEMENTS = create_accessor
|
||||
IMPLEMENTS = dump
|
||||
IMPLEMENTS = destroy; xref; compile
|
||||
IMPLEMENTS = destroy; xref
|
||||
MEMBERS = grib_arguments* args
|
||||
END_CLASS_DEF
|
||||
|
||||
|
@ -39,7 +39,6 @@ or edit "action.class" and rerun ./make_class.pl
|
|||
static void init_class (grib_action_class*);
|
||||
static void dump (grib_action* d, FILE*,int);
|
||||
static void xref (grib_action* d, FILE* f,const char* path);
|
||||
static void compile (grib_action* a, grib_compiler* compiler);
|
||||
static void destroy (grib_context*,grib_action*);
|
||||
static int create_accessor(grib_section*,grib_action*,grib_loader*);
|
||||
|
||||
|
@ -68,7 +67,6 @@ static grib_action_class _grib_action_class_remove = {
|
|||
0, /* notify_change */
|
||||
0, /* reparse */
|
||||
0, /* execute */
|
||||
&compile, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_remove = &_grib_action_class_remove;
|
||||
|
@ -93,14 +91,6 @@ grib_action* grib_action_create_remove( grib_context* context, grib_arguments *a
|
|||
return act;
|
||||
}
|
||||
|
||||
static void compile(grib_action* act, grib_compiler* compiler)
|
||||
{
|
||||
grib_action_remove* a = (grib_action_remove*)act;
|
||||
fprintf(compiler->out,"%s = grib_action_create_remove(ctx,",compiler->var);
|
||||
grib_compile_arguments(a->args,compiler);
|
||||
fprintf(compiler->out,");\n");
|
||||
}
|
||||
|
||||
static void remove_accessor(grib_accessor *a)
|
||||
{
|
||||
grib_section* s = NULL;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
CLASS = action
|
||||
IMPLEMENTS = create_accessor
|
||||
IMPLEMENTS = dump
|
||||
IMPLEMENTS = destroy; xref; compile
|
||||
IMPLEMENTS = destroy; xref
|
||||
MEMBERS = char* the_old
|
||||
MEMBERS = char* the_new
|
||||
END_CLASS_DEF
|
||||
|
@ -40,7 +40,6 @@ or edit "action.class" and rerun ./make_class.pl
|
|||
static void init_class (grib_action_class*);
|
||||
static void dump (grib_action* d, FILE*,int);
|
||||
static void xref (grib_action* d, FILE* f,const char* path);
|
||||
static void compile (grib_action* a, grib_compiler* compiler);
|
||||
static void destroy (grib_context*,grib_action*);
|
||||
static int create_accessor(grib_section*,grib_action*,grib_loader*);
|
||||
|
||||
|
@ -70,7 +69,6 @@ static grib_action_class _grib_action_class_rename = {
|
|||
0, /* notify_change */
|
||||
0, /* reparse */
|
||||
0, /* execute */
|
||||
&compile, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_rename = &_grib_action_class_rename;
|
||||
|
@ -96,11 +94,6 @@ grib_action* grib_action_create_rename( grib_context* context, char* the_old, ch
|
|||
return act;
|
||||
}
|
||||
|
||||
static void compile(grib_action* act, grib_compiler* compiler)
|
||||
{
|
||||
Assert(0);
|
||||
}
|
||||
|
||||
static void rename_accessor(grib_accessor *a,char* name)
|
||||
{
|
||||
int id;
|
||||
|
|
|
@ -66,7 +66,6 @@ static grib_action_class _grib_action_class_section = {
|
|||
¬ify_change, /* notify_change */
|
||||
&reparse, /* reparse */
|
||||
0, /* execute */
|
||||
0, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_section = &_grib_action_class_section;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
START_CLASS_DEF
|
||||
CLASS = action
|
||||
IMPLEMENTS = dump;xref;compile
|
||||
IMPLEMENTS = dump;xref
|
||||
IMPLEMENTS = destroy;execute
|
||||
MEMBERS = grib_expression *expression
|
||||
MEMBERS = char *name
|
||||
|
@ -39,7 +39,6 @@ or edit "action.class" and rerun ./make_class.pl
|
|||
static void init_class (grib_action_class*);
|
||||
static void dump (grib_action* d, FILE*,int);
|
||||
static void xref (grib_action* d, FILE* f,const char* path);
|
||||
static void compile (grib_action* a, grib_compiler* compiler);
|
||||
static void destroy (grib_context*,grib_action*);
|
||||
static int execute(grib_action* a,grib_handle* h);
|
||||
|
||||
|
@ -70,7 +69,6 @@ static grib_action_class _grib_action_class_set = {
|
|||
0, /* notify_change */
|
||||
0, /* reparse */
|
||||
&execute, /* execute */
|
||||
&compile, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_set = &_grib_action_class_set;
|
||||
|
@ -106,16 +104,6 @@ grib_action* grib_action_create_set( grib_context* context,
|
|||
return act;
|
||||
}
|
||||
|
||||
static void compile(grib_action* act, grib_compiler *compiler)
|
||||
{
|
||||
grib_action_set* a = (grib_action_set*)act;
|
||||
|
||||
fprintf(compiler->out,"%s = grib_action_create_set(ctx,",compiler->var);
|
||||
fprintf(compiler->out,"\"%s\",", a->name);
|
||||
grib_compile_expression(a->expression, compiler);
|
||||
fprintf(compiler->out,",%d);\n", a->nofail);
|
||||
}
|
||||
|
||||
static int execute(grib_action* a, grib_handle *h)
|
||||
{
|
||||
int ret=0;
|
||||
|
|
|
@ -67,7 +67,6 @@ static grib_action_class _grib_action_class_set_darray = {
|
|||
0, /* notify_change */
|
||||
0, /* reparse */
|
||||
&execute, /* execute */
|
||||
0, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_set_darray = &_grib_action_class_set_darray;
|
||||
|
|
|
@ -67,7 +67,6 @@ static grib_action_class _grib_action_class_set_iarray = {
|
|||
0, /* notify_change */
|
||||
0, /* reparse */
|
||||
&execute, /* execute */
|
||||
0, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_set_iarray = &_grib_action_class_set_iarray;
|
||||
|
|
|
@ -64,7 +64,6 @@ static grib_action_class _grib_action_class_set_missing = {
|
|||
0, /* notify_change */
|
||||
0, /* reparse */
|
||||
&execute, /* execute */
|
||||
0, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_set_missing = &_grib_action_class_set_missing;
|
||||
|
|
|
@ -67,7 +67,6 @@ static grib_action_class _grib_action_class_set_sarray = {
|
|||
0, /* notify_change */
|
||||
0, /* reparse */
|
||||
&execute, /* execute */
|
||||
0, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_set_sarray = &_grib_action_class_set_sarray;
|
||||
|
|
|
@ -73,7 +73,6 @@ static grib_action_class _grib_action_class_switch = {
|
|||
0, /* notify_change */
|
||||
0, /* reparse */
|
||||
&execute, /* execute */
|
||||
0, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_switch = &_grib_action_class_switch;
|
||||
|
@ -84,7 +83,6 @@ static void init_class(grib_action_class* c)
|
|||
c->create_accessor = (*(c->super))->create_accessor;
|
||||
c->notify_change = (*(c->super))->notify_change;
|
||||
c->reparse = (*(c->super))->reparse;
|
||||
c->compile = (*(c->super))->compile;
|
||||
}
|
||||
/* END_CLASS_IMP */
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
IMPLEMENTS = dump
|
||||
IMPLEMENTS = destroy
|
||||
IMPLEMENTS = reparse
|
||||
IMPLEMENTS = compile
|
||||
MEMBERS = int nofail
|
||||
MEMBERS = char* arg
|
||||
END_CLASS_DEF
|
||||
|
@ -44,7 +43,6 @@ or edit "action.class" and rerun ./make_class.pl
|
|||
|
||||
static void init_class (grib_action_class*);
|
||||
static void dump (grib_action* d, FILE*,int);
|
||||
static void compile (grib_action* a, grib_compiler* compiler);
|
||||
static void destroy (grib_context*,grib_action*);
|
||||
static int create_accessor(grib_section*,grib_action*,grib_loader*);
|
||||
static grib_action* reparse(grib_action* a,grib_accessor* acc,int *doit);
|
||||
|
@ -77,7 +75,6 @@ static grib_action_class _grib_action_class_template = {
|
|||
0, /* notify_change */
|
||||
&reparse, /* reparse */
|
||||
0, /* execute */
|
||||
&compile, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_template = &_grib_action_class_template;
|
||||
|
@ -108,22 +105,6 @@ grib_action* grib_action_create_template( grib_context* context,int nofail,const
|
|||
return act;
|
||||
}
|
||||
|
||||
static void compile(grib_action* act, grib_compiler *compiler)
|
||||
{
|
||||
grib_action_template* a = (grib_action_template*)act;
|
||||
fprintf(compiler->out,"%s = grib_action_create_template(ctx,", compiler->var);
|
||||
fprintf(compiler->out,"%d,",a->nofail);
|
||||
fprintf(compiler->out,"\"%s\",",act->name);
|
||||
if(a->arg) {
|
||||
fprintf(compiler->out,"\"%s\");",a->arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(compiler->out,"NULL);");
|
||||
}
|
||||
fprintf(compiler->out,"\n");
|
||||
}
|
||||
|
||||
static void dump( grib_action* act, FILE* f, int lvl)
|
||||
{
|
||||
grib_action_template* a = ( grib_action_template*)act;
|
||||
|
|
|
@ -72,7 +72,6 @@ static grib_action_class _grib_action_class_transient_darray = {
|
|||
0, /* notify_change */
|
||||
0, /* reparse */
|
||||
&execute, /* execute */
|
||||
0, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_transient_darray = &_grib_action_class_transient_darray;
|
||||
|
@ -82,7 +81,6 @@ static void init_class(grib_action_class* c)
|
|||
c->create_accessor = (*(c->super))->create_accessor;
|
||||
c->notify_change = (*(c->super))->notify_change;
|
||||
c->reparse = (*(c->super))->reparse;
|
||||
c->compile = (*(c->super))->compile;
|
||||
}
|
||||
/* END_CLASS_IMP */
|
||||
|
||||
|
|
|
@ -75,7 +75,6 @@ static grib_action_class _grib_action_class_trigger = {
|
|||
0, /* notify_change */
|
||||
&reparse, /* reparse */
|
||||
0, /* execute */
|
||||
0, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_trigger = &_grib_action_class_trigger;
|
||||
|
@ -85,7 +84,6 @@ static void init_class(grib_action_class* c)
|
|||
c->xref = (*(c->super))->xref;
|
||||
c->notify_change = (*(c->super))->notify_change;
|
||||
c->execute = (*(c->super))->execute;
|
||||
c->compile = (*(c->super))->compile;
|
||||
}
|
||||
/* END_CLASS_IMP */
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
CLASS = action
|
||||
SUPER = action_class_gen
|
||||
IMPLEMENTS = execute
|
||||
IMPLEMENTS = compile
|
||||
END_CLASS_DEF
|
||||
|
||||
*/
|
||||
|
@ -36,7 +35,6 @@ or edit "action.class" and rerun ./make_class.pl
|
|||
*/
|
||||
|
||||
static void init_class (grib_action_class*);
|
||||
static void compile (grib_action* a, grib_compiler* compiler);
|
||||
static int execute(grib_action* a,grib_handle* h);
|
||||
|
||||
|
||||
|
@ -67,7 +65,6 @@ static grib_action_class _grib_action_class_variable = {
|
|||
0, /* notify_change */
|
||||
0, /* reparse */
|
||||
&execute, /* execute */
|
||||
&compile, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_variable = &_grib_action_class_variable;
|
||||
|
@ -110,26 +107,4 @@ static int execute(grib_action* a, grib_handle *h)
|
|||
return grib_create_accessor(h->root, a, NULL );
|
||||
}
|
||||
|
||||
static void compile(grib_action* act, grib_compiler *compiler)
|
||||
{
|
||||
grib_action_variable* a = (grib_action_variable*)act;
|
||||
fprintf(compiler->out,"%s = grib_action_create_variable(ctx,",compiler->var);
|
||||
fprintf(compiler->out,"\"%s\",",act->name);
|
||||
fprintf(compiler->out,"\"%s\",",act->op);
|
||||
fprintf(compiler->out,"%ld,",a->len);
|
||||
fprintf(compiler->out,"NULL,"); /* a->params */
|
||||
fprintf(compiler->out,"NULL,"); /* a->default_value */
|
||||
grib_compile_flags(compiler, act->flags);
|
||||
fprintf(compiler->out,",");
|
||||
if(act->name_space) {
|
||||
fprintf(compiler->out,"\"%s\");",act->name_space);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(compiler->out,"NULL);");
|
||||
}
|
||||
fprintf(compiler->out,"\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
START_CLASS_DEF
|
||||
CLASS = action
|
||||
IMPLEMENTS = create_accessor
|
||||
IMPLEMENTS = dump;xref;compile
|
||||
IMPLEMENTS = dump;xref
|
||||
IMPLEMENTS = destroy;notify_change
|
||||
MEMBERS = grib_expression *expression
|
||||
MEMBERS = grib_action *block_true
|
||||
|
@ -41,7 +41,6 @@ or edit "action.class" and rerun ./make_class.pl
|
|||
static void init_class (grib_action_class*);
|
||||
static void dump (grib_action* d, FILE*,int);
|
||||
static void xref (grib_action* d, FILE* f,const char* path);
|
||||
static void compile (grib_action* a, grib_compiler* compiler);
|
||||
static void destroy (grib_context*,grib_action*);
|
||||
static int create_accessor(grib_section*,grib_action*,grib_loader*);
|
||||
static int notify_change(grib_action* a, grib_accessor* observer,grib_accessor* observed);
|
||||
|
@ -74,7 +73,6 @@ static grib_action_class _grib_action_class_when = {
|
|||
¬ify_change, /* notify_change */
|
||||
0, /* reparse */
|
||||
0, /* execute */
|
||||
&compile, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_when = &_grib_action_class_when;
|
||||
|
@ -111,27 +109,6 @@ grib_action* grib_action_create_when( grib_context* context,
|
|||
return act;
|
||||
}
|
||||
|
||||
static void compile(grib_action* act, grib_compiler *compiler)
|
||||
{
|
||||
grib_action_when* a = (grib_action_when*)act;
|
||||
char t[80];
|
||||
char f[80];
|
||||
|
||||
if(a->block_true)
|
||||
grib_compile_action_branch(a->block_true, compiler,t);
|
||||
else
|
||||
strcpy(t,"NULL");
|
||||
|
||||
if(a->block_false)
|
||||
grib_compile_action_branch(a->block_false, compiler,f);
|
||||
else
|
||||
strcpy(f,"NULL");
|
||||
|
||||
fprintf(compiler->out,"%s = grib_action_create_when(ctx,",compiler->var);
|
||||
grib_compile_expression(a->expression, compiler);
|
||||
fprintf(compiler->out,",%s,%s);\n", t,f);
|
||||
}
|
||||
|
||||
static int create_accessor(grib_section* p, grib_action* act,grib_loader *h)
|
||||
{
|
||||
grib_action_when* self = (grib_action_when*)act;
|
||||
|
|
|
@ -67,7 +67,6 @@ static grib_action_class _grib_action_class_while = {
|
|||
0, /* notify_change */
|
||||
0, /* reparse */
|
||||
0, /* execute */
|
||||
0, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_while = &_grib_action_class_while;
|
||||
|
@ -78,7 +77,6 @@ static void init_class(grib_action_class* c)
|
|||
c->notify_change = (*(c->super))->notify_change;
|
||||
c->reparse = (*(c->super))->reparse;
|
||||
c->execute = (*(c->super))->execute;
|
||||
c->compile = (*(c->super))->compile;
|
||||
}
|
||||
/* END_CLASS_IMP */
|
||||
|
||||
|
|
|
@ -68,7 +68,6 @@ static grib_action_class _grib_action_class_write = {
|
|||
0, /* notify_change */
|
||||
0, /* reparse */
|
||||
&execute, /* execute */
|
||||
0, /* compile */
|
||||
};
|
||||
|
||||
grib_action_class* grib_action_class_write = &_grib_action_class_write;
|
||||
|
|
|
@ -0,0 +1,214 @@
|
|||
/*
|
||||
* Copyright 2005-2016 ECMWF.
|
||||
*
|
||||
* This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
|
||||
GRIB_INLINE static int grib_inline_strcmp(const char* a,const char* b)
|
||||
{
|
||||
if (*a != *b) return 1;
|
||||
while((*a!=0 && *b!=0) && *(a) == *(b) ) {a++;b++;}
|
||||
return (*a==0 && *b==0) ? 0 : 1;
|
||||
}
|
||||
|
||||
grib_keys_iterator* bufr_keys_iterator_new(grib_handle* h)
|
||||
{
|
||||
grib_keys_iterator* ki=NULL;
|
||||
|
||||
if (!h) return NULL;
|
||||
|
||||
ki= (grib_keys_iterator*)grib_context_malloc_clear(h->context,sizeof(grib_keys_iterator));
|
||||
if (!ki) return NULL;
|
||||
|
||||
ki->filter_flags = GRIB_KEYS_ITERATOR_DUMP_ONLY;
|
||||
ki->handle = h;
|
||||
ki->i_curr_attribute=0;
|
||||
|
||||
ki->at_start = 1;
|
||||
ki->match = 0;
|
||||
|
||||
if(ki->seen==NULL ) ki->seen = grib_trie_new(h->context);
|
||||
|
||||
return ki;
|
||||
}
|
||||
|
||||
static void mark_seen(grib_keys_iterator* ki,const char* name)
|
||||
{
|
||||
int* r=(int*)grib_trie_get(ki->seen,name);
|
||||
|
||||
if (r) (*r)++;
|
||||
else {
|
||||
r=grib_context_malloc(ki->handle->context,sizeof(int));
|
||||
*r=1;
|
||||
grib_trie_insert(ki->seen,name,(void*)r);
|
||||
}
|
||||
}
|
||||
|
||||
static int was_seen(grib_keys_iterator* ki,const char* name)
|
||||
{
|
||||
return grib_trie_get(ki->seen,name) != NULL;
|
||||
}
|
||||
|
||||
int bufr_keys_iterator_rewind(grib_keys_iterator* ki)
|
||||
{
|
||||
ki->at_start = 1;
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
||||
static int skip(grib_keys_iterator* kiter)
|
||||
{
|
||||
/* TODO: set the section to hidden, to speed up that */
|
||||
/* if(grib_get_sub_section(kiter->current)) */
|
||||
kiter->match = 0;
|
||||
if(kiter->current->sub_section)
|
||||
return 1;
|
||||
|
||||
if(kiter->current->flags & GRIB_ACCESSOR_FLAG_HIDDEN)
|
||||
return 1;
|
||||
|
||||
if((kiter->filter_flags & GRIB_KEYS_ITERATOR_DUMP_ONLY)!=0 && (kiter->current->flags & GRIB_ACCESSOR_FLAG_DUMP)!=0 &&
|
||||
(kiter->current->flags & GRIB_ACCESSOR_FLAG_READ_ONLY)==0 && (kiter->current->flags & GRIB_ACCESSOR_FLAG_HIDDEN)==0) {
|
||||
mark_seen(kiter,kiter->current->name);
|
||||
return 0;
|
||||
} else return 1;
|
||||
|
||||
if(kiter->current->flags & kiter->accessor_flags)
|
||||
return 1;
|
||||
|
||||
if((kiter->filter_flags & GRIB_KEYS_ITERATOR_SKIP_COMPUTED) && kiter->current->length == 0)
|
||||
return 1;
|
||||
|
||||
if((kiter->filter_flags & GRIB_KEYS_ITERATOR_SKIP_CODED) && kiter->current->length != 0)
|
||||
return 1;
|
||||
|
||||
if(kiter->filter_flags & GRIB_KEYS_ITERATOR_SKIP_DUPLICATES) {
|
||||
if(was_seen(kiter,kiter->current->name)!=0)
|
||||
return 1;
|
||||
}
|
||||
|
||||
mark_seen(kiter,kiter->current->name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int next_attribute(grib_keys_iterator* kiter)
|
||||
{
|
||||
int *r=0;
|
||||
int i_curr_attribute;
|
||||
if (!kiter->current) return 0;
|
||||
if (!kiter->attributes) {
|
||||
kiter->attributes=kiter->current->attributes;
|
||||
kiter->prefix=0;
|
||||
kiter->i_curr_attribute=0;
|
||||
}
|
||||
i_curr_attribute=kiter->i_curr_attribute-1;
|
||||
|
||||
while (kiter->i_curr_attribute < MAX_ACCESSOR_ATTRIBUTES && kiter->attributes[kiter->i_curr_attribute] ) {
|
||||
if ((kiter->attributes[kiter->i_curr_attribute]->flags & GRIB_ACCESSOR_FLAG_DUMP) != 0
|
||||
|| (kiter->attributes[kiter->i_curr_attribute]->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) ==0) break;
|
||||
kiter->i_curr_attribute++;
|
||||
}
|
||||
|
||||
if (kiter->attributes[kiter->i_curr_attribute]) {
|
||||
if (!kiter->prefix) {
|
||||
kiter->prefix=grib_context_malloc_clear(kiter->current->context,strlen(kiter->current->name)+10);
|
||||
r=(int*)grib_trie_get(kiter->seen,kiter->current->name);
|
||||
sprintf(kiter->prefix,"#%d#%s",*r,kiter->current->name);
|
||||
}
|
||||
kiter->i_curr_attribute++;
|
||||
return 1;
|
||||
} else {
|
||||
char* prefix=0;
|
||||
if (!kiter->prefix) return 0;
|
||||
if (!kiter->attributes[i_curr_attribute]) {
|
||||
kiter->prefix=0;
|
||||
return 0;
|
||||
}
|
||||
prefix=grib_context_malloc_clear(kiter->current->context,strlen(kiter->prefix)+strlen(kiter->attributes[i_curr_attribute]->name)+3);
|
||||
sprintf(prefix,"%s->%s",kiter->prefix,kiter->attributes[i_curr_attribute]->name);
|
||||
grib_context_free(kiter->current->context,kiter->prefix);
|
||||
kiter->prefix=prefix;
|
||||
kiter->attributes=kiter->attributes[i_curr_attribute]->attributes;
|
||||
kiter->i_curr_attribute=0;
|
||||
return next_attribute(kiter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int bufr_keys_iterator_next(grib_keys_iterator* kiter)
|
||||
{
|
||||
if(kiter->at_start)
|
||||
{
|
||||
kiter->current = kiter->handle->root->block->first;
|
||||
kiter->at_start = 0;
|
||||
kiter->i_curr_attribute=0;
|
||||
kiter->prefix=0;
|
||||
kiter->attributes=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (next_attribute(kiter)) {
|
||||
return 1;
|
||||
} else {
|
||||
kiter->current = grib_next_accessor(kiter->current);
|
||||
kiter->attributes=0;
|
||||
if (kiter->prefix) {
|
||||
grib_context_free(kiter->current->context,kiter->prefix);
|
||||
kiter->prefix=0;
|
||||
}
|
||||
kiter->i_curr_attribute=0;
|
||||
}
|
||||
}
|
||||
|
||||
while(kiter->current && skip(kiter))
|
||||
kiter->current = grib_next_accessor(kiter->current);
|
||||
|
||||
return kiter->current != NULL;
|
||||
}
|
||||
|
||||
char* bufr_keys_iterator_get_name(grib_keys_iterator* kiter)
|
||||
{
|
||||
int *r=0;
|
||||
char* ret=0;
|
||||
Assert(kiter->current);
|
||||
|
||||
if (kiter->prefix) {
|
||||
int iattribute=kiter->i_curr_attribute-1;
|
||||
ret=grib_context_malloc_clear(kiter->handle->context,strlen(kiter->prefix)+strlen(kiter->attributes[iattribute]->name)+10);
|
||||
sprintf(ret,"%s->%s",kiter->prefix,kiter->attributes[iattribute]->name);
|
||||
} else {
|
||||
ret=grib_context_malloc_clear(kiter->handle->context,strlen(kiter->current->name)+10);
|
||||
|
||||
if (kiter->current->flags & GRIB_ACCESSOR_FLAG_BUFR_DATA) {
|
||||
r=(int*)grib_trie_get(kiter->seen,kiter->current->name);
|
||||
sprintf(ret,"#%d#%s",*r,kiter->current->name);
|
||||
} else {
|
||||
sprintf(ret,"%s",kiter->current->name);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
grib_accessor* bufr_keys_iterator_get_accessor(grib_keys_iterator* kiter)
|
||||
{
|
||||
return kiter->current;
|
||||
}
|
||||
|
||||
int bufr_keys_iterator_delete( grib_keys_iterator* kiter)
|
||||
{
|
||||
if (kiter) {
|
||||
if(kiter->seen)
|
||||
grib_trie_delete(kiter->seen);
|
||||
if (kiter->name_space)
|
||||
grib_context_free(kiter->handle->context,kiter->name_space);
|
||||
grib_context_free(kiter->handle->context,kiter);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
105
src/compile.c
105
src/compile.c
|
@ -1,105 +0,0 @@
|
|||
/*
|
||||
* Copyright 2005-2016 ECMWF.
|
||||
*
|
||||
* This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
|
||||
/***************************************************************************
|
||||
* Jean Baptiste Filippi - 01.11.2005 *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
|
||||
|
||||
#define COMPILE_FLAGS(z) if(flags&z) { flags ^= ~z; fprintf(c->out,"%s%s",sep,#z);sep="|"; }
|
||||
|
||||
void grib_compile_flags(grib_compiler* c,long flags)
|
||||
{
|
||||
char *sep = "";
|
||||
|
||||
fprintf(c->out,"0x%ld",flags);
|
||||
return;
|
||||
|
||||
if(flags == 0) {
|
||||
fprintf(c->out,"0");
|
||||
return;
|
||||
}
|
||||
|
||||
COMPILE_FLAGS(GRIB_ACCESSOR_FLAG_READ_ONLY);
|
||||
COMPILE_FLAGS(GRIB_ACCESSOR_FLAG_DUMP);
|
||||
COMPILE_FLAGS(GRIB_ACCESSOR_FLAG_EDITION_SPECIFIC);
|
||||
COMPILE_FLAGS(GRIB_ACCESSOR_FLAG_CAN_BE_MISSING);
|
||||
COMPILE_FLAGS(GRIB_ACCESSOR_FLAG_HIDDEN);
|
||||
COMPILE_FLAGS(GRIB_ACCESSOR_FLAG_CONSTRAINT);
|
||||
COMPILE_FLAGS(GRIB_ACCESSOR_FLAG_OVERRIDE);
|
||||
COMPILE_FLAGS(GRIB_ACCESSOR_FLAG_NO_COPY);
|
||||
COMPILE_FLAGS(GRIB_ACCESSOR_FLAG_COPY_OK);
|
||||
COMPILE_FLAGS(GRIB_ACCESSOR_FLAG_FUNCTION);
|
||||
COMPILE_FLAGS(GRIB_ACCESSOR_FLAG_DATA);
|
||||
COMPILE_FLAGS(GRIB_ACCESSOR_FLAG_NO_FAIL);
|
||||
COMPILE_FLAGS(GRIB_ACCESSOR_FLAG_TRANSIENT);
|
||||
COMPILE_FLAGS(GRIB_ACCESSOR_FLAG_STRING_TYPE);
|
||||
COMPILE_FLAGS(GRIB_ACCESSOR_FLAG_LONG_TYPE);
|
||||
COMPILE_FLAGS(GRIB_ACCESSOR_FLAG_LOWERCASE);
|
||||
|
||||
if(flags) {
|
||||
fprintf(stderr,"Unknown flags %lx\n", flags);
|
||||
Assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
void grib_compile_action_branch(grib_action* a,grib_compiler* c, char* name)
|
||||
{
|
||||
int first = 1;
|
||||
char var[80];
|
||||
char tmp[80];
|
||||
const char* save = c->var;
|
||||
int n = c->cnt++;
|
||||
c->var = tmp;
|
||||
if(c->cnt >= c->max) {
|
||||
fprintf(stderr,"Not enough variables %d\n",c->max);
|
||||
Assert(0);
|
||||
}
|
||||
sprintf(var,"a[%d]", n);
|
||||
while(a)
|
||||
{
|
||||
if(first) sprintf(tmp,"%s",var); else sprintf(tmp,"b[%d]->next",n);
|
||||
grib_compile(a,c);
|
||||
fprintf(c->out,"b[%d] = %s;\n",n, c->var);
|
||||
a=a->next;
|
||||
first = 0;
|
||||
}
|
||||
c->var = save;
|
||||
|
||||
if(name) strcpy(name, var);
|
||||
}
|
||||
|
||||
void grib_compile_expression(grib_expression* e, grib_compiler *compiler)
|
||||
{
|
||||
if(!e)
|
||||
{
|
||||
fprintf(compiler->out,"NULL");
|
||||
}
|
||||
else
|
||||
{
|
||||
grib_expression_compile(e,compiler);
|
||||
}
|
||||
}
|
||||
|
||||
void grib_compile_arguments(grib_arguments* a, grib_compiler *compiler)
|
||||
{
|
||||
if(!a)
|
||||
fprintf(compiler->out,"NULL");
|
||||
else {
|
||||
fprintf(compiler->out, "grib_arguments_new(ctx,");
|
||||
grib_compile_expression(a->expression, compiler);
|
||||
fprintf(compiler->out, ",");
|
||||
grib_compile_arguments(a->next,compiler);
|
||||
fprintf(compiler->out, ")");
|
||||
}
|
||||
}
|
|
@ -119,6 +119,10 @@ Log mode for information for processing information
|
|||
\see codes_keys_iterator_new */
|
||||
#define CODES_KEYS_ITERATOR_SKIP_FUNCTION GRIB_KEYS_ITERATOR_SKIP_FUNCTION
|
||||
|
||||
/*! only keys present in the dump
|
||||
\ingroup keys_iterator
|
||||
\see codes_keys_iterator_new */
|
||||
#define CODES_KEYS_ITERATOR_DUMP_ONLY GRIB_KEYS_ITERATOR_DUMP_ONLY
|
||||
|
||||
typedef struct grib_values codes_values;
|
||||
typedef struct grib_key_value_list codes_key_value_list;
|
||||
|
@ -1093,12 +1097,14 @@ attributes or by the namespace they belong to.
|
|||
* and namespace
|
||||
*/
|
||||
codes_keys_iterator* codes_keys_iterator_new(codes_handle* h,unsigned long filter_flags, const char* name_space);
|
||||
codes_keys_iterator* bufr_keys_iterator_new(codes_handle* h);
|
||||
|
||||
/*! Step to the next iterator.
|
||||
* @param kiter : valid codes_keys_iterator
|
||||
* @return 1 if next iterator exists, 0 if no more elements to iterate on
|
||||
*/
|
||||
int codes_keys_iterator_next(codes_keys_iterator *kiter);
|
||||
int bufr_keys_iterator_next(codes_keys_iterator *kiter);
|
||||
|
||||
|
||||
/*! get the key name from the iterator
|
||||
|
@ -1119,12 +1125,16 @@ int codes_keys_iterator_delete( codes_keys_iterator* kiter);
|
|||
*/
|
||||
int codes_keys_iterator_rewind(codes_keys_iterator* kiter);
|
||||
|
||||
char* bufr_keys_iterator_get_name(codes_keys_iterator* kiter);
|
||||
char* bufr_keys_iterator_get_next_attribute_name(grib_keys_iterator* kiter);
|
||||
|
||||
int codes_keys_iterator_set_flags(codes_keys_iterator *kiter,unsigned long flags);
|
||||
|
||||
int codes_keys_iterator_get_long(codes_keys_iterator *kiter, long *v, size_t *len);
|
||||
int codes_keys_iterator_get_double(codes_keys_iterator *kiter, double *v, size_t *len);
|
||||
int codes_keys_iterator_get_string(codes_keys_iterator *kiter, char *v, size_t *len);
|
||||
int codes_keys_iterator_get_bytes(codes_keys_iterator *kiter, unsigned char *v, size_t *len);
|
||||
int codes_copy_key(grib_handle* h1,grib_handle* h2,const char* key,int type);
|
||||
|
||||
/* @} */
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ static void init(grib_expression* e);
|
|||
static void destroy(grib_context*,grib_expression* e);
|
||||
|
||||
static void print(grib_context*,grib_expression*,grib_handle*);
|
||||
static void compile(grib_expression*,grib_compiler*);
|
||||
static void add_dependency(grib_expression* e, grib_accessor* observer);
|
||||
static string get_name(grib_expression* e);
|
||||
|
||||
|
@ -33,7 +32,6 @@ static grib_expression_class _grib_expression_class_NAME = {
|
|||
&init, /* constructor */
|
||||
&destroy, /* destructor */
|
||||
&print,
|
||||
&compile,
|
||||
&add_dependency,
|
||||
|
||||
&native_type,
|
||||
|
|
|
@ -1450,7 +1450,7 @@ static grib_accessor* create_accessor_from_descriptor(grib_accessor* a,grib_acce
|
|||
grib_accessor_bufr_data_array *self =(grib_accessor_bufr_data_array*)a;
|
||||
char code[10]={0,};
|
||||
int idx=0;
|
||||
unsigned long flags=0;
|
||||
unsigned long flags=GRIB_ACCESSOR_FLAG_READ_ONLY;
|
||||
grib_action operatorCreator = {0, };
|
||||
grib_accessor* elementAccessor=NULL;
|
||||
grib_action creator = {0, };
|
||||
|
@ -1513,7 +1513,7 @@ static grib_accessor* create_accessor_from_descriptor(grib_accessor* a,grib_acce
|
|||
if (!attribute) return NULL;
|
||||
grib_accessor_add_attribute(elementAccessor,attribute,0);
|
||||
|
||||
attribute=create_attribute_variable("units",section,GRIB_TYPE_STRING,self->expanded->v[idx]->units,0,0,GRIB_ACCESSOR_FLAG_DUMP);
|
||||
attribute=create_attribute_variable("units",section,GRIB_TYPE_STRING,self->expanded->v[idx]->units,0,0,GRIB_ACCESSOR_FLAG_DUMP | flags);
|
||||
if (!attribute) return NULL;
|
||||
grib_accessor_add_attribute(elementAccessor,attribute,0);
|
||||
|
||||
|
|
|
@ -257,6 +257,7 @@ static void init(grib_accessor* a, const long len, grib_arguments* params)
|
|||
{
|
||||
|
||||
a->length = 0;
|
||||
a->flags |= GRIB_ACCESSOR_FLAG_BUFR_DATA;
|
||||
/* a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY; */
|
||||
}
|
||||
|
||||
|
|
|
@ -410,6 +410,7 @@ static grib_accessor* make_clone(grib_accessor* a,grib_section* s,int* err)
|
|||
the_clone=grib_accessor_factory(s, &creator, 0, NULL);
|
||||
the_clone->parent=NULL;
|
||||
the_clone->h=s->h;
|
||||
the_clone->flags=a->flags;
|
||||
variableAccessor=(grib_accessor_variable*)the_clone;
|
||||
|
||||
*err=0;
|
||||
|
|
|
@ -152,6 +152,11 @@ Log mode for information for processing information
|
|||
\see grib_keys_iterator_new */
|
||||
#define GRIB_KEYS_ITERATOR_SKIP_FUNCTION (1<<6)
|
||||
|
||||
/*! only keys present in the dump
|
||||
\ingroup keys_iterator
|
||||
\see grib_keys_iterator_new */
|
||||
#define GRIB_KEYS_ITERATOR_DUMP_ONLY (1<<7)
|
||||
|
||||
typedef struct grib_key_value_list grib_key_value_list;
|
||||
|
||||
typedef struct grib_values grib_values;
|
||||
|
|
|
@ -420,7 +420,6 @@ struct grib_action
|
|||
grib_arguments* default_value; /** default expression as in .def file */
|
||||
char* set;
|
||||
char* debug_info; /** purely for debugging and tracing */
|
||||
/* If you add something, don't forget to update grib_action_compile */
|
||||
};
|
||||
|
||||
typedef struct grib_accessors_list grib_accessors_list;
|
||||
|
@ -432,23 +431,12 @@ struct grib_accessors_list {
|
|||
grib_accessors_list* last;
|
||||
};
|
||||
|
||||
/* compile */
|
||||
|
||||
typedef struct grib_compiler {
|
||||
int cnt;
|
||||
int max;
|
||||
FILE* out;
|
||||
const char* var;
|
||||
} grib_compiler;
|
||||
|
||||
|
||||
|
||||
typedef int (*action_create_accessors_handle_proc) (grib_section* p, grib_action* a, grib_loader* h);
|
||||
typedef int (*action_notify_change_proc) (grib_action* a, grib_accessor* observer,grib_accessor * observed);
|
||||
|
||||
typedef void (*grib_dump_proc) (grib_action*, FILE*, int );
|
||||
typedef void (*grib_xref_proc) (grib_action*, FILE*,const char*);
|
||||
typedef void (*grib_compile_proc) (grib_action*, grib_compiler*);
|
||||
typedef void (*action_init_class_proc) (grib_action_class* a);
|
||||
typedef void (*action_init_proc) (grib_action* a);
|
||||
typedef void (*action_destroy_proc) (grib_context* context, grib_action* a);
|
||||
|
@ -481,7 +469,6 @@ struct grib_action_class
|
|||
action_reparse_proc reparse;
|
||||
action_execute_proc execute;
|
||||
|
||||
grib_compile_proc compile; /** < compile method of the action */
|
||||
};
|
||||
|
||||
|
||||
|
@ -556,7 +543,7 @@ struct grib_accessor
|
|||
#define GRIB_ACCESSOR_FLAG_CAN_BE_MISSING (1<<4)
|
||||
#define GRIB_ACCESSOR_FLAG_HIDDEN (1<<5)
|
||||
#define GRIB_ACCESSOR_FLAG_CONSTRAINT (1<<6)
|
||||
#define GRIB_ACCESSOR_FLAG_OVERRIDE (1<<7)
|
||||
#define GRIB_ACCESSOR_FLAG_BUFR_DATA (1<<7)
|
||||
#define GRIB_ACCESSOR_FLAG_NO_COPY (1<<8)
|
||||
#define GRIB_ACCESSOR_FLAG_COPY_OK (1<<9)
|
||||
#define GRIB_ACCESSOR_FLAG_FUNCTION (1<<10)
|
||||
|
@ -567,9 +554,6 @@ struct grib_accessor
|
|||
#define GRIB_ACCESSOR_FLAG_LONG_TYPE (1<<15)
|
||||
#define GRIB_ACCESSOR_FLAG_DOUBLE_TYPE (1<<16)
|
||||
#define GRIB_ACCESSOR_FLAG_LOWERCASE (1<<17)
|
||||
#define GRIB_ACCESSOR_FLAG_XML (1<<18)
|
||||
#define GRIB_ACCESSOR_FLAG_JSON (1<<19)
|
||||
/* when adding a flag, update grib_compile_flags*/
|
||||
|
||||
/**
|
||||
* a section accessor
|
||||
|
@ -1069,7 +1053,6 @@ typedef const char* (*expression_evaluate_string_proc)(grib_expression*,grib_han
|
|||
typedef const char* (*expression_get_name_proc)(grib_expression*);
|
||||
|
||||
typedef void (*expression_print_proc)(grib_context*,grib_expression*,grib_handle*);
|
||||
typedef void (*expression_compile_proc)(grib_expression*,grib_compiler*);
|
||||
typedef void (*expression_add_dependency_proc) (grib_expression*e, grib_accessor* observer );
|
||||
|
||||
typedef struct grib_expression_class grib_expression_class;
|
||||
|
@ -1097,7 +1080,6 @@ struct grib_expression_class {
|
|||
|
||||
|
||||
expression_print_proc print;
|
||||
expression_compile_proc compile;
|
||||
expression_add_dependency_proc add_dependency;
|
||||
|
||||
expression_native_type_proc native_type;
|
||||
|
@ -1360,6 +1342,21 @@ struct grib_action_file_list
|
|||
grib_action_file * last ;
|
||||
};
|
||||
|
||||
/* keys iterator common to grib and bufr*/
|
||||
struct grib_keys_iterator{
|
||||
grib_handle *handle;
|
||||
unsigned long filter_flags; /** flags to filter out accessors */
|
||||
unsigned long accessor_flags; /** flags to filter out accessors */
|
||||
grib_accessor *current;
|
||||
char *name_space;
|
||||
int at_start;
|
||||
int match;
|
||||
int i_curr_attribute;
|
||||
grib_accessor** attributes;
|
||||
char* prefix;
|
||||
grib_trie *seen;
|
||||
};
|
||||
|
||||
|
||||
/* ----------*/
|
||||
/* md5 */
|
||||
|
|
|
@ -10,7 +10,6 @@ int grib_action_execute(grib_action *a, grib_handle *h);
|
|||
void grib_dump_action_branch(FILE *out, grib_action *a, int decay);
|
||||
void grib_dump_action_tree(grib_context *ctx, FILE *out);
|
||||
void grib_xref_action_branch(FILE *out, grib_action *a, const char *path);
|
||||
void grib_compile(grib_action *a, grib_compiler *compiler);
|
||||
|
||||
/* action_class_alias.c */
|
||||
grib_action *grib_action_create_alias(grib_context *context, const char *name, const char *arg1, const char *name_space, int flags);
|
||||
|
@ -903,8 +902,6 @@ void grib_dump_footer(grib_dumper *d, grib_handle *h);
|
|||
|
||||
/* grib_dumper_class_json.c */
|
||||
|
||||
/* grib_dumper_class_xml.c */
|
||||
|
||||
/* grib_dumper_class_wmo.c */
|
||||
|
||||
/* grib_dumper_class.c */
|
||||
|
@ -1360,7 +1357,6 @@ int grib_expression_evaluate_double(grib_handle *h, grib_expression *g, double *
|
|||
const char *grib_expression_evaluate_string(grib_handle *h, grib_expression *g, char *buf, size_t *size, int *err);
|
||||
const char *grib_expression_get_name(grib_expression *g);
|
||||
void grib_expression_print(grib_context *ctx, grib_expression *g, grib_handle *f);
|
||||
void grib_expression_compile(grib_expression *g, grib_compiler *f);
|
||||
void grib_expression_free(grib_context *ctx, grib_expression *g);
|
||||
void grib_expression_add_dependency(grib_expression *e, grib_accessor *observer);
|
||||
int grib_expression_set_value(grib_handle *h, grib_expression *g, grib_values *v);
|
||||
|
@ -1392,12 +1388,6 @@ char *codes_getenv(const char *name);
|
|||
int compute_key_rank(grib_handle* h, grib_string_list* keys, const char* key);
|
||||
char **str_split(char *a_str, const char a_delim);
|
||||
|
||||
/* compile.c */
|
||||
void grib_compile_flags(grib_compiler *c, long flags);
|
||||
void grib_compile_action_branch(grib_action *a, grib_compiler *c, char *name);
|
||||
void grib_compile_expression(grib_expression *e, grib_compiler *compiler);
|
||||
void grib_compile_arguments(grib_arguments *a, grib_compiler *compiler);
|
||||
|
||||
/* functions.c */
|
||||
long grib_op_eq(long a, long b);
|
||||
long grib_op_ne(long a, long b);
|
||||
|
|
|
@ -17,4 +17,3 @@ extern grib_dumper_class* grib_dumper_class_keys;
|
|||
extern grib_dumper_class* grib_dumper_class_serialize;
|
||||
extern grib_dumper_class* grib_dumper_class_string;
|
||||
extern grib_dumper_class* grib_dumper_class_wmo;
|
||||
extern grib_dumper_class* grib_dumper_class_xml;
|
||||
|
|
|
@ -1,693 +0,0 @@
|
|||
/*
|
||||
* Copyright 2005-2016 ECMWF.
|
||||
*
|
||||
* This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
|
||||
/**************************************
|
||||
* Enrico Fucile
|
||||
**************************************/
|
||||
|
||||
|
||||
#include "grib_api_internal.h"
|
||||
#include <ctype.h>
|
||||
/*
|
||||
This is used by make_class.pl
|
||||
|
||||
START_CLASS_DEF
|
||||
CLASS = dumper
|
||||
IMPLEMENTS = dump_long;dump_bits
|
||||
IMPLEMENTS = dump_double;dump_string;dump_string_array
|
||||
IMPLEMENTS = dump_bytes;dump_values
|
||||
IMPLEMENTS = dump_label;dump_section
|
||||
IMPLEMENTS = init;destroy
|
||||
MEMBERS = long section_offset
|
||||
MEMBERS = long begin
|
||||
MEMBERS = long end
|
||||
END_CLASS_DEF
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/* START_CLASS_IMP */
|
||||
|
||||
/*
|
||||
|
||||
Don't edit anything between START_CLASS_IMP and END_CLASS_IMP
|
||||
Instead edit values between START_CLASS_DEF and END_CLASS_DEF
|
||||
or edit "dumper.class" and rerun ./make_class.pl
|
||||
|
||||
*/
|
||||
|
||||
static void init_class (grib_dumper_class*);
|
||||
static int init (grib_dumper* d);
|
||||
static int destroy (grib_dumper*);
|
||||
static void dump_long (grib_dumper* d, grib_accessor* a,const char* comment);
|
||||
static void dump_bits (grib_dumper* d, grib_accessor* a,const char* comment);
|
||||
static void dump_double (grib_dumper* d, grib_accessor* a,const char* comment);
|
||||
static void dump_string (grib_dumper* d, grib_accessor* a,const char* comment);
|
||||
static void dump_string_array (grib_dumper* d, grib_accessor* a,const char* comment);
|
||||
static void dump_bytes (grib_dumper* d, grib_accessor* a,const char* comment);
|
||||
static void dump_values (grib_dumper* d, grib_accessor* a);
|
||||
static void dump_label (grib_dumper* d, grib_accessor* a,const char* comment);
|
||||
static void dump_section (grib_dumper* d, grib_accessor* a,grib_block_of_accessors* block);
|
||||
|
||||
typedef struct grib_dumper_xml {
|
||||
grib_dumper dumper;
|
||||
/* Members defined in xml */
|
||||
long section_offset;
|
||||
long begin;
|
||||
long end;
|
||||
} grib_dumper_xml;
|
||||
|
||||
|
||||
static grib_dumper_class _grib_dumper_class_xml = {
|
||||
0, /* super */
|
||||
"xml", /* name */
|
||||
sizeof(grib_dumper_xml), /* size */
|
||||
0, /* inited */
|
||||
&init_class, /* init_class */
|
||||
&init, /* init */
|
||||
&destroy, /* free mem */
|
||||
&dump_long, /* dump long */
|
||||
&dump_double, /* dump double */
|
||||
&dump_string, /* dump string */
|
||||
&dump_string_array, /* dump string array */
|
||||
&dump_label, /* dump labels */
|
||||
&dump_bytes, /* dump bytes */
|
||||
&dump_bits, /* dump bits */
|
||||
&dump_section, /* dump section */
|
||||
&dump_values, /* dump values */
|
||||
0, /* header */
|
||||
0, /* footer */
|
||||
};
|
||||
|
||||
grib_dumper_class* grib_dumper_class_xml = &_grib_dumper_class_xml;
|
||||
|
||||
/* END_CLASS_IMP */
|
||||
|
||||
static void print_offset(FILE* out,grib_dumper* d,grib_accessor* a);
|
||||
|
||||
static void init_class (grib_dumper_class* c){}
|
||||
|
||||
static int init(grib_dumper* d)
|
||||
{
|
||||
grib_dumper_xml *self = (grib_dumper_xml*)d;
|
||||
self->section_offset=0;
|
||||
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
||||
static int destroy (grib_dumper* d)
|
||||
{
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
||||
static void aliases(grib_dumper* d,grib_accessor* a)
|
||||
{
|
||||
int i;
|
||||
grib_dumper_xml *self = (grib_dumper_xml*)d;
|
||||
|
||||
if( (d->option_flags & GRIB_DUMP_FLAG_ALIASES) == 0)
|
||||
return;
|
||||
|
||||
if(a->all_names[1])
|
||||
{
|
||||
char *sep = "";
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"# ALIASES: ");
|
||||
|
||||
for(i = 1; i < MAX_ACCESSOR_NAMES; i++)
|
||||
{
|
||||
if(a->all_names[i])
|
||||
{
|
||||
if(a->all_name_spaces[i])
|
||||
fprintf(self->dumper.out,"%s%s.%s", sep,a->all_name_spaces[i],a->all_names[i]);
|
||||
else
|
||||
fprintf(self->dumper.out,"%s%s", sep,a->all_names[i]);
|
||||
}
|
||||
sep = ", ";
|
||||
}
|
||||
fprintf(self->dumper.out,"\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void dump_long(grib_dumper* d,grib_accessor* a,const char* comment)
|
||||
{
|
||||
grib_dumper_xml *self = (grib_dumper_xml*)d;
|
||||
long value; size_t size = 1;
|
||||
long *values=NULL;
|
||||
int err = 0;
|
||||
int i;
|
||||
long count=0;
|
||||
|
||||
grib_value_count(a,&count);
|
||||
size=count;
|
||||
|
||||
if ( (a->flags & GRIB_ACCESSOR_FLAG_XML) == 0)
|
||||
return;
|
||||
|
||||
print_offset(self->dumper.out,d,a);
|
||||
|
||||
if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0){
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"# type %s \n",a->creator->op);
|
||||
}
|
||||
|
||||
if (size>1) {
|
||||
values=(long*)grib_context_malloc_clear(a->context,sizeof(long)*size);
|
||||
err=grib_unpack_long(a,values,&size);
|
||||
} else {
|
||||
err=grib_unpack_long(a,&value,&size);
|
||||
}
|
||||
|
||||
aliases(d,a);
|
||||
if(comment) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"# %s \n",comment);
|
||||
}
|
||||
|
||||
if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"#-READ ONLY- ");
|
||||
} else
|
||||
fprintf(self->dumper.out," ");
|
||||
|
||||
if (size>1) {
|
||||
int cols=9;
|
||||
int icount=0;
|
||||
int lens=strlen(a->name);
|
||||
fprintf(self->dumper.out,"%s = { ",a->name);
|
||||
for (i=0;i<size;i++) {
|
||||
if (icount>cols) {fprintf(self->dumper.out,"\n%-*s",lens+7," ");icount=0;}
|
||||
fprintf(self->dumper.out,"%ld, ",values[i]);
|
||||
icount++;
|
||||
}
|
||||
fprintf(self->dumper.out,"\n%-*s}",lens+5," ");
|
||||
grib_context_free(a->context,values);
|
||||
} else {
|
||||
if( ((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && grib_is_missing_internal(a) )
|
||||
fprintf(self->dumper.out,"%s = MISSING;",a->name);
|
||||
else
|
||||
fprintf(self->dumper.out,"%s = %ld;",a->name,value);
|
||||
}
|
||||
|
||||
if(err) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"# *** ERR=%d (%s)",err,grib_get_error_message(err));
|
||||
}
|
||||
|
||||
fprintf(self->dumper.out,"\n");
|
||||
}
|
||||
|
||||
static int test_bit(long a, long b) {return a&(1<<b);}
|
||||
|
||||
static void dump_bits(grib_dumper* d,grib_accessor* a,const char* comment)
|
||||
{
|
||||
grib_dumper_xml *self = (grib_dumper_xml*)d;
|
||||
int i;
|
||||
long lvalue;
|
||||
double dvalue;
|
||||
size_t size = 1;
|
||||
int err = 0;
|
||||
int isDouble=0;
|
||||
|
||||
switch (grib_accessor_get_native_type(a)) {
|
||||
case GRIB_TYPE_LONG:
|
||||
grib_unpack_long(a,&lvalue,&size);
|
||||
break;
|
||||
case GRIB_TYPE_DOUBLE:
|
||||
grib_unpack_double(a,&dvalue,&size);
|
||||
isDouble=1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if ( (a->flags & GRIB_ACCESSOR_FLAG_XML) == 0)
|
||||
return;
|
||||
|
||||
print_offset(self->dumper.out,d,a);
|
||||
|
||||
if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"# type %s \n",a->creator->op);
|
||||
}
|
||||
|
||||
aliases(d,a);
|
||||
if(comment) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"# %s \n",comment);
|
||||
}
|
||||
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"# flags: ");
|
||||
for(i=0;i<(a->length*8);i++) {
|
||||
if(test_bit(lvalue,a->length*8-i-1))
|
||||
fprintf(self->dumper.out,"1");
|
||||
else
|
||||
fprintf(self->dumper.out,"0");
|
||||
}
|
||||
fprintf(self->dumper.out,"\n");
|
||||
|
||||
if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"#-READ ONLY- ");
|
||||
} else
|
||||
fprintf(self->dumper.out," ");
|
||||
|
||||
if( ((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && grib_is_missing_internal(a) )
|
||||
fprintf(self->dumper.out,"%s = MISSING;",a->name);
|
||||
else {
|
||||
if (isDouble)
|
||||
fprintf(self->dumper.out,"%s = %g;",a->name,dvalue);
|
||||
else
|
||||
fprintf(self->dumper.out,"%s = %ld;",a->name,lvalue);
|
||||
}
|
||||
|
||||
if(err) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"# *** ERR=%d (%s)",err,grib_get_error_message(err));
|
||||
}
|
||||
|
||||
fprintf(self->dumper.out,"\n");
|
||||
}
|
||||
|
||||
static void dump_double(grib_dumper* d,grib_accessor* a,const char* comment)
|
||||
{
|
||||
grib_dumper_xml *self = (grib_dumper_xml*)d;
|
||||
double value; size_t size = 1;
|
||||
int err = grib_unpack_double(a,&value,&size);
|
||||
|
||||
|
||||
if ( (a->flags & GRIB_ACCESSOR_FLAG_XML) == 0)
|
||||
return;
|
||||
|
||||
print_offset(self->dumper.out,d,a);
|
||||
|
||||
if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"# type %s \n",a->creator->op);
|
||||
}
|
||||
|
||||
aliases(d,a);
|
||||
if(comment) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"# %s \n",comment);
|
||||
}
|
||||
|
||||
|
||||
if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"#-READ ONLY- ");
|
||||
} else
|
||||
fprintf(self->dumper.out," ");
|
||||
|
||||
if( ((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && grib_is_missing_internal(a) )
|
||||
fprintf(self->dumper.out,"%s = MISSING;",a->name);
|
||||
else
|
||||
fprintf(self->dumper.out,"%s = %g;",a->name,value);
|
||||
|
||||
|
||||
if(err) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"# *** ERR=%d (%s)",err,grib_get_error_message(err));
|
||||
}
|
||||
|
||||
fprintf(self->dumper.out,"\n");
|
||||
}
|
||||
|
||||
static void dump_string_array(grib_dumper* d,grib_accessor* a,const char* comment)
|
||||
{
|
||||
grib_dumper_xml *self = (grib_dumper_xml*)d;
|
||||
char **values;
|
||||
size_t size = 0,i=0;
|
||||
grib_context* c=NULL;
|
||||
int err = 0;
|
||||
int tab=0;
|
||||
long count=0;
|
||||
|
||||
c=a->context;
|
||||
|
||||
grib_value_count(a,&count);
|
||||
size=count;
|
||||
|
||||
values=(char**)grib_context_malloc_clear(c,size*sizeof(char*));
|
||||
if (!values) {
|
||||
grib_context_log(c,GRIB_LOG_FATAL,"unable to allocate %d bytes",(int)size);
|
||||
return;
|
||||
}
|
||||
|
||||
err = grib_unpack_string_array(a,values,&size);
|
||||
|
||||
if ( (a->flags & GRIB_ACCESSOR_FLAG_XML) == 0)
|
||||
return;
|
||||
|
||||
|
||||
print_offset(self->dumper.out,d,a);
|
||||
|
||||
if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"# type %s \n",a->creator->op);
|
||||
}
|
||||
|
||||
aliases(d,a);
|
||||
if(comment) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"# %s \n",comment);
|
||||
}
|
||||
|
||||
if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"#-READ ONLY- ");
|
||||
tab=13;
|
||||
} else
|
||||
fprintf(self->dumper.out," ");
|
||||
|
||||
tab++;
|
||||
fprintf(self->dumper.out,"%s = {\n",a->name);
|
||||
for (i=0;i<size;i++) {
|
||||
fprintf(self->dumper.out,"%-*s\"%s\",\n",(int)(tab+strlen(a->name)+4)," ",values[i]);
|
||||
}
|
||||
fprintf(self->dumper.out," }");
|
||||
|
||||
if(err) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"# *** ERR=%d (%s)",err,grib_get_error_message(err));
|
||||
}
|
||||
|
||||
fprintf(self->dumper.out,"\n");
|
||||
grib_context_free(c,values);
|
||||
}
|
||||
|
||||
static void dump_string(grib_dumper* d,grib_accessor* a,const char* comment)
|
||||
{
|
||||
grib_dumper_xml *self = (grib_dumper_xml*)d;
|
||||
char *value=NULL;
|
||||
char *p = NULL;
|
||||
size_t size = 0;
|
||||
grib_context* c=NULL;
|
||||
int err = _grib_get_string_length(a,&size);
|
||||
|
||||
c=a->context;
|
||||
if (size==0) return;
|
||||
|
||||
value=(char*)grib_context_malloc_clear(c,size);
|
||||
if (!value) {
|
||||
grib_context_log(c,GRIB_LOG_FATAL,"unable to allocate %d bytes",(int)size);
|
||||
return;
|
||||
}
|
||||
|
||||
err = grib_unpack_string(a,value,&size);
|
||||
p=value;
|
||||
|
||||
if ( (a->flags & GRIB_ACCESSOR_FLAG_XML) == 0)
|
||||
return;
|
||||
|
||||
while(*p) { if(!isprint(*p)) *p = '.'; p++; }
|
||||
|
||||
print_offset(self->dumper.out,d,a);
|
||||
|
||||
if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"# type %s \n",a->creator->op);
|
||||
}
|
||||
|
||||
aliases(d,a);
|
||||
if(comment) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"# %s \n",comment);
|
||||
}
|
||||
|
||||
if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"#-READ ONLY- ");
|
||||
} else
|
||||
fprintf(self->dumper.out," ");
|
||||
|
||||
if( ((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && grib_is_missing_internal(a) )
|
||||
fprintf(self->dumper.out,"%s = MISSING;",a->name);
|
||||
else
|
||||
fprintf(self->dumper.out,"%s = %s;",a->name,value);
|
||||
|
||||
|
||||
if(err) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"# *** ERR=%d (%s)",err,grib_get_error_message(err));
|
||||
}
|
||||
|
||||
fprintf(self->dumper.out,"\n");
|
||||
grib_context_free(c,value);
|
||||
}
|
||||
|
||||
static void dump_bytes(grib_dumper* d,grib_accessor* a,const char* comment)
|
||||
{
|
||||
|
||||
#if 0
|
||||
grib_dumper_xml *self = (grib_dumper_xml*)d;
|
||||
int i,k,err =0;
|
||||
int more = 0;
|
||||
size_t size = a->length;
|
||||
unsigned char* buf = grib_context_malloc(d->handle->context,size);
|
||||
|
||||
if ( (a->flags & GRIB_ACCESSOR_FLAG_XML) == 0)
|
||||
return;
|
||||
|
||||
|
||||
if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY)
|
||||
fprintf(self->dumper.out,"-READ ONLY- ");
|
||||
|
||||
/*for(i = 0; i < d->depth ; i++) fprintf(self->dumper.out," ");*/
|
||||
/*print_offset(self->dumper.out,self->begin,self->end);*/
|
||||
if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0)
|
||||
fprintf(self->dumper.out,"%s ",a->creator->op);
|
||||
|
||||
fprintf(self->dumper.out,"%s = %ld",a->name,a->length);
|
||||
aliases(d,a);
|
||||
fprintf(self->dumper.out," {");
|
||||
|
||||
if(!buf)
|
||||
{
|
||||
if(size == 0)
|
||||
fprintf(self->dumper.out,"}\n");
|
||||
else
|
||||
fprintf(self->dumper.out," *** ERR cannot malloc(%ld) }\n",(long)size);
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(self->dumper.out,"\n");
|
||||
|
||||
err = grib_unpack_bytes(a,buf,&size);
|
||||
if(err){
|
||||
grib_context_free(d->handle->context,buf);
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) \n}",err,grib_get_error_message(err));
|
||||
return ;
|
||||
}
|
||||
|
||||
if(size > 100) {
|
||||
more = size - 100;
|
||||
size = 100;
|
||||
}
|
||||
|
||||
k = 0;
|
||||
/* if(size > 100) size = 100; */
|
||||
while(k < size)
|
||||
{
|
||||
int j;
|
||||
for(i = 0; i < d->depth + 3 ; i++) fprintf(self->dumper.out," ");
|
||||
for(j = 0; j < 16 && k < size; j++, k++)
|
||||
{
|
||||
fprintf(self->dumper.out,"%02x",buf[k]);
|
||||
if(k != size-1)
|
||||
fprintf(self->dumper.out,", ");
|
||||
}
|
||||
fprintf(self->dumper.out,"\n");
|
||||
}
|
||||
|
||||
if(more)
|
||||
{
|
||||
for(i = 0; i < d->depth + 3 ; i++) fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"... %d more values\n",more);
|
||||
}
|
||||
|
||||
for(i = 0; i < d->depth ; i++) fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"} # %s %s \n",a->creator->op, a->name);
|
||||
grib_context_free(d->handle->context,buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void dump_values(grib_dumper* d,grib_accessor* a)
|
||||
{
|
||||
grib_dumper_xml *self = (grib_dumper_xml*)d;
|
||||
int k,err =0;
|
||||
int more = 0;
|
||||
double* buf = NULL;
|
||||
size_t size=0;
|
||||
long count=0;
|
||||
|
||||
if ( (a->flags & GRIB_ACCESSOR_FLAG_XML) == 0)
|
||||
return;
|
||||
|
||||
grib_value_count(a,&count);
|
||||
size=count;
|
||||
if(size == 1){
|
||||
dump_double(d,a,NULL);
|
||||
return ;
|
||||
}
|
||||
buf = (double*)grib_context_malloc(d->handle->context,size * sizeof(double));
|
||||
|
||||
print_offset(self->dumper.out,d,a);
|
||||
|
||||
if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"# type %s \n",a->creator->op);
|
||||
}
|
||||
|
||||
aliases(d,a);
|
||||
|
||||
if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"#-READ ONLY- ");
|
||||
} else
|
||||
fprintf(self->dumper.out," ");
|
||||
|
||||
fprintf(self->dumper.out,"%s(%ld) = ",a->name,(long)size);
|
||||
fprintf(self->dumper.out," {");
|
||||
|
||||
if(!buf)
|
||||
{
|
||||
if(size == 0)
|
||||
fprintf(self->dumper.out,"}\n");
|
||||
else
|
||||
fprintf(self->dumper.out," *** ERR cannot malloc(%ld) }\n",(long)size);
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(self->dumper.out,"\n");
|
||||
|
||||
err = grib_unpack_double(a,buf,&size);
|
||||
|
||||
if(err){
|
||||
grib_context_free(d->handle->context,buf);
|
||||
fprintf(self->dumper.out," *** ERR=%d (%s) \n}",err,grib_get_error_message(err));
|
||||
return ;
|
||||
}
|
||||
|
||||
if(!(d->option_flags & GRIB_DUMP_FLAG_ALL_DATA) && size > 100) {
|
||||
more = size - 100;
|
||||
size = 100;
|
||||
}
|
||||
|
||||
k = 0;
|
||||
while(k < size) {
|
||||
#if 1
|
||||
int j;
|
||||
fprintf(self->dumper.out," ");
|
||||
for(j = 0; j < 5 && k < size; j++, k++) {
|
||||
fprintf(self->dumper.out,"%g",buf[k]);
|
||||
if(k != size-1)
|
||||
fprintf(self->dumper.out,", ");
|
||||
}
|
||||
fprintf(self->dumper.out,"\n");
|
||||
#else
|
||||
|
||||
fprintf(self->dumper.out,"%d %g\n",k,buf[k]);
|
||||
|
||||
#endif
|
||||
|
||||
} if(more) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"... %d more values\n",more);
|
||||
}
|
||||
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"} \n");
|
||||
grib_context_free(d->handle->context,buf);
|
||||
}
|
||||
|
||||
static void dump_label(grib_dumper* d,grib_accessor* a,const char* comment)
|
||||
{
|
||||
/*grib_dumper_xml *self = (grib_dumper_xml*)d;
|
||||
|
||||
for(i = 0; i < d->depth ; i++) fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"----> %s %s %s\n",a->creator->op, a->name,comment?comment:"");*/
|
||||
}
|
||||
|
||||
static void dump_section(grib_dumper* d,grib_accessor* a,grib_block_of_accessors* block)
|
||||
{
|
||||
grib_dumper_xml *self = (grib_dumper_xml*)d;
|
||||
int i;
|
||||
/* grib_section* s = grib_get_sub_section(a); */
|
||||
grib_section* s = a->sub_section;
|
||||
|
||||
if ( (a->flags & GRIB_ACCESSOR_FLAG_XML) == 0)
|
||||
return;
|
||||
|
||||
#if 1
|
||||
if(a->name[0] == '_'){
|
||||
grib_dump_accessors_block(d,block);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
for(i = 0; i < d->depth ; i++) fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"======> %s %s (%ld,%ld,%ld)\n",a->creator->op,
|
||||
a->name,a->length,(long)s->length,(long)s->padding);
|
||||
if (!strncmp(a->name,"section",7)) self->section_offset=a->offset;
|
||||
/*printf("------------- section_offset = %ld\n",self->section_offset);*/
|
||||
d->depth += 3;
|
||||
grib_dump_accessors_block(d,block);
|
||||
d->depth -= 3;
|
||||
|
||||
for(i = 0; i < d->depth ; i++) fprintf(self->dumper.out," ");
|
||||
fprintf(self->dumper.out,"<===== %s %s\n",a->creator->op, a->name);
|
||||
}
|
||||
|
||||
static void print_offset(FILE* out,grib_dumper* d,grib_accessor* a) {
|
||||
int i,k;
|
||||
long offset;
|
||||
long begin=0,end=0;
|
||||
size_t size=0,more=0;
|
||||
grib_dumper_xml *self = (grib_dumper_xml*)d;
|
||||
grib_handle* h=grib_handle_of_accessor(a);
|
||||
|
||||
begin=a->offset-self->section_offset+1;;
|
||||
end =grib_get_next_position_offset(a)-self->section_offset;
|
||||
|
||||
if ((d->option_flags & GRIB_DUMP_FLAG_HEXADECIMAL) != 0 && a->length != 0) {
|
||||
if (begin == end) {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(out,"# Octet: ");
|
||||
fprintf(out,"%ld" ,begin);
|
||||
}
|
||||
else {
|
||||
fprintf(self->dumper.out," ");
|
||||
fprintf(out,"# Octets: ");
|
||||
fprintf(out,"%ld-%ld" ,begin,end);
|
||||
}
|
||||
fprintf(out," = ");
|
||||
size=a->length;
|
||||
|
||||
if(!(d->option_flags & GRIB_DUMP_FLAG_ALL_DATA) && size > 112) {
|
||||
more = size - 112;
|
||||
size = 112;
|
||||
}
|
||||
|
||||
k = 0;
|
||||
while(k < size) {
|
||||
offset=a->offset;
|
||||
for (i=0;i<14 && k<size;i++,k++) {
|
||||
fprintf(out," 0x%.2X",h->buffer->data[offset]);
|
||||
offset++;
|
||||
}
|
||||
if (k<size) fprintf(self->dumper.out,"\n #");
|
||||
} if(more) {
|
||||
fprintf(self->dumper.out,"\n #... %d more values\n",(int)more);
|
||||
}
|
||||
fprintf(self->dumper.out,"\n");
|
||||
|
||||
}
|
||||
}
|
|
@ -1,19 +1,29 @@
|
|||
/* This file is automatically generated by ./make_class.pl, do not edit */
|
||||
{ "bufr_decode_C", &grib_dumper_class_bufr_decode_C, },
|
||||
{ "bufr_decode_C", &grib_dumper_class_bufr_decode_C, },
|
||||
{ "bufr_decode_filter", &grib_dumper_class_bufr_decode_filter, },
|
||||
{ "bufr_decode_filter", &grib_dumper_class_bufr_decode_filter, },
|
||||
{ "bufr_decode_fortran", &grib_dumper_class_bufr_decode_fortran, },
|
||||
{ "bufr_decode_python", &grib_dumper_class_bufr_decode_python, },
|
||||
|
||||
{ "bufr_decode_python", &grib_dumper_class_bufr_decode_python, },
|
||||
{ "bufr_encode_C", &grib_dumper_class_bufr_encode_C, },
|
||||
{ "bufr_encode_C", &grib_dumper_class_bufr_encode_C, },
|
||||
{ "bufr_encode_filter", &grib_dumper_class_bufr_encode_filter, },
|
||||
{ "bufr_encode_filter", &grib_dumper_class_bufr_encode_filter, },
|
||||
{ "bufr_encode_fortran", &grib_dumper_class_bufr_encode_fortran, },
|
||||
{ "bufr_encode_python", &grib_dumper_class_bufr_encode_python, },
|
||||
|
||||
{ "bufr_encode_python", &grib_dumper_class_bufr_encode_python, },
|
||||
{ "debug", &grib_dumper_class_debug, },
|
||||
{ "debug", &grib_dumper_class_debug, },
|
||||
{ "default", &grib_dumper_class_default, },
|
||||
{ "default", &grib_dumper_class_default, },
|
||||
{ "grib_encode_C", &grib_dumper_class_grib_encode_C, },
|
||||
{ "grib_encode_C", &grib_dumper_class_grib_encode_C, },
|
||||
{ "json", &grib_dumper_class_json, },
|
||||
{ "json", &grib_dumper_class_json, },
|
||||
{ "keys", &grib_dumper_class_keys, },
|
||||
{ "keys", &grib_dumper_class_keys, },
|
||||
{ "serialize", &grib_dumper_class_serialize, },
|
||||
{ "serialize", &grib_dumper_class_serialize, },
|
||||
{ "wmo", &grib_dumper_class_wmo, },
|
||||
{ "xml", &grib_dumper_class_xml, },
|
||||
{ "wmo", &grib_dumper_class_wmo, },
|
||||
|
|
|
@ -93,27 +93,6 @@ void grib_expression_print(grib_context* ctx,grib_expression* g,grib_handle* f)
|
|||
Assert(1==0);
|
||||
}
|
||||
|
||||
void grib_expression_compile(grib_expression* g,grib_compiler* f)
|
||||
{
|
||||
grib_expression_class *c = g->cclass;
|
||||
if(!c->compile)
|
||||
{
|
||||
fprintf(stderr, "NO COMPILE METHOD %s\n", c->name);
|
||||
Assert(0);
|
||||
}
|
||||
while(c)
|
||||
{
|
||||
if(c->compile)
|
||||
{
|
||||
c->compile(g,f);
|
||||
return;
|
||||
}
|
||||
c = c->super ? *(c->super) : NULL;
|
||||
}
|
||||
Assert(1==0);
|
||||
|
||||
}
|
||||
|
||||
void grib_expression_free(grib_context* ctx,grib_expression* g)
|
||||
{
|
||||
grib_expression_class *c = g->cclass;
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
IMPLEMENTS = evaluate_double
|
||||
IMPLEMENTS = evaluate_string
|
||||
IMPLEMENTS = print
|
||||
IMPLEMENTS = compile
|
||||
IMPLEMENTS = add_dependency
|
||||
MEMBERS = char *name
|
||||
MEMBERS = long start
|
||||
|
@ -49,7 +48,6 @@ static void init_class (grib_expression_class*);
|
|||
static void destroy(grib_context*,grib_expression* e);
|
||||
|
||||
static void print(grib_context*,grib_expression*,grib_handle*);
|
||||
static void compile(grib_expression*,grib_compiler*);
|
||||
static void add_dependency(grib_expression* e, grib_accessor* observer);
|
||||
static string get_name(grib_expression* e);
|
||||
|
||||
|
@ -77,7 +75,6 @@ static grib_expression_class _grib_expression_class_accessor = {
|
|||
0, /* constructor */
|
||||
&destroy, /* destructor */
|
||||
&print,
|
||||
&compile,
|
||||
&add_dependency,
|
||||
|
||||
&native_type,
|
||||
|
@ -181,12 +178,6 @@ grib_expression* new_accessor_expression(grib_context* c,const char *name,long s
|
|||
return (grib_expression*)e;
|
||||
}
|
||||
|
||||
static void compile(grib_expression* g,grib_compiler* c)
|
||||
{
|
||||
grib_expression_accessor* e = (grib_expression_accessor*)g;
|
||||
fprintf(c->out,"new_accessor_expression(ctx,\"%s\")",e->name);
|
||||
}
|
||||
|
||||
static int native_type(grib_expression* g,grib_handle *h)
|
||||
{
|
||||
grib_expression_accessor* e = (grib_expression_accessor*)g;
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
IMPLEMENTS = evaluate_long
|
||||
IMPLEMENTS = evaluate_double
|
||||
IMPLEMENTS = print
|
||||
IMPLEMENTS = compile
|
||||
IMPLEMENTS = add_dependency
|
||||
MEMBERS = grib_expression *left
|
||||
MEMBERS = grib_expression *right
|
||||
|
@ -49,7 +48,6 @@ static void init_class (grib_expression_class*);
|
|||
static void destroy(grib_context*,grib_expression* e);
|
||||
|
||||
static void print(grib_context*,grib_expression*,grib_handle*);
|
||||
static void compile(grib_expression*,grib_compiler*);
|
||||
static void add_dependency(grib_expression* e, grib_accessor* observer);
|
||||
|
||||
static int native_type(grib_expression*,grib_handle*);
|
||||
|
@ -77,7 +75,6 @@ static grib_expression_class _grib_expression_class_binop = {
|
|||
0, /* constructor */
|
||||
&destroy, /* destructor */
|
||||
&print,
|
||||
&compile,
|
||||
&add_dependency,
|
||||
|
||||
&native_type,
|
||||
|
@ -200,18 +197,6 @@ grib_expression* new_binop_expression(grib_context* c,
|
|||
return (grib_expression*)e;
|
||||
}
|
||||
|
||||
static void compile(grib_expression* g,grib_compiler* c)
|
||||
{
|
||||
grib_expression_binop* e = (grib_expression_binop*)g;
|
||||
fprintf(c->out,"new_binop_expression(ctx,");
|
||||
fprintf(c->out,"%s,",grib_binop_long_proc_name(e->long_func));
|
||||
fprintf(c->out,"%s,",grib_binop_double_proc_name(e->double_func));
|
||||
grib_expression_compile(e->left,c);
|
||||
fprintf(c->out,",");
|
||||
grib_expression_compile(e->right,c);
|
||||
fprintf(c->out,")");
|
||||
}
|
||||
|
||||
static int native_type(grib_expression* g,grib_handle *h)
|
||||
{
|
||||
grib_expression_binop* e = (grib_expression_binop*)g;
|
||||
|
|
|
@ -72,7 +72,6 @@ static grib_expression_class _grib_expression_class_column = {
|
|||
0, /* constructor */
|
||||
&destroy, /* destructor */
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
||||
&native_type,
|
||||
|
|
|
@ -68,7 +68,6 @@ static grib_expression_class _grib_expression_class_constant = {
|
|||
0, /* constructor */
|
||||
&destroy, /* destructor */
|
||||
&print,
|
||||
0,
|
||||
&add_dependency,
|
||||
|
||||
&native_type,
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
IMPLEMENTS = evaluate_long
|
||||
IMPLEMENTS = evaluate_double
|
||||
IMPLEMENTS = print
|
||||
IMPLEMENTS = compile
|
||||
IMPLEMENTS = add_dependency
|
||||
MEMBERS = double value
|
||||
END_CLASS_DEF
|
||||
|
@ -45,7 +44,6 @@ static void init_class (grib_expression_class*);
|
|||
static void destroy(grib_context*,grib_expression* e);
|
||||
|
||||
static void print(grib_context*,grib_expression*,grib_handle*);
|
||||
static void compile(grib_expression*,grib_compiler*);
|
||||
static void add_dependency(grib_expression* e, grib_accessor* observer);
|
||||
|
||||
static int native_type(grib_expression*,grib_handle*);
|
||||
|
@ -69,7 +67,6 @@ static grib_expression_class _grib_expression_class_double = {
|
|||
0, /* constructor */
|
||||
&destroy, /* destructor */
|
||||
&print,
|
||||
&compile,
|
||||
&add_dependency,
|
||||
|
||||
&native_type,
|
||||
|
@ -125,12 +122,6 @@ grib_expression* new_double_expression(grib_context* c,double value)
|
|||
return (grib_expression*)e;
|
||||
}
|
||||
|
||||
static void compile(grib_expression* g,grib_compiler* c)
|
||||
{
|
||||
grib_expression_double* e = (grib_expression_double*)g;
|
||||
fprintf(c->out,"new_double_expression(ctx,%g)",e->value);
|
||||
}
|
||||
|
||||
static int native_type(grib_expression* g,grib_handle *h)
|
||||
{
|
||||
return GRIB_TYPE_DOUBLE;
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
IMPLEMENTS = native_type
|
||||
IMPLEMENTS = evaluate_long
|
||||
IMPLEMENTS = print
|
||||
IMPLEMENTS = compile
|
||||
IMPLEMENTS = add_dependency
|
||||
MEMBERS = char *name
|
||||
MEMBERS = grib_arguments *args
|
||||
|
@ -45,7 +44,6 @@ static void init_class (grib_expression_class*);
|
|||
static void destroy(grib_context*,grib_expression* e);
|
||||
|
||||
static void print(grib_context*,grib_expression*,grib_handle*);
|
||||
static void compile(grib_expression*,grib_compiler*);
|
||||
static void add_dependency(grib_expression* e, grib_accessor* observer);
|
||||
|
||||
static int native_type(grib_expression*,grib_handle*);
|
||||
|
@ -69,7 +67,6 @@ static grib_expression_class _grib_expression_class_functor = {
|
|||
0, /* constructor */
|
||||
&destroy, /* destructor */
|
||||
&print,
|
||||
&compile,
|
||||
&add_dependency,
|
||||
|
||||
&native_type,
|
||||
|
@ -183,15 +180,6 @@ grib_expression* new_func_expression(grib_context* c,const char *name,grib_argum
|
|||
return (grib_expression*)e;
|
||||
}
|
||||
|
||||
static void compile(grib_expression* g,grib_compiler* c)
|
||||
{
|
||||
grib_expression_functor* e = (grib_expression_functor*)g;
|
||||
fprintf(c->out,"new_func_expression(ctx,");
|
||||
fprintf(c->out,"\"%s\",",e->name);
|
||||
grib_compile_arguments(e->args,c);
|
||||
fprintf(c->out,")");
|
||||
}
|
||||
|
||||
static int native_type(grib_expression* g,grib_handle *h)
|
||||
{
|
||||
return GRIB_TYPE_LONG;
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
IMPLEMENTS = evaluate_double
|
||||
IMPLEMENTS = evaluate_string
|
||||
IMPLEMENTS = print
|
||||
IMPLEMENTS = compile
|
||||
MEMBERS = const char *key
|
||||
MEMBERS = const char *dictionary
|
||||
END_CLASS_DEF
|
||||
|
@ -46,7 +45,6 @@ static void init_class (grib_expression_class*);
|
|||
|
||||
|
||||
static void print(grib_context*,grib_expression*,grib_handle*);
|
||||
static void compile(grib_expression*,grib_compiler*);
|
||||
static void add_dependency(grib_expression* e, grib_accessor* observer);
|
||||
static string get_name(grib_expression* e);
|
||||
|
||||
|
@ -73,7 +71,6 @@ static grib_expression_class _grib_expression_class_is_in_dict = {
|
|||
0, /* constructor */
|
||||
0, /* destructor */
|
||||
&print,
|
||||
&compile,
|
||||
&add_dependency,
|
||||
|
||||
&native_type,
|
||||
|
@ -234,12 +231,6 @@ grib_expression* new_is_in_dict_expression(grib_context* c,const char* name,cons
|
|||
return (grib_expression*)e;
|
||||
}
|
||||
|
||||
static void compile(grib_expression* g,grib_compiler* c)
|
||||
{
|
||||
grib_expression_is_in_dict* e = (grib_expression_is_in_dict*)g;
|
||||
fprintf(c->out,"new_is_in_dict_expression(ctx,\"%s\")",e->key);
|
||||
}
|
||||
|
||||
static int native_type(grib_expression* g,grib_handle *h)
|
||||
{
|
||||
grib_expression_is_in_dict* e = (grib_expression_is_in_dict*)g;
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
IMPLEMENTS = evaluate_double
|
||||
IMPLEMENTS = evaluate_string
|
||||
IMPLEMENTS = print
|
||||
IMPLEMENTS = compile
|
||||
IMPLEMENTS = add_dependency
|
||||
MEMBERS = const char *name
|
||||
MEMBERS = const char *list
|
||||
|
@ -48,7 +47,6 @@ static void init_class (grib_expression_class*);
|
|||
static void destroy(grib_context*,grib_expression* e);
|
||||
|
||||
static void print(grib_context*,grib_expression*,grib_handle*);
|
||||
static void compile(grib_expression*,grib_compiler*);
|
||||
static void add_dependency(grib_expression* e, grib_accessor* observer);
|
||||
static string get_name(grib_expression* e);
|
||||
|
||||
|
@ -75,7 +73,6 @@ static grib_expression_class _grib_expression_class_is_in_list = {
|
|||
0, /* constructor */
|
||||
&destroy, /* destructor */
|
||||
&print,
|
||||
&compile,
|
||||
&add_dependency,
|
||||
|
||||
&native_type,
|
||||
|
@ -248,12 +245,6 @@ grib_expression* new_is_in_list_expression(grib_context* c,const char* name,cons
|
|||
return (grib_expression*)e;
|
||||
}
|
||||
|
||||
static void compile(grib_expression* g,grib_compiler* c)
|
||||
{
|
||||
grib_expression_is_in_list* e = (grib_expression_is_in_list*)g;
|
||||
fprintf(c->out,"new_is_in_list_expression(ctx,\"%s\")",e->name);
|
||||
}
|
||||
|
||||
static int native_type(grib_expression* g,grib_handle *h)
|
||||
{
|
||||
grib_expression_is_in_list* e = (grib_expression_is_in_list*)g;
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
IMPLEMENTS = evaluate_double
|
||||
IMPLEMENTS = evaluate_string
|
||||
IMPLEMENTS = print
|
||||
IMPLEMENTS = compile
|
||||
IMPLEMENTS = add_dependency
|
||||
MEMBERS = char *name
|
||||
MEMBERS = size_t start
|
||||
|
@ -49,7 +48,6 @@ static void init_class (grib_expression_class*);
|
|||
static void destroy(grib_context*,grib_expression* e);
|
||||
|
||||
static void print(grib_context*,grib_expression*,grib_handle*);
|
||||
static void compile(grib_expression*,grib_compiler*);
|
||||
static void add_dependency(grib_expression* e, grib_accessor* observer);
|
||||
static string get_name(grib_expression* e);
|
||||
|
||||
|
@ -77,7 +75,6 @@ static grib_expression_class _grib_expression_class_is_integer = {
|
|||
0, /* constructor */
|
||||
&destroy, /* destructor */
|
||||
&print,
|
||||
&compile,
|
||||
&add_dependency,
|
||||
|
||||
&native_type,
|
||||
|
@ -194,12 +191,6 @@ grib_expression* new_is_integer_expression(grib_context* c,const char *name,int
|
|||
return (grib_expression*)e;
|
||||
}
|
||||
|
||||
static void compile(grib_expression* g,grib_compiler* c)
|
||||
{
|
||||
grib_expression_is_integer* e = (grib_expression_is_integer*)g;
|
||||
fprintf(c->out,"new_is_integer_expression(ctx,\"%s\")",e->name);
|
||||
}
|
||||
|
||||
static int native_type(grib_expression* g,grib_handle *h)
|
||||
{
|
||||
grib_expression_is_integer* e = (grib_expression_is_integer*)g;
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
IMPLEMENTS = evaluate_double
|
||||
IMPLEMENTS = evaluate_string
|
||||
IMPLEMENTS = print
|
||||
IMPLEMENTS = compile
|
||||
IMPLEMENTS = add_dependency
|
||||
MEMBERS = char *name
|
||||
MEMBERS = size_t start
|
||||
|
@ -49,7 +48,6 @@ static void init_class (grib_expression_class*);
|
|||
static void destroy(grib_context*,grib_expression* e);
|
||||
|
||||
static void print(grib_context*,grib_expression*,grib_handle*);
|
||||
static void compile(grib_expression*,grib_compiler*);
|
||||
static void add_dependency(grib_expression* e, grib_accessor* observer);
|
||||
static string get_name(grib_expression* e);
|
||||
|
||||
|
@ -77,7 +75,6 @@ static grib_expression_class _grib_expression_class_length = {
|
|||
0, /* constructor */
|
||||
&destroy, /* destructor */
|
||||
&print,
|
||||
&compile,
|
||||
&add_dependency,
|
||||
|
||||
&native_type,
|
||||
|
@ -183,12 +180,6 @@ grib_expression* new_length_expression(grib_context* c,const char *name)
|
|||
return (grib_expression*)e;
|
||||
}
|
||||
|
||||
static void compile(grib_expression* g,grib_compiler* c)
|
||||
{
|
||||
grib_expression_length* e = (grib_expression_length*)g;
|
||||
fprintf(c->out,"new_length_expression(ctx,\"%s\")",e->name);
|
||||
}
|
||||
|
||||
static int native_type(grib_expression* g,grib_handle *h)
|
||||
{
|
||||
grib_expression_length* e = (grib_expression_length*)g;
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
IMPLEMENTS = evaluate_long
|
||||
IMPLEMENTS = evaluate_double
|
||||
IMPLEMENTS = print
|
||||
IMPLEMENTS = compile
|
||||
IMPLEMENTS = add_dependency
|
||||
MEMBERS = long value
|
||||
END_CLASS_DEF
|
||||
|
@ -45,7 +44,6 @@ static void init_class (grib_expression_class*);
|
|||
static void destroy(grib_context*,grib_expression* e);
|
||||
|
||||
static void print(grib_context*,grib_expression*,grib_handle*);
|
||||
static void compile(grib_expression*,grib_compiler*);
|
||||
static void add_dependency(grib_expression* e, grib_accessor* observer);
|
||||
|
||||
static int native_type(grib_expression*,grib_handle*);
|
||||
|
@ -69,7 +67,6 @@ static grib_expression_class _grib_expression_class_long = {
|
|||
0, /* constructor */
|
||||
&destroy, /* destructor */
|
||||
&print,
|
||||
&compile,
|
||||
&add_dependency,
|
||||
|
||||
&native_type,
|
||||
|
@ -129,9 +126,3 @@ static int native_type(grib_expression* g,grib_handle *h)
|
|||
{
|
||||
return GRIB_TYPE_LONG;
|
||||
}
|
||||
|
||||
static void compile(grib_expression* g,grib_compiler* c)
|
||||
{
|
||||
grib_expression_long* e = (grib_expression_long*)g;
|
||||
fprintf(c->out,"new_long_expression(ctx,%ld)",e->value);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
IMPLEMENTS = destroy
|
||||
IMPLEMENTS = evaluate_string
|
||||
IMPLEMENTS = print
|
||||
IMPLEMENTS = compile
|
||||
IMPLEMENTS = add_dependency
|
||||
MEMBERS = char* value
|
||||
END_CLASS_DEF
|
||||
|
@ -44,7 +43,6 @@ static void init_class (grib_expression_class*);
|
|||
static void destroy(grib_context*,grib_expression* e);
|
||||
|
||||
static void print(grib_context*,grib_expression*,grib_handle*);
|
||||
static void compile(grib_expression*,grib_compiler*);
|
||||
static void add_dependency(grib_expression* e, grib_accessor* observer);
|
||||
|
||||
static int native_type(grib_expression*,grib_handle*);
|
||||
|
@ -67,7 +65,6 @@ static grib_expression_class _grib_expression_class_string = {
|
|||
0, /* constructor */
|
||||
&destroy, /* destructor */
|
||||
&print,
|
||||
&compile,
|
||||
&add_dependency,
|
||||
|
||||
&native_type,
|
||||
|
@ -117,12 +114,6 @@ grib_expression* new_string_expression(grib_context* c,const char* value)
|
|||
return (grib_expression*)e;
|
||||
}
|
||||
|
||||
static void compile(grib_expression* g,grib_compiler* c)
|
||||
{
|
||||
grib_expression_string* e = (grib_expression_string*)g;
|
||||
fprintf(c->out,"new_string_expression(ctx,\"%s\")",e->value);
|
||||
}
|
||||
|
||||
static int native_type(grib_expression* g,grib_handle *h)
|
||||
{
|
||||
return GRIB_TYPE_STRING;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
IMPLEMENTS = native_type
|
||||
IMPLEMENTS = evaluate_long
|
||||
IMPLEMENTS = evaluate_double
|
||||
IMPLEMENTS = print;compile
|
||||
IMPLEMENTS = print
|
||||
IMPLEMENTS = add_dependency
|
||||
MEMBERS = grib_expression *left
|
||||
MEMBERS = grib_expression *right
|
||||
|
@ -45,7 +45,6 @@ static void init_class (grib_expression_class*);
|
|||
static void destroy(grib_context*,grib_expression* e);
|
||||
|
||||
static void print(grib_context*,grib_expression*,grib_handle*);
|
||||
static void compile(grib_expression*,grib_compiler*);
|
||||
static void add_dependency(grib_expression* e, grib_accessor* observer);
|
||||
|
||||
static int native_type(grib_expression*,grib_handle*);
|
||||
|
@ -70,7 +69,6 @@ static grib_expression_class _grib_expression_class_string_compare = {
|
|||
0, /* constructor */
|
||||
&destroy, /* destructor */
|
||||
&print,
|
||||
&compile,
|
||||
&add_dependency,
|
||||
|
||||
&native_type,
|
||||
|
@ -158,16 +156,6 @@ grib_expression* new_string_compare_expression(grib_context* c,
|
|||
return (grib_expression*)e;
|
||||
}
|
||||
|
||||
static void compile(grib_expression* g,grib_compiler* c)
|
||||
{
|
||||
grib_expression_string_compare* e = (grib_expression_string_compare*)g;
|
||||
fprintf(c->out,"new_string_compare_expression(ctx,");
|
||||
grib_expression_compile(e->left,c);
|
||||
fprintf(c->out,",");
|
||||
grib_expression_compile(e->right,c);
|
||||
fprintf(c->out,")");
|
||||
}
|
||||
|
||||
static int native_type(grib_expression* g,grib_handle *h)
|
||||
{
|
||||
return GRIB_TYPE_LONG ;
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
IMPLEMENTS = destroy
|
||||
IMPLEMENTS = evaluate_string
|
||||
IMPLEMENTS = print
|
||||
IMPLEMENTS = compile
|
||||
IMPLEMENTS = add_dependency
|
||||
MEMBERS = char* value
|
||||
END_CLASS_DEF
|
||||
|
@ -44,7 +43,6 @@ static void init_class (grib_expression_class*);
|
|||
static void destroy(grib_context*,grib_expression* e);
|
||||
|
||||
static void print(grib_context*,grib_expression*,grib_handle*);
|
||||
static void compile(grib_expression*,grib_compiler*);
|
||||
static void add_dependency(grib_expression* e, grib_accessor* observer);
|
||||
|
||||
static int native_type(grib_expression*,grib_handle*);
|
||||
|
@ -67,7 +65,6 @@ static grib_expression_class _grib_expression_class_sub_string = {
|
|||
0, /* constructor */
|
||||
&destroy, /* destructor */
|
||||
&print,
|
||||
&compile,
|
||||
&add_dependency,
|
||||
|
||||
&native_type,
|
||||
|
@ -124,14 +121,6 @@ grib_expression* new_sub_string_expression(grib_context* c,const char* value,siz
|
|||
return (grib_expression*)e;
|
||||
}
|
||||
|
||||
|
||||
static void compile(grib_expression* g,grib_compiler* c)
|
||||
{
|
||||
grib_expression_sub_string* e = (grib_expression_sub_string*)g;
|
||||
fprintf(c->out,"new_sub_string_expression(ctx,\"%s\")",e->value);
|
||||
}
|
||||
|
||||
|
||||
static int native_type(grib_expression* g,grib_handle *h)
|
||||
{
|
||||
return GRIB_TYPE_STRING;
|
||||
|
|
|
@ -65,7 +65,6 @@ static grib_expression_class _grib_expression_class_true = {
|
|||
0, /* constructor */
|
||||
&destroy, /* destructor */
|
||||
&print,
|
||||
0,
|
||||
&add_dependency,
|
||||
|
||||
&native_type,
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
IMPLEMENTS = evaluate_long
|
||||
IMPLEMENTS = evaluate_double
|
||||
IMPLEMENTS = print
|
||||
IMPLEMENTS = compile
|
||||
IMPLEMENTS = add_dependency
|
||||
MEMBERS = grib_expression *exp
|
||||
MEMBERS = grib_unop_long_proc long_func
|
||||
|
@ -47,7 +46,6 @@ static void init_class (grib_expression_class*);
|
|||
static void destroy(grib_context*,grib_expression* e);
|
||||
|
||||
static void print(grib_context*,grib_expression*,grib_handle*);
|
||||
static void compile(grib_expression*,grib_compiler*);
|
||||
static void add_dependency(grib_expression* e, grib_accessor* observer);
|
||||
|
||||
static int native_type(grib_expression*,grib_handle*);
|
||||
|
@ -73,7 +71,6 @@ static grib_expression_class _grib_expression_class_unop = {
|
|||
0, /* constructor */
|
||||
&destroy, /* destructor */
|
||||
&print,
|
||||
&compile,
|
||||
&add_dependency,
|
||||
|
||||
&native_type,
|
||||
|
@ -148,16 +145,6 @@ grib_expression* new_unop_expression(grib_context* c,
|
|||
return (grib_expression*)e;
|
||||
}
|
||||
|
||||
static void compile(grib_expression* g,grib_compiler* c)
|
||||
{
|
||||
grib_expression_unop* e = (grib_expression_unop*)g;
|
||||
fprintf(c->out,"new_unop_expression(ctx,");
|
||||
fprintf(c->out,"%s,",grib_unop_long_proc_name(e->long_func));
|
||||
fprintf(c->out,"%s,",grib_unop_double_proc_name(e->double_func));
|
||||
grib_expression_compile(e->exp,c);
|
||||
fprintf(c->out,")");
|
||||
}
|
||||
|
||||
static int native_type(grib_expression* g,grib_handle *h)
|
||||
{
|
||||
grib_expression_unop* e = (grib_expression_unop*)g;
|
||||
|
|
|
@ -17,17 +17,6 @@ GRIB_INLINE static int grib_inline_strcmp(const char* a,const char* b)
|
|||
return (*a==0 && *b==0) ? 0 : 1;
|
||||
}
|
||||
|
||||
struct grib_keys_iterator{
|
||||
grib_handle *handle;
|
||||
unsigned long filter_flags; /** flags to filter out accessors */
|
||||
unsigned long accessor_flags; /** flags to filter out accessors */
|
||||
grib_accessor *current;
|
||||
char *name_space;
|
||||
int at_start;
|
||||
int match;
|
||||
grib_trie *seen;
|
||||
};
|
||||
|
||||
grib_keys_iterator* grib_keys_iterator_new(grib_handle* h,unsigned long filter_flags, const char* name_space)
|
||||
{
|
||||
grib_keys_iterator* ki=NULL;
|
||||
|
|
|
@ -1668,3 +1668,77 @@ int grib_key_equal(grib_handle* h1,grib_handle* h2,const char* key,int type,int
|
|||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int codes_copy_key(grib_handle* h1,grib_handle* h2,const char* key,int type)
|
||||
{
|
||||
double d;
|
||||
double* ad;
|
||||
long l;
|
||||
long* al;
|
||||
char* s=0;
|
||||
char** as=0;
|
||||
size_t len1,len2,len;
|
||||
int err=0;
|
||||
|
||||
if ( type != GRIB_TYPE_DOUBLE &&
|
||||
type != GRIB_TYPE_LONG &&
|
||||
type != GRIB_TYPE_STRING ) {
|
||||
err=grib_get_native_type(h1,key,&type);
|
||||
if (err) return err;
|
||||
}
|
||||
|
||||
err=grib_get_size(h1,key,&len1);
|
||||
if (err) return err;
|
||||
|
||||
switch (type) {
|
||||
case GRIB_TYPE_DOUBLE:
|
||||
if (len1==1) {
|
||||
err=grib_get_double(h1,key,&d);
|
||||
if (err) return err;
|
||||
err=grib_set_double(h2,key,d);
|
||||
return err;
|
||||
} else {
|
||||
ad=grib_context_malloc_clear(h1->context,len1*sizeof(double));
|
||||
err=grib_get_double_array(h1,key,ad,&len1);
|
||||
if (err) return err;
|
||||
err=grib_set_double_array(h2,key,ad,len1);
|
||||
grib_context_free(h1->context,ad);
|
||||
return err;
|
||||
}
|
||||
break;
|
||||
case GRIB_TYPE_LONG:
|
||||
if (len1==1) {
|
||||
err=grib_get_long(h1,key,&l);
|
||||
if (err) return err;
|
||||
err=grib_set_long(h2,key,l);
|
||||
return err;
|
||||
} else {
|
||||
al=grib_context_malloc_clear(h1->context,len1*sizeof(long));
|
||||
err=grib_get_long_array(h1,key,al,&len1);
|
||||
if (err) return err;
|
||||
err=grib_set_long_array(h2,key,al,len1);
|
||||
grib_context_free(h1->context,al);
|
||||
return err;
|
||||
}
|
||||
break;
|
||||
case GRIB_TYPE_STRING:
|
||||
err=grib_get_string_length(h1,key,&len);
|
||||
if (len1==1) {
|
||||
s=grib_context_malloc_clear(h1->context,len);
|
||||
err=grib_get_string(h1,key,s,&len);
|
||||
if (err) return err;
|
||||
err=grib_set_string(h2,key,s,len);
|
||||
grib_context_free(h1->context,s);
|
||||
return err;
|
||||
} else {
|
||||
as=grib_context_malloc_clear(h1->context,len1*sizeof(char*));
|
||||
err=grib_get_string_array(h1,key,as,&len1);
|
||||
if (err) return err;
|
||||
err=grib_set_string_array(h2,key,as,len1);
|
||||
return err;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return GRIB_INVALID_TYPE;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue