Handle missing default values in JS UNO structs
Signed-off-by: Stephan Bergmann <stephan.bergmann@collabora.com> Change-Id: I63b589645a8c1efc95b6fb023931c45b1d08b65e Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/7624 Reviewed-by: Michael Stahl <michael.stahl@collabora.com> Tested-by: Jenkins CPCI <releng@collaboraoffice.com> (cherry picked from commit 0e55d63d948f177f3b3dabf459000b576e169815) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208737 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
committed by
Xisco Fauli
parent
427f2f79e9
commit
11d6547889
+20
-6
@@ -2131,15 +2131,29 @@ css::uno::Any fromJs(JSContext* ctx, css::uno::Type const& type, JSValueConst va
|
|||||||
}
|
}
|
||||||
if (has == 0)
|
if (has == 0)
|
||||||
{
|
{
|
||||||
JS_ThrowTypeError(ctx, "TODO: BAD UNO STRUCT VALUE");
|
if (compDesc->ppTypeRefs[i]->eTypeClass == typelib_TypeClass_ANY)
|
||||||
throw JsException();
|
{
|
||||||
|
mems.emplace_back();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
css::uno::TypeDescription memDesc(compDesc->ppTypeRefs[i]);
|
||||||
|
memDesc.makeComplete();
|
||||||
|
std::vector<char> buf(memDesc.get()->nSize, 0);
|
||||||
|
uno_constructData(buf.data(), memDesc.get());
|
||||||
|
mems.emplace_back(buf.data(), css::uno::Type(compDesc->ppTypeRefs[i]));
|
||||||
|
uno_destructData(buf.data(), memDesc.get(), css::uno::cpp_release);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ValueRef mem(ctx, JS_GetProperty(ctx, val, a));
|
else
|
||||||
if (JS_IsException(mem))
|
|
||||||
{
|
{
|
||||||
throw JsException();
|
ValueRef mem(ctx, JS_GetProperty(ctx, val, a));
|
||||||
|
if (JS_IsException(mem))
|
||||||
|
{
|
||||||
|
throw JsException();
|
||||||
|
}
|
||||||
|
mems.push_back(fromJs(ctx, compDesc->ppTypeRefs[i], mem));
|
||||||
}
|
}
|
||||||
mems.push_back(fromJs(ctx, compDesc->ppTypeRefs[i], mem));
|
|
||||||
}
|
}
|
||||||
compDesc = compDesc->pBaseTypeDescription;
|
compDesc = compDesc->pBaseTypeDescription;
|
||||||
if (compDesc == nullptr)
|
if (compDesc == nullptr)
|
||||||
|
|||||||
Reference in New Issue
Block a user