Skip to content

Commit

Permalink
Dead code removal
Browse files Browse the repository at this point in the history
  • Loading branch information
shahramn committed Oct 20, 2023
1 parent 5bbde7f commit 4d57fc7
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 155 deletions.
43 changes: 21 additions & 22 deletions src/action.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,21 @@ static void grib_dump(grib_action* a, FILE* f, int l)
DEBUG_ASSERT(0);
}

void grib_xref(grib_action* a, FILE* f, const char* path)
{
grib_action_class* c = a->cclass;
init(c);

while (c) {
if (c->xref) {
c->xref(a, f, path);
return;
}
c = c->super ? *(c->super) : NULL;
}
printf("xref not implemented for %s\n", a->cclass->name);
DEBUG_ASSERT(0);
}
// void grib_xref(grib_action* a, FILE* f, const char* path)
// {
// grib_action_class* c = a->cclass;
// init(c);

// while (c) {
// if (c->xref) {
// c->xref(a, f, path);
// return;
// }
// c = c->super ? *(c->super) : NULL;
// }
// printf("xref not implemented for %s\n", a->cclass->name);
// DEBUG_ASSERT(0);
// }

void grib_action_delete(grib_context* context, grib_action* a)
{
Expand Down Expand Up @@ -214,10 +213,10 @@ void grib_dump_action_tree(grib_context* ctx, FILE* out)
grib_dump_action_branch(out, ctx->grib_reader->first->root, 0);
}

void grib_xref_action_branch(FILE* out, grib_action* a, const char* path)
{
while (a) {
grib_xref(a, out, path);
a = a->next;
}
}
// void grib_xref_action_branch(FILE* out, grib_action* a, const char* path)
// {
// while (a) {
// grib_xref(a, out, path);
// a = a->next;
// }
// }
22 changes: 2 additions & 20 deletions src/action_class_alias.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
START_CLASS_DEF
CLASS = action
IMPLEMENTS = create_accessor
IMPLEMENTS = dump;xref
IMPLEMENTS = dump
IMPLEMENTS = destroy
MEMBERS = char* target
END_CLASS_DEF
Expand All @@ -38,7 +38,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 destroy (grib_context*,grib_action*);
static int create_accessor(grib_section*,grib_action*,grib_loader*);

Expand All @@ -60,7 +59,7 @@ static grib_action_class _grib_action_class_alias = {
&destroy, /* destroy */

&dump, /* dump */
&xref, /* xref */
0, /* xref */

&create_accessor, /* create_accessor*/

Expand Down Expand Up @@ -268,23 +267,6 @@ static void dump(grib_action* act, FILE* f, int lvl)
grib_context_print(act->context, f, " unalias %s \n", act->name);
}

static void xref(grib_action* act, FILE* f, const char* path)
{
Assert(!"xref is disabled");

// grib_action_alias* a = (grib_action_alias*)act;
// if (a->target) {
// fprintf(f, "bless({name=>'%s', target=>'%s', path=>'%s'},'xref::alias'),\n", act->name, a->target, path);
// if (act->name_space)
// fprintf(f, "bless({name=>'%s.%s', target=>'%s', path=>'%s'},'xref::alias'),\n", act->name_space, act->name, a->target, path);
// }
// else {
// fprintf(f, "bless({name=>'%s', path=>'%s'},'xref::unalias'),\n", act->name, path);
// if (act->name_space)
// fprintf(f, "bless({name=>'%s.%s', path=>'%s'},'xref::unalias'),\n", act->name_space, act->name, path);
// }
}

