Coder Social home page Coder Social logo

c's Introduction

C

Auto-generated types to make binding C code easier while preserving the semantics of the original code.

Usage (Module)

Identifiers are almost 1:1 with C, only replacing spaces with underscores.

// Jai:
c :: #import "C";

SomeLib :: #foreign_library "somelib";
does_something :: (x: *c.char) -> c.unsigned_long_long     #foreign SomeLib;
another_thing  :: (y: c.short) -> c.unsigned_long_long_int #foreign SomeLib;

// C:
unsigned long long does_something(char* x);
unsigned long long int another_thing(short y);

Usage (Static)

If you don't want to use the module version of this, you can simply copy generated_static.jai into your project's directory and #load it.

// Jai:
#load "c.jai"; // Renaming generated_static.jai to c.jai or similar is recommended.

lib :: #foreign_library "lib";
greet :: (name: *c.char) -> *c.char #foreign lib;

// C:
char* greet(const char* name);

Building

Module dependent files can be generated by calling jai generator/generate.jai. Note, the generator script requires generator/sizes.c to be compiled into a dynamic/shared library. This can be done by running the build.bat/build.sh scripts within generator/.

Generating the static version of the module requires at least one of the other generated files. You can simply call jai generator/generate_static.jai. This will create a generated_static.jai file.

License

zlib

If this is not permissive enough let me know and I will change it.

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.