gforth
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Bernd Paysan
Subject: Re: Precisions on the forth SWIG architecture: return by value structs
Date: Tue, 13 Jun 2023 02:17:43 +0200

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/

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]