We planned to upgrade GitLab and Mattermost to the latest version this Friday morning (early). You may experience some downtime!

Verified Commit cef76230 authored by Camil Staps's avatar Camil Staps 🚀

Fix documentation of ccall

parent a9173316
......@@ -380,23 +380,23 @@ where
, aie_arguments = [LABEL, STRING]
, aie_description = join "\n"
[ "Calls a C function."
, "Some of this is documented in https://svn.cs.ru.nl/repos/clean-tools/trunk/htoclean/CallingCFromClean.html"
, "Some of this is documented in https://svn.cs.ru.nl/repos/clean-tools/trunk/htoclean/CallingCFromClean.html."
, "The first argument is the name of the function, the second is the signature."
, "\n"
, "The signature has to be of the form `flags?input?sep output(sep state)?`, where"
, " - sep can be either `-` or `:`."
, " - flags can be `G` and/or `P`. `G` saves the state in global variables and is needed when the called C function will call Clean functions. `P` lets the callee pop arguments (necessary on 32-bit Windows)."
, " - input is a number of input argument types (allowed: `IpRrSsAOF`)."
, " - output is a number of output argument types (allowed: `VIpRrSsAOF`)."
, " - state is a carried state that is not passed to the C function, for example used to thread {{`World`}} in ccalls (allowed: `IpRSA`)."
, " - `sep` can be either `-` or `:`."
, " - `flags` can be `G` and/or `P`. `G` saves the state in global variables and is needed when the called C function will call Clean functions. `P` lets the callee pop arguments (necessary on 32-bit Windows)."
, " - `input` is a number of input argument types (allowed: `IpRrSsAOF`; see below)."
, " - `output` is a number of output argument types (allowed: `VIpRrSsAOF`; see below)."
, " - `state` is a carried state that is not passed to the C function, for example used to thread {{`World`}} in ccalls (allowed: `IpRSA`)."
, "\n"
, "Input, output and state argument types can be:"
, " - `I` for integers"
, " - `p` for pointers (e.g. from {{`System.Pointer`}}; on most systems this is identical to `I`)"
, " - [`Rr`] for reals"
, " - `S` for Clean Strings (`{#Char}`). If used as input type this passes a pointer to the string's length (number of characters). The actual array is at offset 4/8 (32/64 bit). If this is used as output type, the C function has to return a pointer to the string's length, followed by the actual string. A copy of the string will be created in the Clean heap, and this copy will be used by Clean. If the string was allocated in C, for example using malloc, it should be deallocated in C when it no longer used, it is not automatically deallocated by Clean."
, " - `S` for Clean Strings (`{#Char}`). If used as input type this passes a pointer to the string's length (number of characters). The actual array is at offset 4/8 (32/64 bit). If this is used as output type, the C function has to return a pointer to the string's length, followed by the actual string. A copy of the string will be created in the Clean heap, and this copy will be used by Clean. If the string was allocated in C, for example using malloc, it should be deallocated in C when it is no longer used."
, " - `s` for the characters of a Clean String (handy to use in conjuction with {{`packString`}}, as the string is not null-terminated). The length (number of characters) is at offset -4/-8. (32/64 bit)."
, " - `A` for A-stack elements. A pointer to the third block of the node is passed. For arrays, this is a pointer to the elements. The size of the array is one word higher in the block."
, " - `A` for A-stack elements. A pointer to the third block of the node is passed. For arrays, this is a pointer to the elements. One word higher is the element type. The size of the array is two words higher."
, " - [`OF`] for function pointers"
, " - `V` for `void`, packs the following argument types in a tuple (e.g. `VIR` means `(Int, Real)`)"
]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment