From: <jb...@us...> - 2009-01-09 05:56:10
|
Revision: 9289 http://plplot.svn.sourceforge.net/plplot/?rev=9289&view=rev Author: jbauck Date: 2009-01-09 05:56:04 +0000 (Fri, 09 Jan 2009) Log Message: ----------- In the Ada bindings, remove the procedure versions of Get_Device_Name, Get_Version_Number, and Get_Output_File_Name (plgdev, plgver, and plgfnam in traditional-name binding)?\226?\128?\148the function versions are to be used. Remove the null character terminator when converting from C strings to Ada Strings in these functions. Make examples 31 use function-only versions of Get_Output_File_Name and plgfnam. Modified Paths: -------------- trunk/bindings/ada/plplot.adb.cmake trunk/bindings/ada/plplot.ads.cmake trunk/bindings/ada/plplot_traditional.adb.cmake trunk/bindings/ada/plplot_traditional.ads.cmake trunk/doc/docbook/src/ada.xml trunk/examples/ada/x31a.adb.cmake trunk/examples/ada/xthick31a.adb.cmake Modified: trunk/bindings/ada/plplot.adb.cmake =================================================================== --- trunk/bindings/ada/plplot.adb.cmake 2009-01-09 00:49:14 UTC (rev 9288) +++ trunk/bindings/ada/plplot.adb.cmake 2009-01-09 05:56:04 UTC (rev 9289) @@ -1497,26 +1497,19 @@ end Get_Compression_Level; - -- Get the current device (keyword) name - -- plgdev - procedure Get_Device_Name(Device_Name : out String) is - PL_Device_Name : char_array(0..79); - begin - plgdev(PL_Device_Name); - Device_Name := To_Ada(PL_Device_Name, False); - end Get_Device_Name; - - - -- Make a function version of plgdev so that the caller can use it whereever + -- Make a function version of Get_Device_Name so that the caller can use it whereever -- a String type is expected without fooling around with conversions between -- Ada string types. See Example 14 for useage. + -- This _replaces_ the procedure version. -- THIS IS NOT IN THE C API. + + -- Get the current device (keyword) name -- plgdev function Get_Device_Name return String is PL_Device_Name : char_array(0..79); begin plgdev(PL_Device_Name); - return To_Ada(PL_Device_Name, True); + return To_Ada(PL_Device_Name, False); end Get_Device_Name; @@ -1587,23 +1580,19 @@ end Get_File_Family_Parameters; + -- Make a function version of Get_Output_File_Name so that the caller can use it whereever + -- a String type is expected without fooling around with conversions between + -- Ada string types. See Example 14 for useage. + -- This _replaces_ the procedure version. + -- THIS IS NOT IN THE C API. + -- Get the (current) output file name. -- plgfnam - procedure Get_Output_File_Name(Output_File_Name : out String) is - PL_Output_File_Name : char_array(0..79); - begin - plgfnam(PL_Output_File_Name); - Output_File_Name := To_Ada(PL_Output_File_Name, False); - end Get_Output_File_Name; - - - -- Function version of the procedure Get_Output_File_Name; not part of the PLplot API. - -- plgfnam function Get_Output_File_Name return String is Output_File_Name : char_array(0..79); begin plgfnam(Output_File_Name); - return To_Ada(Output_File_Name, True); + return To_Ada(Output_File_Name, False); end Get_Output_File_Name; @@ -1669,23 +1658,19 @@ end Get_Stream_Number; + -- Make a function version of Get_Version_Number so that the caller can use it whereever + -- a String type is expected without fooling around with conversions between + -- Ada string types. See Example 14 for useage. + -- This _replaces_ the procedure version. + -- THIS IS NOT IN THE C API. + -- Get the current library version number -- plgver - procedure Get_Version_Number(Version_Number : out String) is - PL_Version_Number : char_array(0..79); - begin - plgver(PL_Version_Number); - Version_Number := To_Ada(PL_Version_Number, False); - end Get_Version_Number; - - - -- Function version of the procedure Get_Version_Number; not part of the PLplot API. - -- plgver function Get_Version_Number return String is PL_Version_Number : char_array(0..79); begin plgver(PL_Version_Number); - return To_Ada(PL_Version_Number, True); + return To_Ada(PL_Version_Number, False); end Get_Version_Number; Modified: trunk/bindings/ada/plplot.ads.cmake =================================================================== --- trunk/bindings/ada/plplot.ads.cmake 2009-01-09 00:49:14 UTC (rev 9288) +++ trunk/bindings/ada/plplot.ads.cmake 2009-01-09 05:56:04 UTC (rev 9289) @@ -895,15 +895,14 @@ procedure Get_Compression_Level(Compression_Level : out Integer); - -- Get the current device (keyword) name - -- plgdev - procedure Get_Device_Name(Device_Name : out String); - - - -- Make a function version of plgdev so that the caller can use it whereever + -- Make a function version of Get_Device_Name so that the caller can use it whereever -- a String type is expected without fooling around with conversions between -- Ada string types. See Example 14 for useage. + -- This _replaces_ the procedure version. -- THIS IS NOT IN THE C API. + + -- Get the current device (keyword) name + -- plgdev function Get_Device_Name return String; @@ -948,13 +947,14 @@ Maximum_File_Size : out Integer); + -- Make a function version of Get_Output_File_Name so that the caller can use it whereever + -- a String type is expected without fooling around with conversions between + -- Ada string types. See Example 14 for useage. + -- This _replaces_ the procedure version. + -- THIS IS NOT IN THE C API. + -- Get the (current) output file name. -- plgfnam - procedure Get_Output_File_Name(Output_File_Name : out String); - - - -- Function version of the procedure Get_Output_File_Name; not part of the PLplot API. - -- plgver function Get_Output_File_Name return String; @@ -998,12 +998,14 @@ procedure Get_Stream_Number(Stream_Number : out Integer); + -- Make a function version of Get_Version_Number so that the caller can use it whereever + -- a String type is expected without fooling around with conversions between + -- Ada string types. See Example 14 for useage. + -- This _replaces_ the procedure version. + -- THIS IS NOT IN THE C API. + -- Get the current library version number -- plgver - procedure Get_Version_Number(Version_Number : out String); - - -- Function version of the procedure Get_Version_Number; not part of the PLplot API. - -- plgver function Get_Version_Number return String; -- Get viewport boundaries in normalized device coordinates Modified: trunk/bindings/ada/plplot_traditional.adb.cmake =================================================================== --- trunk/bindings/ada/plplot_traditional.adb.cmake 2009-01-09 00:49:14 UTC (rev 9288) +++ trunk/bindings/ada/plplot_traditional.adb.cmake 2009-01-09 05:56:04 UTC (rev 9289) @@ -1461,24 +1461,18 @@ end plgcompression; - -- Get the current device (keyword) name - procedure plgdev(Device_Name : out String) is - PL_Device_Name : char_array(0..79); - begin - PLplot_Thin.plgdev(PL_Device_Name); - Device_Name := To_Ada(PL_Device_Name, False); - end plgdev; - - -- Make a function version of plgdev so that the caller can use it whereever -- a String type is expected without fooling around with conversions between -- Ada string types. See Example 14 for useage. + -- This _replaces_ the procedure version. -- THIS IS NOT IN THE C API. + + -- Get the current device (keyword) name function plgdev return String is PL_Device_Name : char_array(0..79); begin PLplot_Thin.plgdev(PL_Device_Name); - return To_Ada(PL_Device_Name, True); + return To_Ada(PL_Device_Name, False); end plgdev; @@ -1543,21 +1537,18 @@ end plgfam; - -- Get the (current) output file name. - procedure plgfnam(Output_File_Name : out String) is - PL_Output_File_Name : char_array(0..79); - begin - PLplot_Thin.plgfnam(PL_Output_File_Name); - Output_File_Name := To_Ada(PL_Output_File_Name, False); - end plgfnam; + -- Make a function version of plgfnam so that the caller can use it whereever + -- a String type is expected without fooling around with conversions between + -- Ada string types. See Example 14 for useage. + -- This _replaces_ the procedure version. + -- THIS IS NOT IN THE C API. - - -- Function version of the procedure plgfnam; not part of the PLplot API. + -- Get the (current) output file name. function plgfnam return String is PL_Output_File_Name : char_array(0..79); begin PLplot_Thin.plgfnam(PL_Output_File_Name); - return To_Ada(PL_Output_File_Name, True); + return To_Ada(PL_Output_File_Name, False); end plgfnam; @@ -1617,21 +1608,18 @@ end plgstrm; - -- Get the current library version number - procedure plgver(Version_Number : out String) is - PL_Version_Number : char_array(0..79); - begin - PLplot_Thin.plgver(PL_Version_Number); - Version_Number := To_Ada(PL_Version_Number, False); - end plgver; + -- Make a function version of plgver so that the caller can use it whereever + -- a String type is expected without fooling around with conversions between + -- Ada string types. See Example 14 for useage. + -- This _replaces_ the procedure version. + -- THIS IS NOT IN THE C API. - - -- Function version of the procedure plgver; not part of the PLplot API. + -- Get the current library version number function plgver return String is PL_Version_Number : char_array(0..79); begin PLplot_Thin.plgver(PL_Version_Number); - return To_Ada(PL_Version_Number, True); + return To_Ada(PL_Version_Number, False); end plgver; Modified: trunk/bindings/ada/plplot_traditional.ads.cmake =================================================================== --- trunk/bindings/ada/plplot_traditional.ads.cmake 2009-01-09 00:49:14 UTC (rev 9288) +++ trunk/bindings/ada/plplot_traditional.ads.cmake 2009-01-09 05:56:04 UTC (rev 9289) @@ -856,14 +856,13 @@ procedure plgcompression(Compression_Level : out Integer); - -- Get the current device (keyword) name - procedure plgdev(Device_Name : out String); - - -- Make a function version of plgdev so that the caller can use it whereever -- a String type is expected without fooling around with conversions between -- Ada string types. See Example 14 for useage. + -- This _replaces_ the procedure version. -- THIS IS NOT IN THE C API. + + -- Get the current device (keyword) name function plgdev return String; @@ -902,11 +901,13 @@ Maximum_File_Size : out Integer); + -- Make a function version of plgfnam so that the caller can use it whereever + -- a String type is expected without fooling around with conversions between + -- Ada string types. See Example 14 for useage. + -- This _replaces_ the procedure version. + -- THIS IS NOT IN THE C API. + -- Get the (current) output file name. - procedure plgfnam(Output_File_Name : out String); - - - -- Function version of the procedure plgfnam; not part of the PLplot API. function plgfnam return String; -- Get the (current) run level. @@ -943,10 +944,13 @@ procedure plgstrm(Stream_Number : out Integer); + -- Make a function version of plgver so that the caller can use it whereever + -- a String type is expected without fooling around with conversions between + -- Ada string types. See Example 14 for useage. + -- This _replaces_ the procedure version. + -- THIS IS NOT IN THE C API. + -- Get the current library version number - procedure plgver(Version_Number : out String); - - -- Function version of the procedure plgver; not part of the PLplot API. function plgver return String; -- Get viewport boundaries in normalized device coordinates Modified: trunk/doc/docbook/src/ada.xml =================================================================== --- trunk/doc/docbook/src/ada.xml 2009-01-09 00:49:14 UTC (rev 9288) +++ trunk/doc/docbook/src/ada.xml 2009-01-09 05:56:04 UTC (rev 9289) @@ -278,7 +278,7 @@ </sect2> <sect2 id="ada_one_offs"> <title>One-offs</title> - <para> Convenient string handling for Get_Device_Name (<literal>plgdev</literal> in the traditional binding); a function version is provided that simplifies the string handling associated with this feature.</para> + <para> To provide convenient string handling in a fashion that is familiar to Ada programmers, function versions which return a <literal>String</literal> type are provided of <literal>Get_Device_Name</literal>, <literal>Get_Version_Number</literal>, and <literal>Get_Output_File_Name</literal> (<literal>plgdev</literal>, <literal>plgver</literal>, and <literal>plgfnam</literal> in the traditional binding). These functions replace the procedure-style subprograms that are described in the C API documentation.</para> <para> Overloaded <literal>Set_Line_Style</literal> (<literal>plstyl</literal> in the traditional binding) with a version that takes a single argument, <literal>Default_Continuous_Line</literal>. This replaces the awkward situation of calling the normal versions of these procedures with unused arguments simply to set the line style to the default, continuous, line.</para> <para> The contour plotter <literal>Contour_Plot_Irregular_Data</literal> (<literal>plfcont</literal> in the traditional binding) is provided for making contour plots from irregularly spaced data. This feature is not documented in the PLplot API documentation. </para> </sect2> Modified: trunk/examples/ada/x31a.adb.cmake =================================================================== --- trunk/examples/ada/x31a.adb.cmake 2009-01-09 00:49:14 UTC (rev 9288) +++ trunk/examples/ada/x31a.adb.cmake 2009-01-09 05:56:04 UTC (rev 9289) @@ -25,6 +25,7 @@ Ada.Long_Float_Text_IO, Ada.Strings, Ada.Strings.Fixed, + Ada.Strings.Unbounded, Ada.Numerics, Ada.Numerics.Long_Elementary_Functions, PLplot_Auxiliary, @@ -34,6 +35,7 @@ Ada.Long_Float_Text_IO, Ada.Strings, Ada.Strings.Fixed, + Ada.Strings.Unbounded, Ada.Numerics, Ada.Numerics.Long_Elementary_Functions, PLplot_Auxiliary, @@ -64,7 +66,7 @@ b1 : Integer_0_255_Array(0 .. 1) := (0, 0); a1 : Real_Vector(0 .. 1) := (1.0, 1.0); status : Integer; - fnam : String(1 .. 80); + fnam : Unbounded_String; -- Convert a boolean to integers 0 or 1. function Boolean_To_Integer(B : Boolean) return Integer is @@ -193,8 +195,8 @@ -- Retrieve and print the name of the output file (if any). -- This goes to stderr not stdout since it will vary between tests and -- we want stdout to be identical for compare test. - plgfnam(fnam); - if fnam(1) = Character'Val(0) then + fnam := To_Unbounded_String(plgfnam); + if fnam = Null_Unbounded_String then Put_Line("No output file name is set"); else Put_Line("Output file name read"); Modified: trunk/examples/ada/xthick31a.adb.cmake =================================================================== --- trunk/examples/ada/xthick31a.adb.cmake 2009-01-09 00:49:14 UTC (rev 9288) +++ trunk/examples/ada/xthick31a.adb.cmake 2009-01-09 05:56:04 UTC (rev 9289) @@ -25,6 +25,7 @@ Ada.Long_Float_Text_IO, Ada.Strings, Ada.Strings.Fixed, + Ada.Strings.Unbounded, Ada.Numerics, Ada.Numerics.Long_Elementary_Functions, PLplot_Auxiliary, @@ -34,6 +35,7 @@ Ada.Long_Float_Text_IO, Ada.Strings, Ada.Strings.Fixed, + Ada.Strings.Unbounded, Ada.Numerics, Ada.Numerics.Long_Elementary_Functions, PLplot_Auxiliary, @@ -64,7 +66,7 @@ b1 : Integer_0_255_Array(0 .. 1) := (0, 0); a1 : Real_Vector(0 .. 1) := (1.0, 1.0); status : Integer; - fnam : String(1 .. 80); + fnam : Unbounded_String; -- Convert a boolean to integers 0 or 1. function Boolean_To_Integer(B : Boolean) return Integer is @@ -193,8 +195,8 @@ -- Retrieve and print the name of the output file (if any). -- This goes to stderr not stdout since it will vary between tests and -- we want stdout to be identical for compare test. - Get_Output_File_Name(fnam); - if fnam(1) = Character'Val(0) then + fnam := To_Unbounded_String(Get_Output_File_Name); + if fnam = Null_Unbounded_String then Put_Line("No output file name is set"); else Put_Line("Output file name read"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |