packages feed

casadi-bindings-1.9.0.0: Casadi/Wrappers/Classes/WeakRef.hs

{-# OPTIONS_GHC -Wall #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# Language ForeignFunctionInterface #-}
{-# Language FlexibleInstances #-}
{-# Language MultiParamTypeClasses #-}

module Casadi.Wrappers.Classes.WeakRef
       (
         WeakRef,
         WeakRefClass(..),
         weakRef,
         weakRef',
         weakRef'',
         weakRef_alive,
         weakRef_shared,
       ) where


import Prelude hiding ( Functor )

import Data.Vector ( Vector )
import Foreign.C.Types
import Foreign.Ptr ( Ptr )
import Foreign.ForeignPtr ( newForeignPtr )
import System.IO.Unsafe ( unsafePerformIO ) -- for show instances

import Casadi.Wrappers.Classes.PrintableObject
import Casadi.Wrappers.CToolsInstances ( )
import Casadi.Wrappers.Data
import Casadi.Wrappers.Enums
import Casadi.MarshalTypes ( CppVec, StdString' ) -- StdOstream'
import Casadi.Marshal ( Marshal(..), withMarshal )
import Casadi.WrapReturn ( WrapReturn(..) )

instance Show WeakRef where
  show = unsafePerformIO . printableObject_getDescription
-- direct wrapper
foreign import ccall unsafe "CasADi__WeakRef__shared" c_CasADi__WeakRef__shared
  :: Ptr WeakRef' -> IO (Ptr SharedObject')
casADi__WeakRef__shared
  :: WeakRef -> IO SharedObject
casADi__WeakRef__shared x0 =
  withMarshal x0 $ \x0' ->
  c_CasADi__WeakRef__shared x0' >>= wrapReturn

-- classy wrapper
{-|
>[INTERNAL]  Get a shared
>(owning) reference.
-}
weakRef_shared :: WeakRefClass a => a -> IO SharedObject
weakRef_shared x = casADi__WeakRef__shared (castWeakRef x)


-- direct wrapper
foreign import ccall unsafe "CasADi__WeakRef__alive" c_CasADi__WeakRef__alive
  :: Ptr WeakRef' -> IO CInt
casADi__WeakRef__alive
  :: WeakRef -> IO Bool
casADi__WeakRef__alive x0 =
  withMarshal x0 $ \x0' ->
  c_CasADi__WeakRef__alive x0' >>= wrapReturn

-- classy wrapper
{-|
>[INTERNAL]  Check if alive.
-}
weakRef_alive :: WeakRefClass a => a -> IO Bool
weakRef_alive x = casADi__WeakRef__alive (castWeakRef x)


-- direct wrapper
foreign import ccall unsafe "CasADi__WeakRef__WeakRef" c_CasADi__WeakRef__WeakRef
  :: CInt -> IO (Ptr WeakRef')
casADi__WeakRef__WeakRef
  :: Int -> IO WeakRef
casADi__WeakRef__WeakRef x0 =
  withMarshal x0 $ \x0' ->
  c_CasADi__WeakRef__WeakRef x0' >>= wrapReturn

-- classy wrapper
{-|
>>  CasADi::WeakRef::WeakRef(int dummy=0)
>------------------------------------------------------------------------
>[INTERNAL] 
>Default constructor.
>
>>  CasADi::WeakRef::WeakRef(SharedObject shared)
>------------------------------------------------------------------------
>[INTERNAL] 
>Construct from a shared object (also implicit type conversion)
-}
weakRef :: Int -> IO WeakRef
weakRef = casADi__WeakRef__WeakRef


-- direct wrapper
foreign import ccall unsafe "CasADi__WeakRef__WeakRef_TIC" c_CasADi__WeakRef__WeakRef_TIC
  :: IO (Ptr WeakRef')
casADi__WeakRef__WeakRef'
  :: IO WeakRef
casADi__WeakRef__WeakRef'  =
  c_CasADi__WeakRef__WeakRef_TIC  >>= wrapReturn

-- classy wrapper
weakRef' :: IO WeakRef
weakRef' = casADi__WeakRef__WeakRef'


-- direct wrapper
foreign import ccall unsafe "CasADi__WeakRef__WeakRef_TIC_TIC" c_CasADi__WeakRef__WeakRef_TIC_TIC
  :: Ptr SharedObject' -> IO (Ptr WeakRef')
casADi__WeakRef__WeakRef''
  :: SharedObject -> IO WeakRef
casADi__WeakRef__WeakRef'' x0 =
  withMarshal x0 $ \x0' ->
  c_CasADi__WeakRef__WeakRef_TIC_TIC x0' >>= wrapReturn

-- classy wrapper
weakRef'' :: SharedObject -> IO WeakRef
weakRef'' = casADi__WeakRef__WeakRef''