File: global_defines.sed

package info (click to toggle)
plplot 5.9.9-5
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 84,772 kB
  • sloc: ansic: 86,290; xml: 26,754; ada: 17,685; cpp: 15,530; php: 11,938; tcl: 11,125; ml: 6,825; perl: 6,736; f90: 6,709; python: 6,237; java: 6,215; sh: 2,042; makefile: 192; lisp: 75; fortran: 64; sed: 52
file content (43 lines) | stat: -rw-r--r-- 1,993 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# 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.

# Insert text at the start:
1 i\
!     Do not edit this generated file.  Instead, check its consistency\
!     with the #defines in bindings/swig-support/plplotcapi.i using the\
!     (Unix) target "check_f95_parameters".  If that target reports an\
!     inconsistency (via a cmp message) between the generated\
!     plplot_parameters.h_compare file in the build tree and\
!     plplot_parameters.h in the source tree, then copy\
!     plplot_parameters.h_compare on top of plplot_parameters.h and\
!     check in that result.\

# 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?