diff --git a/include/ged/defines.h b/include/ged/defines.h index c37aee13dc..2b71100649 100644 --- a/include/ged/defines.h +++ b/include/ged/defines.h @@ -389,7 +389,6 @@ struct ged { void *ged_ctx; /* Temporary - do not rely on when designing new functionality */ void *ged_interp; /* Temporary - do not rely on when designing new functionality */ - bu_clbk_t ged_interp_eval; /* FIXME: broke the rule written on the previous line */ }; diff --git a/src/libged/search/search.c b/src/libged/search/search.c index b3b429e322..30a96a31b8 100644 --- a/src/libged/search/search.c +++ b/src/libged/search/search.c @@ -360,10 +360,16 @@ ged_search_core(struct ged *gedp, int argc, const char *argv_orig[]) const char *usage = "[-a] [-v[v..]] [-Q] [-h] [path] [expressions...]\n"; /* COPY argv_orig to argv; */ char **argv = NULL; - bu_clbk_t clbk = gedp->ged_interp_eval; - void *u1 = (void *)gedp->ged_interp; + + + bu_clbk_t clbk = NULL; + void *u1 = (void *)gedp; void *u2 = NULL; + if (ged_clbk_get(&clbk, &u2, gedp, argv_orig[0], 0) == BRLCAD_ERROR) { + bu_log("search cmd callback retrieval error\n"); + return BRLCAD_ERROR; + } /* Find how many options we have. Once we get support * for long options, this logic will have to get more sophisticated diff --git a/src/mged/cmd.c b/src/mged/cmd.c index ecd48589cb..34813652d5 100644 --- a/src/mged/cmd.c +++ b/src/mged/cmd.c @@ -194,7 +194,7 @@ mged_pr_output(Tcl_Interp *interp) int -mged_db_search_callback(int argc, const char *argv[], void *userdata, void *UNUSED(d2)) +mged_db_search_callback(int argc, const char *argv[], void *UNUSED(u1), void *u2) { /* FIXME: pretty much copied from tclcad, ideally this should call * tclcad's eval instead of doing its own thing but this is probably @@ -213,15 +213,15 @@ mged_db_search_callback(int argc, const char *argv[], void *userdata, void *UNUS for (i = 1; i < argc; ++i) Tcl_DStringAppendElement(&script, argv[i]); - ret = Tcl_Eval((Tcl_Interp *)userdata, Tcl_DStringValue(&script)); + ret = Tcl_Eval((Tcl_Interp *)u2, Tcl_DStringValue(&script)); Tcl_DStringFree(&script); - result = Tcl_GetStringResult((Tcl_Interp *)userdata); + result = Tcl_GetStringResult((Tcl_Interp *)u2); len = strlen(result); if (len > 0) bu_log("%s%s", result, result[len-1] == '\n' ? "" : "\n"); - Tcl_ResetResult((Tcl_Interp *)userdata); + Tcl_ResetResult((Tcl_Interp *)u2); /* NOTE: Tcl_Eval saves the last -exec result to GEDP->ged_result_str this causes a duplicate print of the last 'search -exec' in mged (since diff --git a/src/mged/setup.c b/src/mged/setup.c index 0839d4ddd3..6d5b0dd9a3 100644 --- a/src/mged/setup.c +++ b/src/mged/setup.c @@ -485,7 +485,10 @@ mged_setup(Tcl_Interp **interpreter) GEDP->ged_post_closedb_callback = &mged_post_closedb_clbk; GEDP->ged_db_callback_udata = &mged_global_db_ctx; GEDP->ged_interp = (void *)interpreter; - GEDP->ged_interp_eval = &mged_db_search_callback; + + // Register during-execution callback function for search command + ged_clbk_set(GEDP, "search", 0, &mged_db_search_callback, (void *)*interpreter); + struct tclcad_io_data *t_iod = tclcad_create_io_data(); t_iod->io_mode = TCL_READABLE; t_iod->interp = *interpreter; @@ -525,7 +528,6 @@ mged_setup(Tcl_Interp **interpreter) mged_global_variable_setup(*interpreter); mged_variable_setup(*interpreter); GEDP->ged_interp = (void *)*interpreter; - GEDP->ged_interp_eval = &mged_db_search_callback; /* Tcl needs to write nulls onto subscripted variable names */ bu_vls_printf(&str, "%s(state)", MGED_DISPLAY_VAR);