From: <ai...@us...> - 2011-01-27 19:03:45
|
Revision: 11513 http://plplot.svn.sourceforge.net/plplot/?rev=11513&view=rev Author: airwin Date: 2011-01-27 19:03:39 +0000 (Thu, 27 Jan 2011) Log Message: ----------- Initial check-in of sed script to transform the #defines in bindings/swig-support/plplotcapi.i into Fortran 95 parameter statements. Create a custom (Unix) target called check_f95_parameters which uses the sed script to create a check version of plplot_parameters.h and compare it with the source tree version to make sure the source tree version is consistent with bindings/swig-support/plplotcapi.i. If the two are ever inconsistent (due to a change in bindings/swig-support/plplotcapi.i or f95/global_defines.sed) check_f95_parameters will show an error until plplot_parameters.h_check is copied from the build tree to plplot_parameters.h to reestablish consistency again. Modified Paths: -------------- trunk/bindings/f95/CMakeLists.txt Added Paths: ----------- trunk/bindings/f95/global_defines.sed Modified: trunk/bindings/f95/CMakeLists.txt =================================================================== --- trunk/bindings/f95/CMakeLists.txt 2011-01-27 18:54:17 UTC (rev 11512) +++ trunk/bindings/f95/CMakeLists.txt 2011-01-27 19:03:39 UTC (rev 11513) @@ -109,6 +109,22 @@ # include those files in the SRCS list or do anything special with # their dependencies. + # Add (Unix) custom target to check that plplot_oct_def is up to date. + add_custom_target( + check_f95_parameters + COMMAND ${CMAKE_COMMAND} -E remove -f + ${CMAKE_CURRENT_BINARY_DIR}/plplot_parameters.h_compare + COMMAND + sed -f ${CMAKE_CURRENT_SOURCE_DIR}/global_defines.sed < + ${CMAKE_SOURCE_DIR}/bindings/swig-support/plplotcapi.i > + ${CMAKE_CURRENT_BINARY_DIR}/plplot_parameters.h_compare + COMMAND + ${CMAKE_COMMAND} -E echo Check that f95 version of plplot_parameters is up to date. + COMMAND + cmp ${CMAKE_CURRENT_SOURCE_DIR}/plplot_parameters.h + ${CMAKE_CURRENT_BINARY_DIR}/plplot_parameters.h_compare + ) + if(STATIC_OPTS) set(plplotf95opts${LIB_TAG}_LIB_SRCS configurable.f90 Added: trunk/bindings/f95/global_defines.sed =================================================================== --- trunk/bindings/f95/global_defines.sed (rev 0) +++ trunk/bindings/f95/global_defines.sed 2011-01-27 19:03:39 UTC (rev 11513) @@ -0,0 +1,32 @@ +# sed script specifically designed to parse the #define statements in +# bindings/swig-support/plplotcapi.i into a file that can be used for +# global variable definitions for f95. + +# Drop every line that is not a #define +/^#define/! d + +# Drop specific #defines from the file that are not available +# because of specific #if statements. +/^#define ZEROW/ d +/^#define ONEW/ d +/OBJECT_DATA/ d +/^#define pltr_img/ d + +# Translate trailing comment identifier into fortran 95 trailing comment. +/^#define/ s?//?!? +# Transform octal constants to Fortran (BOZ) form. +/^#define/ s? 0\([0-9][0-9]*\)? o'\1'? +# Transform hexadecimal constants to Fortran (BOZ) form. +/^#define/ s? 0[xX]\([0-9a-fA-F][0-9a-fA-F]*\)? z'\1'? +# Handle special case of z'80000000' which generates integer overflow +# for gfortran (and probably other Fortran 95 compilers). +/^#define/ s? z'80000000'? ishft(1,31)? + +# Parse what is left while preserving trailing comments. Watch out +# for parentheses around value as well. +# Treat PL_NOTSET as a floating value and append special parameter lines for +# PL_PI and PL_TWOPI in this case as well. + +/^#define/ s?^#define *\(PL_NOTSET\)[ (]*\([^ ]*\)[ )]*\(.*\)$? real(kind=plflt), parameter :: \1 = \2.0_plflt\3\n real(kind=plflt), parameter :: PL_PI = 3.1415926535897932384_plflt\n real(kind=plflt), parameter :: PL_TWOPI = 2.0_plflt*PL_PI? + +/^#define/ s?^#define *\([^ ]*\)[ (]*\([^ ]*\)[ )]*\(.*\)$? integer, parameter :: \1 = \2 \3? Property changes on: trunk/bindings/f95/global_defines.sed ___________________________________________________________________ Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |