Revision: 44516 http://brlcad.svn.sourceforge.net/brlcad/?rev=44516&view=rev Author: bob1961 Date: 2011-04-26 19:28:16 +0000 (Tue, 26 Apr 2011)
Log Message: ----------- Modify asc2g to use libtclcad. Modified Paths: -------------- brlcad/trunk/include/tclcad.h brlcad/trunk/src/conv/CMakeLists.txt brlcad/trunk/src/conv/Makefile.am brlcad/trunk/src/conv/asc/asc2g.c brlcad/trunk/src/libtclcad/tclcad_obj.c Modified: brlcad/trunk/include/tclcad.h =================================================================== --- brlcad/trunk/include/tclcad.h 2011-04-26 17:26:57 UTC (rev 44515) +++ brlcad/trunk/include/tclcad.h 2011-04-26 19:28:16 UTC (rev 44516) @@ -74,9 +74,14 @@ TCLCAD_EXPORT TCLCAD_EXTERN(void tclcad_tcl_library, (Tcl_Interp *interp)); TCLCAD_EXPORT TCLCAD_EXTERN(int Tclcad_Init, (Tcl_Interp *interp)); -/* defined in tcl.c */ +/* defined in tclcad_obj.c */ TCLCAD_EXPORT BU_EXTERN(int Go_Init, (Tcl_Interp *interp)); +TCLCAD_EXPORT BU_EXTERN(int to_open_tcl, + (ClientData UNUSED(clientData), + Tcl_Interp *interp, + int argc, + const char **argv)); __END_DECLS Modified: brlcad/trunk/src/conv/CMakeLists.txt =================================================================== --- brlcad/trunk/src/conv/CMakeLists.txt 2011-04-26 17:26:57 UTC (rev 44515) +++ brlcad/trunk/src/conv/CMakeLists.txt 2011-04-26 19:28:16 UTC (rev 44516) @@ -21,7 +21,7 @@ BRLCAD_ADDEXEC(3dm-g 3dm/3dm-g.cpp "libwdb ${OPENNURBS_LIBRARY}") set_target_properties(3dm-g PROPERTIES COMPILE_DEFINITIONS "OBJ_BREP=1") -BRLCAD_ADDEXEC(asc2g asc/asc2g.c "libged libwdb librt libbu ${WINSOCK_LIB}") +BRLCAD_ADDEXEC(asc2g asc/asc2g.c "libged libwdb librt libbu libtclcad ${WINSOCK_LIB}") BRLCAD_ADDEXEC(asc2pix asc/asc2pix.c libbu) Modified: brlcad/trunk/src/conv/Makefile.am =================================================================== --- brlcad/trunk/src/conv/Makefile.am 2011-04-26 17:26:57 UTC (rev 44515) +++ brlcad/trunk/src/conv/Makefile.am 2011-04-26 19:28:16 UTC (rev 44516) @@ -125,7 +125,7 @@ asc2g_SOURCES = asc/asc2g.c asc2g_CFLAGS = ${STRICT_FLAGS} ${TCL_CPPFLAGS} -asc2g_LDADD = ${WDB} ${GED} +asc2g_LDADD = ${WDB} ${TCLCAD} ${GED} # static is required to avoid MIPSpro 7.3 long rpath linker bug if LINK_STATIC_REQUIRED asc2g_LDFLAGS = -static Modified: brlcad/trunk/src/conv/asc/asc2g.c =================================================================== --- brlcad/trunk/src/conv/asc/asc2g.c 2011-04-26 17:26:57 UTC (rev 44515) +++ brlcad/trunk/src/conv/asc/asc2g.c 2011-04-26 19:28:16 UTC (rev 44516) @@ -43,6 +43,7 @@ #include "ged.h" #include "wdb.h" #include "mater.h" +#include "tclcad.h" /* maximum input line buffer size */ @@ -1761,23 +1762,36 @@ /* this is a Tcl script */ - rewind(ifp); bu_vls_trunc( &line, 0); - /* No longer need ifp - fclose(ifp); ifp = NULL; */ - BU_LIST_INIT(&rt_g.rtg_headwdb.l); interp = Tcl_CreateInterp(); - if (wdb_init_obj(interp, ofp, db_name) != TCL_OK || - wdb_create_cmd(interp, ofp, db_name) != TCL_OK) { - bu_exit(1, "Failed to initialize wdb_obj!\n"); + Go_Init(interp); + wdb_close(ofp); + + { + int ac = 4; + const char *av[5]; + + av[0] = "to_open"; + av[1] = db_name; + av[2] = "db"; + av[3] = argv[2]; + av[4] = (char *)0; + + if (to_open_tcl((ClientData)0, interp, ac, av) != TCL_OK) { + fclose(ifp); + bu_log("Failed to initialize tclcad_obj!\n"); + Tcl_Exit(1); + } } /* Create the safe interpreter */ if ((safe_interp = Tcl_CreateSlave(interp, slave_name, 1)) == NULL) { - bu_exit(1, "Failed to create safe interpreter"); + fclose(ifp); + bu_log("Failed to create safe interpreter"); + Tcl_Exit(1); } /* Create aliases */ @@ -1799,6 +1813,7 @@ while ((gettclblock(&line,ifp)) >= 0) { if (Tcl_Eval(safe_interp, (const char *)bu_vls_addr(&line)) != TCL_OK) { + fclose(ifp); bu_log("Failed to process input file (%s)!\n", argv[1]); bu_log("%s\n", Tcl_GetStringResult(safe_interp)); Tcl_Exit(1); @@ -1807,12 +1822,12 @@ } /* free up our resources */ - mk_write_color_table(ofp); - wdb_close(ofp); ofp = NULL; bu_vls_free(&line); bu_vls_free(&str_title); bu_vls_free(&str_put); + fclose(ifp); + Tcl_Exit(0); } else { bu_vls_free(&line); @@ -1935,7 +1950,7 @@ fclose(ifp); ifp = NULL; wdb_close(ofp); ofp = NULL; - Tcl_Exit(0); + bu_exit(0, ""); return 0; } Modified: brlcad/trunk/src/libtclcad/tclcad_obj.c =================================================================== --- brlcad/trunk/src/libtclcad/tclcad_obj.c 2011-04-26 17:26:57 UTC (rev 44515) +++ brlcad/trunk/src/libtclcad/tclcad_obj.c 2011-04-26 19:28:16 UTC (rev 44516) @@ -96,10 +96,6 @@ (struct ged_obj *gop, struct ged_dm_view *gdvp)); -HIDDEN int to_open_tcl(ClientData clientData, - Tcl_Interp *interp, - int argc, - const char **argv); HIDDEN int to_autoview(struct ged *gedp, int argc, const char *argv[], @@ -1168,7 +1164,7 @@ *@n db get white.r *@n db close */ -HIDDEN int +int to_open_tcl(ClientData UNUSED(clientData), Tcl_Interp *interp, int argc, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd _______________________________________________ BRL-CAD Source Commits mailing list brlcad-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/brlcad-commits