netmaker: Fix generating a service constructor with a rest argument
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 <stephan.bergmann@collabora.com>
This commit is contained in:
committed by
Stephan Bergmann
parent
87a485f5ee
commit
112e72dea2
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user