Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/judah-caruso/C
C interop module for Jai
https://github.com/judah-caruso/C
Last synced: about 2 months ago
JSON representation
C interop module for Jai
- Host: GitHub
- URL: https://github.com/judah-caruso/C
- Owner: judah-caruso
- License: zlib
- Created: 2021-06-08T02:09:42.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-07-11T00:35:12.000Z (about 3 years ago)
- Last Synced: 2024-07-08T11:34:45.104Z (3 months ago)
- Language: C
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.markdown
- License: license.text
Awesome Lists containing this project
README
# 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.
```c++
// 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.```c++
// 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.