summaryrefslogtreecommitdiff
path: root/unodevtools
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-04-16 13:48:49 +0200
committerStephan Bergmann <sbergman@redhat.com>2013-04-16 13:52:29 +0200
commit30a7c6ba6b95ade8e59f9e28108470165dc9a175 (patch)
treef62070e3ab38f92df50d36a48c59751553c71444 /unodevtools
parent24aeeb016323821b7eba6ab78a4dcf5e7ebb157a (diff)
WIP: Experimental new binary type.rdb format
Make uno-skeletonmaker work on top of unoidl/ instead of registry/. These changes have only been tested so far rather lightly. Basic uno-skeletonmaker still works, but more thorough testing of the various input flags is needed. Change-Id: Id7f3aee863a10f8c649325db2d6f34a4057f70ff
Diffstat (limited to 'unodevtools')
-rw-r--r--unodevtools/source/skeletonmaker/cppcompskeleton.cxx119
-rw-r--r--unodevtools/source/skeletonmaker/cpptypemaker.cxx945
-rw-r--r--unodevtools/source/skeletonmaker/javacompskeleton.cxx87
-rw-r--r--unodevtools/source/skeletonmaker/javatypemaker.cxx930
-rw-r--r--unodevtools/source/skeletonmaker/skeletoncommon.cxx614
-rw-r--r--unodevtools/source/skeletonmaker/skeletoncommon.hxx58
-rw-r--r--unodevtools/source/skeletonmaker/skeletoncpp.hxx76
-rw-r--r--unodevtools/source/skeletonmaker/skeletonjava.hxx63
-rw-r--r--unodevtools/source/skeletonmaker/skeletonmaker.cxx25
9 files changed, 1447 insertions, 1470 deletions
diff --git a/unodevtools/source/skeletonmaker/cppcompskeleton.cxx b/unodevtools/source/skeletonmaker/cppcompskeleton.cxx
index bfea9a03ced7..41ef20394654 100644
--- a/unodevtools/source/skeletonmaker/cppcompskeleton.cxx
+++ b/unodevtools/source/skeletonmaker/cppcompskeleton.cxx
@@ -30,8 +30,8 @@ using namespace ::codemaker::cpp;
namespace skeletonmaker { namespace cpp {
void generateIncludes(std::ostream & o,
- const boost::unordered_set< OString, OStringHash >& interfaces,
- OString propertyhelper, bool serviceobject,
+ const std::set< OUString >& interfaces,
+ OUString propertyhelper, bool serviceobject,
bool supportxcomponent)
{
o << "#include \"sal/config.h\"\n";
@@ -55,7 +55,7 @@ void generateIncludes(std::ostream & o,
o << "#include \"cppuhelper/propertysetmixin.hxx\"\n";
}
- boost::unordered_set< OString, OStringHash >::const_iterator iter = interfaces.begin();
+ std::set< OUString >::const_iterator iter = interfaces.begin();
while (iter != interfaces.end())
{
o << "#include \""
@@ -138,7 +138,7 @@ OString generateCompHelperDeclaration(std::ostream & o,
void generateCompHelperDefinition(std::ostream & o,
const OString & implname,
const OString & classname,
- const boost::unordered_set< OString, OStringHash >& services)
+ const std::set< OUString >& services)
{
OString nm;
short nbrackets = generateNamespace(o, implname, true, nm);
@@ -151,12 +151,12 @@ void generateCompHelperDefinition(std::ostream & o,
"_getSupportedServiceNames()\n{\n css::uno::Sequence< "
<< "::rtl::OUString >" << " s(" << services.size() << ");\n";
- boost::unordered_set< OString, OStringHash >::const_iterator iter = services.begin();
+ std::set< OUString >::const_iterator iter = services.begin();
short i=0;
while (iter != services.end())
{
o << " s[" << i++ << "] = ::rtl::OUString(\""
- << (*iter).replace('/','.') << "\");\n";
+ << *iter << "\");\n";
++iter;
}
o << " return s;\n}\n\n";
@@ -500,7 +500,7 @@ void generateXDispatchProvider(std::ostream& o,
void generateAddinConstructorAndHelper(std::ostream& o,
ProgramOptions const & options,
rtl::Reference< TypeManager > const & manager, const OString & classname,
- const boost::unordered_set< OString, OStringHash >& interfaces)
+ const std::set< OUString >& interfaces)
{
o << classname << "::" << classname
<< "(css::uno::Reference< css::uno::XComponentContext > const & context) :\n"
@@ -582,18 +582,13 @@ void generateMemberInitialization(std::ostream& o,
for (AttributeInfo::const_iterator i(members.begin());
i != members.end(); ++i)
{
- RTTypeClass typeClass;
- OString type(i->second.first.replace('.','/'));
- OString name;
sal_Int32 rank;
- std::vector< OString > arguments;
- codemaker::UnoType::Sort sort = codemaker::decomposeAndResolve(
- manager, type, true, true, true, &typeClass, &name, &rank,
- &arguments);
-
- if (sort <= codemaker::UnoType::SORT_CHAR && rank == 0) {
- o << ",\n m_" << i->first << "(";
- printType(o, options, manager, type, 16, true);
+ if ((manager->decompose(i->type, true, 0, &rank, 0, 0)
+ <= codemaker::UnoType::SORT_CHAR)
+ && rank == 0)
+ {
+ o << ",\n m_" << i->name << "(";
+ printType(o, options, manager, i->type, 16, true);
o << ")";
}
}
@@ -609,9 +604,8 @@ void generateMemberDeclaration(std::ostream& o,
i != members.end(); ++i)
{
o << " ";
- printType(o, options, manager, i->second.first.replace('.','/'),
- 1, false);
- o << " m_" << i->first << ";\n";
+ printType(o, options, manager, i->type, 1, false);
+ o << " m_" << i->name << ";\n";
}
}
@@ -619,11 +613,11 @@ OString generateClassDefinition(std::ostream& o,
ProgramOptions const & options,
rtl::Reference< TypeManager > const & manager,
OString const & classname,
- boost::unordered_set< OString, OStringHash > const & interfaces,
+ std::set< OUString > const & interfaces,
AttributeInfo const & properties,
AttributeInfo const & attributes,
- boost::unordered_set< OString, OStringHash > const & propinterfaces,
- OString const & propertyhelper, bool supportxcomponent)
+ std::set< OUString > const & propinterfaces,
+ OUString const & propertyhelper, bool supportxcomponent)
{
OStringBuffer parentname(64);
o << "class " << classname << ":\n";
@@ -641,11 +635,10 @@ OString generateClassDefinition(std::ostream& o,
o << " public ::cppu::WeakImplHelper" << interfaces.size() << "<";
}
- boost::unordered_set< OString, OStringHash >::const_iterator iter =
- interfaces.begin();
+ std::set< OUString >::const_iterator iter = interfaces.begin();
while (iter != interfaces.end())
{
- o << "\n " << scopedCppName(*iter);
+ o << "\n " << scopedCppName(u2b(*iter));
++iter;
if (iter != interfaces.end())
o << ",";
@@ -656,7 +649,7 @@ OString generateClassDefinition(std::ostream& o,
if (propertyhelper.getLength() > 1) {
o << ",\n public ::cppu::PropertySetMixin< "
- << scopedCppName(propertyhelper) << " >";
+ << scopedCppName(u2b(propertyhelper)) << " >";
}
o << "\n{\npublic:\n"
@@ -682,11 +675,10 @@ OString generateClassDefinition(std::ostream& o,
OStringBuffer buffer(256);
buffer.append(parentname.toString());
buffer.append("< ");
- boost::unordered_set< OString, OStringHash >::const_iterator iter =
- interfaces.begin();
+ std::set< OUString >::const_iterator iter = interfaces.begin();
while (iter != interfaces.end())
{
- buffer.append(scopedCppName(*iter));
+ buffer.append(scopedCppName(u2b(*iter)));
++iter;
if (iter != interfaces.end())
buffer.append(", ");
@@ -700,13 +692,11 @@ OString generateClassDefinition(std::ostream& o,
<< parent << "::release(); }\n\n";
}
- boost::unordered_set< OString, OStringHash >::const_iterator it =
- interfaces.begin();
+ std::set< OUString >::const_iterator it = interfaces.begin();
codemaker::GeneratedTypeSet generated;
while (it != interfaces.end())
{
- typereg::Reader reader(manager->getTypeReader((*it).replace('.','/')));
- printMethods(o, options, manager, reader, generated, "", "", " ",
+ printMethods(o, options, manager, *it, generated, "", "", " ",
true, propertyhelper);
++it;
}
@@ -794,10 +784,9 @@ OString generateClassDefinition(std::ostream& o,
<< "(css::uno::Reference< css::uno::XComponentContext > const & context) :\n";
if (supportxcomponent) {
o << " ::cppu::WeakComponentImplHelper" << interfaces.size() << "<";
- boost::unordered_set< OString, OStringHash >::const_iterator iter =
- interfaces.begin();
+ std::set< OUString >::const_iterator iter = interfaces.begin();
while (iter != interfaces.end()) {
- o << "\n " << scopedCppName(*iter);
+ o << "\n " << scopedCppName(u2b(*iter));
++iter;
if (iter != interfaces.end())
o << ",";
@@ -807,7 +796,7 @@ OString generateClassDefinition(std::ostream& o,
}
if (propertyhelper.getLength() > 1) {
o << " ::cppu::PropertySetMixin< "
- << scopedCppName(propertyhelper) << " >(\n"
+ << scopedCppName(u2b(propertyhelper)) << " >(\n"
<< " context, static_cast< Implements >(\n ";
OStringBuffer buffer(128);
if (propinterfaces.find("com/sun/star/beans/XPropertySet")
@@ -881,22 +870,20 @@ void generateXServiceInfoBodies(std::ostream& o,
void generateMethodBodies(std::ostream& o,
ProgramOptions const & options,
rtl::Reference< TypeManager > const & manager,
- boost::unordered_set< OString, OStringHash > const & interfaces,
+ std::set< OUString > const & interfaces,
OString const & classname,
OString const & comphelpernamespace,
- OString const & propertyhelper)
+ OUString const & propertyhelper)
{
OString name(classname.concat("::"));
- boost::unordered_set< OString, OStringHash >::const_iterator iter =
- interfaces.begin();
+ std::set< OUString >::const_iterator iter = interfaces.begin();
codemaker::GeneratedTypeSet generated;
while (iter != interfaces.end()) {
if ( (*iter).equals("com.sun.star.lang.XServiceInfo") ) {
generateXServiceInfoBodies(o, name, comphelpernamespace);
- generated.add(*iter);
+ generated.add(u2b(*iter));
} else {
- typereg::Reader reader(manager->getTypeReader((*iter).replace('.','/')));
- printMethods(o, options, manager, reader, generated, "_",
+ printMethods(o, options, manager, *iter, generated, "_",
name, "", true, propertyhelper);
}
++iter;
@@ -906,10 +893,10 @@ void generateMethodBodies(std::ostream& o,
void generateQueryInterface(std::ostream& o,
ProgramOptions const & options,
rtl::Reference< TypeManager > const & manager,
- const boost::unordered_set< OString, OStringHash >& interfaces,
+ const std::set< OUString >& interfaces,
OString const & parentname,
OString const & classname,
- OString const & propertyhelper)
+ OUString const & propertyhelper)
{
if (propertyhelper.isEmpty())
return;
@@ -924,11 +911,10 @@ void generateQueryInterface(std::ostream& o,
o << "css::uno::Any a(";
o << parentname << "<";
- boost::unordered_set< OString, OStringHash >::const_iterator iter =
- interfaces.begin();
+ std::set< OUString >::const_iterator iter = interfaces.begin();
while (iter != interfaces.end())
{
- o << "\n " << scopedCppName(*iter);
+ o << "\n " << scopedCppName(u2b(*iter));
++iter;
if (iter != interfaces.end())
o << ",";
@@ -945,8 +931,7 @@ void generateQueryInterface(std::ostream& o,
o << "::cppu::OPropertySetHelper::queryInterface(type));\n";
} else {
o << "::cppu::PropertySetMixin<\n ";
- printType(o, options, manager, propertyhelper.replace('.', '/'),
- 0, false);
+ printType(o, options, manager, propertyhelper, 0, false);
o << " >::queryInterface(\n type));\n";
}
}
@@ -963,17 +948,17 @@ void generateSkeleton(ProgramOptions const & options,
return;
}
- boost::unordered_set< OString, OStringHash > interfaces;
- boost::unordered_set< OString, OStringHash > services;
+ std::set< OUString > interfaces;
+ std::set< OUString > services;
AttributeInfo properties;
AttributeInfo attributes;
- boost::unordered_set< OString, OStringHash > propinterfaces;
+ std::set< OUString > propinterfaces;
bool serviceobject = false;
bool supportxcomponent = false;
std::vector< OString >::const_iterator iter = types.begin();
while (iter != types.end()) {
- checkType(manager, *iter, interfaces, services, properties);
+ checkType(manager, b2u(*iter), interfaces, services, properties);
++iter;
}
@@ -992,7 +977,7 @@ void generateSkeleton(ProgramOptions const & options,
if (!services.empty())
serviceobject = true;
- OString propertyhelper = checkPropertyHelper(
+ OUString propertyhelper = checkPropertyHelper(
options, manager, services, interfaces, attributes, propinterfaces);
checkDefaultInterfaces(interfaces, services, propertyhelper);
@@ -1095,22 +1080,22 @@ void generateCalcAddin(ProgramOptions const & options,
rtl::Reference< TypeManager > const & manager,
std::vector< OString > const & types)
{
- boost::unordered_set< OString, OStringHash > interfaces;
- boost::unordered_set< OString, OStringHash > services;
+ std::set< OUString > interfaces;
+ std::set< OUString > services;
AttributeInfo properties;
AttributeInfo attributes;
- boost::unordered_set< OString, OStringHash > propinterfaces;
+ std::set< OUString > propinterfaces;
bool serviceobject = false;
bool supportxcomponent = false;
std::vector< OString >::const_iterator iter = types.begin();
while (iter != types.end()) {
- checkType(manager, *iter, interfaces, services, properties);
+ checkType(manager, b2u(*iter), interfaces, services, properties);
++iter;
}
- OString sAddinService;
+ OUString sAddinService;
if (services.size() != 1) {
throw CannotDumpException(
"for calc add-in components one and only one service type is necessary!"
@@ -1119,10 +1104,10 @@ void generateCalcAddin(ProgramOptions const & options,
// get the one and only add-in service for later use
- boost::unordered_set< OString, OStringHash >::const_iterator iter2 = services.begin();
- sAddinService = (*iter2).replace('/', '.');
+ std::set< OUString >::const_iterator iter2 = services.begin();
+ sAddinService = *iter2;
if (sAddinService.equals("com.sun.star.sheet.AddIn")) {
- sAddinService = (*(++iter2)).replace('/', '.');
+ sAddinService = *(++iter2);
}
// if backwardcompatible==true the AddIn service needs to be added to the
@@ -1142,7 +1127,7 @@ void generateCalcAddin(ProgramOptions const & options,
}
}
- OString propertyhelper = checkPropertyHelper(
+ OUString propertyhelper = checkPropertyHelper(
options, manager, services, interfaces, attributes, propinterfaces);
if (!propertyhelper.isEmpty())
diff --git a/unodevtools/source/skeletonmaker/cpptypemaker.cxx b/unodevtools/source/skeletonmaker/cpptypemaker.cxx
index 5d2c3fde7c8b..946181566b46 100644
--- a/unodevtools/source/skeletonmaker/cpptypemaker.cxx
+++ b/unodevtools/source/skeletonmaker/cpptypemaker.cxx
@@ -27,16 +27,16 @@ using namespace ::codemaker::cpp;
namespace skeletonmaker { namespace cpp {
-void printType(std::ostream & o,
- ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- codemaker::UnoType::Sort sort, RTTypeClass typeClass,
- OString const & name, sal_Int32 rank,
- std::vector< OString > const & arguments, short referenceType,
+void printType(
+ std::ostream & o, ProgramOptions const & options,
+ rtl::Reference< TypeManager > const & manager,
+ codemaker::UnoType::Sort sort, OUString const & nucleus, sal_Int32 rank,
+ std::vector< OUString > const & arguments,
+ rtl::Reference< unoidl::Entity > const & entity, short referenceType,
bool defaultvalue)
{
if (defaultvalue && rank == 0 && sort <= codemaker::UnoType::SORT_CHAR) {
- switch (sort)
- {
+ switch (sort) {
case codemaker::UnoType::SORT_BOOLEAN:
o << "sal_False";
return;
@@ -52,28 +52,23 @@ void printType(std::ostream & o,
case codemaker::UnoType::SORT_DOUBLE:
o << "0";
return;
- case codemaker::UnoType::SORT_VOID:
- case codemaker::UnoType::SORT_STRING:
- case codemaker::UnoType::SORT_TYPE:
- case codemaker::UnoType::SORT_ANY:
- case codemaker::UnoType::SORT_COMPLEX: default: //TODO
+ default:
break;
}
}
if (defaultvalue && referenceType == 16) {
- if (typeClass == RT_TYPE_ENUM) {
- typereg::Reader reader(manager->getTypeReader(name));
- o << name.copy(name.lastIndexOf('/'))
- << "_"
- << codemaker::convertString(reader.getFieldName(0));
+ if (sort == codemaker::UnoType::SORT_ENUM_TYPE) {
+ o << nucleus.copy(nucleus.lastIndexOf('.') + 1) << "_"
+ << dynamic_cast< unoidl::EnumTypeEntity * >(entity.get())->
+ getMembers()[0].name;
}
return;
}
bool bReference = false;
if (((sort > codemaker::UnoType::SORT_CHAR ||
rank > 0) && referenceType != 8 &&
- !(typeClass == RT_TYPE_ENUM && referenceType == 4 && rank == 0)) ||
+ !(sort == codemaker::UnoType::SORT_ENUM_TYPE && referenceType == 4 && rank == 0)) ||
(sort <= codemaker::UnoType::SORT_CHAR && referenceType == 2))
{
bReference = true;
@@ -86,21 +81,20 @@ void printType(std::ostream & o,
o << ((options.shortnames) ? "css::uno::Sequence< " :
"::com::sun::star::uno::Sequence< ");
}
- if (typeClass == RT_TYPE_INTERFACE && referenceType > 0) {
+ if (sort == codemaker::UnoType::SORT_INTERFACE_TYPE && referenceType > 0) {
o << ((options.shortnames) ? "css::uno::Reference< " :
"::com::sun::star::uno::Reference< ");
}
- o << scopedCppName(codemaker::cpp::translateUnoToCppType(
- sort, typeClass, name, false),
+ o << scopedCppName(codemaker::cpp::translateUnoToCppType(sort, nucleus),
options.shortnames && referenceType > 0);
- if (typeClass == RT_TYPE_INTERFACE && referenceType > 0)
+ if (sort == codemaker::UnoType::SORT_INTERFACE_TYPE && referenceType > 0)
o << " >";
if (!arguments.empty()) {
o << "< ";
- for (std::vector< OString >::const_iterator i(arguments.begin());
+ for (std::vector< OUString >::const_iterator i(arguments.begin());
i != arguments.end(); ++i)
{
if (i != arguments.begin())
@@ -121,153 +115,229 @@ void printType(std::ostream & o,
o << "()";
}
-void printType(std::ostream & o,
- ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- OString const & type, short referenceType, bool defaultvalue)
+void printType(
+ std::ostream & o, ProgramOptions const & options,
+ rtl::Reference< TypeManager > const & manager, OUString const & name,
+ short referenceType, bool defaultvalue)
{
- RTTypeClass typeClass;
- OString name;
+ OUString nucleus;
sal_Int32 rank;
- std::vector< OString > arguments;
- codemaker::UnoType::Sort sort = codemaker::decomposeAndResolve(
- manager, type, true, true, true, &typeClass, &name, &rank, &arguments);
- printType(o,
- options, manager, sort, typeClass, name, rank, arguments,
+ std::vector< OUString > arguments;
+ rtl::Reference< unoidl::Entity > entity;
+ codemaker::UnoType::Sort sort = manager->decompose(
+ name, true, &nucleus, &rank, &arguments, &entity);
+ printType(
+ o, options, manager, sort, nucleus, rank, arguments, entity,
referenceType, defaultvalue);
}
-bool printConstructorParameters(std::ostream & o,
- ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader, typereg::Reader const & outerReader,
- std::vector< OString > const & arguments)
+bool printConstructorParameters(
+ std::ostream & o, ProgramOptions const & options,
+ rtl::Reference< TypeManager > const & manager,
+ codemaker::UnoType::Sort sort,
+ rtl::Reference< unoidl::Entity > const & entity, OUString const & name,
+ std::vector< OUString > const & arguments)
{
bool previous = false;
- if (reader.getSuperTypeCount() != 0) {
- OString super(
- codemaker::convertString(reader.getSuperTypeName(0)));
- typereg::Reader superReader(manager->getTypeReader(super));
- if (!superReader.isValid())
- throw CannotDumpException("Bad type library entity " + b2u(super));
-
- previous = printConstructorParameters(o,
- options, manager, superReader, outerReader, arguments);
- }
- for (sal_uInt16 i = 0; i < reader.getFieldCount(); ++i) {
- if (previous)
- o << ", ";
- else
- previous = true;
-
- if ((reader.getFieldFlags(i) & RT_ACCESS_PARAMETERIZED_TYPE) == 0) {
- printType(o, options, manager,
- codemaker::convertString(reader.getFieldTypeName(i)), 4);
- } else if (arguments.empty()) {
- // ToDo !
- // o << "com::sun::star::uno::Any";
- } else {
- sal_uInt16 tparam = 0;
- while (outerReader.getReferenceTypeName(tparam)
- != reader.getFieldTypeName(i))
+ switch (sort) {
+ case codemaker::UnoType::SORT_PLAIN_STRUCT_TYPE:
+ {
+ rtl::Reference< unoidl::PlainStructTypeEntity > ent2(
+ dynamic_cast< unoidl::PlainStructTypeEntity * >(entity.get()));
+ assert(ent2.is());
+ if (!ent2->getDirectBase().isEmpty()) {
+ rtl::Reference< unoidl::Entity > baseEnt;
+ codemaker::UnoType::Sort baseSort = manager->getSort(
+ ent2->getDirectBase(), &baseEnt);
+ previous = printConstructorParameters(
+ o, options, manager, baseSort, baseEnt,
+ ent2->getDirectBase(), std::vector< OUString >());
+ }
+ for (std::vector< unoidl::PlainStructTypeEntity::Member >::
+ const_iterator i(ent2->getDirectMembers().begin());
+ i != ent2->getDirectMembers().end(); ++i)
{
- ++tparam;
- OSL_ASSERT(tparam < outerReader.getReferenceCount());
+ if (previous) {
+ o << ", ";
+ }
+ previous = true;
+ printType(o, options, manager, i->type, 4);
+ o << ' '
+ << codemaker::cpp::translateUnoToCppIdentifier(
+ u2b(i->name), "param");
}
- // assume std::vector< OString >::size_type is at least as
- // large as sal_uInt16:
- printType(o, options, manager, arguments[tparam], 4);
+ break;
}
- o << ' '
- << (codemaker::cpp::translateUnoToCppIdentifier(
- codemaker::convertString(reader.getFieldName(i)),
- "param").
- getStr());
+ case codemaker::UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE:
+ {
+ rtl::Reference< unoidl::PolymorphicStructTypeTemplateEntity > ent2(
+ dynamic_cast< unoidl::PolymorphicStructTypeTemplateEntity * >(
+ entity.get()));
+ assert(ent2.is());
+ for (std::vector<
+ unoidl::PolymorphicStructTypeTemplateEntity::Member >::
+ const_iterator i(ent2->getMembers().begin());
+ i != ent2->getMembers().end(); ++i)
+ {
+ if (previous) {
+ o << ", ";
+ }
+ previous = true;
+ if (i->parameterized) {
+ o << i->type;
+ } else {
+ printType(o, options, manager, i->type, 4);
+ }
+ o << ' '
+ << codemaker::cpp::translateUnoToCppIdentifier(
+ u2b(i->name), "param");
+ }
+ break;
+ }
+ case codemaker::UnoType::SORT_INSTANTIATED_POLYMORPHIC_STRUCT_TYPE:
+ {
+ rtl::Reference< unoidl::PolymorphicStructTypeTemplateEntity > ent2(
+ dynamic_cast< unoidl::PolymorphicStructTypeTemplateEntity * >(
+ entity.get()));
+ assert(ent2.is());
+ for (std::vector<
+ unoidl::PolymorphicStructTypeTemplateEntity::Member >::
+ const_iterator i(ent2->getMembers().begin());
+ i != ent2->getMembers().end(); ++i)
+ {
+ if (previous) {
+ o << ", ";
+ }
+ previous = true;
+ if (i->parameterized) {
+ for (std::vector< OUString >::const_iterator j(
+ ent2->getTypeParameters().begin());
+ j != ent2->getTypeParameters().end(); ++j)
+ {
+ if (i->type == *j) {
+ o << arguments[
+ j - ent2->getTypeParameters().begin()];
+ break;
+ }
+ }
+ } else {
+ printType(o, options, manager, i->type, 4);
+ }
+ o << ' '
+ << codemaker::cpp::translateUnoToCppIdentifier(
+ u2b(i->name), "param");
+ }
+ break;
+ }
+ case codemaker::UnoType::SORT_EXCEPTION_TYPE:
+ {
+ rtl::Reference< unoidl::ExceptionTypeEntity > ent2(
+ dynamic_cast< unoidl::ExceptionTypeEntity * >(entity.get()));
+ assert(ent2.is());
+ if (!ent2->getDirectBase().isEmpty()) {
+ rtl::Reference< unoidl::Entity > baseEnt;
+ codemaker::UnoType::Sort baseSort = manager->getSort(
+ ent2->getDirectBase(), &baseEnt);
+ previous = printConstructorParameters(
+ o, options, manager, baseSort, baseEnt,
+ ent2->getDirectBase(), std::vector< OUString >());
+ }
+ for (std::vector< unoidl::ExceptionTypeEntity::Member >::
+ const_iterator i(ent2->getDirectMembers().begin());
+ i != ent2->getDirectMembers().end(); ++i)
+ {
+ if (previous) {
+ o << ", ";
+ }
+ previous = true;
+ printType(o, options, manager, i->type, 4);
+ o << ' '
+ << codemaker::cpp::translateUnoToCppIdentifier(
+ u2b(i->name), "param");
+ }
+ break;
+ }
+ default:
+ throw CannotDumpException(
+ "unexpected entity \"" + name
+ + "\" in call to skeletonmaker::cpp::printConstructorParameters");
}
return previous;
}
-void printConstructor(std::ostream & o,
- ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader,
- std::vector< OString > const & arguments)
+void printConstructor(
+ std::ostream & o, ProgramOptions const & options,
+ rtl::Reference< TypeManager > const & manager,
+ codemaker::UnoType::Sort sort,
+ rtl::Reference< unoidl::Entity > const & entity, OUString const & name,
+ std::vector< OUString > const & arguments)
{
- OString type(codemaker::convertString(reader.getTypeName()));
- o << "public ";
- o << type.copy(type.lastIndexOf('/') + 1) << '(';
- printConstructorParameters(o, options, manager, reader, reader,
- arguments);
+ o << "public " << name.copy(name.lastIndexOf('.') + 1) << '(';
+ printConstructorParameters(
+ o, options, manager, sort, entity, name, arguments);
o << ");\n";
}
-void printMethodParameters(std::ostream & o,
- ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader, sal_uInt16 method, bool previous,
- bool withtype)
+void printMethodParameters(
+ std::ostream & o, ProgramOptions const & options,
+ rtl::Reference< TypeManager > const & manager,
+ std::vector< unoidl::InterfaceTypeEntity::Method::Parameter > const &
+ parameters,
+ bool withType)
{
- short referenceType = 4;
- for (sal_uInt16 i = 0; i < reader.getMethodParameterCount(method); ++i) {
- if (previous)
+ for (std::vector< unoidl::InterfaceTypeEntity::Method::Parameter >::
+ const_iterator i(parameters.begin());
+ i != parameters.end(); ++i)
+ {
+ if (i != parameters.begin()) {
o << ", ";
-
- previous = true;
-
- if (reader.getMethodParameterFlags(method, i) == RT_PARAM_OUT
- || reader.getMethodParameterFlags(method, i) == RT_PARAM_INOUT)
- {
- referenceType = 2;
- } else {
- referenceType = 4;
}
-
- if (withtype) {
- printType(o, options, manager,
- codemaker::convertString(
- reader.getMethodParameterTypeName(method, i)),
- referenceType);
+ if (withType) {
+ short referenceType;
+ if (i->direction
+ == unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_IN)
+ {
+ referenceType = 4;
+ } else {
+ referenceType = 2;
+ }
+ printType(o, options, manager, i->type, referenceType);
o << ' ';
}
-
- o << (codemaker::cpp::translateUnoToCppIdentifier(
- codemaker::convertString(
- reader.getMethodParameterName(method, i)),
- "param").
- getStr());
+ o << codemaker::cpp::translateUnoToCppIdentifier(u2b(i->name), "param");
}
}
-void printExceptionSpecification(std::ostream & o,
- ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader, sal_uInt16 method)
+void printExceptionSpecification(
+ std::ostream & o,
+ ProgramOptions const & options,
+ rtl::Reference< TypeManager > const & manager,
+ std::vector< OUString > const & exceptions)
{
o << ((options.shortnames) ? " throw (css::uno::RuntimeException" :
" throw (::com::sun::star::uno::RuntimeException");
- if (reader.getMethodExceptionCount(method) > 0) {
- for (sal_uInt16 i = 0; i < reader.getMethodExceptionCount(method); ++i) {
- o << ", ";
- printType(o, options, manager,
- codemaker::convertString(
- reader.getMethodExceptionTypeName(method, i)), 1);
- }
+ for (std::vector< OUString >::const_iterator i(exceptions.begin());
+ i != exceptions.end(); ++i)
+ {
+ o << ", ";
+ printType(o, options, manager, *i, 1);
}
o << ")";
}
-void printSetPropertyMixinBody(std::ostream & o,
- typereg::Reader const & reader,
- sal_uInt16 field,
- sal_uInt16 method)
+void printSetPropertyMixinBody(
+ std::ostream & o, unoidl::InterfaceTypeEntity::Attribute const & attribute)
{
- RTFieldAccess propFlags = checkAdditionalPropertyFlags(reader, field, method);
- OString fieldname = codemaker::convertString(reader.getFieldName(field));
- bool bound = (reader.getFieldFlags(field) & RT_ACCESS_BOUND ? true : false);
+ unoidl::AccumulationBasedServiceEntity::Property::Attributes propFlags
+ = checkAdditionalPropertyFlags(attribute);
o << "\n{\n";
- if (bound)
+ if (attribute.bound)
o << " BoundListeners l;\n";
- if (propFlags & RT_ACCESS_CONSTRAINED) {
- OString fieldtype = codemaker::convertString(
- reader.getFieldTypeName(field));
+ if (propFlags & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_CONSTRAINED) {
+ OString fieldtype = codemaker::convertString(attribute.type);
sal_Int32 index = fieldtype.lastIndexOf('<');
sal_Int32 nPos=0;
@@ -319,21 +389,21 @@ void printSetPropertyMixinBody(std::ostream & o,
}
o << " prepareSet(\n rtl::OUString(\""
- << fieldname << "\"),\n css::uno::Any(), v, ";
+ << attribute.name << "\"),\n css::uno::Any(), v, ";
} else {
o << " prepareSet(\n rtl::OUString(\""
- << fieldname << "\"),\n css::uno::Any(), css::uno::Any(), ";
+ << attribute.name << "\"),\n css::uno::Any(), css::uno::Any(), ";
}
- if (bound)
+ if (attribute.bound)
o << "&l);\n";
else
o << "0);\n";
o << " {\n osl::MutexGuard g(m_aMutex);\n m_"
- << fieldname << " = the_value;\n }\n";
+ << attribute.name << " = the_value;\n }\n";
- if (bound)
+ if (attribute.bound)
o << " l.notify();\n";
o << "}\n\n";
@@ -368,17 +438,16 @@ void generateXDispatchProvider(std::ostream& o,
void printMethods(std::ostream & o,
ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader, codemaker::GeneratedTypeSet & generated,
+ OUString const & name, codemaker::GeneratedTypeSet & generated,
OString const & delegate, OString const & classname,
OString const & indentation, bool defaultvalue,
- OString const & propertyhelper)
+ OUString const & propertyhelper)
{
- OString type(codemaker::convertString(reader.getTypeName()));
- if (generated.contains(type) || type.equals("com/sun/star/uno/XInterface") ||
+ if (generated.contains(u2b(name)) || name == "com.sun.star.uno.XInterface" ||
(defaultvalue &&
- ( type.equals("com/sun/star/lang/XComponent") ||
- type.equals("com/sun/star/lang/XTypeProvider") ||
- type.equals("com/sun/star/uno/XWeak")) ) )
+ ( name == "com.sun.star.lang.XComponent" ||
+ name == "com.sun.star.lang.XTypeProvider" ||
+ name == "com.sun.star.uno.XWeak" ) ) )
{
return;
}
@@ -388,147 +457,137 @@ void printMethods(std::ostream & o,
bool defaultbody = ((delegate.equals(sd)) ? true : false);
if (body && propertyhelper.getLength() > 1) {
- if ( type.equals("com/sun/star/beans/XPropertySet")) {
- generated.add(type);
+ if (name == "com.sun.star.beans.XPropertySet") {
+ generated.add(u2b(name));
generateXPropertySetBodies(
- o, classname, scopedCppName(propertyhelper));
+ o, classname, scopedCppName(u2b(propertyhelper)));
return;
- } else if ( type.equals("com/sun/star/beans/XFastPropertySet")) {
- generated.add(type);
+ } else if (name == "com.sun.star.beans.XFastPropertySet") {
+ generated.add(u2b(name));
generateXFastPropertySetBodies(
- o, classname, scopedCppName(propertyhelper));
+ o, classname, scopedCppName(u2b(propertyhelper)));
return;
- } else if ( type.equals("com/sun/star/beans/XPropertyAccess")) {
- generated.add(type);
+ } else if (name == "com.sun.star.beans.XPropertyAccess") {
+ generated.add(u2b(name));
generateXPropertyAccessBodies(
- o, classname, scopedCppName(propertyhelper));
+ o, classname, scopedCppName(u2b(propertyhelper)));
return;
}
}
if (body && options.componenttype == 2) {
- if (type.equals("com/sun/star/lang/XServiceName")) {
+ if (name == "com.sun.star.lang.XServiceName") {
o << "// ::com::sun::star::lang::XServiceName:\n"
"::rtl::OUString SAL_CALL " << classname << "getServiceName() "
"throw (css::uno::RuntimeException)\n{\n "
"return ::rtl::OUString("
"sADDIN_SERVICENAME);\n}\n";
- generated.add(type);
+ generated.add(u2b(name));
return;
- } else if (type.equals("com/sun/star/sheet/XAddIn")) {
+ } else if (name == "com.sun.star.sheet.XAddIn") {
generateXAddInBodies(o, classname);
- generated.add(type);
+ generated.add(u2b(name));
// special handling of XLocalizable -> parent of XAddIn
- if (!generated.contains("com/sun/star/lang/XLocalizable")) {
+ if (!generated.contains("com.sun.star.lang.XLocalizable")) {
generateXLocalizable(o, classname);
- generated.add("com/sun/star/lang/XLocalizable");
+ generated.add("com.sun.star.lang.XLocalizable");
}
return;
- } else if (type.equals("com/sun/star/lang/XLocalizable")) {
+ } else if (name == "com.sun.star.lang.XLocalizable") {
generateXLocalizable(o, classname);
- generated.add(type);
+ generated.add(u2b(name));
return;
- } else if (type.equals("com/sun/star/sheet/XCompatibilityNames")) {
+ } else if (name == "com.sun.star.sheet.XCompatibilityNames") {
generateXCompatibilityNamesBodies(o, classname);
- generated.add(type);
+ generated.add(u2b(name));
return;
}
}
if (body && options.componenttype == 3) {
- if (type.equals("com/sun/star/lang/XInitialization")) {
+ if (name == "com.sun.star.lang.XInitialization") {
generateXInitialization(o, classname);
- generated.add(type);
+ generated.add(u2b(name));
return;
- } else if (type.equals("com/sun/star/frame/XDispatch")) {
+ } else if (name == "com.sun.star.frame.XDispatch") {
generateXDispatch(o, classname, options.protocolCmdMap);
- generated.add(type);
+ generated.add(u2b(name));
return;
- } else if (type.equals("com/sun/star/frame/XDispatchProvider")) {
+ } else if (name == "com.sun.star.frame.XDispatchProvider") {
generateXDispatchProvider(o, classname, options.protocolCmdMap);
- generated.add(type);
+ generated.add(u2b(name));
return;
}
}
- generated.add(type);
+ generated.add(u2b(name));
+ rtl::Reference< unoidl::Entity > ent;
+ if (manager->getSort(name, &ent) != codemaker::UnoType::SORT_INTERFACE_TYPE)
+ {
+ throw CannotDumpException(
+ "unexpected entity \"" + name
+ + "\" in call to skeletonmaker::cpp::printMethods");
+ }
+ rtl::Reference< unoidl::InterfaceTypeEntity > ent2(
+ dynamic_cast< unoidl::InterfaceTypeEntity * >(ent.get()));
+ assert(ent2.is());
if (options.all || defaultvalue) {
- for (sal_uInt16 i = 0; i < reader.getSuperTypeCount(); ++i) {
- typereg::Reader super(
- manager->getTypeReader(
- codemaker::convertString(
- reader.getSuperTypeName(i))));
- if (!super.isValid()) {
- throw CannotDumpException(
- "Bad type library entity " + reader.getSuperTypeName(i));
- }
-
- printMethods(o, options, manager, super, generated, delegate,
- classname, indentation, defaultvalue, propertyhelper);
+ for (std::vector< OUString >::const_iterator i(
+ ent2->getDirectMandatoryBases().begin());
+ i != ent2->getDirectMandatoryBases().end(); ++i)
+ {
+ printMethods(
+ o, options, manager, *i, generated, delegate, classname,
+ indentation, defaultvalue, propertyhelper);
}
-
- if (reader.getFieldCount() > 0 || reader.getMethodCount() > 0) {
+ if (!(ent2->getDirectAttributes().empty()
+ && ent2->getDirectMethods().empty()))
+ {
o << indentation << "// ";
- printType(o, options, manager, type, 0);
+ printType(o, options, manager, name, 0);
o << ":\n";
}
}
- sal_uInt16 method = 0;
- for (sal_uInt16 i = 0; i < reader.getFieldCount(); ++i) {
+ for (std::vector< unoidl::InterfaceTypeEntity::Attribute >::const_iterator
+ i(ent2->getDirectAttributes().begin());
+ i != ent2->getDirectAttributes().end(); ++i)
+ {
o << indentation;
if (!body)
o << "virtual ";
- printType(o, options, manager,
- codemaker::convertString(reader.getFieldTypeName(i)), 1);
+ printType(o, options, manager, i->type, 1);
o << " SAL_CALL ";
if (!classname.isEmpty())
o << classname;
- o << "get"
- << codemaker::convertString(reader.getFieldName(i)).getStr()
- << "()";
- if (method < reader.getMethodCount()
- && reader.getMethodFlags(method) == RT_MODE_ATTRIBUTE_GET
- && reader.getMethodName(method) == reader.getFieldName(i))
- {
- printExceptionSpecification(o, options, manager, reader, method++);
- } else {
- o << ((options.shortnames) ? " throw (css::uno::RuntimeException)" :
- " throw (::com::sun::star::uno::RuntimeException)");
- }
+ o << "get" << i->name << "()";
+ printExceptionSpecification(o, options, manager, i->getExceptions);
if (body) {
if (defaultbody) {
if (!propertyhelper.isEmpty()) {
o << "\n{\n osl::MutexGuard g(m_aMutex);\n return m_"
- << codemaker::convertString(reader.getFieldName(i)).getStr()
- << ";\n}\n\n";
+ << i->name << ";\n}\n\n";
} else {
o << "\n{\n return ";
if (options.componenttype == 1) {
- o << "m_"
- << codemaker::convertString(
- reader.getFieldName(i)).getStr();
+ o << "m_" << i->name;
} else {
- printType(o, options, manager,
- codemaker::convertString(
- reader.getFieldTypeName(i)),
- 8, true);
+ printType(o, options, manager, i->type, 8, true);
}
o << ";\n}\n\n";
}
} else {
o << "\n" << indentation << "{\n" << indentation << " return "
- << delegate.getStr() << "get"
- << codemaker::convertString(reader.getFieldName(i)).getStr()
- << "();\n" << indentation << "}\n\n";
+ << delegate.getStr() << "get" << i->name << "();\n"
+ << indentation << "}\n\n";
}
} else {
o << ";\n";
}
- if ((reader.getFieldFlags(i) & RT_ACCESS_READONLY) == 0) {
+ if (!i->readOnly) {
o << indentation;
if (!body)
o << "virtual ";
@@ -537,30 +596,17 @@ void printMethods(std::ostream & o,
if (!classname.isEmpty())
o << classname;
- o << "set"
- << (codemaker::convertString(reader.getFieldName(i)).getStr())
- << '(';
- printType(o, options, manager,
- codemaker::convertString(reader.getFieldTypeName(i)), 4);
+ o << "set" << i->name << '(';
+ printType(o, options, manager, i->type, 4);
o << " the_value)";
- if (method < reader.getMethodCount()
- && reader.getMethodFlags(method) == RT_MODE_ATTRIBUTE_SET
- && reader.getMethodName(method) == reader.getFieldName(i))
- {
- printExceptionSpecification(o, options, manager, reader, method++);
- } else {
- o << ((options.shortnames) ? " throw (css::uno::RuntimeException)" :
- " throw (::com::sun::star::uno::RuntimeException)");
- }
+ printExceptionSpecification(o, options, manager, i->setExceptions);
if (body) {
if (defaultbody) {
if (!propertyhelper.isEmpty()) {
- printSetPropertyMixinBody(o, reader, i, method);
+ printSetPropertyMixinBody(o, *i);
} else {
if (options.componenttype == 1) {
- o << "\n{\n m_"
- << codemaker::convertString(
- reader.getFieldName(i)).getStr()
+ o << "\n{\n m_" << i->name
<< " = the_value;\n}\n\n";
} else {
o << "\n{\n\n}\n\n";
@@ -568,8 +614,7 @@ void printMethods(std::ostream & o,
}
} else {
o << "\n" << indentation << "{\n" << indentation << " "
- << delegate.getStr() << "set"
- << codemaker::convertString(reader.getFieldName(i)).getStr()
+ << delegate.getStr() << "set" << i->name
<< "(the_value);\n" << indentation << "}\n\n";
}
} else {
@@ -577,57 +622,50 @@ void printMethods(std::ostream & o,
}
}
}
- for (; method < reader.getMethodCount(); ++method) {
+ for (std::vector< unoidl::InterfaceTypeEntity::Method >::const_iterator i(
+ ent2->getDirectMethods().begin());
+ i != ent2->getDirectMethods().end(); ++i)
+ {
o << indentation;
if (!body)
o << "virtual ";
- printType(o, options, manager,
- codemaker::convertString(
- reader.getMethodReturnTypeName(method)), 1);
+ printType(o, options, manager, i->returnType, 1);
o << " SAL_CALL ";
if (!classname.isEmpty())
o << classname;
- const OString methodName(codemaker::convertString(reader.getMethodName(method)));
-
- o << methodName << '(';
- printMethodParameters(o, options, manager, reader, method, false, true);
+ o << i->name << '(';
+ printMethodParameters(o, options, manager, i->parameters, true);
o << ')';
- printExceptionSpecification(o, options, manager, reader, method);
+ printExceptionSpecification(o, options, manager, i->exceptions);
if (body) {
- static OUString s("void");
if (defaultbody) {
o << "\n{\n";
- if (!reader.getMethodReturnTypeName(method).equals(s)) {
+ if (i->returnType != "void") {
o << " // TODO: Exchange the default return implementation for \""
- << methodName << "\" !!!\n";
+ << i->name << "\" !!!\n";
o << " // Exchange the default return implementation.\n"
" // NOTE: Default initialized polymorphic structs "
"can cause problems because of\n // missing default "
"initialization of primitive types of some C++ compilers or"
"\n // different Any initialization in Java and C++ "
"polymorphic structs.\n return ";
- printType(o, options, manager,
- codemaker::convertString(
- reader.getMethodReturnTypeName(method)), 8, true);
+ printType(o, options, manager, i->returnType, 8, true);
o << ";";
} else {
o << " // TODO: Insert your implementation for \""
- << methodName << "\" here.";
+ << i->name << "\" here.";
}
o << "\n}\n\n";
} else {
o << "\n" << indentation << "{\n" << indentation << " ";
- if (!reader.getMethodReturnTypeName(method).equals(s))
+ if (i->returnType != "void")
o << "return ";
- o << delegate.getStr()
- << (codemaker::convertString(
- reader.getMethodName(method)).getStr())
- << '(';
- printMethodParameters(o, options, manager, reader, method,
- false, false);
+ o << delegate.getStr() << i->name << '(';
+ printMethodParameters(
+ o, options, manager, i->parameters, false);
o << ");\n" << indentation << "}\n\n";
}
} else {
@@ -635,92 +673,115 @@ void printMethods(std::ostream & o,
}
}
- if (method > 0 && !body)
+ if (!body)
o << "\n";
}
-void printConstructionMethods(std::ostream & o,
- ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader)
+void printConstructors(
+ std::ostream & o, ProgramOptions const & options,
+ rtl::Reference< TypeManager > const & manager, OUString const & name)
{
- for (sal_uInt16 i = 0; i < reader.getMethodCount(); ++i) {
+ rtl::Reference< unoidl::Entity > ent;
+ if (manager->getSort(name, &ent)
+ != codemaker::UnoType::SORT_SINGLE_INTERFACE_BASED_SERVICE)
+ {
+ throw CannotDumpException(
+ "unexpected entity \"" + name
+ + "\" in call to skeletonmaker::java::printConstructors");
+ }
+ rtl::Reference< unoidl::SingleInterfaceBasedServiceEntity > ent2(
+ dynamic_cast< unoidl::SingleInterfaceBasedServiceEntity * >(ent.get()));
+ assert(ent2.is());
+ for (std::vector< unoidl::SingleInterfaceBasedServiceEntity::Constructor >::
+ const_iterator i(ent2->getConstructors().begin());
+ i != ent2->getConstructors().end(); ++i)
+ {
o << "static ";
- printType(o,
- options, manager,
- codemaker::convertString(reader.getSuperTypeName(0)), 1);
+ printType(o, options, manager, ent2->getBase(), 1);
o << ' ';
- if (reader.getMethodName(i).isEmpty()) {
+ if (i->defaultConstructor) {
o << "create";
} else {
- o << (codemaker::cpp::translateUnoToCppIdentifier(
- codemaker::convertString(reader.getMethodName(i)),
- "method").
- getStr());
+ o << codemaker::cpp::translateUnoToCppIdentifier(
+ u2b(i->name), "method");
}
o << ((options.shortnames) ? "(css::uno::Reference< css" :
"(::com::sun::star::uno::Reference< ::com::sun::star")
<< "::uno::XComponentContext > const & the_context";
- printMethodParameters(o, options, manager, reader, i,
- true, true);
+ for (std::vector<
+ unoidl::SingleInterfaceBasedServiceEntity::Constructor::
+ Parameter >::const_iterator j(i->parameters.begin());
+ j != i->parameters.end(); ++j)
+ {
+ o << ", ";
+ printType(o, options, manager, j->type, 4);
+ o << ' '
+ << codemaker::cpp::translateUnoToCppIdentifier(
+ u2b(j->name), "param");
+ }
o << ')';
- printExceptionSpecification(o, options, manager, reader, i);
+ printExceptionSpecification(o, options, manager, i->exceptions);
o << ";\n";
}
}
-void printServiceMembers(std::ostream & o,
- ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader, OString const & type,
+void printServiceMembers(
+ std::ostream & o, ProgramOptions const & options,
+ rtl::Reference< TypeManager > const & manager,
+ OUString const & name,
+ rtl::Reference< unoidl::AccumulationBasedServiceEntity > const & entity,
OString const & delegate)
{
- for (sal_uInt16 i = 0; i < reader.getReferenceCount(); ++i) {
- OString referenceType(
- codemaker::convertString(
- reader.getReferenceTypeName(i)).replace('/', '.'));
-
- if ( reader.getReferenceSort(i) == RT_REF_SUPPORTS ) {
- o << "\n// supported interface " << referenceType.getStr() << "\n";
- generateDocumentation(o, options, manager, referenceType, delegate);
- } else if ( reader.getReferenceSort(i) == RT_REF_EXPORTS ) {
- o << "\n// exported service " << referenceType.getStr() << "\n";
- generateDocumentation(o, options, manager, referenceType, delegate);
- o << "\n// end of exported service " << referenceType.getStr() << "\n";
- }
+ assert(entity.is());
+ for (std::vector< OUString >::const_iterator i(
+ entity->getDirectMandatoryBaseServices().begin());
+ i != entity->getDirectMandatoryBaseServices().end(); ++i)
+ {
+ o << "\n// exported service " << *i << "\n";
+ generateDocumentation(o, options, manager, u2b(*i), delegate);
+ o << "\n// end of exported service " << *i << "\n";
+ }
+ for (std::vector< OUString >::const_iterator i(
+ entity->getDirectMandatoryBaseInterfaces().begin());
+ i != entity->getDirectMandatoryBaseInterfaces().end(); ++i)
+ {
+ o << "\n// supported interface " << *i << "\n";
+ generateDocumentation(o, options, manager, u2b(*i), delegate);
}
-
if (delegate.isEmpty()) {
- o << "\n// properties of service \""<< type.getStr() << "\"\n";
- for (sal_uInt16 i = 0; i < reader.getFieldCount(); ++i) {
- OString fieldName(
- codemaker::convertString(reader.getFieldName(i)));
- OString fieldType(
- codemaker::convertString(reader.getFieldTypeName(i)));
-
+ o << "\n// properties of service \""<< name << "\"\n";
+ for (std::vector< unoidl::AccumulationBasedServiceEntity::Property >::
+ const_iterator i(entity->getDirectProperties().begin());
+ i != entity->getDirectProperties().end(); ++i)
+ {
o << "// private ";
- printType(o, options, manager, fieldType, 1);
+ printType(o, options, manager, i->type, 1);
o << " "
<< codemaker::cpp::translateUnoToCppIdentifier(
- fieldName, "property").getStr()
+ u2b(i->name), "property")
<< ";\n";
}
}
}
-void printMapsToCppType(std::ostream & o,
- ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- codemaker::UnoType::Sort sort, RTTypeClass typeClass,
- OString const & name, sal_Int32 rank,
- std::vector< OString > const & arguments, const char * cppTypeSort)
+void printMapsToCppType(
+ std::ostream & o, ProgramOptions const & options,
+ rtl::Reference< TypeManager > const & manager,
+ codemaker::UnoType::Sort sort, OUString const & nucleus, sal_Int32 rank,
+ std::vector< OUString > const & arguments,
+ rtl::Reference< unoidl::Entity > const & entity, const char * cppTypeSort)
{
o << "maps to C++ ";
if (cppTypeSort != 0)
o << cppTypeSort << ' ';
o << "type \"";
- if (rank == 0 && name == "com/sun/star/uno/XInterface") {
+ if (rank == 0 && nucleus == "com.sun.star.uno.XInterface") {
o << "Reference< com::sun::star::uno::XInterface >";
} else {
- printType(o, options, manager, sort, typeClass, name, rank, arguments, 0);
+ printType(
+ o, options, manager, sort, nucleus, rank, arguments, entity, 0,
+ false);
}
o << '"';
}
@@ -729,88 +790,79 @@ void generateDocumentation(std::ostream & o,
ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
OString const & type, OString const & delegate)
{
- if (type.indexOf('/') >= 0)
- throw CannotDumpException("Illegal type name " + b2u(type));
-
- OString binType(type.replace('.', '/'));
- RTTypeClass typeClass;
- OString name;
+ OUString nucleus;
sal_Int32 rank;
- std::vector< OString > arguments;
- codemaker::UnoType::Sort sort = decomposeResolveAndCheck(
- manager, binType, false, true, true, &typeClass, &name, &rank,
- &arguments);
+ codemaker::UnoType::Sort sort = manager->decompose(
+ b2u(type), false, &nucleus, &rank, 0, 0);
- bool comment=true;
+ bool comment = true;
if (!delegate.isEmpty()) {
- if (typeClass != RT_TYPE_INTERFACE &&
- typeClass != RT_TYPE_SERVICE )
+ if (sort != codemaker::UnoType::SORT_INTERFACE_TYPE &&
+ sort != codemaker::UnoType::SORT_SINGLE_INTERFACE_BASED_SERVICE &&
+ sort != codemaker::UnoType::SORT_ACCUMULATION_BASED_SERVICE )
{
return;
}
- comment=false;
+ comment = false;
}
if (comment) {
o << "\n// UNO";
- if (rank > 0) {
+ if (rank != 0) {
o << " sequence type";
- } else if (sort != codemaker::UnoType::SORT_COMPLEX) {
+ } else if (sort <= codemaker::UnoType::SORT_ANY) {
o << " simple type";
} else {
- typereg::Reader reader(manager->getTypeReader(name));
- if (!reader.isValid())
- throw CannotDumpException("Bad type library entity " + b2u(name));
-
- switch (typeClass)
- {
- case RT_TYPE_INTERFACE:
+ switch (sort) {
+ case codemaker::UnoType::SORT_INTERFACE_TYPE:
o << " interface type";
break;
- case RT_TYPE_MODULE:
+ case codemaker::UnoType::SORT_MODULE:
o << "IDL module";
break;
- case RT_TYPE_STRUCT:
- if (reader.getReferenceCount() == 0)
- o << " simple struct type";
- else if (arguments.empty())
- o << " polymorphic struct type template";
- else
- o << " instantiated polymorphic struct type";
+ case codemaker::UnoType::SORT_PLAIN_STRUCT_TYPE:
+ o << " simple struct type";
break;
- case RT_TYPE_ENUM:
+ case codemaker::UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE:
+ o << " polymorphic struct type template";
+ break;
+
+ case codemaker::UnoType::SORT_INSTANTIATED_POLYMORPHIC_STRUCT_TYPE:
+ o << " instantiated polymorphic struct type";
+ break;
+
+ case codemaker::UnoType::SORT_ENUM_TYPE:
o << " enum type";
break;
- case RT_TYPE_EXCEPTION:
+ case codemaker::UnoType::SORT_EXCEPTION_TYPE:
o << " exception type";
break;
- case RT_TYPE_TYPEDEF:
+ case codemaker::UnoType::SORT_TYPEDEF:
o << "IDL typedef";
break;
- case RT_TYPE_SERVICE:
- if (reader.getSuperTypeCount() > 0)
- o << " single-inheritance--based service";
- else
- o << "IDL accumulation-based service";
+ case codemaker::UnoType::SORT_SINGLE_INTERFACE_BASED_SERVICE:
+ o << " single-inheritance--based service";
+ break;
+
+ case codemaker::UnoType::SORT_ACCUMULATION_BASED_SERVICE:
+ o << "IDL accumulation-based service";
+ break;
+
+ case codemaker::UnoType::SORT_INTERFACE_BASED_SINGLETON:
+ o << " inheritance-based singleton";
break;
- case RT_TYPE_SINGLETON:
- if ((manager->getTypeReader(
- codemaker::convertString(
- reader.getSuperTypeName(0))).getTypeClass())
- == RT_TYPE_INTERFACE)
- o << " inheritance-based singleton";
- else
- o << "IDL service-based singleton";
+ case codemaker::UnoType::SORT_SERVICE_BASED_SINGLETON:
+ o << "IDL service-based singleton";
break;
- case RT_TYPE_CONSTANTS:
+ case codemaker::UnoType::SORT_CONSTANT_GROUP:
o << "IDL constant group";
break;
@@ -819,36 +871,33 @@ void generateDocumentation(std::ostream & o,
break;
}
}
- o << " \"" << type.getStr() << "\" ";
+ o << " \"" << type << "\" ";
}
- sort = codemaker::decomposeAndResolve(
- manager, binType, true, true, true, &typeClass, &name, &rank,
- &arguments);
- if (rank > 0) {
+ std::vector< OUString > arguments;
+ rtl::Reference< unoidl::Entity > entity;
+ sort = manager->decompose(
+ b2u(type), true, &nucleus, &rank, &arguments, &entity);
+ if (rank != 0) {
if (comment) {
- printMapsToCppType(o,
- options, manager, sort, typeClass, name, rank, arguments, "array");
+ printMapsToCppType(
+ o, options, manager, sort, nucleus, rank, arguments, entity,
+ "array");
o << '\n';
}
- } else if (sort != codemaker::UnoType::SORT_COMPLEX) {
+ } else if (sort <= codemaker::UnoType::SORT_ANY) {
if (comment) {
- printMapsToCppType(o,
- options, manager, sort, typeClass, name, rank, arguments, 0);
+ printMapsToCppType(
+ o, options, manager, sort, nucleus, rank, arguments, entity, 0);
o << '\n';
}
} else {
- typereg::Reader reader(manager->getTypeReader(name));
- if (!reader.isValid())
- throw CannotDumpException("Bad type library entity " + b2u(name));
-
- switch (typeClass)
- {
- case RT_TYPE_INTERFACE:
+ switch (sort) {
+ case codemaker::UnoType::SORT_INTERFACE_TYPE:
if (comment)
- printMapsToCppType(o,
- options, manager, sort, typeClass, name, rank, arguments,
+ printMapsToCppType(
+ o, options, manager, sort, nucleus, rank, arguments, entity,
"interface");
- if (name == "com/sun/star/uno/XInterface") {
+ if (nucleus == "com.sun.star.uno.XInterface") {
if (comment)
o << '\n';
} else {
@@ -856,96 +905,116 @@ void generateDocumentation(std::ostream & o,
o << "; " << (options.all ? "all" : "direct") << " methods:\n";
codemaker::GeneratedTypeSet generated;
- printMethods(o, options, manager, reader, generated,
- delegate, options.implname, "");
+ printMethods(
+ o, options, manager, nucleus, generated, delegate,
+ options.implname, "");
}
break;
- case RT_TYPE_MODULE:
- printMapsToCppType(o,
- options, manager, sort, typeClass, name, rank, arguments,
+ case codemaker::UnoType::SORT_MODULE:
+ printMapsToCppType(
+ o, options, manager, sort, nucleus, rank, arguments, entity,
"namespace");
o << '\n';
break;
- case RT_TYPE_STRUCT:
- if (reader.getReferenceCount() == 0) {
- printMapsToCppType(o,
- options, manager, sort, typeClass, name, rank, arguments,
- "class");
- } else if (arguments.empty()) {
- printMapsToCppType(o,
- options, manager, sort, typeClass, name, rank, arguments,
- options.java5 ? "generic class" : "class");
- } else {
- printMapsToCppType(o,
- options, manager, sort, typeClass, name, rank, arguments,
- options.java5 ? "generic class instantiation" : "class");
- }
+ case codemaker::UnoType::SORT_PLAIN_STRUCT_TYPE:
+ printMapsToCppType(
+ o, options, manager, sort, nucleus, rank, arguments, entity,
+ "class");
+ o << "; full constructor:\n";
+ printConstructor(
+ o, options, manager, codemaker::UnoType::SORT_PLAIN_STRUCT_TYPE,
+ entity, nucleus, arguments);
+ break;
+
+ case codemaker::UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE:
+ printMapsToCppType(
+ o, options, manager, sort, nucleus, rank, arguments, entity,
+ options.java5 ? "generic class" : "class");
+ o << "; full constructor:\n";
+ printConstructor(
+ o, options, manager,
+ codemaker::UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE,
+ entity, nucleus, arguments);
+ break;
+
+ case codemaker::UnoType::SORT_INSTANTIATED_POLYMORPHIC_STRUCT_TYPE:
+ printMapsToCppType(
+ o, options, manager, sort, nucleus, rank, arguments, entity,
+ options.java5 ? "generic class instantiation" : "class");
o << "; full constructor:\n";
- printConstructor(o, options, manager, reader, arguments);
+ printConstructor(
+ o, options, manager,
+ codemaker::UnoType::SORT_INSTANTIATED_POLYMORPHIC_STRUCT_TYPE,
+ entity, nucleus, arguments);
break;
- case RT_TYPE_ENUM:
- printMapsToCppType(o,
- options, manager, sort, typeClass, name, rank, arguments,
+ case codemaker::UnoType::SORT_ENUM_TYPE:
+ printMapsToCppType(
+ o, options, manager, sort, nucleus, rank, arguments, entity,
"enum");
o << '\n';
break;
- case RT_TYPE_CONSTANTS:
- printMapsToCppType(o,
- options, manager, sort, typeClass, name, rank, arguments,
+ case codemaker::UnoType::SORT_CONSTANT_GROUP:
+ printMapsToCppType(
+ o, options, manager, sort, nucleus, rank, arguments, entity,
"namespace");
o << '\n';
break;
- case RT_TYPE_EXCEPTION:
- printMapsToCppType(o,
- options, manager, sort, typeClass, name, rank, arguments,
+ case codemaker::UnoType::SORT_EXCEPTION_TYPE:
+ printMapsToCppType(
+ o, options, manager, sort, nucleus, rank, arguments, entity,
"exception class");
o << "; full constructor:\n";
- printConstructor(o, options, manager, reader, arguments);
+ printConstructor(
+ o, options, manager, codemaker::UnoType::SORT_EXCEPTION_TYPE,
+ entity, nucleus, arguments);
break;
- case RT_TYPE_SERVICE:
- if (reader.getSuperTypeCount() > 0) {
- if (comment) {
- printMapsToCppType(o, options, manager, sort, typeClass,
- name, rank, arguments, "class");
- o << "; construction methods:\n";
- printConstructionMethods(o, options, manager, reader);
- }
-
- OString super(
- codemaker::convertString(
- reader.getSuperTypeName(0)).replace('/', '.'));
- generateDocumentation(o, options, manager, super, delegate);
- } else {
- if (comment)
- o << ("does not map to C++\n"
- "// the service members are generated instead\n");
- printServiceMembers(o, options, manager, reader, type, delegate);
+ case codemaker::UnoType::SORT_SINGLE_INTERFACE_BASED_SERVICE:
+ if (comment) {
+ printMapsToCppType(
+ o, options, manager, sort, nucleus, rank, arguments, entity,
+ "class");
+ o << "; construction methods:\n";
+ printConstructors(o, options, manager, nucleus);
}
+ generateDocumentation(
+ o, options, manager,
+ u2b(dynamic_cast< unoidl::SingleInterfaceBasedServiceEntity * >(
+ entity.get())->getBase()),
+ delegate);
break;
- case RT_TYPE_SINGLETON:
- if (reader.getSuperTypeCount() > 0 &&
- ((manager->getTypeReader(
- codemaker::convertString(
- reader.getSuperTypeName(0))).
- getTypeClass()) == RT_TYPE_INTERFACE) )
- {
- printMapsToCppType(o, options, manager, sort, typeClass,
- name, rank, arguments,
- "class");
- o << "; get method:\nstatic ";
- printType(o, options, manager,
- codemaker::convertString(reader.getSuperTypeName(0)), 1);
- o << " get(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & context);\n";
- } else {
- o << "does not map to C++\n";
- }
+ case codemaker::UnoType::SORT_ACCUMULATION_BASED_SERVICE:
+ if (comment)
+ o << ("does not map to C++\n"
+ "// the service members are generated instead\n");
+ printServiceMembers(
+ o, options, manager, nucleus,
+ dynamic_cast< unoidl::AccumulationBasedServiceEntity * >(
+ entity.get()),
+ delegate);
+ break;
+
+ case codemaker::UnoType::SORT_INTERFACE_BASED_SINGLETON:
+ printMapsToCppType(
+ o, options, manager, sort, nucleus, rank, arguments, entity,
+ "class");
+ o << "; get method:\nstatic ";
+ printType(
+ o, options, manager,
+ dynamic_cast< unoidl::InterfaceBasedSingletonEntity * >(
+ entity.get())->getBase(),
+ 1);
+ o << " get(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & context);\n";
+ break;
+
+ case codemaker::UnoType::SORT_SERVICE_BASED_SINGLETON:
+ o << "does not map to C++\n";
break;
default:
diff --git a/unodevtools/source/skeletonmaker/javacompskeleton.cxx b/unodevtools/source/skeletonmaker/javacompskeleton.cxx
index 2e9efeda3696..339dbad9ed99 100644
--- a/unodevtools/source/skeletonmaker/javacompskeleton.cxx
+++ b/unodevtools/source/skeletonmaker/javacompskeleton.cxx
@@ -37,7 +37,7 @@ void generatePackage(std::ostream & o, const OString & implname)
}
void generateImports(std::ostream & o, ProgramOptions const & options,
- const OString & propertyhelper,
+ const OUString & propertyhelper,
bool serviceobject, bool supportxcomponent)
{
if (options.componenttype == 3)
@@ -183,7 +183,9 @@ void generateXPropertyAccessBodies(std::ostream& o)
}
-bool checkAttribute(OStringBuffer& attributeValue, sal_uInt16 attribute)
+bool checkAttribute(
+ OStringBuffer& attributeValue,
+ unoidl::AccumulationBasedServiceEntity::Property::Attributes attribute)
{
bool cast = false;
sal_uInt16 attributes[9] = {
@@ -254,15 +256,15 @@ void registerProperties(std::ostream& o,
for (AttributeInfo::const_iterator i(properties.begin());
i != properties.end(); ++i)
{
- if (i->second.second > 0) {
- cast = checkAttribute(attributeValue, i->second.second);
+ if (i->attributes != 0) {
+ cast = checkAttribute(attributeValue, i->attributes);
} else {
cast = true;
attributeValue.append('0');
}
- o << indentation << "registerProperty(\"" << i->first
- << "\", \"m_" << i->first << "\",\n"
+ o << indentation << "registerProperty(\"" << i->name
+ << "\", \"m_" << i->name << "\",\n"
<< indentation << " ";
if (cast)
o << "(short)";
@@ -504,29 +506,28 @@ void generateXDispatchProviderBodies(std::ostream& o, ProgramOptions const & opt
void generateMethodBodies(std::ostream& o,
ProgramOptions const & options,
rtl::Reference< TypeManager > const & manager,
- const boost::unordered_set< OString, OStringHash >& interfaces,
+ const std::set< OUString >& interfaces,
const OString& indentation, bool usepropertymixin)
{
- boost::unordered_set< OString, OStringHash >::const_iterator iter =
- interfaces.begin();
+ std::set< OUString >::const_iterator iter = interfaces.begin();
codemaker::GeneratedTypeSet generated;
while (iter != interfaces.end()) {
- OString type(*iter);
+ OUString type(*iter);
++iter;
if (type.equals("com.sun.star.lang.XServiceInfo")) {
generateXServiceInfoBodies(o);
- generated.add(type);
+ generated.add(u2b(type));
} else {
if (options.componenttype == 2) {
if (type.equals("com.sun.star.lang.XServiceName")) {
o << " // com.sun.star.lang.XServiceName:\n"
" public String getServiceName() {\n"
" return sADDIN_SERVICENAME;\n }\n";
- generated.add(type);
+ generated.add(u2b(type));
continue;
} else if (type.equals("com.sun.star.sheet.XAddIn")) {
generateXAddInBodies(o, options);
- generated.add(type);
+ generated.add(u2b(type));
// special handling of XLocalizable -> parent of XAddIn
if (!generated.contains("com.sun.star.lang.XLocalizable")) {
@@ -536,31 +537,30 @@ void generateMethodBodies(std::ostream& o,
continue;
} else if (type.equals("com.sun.star.lang.XLocalizable")) {
generateXLocalizableBodies(o);
- generated.add(type);
+ generated.add(u2b(type));
continue;
} else if (type.equals("com.sun.star.sheet.XCompatibilityNames")) {
generateXCompatibilityNamesBodies(o);
- generated.add(type);
+ generated.add(u2b(type));
continue;
}
}
if (options.componenttype == 3) {
if (type.equals("com.sun.star.lang.XInitialization")) {
generateXInitializationBodies(o);
- generated.add(type);
+ generated.add(u2b(type));
continue;
} else if (type.equals("com.sun.star.frame.XDispatch")) {
generateXDispatchBodies(o, options);
- generated.add(type);
+ generated.add(u2b(type));
continue;
} else if (type.equals("com.sun.star.frame.XDispatchProvider")) {
generateXDispatchProviderBodies(o, options);
- generated.add(type);
+ generated.add(u2b(type));
continue;
}
}
- typereg::Reader reader(manager->getTypeReader(type.replace('.','/')));
- printMethods(o, options, manager, reader, generated, "_",
+ printMethods(o, options, manager, type, generated, "_",
indentation, true, usepropertymixin);
}
}
@@ -576,8 +576,8 @@ static const char* propcomment=
void generateAddinConstructorAndHelper(std::ostream& o,
ProgramOptions const & options,
rtl::Reference< TypeManager > const & manager, const OString & classname,
- const boost::unordered_set< OString, OStringHash >& services,
- const boost::unordered_set< OString, OStringHash >& interfaces)
+ const std::set< OUString >& services,
+ const std::set< OUString >& interfaces)
{
o << " private com.sun.star.lang.Locale m_locale = "
"new com.sun.star.lang.Locale();\n";
@@ -591,10 +591,10 @@ void generateAddinConstructorAndHelper(std::ostream& o,
// get the one and only add-in service for later use
- boost::unordered_set< OString, OStringHash >::const_iterator iter = services.begin();
- OString sAddinService = (*iter).replace('/', '.');
- if (sAddinService.equals("com.sun.star.sheet.AddIn")) {
- sAddinService = (*(++iter)).replace('/', '.');
+ std::set< OUString >::const_iterator iter = services.begin();
+ OUString sAddinService = *iter;
+ if (sAddinService == "com.sun.star.sheet.AddIn") {
+ sAddinService = *(++iter);
}
@@ -722,11 +722,11 @@ void generateClassDefinition(std::ostream& o,
ProgramOptions const & options,
rtl::Reference< TypeManager > const & manager,
const OString & classname,
- const boost::unordered_set< OString, OStringHash >& services,
- const boost::unordered_set< OString, OStringHash >& interfaces,
+ const std::set< OUString >& services,
+ const std::set< OUString >& interfaces,
const AttributeInfo& properties,
const AttributeInfo& attributes,
- const OString& propertyhelper, bool supportxcomponent)
+ const OUString& propertyhelper, bool supportxcomponent)
{
o << "\n\npublic final class " << classname << " extends ";
@@ -740,8 +740,7 @@ void generateClassDefinition(std::ostream& o,
o << "WeakBase\n";
}
o << " implements ";
- boost::unordered_set< OString, OStringHash >::const_iterator iter =
- interfaces.begin();
+ std::set< OUString >::const_iterator iter = interfaces.begin();
while (iter != interfaces.end()) {
o << (*iter);
++iter;
@@ -767,8 +766,7 @@ void generateClassDefinition(std::ostream& o,
if (!services.empty()) {
o << " private static final String[] m_serviceNames = {\n";
- boost::unordered_set< OString, OStringHash >::const_iterator iter =
- services.begin();
+ std::set< OUString >::const_iterator iter = services.begin();
while (iter != services.end()) {
o << " \"" << (*iter).replace('/','.') << "\"";
++iter;
@@ -786,9 +784,8 @@ void generateClassDefinition(std::ostream& o,
o << " // properties\n";
while (iter != properties.end()) {
o << " protected ";
- printType(o, options, manager, iter->second.first.replace('.','/'),
- false, false);
- o << " m_" << iter->first << ";\n";
+ printType(o, options, manager, iter->type, false, false);
+ o << " m_" << iter->name << ";\n";
++iter;
}
} else if (!attributes.empty()) {
@@ -797,11 +794,9 @@ void generateClassDefinition(std::ostream& o,
o << " // attributes\n";
while (iter != attributes.end()) {
o << " private ";
- printType(o, options, manager, iter->second.first.replace('.','/'),
- false, false);
- o << " m_" << iter->first << " = ";
- printType(o, options, manager, iter->second.first.replace('.','/'),
- false, true);
+ printType(o, options, manager, iter->type, false, false);
+ o << " m_" << iter->name << " = ";
+ printType(o, options, manager, iter->type, false, true);
o <<";\n";
++iter;
}
@@ -843,17 +838,17 @@ void generateSkeleton(ProgramOptions const & options,
rtl::Reference< TypeManager > const & manager,
std::vector< OString > const & types)
{
- boost::unordered_set< OString, OStringHash > interfaces;
- boost::unordered_set< OString, OStringHash > services;
+ std::set< OUString > interfaces;
+ std::set< OUString > services;
AttributeInfo properties;
AttributeInfo attributes;
- boost::unordered_set< OString, OStringHash > propinterfaces;
+ std::set< OUString > propinterfaces;
bool serviceobject = false;
bool supportxcomponent = false;
std::vector< OString >::const_iterator iter = types.begin();
while (iter != types.end()) {
- checkType(manager, *iter, interfaces, services, properties);
+ checkType(manager, b2u(*iter), interfaces, services, properties);
++iter;
}
@@ -898,7 +893,7 @@ void generateSkeleton(ProgramOptions const & options,
if (!services.empty())
serviceobject = true;
- OString propertyhelper = checkPropertyHelper(
+ OUString propertyhelper = checkPropertyHelper(
options, manager, services, interfaces, attributes, propinterfaces);
checkDefaultInterfaces(interfaces, services, propertyhelper);
diff --git a/unodevtools/source/skeletonmaker/javatypemaker.cxx b/unodevtools/source/skeletonmaker/javatypemaker.cxx
index 08761ac0778f..0d24942f6f33 100644
--- a/unodevtools/source/skeletonmaker/javatypemaker.cxx
+++ b/unodevtools/source/skeletonmaker/javatypemaker.cxx
@@ -17,6 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include "sal/config.h"
+
+#include <cstring>
+
#include "codemaker/commonjava.hxx"
#include "skeletoncommon.hxx"
@@ -26,21 +30,15 @@ using namespace ::rtl;
namespace skeletonmaker { namespace java {
-void printType(std::ostream & o,
- ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- OString const & type, bool referenceType,
- bool defaultvalue);
-
-void printType(std::ostream & o,
- ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- codemaker::UnoType::Sort sort, RTTypeClass typeClass,
- OString const & name, sal_Int32 rank,
- std::vector< OString > const & arguments, bool referenceType,
- bool defaultvalue)
+void printType(
+ std::ostream & o, ProgramOptions const & options,
+ rtl::Reference< TypeManager > const & manager,
+ codemaker::UnoType::Sort sort, OUString const & nucleus, sal_Int32 rank,
+ std::vector< OUString > const & arguments, bool referenceType,
+ bool defaultvalue)
{
- if ( defaultvalue && rank == 0 && sort <= codemaker::UnoType::SORT_CHAR ) {
- switch (sort)
- {
+ if (defaultvalue && rank == 0 && sort <= codemaker::UnoType::SORT_CHAR) {
+ switch (sort) {
case codemaker::UnoType::SORT_BOOLEAN:
o << "false";
return;
@@ -56,217 +54,287 @@ void printType(std::ostream & o,
case codemaker::UnoType::SORT_DOUBLE:
o << "0";
return;
- case codemaker::UnoType::SORT_VOID:
- case codemaker::UnoType::SORT_STRING:
- case codemaker::UnoType::SORT_TYPE:
- case codemaker::UnoType::SORT_ANY:
- case codemaker::UnoType::SORT_COMPLEX: default: //TODO
+ default:
break;
}
}
- if ( defaultvalue ) {
- if ( sort == codemaker::UnoType::SORT_COMPLEX &&
- typeClass == RT_TYPE_INTERFACE ) {
+ if (defaultvalue) {
+ if (sort == codemaker::UnoType::SORT_INTERFACE_TYPE) {
o << "null";
return;
- } else if ( sort == codemaker::UnoType::SORT_ANY && rank==0 ) {
+ } else if (sort == codemaker::UnoType::SORT_ANY && rank == 0) {
o << "com.sun.star.uno.Any.VOID";
return;
- } else if ( sort == codemaker::UnoType::SORT_TYPE && rank==0 ) {
+ } else if (sort == codemaker::UnoType::SORT_TYPE && rank == 0) {
o << "com.sun.star.uno.Type.VOID";
return;
- } else
- if ( typeClass != RT_TYPE_ENUM || rank > 0 )
- o << "new ";
+ } else if (sort != codemaker::UnoType::SORT_ENUM_TYPE || rank != 0) {
+ o << "new ";
+ }
}
- OString sType(codemaker::java::translateUnoToJavaType(
- sort, name, referenceType && rank==0).replace('/', '.'));
- if ( sType.indexOf("java.lang.") == 0 )
- sType = sType.copy(10);
- o << sType.getStr();
- if ( !arguments.empty() && options.java5 ) {
+ OString sType(
+ codemaker::java::translateUnoToJavaType(
+ sort, u2b(nucleus), referenceType && rank == 0));
+ if (sType.startsWith("java.lang.")) {
+ sType = sType.copy(std::strlen("java.lang."));
+ }
+ o << sType;
+ if (!arguments.empty() && options.java5) {
o << '<';
- for ( std::vector< OString >::const_iterator i(arguments.begin());
- i != arguments.end(); ++i )
+ for (std::vector< OUString >::const_iterator i(arguments.begin());
+ i != arguments.end(); ++i)
{
- if ( i != arguments.begin() ) {
+ if (i != arguments.begin()) {
o << ", ";
}
-
printType(o, options, manager, *i, true, false);
}
o << '>';
}
- for ( sal_Int32 i = 0; i < rank; ++i ) {
- if ( defaultvalue )
+ for (sal_Int32 i = 0; i != rank; ++i) {
+ if (defaultvalue)
o << "[0]";
else
o << "[]";
}
- if ( defaultvalue && sort > codemaker::UnoType::SORT_CHAR && rank == 0 ) {
- if ( typeClass == RT_TYPE_ENUM )
+ if (defaultvalue && sort > codemaker::UnoType::SORT_CHAR && rank == 0) {
+ if (sort == codemaker::UnoType::SORT_ENUM_TYPE)
o << ".getDefault()";
else
o << "()";
}
}
-void printType(std::ostream & o,
- ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- OString const & type, bool referenceType, bool defaultvalue)
+void printType(
+ std::ostream & o, ProgramOptions const & options,
+ rtl::Reference< TypeManager > const & manager, OUString const & name,
+ bool referenceType, bool defaultvalue)
{
- RTTypeClass typeClass;
- OString name;
+ OUString nucleus;
sal_Int32 rank;
- std::vector< OString > arguments;
- codemaker::UnoType::Sort sort = codemaker::decomposeAndResolve(
- manager, type, true, true, true, &typeClass, &name, &rank, &arguments);
- printType(o,
- options, manager, sort, typeClass, name, rank, arguments,
- referenceType, defaultvalue);
+ std::vector< OUString > arguments;
+ codemaker::UnoType::Sort sort = manager->decompose(
+ name, true, &nucleus, &rank, &arguments, 0);
+ printType(
+ o, options, manager, sort, nucleus, rank, arguments, referenceType,
+ defaultvalue);
}
-bool printConstructorParameters(std::ostream & o,
- ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader, typereg::Reader const & outerReader,
- std::vector< OString > const & arguments)
+bool printConstructorParameters(
+ std::ostream & o, ProgramOptions const & options,
+ rtl::Reference< TypeManager > const & manager,
+ codemaker::UnoType::Sort sort,
+ rtl::Reference< unoidl::Entity > const & entity, OUString const & name,
+ std::vector< OUString > const & arguments)
{
bool previous = false;
- if ( reader.getSuperTypeCount() != 0 ) {
- OString super(
- codemaker::convertString(reader.getSuperTypeName(0)));
- typereg::Reader superReader(manager->getTypeReader(super));
- if ( !superReader.isValid() ) {
- throw CannotDumpException("Bad type library entity " + b2u(super));
+ switch (sort) {
+ case codemaker::UnoType::SORT_PLAIN_STRUCT_TYPE:
+ {
+ rtl::Reference< unoidl::PlainStructTypeEntity > ent2(
+ dynamic_cast< unoidl::PlainStructTypeEntity * >(entity.get()));
+ assert(ent2.is());
+ if (!ent2->getDirectBase().isEmpty()) {
+ rtl::Reference< unoidl::Entity > baseEnt;
+ codemaker::UnoType::Sort baseSort = manager->getSort(
+ ent2->getDirectBase(), &baseEnt);
+ previous = printConstructorParameters(
+ o, options, manager, baseSort, baseEnt,
+ ent2->getDirectBase(), std::vector< OUString >());
+ }
+ for (std::vector< unoidl::PlainStructTypeEntity::Member >::
+ const_iterator i(ent2->getDirectMembers().begin());
+ i != ent2->getDirectMembers().end(); ++i)
+ {
+ if (previous) {
+ o << ", ";
+ }
+ previous = true;
+ printType(o, options, manager, i->type, false);
+ o << ' '
+ << codemaker::java::translateUnoToJavaIdentifier(
+ u2b(i->name), "param");
+ }
+ break;
}
- previous = printConstructorParameters(o,
- options, manager, superReader, outerReader, arguments);
- }
- for ( sal_uInt16 i = 0; i < reader.getFieldCount(); ++i ) {
- if ( previous ) {
- o << ", ";
+ case codemaker::UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE:
+ {
+ rtl::Reference< unoidl::PolymorphicStructTypeTemplateEntity > ent2(
+ dynamic_cast< unoidl::PolymorphicStructTypeTemplateEntity * >(
+ entity.get()));
+ assert(ent2.is());
+ for (std::vector<
+ unoidl::PolymorphicStructTypeTemplateEntity::Member >::
+ const_iterator i(ent2->getMembers().begin());
+ i != ent2->getMembers().end(); ++i)
+ {
+ if (previous) {
+ o << ", ";
+ }
+ previous = true;
+ if (i->parameterized) {
+ o << i->type;
+ } else {
+ printType(o, options, manager, i->type, false);
+ }
+ o << ' '
+ << codemaker::java::translateUnoToJavaIdentifier(
+ u2b(i->name), "param");
+ }
+ break;
}
- previous = true;
- if ( (reader.getFieldFlags(i) & RT_ACCESS_PARAMETERIZED_TYPE) == 0 ) {
- printType(o,
- options, manager,
- codemaker::convertString(reader.getFieldTypeName(i)),
- false);
- } else if ( arguments.empty() ) {
- o << "java.lang.Object";
- } else {
- sal_uInt16 tparam = 0;
- while ( outerReader.getReferenceTypeName(tparam)
- != reader.getFieldTypeName(i) )
+ case codemaker::UnoType::SORT_INSTANTIATED_POLYMORPHIC_STRUCT_TYPE:
+ {
+ rtl::Reference< unoidl::PolymorphicStructTypeTemplateEntity > ent2(
+ dynamic_cast< unoidl::PolymorphicStructTypeTemplateEntity * >(
+ entity.get()));
+ assert(ent2.is());
+ for (std::vector<
+ unoidl::PolymorphicStructTypeTemplateEntity::Member >::
+ const_iterator i(ent2->getMembers().begin());
+ i != ent2->getMembers().end(); ++i)
{
- ++tparam;
- OSL_ASSERT(tparam < outerReader.getReferenceCount());
+ if (previous) {
+ o << ", ";
+ }
+ previous = true;
+ if (i->parameterized) {
+ for (std::vector< OUString >::const_iterator j(
+ ent2->getTypeParameters().begin());
+ j != ent2->getTypeParameters().end(); ++j)
+ {
+ if (i->type == *j) {
+ o << arguments[
+ j - ent2->getTypeParameters().begin()];
+ break;
+ }
+ }
+ } else {
+ printType(o, options, manager, i->type, false);
+ }
+ o << ' '
+ << codemaker::java::translateUnoToJavaIdentifier(
+ u2b(i->name), "param");
+ }
+ break;
+ }
+ case codemaker::UnoType::SORT_EXCEPTION_TYPE:
+ {
+ rtl::Reference< unoidl::ExceptionTypeEntity > ent2(
+ dynamic_cast< unoidl::ExceptionTypeEntity * >(entity.get()));
+ assert(ent2.is());
+ if (!ent2->getDirectBase().isEmpty()) {
+ rtl::Reference< unoidl::Entity > baseEnt;
+ codemaker::UnoType::Sort baseSort = manager->getSort(
+ ent2->getDirectBase(), &baseEnt);
+ previous = printConstructorParameters(
+ o, options, manager, baseSort, baseEnt,
+ ent2->getDirectBase(), std::vector< OUString >());
+ }
+ for (std::vector< unoidl::ExceptionTypeEntity::Member >::
+ const_iterator i(ent2->getDirectMembers().begin());
+ i != ent2->getDirectMembers().end(); ++i)
+ {
+ if (previous) {
+ o << ", ";
+ }
+ previous = true;
+ printType(o, options, manager, i->type, false);
+ o << ' '
+ << codemaker::java::translateUnoToJavaIdentifier(
+ u2b(i->name), "param");
}
- // assume std::vector< OString >::size_type is at least as
- // large as sal_uInt16:
- printType(o, options, manager, arguments[tparam], true);
+ break;
}
- o
- << ' '
- << (codemaker::java::translateUnoToJavaIdentifier(
- codemaker::convertString(reader.getFieldName(i)),
- "param").
- getStr());
+ default:
+ throw CannotDumpException(
+ "unexpected entity \"" + name
+ + "\" in call to skeletonmaker::cpp::printConstructorParameters");
}
return previous;
}
-void printConstructor(std::ostream & o,
- ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader,
- std::vector< OString > const & arguments)
+void printConstructor(
+ std::ostream & o, ProgramOptions const & options,
+ rtl::Reference< TypeManager > const & manager,
+ codemaker::UnoType::Sort sort,
+ rtl::Reference< unoidl::Entity > const & entity, OUString const & name,
+ std::vector< OUString > const & arguments)
{
- OString type(codemaker::convertString(reader.getTypeName()));
- o << "public " << type.copy(type.lastIndexOf('/') + 1) << '(';
- printConstructorParameters(o, options, manager, reader, reader, arguments);
+ o << "public " << name.copy(name.lastIndexOf('.') + 1) << '(';
+ printConstructorParameters(
+ o, options, manager, sort, entity, name, arguments);
o << ");\n";
}
-void printMethodParameters(std::ostream & o,
- ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader, sal_uInt16 method, bool previous,
- bool withtype)
+void printMethodParameters(
+ std::ostream & o, ProgramOptions const & options,
+ rtl::Reference< TypeManager > const & manager,
+ std::vector< unoidl::InterfaceTypeEntity::Method::Parameter > const &
+ parameters,
+ bool withType)
{
- for ( sal_uInt16 i = 0; i < reader.getMethodParameterCount(method); ++i ) {
- if ( previous )
+ for (std::vector< unoidl::InterfaceTypeEntity::Method::Parameter >::
+ const_iterator i(parameters.begin());
+ i != parameters.end(); ++i)
+ {
+ if (i != parameters.begin()) {
o << ", ";
- else
- previous = true;
-
- if ( withtype ) {
- printType(o, options, manager,
- codemaker::convertString(
- reader.getMethodParameterTypeName(method, i)),
- false);
- if ( reader.getMethodParameterFlags(method, i) == RT_PARAM_OUT
- || reader.getMethodParameterFlags(method, i) == RT_PARAM_INOUT )
+ }
+ if (withType) {
+ printType(o, options, manager, i->type, false);
+ if (i->direction
+ != unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_IN)
{
o << "[]";
- } else if ( (reader.getMethodParameterFlags(method, i) & RT_PARAM_REST )
- != 0)
- {
- o << (options.java5 ? "..." : "[]");
}
o << ' ';
}
- o << (codemaker::java::translateUnoToJavaIdentifier(
- codemaker::convertString(
- reader.getMethodParameterName(method, i)),
- "param").
- getStr());
+ o << codemaker::java::translateUnoToJavaIdentifier(
+ u2b(i->name), "param");
}
}
-void printExceptionSpecification(std::ostream & o,
- ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader, sal_uInt16 method)
+void printExceptionSpecification(
+ std::ostream & o, ProgramOptions const & options,
+ rtl::Reference< TypeManager > const & manager,
+ std::vector< OUString > const & exceptions)
{
- if ( reader.getMethodExceptionCount(method) > 0 ) {
+ if (!exceptions.empty()) {
o << " throws ";
- for ( sal_uInt16 i = 0; i < reader.getMethodExceptionCount(method); ++i )
+ for (std::vector< OUString >::const_iterator i(exceptions.begin());
+ i != exceptions.end(); ++i)
{
- if ( i != 0 ) {
+ if (i !=exceptions.begin() ) {
o << ", ";
}
- printType(o,
- options, manager,
- codemaker::convertString(
- reader.getMethodExceptionTypeName(method, i)),
- false);
+ printType(o, options, manager, *i, false);
}
}
}
-void printSetPropertyMixinBody(std::ostream & o,
- typereg::Reader const & reader,
- sal_uInt16 field,
- sal_uInt16 method,
- OString const & indentation)
+void printSetPropertyMixinBody(
+ std::ostream & o, unoidl::InterfaceTypeEntity::Attribute const & attribute,
+ OString const & indentation)
{
- RTFieldAccess propFlags = checkAdditionalPropertyFlags(reader, field, method);
- OString fieldname = codemaker::convertString(reader.getFieldName(field));
- bool bound = (reader.getFieldFlags(field) & RT_ACCESS_BOUND ? true : false);
+ unoidl::AccumulationBasedServiceEntity::Property::Attributes propFlags
+ = checkAdditionalPropertyFlags(attribute);
o << "\n" << indentation << "{\n";
- if ( bound ) {
+ if ( attribute.bound ) {
o << indentation << " PropertySetMixin.BoundListeners l = "
"new PropertySetMixin.BoundListeners();\n\n";
}
o << indentation << " m_prophlp.prepareSet(\""
- << fieldname << "\", ";
- if ( propFlags & RT_ACCESS_CONSTRAINED ) {
- OString fieldtype = codemaker::convertString(reader.getFieldTypeName(field));
+ << attribute.name << "\", ";
+ if ( propFlags & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_CONSTRAINED ) {
+ OString fieldtype = codemaker::convertString(attribute.type);
sal_Int32 index = fieldtype.lastIndexOf('<');
sal_Int32 nPos=0;
@@ -324,17 +392,17 @@ void printSetPropertyMixinBody(std::ostream & o,
o << ", ";
}
- if ( bound )
+ if ( attribute.bound )
o << "l";
else
o << "null";
o << ");\n";
o << indentation << " synchronized (this) {\n"
- << indentation << " m_" << fieldname
+ << indentation << " m_" << attribute.name
<< " = the_value;\n" << indentation << " }\n";
- if ( bound ) {
+ if ( attribute.bound ) {
o << indentation << " l.notifyListeners();\n";
}
o << indentation << "}\n\n";
@@ -346,31 +414,30 @@ void generateXPropertyAccessBodies(std::ostream& o);
void printMethods(std::ostream & o,
ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader,
+ OUString const & name,
codemaker::GeneratedTypeSet & generated,
OString const & delegate, OString const & indentation,
bool defaultvalue, bool usepropertymixin)
{
- OString type(codemaker::convertString(reader.getTypeName()));
- if ( generated.contains(type) || type == "com/sun/star/uno/XInterface" ||
+ if ( generated.contains(u2b(name)) || name == "com.sun.star.uno.XInterface" ||
( defaultvalue &&
- ( type.equals("com/sun/star/lang/XComponent") ||
- type.equals("com/sun/star/lang/XTypeProvider") ||
- type.equals("com/sun/star/uno/XWeak") ) ) ) {
+ ( name == "com.sun.star.lang.XComponent" ||
+ name == "com.sun.star.lang.XTypeProvider" ||
+ name == "com.sun.star.uno.XWeak" ) ) ) {
return;
}
if ( usepropertymixin ) {
- if ( type.equals("com/sun/star/beans/XPropertySet") ) {
- generated.add(type);
+ if (name == "com.sun.star.beans.XPropertySet") {
+ generated.add(u2b(name));
generateXPropertySetBodies(o);
return;
- } else if ( type.equals("com/sun/star/beans/XFastPropertySet") ) {
- generated.add(type);
+ } else if (name == "com.sun.star.beans.XFastPropertySet") {
+ generated.add(u2b(name));
generateXFastPropertySetBodies(o);
return;
- } else if ( type.equals("com/sun/star/beans/XPropertyAccess") ) {
- generated.add(type);
+ } else if (name == "com.sun.star.beans.XPropertyAccess") {
+ generated.add(u2b(name));
generateXPropertyAccessBodies(o);
return;
}
@@ -380,63 +447,57 @@ void printMethods(std::ostream & o,
bool body = !delegate.isEmpty();
bool defaultbody = ((delegate.equals(sd)) ? true : false);
- generated.add(type);
+ generated.add(u2b(name));
+ rtl::Reference< unoidl::Entity > ent;
+ if (manager->getSort(name, &ent) != codemaker::UnoType::SORT_INTERFACE_TYPE)
+ {
+ throw CannotDumpException(
+ "unexpected entity \"" + name
+ + "\" in call to skeletonmaker::java::printMethods");
+ }
+ rtl::Reference< unoidl::InterfaceTypeEntity > ent2(
+ dynamic_cast< unoidl::InterfaceTypeEntity * >(ent.get()));
+ assert(ent2.is());
if ( options.all || defaultvalue ) {
- for (sal_uInt16 i = 0; i < reader.getSuperTypeCount(); ++i) {
- typereg::Reader super(
- manager->getTypeReader(
- codemaker::convertString(
- reader.getSuperTypeName(i))));
- if ( !super.isValid() ) {
- throw CannotDumpException(
- "Bad type library entity " + reader.getSuperTypeName(i));
- }
- printMethods(o, options, manager, super, generated, delegate,
- indentation, defaultvalue, usepropertymixin);
+ for (std::vector< OUString >::const_iterator i(
+ ent2->getDirectMandatoryBases().begin());
+ i != ent2->getDirectMandatoryBases().end(); ++i)
+ {
+ printMethods(
+ o, options, manager, *i, generated, delegate, indentation,
+ defaultvalue, usepropertymixin);
}
- if ( reader.getFieldCount() > 0 || reader.getMethodCount() > 0 ) {
+ if (!(ent2->getDirectAttributes().empty()
+ && ent2->getDirectMethods().empty()))
+ {
o << indentation << "// ";
- printType(o, options, manager, type, false);
+ printType(o, options, manager, name, false);
o << ":\n";
}
}
- sal_uInt16 method = 0;
- for ( sal_uInt16 i = 0; i < reader.getFieldCount(); ++i ) {
+ for (std::vector< unoidl::InterfaceTypeEntity::Attribute >::const_iterator
+ i(ent2->getDirectAttributes().begin());
+ i != ent2->getDirectAttributes().end(); ++i)
+ {
o << indentation << "public ";
- printType(o,
- options, manager,
- codemaker::convertString(reader.getFieldTypeName(i)), false);
- o << " get"
- << codemaker::convertString(reader.getFieldName(i)).getStr()
- << "()";
-
- if ( method < reader.getMethodCount()
- && reader.getMethodFlags(method) == RT_MODE_ATTRIBUTE_GET
- && reader.getMethodName(method) == reader.getFieldName(i) )
- {
- printExceptionSpecification(o, options, manager, reader, method++);
- }
+ printType(o, options, manager, i->type, false);
+ o << " get" << i->name << "()";
+ printExceptionSpecification(o, options, manager, i->getExceptions);
if ( body ) {
if ( defaultbody ) {
if ( usepropertymixin ) {
o << "\n" << indentation << "{\n" << indentation
- << " return m_"
- << codemaker::convertString(reader.getFieldName(i)).getStr()
- << ";\n" << indentation << "}\n\n";
+ << " return m_" << i->name << ";\n" << indentation
+ << "}\n\n";
} else {
o << "\n" << indentation << "{\n" << indentation
<< " return ";
- printType(o,
- options, manager,
- codemaker::convertString(reader.getFieldTypeName(i)),
- false, true);
+ printType(o, options, manager, i->type, false, true);
o << ";\n" << indentation << "}\n\n";
}
} else {
- o << "\n" << indentation << "{\n" << indentation <<
- " return "
- << delegate.getStr() << "get"
- << codemaker::convertString(reader.getFieldName(i)).getStr()
+ o << "\n" << indentation << "{\n" << indentation
+ << " return " << delegate.getStr() << "get" << i->name
<< "();\n" << indentation << "}\n\n";
}
} else {
@@ -444,66 +505,45 @@ void printMethods(std::ostream & o,
}
// REMOVE next line
- if ( (reader.getFieldFlags(i) & RT_ACCESS_READONLY) == 0 ) {
- bool setAttrMethod = false;
- o << indentation << "public void set"
- << (codemaker::convertString(reader.getFieldName(i)).
- getStr())
- << '(';
- printType(o,
- options, manager,
- codemaker::convertString(reader.getFieldTypeName(i)),
- false);
+ if (!i->readOnly) {
+ o << indentation << "public void set" << i->name << '(';
+ printType(o, options, manager, i->type, false);
o << " the_value)";
- if ( method < reader.getMethodCount()
- && reader.getMethodFlags(method) == RT_MODE_ATTRIBUTE_SET
- && reader.getMethodName(method) == reader.getFieldName(i) )
- {
- setAttrMethod=true;
- printExceptionSpecification(o, options, manager, reader, method);
- }
+ printExceptionSpecification(o, options, manager, i->setExceptions);
if ( body ) {
if ( defaultbody ) {
if ( usepropertymixin ) {
- printSetPropertyMixinBody(o, reader, i, method,
- indentation);
+ printSetPropertyMixinBody(o, *i, indentation);
} else {
o << "\n" << indentation << "{\n\n" << indentation
<< "}\n\n";
}
} else {
o << "\n" << indentation << "{\n" << indentation
- << " " << delegate.getStr() << "set"
- << codemaker::convertString(reader.getFieldName(i)).getStr()
+ << " " << delegate.getStr() << "set" << i->name
<< "(the_value);\n" << indentation << "}\n\n";
}
} else {
o << ";\n";
}
- if (setAttrMethod) ++method;
}
}
- for ( ; method < reader.getMethodCount(); ++method ) {
+ for (std::vector< unoidl::InterfaceTypeEntity::Method >::const_iterator i(
+ ent2->getDirectMethods().begin());
+ i != ent2->getDirectMethods().end(); ++i)
+ {
o << indentation << "public ";
- printType(o,
- options, manager,
- codemaker::convertString(
- reader.getMethodReturnTypeName(method)),
- false);
-
- const OString methodName(codemaker::convertString(reader.getMethodName(method)));
-
- o << ' ' << methodName.getStr() << '(';
- printMethodParameters(o, options, manager, reader, method, false, true);
+ printType(o, options, manager, i->returnType, false);
+ o << ' ' << i->name << '(';
+ printMethodParameters(o, options, manager, i->parameters, true);
o << ')';
- printExceptionSpecification(o, options, manager, reader, method);
+ printExceptionSpecification(o, options, manager, i->exceptions);
if ( body ) {
- static OUString s("void");
if ( defaultbody ) {
o << "\n" << indentation << "{\n";
- if ( !reader.getMethodReturnTypeName(method).equals(s) ) {
+ if (i->returnType != "void") {
o << indentation << " // TODO: Exchange the default return "
- << "implementation for \"" << methodName << "\" !!!\n";
+ << "implementation for \"" << i->name << "\" !!!\n";
o << indentation << " // NOTE: "
"Default initialized polymorphic structs can cause problems"
"\n" << indentation << " // because of missing default "
@@ -512,27 +552,21 @@ void printMethods(std::ostream & o,
" in Java and C++\n" << indentation
<< " // polymorphic structs.\n" << indentation
<< " return ";
- printType(o,
- options, manager,
- codemaker::convertString(
- reader.getMethodReturnTypeName(method)),
- false, true);
+ printType(o, options, manager, i->returnType, false, true);
o << ";";
} else {
o << indentation << " // TODO: Insert your implementation for \""
- << methodName << "\" here.";
+ << i->name << "\" here.";
}
o << "\n" << indentation << "}\n\n";
} else {
o << "\n" << indentation << "{\n" << indentation << " ";
- if ( !reader.getMethodReturnTypeName(method).equals(s) )
+ if (i->returnType != "void") {
o << "return ";
- o << delegate.getStr()
- << (codemaker::convertString(
- reader.getMethodName(method)).getStr())
- << '(';
- printMethodParameters(o, options, manager, reader, method,
- false, false);
+ }
+ o << delegate.getStr() << i->name << '(';
+ printMethodParameters(
+ o, options, manager, i->parameters, false);
o << ");\n" << indentation << "}\n\n";
}
} else {
@@ -541,27 +575,51 @@ void printMethods(std::ostream & o,
}
}
-void printConstructionMethods(std::ostream & o,
- ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader)
+void printConstructors(
+ std::ostream & o, ProgramOptions const & options,
+ rtl::Reference< TypeManager > const & manager, OUString const & name)
{
- for ( sal_uInt16 i = 0; i < reader.getMethodCount(); ++i ) {
+ rtl::Reference< unoidl::Entity > ent;
+ if (manager->getSort(name, &ent)
+ != codemaker::UnoType::SORT_SINGLE_INTERFACE_BASED_SERVICE)
+ {
+ throw CannotDumpException(
+ "unexpected entity \"" + name
+ + "\" in call to skeletonmaker::java::printConstructors");
+ }
+ rtl::Reference< unoidl::SingleInterfaceBasedServiceEntity > ent2(
+ dynamic_cast< unoidl::SingleInterfaceBasedServiceEntity * >(ent.get()));
+ assert(ent2.is());
+ for (std::vector< unoidl::SingleInterfaceBasedServiceEntity::Constructor >::
+ const_iterator i(ent2->getConstructors().begin());
+ i != ent2->getConstructors().end(); ++i)
+ {
o << "public static ";
- printType(o,
- options, manager,
- codemaker::convertString(reader.getSuperTypeName(0)), false);
+ printType(o, options, manager, ent2->getBase(), false);
o << ' ';
- if ( reader.getMethodName(i).isEmpty() ) {
+ if (i->defaultConstructor) {
o << "create";
} else {
- o << (codemaker::java::translateUnoToJavaIdentifier(
- codemaker::convertString(reader.getMethodName(i)),
- "method").getStr());
+ o << codemaker::java::translateUnoToJavaIdentifier(
+ u2b(i->name), "method");
}
o << "(com.sun.star.uno.XComponentContext the_context";
- printMethodParameters(o, options, manager, reader, i, true, true);
+ for (std::vector<
+ unoidl::SingleInterfaceBasedServiceEntity::Constructor::
+ Parameter >::const_iterator j(i->parameters.begin());
+ j != i->parameters.end(); ++i)
+ {
+ o << ", ";
+ printType(o, options, manager, j->type, false);
+ if (j->rest) {
+ o << (options.java5 ? "..." : "[]");
+ }
+ o << ' '
+ << codemaker::java::translateUnoToJavaIdentifier(
+ u2b(j->name), "param");
+ }
o << ')';
- printExceptionSpecification(o, options, manager, reader, i);
+ printExceptionSpecification(o, options, manager, i->exceptions);
o << ";\n";
}
}
@@ -570,57 +628,58 @@ void generateDocumentation(std::ostream & o,
ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
OString const & type);
-void printServiceMembers(std::ostream & o,
- ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader, OString const & type,
+void printServiceMembers(
+ std::ostream & o, ProgramOptions const & options,
+ rtl::Reference< TypeManager > const & manager,
+ OUString const & name,
+ rtl::Reference< unoidl::AccumulationBasedServiceEntity > const & entity,
OString const & delegate)
{
- for ( sal_uInt16 i = 0; i < reader.getReferenceCount(); ++i ) {
- OString referenceType(
- codemaker::convertString(
- reader.getReferenceTypeName(i)).replace('/', '.'));
-
- if ( reader.getReferenceSort(i) == RT_REF_SUPPORTS ) {
- o << "\n// supported interface " << referenceType.getStr() << "\n";
- generateDocumentation(o, options, manager, referenceType, delegate);
- } else if ( reader.getReferenceSort(i) == RT_REF_EXPORTS ) {
- o << "\n// exported service " << referenceType.getStr() << "\n";
- generateDocumentation(o, options, manager, referenceType, delegate);
- }
+ assert(entity.is());
+ for (std::vector< OUString >::const_iterator i(
+ entity->getDirectMandatoryBaseServices().begin());
+ i != entity->getDirectMandatoryBaseServices().end(); ++i)
+ {
+ o << "\n// exported service " << *i << "\n";
+ generateDocumentation(o, options, manager, u2b(*i), delegate);
}
-
- o << "\n// properties of service \""<< type.getStr() << "\"\n";
- for ( sal_uInt16 i = 0; i < reader.getFieldCount(); ++i ) {
- OString fieldName(
- codemaker::convertString(reader.getFieldName(i)));
- OString fieldType(
- codemaker::convertString(reader.getFieldTypeName(i)));
-
+ for (std::vector< OUString >::const_iterator i(
+ entity->getDirectMandatoryBaseInterfaces().begin());
+ i != entity->getDirectMandatoryBaseInterfaces().end(); ++i)
+ {
+ o << "\n// supported interface " << *i << "\n";
+ generateDocumentation(o, options, manager, u2b(*i), delegate);
+ }
+ o << "\n// properties of service \""<< name << "\"\n";
+ for (std::vector< unoidl::AccumulationBasedServiceEntity::Property >::
+ const_iterator i(entity->getDirectProperties().begin());
+ i != entity->getDirectProperties().end(); ++i)
+ {
o << "// private ";
- printType(o, options, manager, fieldType, false);
+ printType(o, options, manager, i->type, false);
o << " "
<< codemaker::java::translateUnoToJavaIdentifier(
- fieldName, "property").getStr()
+ u2b(i->name), "property")
<< ";\n";
}
}
-void printMapsToJavaType(std::ostream & o,
- ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- codemaker::UnoType::Sort sort, RTTypeClass typeClass,
- OString const & name, sal_Int32 rank,
- std::vector< OString > const & arguments, const char * javaTypeSort)
+void printMapsToJavaType(
+ std::ostream & o, ProgramOptions const & options,
+ rtl::Reference< TypeManager > const & manager,
+ codemaker::UnoType::Sort sort, OUString const & nucleus, sal_Int32 rank,
+ std::vector< OUString > const & arguments, const char * javaTypeSort)
{
o << "maps to Java " << (options.java5 ? "1.5" : "1.4") << " ";
- if ( javaTypeSort != 0 ) {
+ if (javaTypeSort != 0) {
o << javaTypeSort << ' ';
}
o << "type \"";
- if ( rank == 0 && name == "com/sun/star/uno/XInterface" ) {
+ if (rank == 0 && nucleus == "com.sun.star.uno.XInterface") {
o << "com.sun.star.uno.XInterface";
} else {
- printType(o,
- options, manager, sort, typeClass, name, rank, arguments, false);
+ printType(
+ o, options, manager, sort, nucleus, rank, arguments, false, false);
}
o << '"';
}
@@ -629,89 +688,79 @@ void generateDocumentation(std::ostream & o,
ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
OString const & type, OString const & delegate)
{
- if ( type.indexOf('/') >= 0 ) {
- throw CannotDumpException("Illegal type name " + b2u(type));
- }
- OString binType(type.replace('.', '/'));
- RTTypeClass typeClass;
- OString name;
+ OUString nucleus;
sal_Int32 rank;
- std::vector< OString > arguments;
- codemaker::UnoType::Sort sort = decomposeResolveAndCheck(
- manager, binType, false, true, true, &typeClass, &name, &rank,
- &arguments);
-
- bool comment=true;
- if ( !delegate.isEmpty() ) {
- if ( typeClass != RT_TYPE_INTERFACE && typeClass != RT_TYPE_SERVICE )
+ codemaker::UnoType::Sort sort = manager->decompose(
+ b2u(type), false, &nucleus, &rank, 0, 0);
+
+ bool comment = true;
+ if (!delegate.isEmpty()) {
+ if (sort != codemaker::UnoType::SORT_INTERFACE_TYPE &&
+ sort != codemaker::UnoType::SORT_SINGLE_INTERFACE_BASED_SERVICE &&
+ sort != codemaker::UnoType::SORT_ACCUMULATION_BASED_SERVICE )
+ {
return;
-
- comment=false;
+ }
+ comment = false;
}
- if ( comment ) {
+ if (comment) {
o << "\n// UNO";
- if ( rank > 0 ) {
+ if (rank != 0) {
o << " sequence type";
- } else if ( sort != codemaker::UnoType::SORT_COMPLEX ) {
+ } else if (sort <= codemaker::UnoType::SORT_ANY) {
o << " simple type";
} else {
- typereg::Reader reader(manager->getTypeReader(name));
- if ( !reader.isValid() ) {
- throw CannotDumpException("Bad type library entity " + b2u(name));
- }
- switch ( typeClass ) {
- case RT_TYPE_INTERFACE:
+ switch (sort) {
+ case codemaker::UnoType::SORT_INTERFACE_TYPE:
o << " interface type";
break;
- case RT_TYPE_MODULE:
+ case codemaker::UnoType::SORT_MODULE:
o << "IDL module";
break;
- case RT_TYPE_STRUCT:
- if ( reader.getReferenceCount() == 0 ) {
- o << " simple struct type";
- } else if ( arguments.empty() ) {
- o << " polymorphic struct type template";
- } else {
- o << " instantiated polymorphic struct type";
- }
+ case codemaker::UnoType::SORT_PLAIN_STRUCT_TYPE:
+ o << " simple struct type";
+ break;
+
+ case codemaker::UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE:
+ o << " polymorphic struct type template";
break;
- case RT_TYPE_ENUM:
+ case codemaker::UnoType::SORT_INSTANTIATED_POLYMORPHIC_STRUCT_TYPE:
+ o << " instantiated polymorphic struct type";
+ break;
+
+ case codemaker::UnoType::SORT_ENUM_TYPE:
o << " enum type";
break;
- case RT_TYPE_EXCEPTION:
+ case codemaker::UnoType::SORT_EXCEPTION_TYPE:
o << " exception type";
break;
- case RT_TYPE_TYPEDEF:
+ case codemaker::UnoType::SORT_TYPEDEF:
o << "IDL typedef";
break;
- case RT_TYPE_SERVICE:
- if ( reader.getSuperTypeCount() > 0 ) {
- o << " single-inheritance--based service";
- } else {
- o << "IDL accumulation-based service";
- }
+ case codemaker::UnoType::SORT_SINGLE_INTERFACE_BASED_SERVICE:
+ o << " single-inheritance--based service";
break;
- case RT_TYPE_SINGLETON:
- if ( (manager->getTypeReader(
- codemaker::convertString(
- reader.getSuperTypeName(0))).getTypeClass())
- == RT_TYPE_INTERFACE )
- {
- o << " inheritance-based singleton";
- } else {
- o << "IDL service-based singleton";
- }
+ case codemaker::UnoType::SORT_ACCUMULATION_BASED_SERVICE:
+ o << "IDL accumulation-based service";
break;
- case RT_TYPE_CONSTANTS:
+ case codemaker::UnoType::SORT_INTERFACE_BASED_SINGLETON:
+ o << " inheritance-based singleton";
+ break;
+
+ case codemaker::UnoType::SORT_SERVICE_BASED_SINGLETON:
+ o << "IDL service-based singleton";
+ break;
+
+ case codemaker::UnoType::SORT_CONSTANT_GROUP:
o << "IDL constant group";
break;
@@ -720,119 +769,126 @@ void generateDocumentation(std::ostream & o,
break;
}
}
- o << " \"" << type.getStr() << "\" ";
+ o << " \"" << type << "\" ";
}
- sort = codemaker::decomposeAndResolve(
- manager, binType, true, true, true, &typeClass, &name, &rank,
- &arguments);
- if ( rank > 0 ) {
- printMapsToJavaType(o,
- options, manager, sort, typeClass, name, rank, arguments, "array");
+ std::vector< OUString > arguments;
+ rtl::Reference< unoidl::Entity > entity;
+ sort = manager->decompose(
+ b2u(type), true, &nucleus, &rank, &arguments, &entity);
+ if (rank != 0) {
+ printMapsToJavaType(
+ o, options, manager, sort, nucleus, rank, arguments, "array");
o << '\n';
- } else if ( sort != codemaker::UnoType::SORT_COMPLEX ) {
- printMapsToJavaType(o,
- options, manager, sort, typeClass, name, rank, arguments, 0);
+ } else if (sort <= codemaker::UnoType::SORT_ANY) {
+ printMapsToJavaType(
+ o, options, manager, sort, nucleus, rank, arguments, 0);
o << '\n';
} else {
- typereg::Reader reader(manager->getTypeReader(name));
- if ( !reader.isValid() ) {
- throw CannotDumpException("Bad type library entity " + b2u(name));
- }
- switch ( typeClass ) {
- case RT_TYPE_INTERFACE:
- printMapsToJavaType(o,
- options, manager, sort, typeClass, name, rank, arguments,
+ switch (sort) {
+ case codemaker::UnoType::SORT_INTERFACE_TYPE:
+ printMapsToJavaType(
+ o, options, manager, sort, nucleus, rank, arguments,
"interface");
- if ( name == "com/sun/star/uno/XInterface" ) {
+ if (nucleus == "com.sun.star.uno.XInterface") {
o << '\n';
} else {
- o
- << "; " << (options.all ? "all" : "direct")
- << " methods:\n";
+ o << "; " << (options.all ? "all" : "direct") << " methods:\n";
codemaker::GeneratedTypeSet generated;
- printMethods(o, options, manager, reader, generated,
- delegate, "");
+ printMethods(
+ o, options, manager, nucleus, generated, delegate, "");
}
break;
- case RT_TYPE_MODULE:
- printMapsToJavaType(o,
- options, manager, sort, typeClass, name, rank, arguments,
- "package");
+ case codemaker::UnoType::SORT_MODULE:
+ printMapsToJavaType(
+ o, options, manager, sort, nucleus, rank, arguments, "package");
o << '\n';
break;
- case RT_TYPE_STRUCT:
- if ( reader.getReferenceCount() == 0 ) {
- printMapsToJavaType(o,
- options, manager, sort, typeClass, name, rank, arguments,
- "class");
- } else if ( arguments.empty() ) {
- printMapsToJavaType(o,
- options, manager, sort, typeClass, name, rank, arguments,
- options.java5 ? "generic class" : "class");
- } else {
- printMapsToJavaType(o,
- options, manager, sort, typeClass, name, rank, arguments,
- options.java5 ? "generic class instantiation" : "class");
- }
+ case codemaker::UnoType::SORT_PLAIN_STRUCT_TYPE:
+ printMapsToJavaType(
+ o, options, manager, sort, nucleus, rank, arguments, "class");
o << "; full constructor:\n";
- printConstructor(o, options, manager, reader, arguments);
+ printConstructor(
+ o, options, manager, codemaker::UnoType::SORT_PLAIN_STRUCT_TYPE,
+ entity, nucleus, arguments);
break;
- case RT_TYPE_ENUM:
- case RT_TYPE_CONSTANTS:
- printMapsToJavaType(o,
- options, manager, sort, typeClass, name, rank, arguments,
- "class");
+ case codemaker::UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE:
+ printMapsToJavaType(
+ o, options, manager, sort, nucleus, rank, arguments,
+ options.java5 ? "generic class" : "class");
+ o << "; full constructor:\n";
+ printConstructor(
+ o, options, manager,
+ codemaker::UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE,
+ entity, nucleus, arguments);
+ break;
+
+ case codemaker::UnoType::SORT_INSTANTIATED_POLYMORPHIC_STRUCT_TYPE:
+ printMapsToJavaType(
+ o, options, manager, sort, nucleus, rank, arguments,
+ options.java5 ? "generic class instantiation" : "class");
+ o << "; full constructor:\n";
+ printConstructor(
+ o, options, manager,
+ codemaker::UnoType::SORT_INSTANTIATED_POLYMORPHIC_STRUCT_TYPE,
+ entity, nucleus, arguments);
+ break;
+
+ case codemaker::UnoType::SORT_ENUM_TYPE:
+ case codemaker::UnoType::SORT_CONSTANT_GROUP:
+ printMapsToJavaType(
+ o, options, manager, sort, nucleus, rank, arguments, "class");
o << '\n';
break;
- case RT_TYPE_EXCEPTION:
- printMapsToJavaType(o,
- options, manager, sort, typeClass, name, rank, arguments,
+ case codemaker::UnoType::SORT_EXCEPTION_TYPE:
+ printMapsToJavaType(
+ o, options, manager, sort, nucleus, rank, arguments,
"exception class");
o << "; full constructor:\n";
- printConstructor(o, options, manager, reader, arguments);
+ printConstructor(
+ o, options, manager, codemaker::UnoType::SORT_EXCEPTION_TYPE,
+ entity, nucleus, arguments);
break;
- case RT_TYPE_SERVICE:
- if ( reader.getSuperTypeCount() > 0 ) {
- printMapsToJavaType(o,
- options, manager, sort, typeClass, name, rank, arguments,
- "class");
- o << "; construction methods:\n";
- printConstructionMethods(o, options, manager, reader);
+ case codemaker::UnoType::SORT_SINGLE_INTERFACE_BASED_SERVICE:
+ printMapsToJavaType(
+ o, options, manager, sort, nucleus, rank, arguments, "class");
+ o << "; construction methods:\n";
+ printConstructors(o, options, manager, nucleus);
+ generateDocumentation(
+ o, options, manager,
+ u2b(dynamic_cast< unoidl::SingleInterfaceBasedServiceEntity * >(
+ entity.get())->getBase()),
+ delegate);
+ break;
- OString super(
- codemaker::convertString(
- reader.getSuperTypeName(0)).replace('/', '.'));
+ case codemaker::UnoType::SORT_ACCUMULATION_BASED_SERVICE:
+ o << ("does not map to Java\n"
+ "// the service members are generated instead\n");
+ printServiceMembers(
+ o, options, manager, nucleus,
+ dynamic_cast< unoidl::AccumulationBasedServiceEntity * >(
+ entity.get()),
+ delegate);
+ break;
- generateDocumentation(o, options, manager, super, delegate);
- } else {
- o << ("does not map to Java\n"
- "// the service members are generated instead\n");
- printServiceMembers(o, options, manager, reader, type, delegate);
- }
+ case codemaker::UnoType::SORT_INTERFACE_BASED_SINGLETON:
+ printMapsToJavaType(
+ o, options, manager, sort, nucleus, rank, arguments, "class");
+ o << "; get method:\npublic static ";
+ printType(
+ o, options, manager,
+ dynamic_cast< unoidl::InterfaceBasedSingletonEntity * >(
+ entity.get())->getBase(),
+ false);
+ o << " get(com.sun.star.uno.XComponentContext context);\n";
break;
- case RT_TYPE_SINGLETON:
- if ( reader.getSuperTypeCount() > 0 &&
- ((manager->getTypeReader(
- codemaker::convertString(
- reader.getSuperTypeName(0))).getTypeClass())
- == RT_TYPE_INTERFACE) ) {
- printMapsToJavaType(o, options, manager, sort, typeClass,
- name, rank, arguments, "class");
- o << "; get method:\npublic static ";
- printType(o, options, manager,
- codemaker::convertString(reader.getSuperTypeName(0)),
- false);
- o
- << " get(com.sun.star.uno.XComponentContext context);\n";
- } else {
- o << "does not map to Java\n";
- }
+ case codemaker::UnoType::SORT_SERVICE_BASED_SINGLETON:
+ o << "does not map to Java\n";
break;
default:
diff --git a/unodevtools/source/skeletonmaker/skeletoncommon.cxx b/unodevtools/source/skeletonmaker/skeletoncommon.cxx
index 16ffd28933c1..ae298d06e7f0 100644
--- a/unodevtools/source/skeletonmaker/skeletoncommon.cxx
+++ b/unodevtools/source/skeletonmaker/skeletoncommon.cxx
@@ -22,9 +22,11 @@
#include "codemaker/commonjava.hxx"
#include "codemaker/commoncpp.hxx"
#include "codemaker/generatedtypeset.hxx"
+#include "unoidl/unoidl.hxx"
#include "skeletoncommon.hxx"
+#include <cassert>
#include <iostream>
using namespace ::rtl;
@@ -89,34 +91,11 @@ bool getOutputStream(ProgramOptions const & options,
return bStandardout;
}
-codemaker::UnoType::Sort decomposeResolveAndCheck(
- rtl::Reference< TypeManager > const & manager, OString const & type,
- bool resolveTypedefs, bool allowVoid, bool allowExtraEntities,
- RTTypeClass * typeClass, OString * name, sal_Int32 * rank,
- std::vector< OString > * arguments)
-{
- codemaker::UnoType::Sort sort = codemaker::decomposeAndResolve(
- manager, type, resolveTypedefs, allowVoid, allowExtraEntities,
- typeClass, name, rank, arguments);
- for ( std::vector< OString >::iterator i(arguments->begin());
- i != arguments->end(); ++i )
- {
- RTTypeClass typeClass2;
- OString name2;
- sal_Int32 rank2;
- std::vector< OString > arguments2;
- decomposeResolveAndCheck(
- manager, *i, true, false, false, &typeClass2, &name2, &rank2,
- &arguments2);
- }
- return sort;
-}
-
-bool containsAttribute(AttributeInfo& attributes, OString const & attrname)
+bool containsAttribute(AttributeInfo& attributes, OUString const & attrname)
{
for ( AttributeInfo::const_iterator i(attributes.begin());
i != attributes.end(); ++i ) {
- if ( (*i).first == attrname ) {
+ if ( (*i).name == attrname ) {
return true;
}
}
@@ -125,145 +104,172 @@ bool containsAttribute(AttributeInfo& attributes, OString const & attrname)
// collect attributes including inherited attributes
void checkAttributes(rtl::Reference< TypeManager > const & manager,
- const typereg::Reader& reader,
+ OUString const & name,
AttributeInfo& attributes,
- boost::unordered_set< OString, OStringHash >& propinterfaces)
+ std::set< OUString >& propinterfaces)
{
- OString typeName = codemaker::convertString(reader.getTypeName());
- if ( typeName.equals("com/sun/star/beans/XPropertySet") ||
- typeName.equals("com/sun/star/beans/XFastPropertySet") ||
-// typeName.equals("com/sun/star/beans/XMultiPropertySet") ||
- typeName.equals("com/sun/star/beans/XPropertyAccess") )
+ if ( name == "com.sun.star.beans.XPropertySet" ||
+ name == "com.sun.star.beans.XFastPropertySet" ||
+ name == "com.sun.star.beans.XPropertyAccess" )
{
- propinterfaces.insert(typeName);
+ propinterfaces.insert(name);
}
-
- for ( sal_uInt16 i = 0; i < reader.getSuperTypeCount(); ++i ) {
- typereg::Reader supertype(manager->getTypeReader(
- codemaker::convertString(
- reader.getSuperTypeName(i))));
- if ( !supertype.isValid() ) {
- throw CannotDumpException(
- "Bad type library entity " + reader.getSuperTypeName(i));
+ rtl::Reference< unoidl::Entity > ent;
+ switch (manager->getSort(name, &ent)) {
+ case codemaker::UnoType::SORT_INTERFACE_TYPE:
+ {
+ rtl::Reference< unoidl::InterfaceTypeEntity > ent2(
+ dynamic_cast< unoidl::InterfaceTypeEntity * >(ent.get()));
+ assert(ent2.is());
+ for (std::vector< OUString >::const_iterator i(
+ ent2->getDirectMandatoryBases().begin());
+ i != ent2->getDirectMandatoryBases().end(); ++i)
+ {
+ checkAttributes(manager, *i, attributes, propinterfaces);
+ }
+ for (std::vector< unoidl::InterfaceTypeEntity::Attribute >::
+ const_iterator i(ent2->getDirectAttributes().begin());
+ i != ent2->getDirectAttributes().end(); ++i)
+ {
+ if (!containsAttribute(attributes, i->name)) {
+ attributes.push_back(
+ unoidl::AccumulationBasedServiceEntity::Property(
+ i->name,
+ i->type,
+ (unoidl::AccumulationBasedServiceEntity::Property::
+ Attributes(
+ ((i->bound
+ ? (unoidl::AccumulationBasedServiceEntity::
+ Property::ATTRIBUTE_BOUND)
+ : 0)
+ | (i->readOnly
+ ? (unoidl::AccumulationBasedServiceEntity::
+ Property::ATTRIBUTE_READ_ONLY)
+ : 0))))));
+ }
+ }
+ break;
}
- checkAttributes(manager, supertype, attributes, propinterfaces);
- }
-
- for ( sal_uInt16 i = 0; i < reader.getFieldCount(); ++i ) {
- OString fieldName(
- codemaker::convertString(reader.getFieldName(i)).
- replace('/', '.'));
-
- if ( !containsAttribute(attributes, fieldName) ) {
- OString fieldType(
- codemaker::convertString(reader.getFieldTypeName(i)).
- replace('/', '.'));
- attributes.push_back(AttributeInfo::value_type(
- fieldName, std::pair<OString, sal_Int16>(
- fieldType, reader.getFieldFlags(i))));
+ case codemaker::UnoType::SORT_ACCUMULATION_BASED_SERVICE:
+ {
+ rtl::Reference< unoidl::AccumulationBasedServiceEntity > ent2(
+ dynamic_cast< unoidl::AccumulationBasedServiceEntity * >(
+ ent.get()));
+ assert(ent2.is());
+ for (std::vector< OUString >::const_iterator i(
+ ent2->getDirectMandatoryBaseServices().begin());
+ i != ent2->getDirectMandatoryBaseServices().end(); ++i)
+ {
+ checkAttributes(manager, *i, attributes, propinterfaces);
+ }
+ for (std::vector< OUString >::const_iterator i(
+ ent2->getDirectMandatoryBaseInterfaces().begin());
+ i != ent2->getDirectMandatoryBaseInterfaces().end(); ++i)
+ {
+ checkAttributes(manager, *i, attributes, propinterfaces);
+ }
+ for (std::vector<
+ unoidl::AccumulationBasedServiceEntity::Property >::
+ const_iterator i(ent2->getDirectProperties().begin());
+ i != ent2->getDirectProperties().end(); ++i)
+ {
+ if (!containsAttribute(attributes, i->name)) {
+ attributes.push_back(*i);
+ }
+ }
+ break;
}
+ default:
+ throw CannotDumpException(
+ "unexpected entity \"" + name
+ + "\" in call to skeletonmaker::checkAttributes");
}
}
void checkType(rtl::Reference< TypeManager > const & manager,
- OString const & type,
- boost::unordered_set< OString, OStringHash >& interfaceTypes,
- boost::unordered_set< OString, OStringHash >& serviceTypes,
+ OUString const & name,
+ std::set< OUString >& interfaceTypes,
+ std::set< OUString >& serviceTypes,
AttributeInfo& properties)
{
-
- OString binType(type.replace('.', '/'));
- typereg::Reader reader(manager->getTypeReader(binType));
- if ( !reader.isValid() ) {
- throw CannotDumpException("Bad type library entity " + b2u(binType));
- }
-
- switch ( reader.getTypeClass() )
- {
- case RT_TYPE_INTERFACE:
- {
- // com/sun/star/lang/XComponent should be also not in the list
+ rtl::Reference< unoidl::Entity > ent;
+ switch (manager->getSort(name, &ent)) {
+ case codemaker::UnoType::SORT_INTERFACE_TYPE:
+ // com.sun.star.lang.XComponent should be also not in the list
// but it will be used for checking the impl helper and will be
// removed later if necessary.
- if ( binType.equals("com/sun/star/lang/XTypeProvider") ||
- binType.equals("com/sun/star/uno/XWeak") )
+ if ( name == "com.sun.star.lang.XTypeProvider" ||
+ name == "com.sun.star.uno.XWeak" )
return;
- if (interfaceTypes.find(type) == interfaceTypes.end()) {
- interfaceTypes.insert(type);
+ if (interfaceTypes.find(name) == interfaceTypes.end()) {
+ interfaceTypes.insert(name);
}
- }
break;
- case RT_TYPE_SERVICE:
- if ( serviceTypes.find(binType) == serviceTypes.end() ) {
- serviceTypes.insert(binType);
-
- if ( reader.getSuperTypeCount() > 0 ) {
- OString supername(codemaker::convertString(
- reader.getSuperTypeName(0).replace('/', '.')));
- if ( interfaceTypes.find(supername) == interfaceTypes.end() ) {
- interfaceTypes.insert(supername);
-
- typereg::Reader supertype(manager->getTypeReader(
- codemaker::convertString(
- reader.getSuperTypeName(0))));
- if ( !supertype.isValid() ) {
- throw CannotDumpException(
- "Bad type library entity "
- + reader.getSuperTypeName(0));
- }
- }
-
+ case codemaker::UnoType::SORT_SINGLE_INTERFACE_BASED_SERVICE:
+ if (serviceTypes.find(name) == serviceTypes.end()) {
+ serviceTypes.insert(name);
+ rtl::Reference< unoidl::SingleInterfaceBasedServiceEntity > ent2(
+ dynamic_cast< unoidl::SingleInterfaceBasedServiceEntity * >(
+ ent.get()));
+ assert(ent2.is());
+ if (interfaceTypes.find(ent2->getBase()) == interfaceTypes.end()) {
+ interfaceTypes.insert(ent2->getBase());
// check if constructors are specified, if yes automatically
// support of XInitialization. We will take care of the default
- // constructor because in this case XInitialization is not called.
- if ( reader.getMethodCount() > 1 ||
- ( reader.getMethodCount() == 1 &&
- !reader.getMethodName(0).isEmpty() ) )
+ // constructor because in this case XInitialization is not
+ // called.
+ if (ent2->getConstructors().size() > 1 ||
+ (ent2->getConstructors().size() == 1 &&
+ !ent2->getConstructors()[0].defaultConstructor))
{
- OString s("com.sun.star.lang.XInitialization");
- if ( interfaceTypes.find(s) == interfaceTypes.end() )
+ OUString s("com.sun.star.lang.XInitialization");
+ if (interfaceTypes.find(s) == interfaceTypes.end())
interfaceTypes.insert(s);
}
- } else {
- for ( sal_uInt16 i = 0; i < reader.getReferenceCount(); ++i ) {
- OString referenceType(
- codemaker::convertString(
- reader.getReferenceTypeName(i)).replace('/', '.'));
-
- if ( reader.getReferenceSort(i) == RT_REF_SUPPORTS ) {
- checkType(manager, referenceType, interfaceTypes,
- serviceTypes, properties);
- } else if ( reader.getReferenceSort(i) == RT_REF_EXPORTS ) {
- checkType(manager, referenceType, interfaceTypes,
- serviceTypes, properties);
- }
- }
-
- for ( sal_uInt16 i = 0; i < reader.getFieldCount(); ++i ) {
- OString fieldName(
- codemaker::convertString(reader.getFieldName(i)).
- replace('/', '.'));
- OString fieldType(
- codemaker::convertString(reader.getFieldTypeName(i)).
- replace('/', '.'));
-
- properties.push_back(AttributeInfo::value_type(
- fieldName, std::pair<OString, sal_Int16>(
- fieldType, reader.getFieldFlags(i))));
- }
}
}
break;
- default:
- OSL_ASSERT(false);
+ case codemaker::UnoType::SORT_ACCUMULATION_BASED_SERVICE:
+ if ( serviceTypes.find(name) == serviceTypes.end() ) {
+ serviceTypes.insert(name);
+ rtl::Reference< unoidl::AccumulationBasedServiceEntity > ent2(
+ dynamic_cast< unoidl::AccumulationBasedServiceEntity * >(
+ ent.get()));
+ assert(ent2.is());
+ for (std::vector< OUString >::const_iterator i(
+ ent2->getDirectMandatoryBaseServices().begin());
+ i != ent2->getDirectMandatoryBaseServices().end(); ++i)
+ {
+ checkType(
+ manager, *i, interfaceTypes, serviceTypes, properties);
+ }
+ for (std::vector< OUString >::const_iterator i(
+ ent2->getDirectMandatoryBaseInterfaces().begin());
+ i != ent2->getDirectMandatoryBaseInterfaces().end(); ++i)
+ {
+ checkType(
+ manager, *i, interfaceTypes, serviceTypes, properties);
+ }
+ for (std::vector<
+ unoidl::AccumulationBasedServiceEntity::Property >::
+ const_iterator i(ent2->getDirectProperties().begin());
+ i != ent2->getDirectProperties().end(); ++i)
+ {
+ properties.push_back(*i);
+ }
+ }
break;
+ default:
+ throw CannotDumpException(
+ "unexpected entity \"" + name
+ + "\" in call to skeletonmaker::checkType");
}
}
void checkDefaultInterfaces(
- boost::unordered_set< OString, OStringHash >& interfaces,
- const boost::unordered_set< OString, OStringHash >& services,
- const OString & propertyhelper)
+ std::set< OUString >& interfaces,
+ const std::set< OUString >& services,
+ const OUString & propertyhelper)
{
if ( services.empty() ) {
if (interfaces.find("com.sun.star.lang.XServiceInfo") != interfaces.end())
@@ -287,20 +293,25 @@ void checkDefaultInterfaces(
}
bool checkServiceProperties(rtl::Reference< TypeManager > const & manager,
- const typereg::Reader & reader)
+ OUString const & name)
{
- if ( reader.getFieldCount() > 0 )
- return true;
-
- if ( reader.getReferenceCount() > 0 ) {
- for ( sal_uInt16 i = 0; i < reader.getReferenceCount(); ++i ) {
- if ( reader.getReferenceSort(i) == RT_REF_EXPORTS ) {
- typereg::Reader refreader(
- manager->getTypeReader(
- codemaker::convertString(reader.getReferenceTypeName(i))));
-
- if ( checkServiceProperties(manager, refreader) )
- return true;
+ rtl::Reference< unoidl::Entity > ent;
+ if (manager->getSort(name, &ent)
+ == codemaker::UnoType::SORT_ACCUMULATION_BASED_SERVICE)
+ {
+ rtl::Reference< unoidl::AccumulationBasedServiceEntity > ent2(
+ dynamic_cast< unoidl::AccumulationBasedServiceEntity * >(
+ ent.get()));
+ assert(ent2.is());
+ if (!ent2->getDirectProperties().empty()) {
+ return true;
+ }
+ for (std::vector< OUString >::const_iterator i(
+ ent2->getDirectMandatoryBaseServices().begin());
+ i != ent2->getDirectMandatoryBaseServices().end(); ++i)
+ {
+ if (checkServiceProperties(manager, *i)) {
+ return true;
}
}
}
@@ -308,16 +319,16 @@ bool checkServiceProperties(rtl::Reference< TypeManager > const & manager,
}
-OString checkPropertyHelper(
+OUString checkPropertyHelper(
ProgramOptions const & options,
rtl::Reference< TypeManager > const & manager,
- const boost::unordered_set< OString, OStringHash >& services,
- const boost::unordered_set< OString, OStringHash >& interfaces,
+ const std::set< OUString >& services,
+ const std::set< OUString >& interfaces,
AttributeInfo& attributes,
- boost::unordered_set< OString, OStringHash >& propinterfaces)
+ std::set< OUString >& propinterfaces)
{
- boost::unordered_set< OString, OStringHash >::const_iterator iter;
- boost::unordered_set< OString, OStringHash >::const_iterator end;
+ std::set< OUString >::const_iterator iter;
+ std::set< OUString >::const_iterator end;
if ( !services.empty() ) {
iter = services.begin();
@@ -329,65 +340,64 @@ OString checkPropertyHelper(
bool oldStyleWithProperties = false;
while ( iter != end ) {
- typereg::Reader reader(manager->getTypeReader((*iter).replace('.', '/')));
-
+ rtl::Reference< unoidl::Entity > ent;
+ codemaker::UnoType::Sort sort = manager->getSort(*iter, &ent);
if ( !services.empty() ) {
- if ( options.supportpropertysetmixin && reader.getSuperTypeCount() > 0 )
+ if (options.supportpropertysetmixin
+ && (sort
+ == codemaker::UnoType::SORT_SINGLE_INTERFACE_BASED_SERVICE))
{
- typereg::Reader supertype(
- manager->getTypeReader(
- codemaker::convertString(
- reader.getSuperTypeName(0))));
- if ( !supertype.isValid() ) {
- throw CannotDumpException(
- "Bad type library entity "
- + reader.getSuperTypeName(0));
- }
-
- checkAttributes(manager, supertype, attributes, propinterfaces);
-
- if ( !(attributes.empty() || propinterfaces.empty()) ) {
- return OUStringToOString(
- supertype.getTypeName().replace('/', '.'),
- osl_getThreadTextEncoding());
+ rtl::Reference< unoidl::SingleInterfaceBasedServiceEntity >
+ ent2(
+ dynamic_cast<
+ unoidl::SingleInterfaceBasedServiceEntity * >(
+ ent.get()));
+ assert(ent2.is());
+ checkAttributes(
+ manager, ent2->getBase(), attributes, propinterfaces);
+ if (!(attributes.empty() || propinterfaces.empty())) {
+ return ent2->getBase();
}
} else {
- oldStyleWithProperties = checkServiceProperties(manager, reader);
+ oldStyleWithProperties = checkServiceProperties(manager, *iter);
}
} else {
- checkAttributes(manager, reader, attributes, propinterfaces);
- if ( !(attributes.empty() || propinterfaces.empty()) ) {
- return OUStringToOString(
- reader.getTypeName().replace('/', '.'),
- osl_getThreadTextEncoding());
+ checkAttributes(manager, *iter, attributes, propinterfaces);
+ if (!(attributes.empty() || propinterfaces.empty())) {
+ return *iter;
}
}
++iter;
}
- return (oldStyleWithProperties ? "_" : "");
+ return oldStyleWithProperties ? OUString("_") : OUString();
}
-bool checkXComponentSupport(rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader)
+bool checkXComponentSupport(
+ rtl::Reference< TypeManager > const & manager, OUString const & name)
{
- static OUString s( "com/sun/star/lang/XComponent");
- if ( reader.getTypeName().equals(s) )
+ assert(manager.is());
+ if (name == "com.sun.star.lang.XComponent") {
return true;
-
- for ( sal_uInt16 i = 0; i < reader.getSuperTypeCount(); ++i ) {
- typereg::Reader super(
- manager->getTypeReader(
- codemaker::convertString(
- reader.getSuperTypeName(i))));
- if ( !super.isValid() ) {
- throw CannotDumpException(
- "Bad type library entity " + reader.getSuperTypeName(i));
- }
- if ( checkXComponentSupport(manager, super) )
+ }
+ rtl::Reference< unoidl::Entity > ent;
+ codemaker::UnoType::Sort sort = manager->getSort(name, &ent);
+ if (sort != codemaker::UnoType::SORT_INTERFACE_TYPE) {
+ throw CannotDumpException(
+ "unexpected entity \"" + name
+ + "\" in call to skeletonmaker::checkXComponentSupport");
+ }
+ rtl::Reference< unoidl::InterfaceTypeEntity > ent2(
+ dynamic_cast< unoidl::InterfaceTypeEntity * >(ent.get()));
+ assert(ent2.is());
+ for (std::vector< OUString >::const_iterator i(
+ ent2->getDirectMandatoryBases().begin());
+ i != ent2->getDirectMandatoryBases().end(); ++i)
+ {
+ if (checkXComponentSupport(manager, *i)) {
return true;
+ }
}
-
return false;
}
@@ -395,20 +405,18 @@ bool checkXComponentSupport(rtl::Reference< TypeManager > const & manager,
// if XComponent is directly specified, return true and remove it from the
// supported interfaces list
bool checkXComponentSupport(rtl::Reference< TypeManager > const & manager,
- boost::unordered_set< OString, OStringHash >& interfaces)
+ std::set< OUString >& interfaces)
{
if ( interfaces.empty() )
return false;
- boost::unordered_set< OString, OStringHash >::const_iterator iter =
- interfaces.begin();
+ std::set< OUString >::const_iterator iter = interfaces.begin();
while ( iter != interfaces.end() ) {
if ( (*iter).equals("com.sun.star.lang.XComponent") ) {
interfaces.erase("com.sun.star.lang.XComponent");
return true;
}
- typereg::Reader reader(manager->getTypeReader((*iter).replace('.', '/')));
- if ( checkXComponentSupport(manager, reader) )
+ if ( checkXComponentSupport(manager, *iter) )
return true;
++iter;
}
@@ -416,60 +424,48 @@ bool checkXComponentSupport(rtl::Reference< TypeManager > const & manager,
return false;
}
-sal_uInt16 checkAdditionalPropertyFlags(typereg::Reader const & reader,
- sal_uInt16 field, sal_uInt16 method)
+unoidl::AccumulationBasedServiceEntity::Property::Attributes
+checkAdditionalPropertyFlags(
+ unoidl::InterfaceTypeEntity::Attribute const & attribute)
{
- sal_uInt16 flags = 0;
+ int flags = 0;
bool getterSupportsUnknown = false;
-
- OUString su( "com/sun/star/beans/UnknownPropertyException");
- if ( method < reader.getMethodCount()
- && reader.getMethodFlags(method) == RT_MODE_ATTRIBUTE_GET
- && reader.getMethodName(method) == reader.getFieldName(field) )
+ for (std::vector< OUString >::const_iterator i(
+ attribute.getExceptions.begin());
+ i != attribute.getExceptions.end(); ++i)
{
- if ( reader.getMethodExceptionCount(method) > 0 ) {
- for ( sal_uInt16 i = 0; i < reader.getMethodExceptionCount(method);
- ++i )
- {
- if (su.equals(reader.getMethodExceptionTypeName(method, i)))
- getterSupportsUnknown = true;
- }
+ if (*i == "com.sun.star.beans.UnknownPropertyException") {
+ getterSupportsUnknown = true;
}
- method++;
}
- if ( method < reader.getMethodCount()
- && reader.getMethodFlags(method) == RT_MODE_ATTRIBUTE_SET
- && reader.getMethodName(method) == reader.getFieldName(field) )
+ for (std::vector< OUString >::const_iterator i(
+ attribute.setExceptions.begin());
+ i != attribute.setExceptions.end(); ++i)
{
- if ( reader.getMethodExceptionCount(method) > 0 ) {
- OUString s( "com/sun/star/beans/PropertyVetoException");
- for ( sal_uInt16 i = 0; i < reader.getMethodExceptionCount(method);
- ++i )
- {
- if ( s.equals(reader.getMethodExceptionTypeName(method, i)) )
- flags |= RT_ACCESS_CONSTRAINED;
- if ( getterSupportsUnknown &&
- su.equals(reader.getMethodExceptionTypeName(method, i)) )
- flags |= RT_ACCESS_OPTIONAL;
- }
+ if (*i == "com.sun.star.beans.PropertyVetoException") {
+ flags |= unoidl::AccumulationBasedServiceEntity::Property::
+ ATTRIBUTE_CONSTRAINED;
+ } else if (getterSupportsUnknown
+ && *i == "com.sun.star.beans.UnknownPropertyException")
+ {
+ flags |= unoidl::AccumulationBasedServiceEntity::Property::
+ ATTRIBUTE_OPTIONAL;
}
}
- return flags;
+ return unoidl::AccumulationBasedServiceEntity::Property::Attributes(flags);
}
// This function checks if the specified types for parameters and return
// types are allowed add-in types, for more info see the com.sun.star.sheet.AddIn
// service description
bool checkAddinType(rtl::Reference< TypeManager > const & manager,
- OString const & type, bool & bLastAny,
+ OUString const & type, bool & bLastAny,
bool & bHasXPropertySet, bool bIsReturn)
{
- RTTypeClass typeClass;
- OString name;
+ assert(manager.is());
sal_Int32 rank;
- std::vector< OString > arguments;
- codemaker::UnoType::Sort sort = codemaker::decomposeAndResolve(
- manager, type, true, true, true, &typeClass, &name, &rank, &arguments);
+ codemaker::UnoType::Sort sort = manager->decompose(
+ type, true, 0, &rank, 0, 0);
if ( sort == codemaker::UnoType::SORT_LONG ||
sort == codemaker::UnoType::SORT_DOUBLE ||
@@ -490,14 +486,13 @@ bool checkAddinType(rtl::Reference< TypeManager > const & manager,
return true;
}
}
- if ( sort == codemaker::UnoType::SORT_COMPLEX &&
- typeClass == RT_TYPE_INTERFACE )
+ if ( sort == codemaker::UnoType::SORT_INTERFACE_TYPE )
{
- if ( bIsReturn && type.equals("com/sun/star/sheet/XVolatileResult") )
+ if ( bIsReturn && type == "com.sun.star.sheet.XVolatileResult" )
return true;
- if ( !bIsReturn && type.equals("com/sun/star/table/XCellRange") )
+ if ( !bIsReturn && type == "com.sun.star.table.XCellRange" )
return true;
- if ( !bIsReturn && type.equals("com/sun/star/beans/XPropertySet") )
+ if ( !bIsReturn && type == "com.sun.star.beans.XPropertySet" )
{
if ( bHasXPropertySet ) {
return false;
@@ -510,39 +505,40 @@ bool checkAddinType(rtl::Reference< TypeManager > const & manager,
return false;
}
-void checkAddInTypes(rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader)
+void checkAddInTypes(
+ rtl::Reference< TypeManager > const & manager, OUString const & name,
+ rtl::Reference< unoidl::InterfaceTypeEntity > const & entity)
{
- OString sType(codemaker::convertString(reader.getTypeName()).replace('/', '.'));
+ assert(entity.is());
bool bLastAny = false;
bool bHasXPropertySet = false;
- for ( sal_uInt16 m = 0; m < reader.getMethodCount(); ++m ) {
- OString sMethod(codemaker::convertString(reader.getMethodName(m)));
-
- OString sReturnType(codemaker::convertString(
- reader.getMethodReturnTypeName(m)));
+ for (std::vector< unoidl::InterfaceTypeEntity::Method >::const_iterator i(
+ entity->getDirectMethods().begin());
+ i != entity->getDirectMethods().end(); ++i)
+ {
if ( !checkAddinType(
- manager, sReturnType, bLastAny, bHasXPropertySet, true) )
+ manager, i->returnType, bLastAny, bHasXPropertySet, true) )
{
throw CannotDumpException(
- "the return type of the calc add-in function '" + b2u(sType)
- + ":" + b2u(sMethod)
+ "the return type of the calc add-in function '" + name
+ + ":" + i->name
+ "' is invalid. Please check your IDL defintion.");
}
bHasXPropertySet = false;
- for ( sal_uInt16 p = 0; p < reader.getMethodParameterCount(m); ++p ) {
+ for (std::vector< unoidl::InterfaceTypeEntity::Method::Parameter >::
+ const_iterator j(i->parameters.begin());
+ j != i->parameters.end(); ++j)
+ {
bLastAny = false;
- OString sParamType(codemaker::convertString(
- reader.getMethodParameterTypeName(m, p)));
- if ( !checkAddinType(manager, sParamType,
+ if ( !checkAddinType(manager, j->type,
bLastAny, bHasXPropertySet, false) ||
bLastAny )
{
throw CannotDumpException(
- "the type of the " + OUString::number(p + 1)
- + ". parameter of the calc add-in function '" + b2u(sType)
- + ":" + b2u(sMethod) + "' is invalid."
+ "the type of the " + j->name
+ + " parameter of the calc add-in function '" + name
+ + ":" + i->name + "' is invalid."
+ (bLastAny
? OUString(
" The type 'sequence<any>' is allowed as last"
@@ -558,49 +554,55 @@ void checkAddInTypes(rtl::Reference< TypeManager > const & manager,
}
}
-void generateFunctionParamterMap(std::ostream& o,
+void generateFunctionParameterMap(std::ostream& o,
ProgramOptions const & options,
rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader,
+ OUString const & name,
::codemaker::GeneratedTypeSet & generated,
bool bFirst)
{
- OString sType(codemaker::convertString(reader.getTypeName()));
- if ( sType.equals("com/sun/star/uno/XInterface") ||
- sType.equals("com/sun/star/lang/XLocalizable") ||
- sType.equals("com/sun/star/lang/XServiceInfo") ||
+ if ( name == "com.sun.star.uno.XInterface" ||
+ name == "com.sun.star.lang.XLocalizable" ||
+ name == "com.sun.star.lang.XServiceInfo" ||
// the next three checks becomes obsolete when configuration is used
- sType.equals("com/sun/star/sheet/XAddIn") ||
- sType.equals("com/sun/star/sheet/XCompatibilityNames") ||
- sType.equals("com/sun/star/lang/XServiceName") )
+ name == "com.sun.star.sheet.XAddIn" ||
+ name == "com.sun.star.sheet.XCompatibilityNames" ||
+ name == "com.sun.star.lang.XServiceName" )
{
return;
}
+ rtl::Reference< unoidl::Entity > ent;
+ codemaker::UnoType::Sort sort = manager->getSort(name, &ent);
+ if (sort != codemaker::UnoType::SORT_INTERFACE_TYPE) {
+ throw CannotDumpException(
+ "unexpected entity \"" + name
+ + "\" in call to skeletonmaker::generateFunctionParameterMap");
+ }
+ rtl::Reference< unoidl::InterfaceTypeEntity > ent2(
+ dynamic_cast< unoidl::InterfaceTypeEntity * >(ent.get()));
+ assert(ent2.is());
+
// check if the specified add-in functions supports valid types
- checkAddInTypes(manager, reader);
-
- for ( sal_uInt16 i = 0; i < reader.getSuperTypeCount(); ++i ) {
- typereg::Reader super(
- manager->getTypeReader(
- codemaker::convertString(
- reader.getSuperTypeName(i))));
- if ( !super.isValid() ) {
- throw CannotDumpException(
- "Bad type library entity " + reader.getSuperTypeName(i));
- }
- generateFunctionParamterMap(o, options, manager, super, generated, bFirst);
+ checkAddInTypes(manager, name, ent2);
+
+ for (std::vector< OUString >::const_iterator i(
+ ent2->getDirectMandatoryBases().begin());
+ i != ent2->getDirectMandatoryBases().end(); ++i)
+ {
+ generateFunctionParameterMap(
+ o, options, manager, *i, generated, bFirst);
}
- OString type(codemaker::convertString(reader.getTypeName()));
- if ( generated.contains(type) )
+ if ( generated.contains(u2b(name)) )
return;
else
- generated.add(type);
-
- for ( sal_uInt16 m = 0; m < reader.getMethodCount(); ++m ) {
- OString sMethod(codemaker::convertString(reader.getMethodName(m)));
+ generated.add(u2b(name));
+ for (std::vector< unoidl::InterfaceTypeEntity::Method >::const_iterator i(
+ ent2->getDirectMethods().begin());
+ i != ent2->getDirectMethods().end(); ++i)
+ {
if ( bFirst ) {
if (options.language == 2) {
o << " ParamMap fpm;\n";
@@ -626,33 +628,37 @@ void generateFunctionParamterMap(std::ostream& o,
o << " fpm = new java.util.Hashtable();\n";
}
- for ( sal_uInt16 p = 0; p < reader.getMethodParameterCount(m); ++p ) {
+ std::vector< unoidl::InterfaceTypeEntity::Method::Parameter >::size_type
+ n = 0;
+ for (std::vector< unoidl::InterfaceTypeEntity::Method::Parameter >::
+ const_iterator j(i->parameters.begin());
+ j != i->parameters.end(); ++j)
+ {
if ( options.language == 2 ) {
- o << " fpm[" << p
+ o << " fpm[" << n
<< "] = ::rtl::OUString(\""
- << codemaker::convertString(reader.getMethodParameterName(m, p))
+ << j->name
<< "\");\n";
}
else {
if ( options.java5 )
- o << " fpm.put(" << p << ", \""
- << codemaker::convertString(
- reader.getMethodParameterName(m, p))
+ o << " fpm.put(" << n << ", \""
+ << j->name
<< "\");\n";
else
- o << " fpm.put(new Integer(" << p << "), \""
- << codemaker::convertString(
- reader.getMethodParameterName(m, p))
+ o << " fpm.put(new Integer(" << n << "), \""
+ << j->name
<< "\");\n";
}
+ ++n;
}
if ( options.language == 2 ) {
o << " m_functionMap[::rtl::OUString(\""
- << sMethod << "\")] = fpm;\n\n";
+ << i->name << "\")] = fpm;\n\n";
}
else {
- o << " m_functionMap.put(\"" << sMethod << "\", fpm);\n\n";
+ o << " m_functionMap.put(\"" << i->name << "\", fpm);\n\n";
}
}
}
@@ -660,19 +666,13 @@ void generateFunctionParamterMap(std::ostream& o,
void generateFunctionParameterMap(std::ostream& o,
ProgramOptions const & options,
rtl::Reference< TypeManager > const & manager,
- const boost::unordered_set< OString, OStringHash >& interfaces)
+ const std::set< OUString >& interfaces)
{
::codemaker::GeneratedTypeSet generated;
bool bFirst = true;
- boost::unordered_set< OString, OStringHash >::const_iterator iter = interfaces.begin();
+ std::set< OUString >::const_iterator iter = interfaces.begin();
while ( iter != interfaces.end() ) {
- typereg::Reader reader(manager->getTypeReader((*iter).replace('.','/')));
- if (!reader.isValid()) {
- throw CannotDumpException(
- "Bad type library entity " + reader.getTypeName());
- }
-
- generateFunctionParamterMap(o, options, manager, reader, generated, bFirst);
+ generateFunctionParameterMap(o, options, manager, *iter, generated, bFirst);
++iter;
}
}
diff --git a/unodevtools/source/skeletonmaker/skeletoncommon.hxx b/unodevtools/source/skeletonmaker/skeletoncommon.hxx
index c4f8245926e9..48425b119be3 100644
--- a/unodevtools/source/skeletonmaker/skeletoncommon.hxx
+++ b/unodevtools/source/skeletonmaker/skeletoncommon.hxx
@@ -23,22 +23,21 @@
#include "rtl/ref.hxx"
#include "rtl/string.hxx"
-#include "registry/reader.hxx"
#include "codemaker/typemanager.hxx"
#include "codemaker/unotype.hxx"
+#include "unoidl/unoidl.hxx"
#include <fstream>
-#include <boost/unordered_set.hpp>
#include <map>
+#include <set>
namespace skeletonmaker {
typedef ::std::map< OString, ::std::vector< OString >,
::std::less< OString > > ProtocolCmdMap;
-typedef ::std::vector< ::std::pair< OString,
- ::std::pair< OString, sal_Int16 > > > AttributeInfo;
-
+typedef ::std::vector< unoidl::AccumulationBasedServiceEntity::Property >
+AttributeInfo;
struct ProgramOptions {
ProgramOptions(): java5(true), all(false), dump(false), license(false),
@@ -97,42 +96,23 @@ bool getOutputStream(ProgramOptions const & options,
OString & targetSourceFileName,
OString & tmpSourceFileName);
-codemaker::UnoType::Sort decomposeResolveAndCheck(
- rtl::Reference< TypeManager > const & manager, OString const & type,
- bool resolveTypedefs, bool allowVoid, bool allowExtraEntities,
- RTTypeClass * typeClass, OString * name, sal_Int32 * rank,
- std::vector< OString > * arguments);
-
void checkType(rtl::Reference< TypeManager > const & manager,
- OString const & type,
- boost::unordered_set< OString, OStringHash >& interfaceTypes,
- boost::unordered_set< OString, OStringHash >& serviceTypes,
+ OUString const & type,
+ std::set< OUString >& interfaceTypes,
+ std::set< OUString >& serviceTypes,
AttributeInfo& properties);
void checkDefaultInterfaces(
- boost::unordered_set< OString, OStringHash >& interfaces,
- const boost::unordered_set< OString, OStringHash >& services,
- const OString & propertyhelper);
+ std::set< OUString >& interfaces,
+ const std::set< OUString >& services,
+ const OUString & propertyhelper);
-OString checkPropertyHelper(
+OUString checkPropertyHelper(
ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- const boost::unordered_set< OString, OStringHash >& services,
- const boost::unordered_set< OString, OStringHash >& interfaces,
+ const std::set< OUString >& services,
+ const std::set< OUString >& interfaces,
AttributeInfo& attributes,
- boost::unordered_set< OString, OStringHash >& propinterfaces);
-
-/**
- checks whether the return and parameters types are valid and allowed
- calc add-in type. The function throws a CannotDumpException with an
- detailed error description which type is wrong
-
- @param manager a type manager
- @param reader a registry type reader of an interface defining
- calc add-in functions
-*/
-void checkAddInTypes(rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader);
-
+ std::set< OUString >& propinterfaces);
/**
checks if XComponent have to be supported, if yes it removes it from the
@@ -145,17 +125,17 @@ void checkAddInTypes(rtl::Reference< TypeManager > const & manager,
@return true if XComponent have to be supported
*/
bool checkXComponentSupport(rtl::Reference< TypeManager > const & manager,
- boost::unordered_set< OString, OStringHash >& interfaces);
-
+ std::set< OUString >& interfaces);
-sal_uInt16 checkAdditionalPropertyFlags(typereg::Reader const & reader,
- sal_uInt16 field, sal_uInt16 method);
+unoidl::AccumulationBasedServiceEntity::Property::Attributes
+checkAdditionalPropertyFlags(
+ unoidl::InterfaceTypeEntity::Attribute const & attribute);
void generateFunctionParameterMap(std::ostream& o,
ProgramOptions const & options,
rtl::Reference< TypeManager > const & manager,
- const boost::unordered_set< OString, OStringHash >& interfaces);
+ const std::set< OUString >& interfaces);
}
diff --git a/unodevtools/source/skeletonmaker/skeletoncpp.hxx b/unodevtools/source/skeletonmaker/skeletoncpp.hxx
index 6c7aed726b27..7f923c4dbe0e 100644
--- a/unodevtools/source/skeletonmaker/skeletoncpp.hxx
+++ b/unodevtools/source/skeletonmaker/skeletoncpp.hxx
@@ -33,84 +33,20 @@ namespace skeletonmaker { namespace cpp {
// 4 = const reference (includes css::uno::Reference for interfaces)
// 8 = default construction for example for return types, means "return <type>();"
// 16 = default member initialization in a constructor
-void printType(std::ostream & o,
- ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- codemaker::UnoType::Sort sort, RTTypeClass typeClass,
- OString const & name, sal_Int32 rank,
- std::vector< OString > const & arguments,
- short referenceType, bool defaultvalue=false);
-
-void printType(std::ostream & o,
- ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- OString const & type, short referenceType,
- bool defaultvalue=false);
-
-
-bool printConstructorParameters(std::ostream & o,
- ProgramOptions const & options,
- rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader,
- typereg::Reader const & outerReader,
- std::vector< OString > const & arguments);
-
-
-void printConstructor(std::ostream & o,
- ProgramOptions const & options,
- rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader,
- std::vector< OString > const & arguments);
-
-
-void printMethodParameters(std::ostream & o,
- ProgramOptions const & options,
- rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader,
- sal_uInt16 method, bool previous,
- bool withtype);
-
-
-void printExceptionSpecification(std::ostream & o,
- ProgramOptions const & options,
- rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader,
- sal_uInt16 method);
-
+void printType(
+ std::ostream & o, ProgramOptions const & options,
+ rtl::Reference< TypeManager > const & manager, OUString const & name,
+ short referenceType, bool defaultvalue = false);
void printMethods(std::ostream & o,
ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader,
+ OUString const & name,
codemaker::GeneratedTypeSet & generated,
OString const & delegate,
OString const & classname=OString(),
OString const & indentation=OString(),
bool defaultvalue=false,
- OString const & propertyhelper=OString());
-
-
-void printConstructionMethods(std::ostream & o,
- ProgramOptions const & options,
- rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader);
-
-
-void printServiceMembers(std::ostream & o,
- ProgramOptions const & options,
- rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader,
- OString const & type,
- OString const & delegate);
-
-
-void printMapsToCppType(std::ostream & o,
- ProgramOptions const & options,
- rtl::Reference< TypeManager > const & manager,
- codemaker::UnoType::Sort sort,
- RTTypeClass typeClass,
- OString const & name,
- sal_Int32 rank,
- std::vector< OString > const & arguments,
- const char * cppTypeSort);
-
+ OUString const & propertyhelper=OUString());
void generateDocumentation(std::ostream & o,
ProgramOptions const & options,
diff --git a/unodevtools/source/skeletonmaker/skeletonjava.hxx b/unodevtools/source/skeletonmaker/skeletonjava.hxx
index 4ff907f4088b..39269026740f 100644
--- a/unodevtools/source/skeletonmaker/skeletonjava.hxx
+++ b/unodevtools/source/skeletonmaker/skeletonjava.hxx
@@ -26,73 +26,20 @@
namespace skeletonmaker { namespace java {
-void printType(std::ostream & o,
- ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- codemaker::UnoType::Sort sort, RTTypeClass typeClass,
- OString const & name, sal_Int32 rank,
- std::vector< OString > const & arguments,
- bool referenceType, bool defaultvalue=false);
-
-void printType(std::ostream & o,
- ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- OString const & type, bool referenceType,
- bool defaultvalue=false);
-
-bool printConstructorParameters(std::ostream & o,
- ProgramOptions const & options,
- rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader,
- typereg::Reader const & outerReader,
- std::vector< OString > const & arguments);
-
-void printConstructor(std::ostream & o,
- ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader,
- std::vector< OString > const & arguments);
-
-void printMethodParameters(std::ostream & o,
- ProgramOptions const & options,
- rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader,
- sal_uInt16 method, bool previous,
- bool withtype);
-
-void printExceptionSpecification(std::ostream & o,
- ProgramOptions const & options,
- rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader,
- sal_uInt16 method);
+void printType(
+ std::ostream & o, ProgramOptions const & options,
+ rtl::Reference< TypeManager > const & manager, OUString const & name,
+ bool referenceType, bool defaultvalue = false);
void printMethods(std::ostream & o,
ProgramOptions const & options, rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader,
+ OUString const & name,
codemaker::GeneratedTypeSet & generated,
OString const & delegate,
OString const & indentation=OString(),
bool defaultvalue=false,
bool usepropertymixin=false);
-void printConstructionMethods(std::ostream & o,
- ProgramOptions const & options,
- rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader);
-
-void printServiceMembers(std::ostream & o,
- ProgramOptions const & options,
- rtl::Reference< TypeManager > const & manager,
- typereg::Reader const & reader,
- OString const & type,
- OString const & delegate);
-
-void printMapsToJavaType(std::ostream & o,
- ProgramOptions const & options,
- rtl::Reference< TypeManager > const & manager,
- codemaker::UnoType::Sort sort,
- RTTypeClass typeClass,
- OString const & name, sal_Int32 rank,
- std::vector< OString > const & arguments,
- const char * javaTypeSort);
-
void generateDocumentation(std::ostream & o,
ProgramOptions const & options,
rtl::Reference< TypeManager > const & manager,
diff --git a/unodevtools/source/skeletonmaker/skeletonmaker.cxx b/unodevtools/source/skeletonmaker/skeletonmaker.cxx
index b3937932ee7d..c601245d85c2 100644
--- a/unodevtools/source/skeletonmaker/skeletonmaker.cxx
+++ b/unodevtools/source/skeletonmaker/skeletonmaker.cxx
@@ -22,6 +22,8 @@
#include "sal/main.h"
#include "rtl/process.h"
#include "unodevtools/options.hxx"
+#include "unoidl/unoidl.hxx"
+
#include "skeletonjava.hxx"
#include "skeletoncpp.hxx"
@@ -266,11 +268,10 @@ SAL_IMPLEMENT_MAIN()
}
rtl::Reference< TypeManager > manager(new TypeManager);
- if ( !manager->init(registries) ) {
- std::cerr
- << ("\nError: Using the binary type libraries failed, check the -L"
- " options\n");
- exit(EXIT_FAILURE);
+ for (std::vector< OString >::const_iterator i(registries.begin());
+ i != registries.end(); ++i)
+ {
+ manager->loadProvider(b2u(*i), true);
}
if ( options.dump ) {
@@ -309,9 +310,17 @@ SAL_IMPLEMENT_MAIN()
}
}
- } catch (const CannotDumpException & e) {
- std::cout.flush();
- std::cerr << "\nError: " << e.getMessage() << std::endl;
+ } catch (CannotDumpException & e) {
+ std::cerr << "ERROR: " << e.getMessage() << '\n';
+ return EXIT_FAILURE;
+ } catch (unoidl::NoSuchFileException & e) {
+ std::cerr << "ERROR: No such file <" << e.getUri() << ">\n";
+ return EXIT_FAILURE;
+ } catch (unoidl::FileFormatException & e) {
+ std::cerr
+ << "ERROR: Bad format of <" << e.getUri() << ">, \""
+ << e.getDetail() << "\"\n";
+ return EXIT_FAILURE;
}
return 0;