mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-11-28 02:23:44 +03:00
Rename RefC extension function stubs
This commit is contained in:
parent
d85016b64d
commit
dc25e8f694
@ -84,9 +84,10 @@ This will generate stub FFI function pointers in the generated C file, which
|
||||
your backend should set to the appropriate C functions before ``main`` is
|
||||
called.
|
||||
|
||||
Each ``%foreign "lang: funcName, opts"`` definition will produce a stub whose
|
||||
name is given by ``cName (UN $ lang ++ "_" ++ funcName)``, of the appropriate
|
||||
function pointer type.
|
||||
Each ``%foreign "lang: foreignFuncName, opts"`` definition for a function
|
||||
will produce a stub, of the appropriate function pointer type. This stub will
|
||||
be called ``cName $ NS (mkNamespace lang) funcName``, where ``funcName`` is the
|
||||
fully qualified Idris name of that function.
|
||||
|
||||
So the ``%foreign`` function
|
||||
|
||||
@ -95,9 +96,9 @@ So the ``%foreign`` function
|
||||
%foreign "python: abs"
|
||||
abs : Int -> Int
|
||||
|
||||
produces a stub ``python_abs``, which can be backpatched in Python by:
|
||||
produces a stub ``python_Main_abs``, which can be backpatched in Python by:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
abs_ptr = ctypes.CFUNCTYPE(ctypes.c_int64, ctypes.c_int64)(abs)
|
||||
ctypes.c_void_p.in_dll(cdll, "python_abs").value = ctypes.cast(abs_ptr, ctypes.c_void_p).value
|
||||
ctypes.c_void_p.in_dll(cdll, "python_Main_abs").value = ctypes.cast(abs_ptr, ctypes.c_void_p).value
|
||||
|
@ -921,7 +921,7 @@ createCFunctions n (MkAForeign ccs fargs ret) = do
|
||||
let isStandardFFI = Prelude.elem lang ["RefC", "C"]
|
||||
let fctName = if isStandardFFI
|
||||
then UN $ Basic $ fctForeignName
|
||||
else UN $ Basic $ lang ++ "_" ++ fctForeignName
|
||||
else NS (mkNamespace lang) n
|
||||
if isStandardFFI
|
||||
then case extLibOpts of
|
||||
[lib, header] => addHeader header
|
||||
|
Loading…
Reference in New Issue
Block a user