From: Axel S. <si...@co...> - 2009-10-30 17:02:13
|
Tue May 12 17:36:27 EDT 2009 Axe...@en... * Streamline the types generated for gstreamer by removing the adapted type generator and generalizing the exiting one. hunk ./Makefile.am 104 - tools/hierarchyGenGst/TypeGenerator \ hunk ./Makefile.am 142 -tools_hierarchyGenGst_PKGNAME = tools_hierarchyGenGst_TypeGenerator - -tools_hierarchyGenGst_TypeGenerator_MAIN = \ - $(tools_hierarchyGenGst_TypeGenerator_SOURCES) -tools_hierarchyGenGst_TypeGenerator_EXTERNALDEPS = base-$(PKG_BASE_VERSION) -tools_hierarchyGenGst_TypeGenerator_NOSPLITOBJS = yes -tools_hierarchyGenGst_TypeGenerator_SOURCESDIRS = tools/hierarchyGenGst -tools_hierarchyGenGst_TypeGenerator_SOURCES = \ - tools/hierarchyGenGst/TypeGen.hs -# Fix automake - the subdir-objects option doesn't work here. -am_tools_hierarchyGenGst_TypeGenerator_OBJECTS = $(addsuffix .$(OBJEXT),\ - $(basename $(tools_hierarchyGenGst_TypeGenerator_SOURCES))) -MOSTLYCLEANFILES+= $(am_tools_hierarchyGenGst_TypeGenerator_OBJECTS) -MOSTLYCLEANFILES+= $(tools_hierarchyGenGst_TypeGenerator_SOURCES:.hs=.hi) - hunk ./Makefile.am 2492 - gstreamer/Media/Streaming/GStreamer/Core/MiniHierarchy.chs \ - gstreamer/Media/Streaming/GStreamer/Core/GObjectHierarchy.chs \ - gstreamer/Media/Streaming/GStreamer/Base/Hierarchy.chs \ - gstreamer/Media/Streaming/GStreamer/Base/GObjectHierarchy.chs \ - gstreamer/Media/Streaming/GStreamer/Controller/GObjectHierarchy.chs \ - gstreamer/Media/Streaming/GStreamer/Net/Hierarchy.chs \ - gstreamer/Media/Streaming/GStreamer/Audio/Hierarchy.chs + gstreamer/Media/Streaming/GStreamer/Core/MiniHierarchy.chs hunk ./Makefile.am 2497 - gstreamer/Media/Streaming/GStreamer/Core/HierarchyBase.hs \ - gstreamer/Media/Streaming/GStreamer/Core/MiniHierarchyBase.chs \ hunk ./Makefile.am 2557 - gstreamer/Media/Streaming/GStreamer/Core/MiniHierarchyBase.hs \ hunk ./Makefile.am 2566 -gstreamer/Media/Streaming/GStreamer/Core/Hierarchy.chs : \ - $(srcdir)/gstreamer/hierarchy.list \ - $(srcdir)/tools/hierarchyGenGst/TypeGenerator$(EXEEXT) \ - $(srcdir)/gstreamer/Media/Streaming/GStreamer/Hierarchy.chs.template - $(strip $(srcdir)/tools/hierarchyGenGst/TypeGenerator$(EXEEXT) \ - $(srcdir)/gstreamer/hierarchy.list \ - $(srcdir)/gstreamer/Media/Streaming/GStreamer/Hierarchy.chs.template \ - $@ --tag=gstreamer-core --lib=gstreamer --prefix=gst \ - --root=GObject \ - --modname=Media.Streaming.GStreamer.Core.Hierarchy) +gstreamer/Media/Streaming/GStreamer/Core/Hierarchy.chs : \ + $(srcdir)/tools/hierarchyGen/TypeGenerator$(EXEEXT) \ + $(srcdir)/tools/hierarchyGen/hierarchy.list \ + $(srcdir)/tools/hierarchyGen/Hierarchy.chs.template + $(strip $(srcdir)/tools/hierarchyGen/TypeGenerator$(EXEEXT) \ + $(srcdir)/tools/hierarchyGen/hierarchy.list \ + $(srcdir)/tools/hierarchyGen/Hierarchy.chs.template \ + $@ --tag=gstreamer --lib=gstreamer --prefix=gst \ + --modname=Media.Streaming.GStreamer.Core.Hierarchy \ + --parentname=System.Glib.GObject) hunk ./Makefile.am 2577 -gstreamer/Media/Streaming/GStreamer/Core/MiniHierarchy.chs : \ - $(srcdir)/gstreamer/mini-hierarchy.list \ - $(srcdir)/tools/hierarchyGenGst/TypeGenerator$(EXEEXT) \ - $(srcdir)/gstreamer/Media/Streaming/GStreamer/MiniHierarchy.chs.template - $(strip $(srcdir)/tools/hierarchyGenGst/TypeGenerator$(EXEEXT) \ - $(srcdir)/gstreamer/mini-hierarchy.list \ - $(srcdir)/gstreamer/Media/Streaming/GStreamer/MiniHierarchy.chs.template \ - $@ --tag=gstreamer-core --lib=gstreamer --prefix=gst \ - --root=MiniObject \ +gstreamer/Media/Streaming/GStreamer/Core/MiniHierarchy.chs : \ + $(srcdir)/tools/hierarchyGen/TypeGenerator$(EXEEXT) \ + $(srcdir)/gstreamer/mini-hierarchy.list \ + $(srcdir)/tools/hierarchyGen/Hierarchy.chs.template + $(strip $(srcdir)/tools/hierarchyGen/TypeGenerator$(EXEEXT) \ + $(srcdir)/gstreamer/mini-hierarchy.list \ + $(srcdir)/tools/hierarchyGen/Hierarchy.chs.template \ + $@ --tag=default --lib=gstreamer --prefix=gst --root=MiniObject \ + --parentname=Media.Streaming.GStreamer.Core.MiniHierarchyBase \ hunk ./Makefile.am 2588 -gstreamer/Media/Streaming/GStreamer/Core/GObjectHierarchy.chs : \ - $(srcdir)/gstreamer/gobject-hierarchy.list \ - $(srcdir)/tools/hierarchyGenGst/TypeGenerator$(EXEEXT) \ - $(srcdir)/gstreamer/Media/Streaming/GStreamer/Hierarchy.chs.template - $(strip $(srcdir)/tools/hierarchyGenGst/TypeGenerator$(EXEEXT) \ - $(srcdir)/gstreamer/gobject-hierarchy.list \ - $(srcdir)/gstreamer/Media/Streaming/GStreamer/Hierarchy.chs.template \ - $@ --tag=gstreamer-core --lib=gstreamer --prefix=gst \ - --root=GObject \ - --modname=Media.Streaming.GStreamer.Core.GObjectHierarchy) - -gstreamer/Media/Streaming/GStreamer/Base/Hierarchy.chs : \ - $(srcdir)/gstreamer/hierarchy.list \ - $(srcdir)/tools/hierarchyGenGst/TypeGenerator$(EXEEXT) \ - $(srcdir)/gstreamer/Media/Streaming/GStreamer/Hierarchy.chs.template - $(strip $(srcdir)/tools/hierarchyGenGst/TypeGenerator$(EXEEXT) \ - $(srcdir)/gstreamer/hierarchy.list \ - $(srcdir)/gstreamer/Media/Streaming/GStreamer/Hierarchy.chs.template \ - $@ --tag=gstreamer-base --lib=gstreamer --prefix=gst \ - --root=GObject \ - --modname=Media.Streaming.GStreamer.Base.Hierarchy \ - --parentname=Media.Streaming.GStreamer.Core.Hierarchy) - -gstreamer/Media/Streaming/GStreamer/Base/GObjectHierarchy.chs : \ - $(srcdir)/gstreamer/gobject-hierarchy.list \ - $(srcdir)/tools/hierarchyGenGst/TypeGenerator$(EXEEXT) \ - $(srcdir)/gstreamer/Media/Streaming/GStreamer/Hierarchy.chs.template - $(strip $(srcdir)/tools/hierarchyGenGst/TypeGenerator$(EXEEXT) \ - $(srcdir)/gstreamer/gobject-hierarchy.list \ - $(srcdir)/gstreamer/Media/Streaming/GStreamer/Hierarchy.chs.template \ - $@ --tag=gstreamer-base --lib=gstreamer --prefix=gst \ - --root=GObject \ - --modname=Media.Streaming.GStreamer.Base.GObjectHierarchy) - -gstreamer/Media/Streaming/GStreamer/Controller/GObjectHierarchy.chs : \ - $(srcdir)/gstreamer/gobject-hierarchy.list \ - $(srcdir)/tools/hierarchyGenGst/TypeGenerator$(EXEEXT) \ - $(srcdir)/gstreamer/Media/Streaming/GStreamer/Hierarchy.chs.template - $(strip $(srcdir)/tools/hierarchyGenGst/TypeGenerator$(EXEEXT) \ - $(srcdir)/gstreamer/gobject-hierarchy.list \ - $(srcdir)/gstreamer/Media/Streaming/GStreamer/Hierarchy.chs.template \ - $@ --tag=gstreamer-controller --lib=gstreamer --prefix=gst \ - --root=GObject \ - --modname=Media.Streaming.GStreamer.Controller.GObjectHierarchy) - -gstreamer/Media/Streaming/GStreamer/Net/Hierarchy.chs : \ - $(srcdir)/gstreamer/hierarchy.list \ - $(srcdir)/tools/hierarchyGenGst/TypeGenerator$(EXEEXT) \ - $(srcdir)/gstreamer/Media/Streaming/GStreamer/Hierarchy.chs.template - $(strip $(srcdir)/tools/hierarchyGenGst/TypeGenerator$(EXEEXT) \ - $(srcdir)/gstreamer/hierarchy.list \ - $(srcdir)/gstreamer/Media/Streaming/GStreamer/Hierarchy.chs.template \ - $@ --tag=gstreamer-net --lib=gstreamer --prefix=gst \ - --root=GObject \ - --modname=Media.Streaming.GStreamer.Net.Hierarchy \ - --parentname=Media.Streaming.GStreamer.Core.Hierarchy) - hunk ./Makefile.am 2597 -gstreamer/Media/Streaming/GStreamer/Audio/Hierarchy.chs : \ - $(srcdir)/gstreamer/hierarchy.list \ - $(srcdir)/tools/hierarchyGenGst/TypeGenerator$(EXEEXT) \ - $(srcdir)/gstreamer/Media/Streaming/GStreamer/Hierarchy.chs.template - $(strip $(srcdir)/tools/hierarchyGenGst/TypeGenerator$(EXEEXT) \ - $(srcdir)/gstreamer/hierarchy.list \ - $(srcdir)/gstreamer/Media/Streaming/GStreamer/Hierarchy.chs.template \ - $@ --tag=gstreamer-audio --lib=gstreamer --prefix=gst \ - --root=GObject \ - --modname=Media.Streaming.GStreamer.Audio.Hierarchy \ - --parentname=Media.Streaming.GStreamer.Core.Hierarchy) - hunk ./gstreamer/Media/Streaming/GStreamer/Audio/Types.chs 34 - , module Media.Streaming.GStreamer.Audio.Hierarchy hunk ./gstreamer/Media/Streaming/GStreamer/Audio/Types.chs 41 -{#import Media.Streaming.GStreamer.Audio.Hierarchy#} hunk ./gstreamer/Media/Streaming/GStreamer/Base/Adapter.chs.pp 33 - toAdapter, hunk ./gstreamer/Media/Streaming/GStreamer/Base/Adapter.chs.pp 34 - isAdapter, + gTypeAdapter, + hunk ./gstreamer/Media/Streaming/GStreamer/Base/BaseSink.chs.pp 34 - toBaseSink, + gTypeBaseSink, + [_$_] hunk ./gstreamer/Media/Streaming/GStreamer/Base/BaseSrc.chs.pp 34 - toBaseSrc, + gTypeBaseSrc, + hunk ./gstreamer/Media/Streaming/GStreamer/Base/BaseTransform.chs.pp 34 - toBaseTransform, + gTypeBaseTransform, + hunk ./gstreamer/Media/Streaming/GStreamer/Base/PushSrc.chs 34 - toPushSrc, + gTypePushSrc, hunk ./gstreamer/Media/Streaming/GStreamer/Base/Types.chs 35 - module Media.Streaming.GStreamer.Base.Hierarchy, - module Media.Streaming.GStreamer.Base.GObjectHierarchy, hunk ./gstreamer/Media/Streaming/GStreamer/Base/Types.chs 42 -{#import Media.Streaming.GStreamer.Base.Hierarchy#} -{#import Media.Streaming.GStreamer.Base.GObjectHierarchy#} hunk ./gstreamer/Media/Streaming/GStreamer/Controller/Controller.chs 58 - constructNewGObject Controller $ return cController + constructNewGObject mkController $ return cController hunk ./gstreamer/Media/Streaming/GStreamer/Controller/Types.chs 35 - module Media.Streaming.GStreamer.Controller.GObjectHierarchy, hunk ./gstreamer/Media/Streaming/GStreamer/Controller/Types.chs 39 -{#import Media.Streaming.GStreamer.Controller.GObjectHierarchy#} hunk ./gstreamer/Media/Streaming/GStreamer/Core/Bin.chs.pp 63 - -- Safely downcast an 'Object' to a 'Bin'. hunk ./gstreamer/Media/Streaming/GStreamer/Core/Bin.chs.pp 64 - -- Upcast to a 'Bin'. - toBin, - -- See if an 'Object' is a 'Bin'. - isBin, + gTypeBin, hunk ./gstreamer/Media/Streaming/GStreamer/Core/Buffer.chs.pp 44 - BufferFlags(..), - -- Safely downcast an 'Object' to a 'Bin'. hunk ./gstreamer/Media/Streaming/GStreamer/Core/Buffer.chs.pp 45 - -- Upcast to a 'Bin'. - toBuffer, - -- See if an 'Object' is a 'Bin'. - isBuffer, + gTypeBuffer, + + BufferFlags(..), hunk ./gstreamer/Media/Streaming/GStreamer/Core/Bus.chs.pp 85 - toBus, + gTypeBus, + hunk ./gstreamer/Media/Streaming/GStreamer/Core/Clock.chs.pp 109 - toClock, + gTypeClock, hunk ./gstreamer/Media/Streaming/GStreamer/Core/Element.chs.pp 77 - toElement, + gTypeElement, + hunk ./gstreamer/Media/Streaming/GStreamer/Core/ElementFactory.chs.pp 46 - toElementFactory, + gTypeElementFactory, hunk ./gstreamer/Media/Streaming/GStreamer/Core/GhostPad.chs.pp 34 - toGhostPad, + gTypeGhostPad, + hunk ./gstreamer/Media/Streaming/GStreamer/Core/Index.chs 34 - toIndex, + gTypeIndex, + hunk ./gstreamer/Media/Streaming/GStreamer/Core/IndexFactory.chs 34 - toIndexFactory, + gTypeIndexFactory, + hunk ./gstreamer/Media/Streaming/GStreamer/Core/Message.chs.pp 34 - toMessage, + gTypeMessage, hunk ./gstreamer/Media/Streaming/GStreamer/Core/MiniHierarchyBase.chs 33 + module System.Glib.GObject, hunk ./gstreamer/Media/Streaming/GStreamer/Core/MiniObject.chs 37 - isMiniObject, hunk ./gstreamer/Media/Streaming/GStreamer/Core/Object.chs.pp 34 - toObject, + gTypeObject, + hunk ./gstreamer/Media/Streaming/GStreamer/Core/Pad.chs.pp 34 - toPad, + gTypePad, + hunk ./gstreamer/Media/Streaming/GStreamer/Core/PadTemplate.chs.pp 34 - toPadTemplate, + gTypePadTemplate, + hunk ./gstreamer/Media/Streaming/GStreamer/Core/Pipeline.chs 33 - toPipeline, + gTypePipeline, + hunk ./gstreamer/Media/Streaming/GStreamer/Core/Plugin.chs 33 - toPlugin, + gTypePlugin, + hunk ./gstreamer/Media/Streaming/GStreamer/Core/PluginFeature.chs 34 - toPluginFeature, + gTypePluginFeature, + hunk ./gstreamer/Media/Streaming/GStreamer/Core/Query.chs 35 - isQuery, + gTypeQuery, hunk ./gstreamer/Media/Streaming/GStreamer/Core/Registry.chs 34 - toRegistry, + gTypeRegistry, + hunk ./gstreamer/Media/Streaming/GStreamer/Core/SystemClock.chs 33 - toSystemClock, hunk ./gstreamer/Media/Streaming/GStreamer/Core/SystemClock.chs 34 + gTypeSystemClock, + hunk ./gstreamer/Media/Streaming/GStreamer/Core/Types.chs.pp 39 - module Media.Streaming.GStreamer.Core.GObjectHierarchy, hunk ./gstreamer/Media/Streaming/GStreamer/Core/Types.chs.pp 176 -{#import Media.Streaming.GStreamer.Core.GObjectHierarchy#} hunk ./gstreamer/Media/Streaming/GStreamer/Hierarchy.chs.template 1 -{-# OPTIONS_HADDOCK hide #-} --- GIMP Toolkit (GTK) Binding for Haskell: binding to gstreamer -*-haskell-*- --- --- Author : Peter Gavin --- Created: 1-Apr-2007 --- --- Copyright (c) 2007 Peter Gavin --- --- This library is free software: you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public License --- as published by the Free Software Foundation, either version 3 of --- the License, or (at your option) any later version. --- [_$_] --- This library is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --- Lesser General Public License for more details. --- [_$_] --- You should have received a copy of the GNU Lesser General Public --- License along with this program. If not, see --- <http://www.gnu.org/licenses/>. --- [_$_] --- GStreamer, the C library which this Haskell library depends on, is --- available under LGPL Version 2. The documentation included with --- this library is based on the original GStreamer documentation. --- --- #hide - --- | Maintainer : gtk2hs-devel\@lists.sourceforge.net --- Stability : alpha --- Portability : portable (depends on GHC) -module @MODULE_NAME@ ( -@MODULE_EXPORTS@ - ) where - -import Foreign.ForeignPtr (ForeignPtr, castForeignPtr, unsafeForeignPtrToPtr) -import Foreign.C.Types -import System.Glib.GType (GType, typeInstanceIsA) -import System.Glib.GObject -import Media.Streaming.GStreamer.Core.HierarchyBase -@IMPORT_PARENT@ - -{# context lib="@CONTEXT_LIB@" prefix="@CONTEXT_PREFIX@" #} - -@DECLERATIONS@ rmfile ./gstreamer/Media/Streaming/GStreamer/Hierarchy.chs.template hunk ./gstreamer/Media/Streaming/GStreamer/MiniHierarchy.chs.template 1 -{-# OPTIONS_HADDOCK hide #-} --- GIMP Toolkit (GTK) Binding for Haskell: binding to gstreamer -*-haskell-*- --- --- Author : Peter Gavin --- Created: 1-Apr-2007 --- --- Copyright (c) 2007 Peter Gavin --- --- This library is free software: you can redistribute it and/or --- modify it under the terms of the GNU Lesser General Public License --- as published by the Free Software Foundation, either version 3 of --- the License, or (at your option) any later version. --- [_$_] --- This library is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --- Lesser General Public License for more details. --- [_$_] --- You should have received a copy of the GNU Lesser General Public --- License along with this program. If not, see --- <http://www.gnu.org/licenses/>. --- [_$_] --- GStreamer, the C library which this Haskell library depends on, is --- available under LGPL Version 2. The documentation included with --- this library is based on the original GStreamer documentation. --- --- #hide - --- | Maintainer : gtk2hs-devel\@lists.sourceforge.net --- Stability : alpha --- Portability : portable (depends on GHC) -module @MODULE_NAME@ ( -@MODULE_EXPORTS@ - ) where - -import Foreign.ForeignPtr (ForeignPtr, castForeignPtr, unsafeForeignPtrToPtr) -import Foreign.C.Types -import System.Glib.GType (GType, typeInstanceIsA) -import Media.Streaming.GStreamer.Core.MiniHierarchyBase -@IMPORT_PARENT@ - -{# context lib="@CONTEXT_LIB@" prefix="@CONTEXT_PREFIX@" #} - -@DECLERATIONS@ rmfile ./gstreamer/Media/Streaming/GStreamer/MiniHierarchy.chs.template hunk ./gstreamer/Media/Streaming/GStreamer/Net/Types.chs 35 - module Media.Streaming.GStreamer.Net.Hierarchy hunk ./gstreamer/Media/Streaming/GStreamer/Net/Types.chs 39 -{#import Media.Streaming.GStreamer.Net.Hierarchy#} hunk ./gstreamer/gobject-hierarchy.list 1 - GObject [_$_] - GstURIHandler as URIHandler, gst_uri_handler_get_type if gstreamer-core - GstAdapter as Adapter, gst_adapter_get_type if gstreamer-base - GstController as Controller, gst_controller_get_type if gstreamer-controller rmfile ./gstreamer/gobject-hierarchy.list hunk ./gstreamer/hierarchy.list 1 - GObject [_$_] -## GStreamer classes - GstObject as Object, gst_object_get_type if gstreamer-core - GstPad as Pad, gst_pad_get_type if gstreamer-core - GstGhostPad as GhostPad, gst_ghost_pad_get_type if gstreamer-core - GstPluginFeature as PluginFeature, gst_plugin_feature_get_type if gstreamer-core - GstElementFactory as ElementFactory, gst_element_factory_get_type if gstreamer-core - GstTypeFindFactory as TypeFindFactory, gst_type_find_factory_get_type if gstreamer-core - GstIndexFactory as IndexFactory, gst_index_factory_get_type if gstreamer-core - GstElement as Element, gst_element_get_type if gstreamer-core - GstBin as Bin, gst_bin_get_type if gstreamer-core - GstPipeline as Pipeline, gst_pipeline_get_type if gstreamer-core - GstImplementsInterface as ImplementsInterface, gst_implements_interface_get_type if gstreamer-core - GstTagSetter as TagSetter, gst_tag_setter_get_type if gstreamer-core - GstBaseSrc as BaseSrc, gst_base_src_get_type if gstreamer-base - GstPushSrc as PushSrc, gst_push_src_get_type if gstreamer-base - GstBaseSink as BaseSink, gst_base_sink_get_type if gstreamer-base - GstBaseTransform as BaseTransform, gst_base_transform_get_type if gstreamer-base - GstPlugin as Plugin, gst_plugin_get_type if gstreamer-core - GstRegistry as Registry, gst_registry_get_type if gstreamer-core - GstBus as Bus, gst_bus_get_type if gstreamer-core - GstClock as Clock, gst_clock_get_type if gstreamer-core - GstAudioClock as AudioClock, gst_audio_clock_get_type if gstreamer-audio - GstSystemClock as SystemClock, gst_system_clock_get_type if gstreamer-core - GstNetClientClock as NetClientClock, gst_net_client_clock_get_type if gstreamer-net - GstIndex as Index, gst_index_get_type if gstreamer-core - GstPadTemplate as PadTemplate, gst_pad_template_get_type if gstreamer-core - GstTask as Task, gst_task_get_type if gstreamer-core - GstXML as XML, gst_xml_get_type if gstreamer-core - GstChildProxy as ChildProxy, gst_child_proxy_get_type if gstreamer-core - GstCollectPads as CollectPads, gst_collect_pads_get_type if gstreamer-base rmfile ./gstreamer/hierarchy.list hunk ./gstreamer/mini-hierarchy.list 3 - GstBuffer as Buffer, gst_buffer_get_type if gstreamer-core - GstEvent as Event, gst_event_get_type if gstreamer-core - GstMessage as Message, gst_message_get_type if gstreamer-core - GstQuery as Query, gst_query_get_type if gstreamer-core + GstBuffer as Buffer, gst_buffer_get_type + GstEvent as Event, gst_event_get_type + GstMessage as Message, gst_message_get_type + GstQuery as Query, gst_query_get_type hunk ./tools/hierarchyGen/Hierarchy.chs.template 43 -@DESTR_IMPORT@ hunk ./tools/hierarchyGen/Hierarchy.chs.template 49 -castTo :: (GObjectClass obj, GObjectClass obj') => GType -> String +castTo :: (@ROOTOBJECT@Class obj, @ROOTOBJECT@Class obj') => GType -> String hunk ./tools/hierarchyGen/Hierarchy.chs.template 52 - case toGObject obj of - gobj\@(GObject objFPtr) + case to@ROOTOBJECT@ obj of + gobj\@(@ROOTOBJECT@ objFPtr) hunk ./tools/hierarchyGen/Hierarchy.chs.template 55 - -> unsafeCastGObject gobj + -> unsafeCast@ROOTOBJECT@ gobj hunk ./tools/hierarchyGen/Hierarchy.chs.template 58 -@DECLERATIONS@ +@DECLARATIONS@ hunk ./tools/hierarchyGen/TypeGen.hs 129 + let rootObject = case map (drop 7) (filter ("--root=" `isPrefixOf`) rem) of + [] -> "GObject" + (rootObject:_) -> rootObject hunk ./tools/hierarchyGen/TypeGen.hs 150 - + [_$_] hunk ./tools/hierarchyGen/TypeGen.hs 158 - "MODULE_EXPORTS" -> generateExports parentName forwardNames objs + "MODULE_EXPORTS" -> generateExports rootObject parentName forwardNames objs hunk ./tools/hierarchyGen/TypeGen.hs 164 - "DESTR_IMPORT" -> if destrFun/="objectUnref" then id else - indent 0.ss "import System.Glib.GObject(objectUnref)" hunk ./tools/hierarchyGen/TypeGen.hs 166 - "DECLERATIONS" -> generateDeclerations destrFun prefix objs specialQueries + "DECLARATIONS" -> generateDeclarations rootObject destrFun prefix objs specialQueries + "ROOTOBJECT" -> ss rootObject hunk ./tools/hierarchyGen/TypeGen.hs 205 -generateExports :: String -> [String] -> [[String]] -> ShowS -generateExports parent forwardNames objs = +generateExports :: String -> String -> [String] -> [[String]] -> ShowS +generateExports rootObject parent forwardNames objs = hunk ./tools/hierarchyGen/TypeGen.hs 219 - , n /= "GObject" ] + , n /= rootObject ] hunk ./tools/hierarchyGen/TypeGen.hs 221 -generateDeclerations :: String -> String -> [[String]] -> TypeTable -> ShowS -generateDeclerations destr prefix objs typeTable = +generateDeclarations :: String -> String -> String -> [[String]] -> TypeTable -> ShowS +generateDeclarations rootObject destr prefix objs typeTable = hunk ./tools/hierarchyGen/TypeGen.hs 224 - [ makeClass destr prefix typeTable obj - . makeUpcast obj + [ makeClass rootObject destr prefix typeTable obj + . makeUpcast rootObject obj hunk ./tools/hierarchyGen/TypeGen.hs 229 -makeUpcast :: [String] -> ShowS -makeUpcast [obj] = id -- no casting for GObject -makeUpcast (obj:_:_) = [_$_] - indent 0.ss "castTo".ss obj.ss " :: GObjectClass obj => obj -> ".ss obj. +makeUpcast :: String -> [String] -> ShowS +makeUpcast rootObject [obj] = id -- no casting for root +makeUpcast rootObject (obj:_:_) = [_$_] + indent 0.ss "castTo".ss obj.ss " :: ".ss rootObject.ss "Class obj => obj -> ".ss obj. hunk ./tools/hierarchyGen/TypeGen.hs 237 -makeGType table [obj] = id -- no GType for GObject +makeGType table [obj] = id -- no GType for root hunk ./tools/hierarchyGen/TypeGen.hs 270 -makeClass :: String -> String -> TypeTable -> [String] -> ShowS -makeClass destr prefix table (name:[]) = id -makeClass destr prefix table (name:parents) = +makeClass :: String -> String -> String -> TypeTable -> [String] -> ShowS +makeClass rootObject destr prefix table (name:[]) = id +makeClass rootObject destr prefix table (name:parents) = hunk ./tools/hierarchyGen/TypeGen.hs 296 - indent 0.ss "to".ss name.ss " = unsafeCastGObject . toGObject". + indent 0.ss "to".ss name.ss " = unsafeCast".ss rootObject.ss " . to".ss rootObject. hunk ./tools/hierarchyGen/TypeGen.hs 299 - makeGObjectInstance name. + makeRootInstance rootObject name. hunk ./tools/hierarchyGen/TypeGen.hs 308 -makeGObjectInstance :: String -> ShowS -makeGObjectInstance name = - indent 0.ss "instance GObjectClass ".ss name.ss " where". - indent 1.ss "toGObject = GObject . castForeignPtr . un".ss name. - indent 1.ss "unsafeCastGObject = ".ss name.ss" . castForeignPtr . unGObject" +makeRootInstance :: String -> String -> ShowS +makeRootInstance rootObject name = + indent 0.ss "instance ".ss rootObject.ss "Class ".ss name.ss " where". + indent 1.ss "to".ss rootObject.ss " = ".ss rootObject.ss" . castForeignPtr . un".ss name. + indent 1.ss "unsafeCast".ss rootObject.ss " = ".ss name.ss " . castForeignPtr . un".ss rootObject hunk ./tools/hierarchyGen/hierarchy.list 277 +## GStreamer classes + GstObject as Object, gst_object_get_type if gstreamer + GstPad as Pad, gst_pad_get_type if gstreamer + GstGhostPad as GhostPad, gst_ghost_pad_get_type if gstreamer + GstPluginFeature as PluginFeature, gst_plugin_feature_get_type if gstreamer + GstElementFactory as ElementFactory, gst_element_factory_get_type if gstreamer + GstTypeFindFactory as TypeFindFactory, gst_type_find_factory_get_type if gstreamer + GstIndexFactory as IndexFactory, gst_index_factory_get_type if gstreamer + GstElement as Element, gst_element_get_type if gstreamer + GstBin as Bin, gst_bin_get_type if gstreamer + GstPipeline as Pipeline, gst_pipeline_get_type if gstreamer + GstImplementsInterface as ImplementsInterface, gst_implements_interface_get_type if gstreamer + GstTagSetter as TagSetter, gst_tag_setter_get_type if gstreamer + GstBaseSrc as BaseSrc, gst_base_src_get_type if gstreamer + GstPushSrc as PushSrc, gst_push_src_get_type if gstreamer + GstBaseSink as BaseSink, gst_base_sink_get_type if gstreamer + GstBaseTransform as BaseTransform, gst_base_transform_get_type if gstreamer + GstPlugin as Plugin, gst_plugin_get_type if gstreamer + GstRegistry as Registry, gst_registry_get_type if gstreamer + GstBus as Bus, gst_bus_get_type if gstreamer + GstClock as Clock, gst_clock_get_type if gstreamer + GstAudioClock as AudioClock, gst_audio_clock_get_type if gstreamer + GstSystemClock as SystemClock, gst_system_clock_get_type if gstreamer + GstNetClientClock as NetClientClock, gst_net_client_clock_get_type if gstreamer + GstIndex as Index, gst_index_get_type if gstreamer + GstPadTemplate as PadTemplate, gst_pad_template_get_type if gstreamer + GstTask as Task, gst_task_get_type if gstreamer + GstXML as XML, gst_xml_get_type if gstreamer + GstChildProxy as ChildProxy, gst_child_proxy_get_type if gstreamer + GstCollectPads as CollectPads, gst_collect_pads_get_type if gstreamer +## these are actually GInterfaces + GstURIHandler as URIHandler, gst_uri_handler_get_type if gstreamer + GstAdapter as Adapter, gst_adapter_get_type if gstreamer + GstController as Controller, gst_controller_get_type if gstreamer + hunk ./tools/hierarchyGenGst/TypeGen.hs 1 --- TypeGenerator.hs --- Takes a hierarchical list of all objects in GTK+ and produces --- Haskell class that reflect this hierarchy. -module Main (main) where - -import Data.Char (isAlpha, isAlphaNum, toLower, toUpper, isUpper) -import Data.List (isPrefixOf) -import Control.Monad (when) -import System.Environment (getArgs) -import System.Exit (exitWith, ExitCode(..)) - --- The current object and its inheritence relationship is defined by all --- ancestors and their column position. -type ObjectSpec = [(Int,String)] - --- This is a mapping from a type name to a) the type name in Haskell and --- b) the GTK blah_get_type function. -type TypeQuery = (String, (String, Maybe String)) -type TypeTable = [TypeQuery] - --- A Tag is a string restricting the generation of type entries to --- those lines that have the appropriate "if <tag>" at the end. -type Tag = String - -data ParserState = ParserState { - line :: Int, - col :: Int, - hierObjs :: ObjectSpec, - onlyTags :: [Tag] - } - -freshParserState :: [Tag] -> ParserState -freshParserState = ParserState 1 1 [] - --- The parser returns a list of ObjectSpec and possibly a special type query --- function. Each ObjectSpec describes one object with all its parents. - -pFreshLine :: ParserState -> String -> [(ObjectSpec, TypeQuery)] -pFreshLine ps input = pFL ps input - where - pFL ps ('#':rem) = pFL ps (dropWhile ((/=) '\n') rem) - pFL ps ('\n':rem) = pFL (ps {line = line ps+1, col=1}) rem - pFL ps (' ':rem) = pFL (ps {col=col ps+1}) rem - pFL ps ('\t':rem) = pFL (ps {col=col ps+8}) rem - pFL ps all@('G':'t':'k':rem)= pGetObject ps all rem - pFL ps all@('G':'d':'k':rem)= pGetObject ps all rem - pFL ps all@('G':'n':'o':'m':'e':rem)= pGetObject ps all rem - pFL ps [] = [] - pFL ps all = pGetObject ps all all - -pGetObject :: ParserState -> String -> String -> [(ObjectSpec, TypeQuery)] -pGetObject ps@ParserState { onlyTags=tags } txt txt' = [_$_] - (if readTag `elem` tags then (:) (spec, specialQuery) else id) $ - pFreshLine (ps { hierObjs=spec}) (dropWhile ((/=) '\n') rem'') - where - isBlank c = c==' ' || c=='\t' - isAlphaNum_ c = isAlphaNum c || c=='_' - isTagName c = isAlphaNum_ c || c=='-' || c=='.' --to allow tag 'gtk-2.4' - (origCName,rem) = span isAlphaNum txt - (origHsName,_) = span isAlphaNum txt' - (name,specialQuery,rem') = case (dropWhile isBlank rem) of - ('a':'s':r) -> - let (tyName,r') = span isAlphaNum_ (dropWhile isBlank r) in - case (dropWhile isBlank r') of - (',':r) -> - let (tyQuery,r') = span isAlphaNum_ (dropWhile isBlank r) in - (tyName, (tyName, (origCName, Just tyQuery)), r') - r -> (tyName, (tyName, (origCName, Nothing)), r) - r -> (origHsName, (origHsName, (origCName, Nothing)), r) - parents = dropWhile (\(c,_) -> c>=col ps) (hierObjs ps) - spec = (col ps,name):parents - (readTag, rem'') = case (dropWhile isBlank rem') of - ('i':'f':r) -> span isTagName (dropWhile isBlank r) - r -> ("default",r) - - -------------------------------------------------------------------------------- --- Helper functions -------------------------------------------------------------------------------- - -ss = showString -sc = showChar - -indent :: Int -> ShowS -indent c = ss ("\n"++replicate (2*c) ' ') - -------------------------------------------------------------------------------- --- start of code generation -------------------------------------------------------------------------------- - - -main = do - args <- getArgs - when (length args<3) usage - - ----------------------------------------------------------------------------- - -- Parse command line parameters - -- - let (hierFile: templateFile: goalFile: rem) = args - let tags = map (drop 6) (filter ("--tag=" `isPrefixOf`) rem) - let lib = case map (drop 6) (filter ("--lib=" `isPrefixOf`) rem) of - [] -> "gtk" - (lib:_) -> lib - let prefix = case map (drop 9) (filter ("--prefix=" `isPrefixOf`) rem) of - [] -> "gtk" - (prefix:_) -> prefix - let modName = case map (drop 10) (filter ("--modname=" `isPrefixOf`) rem) of - [] -> bareFName goalFile - (modName:_) -> modName - where bareFName = reverse . - takeWhile isAlphaNum . - drop 1 . - dropWhile isAlpha . - reverse - let parentName = case map (drop 13) (filter ("--parentname=" `isPrefixOf`) rem) of - [] -> "" - (parentName:_) -> parentName - [_$_] - let rootObject = case map (drop 7) (filter ("--root=" `isPrefixOf`) rem) of - [] -> "GObject" - (rootObject:_) -> rootObject - - ----------------------------------------------------------------------------- - -- Read in the input files - -- - content <- if hierFile == "-" - then getContents -- read stdin - else readFile hierFile - template <- readFile templateFile - - ----------------------------------------------------------------------------- - -- Parse the contents of the hierarchy file - -- - let (objs', specialQueries) = unzip $ - pFreshLine (freshParserState tags) content - objs = map (map snd) objs' - - ----------------------------------------------------------------------------- - -- Write the result file by substituting values into the template file - -- - writeFile goalFile $ - templateSubstitute template (\var -> - case var of - "MODULE_NAME" -> ss modName - "MODULE_EXPORTS" -> generateExports parentName objs - "IMPORT_PARENT" -> if null parentName - then ss "" - else ss "{#import " .ss parentName .ss "#}" - "CONTEXT_LIB" -> ss lib - "CONTEXT_PREFIX" -> ss prefix - "DECLERATIONS" -> generateDeclerations prefix rootObject objs specialQueries - _ -> ss "" - ) "" - - -usage = do - putStr "\nProgram to generate Gtk's object hierarchy in Haskell. Usage:\n\ - \TypeGenerator <hierFile> <templateFile> <outFile> {--tag=<tag>}\n\ - \ {--lib=<lib>} {--prefix=<prefix>}\n\ - \ {--modname=<modName>} {--parentname=<parentName>}\n\ - \where\n\ - \ <hierFile> a list of all possible objects, the hierarchy is\n\ - \ taken from the indentation\n\ - \ <templateFile> is the name and path of the output template file\n\ - \ <outFile> is the name and path of the output file\n\ - \ <tag> generate entries that have the tag <tag>\n\ - \ specify `default' for types without tags\n\ - \ <lib> set the lib to use in the c2hs {#context #}\n\ - \ declaration (the default is \"gtk\")\n\ - \ <prefix> set the prefix to use in the c2hs {#context #}\n\ - \ declaration (the default is \"gtk\")\n\ - \ <modName> specify module name if it does not match the\n\ - \ file name, eg a hierarchical module name\n\ - \ <parentName> specify the name of the module that defines any\n\ - \ parent classes eg Hierarchy (default is none)\n" - exitWith $ ExitFailure 1 - - - -------------------------------------------------------------------------------- --- generate dynamic fragments -------------------------------------------------------------------------------- - -generateExports :: String -> [[String]] -> ShowS -generateExports parent objs = - drop 2. - foldl (\s1 s2 -> s1.ss ", ".s2) id - [ indent 1.ss n.ss "(".ss n.ss "), ".ss n.ss "Class,". - indent 1.ss "to".ss n.ss ", ". - indent 1.ss "mk".ss n.ss ", un".ss n.sc ','. - indent 1.ss "castTo".ss n.ss ",". - indent 1.ss "is".ss n - | (n:_) <- objs - , n /= "GObject" ] - -generateDeclerations :: String -> String -> [[String]] -> TypeTable -> ShowS -generateDeclerations prefix rootObject objs typeTable = - foldl (.) id - [ makeClass prefix typeTable rootObject obj - . makeUpcast typeTable rootObject obj - | obj <- objs ] - -makeUpcast :: TypeTable -> String -> [String] -> ShowS -makeUpcast table rootObject [obj] = id -- no casting for GObject -makeUpcast table rootObject (obj:_:_) = [_$_] - indent 0.ss "castTo".ss obj.ss " :: ".ss rootObject.ss "Class obj => obj -> ".ss obj. - indent 0.ss "castTo".ss obj.ss " = mkCastTo".ss rootObject. - indent 1.get_type_func.ss " \"".ss obj.ss "\"". - indent 0.ss "is".ss obj.ss " :: ".ss obj.ss "Class o => o -> Bool". - indent 0.ss "is".ss obj.ss " = mkIs".ss rootObject.ss " ".get_type_func. - indent 0 - where - get_type_func = - ss "{# call fun unsafe ". - ss (case lookup obj table of [_$_] - (Just (_, Just get_type_func)) -> get_type_func - (Just (cname, _)) -> tail $ c2u True cname++"_get_type"). - ss " #}" - -- case to underscore translation: the boolean arg specifies whether - -- the first uppercase letter X is to be replaced by _x (True) or by x. - -- - -- translation: HButtonBox -> hbutton_box - c2u :: Bool -> String -> String - c2u True (x:xs) | isUpper x = '_':toLower x:c2u False xs - c2u False (x:xs) | isUpper x = toLower x:c2u True xs - c2u _ (x:xs) | otherwise = x:c2u True xs - c2u _ [] = [] - -makeOrd fill [] = id -makeOrd fill (obj:preds) = indent 1.ss "compare ".ss obj.ss "Tag ". - fill obj.ss obj.ss "Tag".fill obj. - ss " = EQ".makeGT obj preds - where - makeGT obj [] = id - makeGT obj (pr:eds) = indent 1.ss "compare ".ss obj.ss "Tag ". - fill obj.ss pr.ss "Tag".fill pr. - ss " = GT".makeGT obj eds - -makeClass :: String -> TypeTable -> String -> [String] -> ShowS -makeClass prefix table rootObject (name:[]) = id -makeClass prefix table rootObject (name:parents) = - indent 0.ss "-- ".ss (replicate (75-length name) '*').sc ' '.ss name. - indent 0. - indent 0.ss "{#pointer *". - (case lookup name table of - (Just (cname, _)) | stripPrefix cname == name -> ss name - | otherwise -> ss cname.ss " as ".ss name - where stripPrefix s = if uCasePrefix `isPrefixOf` s - then drop (length prefix) s - else s - uCasePrefix = toUpper (head prefix) : tail prefix -- gtk -> Gtk - ). - ss " foreign newtype #}". - indent 0. - indent 0.ss "mk".ss name.ss " = ".ss name. - indent 0.ss "un".ss name.ss " (".ss name.ss " o) = o". - indent 0. - indent 0.ss "class ".ss (head parents).ss "Class o => ".ss name.ss "Class o". - indent 0.ss "to".ss name.ss " :: ".ss name.ss "Class o => o -> ".ss name. - indent 0.ss "to".ss name.ss " = unsafeCast".ss rootObject.ss " . to".ss rootObject. - indent 0. - makeInstance name (name:init parents). - makeRootInstance name rootObject. - indent 0 - -makeInstance :: String -> [String] -> ShowS -makeInstance name [] = id -makeInstance name (par:ents) = - indent 0.ss "instance ".ss par.ss "Class ".ss name. - makeInstance name ents - -makeRootInstance :: String -> String -> ShowS -makeRootInstance name rootObject = - indent 0.ss "instance ".ss rootObject.ss "Class ".ss name.ss " where". - indent 1.ss "to".ss rootObject.ss " = ".ss "mk".ss rootObject.ss" . castForeignPtr . un".ss name. - indent 1.ss "unsafeCast".ss rootObject.ss " = mk".ss name.ss " . castForeignPtr . un".ss rootObject - -templateSubstitute :: String -> (String -> ShowS) -> ShowS -templateSubstitute template varSubst = doSubst template [_$_] - where doSubst [] = id - doSubst ('\\':'@':cs) = sc '@' . doSubst cs - doSubst ('@':cs) = let (var,_:cs') = span ('@'/=) cs - in varSubst var . doSubst cs' - doSubst (c:cs) = sc c . doSubst cs rmfile ./tools/hierarchyGenGst/TypeGen.hs rmdir ./tools/hierarchyGenGst hunk ./tools/hierarchyGen/TypeGen.hs 150 - [_$_] + |