Embind in-out/out params of primitive type apparently need a wrapper
> let translit = css.i18n.Transliteration.create(Module.getUnoComponentContext()); > let match1; > let match2; > let eq = translit.equals(new Module.OUString("test1"), 0, 5, match1, new Module.OUString("test2"), 0, 5, match2); > console.log('match ' + eq + ', ' + match1 + ', ' + match2); caused an uncaught UnboundTypeError with message "Cannot call uno_Type_com$sun$star$i18n$XTransliteration.equals due to unbound types: Pl", so use > let translit = css.i18n.Transliteration.create(Module.getUnoComponentContext()); > let match1 = new Module.UnoInOutParamLong; > let match2 = new Module.UnoInOutParamLong; > let eq = translit.equals(new Module.OUString("test1"), 0, 5, match1, new Module.OUString("test2"), 0, 5, match2); > console.log('match ' + eq + ', ' + match1.val + ', ' + match2.val); > delete match1; > delete match2; instead Change-Id: Ic5a0a9e37e884817158069702510eab0d29adefa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162784 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
This commit is contained in:
@@ -32,6 +32,22 @@ enum class uno_Reference
|
|||||||
{
|
{
|
||||||
FromAny
|
FromAny
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T> struct UnoInOutParam
|
||||||
|
{
|
||||||
|
UnoInOutParam() {}
|
||||||
|
|
||||||
|
UnoInOutParam(T the_value)
|
||||||
|
: value(the_value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
T get() const { return value; }
|
||||||
|
|
||||||
|
void set(T the_value) { value = the_value; }
|
||||||
|
|
||||||
|
T value;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||||
|
@@ -444,9 +444,49 @@ void dumpParameters(std::ostream& out, rtl::Reference<TypeManager> const& manage
|
|||||||
{
|
{
|
||||||
out << ", ";
|
out << ", ";
|
||||||
}
|
}
|
||||||
|
bool wrap = false;
|
||||||
|
if (param.direction != unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_IN)
|
||||||
|
{
|
||||||
|
switch (manager->getSort(resolveOuterTypedefs(manager, param.type)))
|
||||||
|
{
|
||||||
|
case codemaker::UnoType::Sort::Boolean:
|
||||||
|
case codemaker::UnoType::Sort::Byte:
|
||||||
|
case codemaker::UnoType::Sort::Short:
|
||||||
|
case codemaker::UnoType::Sort::UnsignedShort:
|
||||||
|
case codemaker::UnoType::Sort::Long:
|
||||||
|
case codemaker::UnoType::Sort::UnsignedLong:
|
||||||
|
case codemaker::UnoType::Sort::Hyper:
|
||||||
|
case codemaker::UnoType::Sort::UnsignedHyper:
|
||||||
|
case codemaker::UnoType::Sort::Float:
|
||||||
|
case codemaker::UnoType::Sort::Double:
|
||||||
|
case codemaker::UnoType::Sort::Char:
|
||||||
|
case codemaker::UnoType::Sort::Enum:
|
||||||
|
wrap = true;
|
||||||
|
break;
|
||||||
|
case codemaker::UnoType::Sort::String:
|
||||||
|
case codemaker::UnoType::Sort::Type:
|
||||||
|
case codemaker::UnoType::Sort::Any:
|
||||||
|
case codemaker::UnoType::Sort::Sequence:
|
||||||
|
case codemaker::UnoType::Sort::PlainStruct:
|
||||||
|
case codemaker::UnoType::Sort::InstantiatedPolymorphicStruct:
|
||||||
|
case codemaker::UnoType::Sort::Interface:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw CannotDumpException("unexpected entity \"" + param.type
|
||||||
|
+ "\" as parameter type");
|
||||||
|
}
|
||||||
|
}
|
||||||
if (declarations)
|
if (declarations)
|
||||||
{
|
{
|
||||||
|
if (wrap)
|
||||||
|
{
|
||||||
|
out << "::unoembindhelpers::UnoInOutParam<";
|
||||||
|
}
|
||||||
dumpType(out, manager, param.type);
|
dumpType(out, manager, param.type);
|
||||||
|
if (wrap)
|
||||||
|
{
|
||||||
|
out << ">";
|
||||||
|
}
|
||||||
if (param.direction == unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_IN)
|
if (param.direction == unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_IN)
|
||||||
{
|
{
|
||||||
if (passByReference(manager, param.type))
|
if (passByReference(manager, param.type))
|
||||||
@@ -460,11 +500,16 @@ void dumpParameters(std::ostream& out, rtl::Reference<TypeManager> const& manage
|
|||||||
}
|
}
|
||||||
out << " ";
|
out << " ";
|
||||||
}
|
}
|
||||||
else if (param.direction != unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_IN)
|
else if (param.direction != unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_IN
|
||||||
|
&& !wrap)
|
||||||
{
|
{
|
||||||
out << "*";
|
out << "*";
|
||||||
}
|
}
|
||||||
out << param.name;
|
out << param.name;
|
||||||
|
if (!declarations && wrap)
|
||||||
|
{
|
||||||
|
out << "->value";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -111,6 +111,62 @@ EMSCRIPTEN_BINDINGS(PrimaryBindings)
|
|||||||
},
|
},
|
||||||
allow_raw_pointers());
|
allow_raw_pointers());
|
||||||
|
|
||||||
|
class_<unoembindhelpers::UnoInOutParam<bool>>("UnoInOutParamBoolean")
|
||||||
|
.constructor()
|
||||||
|
.constructor<bool>()
|
||||||
|
.property("val", &unoembindhelpers::UnoInOutParam<bool>::get,
|
||||||
|
&unoembindhelpers::UnoInOutParam<bool>::set);
|
||||||
|
class_<unoembindhelpers::UnoInOutParam<sal_Int8>>("UnoInOutParamByte")
|
||||||
|
.constructor()
|
||||||
|
.constructor<sal_Int8>()
|
||||||
|
.property("val", &unoembindhelpers::UnoInOutParam<sal_Int8>::get,
|
||||||
|
&unoembindhelpers::UnoInOutParam<sal_Int8>::set);
|
||||||
|
class_<unoembindhelpers::UnoInOutParam<sal_Int16>>("UnoInOutParamShort")
|
||||||
|
.constructor()
|
||||||
|
.constructor<sal_Int16>()
|
||||||
|
.property("val", &unoembindhelpers::UnoInOutParam<sal_Int16>::get,
|
||||||
|
&unoembindhelpers::UnoInOutParam<sal_Int16>::set);
|
||||||
|
class_<unoembindhelpers::UnoInOutParam<sal_uInt16>>("UnoInOutParamUnsignedShort")
|
||||||
|
.constructor()
|
||||||
|
.constructor<sal_uInt16>()
|
||||||
|
.property("val", &unoembindhelpers::UnoInOutParam<sal_uInt16>::get,
|
||||||
|
&unoembindhelpers::UnoInOutParam<sal_uInt16>::set);
|
||||||
|
class_<unoembindhelpers::UnoInOutParam<sal_Int32>>("UnoInOutParamLong")
|
||||||
|
.constructor()
|
||||||
|
.constructor<sal_Int32>()
|
||||||
|
.property("val", &unoembindhelpers::UnoInOutParam<sal_Int32>::get,
|
||||||
|
&unoembindhelpers::UnoInOutParam<sal_Int32>::set);
|
||||||
|
class_<unoembindhelpers::UnoInOutParam<sal_uInt32>>("UnoInOutParamUnsignedLong")
|
||||||
|
.constructor()
|
||||||
|
.constructor<sal_uInt32>()
|
||||||
|
.property("val", &unoembindhelpers::UnoInOutParam<sal_uInt32>::get,
|
||||||
|
&unoembindhelpers::UnoInOutParam<sal_uInt32>::set);
|
||||||
|
class_<unoembindhelpers::UnoInOutParam<sal_Int64>>("UnoInOutParamHyper")
|
||||||
|
.constructor()
|
||||||
|
.constructor<sal_Int64>()
|
||||||
|
.property("val", &unoembindhelpers::UnoInOutParam<sal_Int64>::get,
|
||||||
|
&unoembindhelpers::UnoInOutParam<sal_Int64>::set);
|
||||||
|
class_<unoembindhelpers::UnoInOutParam<sal_uInt64>>("UnoInOutParamUnsignedHyper")
|
||||||
|
.constructor()
|
||||||
|
.constructor<sal_uInt64>()
|
||||||
|
.property("val", &unoembindhelpers::UnoInOutParam<sal_uInt64>::get,
|
||||||
|
&unoembindhelpers::UnoInOutParam<sal_uInt64>::set);
|
||||||
|
class_<unoembindhelpers::UnoInOutParam<float>>("UnoInOutParamFloat")
|
||||||
|
.constructor()
|
||||||
|
.constructor<float>()
|
||||||
|
.property("val", &unoembindhelpers::UnoInOutParam<float>::get,
|
||||||
|
&unoembindhelpers::UnoInOutParam<float>::set);
|
||||||
|
class_<unoembindhelpers::UnoInOutParam<double>>("UnoInOutParamDouble")
|
||||||
|
.constructor()
|
||||||
|
.constructor<double>()
|
||||||
|
.property("val", &unoembindhelpers::UnoInOutParam<double>::get,
|
||||||
|
&unoembindhelpers::UnoInOutParam<double>::set);
|
||||||
|
class_<unoembindhelpers::UnoInOutParam<char16_t>>("UnoInOutParamChar")
|
||||||
|
.constructor()
|
||||||
|
.constructor<char16_t>()
|
||||||
|
.property("val", &unoembindhelpers::UnoInOutParam<char16_t>::get,
|
||||||
|
&unoembindhelpers::UnoInOutParam<char16_t>::set);
|
||||||
|
|
||||||
function("getCurrentModelFromViewSh", &getCurrentModelFromViewSh);
|
function("getCurrentModelFromViewSh", &getCurrentModelFromViewSh);
|
||||||
function("getUnoComponentContext", &comphelper::getProcessComponentContext);
|
function("getUnoComponentContext", &comphelper::getProcessComponentContext);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user