From: Andrew R. <and...@us...> - 2008-08-15 07:18:03
|
Jerry, This latest change to the Ada bindings causes a build error for me with gnat 4.2.3 on Ubuntu. plplot.adb:2751:37: non-local pointer cannot point to local object The offending line is PL_Pen_Labels(Index) := Temp_C_String'Unchecked_Access; Cheers Andrew On Thu, Aug 14, 2008 at 10:15:34PM +0000, jb...@us... wrote: > Revision: 8657 > http://plplot.svn.sourceforge.net/plplot/?rev=8657&view=rev > Author: jbauck > Date: 2008-08-14 22:15:33 +0000 (Thu, 14 Aug 2008) > > Log Message: > ----------- > Adjusted Ada bindings for stripchart stuff, affecting x17a.adb and xthick17a.adb. Ada stripchart legend labels still duplicate the fourth one across all four. > > Modified Paths: > -------------- > trunk/bindings/ada/plplot.adb.cmake > trunk/bindings/ada/plplot.ads.cmake > trunk/bindings/ada/plplot_thin.ads.cmake > trunk/bindings/ada/plplot_traditional.adb.cmake > trunk/bindings/ada/plplot_traditional.ads.cmake > > Modified: trunk/bindings/ada/plplot.adb.cmake > =================================================================== > --- trunk/bindings/ada/plplot.adb.cmake 2008-08-14 22:06:23 UTC (rev 8656) > +++ trunk/bindings/ada/plplot.adb.cmake 2008-08-14 22:15:33 UTC (rev 8657) > @@ -1503,6 +1503,18 @@ > plgdev(PL_Device_Name); > Device_Name := To_Ada(PL_Device_Name, True); > end Get_Device_Name; > + > + > + -- 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 IS NOT IN THE C API. > + function Get_Device_Name return String is > + PL_Device_Name : char_array(0..79); > + begin > + PLplot_Thin.plgdev(PL_Device_Name); > + return To_Ada(PL_Device_Name, True); > + end Get_Device_Name; > > > -- Function version of the procedure Get_Device_Name; not part of the PLplot API. > @@ -2716,11 +2728,12 @@ > X_Label, Y_Label, Title_Label : String := To_String(Default_Label_String)) is > > PL_Autoscale_Y, PL_Accumulate : PLBOOL; > - PL_Pen_Labels : Stripchart_String_Array; > + PL_Pen_Labels : PL_Stripchart_String_Array; > > x_LP : Long_Float renames x_Legend_Position; > y_LP : Long_Float renames y_Legend_Position; > > + Temp_C_String : aliased PL_Stripchart_String; > begin > if Autoscale_Y then > PL_Autoscale_Y := PLtrue; > @@ -2734,12 +2747,23 @@ > PL_Accumulate := PLfalse; > end if; > > - -- Adapt strings for Pen_Labels to C. > - for Index in 1..4 loop > - PL_Pen_Labels(Index) := To_C(To_String(Pen_Labels(Index)), True); > + -- Adapt strings for Pen_Labels to C. Head truncates or pads as > + -- necessary to the length of Stripchart_String - 1; we then append > + -- a null terminator which I suppose C needs. This could have also been > + -- accomplished using char_array from the C interfaces. > + -- fix this NOTE that the current implementation displays all four > + -- legend labels the same, and equal to the fourth legend label. The > + -- goal is to match const char *legline[4] in plstripc.c and e.g. > + -- in x17c.c. > + for Index in Pen_Labels'range loop > + Temp_C_String := To_String(Head(Pen_Labels(Index), PL_Stripchart_String'length - 1) & Character'val(0)); > + PL_Pen_Labels(Index) := Temp_C_String'Unchecked_Access; > end loop; > > - plstripc(ID, To_C(X_Options), To_C(Y_Options), x_Min, x_Max, x_Jump, y_Min, y_Max, x_LP, y_LP, PL_Autoscale_Y, PL_Accumulate, Box_Color, Legend_Color, Pen_Colors, Line_Styles, PL_Pen_Labels, To_C(x_Label), To_C(y_Label), To_C(Title_Label)); > + plstripc(ID, To_C(X_Options), To_C(Y_Options), > + x_Min, x_Max, x_Jump, y_Min, y_Max, x_LP, y_LP, PL_Autoscale_Y, > + PL_Accumulate, Box_Color, Legend_Color, Pen_Colors, Line_Styles, > + PL_Pen_Labels, To_C(x_Label), To_C(y_Label), To_C(Title_Label)); > end Create_Stripchart; > > > > Modified: trunk/bindings/ada/plplot.ads.cmake > =================================================================== > --- trunk/bindings/ada/plplot.ads.cmake 2008-08-14 22:06:23 UTC (rev 8656) > +++ trunk/bindings/ada/plplot.ads.cmake 2008-08-14 22:15:33 UTC (rev 8657) > @@ -117,7 +117,8 @@ > Default_Label_String : constant Unbounded_String := To_Unbounded_String(""); > type Label_String_Array_Type is array (1..Max_Lines_For_Multiplot) of Unbounded_String; > Default_Label_String_Array : Label_String_Array_Type := (others => Default_Label_String); > - type Stripchart_Label_String_Array_Type is array (1..4) of Unbounded_String; > + Maximum_Number_Of_Stripcharts : Integer := 4; -- Limited by PLplot designers. > + type Stripchart_Label_String_Array_Type is array (1 .. Maximum_Number_Of_Stripcharts) of Unbounded_String; > > -- Justification for plots > subtype Justification_Type is Integer range -1..2; > @@ -880,6 +881,13 @@ > -- plgdev > function Get_Device_Name return 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 IS NOT IN THE C API. > + function Get_Device_Name return String; > + > + > -- Retrieve current window into device space > -- plgdidev > procedure Get_Device_Window_Parameters > > Modified: trunk/bindings/ada/plplot_thin.ads.cmake > =================================================================== > --- trunk/bindings/ada/plplot_thin.ads.cmake 2008-08-14 22:06:23 UTC (rev 8656) > +++ trunk/bindings/ada/plplot_thin.ads.cmake 2008-08-14 22:15:33 UTC (rev 8657) > @@ -83,7 +83,26 @@ > -- PLplot-specific things -- > -------------------------------------------------------------------------------- > > - type Stripchart_String_Array is array (1..4) of char_array(1..3); > + -- Make a string and array therefore for legends that is compatible with the > + -- C code of plstripc which creates a strip chart. The C code will accept > + -- any length of string and each of the four strings can be different lengths. > + -- These types are a bit of a hack whereby each of the legend strings is the > + -- same length, so that they can be accessed as an array. They are 41 > + -- characters long here including a null terminator; I suppose any length > + -- will work since the stripchart program doesn't seem to mind. The user > + -- will probably never see this type since he is allowed to set up the > + -- legend strings as an array of unbounded strings. Only in preparing to > + -- call the underlying C are the fixed-length strings used. If the user > + -- specifies unbounded legend strings that are longer than allowed here, > + -- they are truncated or padded with spaces, as appropriate, to meet the > + -- required length. Although that length is now 41, it is OK to make it > + -- longer or shorter simply by changing the following line, since everything > + -- else (padding, truncation, conversion to C-style) works automatically. > + -- See the fix this note in plplot.adb and plplot_traditional.adb about how > + -- all this somehow doesn't work correctly, causing all four stripchart > + -- legends to be the same and equal to the fourth one. > + subtype PL_Stripchart_String is String(1 .. 41); > + type PL_Stripchart_String_Array is array (1 .. 4) of access PL_Stripchart_String; > > > -- Access-to-procedure type for Draw_Vector_Plot and its kin. > @@ -1456,7 +1475,7 @@ > xlpos : PLFLT; ylpos : PLFLT; > y_ascl : PLBOOL; acc : PLBOOL; > colbox : PLINT; collab : PLINT; > - colline : PL_Integer_Array; styline : PL_Integer_Array; legline : Stripchart_String_Array; > + colline : PL_Integer_Array; styline : PL_Integer_Array; legline : PL_Stripchart_String_Array; > labx : char_array; laby : char_array; labtop : char_array); > pragma Import(C, plstripc, "c_plstripc"); > > > Modified: trunk/bindings/ada/plplot_traditional.adb.cmake > =================================================================== > --- trunk/bindings/ada/plplot_traditional.adb.cmake 2008-08-14 22:06:23 UTC (rev 8656) > +++ trunk/bindings/ada/plplot_traditional.adb.cmake 2008-08-14 22:15:33 UTC (rev 8657) > @@ -2585,13 +2585,14 @@ > Line_Styles : Integer_Array_1D; > Pen_Labels : Stripchart_Label_String_Array_Type; > X_Label, Y_Label, Title_Label : String := To_String(Default_Label_String)) is > - > + > PL_Autoscale_Y, PL_Accumulate : PLBOOL; > - PL_Pen_Labels : Stripchart_String_Array; > + PL_Pen_Labels : PL_Stripchart_String_Array; > > x_LP : Long_Float renames x_Legend_Position; > y_LP : Long_Float renames y_Legend_Position; > > + Temp_C_String : aliased PL_Stripchart_String; > begin > if Autoscale_Y then > PL_Autoscale_Y := PLtrue; > @@ -2605,15 +2606,23 @@ > PL_Accumulate := PLfalse; > end if; > > - -- Adapt strings for Pen_Labels to C. > - for Index in 1..4 loop > - PL_Pen_Labels(Index) := To_C(To_String(Pen_Labels(Index)), True); > + -- Adapt strings for Pen_Labels to C. Head truncates or pads as > + -- necessary to the length of Stripchart_String - 1; we then append > + -- a null terminator which I suppose C needs. This could have also been > + -- accomplished using char_array from the C interfaces. > + -- fix this NOTE that the current implementation displays all four > + -- legend labels the same, and equal to the fourth legend label. The > + -- goal is to match const char *legline[4] in plstripc.c and e.g. > + -- in x17c.c. > + for Index in Pen_Labels'range loop > + Temp_C_String := To_String(Head(Pen_Labels(Index), PL_Stripchart_String'length - 1) & Character'val(0)); > + PL_Pen_Labels(Index) := Temp_C_String'Unchecked_Access; > end loop; > - > + > PLplot_Thin.plstripc(ID, To_C(X_Options), To_C(Y_Options), > - x_Min, x_Max, x_Jump, y_Min, y_Max, x_LP, y_LP, PL_Autoscale_Y, > - PL_Accumulate, Box_Color, Legend_Color, Pen_Colors, Line_Styles, > - PL_Pen_Labels, To_C(x_Label), To_C(y_Label), To_C(Title_Label)); > + x_Min, x_Max, x_Jump, y_Min, y_Max, x_LP, y_LP, PL_Autoscale_Y, > + PL_Accumulate, Box_Color, Legend_Color, Pen_Colors, Line_Styles, > + PL_Pen_Labels, To_C(x_Label), To_C(y_Label), To_C(Title_Label)); > end plstripc; > > > > Modified: trunk/bindings/ada/plplot_traditional.ads.cmake > =================================================================== > --- trunk/bindings/ada/plplot_traditional.ads.cmake 2008-08-14 22:06:23 UTC (rev 8656) > +++ trunk/bindings/ada/plplot_traditional.ads.cmake 2008-08-14 22:15:33 UTC (rev 8657) > @@ -119,7 +119,8 @@ > Default_Label_String : constant Unbounded_String := To_Unbounded_String(""); > type Label_String_Array_Type is array (1..Max_Lines_For_Multiplot) of Unbounded_String; > Default_Label_String_Array : Label_String_Array_Type := (others => Default_Label_String); > - type Stripchart_Label_String_Array_Type is array (1..4) of Unbounded_String; > + Maximum_Number_Of_Stripcharts : Integer := 4; -- Limited by PLplot designers. > + type Stripchart_Label_String_Array_Type is array (1 .. Maximum_Number_Of_Stripcharts) of Unbounded_String; > > -- Justification for plots > subtype Justification_Type is Integer range -1..2; > @@ -842,6 +843,13 @@ > -- Function version of the procedure Get_Device_Name; not part of the PLplot API. > function plgdev return 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 IS NOT IN THE C API. > + function plgdev return String; > + > + > -- Retrieve current window into device space > procedure plgdidev > (Relative_Margin_Width : out Long_Float; > > > This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Plplot-cvs mailing list > Plp...@li... > https://lists.sourceforge.net/lists/listinfo/plplot-cvs > |
From: Alan W. I. <ir...@be...> - 2008-08-15 17:39:50
|
On 2008-08-15 08:18+0100 Andrew Ross wrote: > > Jerry, > > This latest change to the Ada bindings causes a build error for me with > gnat 4.2.3 on Ubuntu. > > plplot.adb:2751:37: non-local pointer cannot point to local object > The offending line is > PL_Pen_Labels(Index) := Temp_C_String'Unchecked_Access; This must depend on the version of gnat since I don't see this error for gnat 4.3.1-2 from Debian testing (and I presume Jerry didn't see it for his gnat-4.3 version as well). Perhaps we should just state explicitly that we only support gnat-4.3? Alan __________________________ Alan W. Irwin Astronomical research affiliation with Department of Physics and Astronomy, University of Victoria (astrowww.phys.uvic.ca). Programming affiliations with the FreeEOS equation-of-state implementation for stellar interiors (freeeos.sf.net); PLplot scientific plotting software package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project (lbproject.sf.net). __________________________ Linux-powered Science __________________________ |
From: Jerry <lan...@qw...> - 2008-08-15 20:10:26
|
On Aug 15, 2008, at 10:39 AM, Alan W. Irwin wrote: > On 2008-08-15 08:18+0100 Andrew Ross wrote: > >> >> Jerry, >> >> This latest change to the Ada bindings causes a build error for me >> with >> gnat 4.2.3 on Ubuntu. >> >> plplot.adb:2751:37: non-local pointer cannot point to local object >> The offending line is >> PL_Pen_Labels(Index) := Temp_C_String'Unchecked_Access; > > This must depend on the version of gnat since I don't see this > error for > gnat 4.3.1-2 from Debian testing (and I presume Jerry didn't see it > for his gnat-4.3 version as well). > > Perhaps we should just state explicitly that we only support gnat-4.3? > > Alan > Wow--that looks like a compiler error, as I understand it. In Ada, pointers are officially called access variables and the "regular" access variables are designed to never allow dumb pointer stuff such as danglers. However, the language does allow another access type, Unchecked_Access, so that you can shoot yourself in the foot if you so desire. (Actually, the unchecked version is sometimes apparently necessary, as I found in the above case.) If the offending line were PL_Pen_Labels(Index) := Temp_C_String'Access; then indeed the compiler would, should, and does issue "non-local pointer cannot point to local object." However, the sole purpose of using Unchecked_Access is to make this compile error go away (and assumes that you really know what you're doing with that pointer). I think I'll throw this at comp.lang.ada and see if anyone has anything to say about it. I'm not in favor of supporting only GNAT 4.3, since this is a relatively new version and I know that lots of people don't update their compilers if they're not broken--some still use gcc 3.14 or some such version. And if some version of the compiler is broken then maybe they should update it. Jerry |
From: Andrew R. <and...@us...> - 2008-08-16 05:43:12
|
On Fri, Aug 15, 2008 at 01:10:33PM -0700, Jerry wrote: > > On Aug 15, 2008, at 10:39 AM, Alan W. Irwin wrote: > > > On 2008-08-15 08:18+0100 Andrew Ross wrote: > > > >> > >> Jerry, > >> > >> This latest change to the Ada bindings causes a build error for me > >> with > >> gnat 4.2.3 on Ubuntu. > >> > >> plplot.adb:2751:37: non-local pointer cannot point to local object > >> The offending line is > >> PL_Pen_Labels(Index) := Temp_C_String'Unchecked_Access; > > > > This must depend on the version of gnat since I don't see this > > error for > > gnat 4.3.1-2 from Debian testing (and I presume Jerry didn't see it > > for his gnat-4.3 version as well). > > > > Perhaps we should just state explicitly that we only support gnat-4.3? > > > > Alan > > > Wow--that looks like a compiler error, as I understand it. In Ada, > pointers are officially called access variables and the "regular" > access variables are designed to never allow dumb pointer stuff such > as danglers. However, the language does allow another access type, > Unchecked_Access, so that you can shoot yourself in the foot if you > so desire. (Actually, the unchecked version is sometimes apparently > necessary, as I found in the above case.) If the offending line were > > PL_Pen_Labels(Index) := Temp_C_String'Access; > > then indeed the compiler would, should, and does issue "non-local > pointer cannot point to local object." However, the sole purpose of > using Unchecked_Access is to make this compile error go away (and > assumes that you really know what you're doing with that pointer). > > I think I'll throw this at comp.lang.ada and see if anyone has > anything to say about it. > > I'm not in favor of supporting only GNAT 4.3, since this is a > relatively new version and I know that lots of people don't update > their compilers if they're not broken--some still use gcc 3.14 or > some such version. And if some version of the compiler is broken then > maybe they should update it. Jerry, Let me know if you want any further information, or if you like me to try a simpler test case to try and pin this down. Andrew |
From: Jerry <lan...@qw...> - 2008-08-16 23:54:19
|
I've put this to the comp.lang.ada list and early comments tend towards a compiler error. (Apparently all of the GNAT releases are not subjected to the famous Ada validation suite.) There is also a note from one of the responders that "I've mentioned already that Ubuntu 8.04 has broken support for Ada. Better stick to Debian." Not sure what that earlier comment was about. In the meantime, I've changed the Ada bindings so that now the offending line uses 'Access instead of 'Unchecked_Access." In theory, this is preferable anyway. Andrew, let me know if this improves the situation. Jerry On Aug 15, 2008, at 12:18 AM, Andrew Ross wrote: > > Jerry, > > This latest change to the Ada bindings causes a build error for me > with > gnat 4.2.3 on Ubuntu. > > plplot.adb:2751:37: non-local pointer cannot point to local object > The offending line is > PL_Pen_Labels(Index) := Temp_C_String'Unchecked_Access; > > Cheers > > Andrew > |
From: Andrew R. <and...@us...> - 2008-08-17 18:00:49
|
Jerry, That is great. It has solved the build problems for me. Example 17 works fine except for the problem with the same label appearing 4 times that you have already reported. Andrew On Sat, Aug 16, 2008 at 04:54:26PM -0700, Jerry wrote: > I've put this to the comp.lang.ada list and early comments tend > towards a compiler error. (Apparently all of the GNAT releases are > not subjected to the famous Ada validation suite.) There is also a > note from one of the responders that "I've mentioned already that > Ubuntu 8.04 has broken support for Ada. Better stick to Debian." Not > sure what that earlier comment was about. > > In the meantime, I've changed the Ada bindings so that now the > offending line uses 'Access instead of 'Unchecked_Access." In theory, > this is preferable anyway. > > Andrew, let me know if this improves the situation. > > Jerry > > > On Aug 15, 2008, at 12:18 AM, Andrew Ross wrote: > > > > > Jerry, > > > > This latest change to the Ada bindings causes a build error for me > > with > > gnat 4.2.3 on Ubuntu. > > > > plplot.adb:2751:37: non-local pointer cannot point to local object > > The offending line is > > PL_Pen_Labels(Index) := Temp_C_String'Unchecked_Access; > > > > Cheers > > > > Andrew > > > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Plplot-devel mailing list > Plp...@li... > https://lists.sourceforge.net/lists/listinfo/plplot-devel > |
From: Jerry <lan...@qw...> - 2008-08-17 21:04:47
|
Andrew, Glad to hear it, and thanks for checking. Jerry On Aug 17, 2008, at 11:00 AM, Andrew Ross wrote: > > Jerry, > > That is great. It has solved the build problems for me. Example 17 > works > fine except for the problem with the same label appearing 4 times that > you have already reported. > > Andrew > > On Sat, Aug 16, 2008 at 04:54:26PM -0700, Jerry wrote: >> I've put this to the comp.lang.ada list and early comments tend >> towards a compiler error. (Apparently all of the GNAT releases are >> not subjected to the famous Ada validation suite.) There is also a >> note from one of the responders that "I've mentioned already that >> Ubuntu 8.04 has broken support for Ada. Better stick to Debian." Not >> sure what that earlier comment was about. >> >> In the meantime, I've changed the Ada bindings so that now the >> offending line uses 'Access instead of 'Unchecked_Access." In theory, >> this is preferable anyway. >> >> Andrew, let me know if this improves the situation. >> >> Jerry >> >> >> On Aug 15, 2008, at 12:18 AM, Andrew Ross wrote: >> >>> >>> Jerry, >>> >>> This latest change to the Ada bindings causes a build error for me >>> with >>> gnat 4.2.3 on Ubuntu. >>> >>> plplot.adb:2751:37: non-local pointer cannot point to local object >>> The offending line is >>> PL_Pen_Labels(Index) := Temp_C_String'Unchecked_Access; >>> >>> Cheers >>> >>> Andrew >>> >> >> >> --------------------------------------------------------------------- >> ---- >> This SF.Net email is sponsored by the Moblin Your Move Developer's >> challenge >> Build the coolest Linux based applications with Moblin SDK & win >> great prizes >> Grand prize is a trip for two to an Open Source event anywhere in >> the world >> http://moblin-contest.org/redirect.php?banner_id=100&url=/ >> _______________________________________________ >> Plplot-devel mailing list >> Plp...@li... >> https://lists.sourceforge.net/lists/listinfo/plplot-devel >> > |