forked from scala-js/scala-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request scala-js#4677 from sjrd/independent-javalib
Make the javalib independent of the Scala library.
- Loading branch information
Showing
49 changed files
with
1,002 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Scala.js (https://www.scala-js.org/) | ||
* | ||
* Copyright EPFL. | ||
* | ||
* Licensed under Apache License 2.0 | ||
* (https://www.apache.org/licenses/LICENSE-2.0). | ||
* | ||
* See the NOTICE file distributed with this work for | ||
* additional information regarding copyright ownership. | ||
*/ | ||
|
||
package java.nio | ||
|
||
import scala.scalajs.js.typedarray.DataView | ||
|
||
/** Copy of features in `scala.scalajs.js.typedarray.DateViewExt`. | ||
* | ||
* Defined as functions instead of extension methods, because the AnyVal over | ||
* a JS type generates an `equals` method that references `BoxesRunTime`. | ||
*/ | ||
private[nio] object DataViewExt { | ||
/** Reads a 2's complement signed 64-bit integers from the data view. | ||
* @param index Starting index | ||
* @param littleEndian Whether the number is stored in little endian | ||
*/ | ||
@inline | ||
def dataViewGetInt64(dataView: DataView, index: Int, littleEndian: Boolean): Long = { | ||
val high = dataView.getInt32(index + (if (littleEndian) 4 else 0), littleEndian) | ||
val low = dataView.getInt32(index + (if (littleEndian) 0 else 4), littleEndian) | ||
(high.toLong << 32) | (low.toLong & 0xffffffffL) | ||
} | ||
|
||
/** Writes a 2's complement signed 64-bit integers to the data view. | ||
* @param index Starting index | ||
* @param value Value to be written | ||
* @param littleEndian Whether to store the number in little endian | ||
*/ | ||
@inline | ||
def dataViewSetInt64(dataView: DataView, index: Int, value: Long, littleEndian: Boolean): Unit = { | ||
val high = (value >>> 32).toInt | ||
val low = value.toInt | ||
dataView.setInt32(index + (if (littleEndian) 4 else 0), high, littleEndian) | ||
dataView.setInt32(index + (if (littleEndian) 0 else 4), low, littleEndian) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.