-
Notifications
You must be signed in to change notification settings - Fork 4
Updated LowLevel/Functions manual documentation #1300
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
base: main
Are you sure you want to change the base?
Conversation
| > [!NOTE] | ||
| > The `hs-bindgen-runtime` library provides Template Haskell utilities for | ||
| > generating these instances manually when needed. See | ||
| > `HsBindgen.Runtime.TH.Instances` for details. This can be useful when | ||
| > working with function pointer types that `hs-bindgen` doesn't automatically | ||
| > generate instances for, or when writing custom high-level bindings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this.
| - Types appearing as function parameters receive `"wrapper"` imports (you need | ||
| to create function pointers to pass as arguments) | ||
| - Types for function pointer values receive `"dynamic"` imports (you | ||
| need to call returned function pointers) | ||
| - Types appearing in struct or union fields receive both (they may flow in | ||
| either direction) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rephrase this, and mention that these instances are only generated if the function signature has at least one domain specific type (because otherwise they would be orphans and to avoid repeating the instances)
| do | ||
| funPtr <- toFunPtr myCallback | ||
| onProgressChanged (ProgressUpdate funPtr) | ||
| freeHaskellFunPtr (un_ProgressUpdate funPtr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this example to use bracket
| Since these function pointer types appear in struct fields, they receive both | ||
| wrapper and dynamic imports. This allows you to populate the struct with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not quite right. Maybe say something like "Here we need both instances"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Introduction
- Safe vs Unsafe
- Function addresses
3.1. current "Function pointers" beceomes section 3
3.2. "Implicit function to pointer conversion" becomes 3.2 - Conversion between Haskell functions and C functions
- Userland CAPI: Introduction (we generate a C wrapper, yadayayada)
5.1 Structs by value
5.2 Static inline functions
This PR closes #827.