File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -93,13 +93,11 @@ library
9393 Clang.HighLevel.Fold
9494 Clang.HighLevel.SourceLoc
9595 Clang.HighLevel.Tokens
96- Clang.HighLevel.UserProvided
9796 Clang.HighLevel.Wrappers
9897 build-depends :
9998 -- External dependencies
10099 , data-default >= 0.7 && < 0.9
101100 , exceptions >= 0.10 && < 0.11
102- , mtl >= 2.2 && < 2.4
103101 , text >= 1.2 && < 2.2
104102 , unliftio-core >= 0.2.1 && < 0.3
105103
Original file line number Diff line number Diff line change @@ -41,8 +41,6 @@ module Clang.HighLevel (
4141 , clang_getDiagnostics
4242 -- * Folds
4343 , clang_visitChildren
44- -- * User-provided names
45- , clang_getCursorSpelling
4644 -- * Declaration classification
4745 , classifyDeclaration
4846 , classifyTentativeDefinition
@@ -58,5 +56,4 @@ import Clang.HighLevel.Diagnostics
5856import Clang.HighLevel.Fold
5957import Clang.HighLevel.SourceLoc
6058import Clang.HighLevel.Tokens
61- import Clang.HighLevel.UserProvided
6259import Clang.HighLevel.Wrappers
Original file line number Diff line number Diff line change @@ -40,8 +40,6 @@ module Clang.HighLevel.Types (
4040 , foldRecurseOpt
4141 , foldRecursePure
4242 , foldRecursePureOpt
43- -- * User-provided names
44- , CursorSpelling (.. )
4543 -- * Declaration classification
4644 , DeclarationClassification (.. )
4745 ) where
@@ -51,4 +49,3 @@ import Clang.HighLevel.Diagnostics
5149import Clang.HighLevel.Fold
5250import Clang.HighLevel.SourceLoc
5351import Clang.HighLevel.Tokens
54- import Clang.HighLevel.UserProvided
Load diff This file was deleted.
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ module Clang.Internal.Results (
1414 , checkNotNull
1515 , ensureNotInRange
1616 -- * Auxiliary
17- , isNullPtr
17+ , IsNullPtr ( .. )
1818 ) where
1919
2020import Control.Exception
@@ -76,12 +76,12 @@ ensureOn f p call = do
7676
7777-- | Ensure that a function did not return 'nullPtr' (indicating error)
7878ensureNotNull ::
79- (HasCallStack , Coercible a ( Ptr x ) , Show a )
79+ (HasCallStack , IsNullPtr a , Show a )
8080 => IO a -> IO a
8181ensureNotNull = ensure (not . isNullPtr)
8282
8383-- | If the result is 'nullPtr', return 'Nothing'
84- checkNotNull :: Coercible a ( Ptr x ) => IO a -> IO (Maybe a )
84+ checkNotNull :: IsNullPtr a => IO a -> IO (Maybe a )
8585checkNotNull call = do
8686 ptr <- call
8787 return $ if isNullPtr ptr
@@ -110,8 +110,11 @@ ensureNotInRange = ensureOn conv (not . simpleEnumInRange)
110110 Auxiliary
111111-------------------------------------------------------------------------------}
112112
113- isNullPtr :: Coercible a (Ptr x ) => a -> Bool
114- isNullPtr ptr = ptr' == nullPtr
115- where
116- ptr' :: Ptr x
117- ptr' = coerce ptr
113+ class IsNullPtr a where
114+ isNullPtr :: a -> Bool
115+
116+ instance IsNullPtr (Ptr a ) where
117+ isNullPtr ptr = ptr' == nullPtr
118+ where
119+ ptr' :: Ptr x
120+ ptr' = coerce ptr
Original file line number Diff line number Diff line change @@ -208,6 +208,7 @@ module Clang.LowLevel.Core (
208208 , clang_CXRewriter_writeMainFileToStdOut
209209 , clang_CXRewriter_dispose
210210 -- * Auxiliary
211+ , IsNullPtr (.. )
211212 , nullCursor
212213 ) where
213214
@@ -604,7 +605,7 @@ clang_getDiagnosticFixIt diagnostic fixit = liftIO $
604605-- <https://clang.llvm.org/doxygen/group__CINDEX.html#gacdb7815736ca709ce9a5e1ec2b7e16ac>
605606newtype CXTranslationUnit = CXTranslationUnit (Ptr () )
606607 deriving stock (Show )
607- deriving newtype (Storable )
608+ deriving newtype (Storable , IsNullPtr )
608609
609610-- | An opaque type representing target information for a given translation
610611-- unit.
@@ -1729,6 +1730,7 @@ clang_getCursorExtent cursor = liftIO $
17291730
17301731newtype CXToken = CXToken (Ptr () )
17311732 deriving stock (Show )
1733+ deriving newtype (IsNullPtr )
17321734
17331735foreign import capi unsafe " clang_wrappers.h wrap_getToken"
17341736 wrap_getToken :: CXTranslationUnit -> R CXSourceLocation_ -> IO CXToken
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ module Clang.LowLevel.Core.Pointers (
55
66import Foreign
77
8+ import Clang.Internal.Results
9+
810{- ------------------------------------------------------------------------------
911 CXFile
1012-------------------------------------------------------------------------------}
@@ -16,7 +18,7 @@ import Foreign
1618-- <https://clang.llvm.org/doxygen/group__CINDEX__FILES.html#gacfcea9c1239c916597e2e5b3e109215a>
1719newtype CXFile = CXFile (Ptr () )
1820 deriving stock (Show , Eq )
19- deriving newtype (Storable )
21+ deriving newtype (Storable , IsNullPtr )
2022
2123{- ------------------------------------------------------------------------------
2224 CXPrintingPolicy
You can’t perform that action at this time.
0 commit comments