0N/A#! /bin/sh
0N/A
0N/A#
2362N/A# Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
0N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A#
0N/A# This code is free software; you can redistribute it and/or modify it
0N/A# under the terms of the GNU General Public License version 2 only, as
2362N/A# published by the Free Software Foundation. Oracle designates this
0N/A# particular file as subject to the "Classpath" exception as provided
2362N/A# by Oracle in the LICENSE file that accompanied this code.
0N/A#
0N/A# This code is distributed in the hope that it will be useful, but WITHOUT
0N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A# version 2 for more details (a copy is included in the LICENSE file that
0N/A# accompanied this code).
0N/A#
0N/A# You should have received a copy of the GNU General Public License version
0N/A# 2 along with this work; if not, write to the Free Software Foundation,
0N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A#
2362N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A# or visit www.oracle.com if you need additional information or have any
2362N/A# questions.
0N/A#
0N/A
0N/A# Generate concrete buffer classes
0N/A
0N/A# Required environment variables
0N/A# NAWK SED SPP To invoke tools
0N/A# TYPE Primitive type
0N/A# SRC Source file
0N/A# DST Destination file
0N/A#
0N/A# Optional environment variables
0N/A# RW Mutability: R(ead only), W(ritable)
0N/A# BO Byte order: B(ig), L(ittle), S(wapped), U(nswapped)
0N/A# BIN Defined => generate binary-data access methods
0N/A
0N/Atype=$TYPE
0N/Arw=$RW
0N/Arwkey=XX
0N/A
0N/Acase $type in
0N/A char) fulltype=character;;
2005N/A int) fulltype=integer;;
0N/A *) fulltype=$type;;
0N/Aesac
0N/A
0N/Acase $type in
0N/A byte) LBPV=0;;
0N/A char | short) LBPV=1;;
0N/A int | float) LBPV=2;;
0N/A long | double) LBPV=3;;
0N/Aesac
0N/A
2005N/Acase $type in
2005N/A float|double) floatingPointOrIntegralType=floatingPointType;;
2005N/A *) floatingPointOrIntegralType=integralType;;
2005N/Aesac
2005N/A
0N/AtypesAndBits() {
0N/A
0N/A type="$1"; BO="$2"
0N/A memtype=$type; swaptype=$type; frombits=; tobits=
0N/A
0N/A case $type in
0N/A float) memtype=int
0N/A if [ x$BO != xU ]; then
0N/A swaptype=int
0N/A fromBits=Float.intBitsToFloat
0N/A toBits=Float.floatToRawIntBits
0N/A fi;;
0N/A double) memtype=long
0N/A if [ x$BO != xU ]; then
0N/A swaptype=long
0N/A fromBits=Double.longBitsToDouble
0N/A toBits=Double.doubleToRawLongBits
0N/A fi;;
0N/A esac
0N/A
0N/A echo memtype=$memtype swaptype=$swaptype fromBits=$fromBits toBits=$toBits
0N/A
0N/A echo $type $fulltype $memtype $swaptype \
0N/A | $NAWK '{ type = $1; fulltype = $2; memtype = $3; swaptype = $4;
0N/A x = substr(type, 1, 1);
0N/A Type = toupper(x) substr(type, 2);
0N/A Fulltype = toupper(x) substr(fulltype, 2);
0N/A Memtype = toupper(substr(memtype, 1, 1)) substr(memtype, 2);
0N/A Swaptype = toupper(substr(swaptype, 1, 1)) substr(swaptype, 2);
0N/A printf("Type=%s x=%s Fulltype=%s Memtype=%s Swaptype=%s ",
0N/A Type, x, Fulltype, Memtype, Swaptype); }'
0N/A
0N/A echo "swap=`if [ x$BO = xS ]; then echo Bits.swap; fi`"
0N/A
0N/A}
0N/A
0N/Aeval `typesAndBits $type $BO`
0N/A
0N/Aa=`if [ $type = int ]; then echo an; else echo a; fi`
0N/AA=`if [ $type = int ]; then echo An; else echo A; fi`
0N/A
0N/Aif [ "x$rw" = xR ]; then rwkey=ro; else rwkey=rw; fi
0N/A
0N/Aset -e
0N/A
0N/A$SPP <$SRC >$DST \
0N/A -K$type \
2005N/A -K$floatingPointOrIntegralType \
0N/A -Dtype=$type \
0N/A -DType=$Type \
0N/A -Dfulltype=$fulltype \
0N/A -DFulltype=$Fulltype \
0N/A -Dx=$x \
0N/A -Dmemtype=$memtype \
0N/A -DMemtype=$Memtype \
0N/A -DSwaptype=$Swaptype \
0N/A -DfromBits=$fromBits \
0N/A -DtoBits=$toBits \
0N/A -DLG_BYTES_PER_VALUE=$LBPV \
0N/A -DBYTES_PER_VALUE="(1 << $LBPV)" \
0N/A -DBO=$BO \
0N/A -Dswap=$swap \
0N/A -DRW=$rw \
0N/A -K$rwkey \
0N/A -Da=$a \
0N/A -DA=$A \
0N/A -Kbo$BO
0N/A
0N/Aif [ $BIN ]; then
0N/A
0N/A genBinOps() {
0N/A type="$1"
0N/A Type=`echo $1 | $NAWK '{ print toupper(substr($1, 1, 1)) substr($1, 2) }'`
0N/A fulltype="$2"
0N/A LBPV="$3"
0N/A nbytes="$4"
0N/A nbytesButOne="$5"
0N/A a=`if [ $type = int ]; then echo an; else echo a; fi`
0N/A src=$6
0N/A eval `typesAndBits $type`
0N/A $SPP <$src \
0N/A -Dtype=$type \
0N/A -DType=$Type \
0N/A -Dfulltype=$fulltype \
0N/A -Dmemtype=$memtype \
0N/A -DMemtype=$Memtype \
0N/A -DfromBits=$fromBits \
0N/A -DtoBits=$toBits \
0N/A -DLG_BYTES_PER_VALUE=$LBPV \
0N/A -DBYTES_PER_VALUE="(1 << $LBPV)" \
0N/A -Dnbytes=$nbytes \
0N/A -DnbytesButOne=$nbytesButOne \
0N/A -DRW=$rw \
0N/A -K$rwkey \
0N/A -Da=$a \
0N/A -be
0N/A }
0N/A
0N/A mv $DST $DST.tmp
0N/A sed -e '/#BIN/,$d' <$DST.tmp >$DST
0N/A rm -f $DST.tmp
1776N/A binops=`dirname $SRC`/`basename $SRC .java.template`-bin.java.template
0N/A genBinOps char character 1 two one $binops >>$DST
0N/A genBinOps short short 1 two one $binops >>$DST
0N/A genBinOps int integer 2 four three $binops >>$DST
0N/A genBinOps long long 3 eight seven $binops >>$DST
0N/A genBinOps float float 2 four three $binops >>$DST
0N/A genBinOps double double 3 eight seven $binops >>$DST
0N/A echo '}' >>$DST
0N/A
0N/Afi