Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/netpyoung/pt.c-interop-in-clojure
https://youtu.be/40cvevHg0J8
https://github.com/netpyoung/pt.c-interop-in-clojure
clojure ffi interop java
Last synced: 4 months ago
JSON representation
https://youtu.be/40cvevHg0J8
- Host: GitHub
- URL: https://github.com/netpyoung/pt.c-interop-in-clojure
- Owner: netpyoung
- Created: 2019-04-21T13:58:54.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-19T15:34:38.000Z (over 4 years ago)
- Last Synced: 2024-10-11T10:14:23.216Z (4 months ago)
- Topics: clojure, ffi, interop, java
- Language: Clojure
- Homepage:
- Size: 14.6 KB
- Stars: 13
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
Awesome Lists containing this project
README
* Table of Contents :TOC:
- [[#interop-with-c-in-clojure][Interop with C in Clojure]]
- [[#problem][problem]]
- [[#java--c-binding][Java & C Binding]]
- [[#jni][JNI]]
- [[#jna][JNA]]
- [[#jnr][JNR]]
- [[#skip-javacpp][SKIP JavaCPP]]
- [[#panama][Panama]]
- [[#performance-check][performance check]]
- [[#jni-example][JNI Example]]
- [[#jna-example][JNA Example]]
- [[#jnr-example][JNR Example]]
- [[#skip-javacpp-example][SKIP JavaCPP Example]]
- [[#panama-example][Panama Example]]
- [[#jna-example-sdl2][JNA Example (SDL2)]]
- [[#panama-example-sdl2][Panama Example (SDL2)]]
- [[#sdl][SDL]]
- [[#sdl-language-bindings][SDL Language Bindings]]
- [[#commonlisp][CommonLisp?]]
- [[#java][Java?]]
- [[#clojure][Clojure?]]
- [[#java-interop-types][java interop types]]* Interop with C in Clojure
- [[https://www.slideshare.net/netpyoung/interop-with-c-in-clojure][slideshare]]* problem
- How to load library.
- writing wrapper function.
- C structure layout for pointer access.* Java & C Binding
| name | date |
|---------+---------|
| JNI | 1997.02 |
| JNA | 2007.05 |
| JNR | 2013.02 |
| JavaCPP | 2015.07 |
| panama | EAB |** JNI
- https://docs.oracle.com/javase/8/docs/technotes/guides/jni/
- from JDK 1.1
** JNA
- https://github.com/java-native-access/jna
** JNR
- 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
** SKIP JavaCPP
** Panama
- https://openjdk.java.net/projects/panama/
- https://download.java.net/java/early_access/panama/docs/api/java.base/java/foreign/package-summary.html
- [[https://www.youtube.com/watch?v=cfxBrYud9KM][Panama: A Foreign Policy for Java by Maurizio Cimadamore]]
- [[https://www.youtube.com/watch?v=49GUljUmGHg][Going Meta to Valhalla & Panama with John Rose]]
** performance check
https://github.com/yulewei/java-ffi-demo
JNI > JNR > JNA (Direct Mapping) > JNA (Interface Mapping)* JNI Example
1. prepare native c library
2. =writing= && compile interop java file
3. generate interop c header
4. =writing= && c`mpile interop c library
5. =writing= && build clojure project with interop java file
6. call ~clojure library~ with ~native c library~ and ~interop c library~* JNA Example
1. prepare native c library
2. =writing= && build clojure project* JNR Example
1. prepare native c library
2. =writing= && build clojure project
* SKIP JavaCPP Example
* Panama Example* JNA Example (SDL2)
SDL2(C language) binding in clojure
* Panama Example (SDL2)
SDL2(C language) binding in clojure* SDL
- 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* SDL Language Bindings
https://www.libsdl.org/languages.phpAda
C#
D
Go
Lua
OCaml
Pascal
Python
Rust* CommonLisp?
- lispbuilder-sdl - https://github.com/lispbuilder/lispbuilder* Java?
- java: https://github.com/javasdl/libjavasdl
JNA* Clojure?
- Demo clojure with SDL2 (panama)
- https://www.youtube.com/watch?v=40cvevHg0J8* java interop types
- https://www.slideshare.net/SeanLo4/jnainfo-52738038| 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 |