From: Duncan C. <dun...@us...> - 2005-04-01 22:55:34
|
Update of /cvsroot/gtk2hs/gtk2hs/tools/apiGen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20043/tools/apiGen Modified Files: ModuleScan.hs ApiGen.hs Template.chs README CodeGen.hs MarshalFixup.hs gapi2xml.pl Log Message: More ApiGen updates: ModuleScan.hs, ApiGen.hs, Template.chs: do rcs version and timestamps. CodeGen.hs, MarshalFixup.hs: add support for ignoring documentation of selected parameters or return values. Often the docs for these in the original C docs are rather pointless. gapi2xml.pl: minor change from upstream. README: update to reflect recent changes. Index: Template.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/tools/apiGen/Template.chs,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- Template.chs 27 Feb 2005 20:02:14 -0000 1.9 +++ Template.chs 1 Apr 2005 22:55:22 -0000 1.10 @@ -1,5 +1,5 @@ -- -*-haskell-*- --- GIMP Toolkit (GTK) Widget @OBJECT_NAME@ +-- GIMP Toolkit (GTK) @OBJECT_KIND@ @OBJECT_NAME@ -- -- Author : @AUTHORS@ -- Index: ModuleScan.hs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/tools/apiGen/ModuleScan.hs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- ModuleScan.hs 25 Mar 2005 19:14:39 -0000 1.6 +++ ModuleScan.hs 1 Apr 2005 22:55:22 -0000 1.7 @@ -23,6 +23,8 @@ module_filename :: String, module_authors :: [String], module_created :: String, + module_rcs_version :: String, + module_rcs_timestamp :: String, module_copyright_dates :: Either String (String, String), -- eg "2004" or "2004-2005" module_copyright_holders :: [String], @@ -42,6 +44,7 @@ data Line = None | Authors [String] | Created String + | Version String String String String | Copyright (Either String (String, String)) [String] | Module String String | Export String @@ -133,6 +136,10 @@ module_filename = "", module_authors = head $ [ authors | Authors authors <- headerLines ] ++ [[missing]], module_created = head $ [ created | Created created <- headerLines ] ++ [missing], + module_rcs_version = head $ [ major ++ "." ++ minor + | Version major minor _ _ <- headerLines ] ++ [""], + module_rcs_timestamp = head $ [ date ++ " " ++ time + | Version _ _ date time <- headerLines ] ++ [""], module_copyright_dates = head $ [ dates | Copyright dates _ <- headerLines ] ++ [Left missing], module_copyright_holders = head $ [ authors | Copyright _ authors <- headerLines ] ++ [[missing]], module_exports = let exportLines = takeWhile (not.isExportEndLine) @@ -156,6 +163,7 @@ scanLine :: String -> [String] -> Line scanLine _ ("--":"Author":":":author) = scanAuthor author scanLine _ ("--":"Created:":created) = Created (unwords created) +scanLine _ ["--","Version",_,major,".",minor,_,_,_,date,time,_] = Version major minor date time scanLine _ ("--":"Copyright":"(":c:")":copyright) = scanCopyright copyright scanLine (' ':' ':_) ("module":moduleName) = Export (concat moduleName) scanLine _ ("module":moduleName) = scanModuleName moduleName Index: CodeGen.hs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/tools/apiGen/CodeGen.hs,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- CodeGen.hs 31 Mar 2005 16:39:19 -0000 1.15 +++ CodeGen.hs 1 Apr 2005 22:55:22 -0000 1.16 @@ -14,7 +14,7 @@ import StringUtils import ModuleScan import MarshalFixup (stripKnownPrefixes, maybeNullParameter, maybeNullResult, - fixCFunctionName, leafClass) + fixCFunctionName, leafClass, nukeParameterDocumentation) import Prelude hiding (Enum, lines) import List (groupBy, sortBy, isPrefixOf, isSuffixOf, partition, find) @@ -57,7 +57,10 @@ let types | returnType' == "()" = types' | otherwise = returnType' : types' docs = mergeParamDocs (lookup "Returns" paramDocMap) docs' - in ("IO (" ++ sepBy ", " types "" ++ ")", docs) + in (case types of + [t] -> "IO " ++ t + ts -> "IO (" ++ sepBy ", " types "" ++ ")" + ,docs) (outParamMarshalersBefore, outParamMarshalersAfter, returnOutParamFragments) = unzip3 [ genMarshalOutParameter outParamType (changeIllegalNames (cParamNameToHsName name)) | (OutParam outParamType, name) <- paramTypes' ] @@ -90,7 +93,9 @@ else [DocArg (paramdoc_name paramdoc) ,DocText " - "] ) ++ paramdoc_paragraph paramdoc) - | paramdoc <- funcdoc_params doc ] + | paramdoc <- funcdoc_params doc + , not (nukeParameterDocumentation (method_cname method) + (paramdoc_name paramdoc))] formatParamTypes :: [(String, Maybe [DocParaSpan])] -> ShowS formatParamTypes paramTypes = format True False paramTypes Index: gapi2xml.pl =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/tools/apiGen/gapi2xml.pl,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- gapi2xml.pl 1 Mar 2005 21:20:45 -0000 1.3 +++ gapi2xml.pl 1 Apr 2005 22:55:22 -0000 1.4 @@ -186,6 +186,8 @@ $objects{$1} = $2 . $objects{$1}; } elsif ($cast_macro =~ /GTK_CHECK_CLASS_CAST.*,\s*(\w+),\s*(\w+)/) { $objects{$1} .= ":$2"; + } elsif ($cast_macro =~ /GST_IMPLEMENTS_INTERFACE_CHECK_INSTANCE_CAST.*,\s*(\w+),\s*(\w+)/) { + $objects{$1} = $2 . $objects{$1}; } } elsif ($line =~ /INSTANCE_GET_INTERFACE.*,\s*(\w+),\s*(\w+)/) { $ifaces{$1} = $2; Index: ApiGen.hs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/tools/apiGen/ApiGen.hs,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- ApiGen.hs 25 Mar 2005 19:14:54 -0000 1.21 +++ ApiGen.hs 1 Apr 2005 22:55:22 -0000 1.22 @@ -148,7 +148,9 @@ module_filename = object_name object ++ ".chs", module_authors = ["[Insert your full name here]"], module_created = date, - module_copyright_dates = Left year, + module_rcs_version = "", + module_rcs_timestamp = "", + module_copyright_dates = Left year, module_copyright_holders = ["[Insert your full name here]"], module_exports = [], module_imports = [], @@ -161,8 +163,11 @@ case var of "YEAR" -> ss $ formatCopyrightDates year (module_copyright_dates moduleInfo) "DATE" -> ss $ module_created moduleInfo + "OBJECT_KIND" -> ss $ if object_isinterface object then "Interface" else "Widget" "OBJECT_NAME" -> ss $ module_name moduleInfo "AUTHORS" -> ss $ concat $ intersperse ", " $ module_authors moduleInfo + "RCS_VERSION" -> ss $ module_rcs_version moduleInfo + "RCS_TIMESTAMP" -> ss $ module_rcs_timestamp moduleInfo "COPYRIGHT" -> ss $ concat $ intersperse ", " $ module_copyright_holders moduleInfo "DESCRIPTION" -> haddocFormatParas knownTypes False (moduledoc_summary moduleDoc) "DOCUMENTATION" -> genModuleDocumentation knownTypes moduleDoc Index: README =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/tools/apiGen/README,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- README 26 Jan 2005 12:13:28 -0000 1.4 +++ README 1 Apr 2005 22:55:22 -0000 1.5 @@ -16,9 +16,6 @@ eg for possibly NULL Strings you would want to change to use Maybe String also it is not possible to automatically determine the element type of GLists so this will have to be determined manually. - * Some functions have multiple out parameters which would be better done in - Haskell by returning a tuple (this may be possible to do automatically but - currently it is not). * Documentation. This is converted directly from the C documentation so there are usually things that you would want to change to make things make sense in Haskell. Code samples should be converted for example. @@ -56,8 +53,3 @@ Some improvements that would be good: * Complete marshaling code for more types - * Emit signal and property bindings with documentation - * Deal with Enums, Flags, and Interfaces properly - - make objects instances of interfaces they implement - - make a note of structs and boxed types - - allow import of parent api files for reference to known types Index: MarshalFixup.hs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/tools/apiGen/MarshalFixup.hs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- MarshalFixup.hs 25 Mar 2005 19:14:55 -0000 1.4 +++ MarshalFixup.hs 1 Apr 2005 22:55:22 -0000 1.5 @@ -104,6 +104,59 @@ maybeNullResult "gtk_notebook_get_tab_label_text" = True maybeNullResult _ = False +-- Often the documentation for parameters or the return value of functions +-- that is included in the gtk-doc docs are just pointless. So this table +-- lists the function and parameter names for which we do not want to use the +-- gtk-doc documentation. +nukeParameterDocumentation :: String -> String -> Bool +nukeParameterDocumentation "gtk_button_box_get_layout" "Returns" = True +nukeParameterDocumentation "gtk_button_set_label" "label" = True +nukeParameterDocumentation "gtk_button_get_label" "Returns" = True +nukeParameterDocumentation "gtk_toggle_button_get_active" "Returns" = True +nukeParameterDocumentation "gtk_image_new_from_file" "filename" = True +nukeParameterDocumentation "gtk_image_new_from_pixbuf" "pixbuf" = True +nukeParameterDocumentation "gtk_label_new" "str" = True +nukeParameterDocumentation "gtk_label_set_text" "str" = True +nukeParameterDocumentation "gtk_label_set_label" "str" = True +nukeParameterDocumentation "gtk_label_set_justify" "jtype" = True +nukeParameterDocumentation "gtk_label_get_justify" "Returns" = True +nukeParameterDocumentation "gtk_label_set_use_underline" "setting" = True +nukeParameterDocumentation "gtk_label_get_use_underline" "Returns" = True +nukeParameterDocumentation "gtk_label_get_text" "Returns" = True +nukeParameterDocumentation "gtk_label_get_label" "Returns" = True +nukeParameterDocumentation "gtk_label_set_text_with_mnemonic" "str" = True +nukeParameterDocumentation "gtk_progress_bar_set_text" "text" = True +nukeParameterDocumentation "gtk_progress_bar_get_orientation" "Returns" = True +nukeParameterDocumentation "gtk_progress_bar_set_orientation" "orientation" = True +nukeParameterDocumentation "gtk_statusbar_set_has_resize_grip" "setting" = True +nukeParameterDocumentation "gtk_statusbar_get_has_resize_grip" "Returns" = True +nukeParameterDocumentation "gtk_editable_get_editable" "Returns" = True +nukeParameterDocumentation "gtk_entry_set_text" "text" = True +nukeParameterDocumentation "gtk_entry_get_text" "Returns" = True +nukeParameterDocumentation "gtk_entry_append_text" "text" = True +nukeParameterDocumentation "gtk_entry_prepend_text" "text" = True +nukeParameterDocumentation "gtk_entry_set_invisible_char" "ch" = True +nukeParameterDocumentation "gtk_entry_set_has_frame" "setting" = True +nukeParameterDocumentation "gtk_entry_set_completion" "completion" = True +nukeParameterDocumentation "spin_button_get_value" "Returns" = True +nukeParameterDocumentation "spin_button_get_value_as_int" "Returns" = True +nukeParameterDocumentation "spin_button_set_value" "value" = True +nukeParameterDocumentation "gtk_expander_new" "label" = True +nukeParameterDocumentation "gtk_expander_set_expanded" "expanded" = True +nukeParameterDocumentation "gtk_expander_get_expanded" "Returns" = True +nukeParameterDocumentation "gtk_expander_set_spacing" "spacing" = True +nukeParameterDocumentation "gtk_expander_set_label" "label" = True +nukeParameterDocumentation "gtk_expander_get_label" "Returns" = True +nukeParameterDocumentation "gtk_expander_get_use_markup" "Returns" = True +nukeParameterDocumentation "gtk_fixed_set_has_window" "hasWindow" = True +nukeParameterDocumentation "gtk_fixed_get_has_window" "Returns" = True +nukeParameterDocumentation "gtk_notebook_get_n_pages" "Returns" = True +nukeParameterDocumentation "gtk_adjustment_set_value" "value" = True +nukeParameterDocumentation "gtk_adjustment_get_value" "Returns" = True +nukeParameterDocumentation "gtk_arrow_new" "arrowType" = True +nukeParameterDocumentation "gtk_arrow_new" "shadowType" = True +nukeParameterDocumentation _ _ = False + -- On win32 for glib/gtk 2.6 they changed the interpretation of functions that -- take or return system file names (as opposed to user displayable -- representations of file names). Previously the string encoding of the file |