[brlcad-commits] SF.net SVN: brlcad:[47828] brlcad/trunk
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <br...@us...> - 2011-12-07 02:35:10
|
Revision: 47828 http://brlcad.svn.sourceforge.net/brlcad/?rev=47828&view=rev Author: brlcad Date: 2011-12-07 02:34:59 +0000 (Wed, 07 Dec 2011) Log Message: ----------- De-tcl two rather intertwined libbu functions, bu_observer_cmd() and bu_cmd(), along with all of the command history functions. Define bu_cmdtab callback signature so we get proper type checking, but instead of clientdata+tclinterp, make it a void* and make argv const. Those changes end up impacting nearly 8k lines of caller code where we have to update the (mostly-but-not-all-deprecated) various "tcl object" codes to pass their data around within the new observer and cmd callbacks without being explicit function parameters. Remove most of the deprecated/obsolete object API declarations while we're at it so further use isn't encouraged. While moderately equivalent to the prior behavior, this patch does change numerous command outputs from going to the Tcl channel to instead getting output through bu_log. Of course, even through most of the caller code is deprecated, more testing is warranted (particularly for archer). This involved approximately 26 hours of continuous effort. My pinky is tired. Modified Paths: -------------- brlcad/trunk/include/bu.h brlcad/trunk/include/cmd.h brlcad/trunk/include/dg.h brlcad/trunk/include/dm.h brlcad/trunk/include/ged.h brlcad/trunk/include/obj.h brlcad/trunk/src/bwish/cmd.c brlcad/trunk/src/gtools/g_diff.c brlcad/trunk/src/libbu/cmd.c brlcad/trunk/src/libbu/cmdhist.c brlcad/trunk/src/libbu/observer.c brlcad/trunk/src/libbu/tcl.c brlcad/trunk/src/libdm/dm_obj.c brlcad/trunk/src/libdm/labels.c brlcad/trunk/src/libdm/tcl.c brlcad/trunk/src/libfb/fb_obj.c brlcad/trunk/src/libfb/tcl.c brlcad/trunk/src/libged/dg_obj.c brlcad/trunk/src/libged/vdraw.c brlcad/trunk/src/libged/view_obj.c brlcad/trunk/src/libged/wdb_bigE.c brlcad/trunk/src/libged/wdb_importFg4Section.c brlcad/trunk/src/libged/wdb_nirt.c brlcad/trunk/src/libged/wdb_obj.c brlcad/trunk/src/libged/wdb_qray.c brlcad/trunk/src/libged/wdb_track.c brlcad/trunk/src/libged/wdb_vdraw.c brlcad/trunk/src/libtclcad/cmdhist_obj.c brlcad/trunk/src/libtclcad/tclcad_obj.c brlcad/trunk/src/mged/clone.c brlcad/trunk/src/mged/cmd.c brlcad/trunk/src/mged/mged.c Modified: brlcad/trunk/include/bu.h =================================================================== --- brlcad/trunk/include/bu.h 2011-12-07 01:28:03 UTC (rev 47827) +++ brlcad/trunk/include/bu.h 2011-12-07 02:34:59 UTC (rev 47828) @@ -2462,7 +2462,7 @@ */ struct bu_cmdtab { char *ct_name; - int (*ct_func)(); + int (*ct_func)(void *data, int argc, const char *argv[]); }; @@ -5286,7 +5286,7 @@ * runs a given command, calling the corresponding observer callback * if it matches. */ -BU_EXPORT extern int bu_observer_cmd(ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[]); +BU_EXPORT extern int bu_observer_cmd(void *clientData, int argc, const char *argv[]); /** * Notify observers. Modified: brlcad/trunk/include/cmd.h =================================================================== --- brlcad/trunk/include/cmd.h 2011-12-07 01:28:03 UTC (rev 47827) +++ brlcad/trunk/include/cmd.h 2011-12-07 02:34:59 UTC (rev 47828) @@ -25,16 +25,7 @@ * @brief * Routines for maintaining a command history * - * The history routines were borrowed from mged/history.c - * and modified to work with command history objects. - * */ -/** @file cmdhist_obj.c - * - * A cmdhist object contains the attributes and - * methods for maintaining command history. - * - */ #ifndef __CMD_H__ #define __CMD_H__ @@ -61,10 +52,9 @@ #include "bu.h" -#define CMD_NULL (int (*)(ClientData, Tcl_Interp *, int, const char **))NULL -#define CMDHIST_NULL (struct bu_cmdhist *)NULL -#define CMDHIST_OBJ_NULL (struct bu_cmdhist_obj *)NULL +#define CMD_NULL (int (*)(void *, int, const char **))NULL + struct bu_cmdhist { struct bu_list l; struct bu_vls h_command; @@ -72,6 +62,7 @@ struct timeval h_finish; int h_status; }; +#define CMDHIST_NULL (struct bu_cmdhist *)NULL struct bu_cmdhist_obj { struct bu_list l; @@ -79,6 +70,7 @@ struct bu_cmdhist cho_head; struct bu_cmdhist *cho_curr; }; +#define CMDHIST_OBJ_NULL (struct bu_cmdhist_obj *)NULL /** @@ -90,40 +82,24 @@ * added to interp. * * @param clientData - data/state associated with the command - * @param interp - tcl interpreter wherein this command is registered * (Note - the result of the command is also stored here) * @param argc - number of arguments in argv * @param argv - command to execute and its arguments * @param cmds - commands and related function pointers * @param cmd_index - indicates which argv element holds the subcommand * - * @return TCL_OK if successful, otherwise, TCL_ERROR. + * @return BRLCAD_OK if successful, otherwise, BRLCAD_ERROR. */ -BU_EXPORT extern int bu_cmd(ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[], struct bu_cmdtab *cmds, int cmd_index); +BU_EXPORT extern int bu_cmd(void *data, int argc, const char *argv[], struct bu_cmdtab *cmds, int cmd_index); /** - * b u _ r e g i s t e r _ c m d s - * - * This is a convenience routine for registering an array of commands - * with a Tcl interpreter. Note - this is not intended for use by - * commands with associated state (i.e. ClientData). - * - * @param interp - Tcl interpreter wherein to register the commands - * @param cmds - commands and related function pointers - * - * @return - * void - */ -BU_EXPORT extern void bu_register_cmds(Tcl_Interp *interp, struct bu_cmdtab *cmds); - -/** * @brief * Prints out the command history. * * USAGE: - * procname history [-delays] [-outfile filename] + * history [-delays] [-outfile filename] */ -BU_EXPORT extern int bu_cmdhist_history(ClientData clientData, Tcl_Interp *interp, int argc, const char **argv); +BU_EXPORT extern int bu_cmdhist_history(void *clientData, int argc, const char **argv); /** * @brief @@ -132,7 +108,7 @@ * USAGE: * procname add cmd */ -BU_EXPORT extern int bu_cmdhist_add(ClientData clientData, Tcl_Interp *interp, int argc, const char **argv); +BU_EXPORT extern int bu_cmdhist_add(void *clientData, int argc, const char **argv); /** * Return the current command. @@ -140,7 +116,7 @@ * USAGE: * procname curr */ -BU_EXPORT extern int bu_cmdhist_curr(ClientData clientData, Tcl_Interp *interp, int argc, const char **argv); +BU_EXPORT extern int bu_cmdhist_curr(void *clientData, int argc, const char **argv); /** * Set the current command to the next command. @@ -148,7 +124,7 @@ * USAGE: * procname next */ -BU_EXPORT extern int bu_cmdhist_next(ClientData clientData, Tcl_Interp *interp, int argc, const char **argv); +BU_EXPORT extern int bu_cmdhist_next(void *clientData, int argc, const char **argv); /** * Set the current command to the previous command. @@ -156,7 +132,7 @@ * USAGE: * procname prev */ -BU_EXPORT extern int bu_cmdhist_prev(ClientData clientData, Tcl_Interp *interp, int argc, const char **argv); +BU_EXPORT extern int bu_cmdhist_prev(void *clientData, int argc, const char **argv); #endif /* __CMD_H__ */ /** @} */ Modified: brlcad/trunk/include/dg.h =================================================================== --- brlcad/trunk/include/dg.h 2011-12-07 01:28:03 UTC (rev 47827) +++ brlcad/trunk/include/dg.h 2011-12-07 02:34:59 UTC (rev 47828) @@ -21,14 +21,10 @@ /** @{ */ /** @file dg.h * - * Functions provided by the LIBGED geometry editing library that are - * related to drawable geometry. + * DEPRECATED object structures and functions provided by the LIBGED + * geometry editing library that are related to drawable geometry. + * These structures and routines should not be used. * - * A drawable geometry object is associated with a database object and - * is used to maintain lists of geometry that are ready for display. - * This geometry can come from a BRL-CAD database or from vdraw - * commands. The drawable geometry object is also capabable of - * indirectly raytracing geometry that comes from a BRL-CAD database. */ #ifndef __DG_H__ @@ -40,6 +36,13 @@ __BEGIN_DECLS +/* DEPRECATED * DEPRECATED * DEPRECATED * DEPRECATED * DEPRECATED * DEPRECATED * + * DEPRECATED * * DEPRECATED * + * DEPRECATED * Everything in this file should not be used. * DEPRECATED * + * DEPRECATED * * DEPRECATED * + * DEPRECATED * DEPRECATED * DEPRECATED * DEPRECATED * DEPRECATED * DEPRECATED * + */ + /* * Carl's vdraw stuff. */ @@ -49,9 +52,9 @@ #define RT_VDRW_DEF_COLOR 0xffff00 struct vd_curve { struct bu_list l; - char vdc_name[RT_VDRW_MAXNAME+1]; /**< @brief name array */ - long vdc_rgb; /**< @brief color */ - struct bu_list vdc_vhd; /**< @brief head of list of vertices */ + char vdc_name[RT_VDRW_MAXNAME+1]; /**< @brief name array */ + long vdc_rgb; /**< @brief color */ + struct bu_list vdc_vhd; /**< @brief head of list of vertices */ }; #define VD_CURVE_NULL ((struct vd_curve *)NULL) @@ -78,192 +81,170 @@ int aborted; }; + struct dg_qray_color { unsigned char r; unsigned char g; unsigned char b; }; + struct dg_qray_fmt { char type; struct bu_vls fmt; }; + struct dg_obj { struct bu_list l; - struct bu_vls dgo_name; /**< @brief drawable geometry object name */ - struct rt_wdb *dgo_wdbp; /**< @brief associated database */ - struct bu_list dgo_headSolid; /**< @brief head of solid list */ - struct bu_list dgo_headVDraw; /**< @brief head of vdraw list */ - struct vd_curve *dgo_currVHead; /**< @brief current vdraw head */ - struct solid *dgo_freeSolids; /**< @brief ptr to head of free solid list */ + struct bu_vls dgo_name; /**< @brief drawable geometry object name */ + struct rt_wdb *dgo_wdbp; /**< @brief associated database */ + struct bu_list dgo_headSolid; /**< @brief head of solid list */ + struct bu_list dgo_headVDraw; /**< @brief head of vdraw list */ + struct vd_curve *dgo_currVHead; /**< @brief current vdraw head */ + struct solid *dgo_freeSolids; /**< @brief ptr to head of free solid list */ char **dgo_rt_cmd; size_t dgo_rt_cmd_len; struct bu_observer dgo_observers; - struct run_rt dgo_headRunRt; /**< @brief head of forked rt processes */ - struct bu_vls dgo_qray_basename; /**< @brief basename of query ray vlist */ - struct bu_vls dgo_qray_script; /**< @brief query ray script */ - char dgo_qray_effects; /**< @brief t for text, g for graphics or b for both */ - int dgo_qray_cmd_echo; /**< @brief 0 - don't echo command, 1 - echo command */ + struct run_rt dgo_headRunRt; /**< @brief head of forked rt processes */ + struct bu_vls dgo_qray_basename; /**< @brief basename of query ray vlist */ + struct bu_vls dgo_qray_script; /**< @brief query ray script */ + char dgo_qray_effects; /**< @brief t for text, g for graphics or b for both */ + int dgo_qray_cmd_echo; /**< @brief 0 - don't echo command, 1 - echo command */ struct dg_qray_fmt *dgo_qray_fmts; struct dg_qray_color dgo_qray_odd_color; struct dg_qray_color dgo_qray_even_color; struct dg_qray_color dgo_qray_void_color; struct dg_qray_color dgo_qray_overlap_color; - int dgo_shaded_mode; /**< @brief 1 - draw bots shaded by default */ - char *dgo_outputHandler; /**< @brief tcl script for handling output */ - int dgo_uplotOutputMode; /**< @brief output mode for unix plots */ - void (*dgo_rtCmdNotify)(); /**< @brief function called when rt command completes */ + int dgo_shaded_mode; /**< @brief 1 - draw bots shaded by default */ + char *dgo_outputHandler; /**< @brief tcl script for handling output */ + int dgo_uplotOutputMode; /**< @brief output mode for unix plots */ + void (*dgo_rtCmdNotify)(); /**< @brief function called when rt command completes */ + Tcl_Interp *interp; }; -GED_EXPORT extern struct dg_obj HeadDGObj; /**< @brief head of drawable geometry object list */ +GED_EXPORT extern struct dg_obj HeadDGObj; /**< @brief head of drawable geometry object list */ #define GED_DGO_NULL ((struct dg_obj *)NULL) +/* DEPRECATED * DEPRECATED * DEPRECATED * DEPRECATED * DEPRECATED * DEPRECATED * + * DEPRECATED * * DEPRECATED * + * DEPRECATED * Everything in this file should not be used. * DEPRECATED * + * DEPRECATED * * DEPRECATED * + * DEPRECATED * DEPRECATED * DEPRECATED * DEPRECATED * DEPRECATED * DEPRECATED * + */ + /* defined in dg_obj.c */ GED_EXPORT extern int Dgo_Init(Tcl_Interp *interp); GED_EXPORT extern int dgo_cmd(ClientData clientData, Tcl_Interp *interp, int argc, - char **argv); -GED_EXPORT extern int dgo_set_outputHandler_cmd(struct dg_obj *dgop, - Tcl_Interp *interp, - int argc, - char **argv); -GED_EXPORT extern int dgo_set_transparency_cmd(struct dg_obj *dgop, - Tcl_Interp *interp, - int argc, - char **argv); -GED_EXPORT extern int dgo_observer_cmd(struct dg_obj *dgop, - Tcl_Interp *interp, - int argc, - char **argv); + const char **argv); +GED_EXPORT extern int dgo_set_outputHandler_cmd(struct dg_obj *dgop, + int argc, + const char **argv); +GED_EXPORT extern int dgo_set_transparency_cmd(struct dg_obj *dgop, + int argc, + const char **argv); +GED_EXPORT extern int dgo_observer_cmd(struct dg_obj *dgop, + int argc, + const char **argv); GED_EXPORT extern void dgo_deleteProc(ClientData clientData); GED_EXPORT extern void dgo_autoview(struct dg_obj *dgop, - struct view_obj *vop, - Tcl_Interp *interp); -GED_EXPORT extern int dgo_autoview_cmd(struct dg_obj *dgop, - struct view_obj *vop, - Tcl_Interp *interp, - int argc, char **argv); -GED_EXPORT extern int dgo_blast_cmd(struct dg_obj *dgop, - Tcl_Interp *interp, - int argc, - char **argv); -GED_EXPORT extern int dgo_draw_cmd(struct dg_obj *dgop, - Tcl_Interp *interp, - int argc, char **argv, - int kind); -GED_EXPORT extern int dgo_E_cmd(struct dg_obj *dgop, - Tcl_Interp *interp, + struct view_obj *vop); +GED_EXPORT extern int dgo_autoview_cmd(struct dg_obj *dgop, + struct view_obj *vop, + int argc, const char **argv); +GED_EXPORT extern int dgo_blast_cmd(struct dg_obj *dgop, + int argc, + const char **argv); +GED_EXPORT extern int dgo_draw_cmd(struct dg_obj *dgop, + int argc, const char **argv, + int kind); +GED_EXPORT extern int dgo_E_cmd(struct dg_obj *dgop, + int argc, + const char **argv); +GED_EXPORT extern int dgo_erase_cmd(struct dg_obj *dgop, + int argc, + const char **argv); +GED_EXPORT extern int dgo_erase_all_cmd(struct dg_obj *dgop, + int argc, + const char **argv); +GED_EXPORT extern int dgo_get_autoview_cmd(struct dg_obj *dgop, + int argc, + const char **argv); +GED_EXPORT extern int dgo_how_cmd(struct dg_obj *dgop, int argc, - char **argv); -GED_EXPORT extern int dgo_erase_cmd(struct dg_obj *dgop, - Tcl_Interp *interp, - int argc, - char **argv); -GED_EXPORT extern int dgo_erase_all_cmd(struct dg_obj *dgop, - Tcl_Interp *interp, - int argc, - char **argv); -GED_EXPORT extern int dgo_get_autoview_cmd(struct dg_obj *dgop, - Tcl_Interp *interp, - int argc, - char **argv); -GED_EXPORT extern int dgo_how_cmd(struct dg_obj *dgop, - Tcl_Interp *interp, + const char **argv); +GED_EXPORT extern int dgo_illum_cmd(struct dg_obj *dgop, int argc, - char **argv); -GED_EXPORT extern int dgo_illum_cmd(struct dg_obj *dgop, - Tcl_Interp *interp, + const char **argv); +GED_EXPORT extern int dgo_label_cmd(struct dg_obj *dgop, + int argc, + const char **argv); +GED_EXPORT extern struct dg_obj *dgo_open_cmd(const char *oname, + struct rt_wdb *wdbp); +GED_EXPORT extern int dgo_overlay_cmd(struct dg_obj *dgop, int argc, - char **argv); -GED_EXPORT extern int dgo_label_cmd(struct dg_obj *dgop, - Tcl_Interp *interp, + const char **argv); +GED_EXPORT extern int dgo_report_cmd(struct dg_obj *dgop, + int argc, + const char **argv); +GED_EXPORT extern int dgo_rt_cmd(struct dg_obj *dgop, + struct view_obj *vop, + int argc, + const char **argv); +GED_EXPORT extern int dgo_rtabort_cmd(struct dg_obj *dgop, int argc, - char **argv); -GED_EXPORT extern struct dg_obj *dgo_open_cmd(char *oname, - struct rt_wdb *wdbp); -GED_EXPORT extern int dgo_overlay_cmd(struct dg_obj *dgop, - Tcl_Interp *interp, - int argc, - char **argv); -GED_EXPORT extern int dgo_report_cmd(struct dg_obj *dgop, - Tcl_Interp *interp, - int argc, - char **argv); -GED_EXPORT extern int dgo_rt_cmd(struct dg_obj *dgop, - struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char **argv); -GED_EXPORT extern int dgo_rtabort_cmd(struct dg_obj *dgop, - Tcl_Interp *interp, - int argc, - char **argv); -GED_EXPORT extern int dgo_rtcheck_cmd(struct dg_obj *dgop, - struct view_obj *vop, - Tcl_Interp *interp, - int argc, char **argv); -GED_EXPORT extern int dgo_who_cmd(struct dg_obj *dgop, - Tcl_Interp *interp, - int argc, - char **argv); -GED_EXPORT extern void dgo_zap_cmd(struct dg_obj *dgop, - Tcl_Interp *interp); -GED_EXPORT extern int dgo_shaded_mode_cmd(struct dg_obj *dgop, - Tcl_Interp *interp, - int argc, - char **argv); + const char **argv); +GED_EXPORT extern int dgo_rtcheck_cmd(struct dg_obj *dgop, + struct view_obj *vop, + int argc, const char **argv); +GED_EXPORT extern int dgo_who_cmd(struct dg_obj *dgop, + int argc, + const char **argv); +GED_EXPORT extern void dgo_zap_cmd(struct dg_obj *dgop); +GED_EXPORT extern int dgo_shaded_mode_cmd(struct dg_obj *dgop, + int argc, + const char **argv); GED_EXPORT extern int dgo_tree_cmd(struct dg_obj *dgop, - Tcl_Interp *interp, int argc, - char **argv); + const char **argv); GED_EXPORT extern void dgo_color_soltab(); -GED_EXPORT extern void dgo_eraseobjall_callback(struct db_i *dbip, - Tcl_Interp *interp, - struct directory *dp, - int notify); +GED_EXPORT extern void dgo_eraseobjall_callback(struct db_i *dbip, + struct directory *dp, + int notify); GED_EXPORT extern void dgo_eraseobjpath(); GED_EXPORT extern void dgo_impending_wdb_close(); GED_EXPORT extern int dgo_invent_solid(); -GED_EXPORT extern void dgo_notify(struct dg_obj *dgop, - Tcl_Interp *interp); -GED_EXPORT extern void dgo_notifyWdb(struct rt_wdb *wdbp, - Tcl_Interp *interp); +GED_EXPORT extern void dgo_notify(struct dg_obj *dgop); +GED_EXPORT extern void dgo_notifyWdb(struct rt_wdb *wdbp); GED_EXPORT extern void dgo_zapall(); /* defined in nirt.c */ -GED_EXPORT extern int dgo_nirt_cmd(struct dg_obj *dgop, - struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char **argv); -GED_EXPORT extern int dgo_vnirt_cmd(struct dg_obj *dgop, - struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char **argv); +GED_EXPORT extern int dgo_nirt_cmd(struct dg_obj *dgop, + struct view_obj *vop, + int argc, + const char **argv); +GED_EXPORT extern int dgo_vnirt_cmd(struct dg_obj *dgop, + struct view_obj *vop, + int argc, + const char **argv); /* defined in qray.c */ -GED_EXPORT extern int dgo_qray_cmd(struct dg_obj *dgop, - Tcl_Interp *interp, - int argc, - char **argv); +extern int dgo_qray_cmd(void *data, int argc, const char **argv); GED_EXPORT extern void dgo_init_qray(struct dg_obj *dgop); /* defined in bigE.c */ -GED_EXPORT extern int dg_E_cmd(struct dg_obj *dgop, - Tcl_Interp *interp, - int argc, - char **argv); +GED_EXPORT extern int dg_E_cmd(struct dg_obj *dgop, + int argc, + const char **argv); /* functions defined in vdraw.c */ -GED_EXPORT extern int vdraw_cmd_tcl(struct dg_obj *dgop, - Tcl_Interp *interp, - int argc, - char **argv); +GED_EXPORT extern int vdraw_cmd_tcl(struct dg_obj *dgop, + int argc, + const char **argv); __END_DECLS Modified: brlcad/trunk/include/dm.h =================================================================== --- brlcad/trunk/include/dm.h 2011-12-07 01:28:03 UTC (rev 47827) +++ brlcad/trunk/include/dm.h 2011-12-07 02:34:59 UTC (rev 47828) @@ -285,25 +285,6 @@ }; -/** - * D M _ O B J - *@brief - * A display manager object is used for interacting with a display manager. - */ -struct dm_obj { - struct bu_list l; - struct bu_vls dmo_name; /**< @brief display manager object name/cmd */ - struct dm *dmo_dmp; /**< @brief display manager pointer */ -#ifdef USE_FBSERV - struct fbserv_obj dmo_fbs; /**< @brief fbserv object */ -#endif - struct bu_observer dmo_observers; /**< @brief fbserv observers */ - mat_t viewMat; - int (*dmo_drawLabelsHook)(); - void *dmo_drawLabelsHookClientData; -}; - - #define DM_OPEN(_interp, _type, _argc, _argv) dm_open(_interp, _type, _argc, _argv) #define DM_CLOSE(_dmp) _dmp->dm_close(_dmp) #define DM_DRAW_BEGIN(_dmp) _dmp->dm_drawBegin(_dmp) @@ -406,7 +387,7 @@ /* labels.c */ DM_EXPORT extern int dm_draw_labels(struct dm *dmp, struct rt_wdb *wdbp, - char *name, + const char *name, mat_t viewmat, int *labelsColor, int (*labelsHook)(), Modified: brlcad/trunk/include/ged.h =================================================================== --- brlcad/trunk/include/ged.h 2011-12-07 01:28:03 UTC (rev 47827) +++ brlcad/trunk/include/ged.h 2011-12-07 02:34:59 UTC (rev 47828) @@ -540,7 +540,7 @@ struct ged_drawable *ged_gdp; struct ged_view *ged_gvp; - struct fbserv_obj *ged_fbsp; + struct fbserv_obj *ged_fbsp; /* FIXME: this shouldn't be here */ void *ged_dmp; void *ged_refresh_clientdata; /**< @brief client data passed to refresh handler */ @@ -578,14 +578,17 @@ }; +/* FIXME: this shouldn't be part of libged API (libged shouldn't know + * about libdm or libfb types, should be managed through callbacks). + */ struct ged_dm_view { struct bu_list l; struct bu_vls gdv_callback; struct bu_vls gdv_name; struct ged_view *gdv_view; struct dm *gdv_dmp; - struct fbserv_obj gdv_fbs; - struct ged_obj *gdv_gop; /* Pointer back to its ged object */ + struct fbserv_obj gdv_fbs; /* FIXME: this shouldn't be here */ + struct ged_obj *gdv_gop; /* FIXME: this shouldn't be here */ }; /* defined in adc.c */ @@ -748,7 +751,7 @@ /** * Tesselates each operand object, then performs the - * boolean evaluation, storing result in new_obj + * boolean evaluation, storing result in 'new_obj' */ GED_EXPORT extern int ged_bev(struct ged *gedp, int argc, const char *argv[]); Modified: brlcad/trunk/include/obj.h =================================================================== --- brlcad/trunk/include/obj.h 2011-12-07 01:28:03 UTC (rev 47827) +++ brlcad/trunk/include/obj.h 2011-12-07 02:34:59 UTC (rev 47828) @@ -91,466 +91,26 @@ * DEPRECATED * DEPRECATED * DEPRECATED * DEPRECATED * DEPRECATED * DEPRECATED * */ -/* defined in go_refresh.c */ +GED_EXPORT extern int Wdb_Init(Tcl_Interp *interp); +GED_EXPORT extern int Vo_Init(Tcl_Interp *interp); + +/* wdb_obj.c (used by g_diff) */ +GED_EXPORT extern int wdb_get_tcl(void *clientData, int argc, const char *argv[]); +GED_EXPORT extern int wdb_init_obj(Tcl_Interp *interp, struct rt_wdb *wdbp, const char *oname); +GED_EXPORT extern int wdb_create_cmd(struct rt_wdb *wdbp, const char *oname); + +/* wdb_obj.c (used by mged) */ +GED_EXPORT extern int wdb_copy_cmd(struct rt_wdb *wdbp, int argc, const char *argv[]); +GED_EXPORT extern int wdb_stub_cmd(struct rt_wdb *wdbp, int argc, const char *argv[]); +GED_EXPORT extern int wdb_rt_gettrees_cmd(struct rt_wdb *wdbp, int argc, const char *argv[]); + +/* go_refresh.c */ GED_EXPORT extern void go_refresh(struct ged_obj *gop, struct ged_dm_view *gdvp); GED_EXPORT extern void go_refresh_draw(struct ged_obj *gop, struct ged_dm_view *gdvp); -/* FIXME: wdb routines do not belong in libged. need to be removed. - */ -/* defined in wdb_comb_std.c */ -GED_EXPORT extern int wdb_comb_std_cmd(struct rt_wdb *gedp, - Tcl_Interp *interp, - int argc, - char **argv); -/* FIXME: wdb routines do not belong in libged. need to be removed. - */ -/* defined in wdb_obj.c */ -GED_EXPORT extern int Wdb_Init(Tcl_Interp *interp); - -GED_EXPORT extern int wdb_create_cmd(Tcl_Interp *interp, - struct rt_wdb *wdbp, - const char *oname); -GED_EXPORT extern void wdb_deleteProc(ClientData clientData); -GED_EXPORT extern int wdb_get_tcl(ClientData clientData, - Tcl_Interp *interp, - int argc, char *argv[]); -GED_EXPORT extern int wdb_init_obj(Tcl_Interp *interp, - struct rt_wdb *wdbp, - const char *oname); -GED_EXPORT extern struct db_i *wdb_prep_dbip(Tcl_Interp *interp, - const char *filename); -GED_EXPORT extern int wdb_bot_face_sort_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, char *argv[]); -GED_EXPORT extern int wdb_bot_decimate_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_close_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_reopen_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_match_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_get_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_put_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - const char *argv[]); -GED_EXPORT extern int wdb_adjust_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - const char *argv[]); -GED_EXPORT extern int wdb_form_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_tops_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_rt_gettrees_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - const char *argv[]); -GED_EXPORT extern int wdb_dump_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_dbip_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_ls_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_list_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_lt_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_pathlist_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_pathsum_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_expand_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_kill_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_killall_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_killtree_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_copy_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_move_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_move_all_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_concat_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_dup_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_group_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_remove_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_stub_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - const char *argv[]); -GED_EXPORT extern int wdb_region_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_comb_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_find_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_which_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_title_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_color_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_prcolor_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_tol_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_push_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_whatid_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_keep_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_cat_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_instance_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_observer_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_make_bb_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_units_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_hide_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_unhide_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_attr_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_summary_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_comb_std_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_nmg_collapse_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_nmg_simplify_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_shells_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_xpush_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_showmats_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_copyeval_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_version_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_bo_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_track_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_bot_smooth_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int wdb_importFg4Section_cmd(struct rt_wdb *wdbp, - Tcl_Interp *interp, - int argc, - char *argv[]); - - - -/* FIXME: vo routines do not belong in libged. need to be refactored, - * renamed, or removed. - */ -/* defined in view_obj.c */ -GED_EXPORT extern struct view_obj HeadViewObj; /**< @brief head of view object list */ -GED_EXPORT extern int Vo_Init(Tcl_Interp *interp); -GED_EXPORT extern struct view_obj *vo_open_cmd(const char *oname); -GED_EXPORT extern void vo_center(struct view_obj *vop, - Tcl_Interp *interp, - point_t center); -GED_EXPORT extern int vo_center_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern void vo_size(struct view_obj *vop, - Tcl_Interp *interp, - fastf_t size); -GED_EXPORT extern int vo_size_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int vo_invSize_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern void vo_mat_aet(struct view_obj *vop); -GED_EXPORT extern int vo_zoom(struct view_obj *vop, - Tcl_Interp *interp, - fastf_t sf); -GED_EXPORT extern int vo_zoom_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, char *argv[]); -GED_EXPORT extern int vo_orientation_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int vo_lookat_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern void vo_setview(struct view_obj *vop, - Tcl_Interp *interp, - vect_t rvec); -GED_EXPORT extern int vo_setview_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int vo_eye_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int vo_eye_pos_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int vo_pmat_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int vo_perspective_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern void vo_update(struct view_obj *vop, - Tcl_Interp *interp, - int oflag); -GED_EXPORT extern int vo_aet_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int vo_rmat_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int vo_model2view_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int vo_pmodel2view_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int vo_view2model_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int vo_pov_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int vo_units_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int vo_base2local_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int vo_local2base_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int vo_rot(struct view_obj *vop, - Tcl_Interp *interp, - char coord, - char origin, - mat_t rmat, - int (*func)()); -GED_EXPORT extern int vo_rot_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, char *argv[], - int (*func)()); -GED_EXPORT extern int vo_arot_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[], - int (*func)()); -GED_EXPORT extern int vo_mrot_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[], - int (*func)()); -GED_EXPORT extern int vo_tra(struct view_obj *vop, - Tcl_Interp *interp, - char coord, - vect_t tvec, - int (*func)()); -GED_EXPORT extern int vo_tra_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, char *argv[], - int (*func)()); -GED_EXPORT extern int vo_slew(struct view_obj *vop, - Tcl_Interp *interp, - vect_t svec); -GED_EXPORT extern int vo_slew_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, char *argv[]); -GED_EXPORT extern int vo_observer_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int vo_coord_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int vo_rotate_about_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int vo_keypoint_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int vo_vrot_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int vo_sca(struct view_obj *vop, - Tcl_Interp *interp, - fastf_t sf, - int (*func)()); -GED_EXPORT extern int vo_sca_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[], - int (*func)()); -GED_EXPORT extern int vo_viewDir_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int vo_ae2dir_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); -GED_EXPORT extern int vo_dir2ae_cmd(struct view_obj *vop, - Tcl_Interp *interp, - int argc, - char *argv[]); - __END_DECLS #endif /* __GED_H__ */ Modified: brlcad/trunk/src/bwish/cmd.c =================================================================== --- brlcad/trunk/src/bwish/cmd.c 2011-12-07 01:28:03 UTC (rev 47827) +++ brlcad/trunk/src/bwish/cmd.c 2011-12-07 02:34:59 UTC (rev 47828) @@ -51,10 +51,9 @@ /***************************** BWISH/BTCLSH COMMANDS *****************************/ HIDDEN int -cmd_quit(ClientData UNUSED(clientData), - Tcl_Interp *UNUSED(interp), +cmd_quit(void *UNUSED(clientData), int argc, - char **argv) + const char **argv) { int status; @@ -152,8 +151,9 @@ * Prints out the command history, either to bu_log or to a file. */ int -cmd_history(ClientData UNUSED(clientData), Tcl_Interp *interp, int argc, char **argv) +cmd_history(void *clientData, int argc, const char **argv) { + Tcl_Interp *interp = (Tcl_Interp *)clientData; FILE *fp; int with_delays = 0; struct bu_cmdhist *hp, *hp_prev; @@ -277,8 +277,9 @@ int -cmd_hist(ClientData UNUSED(clientData), Tcl_Interp *interp, int argc, char **argv) +cmd_hist(void *clientData, int argc, const char **argv) { + Tcl_Interp *interp = (Tcl_Interp *)clientData; struct bu_vls *vp; struct bu_vls vls; @@ -346,16 +347,26 @@ } -HIDDEN struct bu_cmdtab bwish_cmds[] = +static int +wrapper_func(ClientData data, Tcl_Interp *interp, int argc, const char *argv[]) { - {"exit", cmd_quit}, - {"history", cmd_history}, - {"hist", cmd_hist}, - {"q", cmd_quit}, - {(char *)NULL, CMD_NULL} -}; + struct bu_cmdtab *ctp = (struct bu_cmdtab *)data;; + return ctp->ct_func(interp, argc, argv); +} + +static void +register_cmds(Tcl_Interp *interp, struct bu_cmdtab *cmds) +{ + struct bu_cmdtab *ctp = NULL; + + for (ctp = cmds; ctp->ct_name != (char *)NULL; ctp++) { + (void)Tcl_CreateCommand(interp, ctp->ct_name, wrapper_func, (ClientData)ctp, (Tcl_CmdDeleteProc *)NULL); + } +} + + #ifdef BWISH /* structure provided in libtclcad. provides -format pix-n-w support. * doesn't really seem to be used anywhere except here. @@ -363,11 +374,20 @@ extern Tk_PhotoImageFormat tkImgFmtPIX; #endif + int cmdInit(Tcl_Interp *interp) { + static struct bu_cmdtab bwish_cmds[] = { + {"exit", cmd_quit}, + {"history", cmd_history}, + {"hist", cmd_hist}, + {"q", cmd_quit}, + {(char *)NULL, CMD_NULL} + }; + /* Register bwish/btclsh commands */ - bu_register_cmds(interp, bwish_cmds); + register_cmds(interp, bwish_cmds); #ifdef BWISH /* Add pix format for images */ Modified: brlcad/trunk/src/gtools/g_diff.c =================================================================== --- brlcad/trunk/src/gtools/g_diff.c 2011-12-07 01:28:03 UTC (rev 47827) +++ brlcad/trunk/src/gtools/g_diff.c 2011-12-07 02:34:59 UTC (rev 47828) @@ -873,7 +873,7 @@ /* need to add this object */ has_diff += 1; argv[2] = dp2->d_namep; - if (wdb_get_tcl((ClientData)(wdb2), interp, 3, argv) == TCL_ERROR || + if (wdb_get_tcl((void *)wdb2, 3, (const char **)argv) == TCL_ERROR || !strncmp(Tcl_GetStringResult(interp), "invalid", 7)) { /* could not get TCL version */ if (mode == HUMAN) @@ -982,7 +982,7 @@ bu_exit(1, "wdb_init_obj failed on %s\n", file1); } - if (wdb_create_cmd(interp, wdb1, "_db1") != TCL_OK) { + if (wdb_create_cmd(wdb1, "_db1") != TCL_OK) { wdb_close(wdb1); bu_exit(1, "wdb_create_cmd failed on %s\n", file1); } @@ -1020,7 +1020,7 @@ bu_exit(1, "wdb_init_obj failed on %s\n", file2); } - if (wdb_create_cmd(interp, wdb2, "_db2") != TCL_OK) { + if (wdb_create_cmd(wdb2, "_db2") != TCL_OK) { wdb_close(wdb1); bu_exit(1, "wdb_create_cmd failed on %s\n", file2); } Modified: brlcad/trunk/src/libbu/cmd.c =================================================================== --- brlcad/trunk/src/libbu/cmd.c 2011-12-07 01:28:03 UTC (rev 47827) +++ brlcad/trunk/src/libbu/cmd.c 2011-12-07 02:34:59 UTC (rev 47828) @@ -29,47 +29,38 @@ int -bu_cmd(ClientData clientData, Tcl_Interp *interp, int argc, const char **argv, struct bu_cmdtab *cmds, int cmd_index) +bu_cmd(void *data, int argc, const char **argv, struct bu_cmdtab *cmds, int cmd_index /*, const int *retval */) { struct bu_cmdtab *ctp = NULL; /* sanity */ if (UNLIKELY(cmd_index >= argc)) { - Tcl_AppendResult(interp, "missing command; must be one of:", (char *)NULL); + bu_log("missing command; must be one of:"); goto missing_cmd; } for (ctp = cmds; ctp->ct_name != (char *)NULL; ctp++) { if (ctp->ct_name[0] == argv[cmd_index][0] && BU_STR_EQUAL(ctp->ct_name, argv[cmd_index])) { - return (*ctp->ct_func)(clientData, interp, argc, argv); + /* retval = (*ctp->ct_func(data, argc, argv); + * return BRLCAD_OK; + */ + return (*ctp->ct_func)(data, argc, argv); } } - Tcl_AppendResult(interp, "unknown command: ", argv[cmd_index], ";", " must be one of: ", (char *)NULL); + bu_log("unknown command: %s; must be one of: ", argv[cmd_index]); missing_cmd: for (ctp = cmds; ctp->ct_name != (char *)NULL; ctp++) { - Tcl_AppendResult(interp, " ", ctp->ct_name, (char *)NULL); + bu_log(" %s", ctp->ct_name); } - Tcl_AppendResult(interp, "\n", (char *)NULL); + bu_log("\n"); - return TCL_ERROR; + return BRLCAD_ERROR; } -void -bu_register_cmds(Tcl_Interp *interp, struct bu_cmdtab *cmds) -{ - struct bu_cmdtab *ctp = NULL; - - for (ctp = cmds; ctp->ct_name != (char *)NULL; ctp++) { - Tcl_CmdProc *func = (Tcl_CmdProc *)ctp->ct_func; - (void)Tcl_CreateCommand(interp, ctp->ct_name, func, (ClientData)ctp, (Tcl_CmdDeleteProc *)NULL); - } -} - - /* * Local Variables: * mode: C Modified: brlcad/trunk/src/libbu/cmdhist.c =================================================================== --- brlcad/trunk/src/libbu/cmdhist.c 2011-12-07 01:28:03 UTC (rev 47827) +++ brlcad/trunk/src/libbu/cmdhist.c 2011-12-07 02:34:59 UTC (rev 47828) @@ -23,8 +23,6 @@ #include <string.h> #include "bio.h" -#include "tcl.h" - #include "bu.h" #include "cmd.h" @@ -33,7 +31,7 @@ * H I S T O R Y _ R E C O R D * * Stores the given command with start and finish times in the - * history vls'es. 'status' is either TCL_OK or TCL_ERROR. + * history vls'es. 'status' is either BRLCAD_OK or BRLCAD_ERROR. */ HIDDEN void cmdhist_record(struct bu_cmdhist_obj *chop, struct bu_vls *cmdp, struct timeval *start, struct timeval *finish, int status) @@ -77,23 +75,18 @@ int -bu_cmdhist_history(ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[]) +bu_cmdhist_history(void *data, int argc, const char *argv[]) { - struct bu_cmdhist_obj *chop = (struct bu_cmdhist_obj *)clientData; FILE *fp; int with_delays = 0; struct bu_cmdhist *hp, *hp_prev; struct bu_vls str; struct timeval tvdiff; + struct bu_cmdhist_obj *chop = (struct bu_cmdhist_obj *)data; if (argc < 2 || 5 < argc) { - struct bu_vls vls; - - bu_vls_init(&vls); - bu_vls_printf(&vls, "help history"); - Tcl_Eval(interp, bu_vls_addr(&vls)); - bu_vls_free(&vls); - return TCL_ERROR; + bu_log("Usage: %s -delays\nList command history.\n", argv[0]); + return BRLCAD_ERROR; } fp = NULL; @@ -106,23 +99,22 @@ else if (BU_STR_EQUAL(argv[2], outfile)) { if (fp != NULL) { fclose(fp); - Tcl_AppendResult(interp, "history: -outfile option given more than once\n", - (char *)NULL); - return TCL_ERROR; + bu_log("%s: -outfile option given more than once\n", argv[0]); + return BRLCAD_ERROR; } else if (argc < 4 || BU_STR_EQUAL(argv[3], delays)) { - Tcl_AppendResult(interp, "history: I need a file name\n", (char *)NULL); - return TCL_ERROR; + bu_log("%s: I need a file name\n", argv[0]); + return BRLCAD_ERROR; } else { fp = fopen(argv[3], "ab+"); if (UNLIKELY(fp == NULL)) { - Tcl_AppendResult(interp, "history: error opening file", (char *)NULL); - return TCL_ERROR; + bu_log("%s: error opening file", argv[0]); + return BRLCAD_ERROR; } --argc; ++argv; } } else { - Tcl_AppendResult(interp, "Invalid option ", argv[2], "\n", (char *)NULL); + bu_log("Invalid option %s\n", argv[2]); } --argc; ++argv; @@ -139,40 +131,37 @@ } - if (hp->h_status == TCL_ERROR) + if (hp->h_status == BRLCAD_ERROR) bu_vls_printf(&str, "# "); bu_vls_vlscat(&str, &(hp->h_command)); if (fp != NULL) bu_vls_fwrite(fp, &str); else - Tcl_AppendResult(interp, bu_vls_addr(&str), (char *)NULL); + bu_log("%s\n", bu_vls_addr(&str)); } if (fp != NULL) fclose(fp); - return TCL_OK; + return BRLCAD_OK; } int -bu_cmdhist_add(ClientData clientData, Tcl_Interp *interp, int argc, const char **argv) +bu_cmdhist_add(void *clientData, int argc, const char **argv) { struct bu_cmdhist_obj *chop = (struct bu_cmdhist_obj *)clientData; struct bu_vls vls; struct timeval zero; if (argc != 3) { - bu_vls_init(&vls); - bu_vls_printf(&vls, "helplib cmdhist_add"); - Tcl_Eval(interp, bu_vls_addr(&vls)); - bu_vls_free(&vls); - return TCL_ERROR; + bu_log("ERROR: expecting only three arguments\n"); + return BRLCAD_ERROR; } if (UNLIKELY(argv[2][0] == '\n' || argv[2][0] == '\0')) - return TCL_OK; + return BRLCAD_OK; bu_vls_init(&vls); bu_vls_strcpy(&vls, argv[2]); @@ -180,84 +169,69 @@ bu_vls_putc(&vls, '\n'); zero.tv_sec = zero.tv_usec = 0L; - cmdhist_record(chop, &vls, &zero, &zero, TCL_OK); + cmdhist_record(chop, &vls, &zero, &zero, BRLCAD_OK); bu_vls_free(&vls); - return TCL_OK; + return BRLCAD_OK; } int -bu_cmdhist_prev(ClientData clientData, Tcl_Interp *interp, int argc, const char **argv) +bu_cmdhist_prev(void *clientData, int argc, const char **UNUSED(argv)) { struct bu_cmdhist_obj *chop = (struct bu_cmdhist_obj *)clientData; struct bu_cmdhist *hp; if (argc != 2) { - struct bu_vls vls; - - bu_vls_init(&vls); - bu_vls_printf(&vls, "helplib %s", argv[0]); - Tcl_Eval(interp, bu_vls_addr(&vls)); - bu_vls_free(&vls); - return TCL_ERROR; + bu_log("ERROR: expecting only two arguments\n"); + return BRLCAD_ERROR; } hp = BU_LIST_PLAST(bu_cmdhist, chop->cho_curr); if (BU_LIST_NOT_HEAD(hp, &chop->cho_head.l)) chop->cho_curr = hp; - Tcl_AppendResult(interp, bu_vls_addr(&chop->cho_curr->h_command), (char *)NULL); - return TCL_OK; + bu_log("%s", bu_vls_addr(&chop->cho_curr->h_command)); + return BRLCAD_OK; } int -bu_cmdhist_curr(ClientData clientData, Tcl_Interp *interp, int argc, const char **argv) +bu_cmdhist_curr(void *clientData, int argc, const char **UNUSED(argv)) { struct bu_cmdhist_obj *chop = (struct bu_cmdhist_obj *)clientData; if (argc != 2) { - struct bu_vls vls; - - bu_vls_init(&vls); - bu_vls_printf(&vls, "helplib %s", argv[0]); - Tcl_Eval(interp, bu_vls_addr(&vls)); - bu_vls_free(&vls); - return TCL_ERROR; + bu_log("ERROR: expecting only two arguments\n"); + return BRLCAD_ERROR; } if (BU_LIST_NOT_HEAD(chop->cho_curr, &chop->cho_head.l)) - Tcl_AppendResult(interp, bu_vls_addr(&chop->cho_curr->h_command), (char *)NULL); + bu_log("%s", bu_vls_addr(&chop->cho_curr->h_command)); - return TCL_OK; + return BRLCAD_OK; } int -bu_cmdhist_next(ClientData clientData, Tcl_Interp *interp, int argc, const char **argv) +bu_cmdhist_next(void *clientData, int argc, const char **UNUSED(argv)) { struct bu_cmdhist_obj *chop = (struct bu_cmdhist_obj *)clientData; if (argc != 2) { - struct bu_vls vls; - - bu_vls_init(&vls); - bu_vls_printf(&vls, "helplib %s", argv[0]); - Tcl_Eval(interp, bu_vls_addr(&vls)); - bu_vls_free(&vls); - return TCL_ERROR; + bu_log("ERROR: expecting only two arguments\n"); + return BRLCAD_ERROR; } if (BU_LIST_IS_HEAD(chop->cho_curr, &chop->cho_head.l)) - return TCL_ERROR; + return BRLCAD_ERROR; chop->cho_curr = BU_LIST_PNEXT(bu_cmdhist, chop->cho_curr); if (BU_LIST_IS_HEAD(chop->cho_curr, &chop->cho_head.l)) - return TCL_ERROR; + return BRLCAD_ERROR; - Tcl_AppendResult(interp, bu_vls_addr(&chop->cho_curr->h_command), (char *)NULL); - return TCL_OK; + bu_log("%s", bu_vls_addr(&chop->cho_curr->h_command)); + return BRLCAD_OK; } Modified: brlcad/trunk/src/libbu/observer.c =================================================================== --- brlcad/trunk/src/libbu/observer.c 2011-12-07 01:28:03 UTC (rev 47827) +++ brlcad/trunk/src/libbu/observer.c 2011-12-07 02:34:59 UTC (rev 47828) @@ -35,19 +35,14 @@ * */ HIDDEN int -observer_attach_tcl(ClientData clientData, Tcl_Interp *interp, int argc, const char **argv) +observer_attach(void *clientData, int argc, const char **argv) { struct bu_observer *headp = (struct bu_observer *)clientData; struct bu_observer *op; if (argc < 2 || 3 < argc) { - struct bu_vls vls; - - bu_vls_init(&vls); - bu_vls_printf(&vls, "helplib bu_observer_attach"); - Tcl_Eval(interp, bu_vls_addr(&vls)); - bu_vls_free(&vls); - return TCL_ERROR; + bu_log("ERROR: expecting only three arguments\n"); + return BRLCAD_ERROR; } /* see if it already exists, if so, modify it */ @@ -60,7 +55,7 @@ /* overwrite cmd */ bu_vls_strcpy(&op->cmd, argv[2]); - return TCL_OK; + return BRLCAD_OK; } /* acquire bu_observer struct */ @@ -77,7 +72,7 @@ /* append to list of bu_observer's */ BU_LIST_APPEND(&headp->l, &op->l); - return TCL_OK; + return BRLCAD_OK; } @@ -89,19 +84,14 @@ * */ HIDDEN int -observer_detach_tcl(ClientData clientData, Tcl_Interp *interp, int argc, const char **argv) +observer_detach(void *clientData, int argc, const char **argv) { struct bu_observer *headp = (struct bu_observer *)clientData; struct bu_observer *op; if (argc != 2) { - struct bu_vls vls; - - bu_vls_init(&vls); - bu_vls_printf(&vls, "helplib bu_observer_attach"); - Tcl_Eval(interp, bu_vls_addr(&vls)); - bu_vls_free(&vls); - return TCL_ERROR; + bu_log("ERROR: expecting two arguments\n"); + return BRLCAD_ERROR; } /* search for observer and remove from list */ @@ -110,13 +100,13 @@ BU_LIST_DEQUEUE(&op->l); bu_vls_free(&op->observer); bu_vls_free(&op->cmd); - bu_free((genptr_t)op, "observer_detach_tcl: op"); + bu_free((genptr_t)op, "observer_detach: op"); - return TCL_OK; + return BRLCAD_OK; } - Tcl_AppendResult(interp, "detach: ", argv[1], " not found", (char *)NULL); - return TCL_ERROR; + bu_log("detach: %s not found", argv[1]); + return BRLCAD_ERROR; } @@ -128,27 +118,21 @@ * */ HIDDEN int -observer_show_tcl(ClientData clientData, Tcl_Interp *interp, int argc, const char **argv) +observer_show(void *clientData, int argc, const char **UNUSED(argv)) { struct bu_observer *headp = (struct bu_observer *)clientData; struct bu_observer *op; if (argc != 1) { - struct bu_vls vls; - - bu_vls_init(&vls); - bu_vls_printf(&vls, "helplib %s", argv[0]); - Tcl_Eval(interp, bu_vls_addr(&vls)); - bu_vls_free(&vls); - return TCL_ERROR; + bu_log("ERROR: expecting only one argument\n"); + return BRLCAD_ERROR; } for (BU_LIST_FOR(op, bu_observer, &headp->l)) { - Tcl_AppendResult(interp, bu_vls_addr(&op->observer), " - ", - bu_vls_addr(&op->cmd), "\n", (char *)NULL); + bu_log("%s - %s\n", bu_vls_addr(&op->observer), bu_vls_addr(&op->cmd)); } - return TCL_OK; + return BRLCAD_OK; } @@ -198,17 +182,17 @@ * wdb_obj interfaces. */ static struct bu_cmdtab bu_observer_cmds[] = { - {"attach", observer_attach_tcl}, - {"detach", observer_detach_tcl}, - {"show", observer_show_tcl}, + {"attach", observer_attach}, + {"detach", observer_detach}, + {"show", observer_show}, {(char *)0, CMD_NULL} }; int -bu_observer_cmd(ClientData clientData, Tcl_Interp *interp, int argc, const char **argv) +bu_observer_cmd(void *clientData, int argc, const char **argv) { - return bu_cmd(clientData, interp, argc, argv, bu_observer_cmds, 0); + return bu_cmd(clientData, argc, argv, bu_observer_cmds, 0); } Modified: brlcad/trunk/src/libbu/tcl.c =================================================================== --- brlcad/trunk/src/libbu/tcl.c 2011-12-07 01:28:03 UTC (rev 47827) +++ brlcad/trunk/src/libbu/tcl.c 2011-12-07 02:34:59 UTC (rev 47828) @@ -38,124 +38,57 @@ /** - * Convert the "form" of a bu_structparse table into a TCL result - * string, with parameter-name data-type pairs: + * A wrapper for bu_mem_barriercheck. * - * V {%f %f %f} A {%f %f %f} - * - * A different routine should build a more general 'form', along the - * lines of: - * - * {V {%f %f %f} default {help}} {A {%f %f %f} default# {help}} - * - * @param interp tcl interpreter - * @param sp structparse table - * - * @return - * void - */ -HIDDEN void -tcl_bu_structparse_get_terse_form(Tcl_Interp *interp, - const struct bu_structparse *sp) -{ -#if 1 - struct bu_vls vlog; - - bu_vls_init(&vlog); - bu_structparse_get_terse_form(&vlog, sp); - Tcl_AppendResult(interp, bu_vls_addr(&vlog), (char *)NULL); - bu_vls_free(&vlog); -#else - struct bu_vls str; - int i; - - bu_vls_init(&str); - - while (sp->sp_name != NULL) { - Tcl_AppendElement(interp, sp->sp_name); - bu_vls_trunc(&str, 0); - /* These types are specified by lengths, e.g. %80s */ - if (BU_STR_EQUAL(sp->sp_fmt, "%c") || - BU_STR_EQUAL(sp->sp_fmt, "%s") || - BU_STR_EQUAL(sp->sp_fmt, "%S") || /* XXX - DEPRECATED [7.14] */ - BU_STR_EQUAL(sp->sp_fmt, "%V")) { - if (sp->sp_count > 1) { - /* Make them all look like %###s */ - bu_vls_printf(&str, "%%%lds", sp->sp_count); - } else { - /* Singletons are specified by their actual character */ - bu_vls_printf(&str, "%%c"); - } - } else { - /* Vectors are specified by repetition, e.g. {%f %f %f} */ - bu_vls_printf(&str, "%s", sp->sp_fmt); - for (i = 1; i < sp->sp_count; i++) - bu_vls_printf(&str, " %s", sp->sp_fmt); - } - Tcl_AppendElement(interp, bu_vls_addr(&str)); - ++sp; - } - bu_vls_free(&str); -#endif -} - - -/** - * A tcl wrapper for bu_mem_barriercheck. - * * @param clientData - associated data/state - * @param interp - tcl interpreter in which this command was registered. * @param argc - number of elements in argv * @param argv - command name and arguments * - * @return TCL_OK if successful, otherwise, TCL_ERROR. + * @return BRLCAD_OK if successful, otherwise, BRLCAD_ERROR. */ HIDDEN int tcl_bu_mem_barriercheck(ClientData UNUSED(clientData), - Tcl_Interp *interp, int argc, const char **argv) { int ret; if (argc > 1) { - Tcl_AppendResult(interp, "Usage: ", argv[0], "\n", (char *)NULL); - return TCL_ERROR; + bu_log("Usage: %s\n", argv[0]); + return BRLCAD_ERROR; } ret = bu_mem_barriercheck(); if (UNLIKELY(ret < 0)) { - Tcl_AppendResult(interp, "bu_mem_barriercheck() failed\n", NULL); - return TCL_ERROR; + bu_log("bu_mem_barriercheck() failed\n"); + return BRLCAD_ERROR; } - return TCL_OK; + return BRLCAD_OK; } /** - * A tcl wrapper for bu_prmem. Prints map of - * memory currently in use, to stderr. + * A wrapper for bu_prmem. Prints map of memory currently in use, to + * stderr. * * @param clientData - associated data/state - * @param interp - tcl interpreter in which this command was registered. * @param argc - number of elements in argv * @param argv - command name and arguments * - * @return TCL_OK if successful, otherwise, TCL_ERROR. + * @return BRLCAD_OK if successful, otherwise, BRLCAD_ERROR. */ HIDDEN int tcl_bu_prmem(ClientData UNUSED(clientData), - Tcl_Interp *interp, int argc, const char **argv) { if (argc != 2) { - Tcl_AppendResult(interp, "Usage: bu_prmem title\n"); - return TCL_ERROR; + bu_log("Usage: bu_prmem title\n"); + return BRLCAD_ERROR; } bu_prmem(argv[1]); - return TCL_OK; + return BRLCAD_OK; } @@ -176,15 +109,13 @@ * bu_get_value_by_keyword V8 [concat type [.inmem get box.s]] * * @param clientData - associated data/state - * @param interp - tcl interpreter in which this command was registered. * @param argc - number of elements in argv * @param argv - command name and arguments * - * @return TCL_OK if successful, otherwise, TCL_ERROR. + * @return BRLCAD_OK if successful, otherwise, BRLCAD_ERROR. */ HIDDEN int tcl_bu_get_value_by_keyword(ClientData UNUSED(clientData), - Tcl_Interp *interp, int ar... [truncated message content] |