author | amenkov |
Tue, 14 Sep 2010 12:38:49 +0400 | |
changeset 6505 | b1faae5e44a3 |
parent 5506 | 202f599c92aa |
permissions | -rw-r--r-- |
2 | 1 |
#! /bin/sh |
2 |
||
3 |
# |
|
5506 | 4 |
# Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved. |
2 | 5 |
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6 |
# |
|
7 |
# This code is free software; you can redistribute it and/or modify it |
|
8 |
# under the terms of the GNU General Public License version 2 only, as |
|
5506 | 9 |
# published by the Free Software Foundation. Oracle designates this |
2 | 10 |
# particular file as subject to the "Classpath" exception as provided |
5506 | 11 |
# by Oracle in the LICENSE file that accompanied this code. |
2 | 12 |
# |
13 |
# This code is distributed in the hope that it will be useful, but WITHOUT |
|
14 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 |
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 |
# version 2 for more details (a copy is included in the LICENSE file that |
|
17 |
# accompanied this code). |
|
18 |
# |
|
19 |
# You should have received a copy of the GNU General Public License version |
|
20 |
# 2 along with this work; if not, write to the Free Software Foundation, |
|
21 |
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
22 |
# |
|
5506 | 23 |
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
24 |
# or visit www.oracle.com if you need additional information or have any |
|
25 |
# questions. |
|
2 | 26 |
# |
27 |
||
28 |
# Generate concrete buffer classes |
|
29 |
||
30 |
# Required environment variables |
|
31 |
# NAWK SED SPP To invoke tools |
|
32 |
# TYPE Primitive type |
|
33 |
# SRC Source file |
|
34 |
# DST Destination file |
|
35 |
# |
|
36 |
# Optional environment variables |
|
37 |
# RW Mutability: R(ead only), W(ritable) |
|
38 |
# BO Byte order: B(ig), L(ittle), S(wapped), U(nswapped) |
|
39 |
# BIN Defined => generate binary-data access methods |
|
40 |
||
41 |
type=$TYPE |
|
42 |
rw=$RW |
|
43 |
rwkey=XX |
|
44 |
||
45 |
case $type in |
|
46 |
char) fulltype=character;; |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
47 |
int) fulltype=integer;; |
2 | 48 |
*) fulltype=$type;; |
49 |
esac |
|
50 |
||
51 |
case $type in |
|
52 |
byte) LBPV=0;; |
|
53 |
char | short) LBPV=1;; |
|
54 |
int | float) LBPV=2;; |
|
55 |
long | double) LBPV=3;; |
|
56 |
esac |
|
57 |
||
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
58 |
case $type in |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
59 |
float|double) floatingPointOrIntegralType=floatingPointType;; |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
60 |
*) floatingPointOrIntegralType=integralType;; |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
61 |
esac |
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
62 |
|
2 | 63 |
typesAndBits() { |
64 |
||
65 |
type="$1"; BO="$2" |
|
66 |
memtype=$type; swaptype=$type; frombits=; tobits= |
|
67 |
||
68 |
case $type in |
|
69 |
float) memtype=int |
|
70 |
if [ x$BO != xU ]; then |
|
71 |
swaptype=int |
|
72 |
fromBits=Float.intBitsToFloat |
|
73 |
toBits=Float.floatToRawIntBits |
|
74 |
fi;; |
|
75 |
double) memtype=long |
|
76 |
if [ x$BO != xU ]; then |
|
77 |
swaptype=long |
|
78 |
fromBits=Double.longBitsToDouble |
|
79 |
toBits=Double.doubleToRawLongBits |
|
80 |
fi;; |
|
81 |
esac |
|
82 |
||
83 |
echo memtype=$memtype swaptype=$swaptype fromBits=$fromBits toBits=$toBits |
|
84 |
||
85 |
echo $type $fulltype $memtype $swaptype \ |
|
86 |
| $NAWK '{ type = $1; fulltype = $2; memtype = $3; swaptype = $4; |
|
87 |
x = substr(type, 1, 1); |
|
88 |
Type = toupper(x) substr(type, 2); |
|
89 |
Fulltype = toupper(x) substr(fulltype, 2); |
|
90 |
Memtype = toupper(substr(memtype, 1, 1)) substr(memtype, 2); |
|
91 |
Swaptype = toupper(substr(swaptype, 1, 1)) substr(swaptype, 2); |
|
92 |
printf("Type=%s x=%s Fulltype=%s Memtype=%s Swaptype=%s ", |
|
93 |
Type, x, Fulltype, Memtype, Swaptype); }' |
|
94 |
||
95 |
echo "swap=`if [ x$BO = xS ]; then echo Bits.swap; fi`" |
|
96 |
||
97 |
} |
|
98 |
||
99 |
eval `typesAndBits $type $BO` |
|
100 |
||
101 |
a=`if [ $type = int ]; then echo an; else echo a; fi` |
|
102 |
A=`if [ $type = int ]; then echo An; else echo A; fi` |
|
103 |
||
104 |
if [ "x$rw" = xR ]; then rwkey=ro; else rwkey=rw; fi |
|
105 |
||
106 |
set -e |
|
107 |
||
108 |
$SPP <$SRC >$DST \ |
|
109 |
-K$type \ |
|
4502
18f387917b89
6903754: (bf) Improve floating-point buffer comparison
martin
parents:
4115
diff
changeset
|
110 |
-K$floatingPointOrIntegralType \ |
2 | 111 |
-Dtype=$type \ |
112 |
-DType=$Type \ |
|
113 |
-Dfulltype=$fulltype \ |
|
114 |
-DFulltype=$Fulltype \ |
|
115 |
-Dx=$x \ |
|
116 |
-Dmemtype=$memtype \ |
|
117 |
-DMemtype=$Memtype \ |
|
118 |
-DSwaptype=$Swaptype \ |
|
119 |
-DfromBits=$fromBits \ |
|
120 |
-DtoBits=$toBits \ |
|
121 |
-DLG_BYTES_PER_VALUE=$LBPV \ |
|
122 |
-DBYTES_PER_VALUE="(1 << $LBPV)" \ |
|
123 |
-DBO=$BO \ |
|
124 |
-Dswap=$swap \ |
|
125 |
-DRW=$rw \ |
|
126 |
-K$rwkey \ |
|
127 |
-Da=$a \ |
|
128 |
-DA=$A \ |
|
129 |
-Kbo$BO |
|
130 |
||
131 |
if [ $BIN ]; then |
|
132 |
||
133 |
genBinOps() { |
|
134 |
type="$1" |
|
135 |
Type=`echo $1 | $NAWK '{ print toupper(substr($1, 1, 1)) substr($1, 2) }'` |
|
136 |
fulltype="$2" |
|
137 |
LBPV="$3" |
|
138 |
nbytes="$4" |
|
139 |
nbytesButOne="$5" |
|
140 |
a=`if [ $type = int ]; then echo an; else echo a; fi` |
|
141 |
src=$6 |
|
142 |
eval `typesAndBits $type` |
|
143 |
$SPP <$src \ |
|
144 |
-Dtype=$type \ |
|
145 |
-DType=$Type \ |
|
146 |
-Dfulltype=$fulltype \ |
|
147 |
-Dmemtype=$memtype \ |
|
148 |
-DMemtype=$Memtype \ |
|
149 |
-DfromBits=$fromBits \ |
|
150 |
-DtoBits=$toBits \ |
|
151 |
-DLG_BYTES_PER_VALUE=$LBPV \ |
|
152 |
-DBYTES_PER_VALUE="(1 << $LBPV)" \ |
|
153 |
-Dnbytes=$nbytes \ |
|
154 |
-DnbytesButOne=$nbytesButOne \ |
|
155 |
-DRW=$rw \ |
|
156 |
-K$rwkey \ |
|
157 |
-Da=$a \ |
|
158 |
-be |
|
159 |
} |
|
160 |
||
161 |
mv $DST $DST.tmp |
|
162 |
sed -e '/#BIN/,$d' <$DST.tmp >$DST |
|
163 |
rm -f $DST.tmp |
|
4115
e09be02771b6
6888701: Change all template java source files to a .java-template file suffix
ohair
parents:
2
diff
changeset
|
164 |
binops=`dirname $SRC`/`basename $SRC .java.template`-bin.java.template |
2 | 165 |
genBinOps char character 1 two one $binops >>$DST |
166 |
genBinOps short short 1 two one $binops >>$DST |
|
167 |
genBinOps int integer 2 four three $binops >>$DST |
|
168 |
genBinOps long long 3 eight seven $binops >>$DST |
|
169 |
genBinOps float float 2 four three $binops >>$DST |
|
170 |
genBinOps double double 3 eight seven $binops >>$DST |
|
171 |
echo '}' >>$DST |
|
172 |
||
173 |
fi |