-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add Transform types * chore: add tests for transforms
- Loading branch information
1 parent
8e2ad0c
commit 7089e46
Showing
33 changed files
with
263 additions
and
299 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,8 +20,7 @@ jobs: | |
- uses: VirtusLab/[email protected] | ||
with: | ||
jvm: temurin:1.${{ matrix.jvm }} | ||
apps: mill | ||
- run: mill j${{ matrix.jvm }}.benchmarks.test -f1 -wi 2 -i 2 -o j${{ matrix.jvm }}-${{ matrix.os }}.bench -rff j${{ matrix.jvm }}-${{ matrix.os }}.json -rf json .*${{ matrix.benchmark }}${{ matrix.jit }}.* | ||
- run: ./mill j${{ matrix.jvm }}.benchmarks.test -f1 -wi 2 -i 2 -o j${{ matrix.jvm }}-${{ matrix.os }}.bench -rff j${{ matrix.jvm }}-${{ matrix.os }}.json -rf json .*${{ matrix.benchmark }}${{ matrix.jit }}.* | ||
- run: scala-cli run scripts/PublishBenchmarkReport.sc -- "Java ${{ matrix.jvm}}" ${{ matrix.os }} out/j${{ matrix.jvm }}/benchmarks/test/jmhRun.dest/j${{ matrix.jvm }}-${{ matrix.os }}.json ${{ matrix.benchmark }} ${{ matrix.jit }} >> $GITHUB_STEP_SUMMARY | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
|
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 |
---|---|---|
|
@@ -15,8 +15,7 @@ jobs: | |
- uses: coursier/[email protected] | ||
with: | ||
jvm: temurin:1.17 | ||
apps: mill | ||
- run: mill mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll __.sources | ||
- run: ./mill mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll __.sources | ||
|
||
unit-tests: | ||
strategy: | ||
|
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,13 @@ | ||
package fr.hammons.slinc | ||
|
||
trait Transform[A, B](using val desc: DescriptorOf[B])( | ||
_transformFrom: B => A, | ||
_transformTo: A => B | ||
) extends DescriptorOf[A]: | ||
val descriptor | ||
: TransformDescriptor { type Inner = A; val cRep: desc.descriptor.type } = | ||
new TransformDescriptor: | ||
val cRep: desc.descriptor.type = desc.descriptor | ||
type Inner = A | ||
val transformFrom = _transformFrom | ||
val transformTo = _transformTo |
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 |
---|---|---|
@@ -1,11 +1,12 @@ | ||
package fr.hammons.slinc.modules | ||
|
||
import fr.hammons.slinc.{Bytes, TypeDescriptor} | ||
import fr.hammons.slinc.Bytes | ||
import fr.hammons.slinc.ForeignTypeDescriptor | ||
|
||
/** A module used to perform Platform dependent work with a descriptor | ||
*/ | ||
trait DescriptorModule: | ||
def memberOffsets(sd: List[TypeDescriptor]): IArray[Bytes] | ||
def sizeOf(td: TypeDescriptor): Bytes | ||
def alignmentOf(td: TypeDescriptor): Bytes | ||
def toCarrierType(td: TypeDescriptor): Class[?] | ||
def memberOffsets(sd: List[ForeignTypeDescriptor]): IArray[Bytes] | ||
def sizeOf(td: ForeignTypeDescriptor): Bytes | ||
def alignmentOf(td: ForeignTypeDescriptor): Bytes | ||
def toCarrierType(td: ForeignTypeDescriptor): Class[?] |
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 |
---|---|---|
@@ -1,8 +1,26 @@ | ||
package fr.hammons.slinc.types | ||
|
||
import fr.hammons.slinc.Transform | ||
|
||
type CChar = Byte | ||
type CShort = Short | ||
type CInt = Int | ||
type CFloat = Float | ||
type CDouble = Double | ||
type CLongLong = Long | ||
|
||
opaque type CBool >: Boolean <: Boolean = Boolean | ||
|
||
object CBool: | ||
given Transform[CBool, Byte]( | ||
b => if b != (0: Byte) then true else false, | ||
b => if b then 1: Byte else 0: Byte | ||
) | ||
|
||
opaque type CBoolShort >: Boolean <: Boolean = Boolean | ||
|
||
object CBoolShort: | ||
given Transform[CBoolShort, Short]( | ||
s => if s != (0: Short) then true else false, | ||
b => if b then 1: Short else 0: Short | ||
) |
Oops, something went wrong.