Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve unifex supported types tables #103

Merged
merged 2 commits into from
Jan 30, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 14 additions & 47 deletions pages/supported_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,17 @@ Below we present which types you can use at this moment.
You can also refer to [#42](https://github.com/membraneframework/unifex/issues/42) to see
state of work on remaining types.

## NIF
| type | as function parameter | as return type |
| --------- | :-------------------: | :-------------: |
| `atom` | yes | yes |
| `bool` | yes | yes |
| `unsigned`| yes | yes |
| `uint64` | yes | yes |
| `int` | yes | yes |
| `int64` | yes | yes |
| `float` | yes | yes |
| `list` | yes | yes |
| `payload` | yes | yes |
| `pid` | yes | yes |
| `string` | yes | yes |

## CNode
| type | as function parameter | as return type |
| --------- | :-------------------: | :-------------: |
| `atom` | yes | yes |
| `bool` | yes | yes |
| `unsigned`| yes | yes |
| `uint64` | no | no |
| `int` | yes | yes |
| `int64` | no | no |
| `float` | yes | yes |
| `list` | yes | yes |
| `payload` | yes | yes |
| `pid` | yes | yes |
| `string` | yes | yes |

## Types mapping
List of examples, how specific type in `*.spec.exs` will be translated onto native side

Elixir type | Native type
--- | ---
`atom` | `char *`
`bool` | `int`
`float` | `double`
`int` | `int`
`int64` | `int64_t`
`payload` | `UnifexPayload`
`pid` | `UnifexPid`
`state` | `UnifexState *`
`string` | `char *`
`uint64` | `uint64_t`
`unsigned` | `unsigned int`
`[int]` | `int *`, `unsigned int`
## Supported types
| Elixir type | Native type | NIF as a function parameter | NIF as a return type | CNode as a function parameter | CNode as a return type |
Janix4000 marked this conversation as resolved.
Show resolved Hide resolved
| --------- | :-----------------------------: | :-------------------------: | :------------------: | :---------------------------: | :---------------------: |
| `atom` | `char *` | ✅ | ✅ | ✅ | ✅ |
| `bool` | `int` | ✅ | ✅ | ✅ | ✅ |
| `unsigned` | `unsigned int` | ✅ | ✅ | ✅ | ✅ |
| `uint64` | `uint64_t` | ✅ | ✅ | ❌ | ❌ |
| `int` | `int` | ✅ | ✅ | ✅ | ✅ |
| `int64` | `int64_t` | ✅ | ✅ | ❌ | ❌ |
| `float` | `double` | ✅ | ✅ | ✅ | ✅ |
| `payload` | `UnifexPayload` | ✅ | ✅ | ✅ | ✅ |
| `pid` | `UnifexPid` | ✅ | ✅ | ✅ | ✅ |
| `string` | `char *` | ✅ | ✅ | ✅ | ✅ |
| `[type]` | `native_type *`, `unsigned int` | ✅ | ✅ | ✅ | ✅ |