Dead code removal

This commit is contained in:
Shahram Najm 2024-02-19 22:08:24 +00:00
parent 5918bee645
commit 141e2acc0d
2 changed files with 34 additions and 42 deletions

View File

@ -1311,7 +1311,6 @@ 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_print(grib_context* ctx, grib_expression* g, grib_handle* f);
void grib_expression_free(grib_context* ctx, grib_expression* g); void grib_expression_free(grib_context* ctx, grib_expression* g);
void grib_expression_add_dependency(grib_expression* e, grib_accessor* observer); 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);
grib_arguments* grib_arguments_new(grib_context* c, grib_expression* g, grib_arguments* n); grib_arguments* grib_arguments_new(grib_context* c, grib_expression* g, grib_arguments* n);
void grib_arguments_free(grib_context* c, grib_arguments* g); void grib_arguments_free(grib_context* c, grib_arguments* g);
void grib_arguments_print(grib_context* c, grib_arguments* g, grib_handle* f); void grib_arguments_print(grib_context* c, grib_arguments* g, grib_handle* f);

View File

@ -19,8 +19,7 @@ int grib_expression_native_type(grib_handle* h, grib_expression* g)
c = c->super ? *(c->super) : NULL; c = c->super ? *(c->super) : NULL;
} }
if (g->cclass) if (g->cclass)
grib_context_log(h->context, GRIB_LOG_ERROR, "No native_type() in %s", g->cclass->name); grib_context_log(h->context, GRIB_LOG_FATAL, "%s: No native_type() in %s", __func__, g->cclass->name);
Assert(1 == 0);
return 0; return 0;
} }
@ -55,7 +54,7 @@ const char* grib_expression_evaluate_string(grib_handle* h, grib_expression* g,
c = c->super ? *(c->super) : NULL; c = c->super ? *(c->super) : NULL;
} }
if (g->cclass) if (g->cclass)
grib_context_log(h->context, GRIB_LOG_ERROR, "No evaluate_string() in %s", g->cclass->name); grib_context_log(h->context, GRIB_LOG_ERROR, "%s: No evaluate_string() in %s", __func__, g->cclass->name);
*err = GRIB_INVALID_TYPE; *err = GRIB_INVALID_TYPE;
return 0; return 0;
@ -69,8 +68,9 @@ const char* grib_expression_get_name(grib_expression* g)
return c->get_name(g); return c->get_name(g);
c = c->super ? *(c->super) : NULL; c = c->super ? *(c->super) : NULL;
} }
if (g->cclass) printf("No expression_get_name() in %s\n", g->cclass->name); if (g->cclass) {
Assert(1 == 0); grib_context_log(grib_context_get_default(), GRIB_LOG_FATAL, "%s: No get_name() in %s", __func__, g->cclass->name);
}
return 0; return 0;
} }
@ -84,7 +84,6 @@ void grib_expression_print(grib_context* ctx, grib_expression* g, grib_handle* f
} }
c = c->super ? *(c->super) : NULL; c = c->super ? *(c->super) : NULL;
} }
Assert(1 == 0);
} }
void grib_expression_free(grib_context* ctx, grib_expression* g) void grib_expression_free(grib_context* ctx, grib_expression* g)
@ -110,43 +109,37 @@ void grib_expression_add_dependency(grib_expression* e, grib_accessor* observer)
} }
c = c->super ? *(c->super) : NULL; c = c->super ? *(c->super) : NULL;
} }
Assert(1 == 0);
} }
/*----------------------------------------*/ // int grib_expression_set_value(grib_handle* h, grib_expression* g, grib_values* v)
int grib_expression_set_value(grib_handle* h, grib_expression* g, grib_values* v) // {
{ // char buffer[1024];
char buffer[1024]; // int ret = 0;
int ret = 0; // size_t size = sizeof(buffer);
size_t size = sizeof(buffer); // switch (v->type = grib_expression_native_type(h, g)) {
// case GRIB_TYPE_LONG:
switch (v->type = grib_expression_native_type(h, g)) { // return grib_expression_evaluate_long(h, g, &v->long_value);
case GRIB_TYPE_LONG: // break;
return grib_expression_evaluate_long(h, g, &v->long_value); // case GRIB_TYPE_DOUBLE:
break; // return grib_expression_evaluate_double(h, g, &v->double_value);
// break;
case GRIB_TYPE_DOUBLE: // case GRIB_TYPE_STRING:
return grib_expression_evaluate_double(h, g, &v->double_value); // v->string_value = grib_expression_evaluate_string(h, g, buffer, &size, &ret);
break; // if (ret != GRIB_SUCCESS) {
// grib_context_log(h->context, GRIB_LOG_ERROR,
case GRIB_TYPE_STRING: // "grib_expression_set_value: unable to evaluate %s as string",
v->string_value = grib_expression_evaluate_string(h, g, buffer, &size, &ret); // grib_expression_get_name(g));
if (ret != GRIB_SUCCESS) { // return ret;
grib_context_log(h->context, GRIB_LOG_ERROR, // }
"grib_expression_set_value: unable to evaluate %s as string", // Assert(v->string_value != buffer);
grib_expression_get_name(g)); // Assert(v->string_value);
return ret; // break;
} // default:
Assert(v->string_value != buffer); // Assert(!"grib_expression_set_value");
Assert(v->string_value); // break;
break; // }
// return 0;
default: // }
Assert(1 == 0);
break;
}
return 0;
}
/*----------------------------------------*/ /*----------------------------------------*/
grib_arguments* grib_arguments_new(grib_context* c, grib_expression* g, grib_arguments* n) grib_arguments* grib_arguments_new(grib_context* c, grib_expression* g, grib_arguments* n)