Skip to content
Browse files

oh my god

  • Loading branch information...
1 parent fe5e95c commit 2b9deb7a52298e4f56efa9600e4cabd05db6bfb0 Will Thompson committed
Showing with 217 additions and 69 deletions.
  1. +0 −60 GI/BaseInfo.chs
  2. +0 −2 GI/BaseInfo.h
  3. +36 −0 GI/Typelib.chs
  4. +164 −0 GI/Types.chs
  5. +5 −7 GObject-Introspection.cabal
  6. +1 −0 LICENSE
  7. +11 −0 Main.hs
View
60 GI/BaseInfo.chs
@@ -1,60 +0,0 @@
-module GI.BaseInfo
- (
- )
-where
-
-import Foreign
-
-#include <girepository.h>
-
-{# pointer *GIBaseInfo as BaseInfo newtype #}
-{# class BaseInfoClass BaseInfo #}
-
-{# pointer *GICallableInfo as CallableInfo newtype #}
-{# class BaseInfoClass => CallableInfoClass CallableInfo #}
-
-{# pointer *GIFunctionInfo as FunctionInfo newtype #}
-{# class CallableInfoClass => FunctionInfoClass FunctionInfo #}
-
-{# pointer *GISignalInfo as SignalInfo newtype #}
-{# class CallableInfoClass => SignalInfoClass SignalInfo #}
-
-{# pointer *GIVFuncInfo as VFuncInfo newtype #}
-{# class CallableInfoClass => VFuncInfoClass VFuncInfo #}
-
-{# pointer *GIRegisteredTypeInfo as RegisteredTypeInfo newtype #}
-{# class BaseInfoClass => RegisteredTypeInfoClass RegisteredTypeInfo #}
-
-{# pointer *GIEnumInfo as EnumInfo newtype #}
-{# class RegisteredTypeInfoClass => EnumInfoClass EnumInfo #}
-
-{# pointer *GIInterfaceInfo as InterfaceInfo newtype #}
-{# class RegisteredTypeInfoClass => InterfaceInfoClass InterfaceInfo #}
-
-{# pointer *GIObjectInfo as ObjectInfo newtype #}
-{# class RegisteredTypeInfoClass => ObjectInfoClass ObjectInfo #}
-
-{# pointer *GIStructInfo as StructInfo newtype #}
-{# class RegisteredTypeInfoClass => StructInfoClass StructInfo #}
-
-{# pointer *GIUnionInfo as UnionInfo newtype #}
-{# class RegisteredTypeInfoClass => UnionInfoClass UnionInfo #}
-
-{# pointer *GIArgInfo as ArgInfo newtype #}
-{# class BaseInfoClass => ArgInfoClass ArgInfo #}
-
-{# pointer *GIConstantInfo as ConstantInfo newtype #}
-{# class BaseInfoClass => ConstantInfoClass ConstantInfo #}
-
-{# pointer *GIErrorDomainInfo as ErrorDomainInfo newtype #}
-{# class BaseInfoClass => ErrorDomainInfoClass ErrorDomainInfo #}
-
-{# pointer *GIFieldInfo as FieldInfo newtype #}
-{# class BaseInfoClass => FieldInfoClass FieldInfo #}
-
-{# pointer *GIPropertyInfo as PropertyInfo newtype #}
-{# class BaseInfoClass => PropertyInfoClass PropertyInfo #}
-
-{# pointer *GITypeInfo as TypeInfo newtype #}
-{# class BaseInfoClass => TypeInfoClass TypeInfo #}
-
View
2 GI/BaseInfo.h
@@ -1,2 +0,0 @@
-#include "/usr/include/gobject-introspection-1.0/girepository.h"
-#include <girepository.h>
View
36 GI/Typelib.chs
@@ -0,0 +1,36 @@
+module GI.Typelib
+ ( repositoryGetNInfos
+ , repositoryRequire
+ , repositoryLoad
+ )
+where
+
+import Foreign
+import Foreign.C
+
+import System.Glib.GError
+
+#include <girepository.h>
+
+{# pointer *GITypelib as Typelib newtype #}
+{# pointer *GIRepository as Repository newtype #}
+
+getDefaultRepository :: IO Repository
+getDefaultRepository = {# call g_irepository_get_default #}
+
+nullRepository = Repository nullPtr
+
+repositoryGetNInfos :: String -> IO CInt
+repositoryGetNInfos ns = withCString ns $ \nsPtr ->
+ {# call unsafe g_irepository_get_n_infos #} nullRepository nsPtr
+
+repositoryRequire :: String -> IO Typelib
+repositoryRequire ns = --version =
+ withCString ns $ \nsPtr ->
+-- withCString version $ \versionPtr ->
+ propagateGError $ {# call unsafe g_irepository_require #} nullRepository nsPtr nullPtr 0
+
+repositoryLoad :: Typelib -> IO String
+repositoryLoad typelib = do
+ ret <- propagateGError $ {# call unsafe g_irepository_load_typelib #} nullRepository typelib 0
+ peekCString ret
View
164 GI/Types.chs
@@ -0,0 +1,164 @@
+module GI.Types
+ (
+ CallableInfo(..)
+ , CallableInfoClass(..)
+ , FunctionInfo(..)
+ , FunctionInfoClass(..)
+ , SignalInfo(..)
+ , SignalInfoClass(..)
+ , VFuncInfo(..)
+ , VFuncInfoClass(..)
+ , RegisteredTypeInfo(..)
+ , RegisteredTypeInfoClass(..)
+ , EnumInfo(..)
+ , EnumInfoClass(..)
+ , InterfaceInfo(..)
+ , InterfaceInfoClass(..)
+ , ObjectInfo(..)
+ , ObjectInfoClass(..)
+ , StructInfo(..)
+ , StructInfoClass(..)
+ , UnionInfo(..)
+ , UnionInfoClass(..)
+ , ArgInfo(..)
+ , ArgInfoClass(..)
+ , ConstantInfo(..)
+ , ConstantInfoClass(..)
+ , ErrorDomainInfo(..)
+ , ErrorDomainInfoClass(..)
+ , FieldInfo(..)
+ , FieldInfoClass(..)
+ , PropertyInfo(..)
+ , PropertyInfoClass(..)
+ , TypeInfo(..)
+ , TypeInfoClass(..)
+ )
+where
+
+import Foreign
+
+#include <girepository.h>
+
+{# pointer *GIBaseInfo as BaseInfo newtype #}
+{# class BaseInfoClass BaseInfo #}
+
+{# pointer *GICallableInfo as CallableInfo newtype #}
+{# class CallableInfoClass CallableInfo #}
+instance BaseInfoClass CallableInfo where
+ baseInfo (CallableInfo p) = BaseInfo (castPtr p)
+ fromBaseInfo (BaseInfo p) = CallableInfo (castPtr p)
+
+{# pointer *GIFunctionInfo as FunctionInfo newtype #}
+{# class FunctionInfoClass FunctionInfo #}
+instance BaseInfoClass FunctionInfo where
+ baseInfo (FunctionInfo p) = BaseInfo (castPtr p)
+ fromBaseInfo (BaseInfo p) = FunctionInfo (castPtr p)
+instance CallableInfoClass FunctionInfo where
+ callableInfo (FunctionInfo p) = CallableInfo (castPtr p)
+ fromCallableInfo (CallableInfo p) = FunctionInfo (castPtr p)
+
+{# pointer *GISignalInfo as SignalInfo newtype #}
+{# class SignalInfoClass SignalInfo #}
+instance BaseInfoClass SignalInfo where
+ baseInfo (SignalInfo p) = BaseInfo (castPtr p)
+ fromBaseInfo (BaseInfo p) = SignalInfo (castPtr p)
+instance CallableInfoClass SignalInfo where
+ callableInfo (SignalInfo p) = CallableInfo (castPtr p)
+ fromCallableInfo (CallableInfo p) = SignalInfo (castPtr p)
+
+{# pointer *GIVFuncInfo as VFuncInfo newtype #}
+{# class VFuncInfoClass VFuncInfo #}
+instance BaseInfoClass VFuncInfo where
+ baseInfo (VFuncInfo p) = BaseInfo (castPtr p)
+ fromBaseInfo (BaseInfo p) = VFuncInfo (castPtr p)
+instance CallableInfoClass VFuncInfo where
+ callableInfo (VFuncInfo p) = CallableInfo (castPtr p)
+ fromCallableInfo (CallableInfo p) = VFuncInfo (castPtr p)
+
+{# pointer *GIRegisteredTypeInfo as RegisteredTypeInfo newtype #}
+{# class RegisteredTypeInfoClass RegisteredTypeInfo #}
+instance BaseInfoClass RegisteredTypeInfo where
+ baseInfo (RegisteredTypeInfo p) = BaseInfo (castPtr p)
+ fromBaseInfo (BaseInfo p) = RegisteredTypeInfo (castPtr p)
+
+{# pointer *GIEnumInfo as EnumInfo newtype #}
+{# class EnumInfoClass EnumInfo #}
+instance BaseInfoClass EnumInfo where
+ baseInfo (EnumInfo p) = BaseInfo (castPtr p)
+ fromBaseInfo (BaseInfo p) = EnumInfo (castPtr p)
+instance RegisteredTypeInfoClass EnumInfo where
+ registeredTypeInfo (EnumInfo p) = RegisteredTypeInfo (castPtr p)
+ fromRegisteredTypeInfo (RegisteredTypeInfo p) = EnumInfo (castPtr p)
+
+{# pointer *GIInterfaceInfo as InterfaceInfo newtype #}
+{# class InterfaceInfoClass InterfaceInfo #}
+instance BaseInfoClass InterfaceInfo where
+ baseInfo (InterfaceInfo p) = BaseInfo (castPtr p)
+ fromBaseInfo (BaseInfo p) = InterfaceInfo (castPtr p)
+instance RegisteredTypeInfoClass InterfaceInfo where
+ registeredTypeInfo (InterfaceInfo p) = RegisteredTypeInfo (castPtr p)
+ fromRegisteredTypeInfo (RegisteredTypeInfo p) = InterfaceInfo (castPtr p)
+
+{# pointer *GIObjectInfo as ObjectInfo newtype #}
+{# class ObjectInfoClass ObjectInfo #}
+instance BaseInfoClass ObjectInfo where
+ baseInfo (ObjectInfo p) = BaseInfo (castPtr p)
+ fromBaseInfo (BaseInfo p) = ObjectInfo (castPtr p)
+instance RegisteredTypeInfoClass ObjectInfo where
+ registeredTypeInfo (ObjectInfo p) = RegisteredTypeInfo (castPtr p)
+ fromRegisteredTypeInfo (RegisteredTypeInfo p) = ObjectInfo (castPtr p)
+
+{# pointer *GIStructInfo as StructInfo newtype #}
+{# class StructInfoClass StructInfo #}
+instance BaseInfoClass StructInfo where
+ baseInfo (StructInfo p) = BaseInfo (castPtr p)
+ fromBaseInfo (BaseInfo p) = StructInfo (castPtr p)
+instance RegisteredTypeInfoClass StructInfo where
+ registeredTypeInfo (StructInfo p) = RegisteredTypeInfo (castPtr p)
+ fromRegisteredTypeInfo (RegisteredTypeInfo p) = StructInfo (castPtr p)
+
+{# pointer *GIUnionInfo as UnionInfo newtype #}
+{# class UnionInfoClass UnionInfo #}
+instance BaseInfoClass UnionInfo where
+ baseInfo (UnionInfo p) = BaseInfo (castPtr p)
+ fromBaseInfo (BaseInfo p) = UnionInfo (castPtr p)
+instance RegisteredTypeInfoClass UnionInfo where
+ registeredTypeInfo (UnionInfo p) = RegisteredTypeInfo (castPtr p)
+ fromRegisteredTypeInfo (RegisteredTypeInfo p) = UnionInfo (castPtr p)
+
+{# pointer *GIArgInfo as ArgInfo newtype #}
+{# class ArgInfoClass ArgInfo #}
+instance BaseInfoClass ArgInfo where
+ baseInfo (ArgInfo p) = BaseInfo (castPtr p)
+ fromBaseInfo (BaseInfo p) = ArgInfo (castPtr p)
+
+{# pointer *GIConstantInfo as ConstantInfo newtype #}
+{# class ConstantInfoClass ConstantInfo #}
+instance BaseInfoClass ConstantInfo where
+ baseInfo (ConstantInfo p) = BaseInfo (castPtr p)
+ fromBaseInfo (BaseInfo p) = ConstantInfo (castPtr p)
+
+{# pointer *GIErrorDomainInfo as ErrorDomainInfo newtype #}
+{# class ErrorDomainInfoClass ErrorDomainInfo #}
+instance BaseInfoClass ErrorDomainInfo where
+ baseInfo (ErrorDomainInfo p) = BaseInfo (castPtr p)
+ fromBaseInfo (BaseInfo p) = ErrorDomainInfo (castPtr p)
+
+{# pointer *GIFieldInfo as FieldInfo newtype #}
+{# class FieldInfoClass FieldInfo #}
+instance BaseInfoClass FieldInfo where
+ baseInfo (FieldInfo p) = BaseInfo (castPtr p)
+ fromBaseInfo (BaseInfo p) = FieldInfo (castPtr p)
+
+{# pointer *GIPropertyInfo as PropertyInfo newtype #}
+{# class PropertyInfoClass PropertyInfo #}
+instance BaseInfoClass PropertyInfo where
+ baseInfo (PropertyInfo p) = BaseInfo (castPtr p)
+ fromBaseInfo (BaseInfo p) = PropertyInfo (castPtr p)
+
+{# pointer *GITypeInfo as TypeInfo newtype #}
+{# class TypeInfoClass TypeInfo #}
+instance BaseInfoClass TypeInfo where
+ baseInfo (TypeInfo p) = BaseInfo (castPtr p)
+ fromBaseInfo (BaseInfo p) = TypeInfo (castPtr p)
+
View
12 GObject-Introspection.cabal
@@ -48,14 +48,12 @@ Build-type: Simple
-- Constraint on the version of Cabal needed to build this package.
Cabal-version: >=1.2
-Library
- -- Modules exported by the library.
- Exposed-modules:
- GI.BaseInfo
+Executable lol
+ main-is: Main.hs
+ other-modules: GI.Types, GI.Typelib
pkgconfig-depends: gobject-introspection-1.0
-
- -- Packages needed in order to build this package.
- build-depends: base >= 4
+ extensions: ForeignFunctionInterface
+ build-depends: base >= 4, gtk, glib
-- Modules not exported by this package.
-- Other-modules:
View
1 LICENSE
@@ -0,0 +1 @@
+LOL
View
11 Main.hs
@@ -0,0 +1,11 @@
+module Main where
+
+import GI.Typelib
+import Graphics.UI.Gtk
+import System.Glib.GError
+
+main = handleGError (\(GError dom code msg) -> print (dom, code, msg)) $ do
+ initGUI
+ tp <- repositoryRequire "GLib"
+ repositoryLoad tp
+ print =<< repositoryGetNInfos "GLib"

0 comments on commit 2b9deb7

Please sign in to comment.
Something went wrong with that request. Please try again.