-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ffi: migrate to jffi which will provide a path for struct support
- Loading branch information
Showing
7 changed files
with
157 additions
and
180 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package gay.pizza.pork.ffi | ||
|
||
data class FfiAddress(val location: Long) { | ||
companion object { | ||
val Null = FfiAddress(0L) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
17 changes: 17 additions & 0 deletions
17
ffi/src/main/kotlin/gay/pizza/pork/ffi/FfiStringWrapper.kt
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,17 @@ | ||
package gay.pizza.pork.ffi | ||
|
||
import com.kenai.jffi.MemoryIO | ||
|
||
class FfiStringWrapper(input: String) { | ||
val address: Long | ||
|
||
init { | ||
val bytes = input.toByteArray() | ||
address = MemoryIO.getInstance().allocateMemory((bytes.size + 1).toLong(), true) | ||
MemoryIO.getInstance().putZeroTerminatedByteArray(address, bytes, 0, bytes.size) | ||
} | ||
|
||
fun free() { | ||
MemoryIO.getInstance().freeMemory(address) | ||
} | ||
} |
93 changes: 0 additions & 93 deletions
93
ffi/src/main/kotlin/gay/pizza/pork/ffi/JnaNativeProvider.kt
This file was deleted.
Oops, something went wrong.