Skip to content

Resizable ArrayBuffer: DataView methods#3021

Merged
rwaldron merged 2 commits into
tc39:mainfrom
bocoup:resizable-arraybuffer-dv-methods
Jun 25, 2021
Merged

Resizable ArrayBuffer: DataView methods#3021
rwaldron merged 2 commits into
tc39:mainfrom
bocoup:resizable-arraybuffer-dv-methods

Conversation

@jugglinmike

Copy link
Copy Markdown
Contributor

The files in this patch are highly similar. Only the test for
DataView.prototype.getBigInt64 and DataView.prototype.setBigInt64
were written manually. The others were generated from those files via
the following script:

#!/bin/bash

set -eu

names='
BigUint64
Float32
Float64
Int16
Int32
Int8
Uint16
Uint32
Uint8
'

for name in ${names}; do
  lower=$(echo ${name} | tr '[:upper:]' '[:lower:]')
  if [ ${name} == 'BigUint64' ]; then
    replace_bigints=''
  else
    replace_bigints='-e s/\b\([0-9]\+\)n\b/\1/g'
  fi

  sed \
    -e "s/getbigint64/get${lower}/g" \
    -e "s/getBigInt64/get${name}/g" \
    ${replace_bigints} \
    ./test/built-ins/DataView/prototype/getBigInt64/resizable-buffer.js \
    > ./test/built-ins/DataView/prototype/get${name}/resizable-buffer.js

  sed \
    -e "s/setbigint64/set${lower}/g" \
    -e "s/setBigInt64/set${name}/g" \
    ${replace_bigints} \
    ./test/built-ins/DataView/prototype/setBigInt64/resizable-buffer.js \
    > ./test/built-ins/DataView/prototype/set${name}/resizable-buffer.js
done

The files in this patch are highly similar. Only the test for
`DataView.prototype.getBigInt64` and `DataView.prototype.setBigInt64`
were written manually. The others were generated from those files via
the following script:

    #!/bin/bash

    set -eu

    names='
    BigUint64
    Float32
    Float64
    Int16
    Int32
    Int8
    Uint16
    Uint32
    Uint8
    '

    for name in ${names}; do
      lower=$(echo ${name} | tr '[:upper:]' '[:lower:]')
      if [ ${name} == 'BigUint64' ]; then
        replace_bigints=''
      else
        replace_bigints='-e s/\b\([0-9]\+\)n\b/\1/g'
      fi

      sed \
        -e "s/getbigint64/get${lower}/g" \
        -e "s/getBigInt64/get${name}/g" \
        ${replace_bigints} \
        ./test/built-ins/DataView/prototype/getBigInt64/resizable-buffer.js \
        > ./test/built-ins/DataView/prototype/get${name}/resizable-buffer.js

      sed \
        -e "s/setbigint64/set${lower}/g" \
        -e "s/setBigInt64/set${name}/g" \
        ${replace_bigints} \
        ./test/built-ins/DataView/prototype/setBigInt64/resizable-buffer.js \
        > ./test/built-ins/DataView/prototype/set${name}/resizable-buffer.js
    done
@jugglinmike

Copy link
Copy Markdown
Contributor Author

This is in service of gh-3003.

@rwaldron

Copy link
Copy Markdown
Contributor

The others were generated from those files via the following script:

NICE!

@rwaldron rwaldron merged commit 5b31a8a into tc39:main Jun 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants