<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi Pocho,</p>
<p>What follows is Felipe Zak's private answer (thanks Felipe!).</p>
<p>----</p>
<p><span data-teams="true">Hi (<span
class="___87nhvx0 fau6ura f3052tw lpcCommonWeb-hoverTarget cw-container-103"
aria-label="Mentioned Javier"><span dir="auto"
class="fui-StyledText ___rj1mvc0 fyind8e f1k6fduh fdvs7vj fx5ovu0"
itemtype="http://schema.skype.com/Mention">Javier</span></span> <span
class="___87nhvx0 fau6ura f3052tw lpcCommonWeb-hoverTarget cw-container-103"
aria-label="Mentioned Pimas"><span dir="auto"
class="fui-StyledText ___rj1mvc0 fyind8e f1k6fduh fdvs7vj fx5ovu0"
itemtype="http://schema.skype.com/Mention">Pimas</span></span>),
UnionExample.st is an example with a union in Cuis.</span></p>
<p><span data-teams="true">An example of a union structure in object
memory:</span></p>
<p><span data-teams="true">
<p>UnionExample new.</p>
<p>(the single handle -aByteArray- changes depending on what is
set)</p>
</span><br>
</p>
<p><span data-teams="true"><img
src="cid:part1.2e8F55B1.3RMXNj0n@cuis.st"
moz-do-not-send="false" width="200" height="248"></span></p>
<p><span data-teams="true">An </span><span data-teams="true">example
in external heap:</span></p>
<p><span data-teams="true">UnionExample externalNew.</span></p>
<p><span data-teams="true"><img
src="cid:part2.Abfsea4e.jVRz8fd9@cuis.st"
moz-do-not-send="false" width="250" height="250"></span></p>
<p><span data-teams="true"><br>
</span></p>
<p><span data-teams="true">Then, used that union in another stucture
(StructureExampleWithUnion.st):</span></p>
<p><span data-teams="true"><img
src="cid:part3.5WJLiSyI.dzVaxu7z@cuis.st"
moz-do-not-send="false" width="306" height="293"></span></p>
<p><span data-teams="true">Hope this helps!</span></p>
<p><span data-teams="true"><br>
</span></p>
<div class="moz-cite-prefix">On 2025-12-15 2:46 PM, Javier Pimás via
Cuis-dev wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAAYkY5TRFEYfCamyWSsBodQLmD1=uNotMuZoZWxNVK4iVxd0Pg@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">Hi folks,
<div><br>
</div>
<div>I'm trying to define a wrapper (in cuis) of the following C
struct:</div>
<div><br>
</div>
<div><font face="monospace">typedef struct InteropData {<br>
uint64_t dataType;<br>
union {<br>
double quad;</font></div>
<div><font face="monospace"> int32_t int32;<br>
uint32_t uint32;<br>
int64_t int64;<br>
uint64_t uint64;<br>
char16_t *wstr;<br>
void *ptr;<br>
};<br>
} InteropData; // size 24</font></div>
<div><br>
</div>
<div>for now I made an ExternalStructure subclass with the
following method:</div>
<div><br>
</div>
<div>InteropData class >> #fields<br>
"<br>
self defineFields<br>
"<br>
^#(<br>
(dataType 'uint64')</div>
<div> (payload 'uint64')<br>
)</div>
<div><br>
</div>
<div>As you can see, the payload is a bag of cats, and I wonder
if there's a way to specify the union fields so that they get
generated automatically.</div>
<div><br>
</div>
<div>Cheers,</div>
<div>Javier </div>
<div><br>
</div>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
</blockquote>
<pre class="moz-signature" cols="72">--
Juan Vuletich
<a class="moz-txt-link-abbreviated" href="http://www.cuis.st">www.cuis.st</a>
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich</pre>
</body>
</html>