static void destroy(grib_context* context, grib_action* act)
{
grib_action_alias* a = (grib_action_alias*)act;
Expand Down
10 changes: 2 additions & 8 deletions src/action_class_gen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
START_CLASS_DEF
CLASS = action
IMPLEMENTS = create_accessor
IMPLEMENTS = dump;xref
IMPLEMENTS = dump
IMPLEMENTS = destroy
IMPLEMENTS = notify_change
MEMBERS = long len
Expand All @@ -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 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);
Expand All @@ -64,7 +63,7 @@ static grib_action_class _grib_action_class_gen = {
&destroy, /* destroy */

&dump, /* dump */
&xref, /* xref */
0, /* xref */

&create_accessor, /* create_accessor*/

Expand Down Expand Up @@ -130,11 +129,6 @@ static void dump(grib_action* act, FILE* f, int lvl)
// For xref implementation see
// src/deprecated/action_class_gen.cc

static void xref(grib_action* act, FILE* f, const char* path)
{
Assert(!"xref is disabled");
}

static int create_accessor(grib_section* p, grib_action* act, grib_loader* loader)
{
grib_action_gen* a = (grib_action_gen*)act;
Expand Down
8 changes: 2 additions & 6 deletions src/action_class_if.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
IMPLEMENTS = create_accessor
IMPLEMENTS = dump
IMPLEMENTS = destroy
IMPLEMENTS = xref
IMPLEMENTS = reparse;execute
MEMBERS = grib_expression *expression
MEMBERS = grib_action *block_true
Expand All @@ -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 xref (grib_action* d, FILE* f,const char* path);
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);
Expand Down Expand Up @@ -73,7 +71,7 @@ static grib_action_class _grib_action_class_if = {
&destroy, /* destroy */

&dump, /* dump */
&xref, /* xref */
0, /* xref */

&create_accessor, /* create_accessor*/

Expand All @@ -86,6 +84,7 @@ grib_action_class* grib_action_class_if = &_grib_action_class_if;

static void init_class(grib_action_class* c)
{
c->xref = (*(c->super))->xref;
c->notify_change = (*(c->super))->notify_change;
}
/* END_CLASS_IMP */
Expand Down Expand Up @@ -306,6 +305,3 @@ static void destroy(grib_context* context, grib_action* act)
grib_context_free_persistent(context, act->op);
}

static void xref(grib_action* d, FILE* f, const char* path)
{
}
8 changes: 2 additions & 6 deletions src/action_class_modify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
START_CLASS_DEF
CLASS = action
IMPLEMENTS = dump;xref
IMPLEMENTS = dump
IMPLEMENTS = create_accessor
IMPLEMENTS = destroy
MEMBERS = long flags
Expand All @@ -38,7 +38,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 destroy (grib_context*,grib_action*);
static int create_accessor(grib_section*,grib_action*,grib_loader*);

Expand All @@ -61,7 +60,7 @@ static grib_action_class _grib_action_class_modify = {
&destroy, /* destroy */

&dump, /* dump */
&xref, /* xref */
0, /* xref */

&create_accessor, /* create_accessor*/

Expand Down Expand Up @@ -128,6 +127,3 @@ static void destroy(grib_context* context, grib_action* act)
grib_context_free_persistent(context, act->op);
}

static void xref(grib_action* d, FILE* f, const char* path)
{
}
9 changes: 2 additions & 7 deletions src/action_class_noop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
START_CLASS_DEF
CLASS = action
IMPLEMENTS = dump;destroy;xref;execute
IMPLEMENTS = dump;destroy;execute
END_CLASS_DEF
*/
Expand All @@ -34,7 +34,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 destroy (grib_context*,grib_action*);
static int execute(grib_action* a,grib_handle* h);

Expand All @@ -55,7 +54,7 @@ static grib_action_class _grib_action_class_noop = {
&destroy, /* destroy */

&dump, /* dump */
&xref, /* xref */
0, /* xref */

0, /* create_accessor*/

Expand Down Expand Up @@ -101,10 +100,6 @@ static void destroy(grib_context* context, grib_action* act)
grib_context_free_persistent(context, act->op);
}

static void xref(grib_action* d, FILE* f, const char* path)
{
}

static int execute(grib_action* act, grib_handle* h)
{
return 0;
Expand Down
8 changes: 2 additions & 6 deletions src/action_class_remove.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
CLASS = action
IMPLEMENTS = create_accessor
IMPLEMENTS = dump
IMPLEMENTS = destroy; xref
IMPLEMENTS = destroy
MEMBERS = grib_arguments* args
END_CLASS_DEF
Expand All @@ -37,7 +37,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 destroy (grib_context*,grib_action*);
static int create_accessor(grib_section*,grib_action*,grib_loader*);

Expand All @@ -59,7 +58,7 @@ static grib_action_class _grib_action_class_remove = {
&destroy, /* destroy */

&dump, /* dump */
&xref, /* xref */
0, /* xref */

&create_accessor, /* create_accessor*/

Expand Down Expand Up @@ -153,6 +152,3 @@ static void destroy(grib_context* context, grib_action* act)
grib_context_free_persistent(context, act->op);
}

static void xref(grib_action* d, FILE* f, const char* path)
{
}
9 changes: 2 additions & 7 deletions src/action_class_rename.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
CLASS = action
IMPLEMENTS = create_accessor
IMPLEMENTS = dump
IMPLEMENTS = destroy; xref
IMPLEMENTS = destroy
MEMBERS = char* the_old
MEMBERS = char* the_new
END_CLASS_DEF
Expand All @@ -38,7 +38,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 destroy (grib_context*,grib_action*);
static int create_accessor(grib_section*,grib_action*,grib_loader*);

Expand All @@ -61,7 +60,7 @@ static grib_action_class _grib_action_class_rename = {
&destroy, /* destroy */

&dump, /* dump */
&xref, /* xref */
0, /* xref */

&create_accessor, /* create_accessor*/

Expand Down Expand Up @@ -148,7 +147,3 @@ static void destroy(grib_context* context, grib_action* act)
grib_context_free_persistent(context, act->name);
grib_context_free_persistent(context, act->op);
}

static void xref(grib_action* d, FILE* f, const char* path)
{
}
19 changes: 2 additions & 17 deletions src/action_class_section.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
START_CLASS_DEF
CLASS = action
IMPLEMENTS = notify_change
IMPLEMENTS = reparse
IMPLEMENTS = xref
END_CLASS_DEF
*/
Expand All @@ -36,9 +34,7 @@ or edit "action.class" and rerun ./make_class.pl
*/

static void init_class (grib_action_class*);
static void xref (grib_action* d, FILE* f,const char* path);
static int notify_change(grib_action* a, grib_accessor* observer,grib_accessor* observed);
static grib_action* reparse(grib_action* a,grib_accessor* acc,int *doit);


typedef struct grib_action_section {
Expand All @@ -57,12 +53,12 @@ static grib_action_class _grib_action_class_section = {
0, /* destroy */

0, /* dump */
&xref, /* xref */
0, /* xref */

0, /* create_accessor*/

&notify_change, /* notify_change */
&reparse, /* reparse */
0, /* reparse */
0, /* execute */
};

Expand Down Expand Up @@ -231,14 +227,3 @@ static int notify_change(grib_action* act, grib_accessor* notified,

return GRIB_SUCCESS;
}

static grib_action* reparse(grib_action* a, grib_accessor* acc, int* doit)
{
fprintf(stderr, "action_class_section::reparse should be inherited: %s\n", a->name);
Assert(0);
return 0;
}

static void xref(grib_action* d, FILE* f, const char* path)
{
}
Loading

0 comments on commit 4d57fc7

Please sign in to comment.