<div dir="ltr"><p><strong>Hi all,</strong></p>
<p>Here’s a quick update outlining the progress from <strong>Week 9</strong> of the Rust–UNO binding project.</p>
<p>Last week, I worked on handling <strong>edge cases</strong> in the generated code. I’ll also summarize what we have been doing over the past weeks regarding the generated code:</p>
<ul>
<li>
<p>When calling <strong>C++ logic via FFI</strong>, we found that we must wrap it in <strong>C functions or C-compatible types</strong> (e.g., structs, enums).</p>
</li>
<li>
<p>To address this, we relied on <strong><code>XInterface</code></strong> (the base interface for all UNO interfaces). We pass it as a parameter, cast it to the required interface, and then call the target method.</p>
</li>
<li>
<p>Since Rust <strong>traits</strong> cannot be directly used across FFI boundaries, we always evaluate whether something can safely cross FFI before implementing it.</p>
</li>
<li>
<p>For other <strong>core UNO types</strong>, we used their <strong>internal pointers</strong> to pass values between Rust and C. We then cast those pointers to the corresponding C++ types (e.g., <code>rtl_uString</code> and <code>OUString</code>).</p>
</li>
<li>
<p>As Rust does not support <strong>inheritance for structs</strong>, we handled this by using <strong>composition</strong> in the parent struct instead.</p>
</li>
</ul>
<p>Here’s an example of what we discussed:<br>```<br>/// FFI bridge for ooo.vba.excel.XRange::Address<br>rtl_uString* Address_(<br> XInterface* pInterface,<br> uno_Any* RowAbsolute,<br> uno_Any* ColumnAbsolute,<br> uno_Any* ReferenceStyle,<br> uno_Any* External,<br> uno_Any* RelativeTo<br>)<br>{<br> if (!pInterface)<br> return nullptr;<br><br> try<br> {<br> Reference<ooo::vba::excel::XRange> xInterface(pInterface, UNO_QUERY_THROW);<br><br> auto result = xInterface->Address(<br> *reinterpret_cast<Any*>(RowAbsolute),<br> *reinterpret_cast<Any*>(ColumnAbsolute),<br> *reinterpret_cast<Any*>(ReferenceStyle),<br> *reinterpret_cast<Any*>(External),<br> *reinterpret_cast<Any*>(RelativeTo)<br> );<br><br> // Convert OUString result to rtl_uString*<br> return result.pData;<br> }<br> catch (const Exception& e)<br> {<br> SAL_WARN("codemaker.rustmaker", "Exception in FFI bridge function");<br> (void)e;<br> return nullptr;<br> }<br>}<br>```<br></p><p><strong>Next steps:</strong></p><p>
</p><ul>
<li>
<p>Continue handling <strong>edge cases</strong> in the generated code.</p>
</li>
<li>
<p>Expand support for <strong>core UNO types</strong>.<br></p>
</li>
</ul><div>Best,<br>Ali</div><div><br></div></div>