packages feed

gi-gst-0.1.6.13: GI/Gst/Structs/PluginDesc.hs


{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

A plugin should export a variable of this type called plugin_desc. The plugin
loader will use the data provided there to initialize the plugin.

The @licence parameter must be one of: LGPL, GPL, QPL, GPL/QPL, MPL,
BSD, MIT/X11, Proprietary, unknown.
-}

module GI.Gst.Structs.PluginDesc
    ( 

-- * Exported types
    PluginDesc(..)                          ,
    newZeroPluginDesc                       ,
    noPluginDesc                            ,


 -- * Properties
-- ** Description
    pluginDescReadDescription               ,


-- ** License
    pluginDescReadLicense                   ,


-- ** MajorVersion
    pluginDescReadMajorVersion              ,


-- ** MinorVersion
    pluginDescReadMinorVersion              ,


-- ** Name
    pluginDescReadName                      ,


-- ** Origin
    pluginDescReadOrigin                    ,


-- ** Package
    pluginDescReadPackage                   ,


-- ** ReleaseDatetime
    pluginDescReadReleaseDatetime           ,


-- ** Source
    pluginDescReadSource                    ,


-- ** Version
    pluginDescReadVersion                   ,




    ) where

import Prelude ()
import Data.GI.Base.ShortPrelude

import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map

import GI.Gst.Types
import GI.Gst.Callbacks

newtype PluginDesc = PluginDesc (ForeignPtr PluginDesc)
-- | Construct a `PluginDesc` struct initialized to zero.
newZeroPluginDesc :: MonadIO m => m PluginDesc
newZeroPluginDesc = liftIO $ callocBytes 112 >>= wrapPtr PluginDesc

noPluginDesc :: Maybe PluginDesc
noPluginDesc = Nothing

pluginDescReadMajorVersion :: PluginDesc -> IO Int32
pluginDescReadMajorVersion s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO Int32
    return val

pluginDescReadMinorVersion :: PluginDesc -> IO Int32
pluginDescReadMinorVersion s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 4) :: IO Int32
    return val

pluginDescReadName :: PluginDesc -> IO T.Text
pluginDescReadName s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO CString
    val' <- cstringToText val
    return val'

pluginDescReadDescription :: PluginDesc -> IO T.Text
pluginDescReadDescription s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 16) :: IO CString
    val' <- cstringToText val
    return val'

-- XXX Skipped getter for "PluginDesc:plugin_init" :: Not implemented: "Wrapping foreign callbacks is not supported yet"

pluginDescReadVersion :: PluginDesc -> IO T.Text
pluginDescReadVersion s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 32) :: IO CString
    val' <- cstringToText val
    return val'

pluginDescReadLicense :: PluginDesc -> IO T.Text
pluginDescReadLicense s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 40) :: IO CString
    val' <- cstringToText val
    return val'

pluginDescReadSource :: PluginDesc -> IO T.Text
pluginDescReadSource s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 48) :: IO CString
    val' <- cstringToText val
    return val'

pluginDescReadPackage :: PluginDesc -> IO T.Text
pluginDescReadPackage s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 56) :: IO CString
    val' <- cstringToText val
    return val'

pluginDescReadOrigin :: PluginDesc -> IO T.Text
pluginDescReadOrigin s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 64) :: IO CString
    val' <- cstringToText val
    return val'

pluginDescReadReleaseDatetime :: PluginDesc -> IO T.Text
pluginDescReadReleaseDatetime s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 72) :: IO CString
    val' <- cstringToText val
    return val'

type family ResolvePluginDescMethod (t :: Symbol) (o :: *) :: * where
    ResolvePluginDescMethod l o = MethodResolutionFailed l o

instance (info ~ ResolvePluginDescMethod t PluginDesc, MethodInfo info PluginDesc p) => IsLabelProxy t (PluginDesc -> p) where
    fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolvePluginDescMethod t PluginDesc, MethodInfo info PluginDesc p) => IsLabel t (PluginDesc -> p) where
    fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info)
#endif