Skip to content

Commit

Permalink
Bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
PMunch committed Jan 7, 2023
1 parent 7dc441b commit d63b126
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,18 @@ generates all the Nim definitions.
The three main things you need to know to use Futhark is `sysPath`, `path`, and
normal imports (the `"stb_image.h"` part in the above example).
- `sysPath` denotes system paths, these will be passed to Øpir to make sure
Clang knows where to find all the definitions.
Clang knows where to find all the definitions. This can also be passed with
`-d:sysPath:<path 1>:<path 2>` if you want to automatically generate these.
- `path` denotes library paths, these will also be passed to Øpir, but anything
found in these paths which is used by the files you have in your project will
be wrapped by Futhark.
be wrapped by Futhark as well.
- Files listed in quotes in the importc are equivalent to `#include "file.h"`
in C. Futhark will generate all definitions in these files, and if `file.h`
imports more files found in any of the paths passed in by `path` these files
will also be imported.

Note: The difference between `sysPath` and `path` is simply about how Futhark
handles the file. `sysPath` are paths which are fed to Øpir and Clang in order
handles the files. `sysPath` are paths which are fed to Øpir and Clang in order
to make Clang able to read all the types. `path` are the paths Futhark takes
into account when generating definitions. This difference exists to make sure
Futhark doesn't import all kinds of low-level system stuff which is already
Expand Down Expand Up @@ -148,10 +149,15 @@ about `SomeType`.

## Destructors
If you are using a C library you will probably want to wrap destructor calls.
Futhark makes all C objects `{.pure, inheritable.}` which means you can quite easily use somewhat idiomatic Nim to achieve destructors.
Futhark makes all C objects `{.pure, inheritable.}` which means you can quite
easily use somewhat idiomatic Nim to achieve destructors.

An example usecase from MiniAudio bindings is as follows:
```nim
type TAudioEngine = object of maEngine # Creates a new object in this scope, which allows destructors
type TAudioEngine = object of maEngine # Creates a new object in this scope
# maEngine is a type wrapped by Futhark
# TAudioEngine can now have a destructor
# attached to it
proc `=destroy`(engine: var TAudioEngine) = # Define a destructor as normal
maEngineUninit(engine.addr)
Expand All @@ -175,15 +181,16 @@ can be spent on quality Nim translation.
# Sounds great, what's the catch?
Futhark is currently in an alpha state. It currently doesn't support C++, and
it doesn't understand things like function-style macros. It might also mess up
on definition types I haven't seen yet in the small handful of libraries I've
tested it against. All of these things are things I hope to get fixed up.
on definition types which haven't been encountered yet, although this is more
and more rare as people use it. All of these things are things I hope to get
fixed up.

# Installation
To install Futhark you first need to have clang installed. Installing clang on
Linux is as simple as just grabbing it from your package manager (e.g. `sudo
apt install libclang-dev`). To install clang on Windows you need to install
[LLVM](https://github.com/llvm/llvm-project/releases/tag/llvmorg-13.0.1) (you
probably want to grab the `LLVM-13.0.1-win64.exe` version).
[LLVM](https://github.com/llvm/llvm-project/releases/tag/llvmorg-15.0.6) (you
probably want to grab the `LLVM-15.0.6-win64.exe` version).

If you have Clang installed in your system path you can now simply run:
```
Expand All @@ -206,4 +213,3 @@ even if it is the same as for Linux, just in order to add it as a note.
## TODO
- Proper handling of C macros (inherently hard because C macros are typeless)
- Find way to not require C compiler include paths
- Verify if/make it work on Windows and Mac
2 changes: 1 addition & 1 deletion futhark.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.6.1" # Remember to update the version in futhark.nim as well
version = "0.7.0" # Remember to update the version in futhark.nim as well
author = "PMunch"
description = "A package which uses libclang to parse C headers into Nim files for easy interop"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion src/futhark.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import macroutils except Lit

const
Stringable = {nnkStrLit..nnkTripleStrLit, nnkCommentStmt, nnkIdent, nnkSym}
VERSION = "0.6.1"
VERSION = "0.7.0"
builtins = ["addr", "and", "as", "asm",
"bind", "block", "break",
"case", "cast", "concept", "const", "continue", "converter",
Expand Down

0 comments on commit d63b126

Please sign in to comment.