From: <ai...@us...> - 2013-11-25 19:44:38
|
Revision: 12749 http://sourceforge.net/p/plplot/code/12749 Author: airwin Date: 2013-11-25 19:44:36 +0000 (Mon, 25 Nov 2013) Log Message: ----------- Move pltcl.c and the build of the pltcl executable from utils to the more obvious (in my opinion) directory location bindings/tcl. Tested by: Alan W. Irwin <ai...@us...> on Linux using the test_noninteractive and test_interactive targets in the build tree. Modified Paths: -------------- trunk/bindings/tcl/CMakeLists.txt trunk/examples/tcl/README.tcldemos trunk/utils/CMakeLists.txt Added Paths: ----------- trunk/bindings/tcl/pltcl.c Removed Paths: ------------- trunk/utils/pltcl.c Modified: trunk/bindings/tcl/CMakeLists.txt =================================================================== --- trunk/bindings/tcl/CMakeLists.txt 2013-11-25 06:30:00 UTC (rev 12748) +++ trunk/bindings/tcl/CMakeLists.txt 2013-11-25 19:44:36 UTC (rev 12749) @@ -187,20 +187,12 @@ if(ENABLE_itcl) include_directories(${ITCL_INCLUDE_PATH}) - set( - libplplottcltk${LIB_TAG}_COMPILE_FLAGS - "${libplplottcltk${LIB_TAG}_COMPILE_FLAGS} -I${ITCL_INCLUDE_PATH}" - ) - set(plplottcltk${LIB_TAG}_link_libraries - ${plplottcltk${LIB_TAG}_link_libraries} - ${ITCL_LIBRARY} - ) - set( - libplplottcltk${LIB_TAG}_LINK_FLAGS - ${libplplottcltk${LIB_TAG}_LINK_FLAGS} - ${ITCL_LIBRARY} - ) + # tkMain.c is the only code that currently has a dependence on + # itcl library routines. Since that code is now part of the source code + # for libplplottcltk_Main, only flags for that library (but not + # libplplottcltk any more) are modified below. + set( libplplottcltk_Main${LIB_TAG}_COMPILE_FLAGS "${libplplottcltk_Main${LIB_TAG}_COMPILE_FLAGS} -I${ITCL_INCLUDE_PATH}" @@ -289,19 +281,10 @@ if(ENABLE_itk) include_directories(${ITK_INCLUDE_PATH}) - set( - libplplottcltk${LIB_TAG}_COMPILE_FLAGS - "${libplplottcltk${LIB_TAG}_COMPILE_FLAGS} -I${ITK_INCLUDE_PATH}" - ) - set(plplottcltk${LIB_TAG}_link_libraries - ${plplottcltk${LIB_TAG}_link_libraries} - ${ITK_LIBRARY} - ) - set( - libplplottcltk${LIB_TAG}_LINK_FLAGS - ${libplplottcltk${LIB_TAG}_LINK_FLAGS} - ${ITK_LIBRARY} - ) + # tkMain.c is the only code that currently has a dependence on + # itk library routines. Since that code is now part of the source code + # for libplplottcltk_Main, only flags for that library (but not + # libplplottcltk any more) are modified below. set( libplplottcltk_Main${LIB_TAG}_COMPILE_FLAGS @@ -588,4 +571,20 @@ ) install(FILES ${PC_CONFIGURED_FILE} DESTINATION ${PKG_CONFIG_DIR}) endif(PKG_CONFIG_EXECUTABLE) + + add_executable(pltcl pltcl.c) + + target_link_libraries(pltcl plplot${LIB_TAG} plplottcltk_Main${LIB_TAG} plplottcltk${LIB_TAG} ${ITCL_LIBRARY} ${TCL_LIBRARY}) + + if(USE_RPATH) + set_target_properties(pltcl + PROPERTIES + INSTALL_RPATH "${LIB_INSTALL_RPATH}" + ) + endif(USE_RPATH) + + install(TARGETS pltcl + EXPORT export_plplot + DESTINATION ${BIN_DIR} + ) endif(ENABLE_tcl) Copied: trunk/bindings/tcl/pltcl.c (from rev 12743, trunk/utils/pltcl.c) =================================================================== --- trunk/bindings/tcl/pltcl.c (rev 0) +++ trunk/bindings/tcl/pltcl.c 2013-11-25 19:44:36 UTC (rev 12749) @@ -0,0 +1,182 @@ +// $Id$ +// +// Main program for Tcl-interface to PLplot. Allows interpretive +// execution of plotting primitives without regard to output driver. +// +// Maurice LeBrun +// IFS, University of Texas at Austin +// 19-Jun-1994 +// +// Copyright (C) 2004 Joao Cardoso +// +// This file is part of PLplot. +// +// PLplot is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License as published +// by the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// PLplot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public License +// along with PLplot; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// +// + +#include "plplotP.h" +#define USINGPLDLL +#include "pltcl.h" +#ifdef HAVE_ITCL +# ifndef HAVE_ITCLDECLS_H +# define RESOURCE_INCLUDED +# endif +# include <itcl.h> +#endif + +static int +AppInit( Tcl_Interp *interp ); + +//-------------------------------------------------------------------------- +// main -- +// +// Just a stub routine to call pltclMain. The latter is nice to have when +// building extended tclsh's, since then you don't have to rely on sucking +// the Tcl main out of libtcl (which doesn't work correctly on all +// systems/compilers/linkers/etc). Hopefully in the future Tcl will +// supply a sufficiently capable tclMain() type function that can be used +// instead. +//-------------------------------------------------------------------------- + +int +main( int argc, const char **argv ) +{ + exit( pltclMain( argc, argv, NULL, AppInit ) ); +} + +//-------------------------------------------------------------------------- +// plExitCmd +// +// PLplot/Tcl extension command -- handle exit. +// The reason for overriding the normal exit command is so we can tell +// the PLplot library to clean up. +//-------------------------------------------------------------------------- + +static int +plExitCmd( ClientData clientData, Tcl_Interp *interp, int argc, char **argv ) +{ + const char *tmp = Tcl_GetStringResult( interp ); + (void) argc; + (void) argv; + (void) clientData; + +// Print error message if one given + if ( tmp != NULL && tmp != '\0' ) + fprintf( stderr, "%s\n", Tcl_GetStringResult( interp ) ); + + plspause( 0 ); + plend(); + + Tcl_UnsetVar( interp, "tcl_prompt1", 0 ); + Tcl_Eval( interp, "tclexit" ); + + return TCL_OK; +} + +//-------------------------------------------------------------------------- +// prPromptCmd +// +// PLplot/Tcl extension command -- print the prompt. +// Allows much more flexible setting of the prompt. +//-------------------------------------------------------------------------- + +static int +prPromptCmd( ClientData clientData, Tcl_Interp *interp, int argc, char **argv ) +{ + PLStream *pls; + char prompt[80]; + (void) argc; + (void) argv; + (void) clientData; + + plgpls( &pls ); + + if ( pls->ipls == 0 ) + sprintf( prompt, "pltext; puts -nonewline \"pltcl> \"; flush stdout" ); + else + sprintf( prompt, "pltext; puts -nonewline \"pltcl_%d> \"; flush stdout", pls->ipls ); + + Tcl_VarEval( interp, prompt, 0 ); + + return TCL_OK; +} + +// +//-------------------------------------------------------------------------- +// +// AppInit -- +// +// This procedure performs application-specific initialization. +// Most applications, especially those that incorporate additional +// packages, will have their own version of this procedure. +// +// Results: +// Returns a standard Tcl completion code, and leaves an error +// message in interp->result if an error occurs. +// +// Side effects: +// Depends on the startup script. +// +//-------------------------------------------------------------------------- +// + +static int +AppInit( Tcl_Interp *interp ) +{ +// +// Call the init procedures for included packages. Each call should +// look like this: +// +// if (Mod_Init(interp) == TCL_ERROR) { +// return TCL_ERROR; +// } +// +// where "Mod" is the name of the module. +// + if ( Tcl_Init( interp ) == TCL_ERROR ) + { + printf( "Error Tcl_Init\n" ); + return TCL_ERROR; + } +#ifdef HAVE_ITCL + if ( Itcl_Init( interp ) == TCL_ERROR ) + { + return TCL_ERROR; + } +#endif + if ( Pltcl_Init( interp ) == TCL_ERROR ) + { + return TCL_ERROR; + } + +// Application-specific startup. That means: for use in pltcl ONLY. + +// Rename "exit" to "tclexit", and insert custom exit handler + + Tcl_VarEval( interp, "rename exit tclexit", (char *) NULL ); + + Tcl_CreateCommand( interp, "exit", (Tcl_CmdProc *) plExitCmd, + (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL ); + + Tcl_CreateCommand( interp, "pr_prompt", (Tcl_CmdProc *) prPromptCmd, + (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL ); + +// Custom prompt, to make sure we are in text mode when entering commands + + Tcl_SetVar( interp, "tcl_prompt1", "pr_prompt", 0 ); + + return TCL_OK; +} Modified: trunk/examples/tcl/README.tcldemos =================================================================== --- trunk/examples/tcl/README.tcldemos 2013-11-25 06:30:00 UTC (rev 12748) +++ trunk/examples/tcl/README.tcldemos 2013-11-25 19:44:36 UTC (rev 12749) @@ -42,7 +42,7 @@ There are two ways to run tcldemos.tcl: (1) -pltcl | ../../utils/pltcl +pltcl | ../../bindings/tcl/pltcl plinit source tcldemos.tcl 0 Modified: trunk/utils/CMakeLists.txt =================================================================== --- trunk/utils/CMakeLists.txt 2013-11-25 06:30:00 UTC (rev 12748) +++ trunk/utils/CMakeLists.txt 2013-11-25 19:44:36 UTC (rev 12749) @@ -69,32 +69,6 @@ install(TARGETS pltek DESTINATION ${BIN_DIR}) -if(ENABLE_tcl) - include_directories( - ${CMAKE_SOURCE_DIR}/bindings/tcl - ${TCL_INCLUDE_PATH} - ) - if(HAVE_ITCL) - include_directories(${ITCL_INCLUDE_PATH}) - endif(HAVE_ITCL) - - add_executable(pltcl pltcl.c) - - target_link_libraries(pltcl plplot${LIB_TAG} plplottcltk_Main${LIB_TAG} plplottcltk${LIB_TAG} ${ITCL_LIBRARY} ${TCL_LIBRARY}) - - if(USE_RPATH) - set_target_properties(pltcl - PROPERTIES - INSTALL_RPATH "${LIB_INSTALL_RPATH}" - ) - endif(USE_RPATH) - - install(TARGETS pltcl - EXPORT export_plplot - DESTINATION ${BIN_DIR} - ) -endif(ENABLE_tcl) - # Build simple executable to check parity bits of all characters read # by stdin. add_executable(parity_bit_check parity_bit_check.c) Deleted: trunk/utils/pltcl.c =================================================================== --- trunk/utils/pltcl.c 2013-11-25 06:30:00 UTC (rev 12748) +++ trunk/utils/pltcl.c 2013-11-25 19:44:36 UTC (rev 12749) @@ -1,182 +0,0 @@ -// $Id$ -// -// Main program for Tcl-interface to PLplot. Allows interpretive -// execution of plotting primitives without regard to output driver. -// -// Maurice LeBrun -// IFS, University of Texas at Austin -// 19-Jun-1994 -// -// Copyright (C) 2004 Joao Cardoso -// -// This file is part of PLplot. -// -// PLplot is free software; you can redistribute it and/or modify -// it under the terms of the GNU Library General Public License as published -// by the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// PLplot is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public License -// along with PLplot; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -// -// - -#include "plplotP.h" -#define USINGPLDLL -#include "pltcl.h" -#ifdef HAVE_ITCL -# ifndef HAVE_ITCLDECLS_H -# define RESOURCE_INCLUDED -# endif -# include <itcl.h> -#endif - -static int -AppInit( Tcl_Interp *interp ); - -//-------------------------------------------------------------------------- -// main -- -// -// Just a stub routine to call pltclMain. The latter is nice to have when -// building extended tclsh's, since then you don't have to rely on sucking -// the Tcl main out of libtcl (which doesn't work correctly on all -// systems/compilers/linkers/etc). Hopefully in the future Tcl will -// supply a sufficiently capable tclMain() type function that can be used -// instead. -//-------------------------------------------------------------------------- - -int -main( int argc, const char **argv ) -{ - exit( pltclMain( argc, argv, NULL, AppInit ) ); -} - -//-------------------------------------------------------------------------- -// plExitCmd -// -// PLplot/Tcl extension command -- handle exit. -// The reason for overriding the normal exit command is so we can tell -// the PLplot library to clean up. -//-------------------------------------------------------------------------- - -static int -plExitCmd( ClientData clientData, Tcl_Interp *interp, int argc, char **argv ) -{ - const char *tmp = Tcl_GetStringResult( interp ); - (void) argc; - (void) argv; - (void) clientData; - -// Print error message if one given - if ( tmp != NULL && tmp != '\0' ) - fprintf( stderr, "%s\n", Tcl_GetStringResult( interp ) ); - - plspause( 0 ); - plend(); - - Tcl_UnsetVar( interp, "tcl_prompt1", 0 ); - Tcl_Eval( interp, "tclexit" ); - - return TCL_OK; -} - -//-------------------------------------------------------------------------- -// prPromptCmd -// -// PLplot/Tcl extension command -- print the prompt. -// Allows much more flexible setting of the prompt. -//-------------------------------------------------------------------------- - -static int -prPromptCmd( ClientData clientData, Tcl_Interp *interp, int argc, char **argv ) -{ - PLStream *pls; - char prompt[80]; - (void) argc; - (void) argv; - (void) clientData; - - plgpls( &pls ); - - if ( pls->ipls == 0 ) - sprintf( prompt, "pltext; puts -nonewline \"pltcl> \"; flush stdout" ); - else - sprintf( prompt, "pltext; puts -nonewline \"pltcl_%d> \"; flush stdout", pls->ipls ); - - Tcl_VarEval( interp, prompt, 0 ); - - return TCL_OK; -} - -// -//-------------------------------------------------------------------------- -// -// AppInit -- -// -// This procedure performs application-specific initialization. -// Most applications, especially those that incorporate additional -// packages, will have their own version of this procedure. -// -// Results: -// Returns a standard Tcl completion code, and leaves an error -// message in interp->result if an error occurs. -// -// Side effects: -// Depends on the startup script. -// -//-------------------------------------------------------------------------- -// - -static int -AppInit( Tcl_Interp *interp ) -{ -// -// Call the init procedures for included packages. Each call should -// look like this: -// -// if (Mod_Init(interp) == TCL_ERROR) { -// return TCL_ERROR; -// } -// -// where "Mod" is the name of the module. -// - if ( Tcl_Init( interp ) == TCL_ERROR ) - { - printf( "Error Tcl_Init\n" ); - return TCL_ERROR; - } -#ifdef HAVE_ITCL - if ( Itcl_Init( interp ) == TCL_ERROR ) - { - return TCL_ERROR; - } -#endif - if ( Pltcl_Init( interp ) == TCL_ERROR ) - { - return TCL_ERROR; - } - -// Application-specific startup. That means: for use in pltcl ONLY. - -// Rename "exit" to "tclexit", and insert custom exit handler - - Tcl_VarEval( interp, "rename exit tclexit", (char *) NULL ); - - Tcl_CreateCommand( interp, "exit", (Tcl_CmdProc *) plExitCmd, - (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL ); - - Tcl_CreateCommand( interp, "pr_prompt", (Tcl_CmdProc *) prPromptCmd, - (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL ); - -// Custom prompt, to make sure we are in text mode when entering commands - - Tcl_SetVar( interp, "tcl_prompt1", "pr_prompt", 0 ); - - return TCL_OK; -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |