<div dir="ltr"><div>Hi all,</div><div><br>Tanks for this work.</div><div><br></div><div>Bests,</div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><br>Régis Perdreau<br><br></div></div><br></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">Le lun. 16 juin 2025 à 13:21, Devansh Varshney <<a href="mailto:varshney.devansh614@gmail.com">varshney.devansh614@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi everyone,<br><br><div>T<span style="font-family:arial,sans-serif">h<span class="gmail_default">is</span></span> week has been one of the best learning<span class="gmail_default" style="font-family:comic sans ms,sans-serif"> </span>experiences for me,</div><div>especially digging into the "behind-the-scenes" of<span class="gmail_default" style="font-family:comic sans ms,sans-serif"></span><span class="gmail_default" style="font-family:arial,sans-serif"> </span><span style="font-family:arial,sans-serif">L</span>ibreOffice's UNO APIs.</div><br>My initial work (<a href="https://gerrit.libreoffice.org/c/core/+/185362" target="_blank">Gerrit 185362</a>) was a first step, but feedback from my<br>mentors in our meetings provided a crucial directive: first, figure out<br>how to get the data. Before we can build a great auto-completion system,<br>we need a deep, proven understanding of where all the information (for<br>BASIC, UNO, ScriptForge, etc.) lives and how to access it programmatically.<br><br>This led to a fascinating dive into the UNO data pipeline.<br><br><b><u><font size="4">Understanding the UNO Data Pipeline: From IDL to Runtime</font></u></b><br>For anyone curious about how UNO works under the hood, here's a breakdown of<br>what I've learned. It's a pipeline that turns human-readable API definitions<br>into an efficient system the application uses at runtime.<br><br>    <span class="gmail_default" style="font-family:comic sans ms,sans-serif"></span><b>IDL</b> <b>(Interface Definition Language):</b> This is the source of truth for all<br>   <b> </b>UNO APIs. These .idl text files define every service, interface, method,<br>    property, struct, and enum.<br>        <b>Locations: udkapi/</b> (core types) & <b>offapi/ </b>(office-specific types).<br><br>    <b>idlc & regmerge:</b> During the build, idlc (the IDL Compiler)<br>    compiles .idl files into intermediate binary .urd files. Then,<br>    regmerge combines these into .rdb (Registry Database) files.<br><br>    <b>.rdb Files:</b> These are the optimized binary databases that LibreOffice<br>    loads at startup. Key files include types.rdb (from udkapi.rdb etc.),<br>    services.rdb, and offapi.rdb. This is an installation artifact,<br>    not a source file, which clarified my initial search!<br><br>   <b> theCoreReflection:</b> At runtime, this powerful UNO service provides<br>    live, programmatic access to all the type information that was loaded<br>    from the .rdb files.<br><br>   <b> regview Tool:</b> A command-line tool (registry/tools/regview.cxx)<br>    designed to dump the contents of an .rdb file. My initial attempts<br>    to use this was unsuccessful, which, along with mentor guidance, led us to<br>    pivot our strategy.<br><br>    <b>SbUnoObject & XIntrospectionAccess:</b> The bridge in BASIC for<br>    interacting with live UNO objects, using dynamic introspection to<br>    discover their capabilities.<br><br><div><u>A simplified flow of this pipeline looks like this:</u></div><div><br></div><div><span style="font-family:arial,sans-serif"><b>.idl Files</b>    --(idlc)-->   <b>.urd Files</b>    --(regmerge)-->   <span class="gmail_default">   </span></span><b><span style="font-family:arial,sans-serif">.</span>rdb Files</b><br>(Source of Truth)         (Binary intermediate)           (Loaded by LO Runtime)<br><span class="gmail_default" style="font-family:comic sans ms,sans-serif"></span>                                                        <span style="font-family:arial,sans-serif">     <span class="gmail_default">                       </span><span class="gmail_default"></span><span class="gmail_default"> </span>  </span>  |<br> <span style="font-family:arial,sans-serif">                                                   <span class="gmail_default">                       </span>           <span class="gmail_default"> </span>  v<br>                                                <span class="gmail_default"> </span>   <span class="gmail_default">                    </span>  </span><LO Runtime Type System><br>                                        <span style="font-family:arial,sans-serif">          <span class="gmail_default">                 </span>  </span>(Accessible via theCoreReflection)<br>             <span style="font-family:arial,sans-serif">                                                 <span class="gmail_default">                       </span>   ^<br>                                                            <span class="gmail_default">                       </span>     | (R</span>eads .rdb)<br>                       <span style="font-family:arial,sans-serif">                                  <span class="gmail_default">                    </span>  <b>regview Tool</b><br>                                                            <span class="gmail_default">                      </span>     |<br>                                                          <span class="gmail_default">                      </span>       v<br>                                                     <span class="gmail_default">                 </span>     <Textual Du</span>mp></div><div><br></div><div><br></div><div><b><font size="4"><u>Understanding ScriptForge (wizards/source/scriptforge/)</u></font></b><br><br>I also looked into ScriptForge, which is crucial for modern BASIC scripting.<br><a href="https://gerrit.libreoffice.org/c/core/+/164867" target="_blank">https://gerrit.libreoffice.org/c/core/+/164867</a><br><span style="font-family:arial,sans-serif">   <span class="gmail_default">-</span> <b>.xlb files</b> are XML manifests listing the libraries.<br>   <span class="gmail_default">-</span> <b>.xba files </b>are ZIP-like packages containing the actual .bas source modules.<br>   <span class="gmail_default">-</span> <b>.pyi file</b> is a</span> Python stub that provides type hints to Python IDEs for<br>    auto-completion. As Rafael Lima mentioned, this might be manually created,<br>    making it a great model for the kind of rich API definition we want to<br>    achieve for BASIC.<br><br><u>How its information becomes available:</u></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif"><b>.bas files (inside .xba packages listed in .xlb)</b><br><span class="gmail_default"></span>  <span class="gmail_default"></span><span class="gmail_default">                 </span>  |<br>   <span class="gmail_default">                </span> v (Loaded by BasicManager/StarBASIC)<br><span class="gmail_default"></span><b><SbModule objects with source code></b><br>  <span class="gmail_default">                </span>  |<br>   <span class="gmail_default">               </span> v (Compiled by SbiParser)<b><br><SbMethod, SbxVariable symbols within the SbModule></b><br><br><span class="gmail_default">            </span><u>--- Parallel path for Python tooling ---</u><br><b>.pyi file (wizards/source/scriptforge/python/scriptforge.pyi)</b><br>    <span class="gmail_default">                    </span>|<br>   <span class="gmail_default">                   </span> v (Read by Python IDEs)<b><br><Type hints for Python auto-completion></b></span></div><div><br></div><div><br></div><div><b><u><font size="4">From Static File Parsing to C++ PoCs</font></u></b><br><br>Given the complexities of parsing static RDB/IDL files directly, and the<br>clear guidance from Meeting 3, our immediate focus has shifted. The new<br>priority is to write C++ Proof-of-Concept (PoC) code to programmatically<br>gather data and get this code onto Gerrit for review.<br><br>I'm very excited to share that the first two PoCs are complete<span class="gmail_default" style="font-family:comic sans ms,sans-serif"></span><span class="gmail_default" style="font-family:arial,sans-serif">.</span><br>Gerrit Patch:<a href="https://gerrit.libreoffice.org/c/core/+/186475" target="_blank"> https://gerrit.libreoffice.org/c/core/+/186475</a><br>This patch contains the CppUnit tests for these experiments.<br><br><b><u><font size="2">UNO Services and Memes<span class="gmail_default" style="font-family:arial,sans-serif"> </span><span class="gmail_default" style="font-family:arial,sans-serif">-</span><span style="font-family:arial,sans-serif"> </span>Why Context Comes First</font></u></b><br>So for example I’ve seen this happen a lot on social media. There’s a meme<br>going around, people are laughing, sharing it, reacting to it… and then there’s<br>always someone in the comments asking:<br>"What’s the context behind this?"<br><br>I mean, I’ve done it too. Sometimes you just miss the reference, maybe it’s<br>from a movie, or some political moment, or even a viral soundbite. Without the<br>context, it’s just a picture or a clip. You don’t get why it’s funny, why it<span class="gmail_default" style="font-family:arial,sans-serif"> </span><span style="font-family:arial,sans-serif">hi</span>ts.<br><br><u>And then someone replies and goes:</u><br>"Oh, this is from Interstellar, that scene where Cooper watches years of<br>messages after time dilation."<br><br>Now it starts to click. <i>That context sets the stage</i>.<br><br><u>Then maybe another reply adds:</u><br>"Yeah, and the reason it’s funny here is because someone compared it to<br>missing one lecture and coming back to find the whole syllabus changed."<br><br>So first you got the context, then someone gave the reference point, say, the<br>movie and then you dove into the details: the exact scene, the emotion, the<br>punchline. That’s what makes it all land.<br><br>And honestly, that’s how I see working with UNO services too.<br><br>In our PoC, we had to first get the component context otherwise we’re just<br>floating, not grounded in the current state of the app. Once we had that, we<br>could ask for something like com.sun.star.reflection.CoreReflection, and only<br>then could we start introspecting the real details, interfaces, methods,<br>enums, all the building blocks.<br><br><u>It’s kind of beautiful how that maps:</u><br><b>Context</b> → <b>“Where am I?”</b><br><b>Service</b> → <b>“What am I working with?”</b><br><b>Introspection</b> → <b>“What can this thing do?”</b><br><br>And just like in memes, without context, the rest doesn’t mean much.<br>Funny enough, this whole idea of “context” is even a thing in frameworks like<br>React or Java. So maybe context is more universal than we think<span class="gmail_default" style="font-family:comic sans ms,sans-serif"></span>.<br><font size="2"><br><b><u>Summary of C++ Proof-of-Concepts (PoCs)</u></b></font><br>Here's a breakdown of the PoCs I've implemented in the Gerrit patch:<br><br><b>PoC 1: Listing All Available UNO Service Names</b><br>    <b>Concept:</b> Queries the <i>XMultiComponentFactory</i> (Service Manager) to get<br>    all creatable UNO service names.<br>    <b>Source:</b> comphelper/processfactory.hxx (getProcessServiceManager()).<br><span style="font-family:arial,sans-serif"> <b>   Task:</b><br>      <span class="gmail_default">-</span>  Get XComponentContext.<br>      <span class="gmail_default">-</span>  Get XMultiComponentFactory.<br>      <span class="gmail_default">-</span>  Call getAvailableServiceNames().<br>      <span class="gmail_default">-</span>  Log each service name.</span><br>    <b>Result:</b> Successfully dumped service names.<br><br><b>PoC 2: Introspecting Specific UNO Definitions via theCoreReflection</b><br>    <b>Concept:</b> <i>theCoreReflection</i> provides access to the complete in-memory<br>    type information that LibreOffice loaded from its RDBs.<br>    <b>Source</b>: com.sun.star.reflection.theCoreReflection, XIdlClass, etc.<br>    (implementation in <a href="https://git.libreoffice.org/core/+/refs/heads/master/stoc" target="_blank">stoc/source/</a>).<br>    <b>Task:</b><br>   <span style="font-family:arial,sans-serif">     <span class="gmail_default">- </span>Get theCoreReflection instance.<br>        <span class="gmail_default">- </span>For a list of key type names (XModel, XSpreadsheet, PropertyValue, etc.):<br>        <span class="gmail_default">- </span>Call forName(sTypeName) to get its XIdlClass blueprint.<br>        <span class="gmail_default">- </span>Dump all details: superclasses, methods (with full parameter info),<br>        <span class="gmail_default">   </span>properties, struct fields, and enum members.<br>    <b>Result:</b> <span class="gmail_default"></span><span class="gmail_default">E</span>xtracted rich, detailed API definitions. This</span><br>    proves we can get the data needed for Parameter Info and accurate dot-completion.<br><br><a href="https://gerrit.libreoffice.org/c/core/+/186475/4/basic/uno_available_services_cpp_dump.txt" target="_blank">https://gerrit.libreoffice.org/c/core/+/186475/4/basic/uno_available_services_cpp_dump.txt</a><br><br><b><u>Next Steps: Diving into BASIC Internals</u></b><br><br>With the UNO data access path validated, the next focus is on BASIC itself.<br><br>    <b>PoC 3 (In Progress): The MsgBox Deep Dive</b><br>        My current task is to trace <b>MsgBox</b> from its user-facing documentation<br>        (both LO and MSO) down to its C++ implementation<br>        (<b>SbRtl_MsgBox in basic/source/runtime/methods.cxx</b>). This will help<br>        us understand how to handle built-in functions and their often-implicit<br>        parameter signatures.<br><br>    <b>Future PoC: Parser Symbol Extraction</b><br>        After MsgBox, the plan is to write a C++ PoC that interacts with the<br>        SbiParser to extract its internal symbol tables (SbiSymPool) for<br>        user-defined code.<br><br>A mentor's comment, <b>"We have a cppumaker, etc., and why not a basicmaker?"</b>,<br>really resonated with me. It highlights that our ultimate goal is to create<br>a powerful "analyzer" for BASIC that provides the same level of rich,<br>structured information for our IDE tools as other "makers" do for their<br>respective languages.<span class="gmail_default" style="font-family:arial,sans-serif"> And yes I have to speed up stuff.</span><br><br>Thanks for following this<span class="gmail_default" style="font-family:comic sans ms,sans-serif">.</span></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><span style="font-family:monospace"><b>Regards,</b></span></div><div><span style="font-family:monospace;color:rgb(153,0,255)"><b>Devansh</b></span><br></div></div></div></div>
</blockquote></div>