<div dir="ltr"><br><br><div class="gmail_quote">On Thu, May 5, 2011 at 17:05, Ludo Brands <span dir="ltr"><<a href="mailto:ludo.brands@free.fr">ludo.brands@free.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><span><font size="2" color="#0000ff" face="Arial"></font></span>
<div></div>
<div><font face="Arial"><font color="#0000ff"><font size="2">O<span>K </span><span>. You have
avoided using macros but are loosing the access to "pseudo" members
su_len,su_family,su_port and su_scope_id. The DOCUMENTATION_ONLY suggests that
these members are documented parts of the interface. Also it will be up to the
user to figure out where to get su_len according to
SU_HAVE_SOCKADDR_SA_LEN.</span></font></font></font></div></div></blockquote><div><br>I can not find them in the preprocessor code (the define and the "document only" members), that's why I avoided them at this point. but if I'll find them required, I'll invest more time to add them.<br>
</div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div>
<div><font face="Arial"><font color="#0000ff"><font size="2"><span></span></font></font></font><font face="Arial"><font color="#0000ff"><font size="2"><span></span></font></font></font><font face="Arial"><font color="#0000ff"><font size="2"><span></span></font></font></font> </div>
<div><font face="Arial"><font color="#0000ff"><font size="2"><span></span></font></font></font> </div>
<div><font face="Tahoma"><font size="2"><div class="im"><font face="Arial"><font color="#0000ff"><span> </span></font></font>-----Message
d'origine-----<br><b>De :</b> <a href="mailto:fpc-pascal-bounces@lists.freepascal.org" target="_blank">fpc-pascal-bounces@lists.freepascal.org</a>
[mailto:<a href="mailto:fpc-pascal-bounces@lists.freepascal.org" target="_blank">fpc-pascal-bounces@lists.freepascal.org</a>] <b>De la part de</b>
ik<br></div><b>Envoyé :</b> jeudi 5 mai 2011 15:19<div class="im"><br><b>À :</b> FPC-Pascal
users discussions<br></div><b>Objet :</b> Re: RE : RE : RE : [fpc-pascal] How to
translate this union ?<br><br></font></font></div><div><div></div><div class="h5">
<blockquote dir="ltr" style="margin-right:0px">
<div dir="ltr"><br>I've done the following at the moment:<br><br>{$IFDEF
SU_HAVE_SOCKADDR_SA_LEN}<br>//
#define
su_len su_sa.sa_len
<- unsupported for now<br>{$ELSE}<br>//
#define
su_len su_array[0] <-
unsupported for now<br>{$ENDIF}<br>//
#define
su_family su_sa.sa_family <-
unsupported for now<br>//
#define
su_port su_sin.sin_port <-
unsupported for now<br>//
#define
su_scope_id su_array32[6] <- unsupported for
now <br><br>su_sockaddr_u =
record<br>
case Byte
of<br>
0 : (su_dummy :
cshort);
//< Dummy member to
initialize<br>
1 : (su_array : array[0..31] of char); //
Presented as
chars<br>
2 : (su_array16 : array[0..15] of cuint16); // Presented as 16-bit
ints<br>
3 : (su_array32 : array[0..8] of cuint32); // Presented as 32-bit
ints<br>
4 : (su_sa :
sockaddr);
// Address in struct sockaddr
format<br>
5 : (su_sin :
sockaddr_in);
// Address in IPv4 format<br>{$IFDEF
SU_HAVE_IN6}<br>
6 : (su_sin6 :
sockaddr_in6);
// Address in IPv6
format<br>{$ENDIF}<br>
end;<br><br><br>As I understood by you and C developers that I talked to, the
macro create a shortcut to be used.<br><br>Thanks,<br><br>Ido<br><br>
<div class="gmail_quote">On Sat, Apr 30, 2011 at 11:53, Ludo Brands <span dir="ltr"><<a href="mailto:ludo.brands@free.fr" target="_blank">ludo.brands@free.fr</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="padding-left:1ex;margin:0px 0px 0px 0.8ex;border-left:#ccc 1px solid">
<div>
<div><font size="2" color="#0000ff" face="Arial"><span>Using macros, the
translation looks like</span></font></div>
<div><font size="2" color="#0000ff" face="Arial"></font> </div>
<div><font face="Arial"><font color="#0000ff"><font size="2">{$MACRO
ON}<br>{$ifndef DOCUMENTATION_ONLY}<br>{$if SU_HAVE_SOCKADDR_SA_LEN
<>0}<br> {$define su_len:=su_sa.sa_len}<br>{$else}<br>
{$define su_len:=su_array[0]}<br>{$endif}<br>{$define
su_family:=su_sa.sa_family}<br>{$define
su_port:=su_sin.sin_port}<br>{$define
su_scope_id:=su_array32[6]}<br>{$endif}<br><span>type</span></font></font></font></div>
<div><font face="Arial"><font color="#0000ff"><font size="2"><span> su_sockaddr_u =
record<br> case longint
of<br> {$ifdef
DOCUMENTATION_ONLY}<br>
0 : ( su_len : byte
);<br> 1 : ( su_family
: byte );<br> 2 : (
su_port : word );<br>
{$else}<br> 3 : (
su_dummy : smallint
);<br>
{$endif}<br> 4 : (
su_array : array[0..31] of char
);<br> 5 : (
su_array16 : array[0..15] of word
);<br> 6 : (
su_array32 : array[0..7] of longword
);<br> 7 : ( su_sa :
sockaddr );<br> 8 : (
su_sin : sockaddr_in
);<br> {$if
SU_HAVE_IN6
<>0}<br> 9 : (
su_sin6 : sockaddr_in6
);<br>
{$endif}<br> {$ifdef
DOCUMENTATION_ONLY}<br>
10 : ( su_scope_id : longword
);<br>
{$endif}<br>
end;<br></span></font></font></font></div>
<blockquote dir="ltr" style="margin-right:0px">
<div></div>
<div dir="ltr" lang="fr" align="left"><font size="2" face="Tahoma">
<div>-----Message d'origine-----<br><b>De :</b> <a href="mailto:fpc-pascal-bounces@lists.freepascal.org" target="_blank">fpc-pascal-bounces@lists.freepascal.org</a> [mailto:<a href="mailto:fpc-pascal-bounces@lists.freepascal.org" target="_blank">fpc-pascal-bounces@lists.freepascal.org</a>] <b>De la part
de</b> Ludo Brands<br></div><b>Envoyé :</b> samedi 30 avril 2011
10:29
<div><br><b>À :</b> 'FPC-Pascal users
discussions'<br></div><b>Objet :</b> RE : RE : [fpc-pascal] How to
translate this union ?<br><br></font></div>
<div>
<div></div>
<div>
<div><span><font size="2" color="#0000ff" face="Arial">Forget my previous reply.
I found the original header file on sourceforge. </font></span></div>
<div><span><font size="2" color="#0000ff" face="Arial"></font></span> </div>
<div><span><font size="2" color="#0000ff" face="Arial">I have alse a better
understanding now of what the code is supposed to do: in case
DOCUMENTATION_ONLY is not defined, a reference to, for example,
su_sockaddr_u.su_family will be subsstituted by
su_sockaddr_u.susa.sa_family. </font></span></div>
<div><span><font size="2" color="#0000ff" face="Arial">You could use macros and
do a {$define su_family:=susa.sa_family} with the following
limitations:</font></span></div>
<div><span><font size="2" color="#0000ff" face="Arial">- if you have variables
or other record members named su_family, not part of the su_sockaddr_u
record, they will be renamed also. </font></span></div>
<div><span><font size="2" color="#0000ff" face="Arial">- it works only for the
units that include your .inc file.</font></span></div>
<div><span></span> </div>
<blockquote dir="ltr" style="margin-right:0px">
<div></div>
<div dir="ltr" lang="fr" align="left"><font size="2" face="Tahoma">-----Message
d'origine-----<br><b>De :</b> <a href="mailto:fpc-pascal-bounces@lists.freepascal.org" target="_blank">fpc-pascal-bounces@lists.freepascal.org</a> [mailto:<a href="mailto:fpc-pascal-bounces@lists.freepascal.org" target="_blank">fpc-pascal-bounces@lists.freepascal.org</a>] <b>De la part
de</b> Ludo Brands<br><b>Envoyé :</b> samedi 30 avril 2011
09:18<br><b>À :</b> 'FPC-Pascal users
discussions'<br><b>Objet :</b> RE : [fpc-pascal] How to translate
this union ?<br><br></font></div>
<div><span><font size="2" color="#0000ff" face="Arial">Can you post the
original c code? You point to a file that seems to be a reworked output
from h2pas. As it is now, it indeed doesn't make any sense. I would
think the su_len,su_family,su_port should make up a record but they
aren't.</font></span></div>
<div><span><font size="2" color="#0000ff" face="Arial"></font></span> </div>
<div><span><font size="2" color="#0000ff" face="Arial">I suggest you move the
#defines inside the union declaration to somewhere before the union
declaration. It'll double up the ifdef's but make the code so much more
readable.</font></span></div>
<div><span><font size="2" color="#0000ff" face="Arial"></font></span> </div>
<div><span><font size="2" color="#0000ff" face="Arial"></font></span> </div>
<div></div>
<div><font size="2" face="Tahoma">-----Message
d'origine-----<br><b>De :</b> <a href="mailto:fpc-pascal-bounces@lists.freepascal.org" target="_blank">fpc-pascal-bounces@lists.freepascal.org</a> [mailto:<a href="mailto:fpc-pascal-bounces@lists.freepascal.org" target="_blank">fpc-pascal-bounces@lists.freepascal.org</a>] <b>De la part
de</b> ik<br><b>Envoyé :</b> vendredi 29 avril 2011
22:15<br><b>À :</b> FPC-Pascal users
discussions<br><b>Objet :</b> [fpc-pascal] How to translate this
union ?<br><br></font></div>
<blockquote dir="ltr" style="margin-right:0px">
<div dir="ltr">Hello list,<br><br>I'm trying to translate the <a href="https://github.com/ik5/sofia-sip/blob/master/src/lib/sui.inc#L199" target="_blank">following union</a> to Pascal, but I do not understand
it, and so does h2pas.<br>How to translate it
?<br><br>Thanks,<br><br>Ido<br><br><br clear="all">
<div dir="ltr">LINESIP - Opening the source for communication<br><a href="http://www.linesip.com" target="_blank">http://www.linesip.com</a><br><a href="http://www.linesip.co.il" target="_blank">http://www.linesip.co.il</a><br>
<br></div><br></div></blockquote></blockquote></div></div></blockquote></div><br>_______________________________________________<br>fpc-pascal
maillist - <a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank">fpc-pascal@lists.freepascal.org</a><br><a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a><br>
</blockquote></div><br></div></blockquote></div></div></div>
<br>_______________________________________________<br>
fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a><br>
<a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a><br></blockquote></div><br></div>