packages feed

casadi-bindings-core-1.9.0.1: Casadi/Core/Classes/ImplicitFunction.hs

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

module Casadi.Core.Classes.ImplicitFunction
       (
         ImplicitFunction,
         ImplicitFunctionClass(..),
         implicitFunction_getF,
         implicitFunction_getJac,
         implicitFunction_getLinsol,
       ) where


import Prelude hiding ( Functor )

import Data.Vector ( Vector )
import Foreign.C.Types
import Foreign.Marshal ( new, free )
import Foreign.Storable ( peek )
import Foreign.Ptr ( Ptr, nullPtr )
import Foreign.ForeignPtr ( newForeignPtr )
import System.IO.Unsafe ( unsafePerformIO ) -- for show instances

import Casadi.Core.Classes.PrintableObject
import Casadi.Internal.CToolsInstances ( )
import Casadi.Internal.FormatException ( formatException )
import Casadi.Internal.MarshalTypes ( StdVec, StdString) -- StdPair StdOstream'
import Casadi.Internal.Marshal ( Marshal(..), withMarshal )
import Casadi.Internal.WrapReturn ( WrapReturn(..) )
import Casadi.Core.Data
import Casadi.Core.Enums

instance Show ImplicitFunction where
  show = unsafePerformIO . printableObject_getDescription
-- direct wrapper
foreign import ccall unsafe "casadi__ImplicitFunction__getF" c_casadi__ImplicitFunction__getF
  :: Ptr (Ptr StdString) -> Ptr ImplicitFunction' -> IO (Ptr Function')
casadi__ImplicitFunction__getF
  :: ImplicitFunction -> IO Function
casadi__ImplicitFunction__getF x0 =
  withMarshal x0 $ \x0' ->
  do
    errStrPtrP <- new nullPtr
    ret <- c_casadi__ImplicitFunction__getF errStrPtrP x0'
    errStrPtr <- peek errStrPtrP
    free errStrPtrP
    if errStrPtr == nullPtr then wrapReturn ret else wrapReturn errStrPtr >>= (error . formatException)


-- classy wrapper
implicitFunction_getF :: ImplicitFunctionClass a => a -> IO Function
implicitFunction_getF x = casadi__ImplicitFunction__getF (castImplicitFunction x)


-- direct wrapper
foreign import ccall unsafe "casadi__ImplicitFunction__getJac" c_casadi__ImplicitFunction__getJac
  :: Ptr (Ptr StdString) -> Ptr ImplicitFunction' -> IO (Ptr Function')
casadi__ImplicitFunction__getJac
  :: ImplicitFunction -> IO Function
casadi__ImplicitFunction__getJac x0 =
  withMarshal x0 $ \x0' ->
  do
    errStrPtrP <- new nullPtr
    ret <- c_casadi__ImplicitFunction__getJac errStrPtrP x0'
    errStrPtr <- peek errStrPtrP
    free errStrPtrP
    if errStrPtr == nullPtr then wrapReturn ret else wrapReturn errStrPtr >>= (error . formatException)


-- classy wrapper
implicitFunction_getJac :: ImplicitFunctionClass a => a -> IO Function
implicitFunction_getJac x = casadi__ImplicitFunction__getJac (castImplicitFunction x)


-- direct wrapper
foreign import ccall unsafe "casadi__ImplicitFunction__getLinsol" c_casadi__ImplicitFunction__getLinsol
  :: Ptr (Ptr StdString) -> Ptr ImplicitFunction' -> IO (Ptr LinearSolver')
casadi__ImplicitFunction__getLinsol
  :: ImplicitFunction -> IO LinearSolver
casadi__ImplicitFunction__getLinsol x0 =
  withMarshal x0 $ \x0' ->
  do
    errStrPtrP <- new nullPtr
    ret <- c_casadi__ImplicitFunction__getLinsol errStrPtrP x0'
    errStrPtr <- peek errStrPtrP
    free errStrPtrP
    if errStrPtr == nullPtr then wrapReturn ret else wrapReturn errStrPtr >>= (error . formatException)


-- classy wrapper
implicitFunction_getLinsol :: ImplicitFunctionClass a => a -> IO LinearSolver
implicitFunction_getLinsol x = casadi__ImplicitFunction__getLinsol (castImplicitFunction x)