Re: Precisions on the forth SWIG architecture: return by value structs

Bernd Paysan <[email protected]> Tue, 13 Jun 2023 02:17:43 +0200
Newsgroups gmane.comp.lang.forth.gforth
Message-ID <2800835.AiC22s8V5E@liubei>
Am Dienstag, 13. Juni 2023, 01:32:08 CEST schrieb Bernd Paysan:
> Am Dienstag, 13. Juni 2023, 00:17:14 CEST schrieb Bernd Paysan:
> > Structs as arguments are already dealt with by a{*(type*)} (the argument-
> > generating code would be then identical for a, but with struct as name).
> 
> The Swig module from Gerald does handle this part already fine, i.e. it
> converts structs as parameters into the a{*(type*)} sequence.
> 
> > There, the cast includes the pointer-accessing *, it's just structs as
> > return are not yet supported by libcc.fs.
> 
> And the Swig module just emits a "… -- struct" in that case, though without
> the necessary typecast information (which is not yet supported by libcc.fs,
> either).

I suggest this change here, then the type information is available and I can 
deal with it from libcc.fs.

diff --git a/Source/Modules/forth.cxx b/Source/Modules/forth.cxx
index 70787393e..4e4298000 100644
--- a/Source/Modules/forth.cxx
+++ b/Source/Modules/forth.cxx
@@ -1186,7 +1186,8 @@ String *FORTH::typeLookup( Node *node, const char 
*prefix, String *typeTemplate,
                if( structTemplate == NULL || Len( structTemplate ) == 0 )
                {
                        Swig_warning( WARN_FORTH_NONTEMPLATE_STRUCT, 
input_file, line_number, "No template passed for struct \"%s\", using 
\"struct\"\n", cTypeName);
-                       typeName = NewString( "struct" );
+                       typeName = NewString( "struct{*(%{c-name}*)}" );
+                       Replace( typeName, "%{c-name}", cTypeName, 
DOH_REPLACE_ANY );
                }
                else
                {

-- 
Bernd Paysan
"If you want it done right, you have to do it yourself"
net2o id: kQusJzA;7*?t=uy@X}1GWr!+0qqp_Cn176t4(dQ*
https://net2o.de/
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEERJ1NDqPQRwYnwBjr9y2Uk5MtoGcFAmSHtacACgkQ9y2Uk5Mt
oGeX0RAAgcrSzPOUByqoVHRe70/I3qJ9XdtMUA17SQNYFwMDm538JHkq5iJdcFzN
nP3MEnjNu+cBZSCckm0XZP1Y0B/ZIut6T5cTjx0GzQvHJxEcR9WCKSeoUiMEbLVH
KAQMcllumJ3NLO7Kj6s0VE5uzHu3NtNJ5t+8zXfN6css2SBIveqhNDC/ztSWcKWV
nyiIxieNI7Dn/CsuJ+a8mOoRlqgBydxcNZQpjvOA0gg+c4oQz25m3Ot8951UKTYd
4cVg0D0tHABQLS9h06CVj43E6DdvjtDasu63y4YA7nNLHIz46AzdjGk2tXVjIga3
4eKcxWZZAKUGkOn4mLOqkDSluk/IHH9G0+yNR2nnT0KldwfdSHG1qk9gtot2//Qj
CABtRK50G4LQQ5C3L6fPP2uUNwNLzlltSuLC/A8aEU2196pe7/PPd6CvgGCKXk2p
AsbkD1P8l4nsWHRkXylcwqeOoSyPLbL7O3H+u9V3/uO3Qe+o7kvbJe+rNzYuhkht
TGt2dkWQWRoh3eSrsRzTn1t+PEbcPlAr3jnOgpeOUGjz+aXsfU4JKUwpfvwiT8is
YWXLi1Gg/yaVvv1EYZNVE6//cJZbfNw8SvHiVE+aBX4sH/pgygJ7r1JpkgENo4TO
rOZc8F05QqxOWBZeU5utIvNCtnNCores+QGFDKHtkeMCfYE6rxA=
=un7p
-----END PGP SIGNATURE-----