Skip to content

Commit d44a868

Browse files
committed
Initial commit
0 parents  commit d44a868

File tree

8 files changed

+91
-0
lines changed

8 files changed

+91
-0
lines changed

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Ignore the dynamic library files
2+
*.so
3+
*.dylib
4+
*.o
5+
*.a
6+
*.dll
7+
8+
# Spells directory
9+
spells/
10+
11+
# Editors and IDEs
12+
.vscode/
13+
14+
# Ignore local history
15+
.history

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
SHELL=/bin/bash
2+
3+
default:
4+
${MAKE} linux
5+
6+
linux:
7+
gcc -shared -fPIC -I../chaos/ template.c -o template.so
8+
9+
macos:
10+
gcc -shared -fPIC -I../chaos/ -undefined dynamic_lookup template.c -o template.dylib
11+
12+
test:
13+
mkdir -p spells/template
14+
export GLOBIGNORE='*.c'
15+
cp template.* spells/template/
16+
chaos test.kaos

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Template for Chaos C extension developers
2+
3+
Fork this repository to create Chaos C extensions.
4+
5+
At bare minimum, your C extension should be able to build with these commands on the relative platforms:
6+
7+
```
8+
make linux
9+
make macos
10+
make windows
11+
```
12+
13+
Your package name have to match with dynamic library name, for `template` it must be `template(.so|.dylib|.dll)`
14+
and the `name` field in `occultist.json`.
15+
16+
This template provides the necessary `make` commands, an example C code and everything required to
17+
being compiled by `occultist` with proper file extensions on the target platform.
18+
19+
## Useful Links
20+
21+
[**Developing Chaos C Extensions**](https://chaos-lang.org/docs/16_chaos_c_extensions_development)
22+
23+
[**API Reference**](https://chaos-lang.org/docs/api)

make.bat

Whitespace-only changes.

occultist.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "template",
3+
"version": "1.0.0",
4+
"description": "Template for Chaos C extension developers.",
5+
"tags": ["official", "template"],
6+
"type": "extension",
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "M. Mert Yildiran",
11+
"email": "[email protected]",
12+
"role": "Maintainer"
13+
}
14+
]
15+
}

template.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include "Chaos.h"
2+
3+
char *hello_params_name[] = {};
4+
unsigned hello_params_type[] = {};
5+
unsigned short hello_params_length = 0;
6+
int KAOS_EXPORT Kaos_hello()
7+
{
8+
printf("Hello from the template!\n");
9+
return 0;
10+
}
11+
12+
int KAOS_EXPORT KaosRegister(struct Kaos _kaos)
13+
{
14+
kaos = _kaos;
15+
kaos.defineFunction("hello", K_VOID, hello_params_name, hello_params_type, hello_params_length);
16+
17+
return 0;
18+
}

test.kaos

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import template
2+
3+
template.hello()

test.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello from the template!

0 commit comments

Comments
 (0)