Many revisions, build out function signature section

This commit is contained in:
Justin Ethier 2021-01-15 14:23:36 -05:00
parent e3d4e27a89
commit e8e6823b02

View file

@ -28,28 +28,44 @@ This can be resolved by using the correct function pointer in the call:
This is problematic for a few reasons:
- The caller needs to know which cast to use. We can resolve that by extending the closure type and using a wrapper to call, however
- The number of arguments in the pointer will differt depending on the variadic function we are wrapping. This creates the same problem we attempt to solve using `dispatch.c`. We can make this work for up to N arguments by using the same approach but that is clumsy at best.
- The number of arguments in the pointer will differ depending on the variadic function we are wrapping. This creates the same problem we attempt to solve using `dispatch.c`. We can make this work for up to N arguments by using the same approach but that is clumsy at best.
# Proposed Solution
TODO: WIP here -
The ideal solution is to change the signature of all of our C functions
The current function signatures are (one with closure and one without - believe those are our globals so there is never a closure):
static void __lambda_1195(void *data, int argc, object self_7314094, object k_737772) ;
static void __lambda_1189(void *data, int argc, closure _,object k_737760, object make_732525_733959, object name_732526_733960) ;
The ideal solution is to change the signature of all of our C functions to a common interface so the function pointer may be called correctly in all cases.
static void __lambda(void *data, int argc, closure _,
## Current Function Signatures
- Fixed Arguments:
static void __lambda_705(void *data, int argc, closure _,object k_735994, object x_731110_733428) {
Our current function signature is as follows:
- Variadic: static void __lambda_687(void *data, int argc, closure _,object k_735958, object init_731083_733418, object o_731084_733419_raw, ...) {
static void __lambda_1195(void *data, int argc, object closure, object k
Where:
* `data` is state data for the current thread
* `argc` indicates how many arguments were sent by the caller. Generally only applicable for variadic functions.
* `closure` is the caller's closure. Note this is ignored for global functions as closures are never applicable to them.
* `k` is the continuation
In addition zero or more objects may be listed after that as well as an ellipsis `...` for variadic functions. For example:
static void __lambda_1195(void *data, int argc, object self_7314094, object k_737772) ;
static void __lambda_1189(void *data, int argc, closure _,object k_737760, object make_732525_733959, object name_732526_733960) ;
static void __lambda_705(void *data, int argc, closure _,object k_735994, object x_731110_733428);
static void __lambda_687(void *data, int argc, closure _,object k_735958, object init_731083_733418, object o_731084_733419_raw, ...);
TODO: `define-c` examples
## New Signatures
TBD
static void __lambda(void *data, object closure, object k, int argc, object *args) ;
TODO: how to call these functions
TODO: how to unpack args for a call
TODO: fixed and variadic examples (same?)