GithubHelp home page GithubHelp logo

josephcatrambone / jnr-ffi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jnr/jnr-ffi

0.0 2.0 0.0 5.49 MB

Java Abstracted Foreign Function Layer

License: Other

C 1.94% Makefile 0.22% Java 97.84%

jnr-ffi's Introduction

jnr-ffi Build Status

jnr-ffi is a Java library for loading native libraries without writing JNI code by hand, or using tools such as SWIG.

Example

package helloworld;

import jnr.ffi.LibraryLoader;

public class HelloWorld {
    public static interface LibC {
        int puts(String s);
    }

    public static void main(String[] args) {
        LibC libc = LibraryLoader.create(LibC.class).load("c");

        libc.puts("Hello, World");
    }
}

Supported Types

All Java primitives are mapped simply to the equivalent C types.

  • byte - 8 bit signed integer
  • short - 16 bit signed integer
  • int - 32 bit signed integer
  • long - natural long (i.e. 32 bits wide on 32-bit systems, 64 bits wide on 64-bit systems)
  • float - 32 bit float
  • double - 64 bit float

The width and/or signed-ness of these basic types can be specified using one of the type alias annotations. e.g.

// Use the correct width for the result from getpid(3)
@pid_t long getpid();

// read(2) returns a signed long result, and its length parameter is an unsigned long
@ssize_t long read(int fd, Pointer data, @size_t long len);

In addition, the following Java types are mapped to a C pointer

  • String - equivalent to const char *
  • Pointer - equivalent to void *
  • Buffer - equivalent to void *

jnr-ffi's People

Contributors

vp-of-awesome avatar headius avatar goto1134 avatar enebo avatar henriquemotaesteves avatar nirvdrum avatar mpoindexter avatar mkristian avatar gilles-duboscq avatar emcrisostomo avatar pepijnve avatar bkgood avatar vvs avatar pjenvey avatar jernst avatar eregon avatar zhanhb avatar tduehr avatar nabijaczleweli avatar vinodkumar077 avatar rgrunber avatar olleolleolle avatar flandr avatar mwarren avatar jglick avatar camlow325 avatar jeff5 avatar felfert avatar qmx avatar tfiskgul avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.