All Projects → scala-native → scala-native-bindgen

scala-native / scala-native-bindgen

Licence: BSD-3-Clause license
Scala Native Binding Generator

Programming Languages

C++
36643 projects - #6 most used programming language
scala
5932 projects
c
50402 projects - #5 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to scala-native-bindgen

input.rs
libinput bindings for rust
Stars: ✭ 58 (+100%)
Mutual labels:  bindings
Xamarin-Android
PSPDFKit for Android wrapper for the Xamarin platform.
Stars: ✭ 18 (-37.93%)
Mutual labels:  bindings
Xamarin-iOS
PSPDFKit for iOS wrapper for the Xamarin platform.
Stars: ✭ 14 (-51.72%)
Mutual labels:  bindings
redux-polyglot
Polyglot.js bindings for Redux
Stars: ✭ 59 (+103.45%)
Mutual labels:  bindings
node-tdlib
TDLib Binding with Telegram Bot API Reimplemention for Node.js
Stars: ✭ 35 (+20.69%)
Mutual labels:  bindings
pywrap
C++ binding generator based on libclang and pybind11
Stars: ✭ 17 (-41.38%)
Mutual labels:  binding-generator
jquery-bindings
Simple two-way data binding using proxies and requestIdleCallback
Stars: ✭ 17 (-41.38%)
Mutual labels:  bindings
crystal-autobind
Automatic C bindings generator for Crystal
Stars: ✭ 15 (-48.28%)
Mutual labels:  bindings
bound
Data-binding made easy
Stars: ✭ 21 (-27.59%)
Mutual labels:  bindings
fltk-rs
Rust bindings for the FLTK GUI library.
Stars: ✭ 929 (+3103.45%)
Mutual labels:  bindings
crystal-chipmunk
Crystal bindings to Chipmunk, a fast and lightweight 2D game physics library
Stars: ✭ 38 (+31.03%)
Mutual labels:  bindings
cairo
Package cairo provides full Go bindings for Cairo, a 2D graphics library.
Stars: ✭ 28 (-3.45%)
Mutual labels:  bindings
x11-rs
Rust bindings for X11 libraries
Stars: ✭ 169 (+482.76%)
Mutual labels:  bindings
laravel-auto-binder
Bind interfaces to concrete classes automatically
Stars: ✭ 67 (+131.03%)
Mutual labels:  bindings
go-wlroots
Go binding for wlroots
Stars: ✭ 92 (+217.24%)
Mutual labels:  bindings
Hotkeys
🔤 A small C# (.NET) Library which allows binding of global HotKeys to any Application's Windows (including Windows Apps such as explorer.exe), even in Background. (using P/Invokes)
Stars: ✭ 66 (+127.59%)
Mutual labels:  bindings
lualite
a one header library for creating Lua bindings to C++
Stars: ✭ 76 (+162.07%)
Mutual labels:  bindings
nuklear4j
Java binding for nuklear
Stars: ✭ 61 (+110.34%)
Mutual labels:  bindings
bindingsrx
A 2 way binding system for unity using unirx
Stars: ✭ 109 (+275.86%)
Mutual labels:  bindings
mltools
MLDB Unity Editor Bindings
Stars: ✭ 22 (-24.14%)
Mutual labels:  bindings

Scala Native Binding Generator

Build Status

The tool generates Scala Native bindings from C headers.

Documentation

Documentation can be found at scala-native.github.io/scala-native-bindgen.

Bindgen Features

  • possibility to reuse types from existing bindings.
  • type casts that make recursive structs be valid Scala Native structs.
  • implicit classes for structs and unions that make fields access easier.
  • implicit classes that add setters and getters to structs with more than 22 fields (such structs in Scala Native are represented as arrays of bytes).
  • literal defines embedding #define MY_CONSTANT 42val MY_CONSTANT: native.CInt = 42.
  • read-only bindings for extern variables (such variables cannot be updated due to Scala Native limitation).
  • declarations filtering by prefix.

Example

struct point {
    float x;
    float y;
};

struct vector {
    struct point a;
    struct point b;
};

struct vector *add(struct vector *v1, struct vector *v2);
import scala.scalanative._
import scala.scalanative.native._

@native.link("vector")
@native.extern
object vector {
  type struct_point = native.CStruct2[native.CFloat, native.CFloat]
  type struct_vector = native.CStruct2[struct_point, struct_point]
  def add(v1: native.Ptr[struct_vector], v2: native.Ptr[struct_vector]): native.Ptr[struct_vector] = native.extern

  object implicits {
    implicit class struct_point_ops(val p: native.Ptr[struct_point]) extends AnyVal {
      def x: native.CFloat = !p._1
      def x_=(value: native.CFloat): Unit = !p._1 = value
      def y: native.CFloat = !p._2
      def y_=(value: native.CFloat): Unit = !p._2 = value
    }

    implicit class struct_vector_ops(val p: native.Ptr[struct_vector]) extends AnyVal {
      def a: native.Ptr[struct_point] = p._1
      def a_=(value: native.Ptr[struct_point]): Unit = !p._1 = !value
      def b: native.Ptr[struct_point] = p._2
      def b_=(value: native.Ptr[struct_point]): Unit = !p._2 = !value
    }
  }

  object struct_point {
    import implicits._
    def apply()(implicit z: native.Zone): native.Ptr[struct_point] = native.alloc[struct_point]
    def apply(x: native.CFloat, y: native.CFloat)(implicit z: native.Zone): native.Ptr[struct_point] = {
      val ptr = native.alloc[struct_point]
      ptr.x = x
      ptr.y = y
      ptr
    }
  }

  object struct_vector {
    import implicits._
    def apply()(implicit z: native.Zone): native.Ptr[struct_vector] = native.alloc[struct_vector]
    def apply(a: native.Ptr[struct_point], b: native.Ptr[struct_point])(implicit z: native.Zone): native.Ptr[struct_vector] = {
      val ptr = native.alloc[struct_vector]
      ptr.a = a
      ptr.b = b
      ptr
    }
  }
}

License

This project is distributed under the Scala license. See LICENSE.txt for details

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].