Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cabal.project.base
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ index-state: 2025-09-16T04:55:58Z
source-repository-package
type: git
location: https://github.com/well-typed/libclang
tag: 41f70874b0f803366144059c0ed0f65809e8c385
tag: 6c0867cd6f627b07c7cf20e396a0b1528907bdbb
4 changes: 4 additions & 0 deletions hs-bindgen/examples/golden/ordinary_anon_child.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Empty lines in this file are significant!


__MATHCALL_VEC;
3 changes: 3 additions & 0 deletions hs-bindgen/examples/golden/ordinary_anon_parent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#define __MATHCALL_VEC extern double _ ## acos (double x)

#include <ordinary_anon_child.h>
1 change: 1 addition & 0 deletions hs-bindgen/fixtures/ordinary_anon_parent/Example.pp.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module Example () where
39 changes: 39 additions & 0 deletions hs-bindgen/fixtures/ordinary_anon_parent/Example/FunPtr.pp.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{-# LANGUAGE CApiFFI #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_HADDOCK prune #-}

module Example.FunPtr where

import qualified Foreign.C as FC
import qualified GHC.IO.Unsafe
import qualified GHC.Ptr as Ptr
import qualified HsBindgen.Runtime.Prelude
import Prelude (IO)

$(HsBindgen.Runtime.Prelude.addCSource (HsBindgen.Runtime.Prelude.unlines
[ "#include <ordinary_anon_parent.h>"
, "/* get__acos_ptr */"
, "__attribute__ ((const))"
, "double (*hs_bindgen_test_ordinary_anon_parent_c6a8256d628dc56b (void)) ("
, " double arg1"
, ")"
, "{"
, " return &_acos;"
, "}"
]))

foreign import ccall unsafe "hs_bindgen_test_ordinary_anon_parent_c6a8256d628dc56b" hs_bindgen_test_ordinary_anon_parent_c6a8256d628dc56b ::
IO (Ptr.FunPtr (FC.CDouble -> IO FC.CDouble))

{-# NOINLINE _acos_ptr #-}

{-| __C declaration:__ @_acos@

__defined at:__ @ordinary_anon_child.h:4:1@

__exported by:__ @ordinary_anon_parent.h@
-}
_acos_ptr :: Ptr.FunPtr (FC.CDouble -> IO FC.CDouble)
_acos_ptr =
GHC.IO.Unsafe.unsafePerformIO hs_bindgen_test_ordinary_anon_parent_c6a8256d628dc56b
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module Example.Global () where
32 changes: 32 additions & 0 deletions hs-bindgen/fixtures/ordinary_anon_parent/Example/Safe.pp.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{-# LANGUAGE CApiFFI #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_HADDOCK prune #-}

module Example.Safe where

import qualified Foreign.C as FC
import qualified HsBindgen.Runtime.Prelude
import Prelude (IO)

$(HsBindgen.Runtime.Prelude.addCSource (HsBindgen.Runtime.Prelude.unlines
[ "#include <ordinary_anon_parent.h>"
, "double hs_bindgen_test_ordinary_anon_parent_49d2dc050c5f231a ("
, " double arg1"
, ")"
, "{"
, " return _acos(arg1);"
, "}"
]))

{-| __C declaration:__ @_acos@

__defined at:__ @ordinary_anon_child.h:4:1@

__exported by:__ @ordinary_anon_parent.h@
-}
foreign import ccall safe "hs_bindgen_test_ordinary_anon_parent_49d2dc050c5f231a" _acos ::
FC.CDouble
{- ^ __C declaration:__ @x@
-}
-> IO FC.CDouble
32 changes: 32 additions & 0 deletions hs-bindgen/fixtures/ordinary_anon_parent/Example/Unsafe.pp.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{-# LANGUAGE CApiFFI #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_HADDOCK prune #-}

module Example.Unsafe where

import qualified Foreign.C as FC
import qualified HsBindgen.Runtime.Prelude
import Prelude (IO)

$(HsBindgen.Runtime.Prelude.addCSource (HsBindgen.Runtime.Prelude.unlines
[ "#include <ordinary_anon_parent.h>"
, "double hs_bindgen_test_ordinary_anon_parent_faad0266dab4d429 ("
, " double arg1"
, ")"
, "{"
, " return _acos(arg1);"
, "}"
]))

{-| __C declaration:__ @_acos@

__defined at:__ @ordinary_anon_child.h:4:1@

__exported by:__ @ordinary_anon_parent.h@
-}
foreign import ccall unsafe "hs_bindgen_test_ordinary_anon_parent_faad0266dab4d429" _acos ::
FC.CDouble
{- ^ __C declaration:__ @x@
-}
-> IO FC.CDouble
5 changes: 5 additions & 0 deletions hs-bindgen/fixtures/ordinary_anon_parent/bindingspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version:
hs_bindgen: 0.1.0
binding_specification: '1.0'
hsmodule: Example
types: []
178 changes: 178 additions & 0 deletions hs-bindgen/fixtures/ordinary_anon_parent/decls.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
[
DeclForeignImport
ForeignImportDecl {
foreignImportName = Name
"@NsVar"
"_acos",
foreignImportParameters = [
FunctionParameter {
functionParameterName = Just
(Name "@NsVar" "x"),
functionParameterType =
HsPrimType HsPrimCDouble,
functionParameterComment = Just
Comment {
commentTitle = Nothing,
commentOrigin = Just "x",
commentLocation = Nothing,
commentHeaderInfo = Nothing,
commentChildren = []}}],
foreignImportResultType =
NormalResultType
(HsIO
(HsPrimType HsPrimCDouble)),
foreignImportOrigName =
"hs_bindgen_test_ordinary_anon_parent_49d2dc050c5f231a",
foreignImportCallConv =
CallConvUserlandCAPI
UserlandCapiWrapper {
capiWrapperDefinition =
concat
[
"double hs_bindgen_test_ordinary_anon_parent_49d2dc050c5f231a (\n",
" double arg1\n",
")\n",
"{\n",
" return _acos(arg1);\n",
"}"],
capiWrapperImport =
"ordinary_anon_parent.h"},
foreignImportOrigin = Function
Function {
functionArgs = [
_×_
(Just
NamePair {
nameC = Name "x",
nameHsIdent = Identifier "x"})
(TypePrim
(PrimFloating PrimDouble))],
functionAttrs =
FunctionAttributes
ImpureFunction,
functionRes = TypePrim
(PrimFloating PrimDouble)},
foreignImportComment = Just
Comment {
commentTitle = Nothing,
commentOrigin = Just "_acos",
commentLocation = Just
"ordinary_anon_child.h:4:1",
commentHeaderInfo = Just
HeaderInfo {
headerMainHeaders = NE.fromList
["ordinary_anon_parent.h"],
headerInclude =
"ordinary_anon_child.h"},
commentChildren = []},
foreignImportSafety = Safe},
DeclForeignImport
ForeignImportDecl {
foreignImportName = Name
"@NsVar"
"_acos",
foreignImportParameters = [
FunctionParameter {
functionParameterName = Just
(Name "@NsVar" "x"),
functionParameterType =
HsPrimType HsPrimCDouble,
functionParameterComment = Just
Comment {
commentTitle = Nothing,
commentOrigin = Just "x",
commentLocation = Nothing,
commentHeaderInfo = Nothing,
commentChildren = []}}],
foreignImportResultType =
NormalResultType
(HsIO
(HsPrimType HsPrimCDouble)),
foreignImportOrigName =
"hs_bindgen_test_ordinary_anon_parent_faad0266dab4d429",
foreignImportCallConv =
CallConvUserlandCAPI
UserlandCapiWrapper {
capiWrapperDefinition =
concat
[
"double hs_bindgen_test_ordinary_anon_parent_faad0266dab4d429 (\n",
" double arg1\n",
")\n",
"{\n",
" return _acos(arg1);\n",
"}"],
capiWrapperImport =
"ordinary_anon_parent.h"},
foreignImportOrigin = Function
Function {
functionArgs = [
_×_
(Just
NamePair {
nameC = Name "x",
nameHsIdent = Identifier "x"})
(TypePrim
(PrimFloating PrimDouble))],
functionAttrs =
FunctionAttributes
ImpureFunction,
functionRes = TypePrim
(PrimFloating PrimDouble)},
foreignImportComment = Just
Comment {
commentTitle = Nothing,
commentOrigin = Just "_acos",
commentLocation = Just
"ordinary_anon_child.h:4:1",
commentHeaderInfo = Just
HeaderInfo {
headerMainHeaders = NE.fromList
["ordinary_anon_parent.h"],
headerInclude =
"ordinary_anon_child.h"},
commentChildren = []},
foreignImportSafety = Unsafe},
DeclForeignImport
ForeignImportDecl {
foreignImportName = Name
"@NsVar"
"hs_bindgen_test_ordinary_anon_parent_c6a8256d628dc56b",
foreignImportParameters = [],
foreignImportResultType =
NormalResultType
(HsIO
(HsFunPtr
(HsFun
(HsPrimType HsPrimCDouble)
(HsIO
(HsPrimType HsPrimCDouble))))),
foreignImportOrigName =
"hs_bindgen_test_ordinary_anon_parent_c6a8256d628dc56b",
foreignImportCallConv =
CallConvUserlandCAPI
UserlandCapiWrapper {
capiWrapperDefinition =
concat
[
"/* get__acos_ptr */\n",
"__attribute__ ((const))\n",
"double (*hs_bindgen_test_ordinary_anon_parent_c6a8256d628dc56b (void)) (\n",
" double arg1\n",
")\n",
"{\n",
" return &_acos;\n",
"}"],
capiWrapperImport =
"ordinary_anon_parent.h"},
foreignImportOrigin = Global
(TypeFun
[
TypePrim
(PrimFloating PrimDouble)]
(TypePrim
(PrimFloating PrimDouble))),
foreignImportComment = Nothing,
foreignImportSafety = Unsafe},
DeclSimple,
DeclSimple]
2 changes: 2 additions & 0 deletions hs-bindgen/fixtures/ordinary_anon_parent/exts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CApiFFI
TemplateHaskell
2 changes: 2 additions & 0 deletions hs-bindgen/fixtures/ordinary_anon_parent/rust-bindgen.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* automatically generated by rust-bindgen 0.71.1 */

56 changes: 56 additions & 0 deletions hs-bindgen/fixtures/ordinary_anon_parent/th.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
-- addDependentFile examples/golden/ordinary_anon_child.h
-- addDependentFile examples/golden/ordinary_anon_parent.h
-- #include <ordinary_anon_parent.h>
-- double hs_bindgen_test_ordinary_anon_parent_49d2dc050c5f231a (
-- double arg1
-- )
-- {
-- return _acos(arg1);
-- }
-- double hs_bindgen_test_ordinary_anon_parent_faad0266dab4d429 (
-- double arg1
-- )
-- {
-- return _acos(arg1);
-- }
-- /* get__acos_ptr */
-- __attribute__ ((const))
-- double (*hs_bindgen_test_ordinary_anon_parent_c6a8256d628dc56b (void)) (
-- double arg1
-- )
-- {
-- return &_acos;
-- }
{-| __C declaration:__ @_acos@

__defined at:__ @ordinary_anon_child.h:4:1@

__exported by:__ @ordinary_anon_parent.h@
-}
foreign import ccall safe "hs_bindgen_test_ordinary_anon_parent_49d2dc050c5f231a" _acos :: CDouble ->
IO CDouble
{-| __C declaration:__ @_acos@

__defined at:__ @ordinary_anon_child.h:4:1@

__exported by:__ @ordinary_anon_parent.h@
-}
foreign import ccall safe "hs_bindgen_test_ordinary_anon_parent_faad0266dab4d429" _acos :: CDouble ->
IO CDouble
foreign import ccall safe "hs_bindgen_test_ordinary_anon_parent_c6a8256d628dc56b" hs_bindgen_test_ordinary_anon_parent_c6a8256d628dc56b :: IO (FunPtr (CDouble ->
IO CDouble))
{-# NOINLINE _acos_ptr #-}
{-| __C declaration:__ @_acos@

__defined at:__ @ordinary_anon_child.h:4:1@

__exported by:__ @ordinary_anon_parent.h@
-}
_acos_ptr :: FunPtr (CDouble -> IO CDouble)
{-| __C declaration:__ @_acos@

__defined at:__ @ordinary_anon_child.h:4:1@

__exported by:__ @ordinary_anon_parent.h@
-}
_acos_ptr = unsafePerformIO hs_bindgen_test_ordinary_anon_parent_c6a8256d628dc56b
Loading
Loading