- Interop with C in Clojure
- problem
- Java & C Binding
- JNI Example
- JNA Example
- JNR Example
- SKIP JavaCPP Example
- Panama Example
- JNA Example (SDL2)
- Panama Example (SDL2)
- SDL
- SDL Language Bindings
- CommonLisp?
- Java?
- Clojure?
- java interop types
- How to load library.
- writing wrapper function.
- C structure layout for pointer access.
| name | date |
|---|---|
| JNI | 1997.02 |
| JNA | 2007.05 |
| JNR | 2013.02 |
| JavaCPP | 2015.07 |
| panama | EAB |
- https://github.com/jnr/jnr-ffi
- jnr-ffi is a Java library for loading native libraries without writing JNI code by hand, or using tools such as SWIG.
- https://www.slideshare.net/skrb/jnr-java-native-runtime
- https://www.oracle.com/technetwork/java/jvmls2013nutter-2013526.pdf
- https://openjdk.java.net/projects/panama/
- https://download.java.net/java/early_access/panama/docs/api/java.base/java/foreign/package-summary.html
- Panama: A Foreign Policy for Java by Maurizio Cimadamore
- Going Meta to Valhalla & Panama with John Rose
https://github.com/yulewei/java-ffi-demo JNI > JNR > JNA (Direct Mapping) > JNA (Interface Mapping)
- prepare native c library
writing&& compile interop java file- generate interop c header
writing&& c`mpile interop c librarywriting&& build clojure project with interop java file- call
clojure librarywithnative c libraryandinterop c library
- prepare native c library
writing&& build clojure project
- prepare native c library
writing&& build clojure project
SDL2(C language) binding in clojure
SDL2(C language) binding in clojure
- Simple DirectMedia Layer
- cross-platform development library.
- designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware
- via OpenGL and Direct3D
https://www.libsdl.org/languages.php
Ada C# D Go Lua OCaml Pascal Python Rust
- lispbuilder-sdl - https://github.com/lispbuilder/lispbuilder
- java: https://github.com/javasdl/libjavasdl JNA
- Demo clojure with SDL2 (panama)
| Native Type | Size | Java Type | Common Windows Type |
|---|---|---|---|
| char | 8 | byte | BYTE, TCHAR |
| short | 16 | short | short WORD |
| wchar_t | 16/32 | char | WCHAR, TCHAR |
| int | 32 | int | DWORD |
| int | boolean | BOOL | |
| long | 32/64 | NativeLong | LONG |
| long long, __int64 | 64 | long | |
| float | 32 | float | |
| double | 64 | double | |
| char* | C String | String | LPCTSTR |
| void* | pointer | Pointer | LPVOID, HANDLE, LPXXX |