From 112e72dea2e4286bb289ff14e9d0aecb5aa31d2e Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Wed, 11 Feb 2026 10:56:37 +0100 Subject: [PATCH] netmaker: Fix generating a service constructor with a rest argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a rest argument is used in an IDL, it was previously just generating a single Any argument for the constructor and then trying to pass that directly to createInstanceWithArgumentsAndContext. That doesn’t compile because that method requires an array of Anys for the arguments parameter. Instead this patch makes it generate “params Any[] rest” which seems to be the .NET way to do variadic arguments. I don’t think there are any LibreOffice services using constructors with rest parameters and presumably no one is using it outside of LO with .NET because it wouldn’t compile, so hopefully this patch has little risk. Fixing it enables us to use rest parameters in a future unit test for pyuno. Change-Id: I7dbf96f945011db546374ae1d6cf904a5bd262ce Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199135 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- codemaker/source/netmaker/netproduce.cxx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/codemaker/source/netmaker/netproduce.cxx b/codemaker/source/netmaker/netproduce.cxx index 3eb68c22a7fe..0fe92b1abfa0 100644 --- a/codemaker/source/netmaker/netproduce.cxx +++ b/codemaker/source/netmaker/netproduce.cxx @@ -1020,11 +1020,14 @@ void NetProducer::produceService( .append("(com.sun.star.uno.XComponentContext ctx"); if (!ctor.parameters.empty()) file.append(", "); - separatedForeach( - ctor.parameters, [&file]() { file.append(", "); }, - [this, &file](const auto& p) { - file.append(getNetName(p.type)).append(" ").append(getSafeIdentifier(p.name)); - }); + separatedForeach(ctor.parameters, [&file]() { file.append(", "); }, + [this, &file, restParam](const auto& p) { + if (&p == restParam) + file.append("params ").append(getNetName(p.type)).append("[]"); + else + file.append(getNetName(p.type)); + file.append(" ").append(getSafeIdentifier(p.name)); + }); file.append(")").endLine().beginBlock(); file.beginLine()