INTEGRATION: CWS jsc3 (1.35.14); FILE MERGED

2006/02/28 08:20:01 jsc 1.35.14.7: #i62183# change comment
2006/02/21 13:32:33 jsc 1.35.14.6: #i62183# resolve merge conflicts
2006/02/20 11:25:11 jsc 1.35.14.5: RESYNC: (1.36-1.37); FILE MERGED
2006/02/17 16:44:56 jsc 1.35.14.4: #i56247# exchange forward declaration with include
2006/02/17 15:58:17 jsc 1.35.14.3: #62183# re- declare ambiguous base interface methods
2006/01/20 13:39:00 jsc 1.35.14.2: RESYNC: (1.35-1.36); FILE MERGED
2006/01/20 13:01:47 jsc 1.35.14.1: #i53950# refactor translateIdentifier to translateUnoToCppIdentifer
This commit is contained in:
Vladimir Glazounov
2006-03-15 08:13:51 +00:00
parent 2eaa59ef4a
commit f14849d780

View File

@@ -4,9 +4,9 @@
* *
* $RCSfile: cpputype.cxx,v $ * $RCSfile: cpputype.cxx,v $
* *
* $Revision: 1.38 $ * $Revision: 1.39 $
* *
* last change: $Author: rt $ $Date: 2006-03-09 10:26:41 $ * last change: $Author: vg $ $Date: 2006-03-15 09:13:51 $
* *
* The Contents of this file are made available subject to * The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1. * the terms of GNU Lesser General Public License Version 2.1.
@@ -55,6 +55,7 @@
#include "includes.hxx" #include "includes.hxx"
using namespace rtl; using namespace rtl;
using namespace codemaker::cpp;
namespace { namespace {
@@ -68,216 +69,6 @@ rtl::OString translateSimpleUnoType(rtl::OString const & unoType) {
return trans[codemaker::UnoType::getSort(unoType)]; return trans[codemaker::UnoType::getSort(unoType)];
} }
rtl::OString translateIdentifier(
rtl::OString const & unoIdentifier, rtl::OString const & prefix,
bool global, rtl::OString const * forbidden = 0)
{
if (// Keywords:
unoIdentifier == "asm"
|| unoIdentifier == "auto"
|| unoIdentifier == "bool"
|| unoIdentifier == "break"
|| unoIdentifier == "case"
|| unoIdentifier == "catch"
|| unoIdentifier == "char"
|| unoIdentifier == "class"
|| unoIdentifier == "const"
/* unoIdentifier == "const_cast" */
|| unoIdentifier == "continue"
|| unoIdentifier == "default"
|| unoIdentifier == "delete"
|| unoIdentifier == "do"
|| unoIdentifier == "double"
/* unoIdentifier == "dynamic_cast" */
|| unoIdentifier == "else"
|| unoIdentifier == "enum"
|| unoIdentifier == "explicit"
|| unoIdentifier == "export"
|| unoIdentifier == "extern"
|| unoIdentifier == "false"
|| unoIdentifier == "float"
|| unoIdentifier == "for"
|| unoIdentifier == "friend"
|| unoIdentifier == "goto"
|| unoIdentifier == "if"
|| unoIdentifier == "inline"
|| unoIdentifier == "int"
|| unoIdentifier == "long"
|| unoIdentifier == "mutable"
|| unoIdentifier == "namespace"
|| unoIdentifier == "new"
|| unoIdentifier == "operator"
|| unoIdentifier == "private"
|| unoIdentifier == "protected"
|| unoIdentifier == "public"
|| unoIdentifier == "register"
/* unoIdentifier == "reinterpret_cast" */
|| unoIdentifier == "return"
|| unoIdentifier == "short"
|| unoIdentifier == "signed"
|| unoIdentifier == "sizeof"
|| unoIdentifier == "static"
/* unoIdentifier == "static_cast" */
|| unoIdentifier == "struct"
|| unoIdentifier == "switch"
|| unoIdentifier == "template"
|| unoIdentifier == "this"
|| unoIdentifier == "throw"
|| unoIdentifier == "true"
|| unoIdentifier == "try"
|| unoIdentifier == "typedef"
|| unoIdentifier == "typeid"
|| unoIdentifier == "typename"
|| unoIdentifier == "union"
|| unoIdentifier == "unsigned"
|| unoIdentifier == "using"
|| unoIdentifier == "virtual"
|| unoIdentifier == "void"
|| unoIdentifier == "volatile"
/* unoIdentifier == "wchar_t" */
|| unoIdentifier == "while"
// Alternative representations:
|| unoIdentifier == "and"
/* unoIdentifier == "and_eq" */
|| unoIdentifier == "bitand"
|| unoIdentifier == "bitor"
|| unoIdentifier == "compl"
|| unoIdentifier == "not"
/* unoIdentifier == "not_eq" */
|| unoIdentifier == "or"
/* unoIdentifier == "or_eq" */
|| unoIdentifier == "xor"
/* unoIdentifier == "xor_eq" */
// Standard macros:
|| unoIdentifier == "BUFSIZ"
|| unoIdentifier == "CLOCKS_PER_SEC"
|| unoIdentifier == "EDOM"
|| unoIdentifier == "EOF"
|| unoIdentifier == "ERANGE"
|| unoIdentifier == "EXIT_FAILURE"
|| unoIdentifier == "EXIT_SUCCESS"
|| unoIdentifier == "FILENAME_MAX"
|| unoIdentifier == "FOPEN_MAX"
|| unoIdentifier == "HUGE_VAL"
|| unoIdentifier == "LC_ALL"
|| unoIdentifier == "LC_COLLATE"
|| unoIdentifier == "LC_CTYPE"
|| unoIdentifier == "LC_MONETARY"
|| unoIdentifier == "LC_NUMERIC"
|| unoIdentifier == "LC_TIME"
|| unoIdentifier == "L_tmpnam"
|| unoIdentifier == "MB_CUR_MAX"
|| unoIdentifier == "NULL"
|| unoIdentifier == "RAND_MAX"
|| unoIdentifier == "SEEK_CUR"
|| unoIdentifier == "SEEK_END"
|| unoIdentifier == "SEEK_SET"
|| unoIdentifier == "SIGABRT"
|| unoIdentifier == "SIGFPE"
|| unoIdentifier == "SIGILL"
|| unoIdentifier == "SIGINT"
|| unoIdentifier == "SIGSEGV"
|| unoIdentifier == "SIGTERM"
|| unoIdentifier == "SIG_DFL"
|| unoIdentifier == "SIG_ERR"
|| unoIdentifier == "SIG_IGN"
|| unoIdentifier == "TMP_MAX"
|| unoIdentifier == "WCHAR_MAX"
|| unoIdentifier == "WCHAR_MIN"
|| unoIdentifier == "WEOF"
/* unoIdentifier == "_IOFBF" */
/* unoIdentifier == "_IOLBF" */
/* unoIdentifier == "_IONBF" */
|| unoIdentifier == "assert"
|| unoIdentifier == "errno"
|| unoIdentifier == "offsetof"
|| unoIdentifier == "setjmp"
|| unoIdentifier == "stderr"
|| unoIdentifier == "stdin"
|| unoIdentifier == "stdout"
/* unoIdentifier == "va_arg" */
/* unoIdentifier == "va_end" */
/* unoIdentifier == "va_start" */
// Standard values:
|| unoIdentifier == "CHAR_BIT"
|| unoIdentifier == "CHAR_MAX"
|| unoIdentifier == "CHAR_MIN"
|| unoIdentifier == "DBL_DIG"
|| unoIdentifier == "DBL_EPSILON"
|| unoIdentifier == "DBL_MANT_DIG"
|| unoIdentifier == "DBL_MAX"
|| unoIdentifier == "DBL_MAX_10_EXP"
|| unoIdentifier == "DBL_MAX_EXP"
|| unoIdentifier == "DBL_MIN"
|| unoIdentifier == "DBL_MIN_10_EXP"
|| unoIdentifier == "DBL_MIN_EXP"
|| unoIdentifier == "FLT_DIG"
|| unoIdentifier == "FLT_EPSILON"
|| unoIdentifier == "FLT_MANT_DIG"
|| unoIdentifier == "FLT_MAX"
|| unoIdentifier == "FLT_MAX_10_EXP"
|| unoIdentifier == "FLT_MAX_EXP"
|| unoIdentifier == "FLT_MIN"
|| unoIdentifier == "FLT_MIN_10_EXP"
|| unoIdentifier == "FLT_MIN_EXP"
|| unoIdentifier == "FLT_RADIX"
|| unoIdentifier == "FLT_ROUNDS"
|| unoIdentifier == "INT_MAX"
|| unoIdentifier == "INT_MIN"
|| unoIdentifier == "LDBL_DIG"
|| unoIdentifier == "LDBL_EPSILON"
|| unoIdentifier == "LDBL_MANT_DIG"
|| unoIdentifier == "LDBL_MAX"
|| unoIdentifier == "LDBL_MAX_10_EXP"
|| unoIdentifier == "LDBL_MAX_EXP"
|| unoIdentifier == "LDBL_MIN"
|| unoIdentifier == "LDBL_MIN_10_EXP"
|| unoIdentifier == "LDBL_MIN_EXP"
|| unoIdentifier == "LONG_MAX"
|| unoIdentifier == "LONG_MIN"
|| unoIdentifier == "MB_LEN_MAX"
|| unoIdentifier == "SCHAR_MAX"
|| unoIdentifier == "SCHAR_MIN"
|| unoIdentifier == "SHRT_MAX"
|| unoIdentifier == "SHRT_MIN"
|| unoIdentifier == "UCHAR_MAX"
|| unoIdentifier == "UINT_MAX"
|| unoIdentifier == "ULONG_MAX"
|| unoIdentifier == "USHRT_MAX"
|| (global
&& (// Standard types:
/* unoIdentifier == "clock_t" */
/* unoIdentifier == "div_t" */
unoIdentifier == "FILE"
/* unoIdentifier == "fpos_t" */
/* unoIdentifier == "jmp_buf" */
|| unoIdentifier == "lconv"
/* unoIdentifier == "ldiv_t" */
/* unoIdentifier == "mbstate_t" */
/* unoIdentifier == "ptrdiff_t" */
/* unoIdentifier == "sig_atomic_t" */
/* unoIdentifier == "size_t" */
/* unoIdentifier == "time_t" */
|| unoIdentifier == "tm"
/* unoIdentifier == "va_list" */
/* unoIdentifier == "wctrans_t" */
/* unoIdentifier == "wctype_t" */
/* unoIdentifier == "wint_t" */
// Standard namespaces:
|| unoIdentifier == "std"))
// Others:
|| unoIdentifier == "NDEBUG"
|| forbidden != 0 && unoIdentifier == *forbidden)
{
rtl::OStringBuffer buf(prefix);
buf.append('_');
buf.append(unoIdentifier);
return buf.makeStringAndClear();
} else {
return unoIdentifier;
}
}
} }
//************************************************************************* //*************************************************************************
@@ -369,7 +160,8 @@ void CppuType::dumpGetCppuTypePreamble(FileStream & out) {
out << indent() out << indent()
<< "static inline ::com::sun::star::uno::Type const & get() {\n"; << "static inline ::com::sun::star::uno::Type const & get() {\n";
} else { } else {
if (codemaker::cppumaker::dumpNamespaceOpen(out, m_typeName, false)) { if (codemaker::cppumaker::dumpNamespaceOpen(out, m_typeMgr,
m_typeName, false)) {
out << "\n\n"; out << "\n\n";
} }
out << ("inline ::com::sun::star::uno::Type const &" out << ("inline ::com::sun::star::uno::Type const &"
@@ -605,7 +397,7 @@ void CppuType::dumpInitializer(
{ {
typereg::Reader reader(m_typeMgr.getTypeReader(t)); typereg::Reader reader(m_typeMgr.getTypeReader(t));
OSL_ASSERT(reader.isValid()); OSL_ASSERT(reader.isValid());
out << scopedName(rtl::OString(), t) << "_" out << scopedCppName(m_typeMgr, t) << "_"
<< rtl::OUStringToOString( << rtl::OUStringToOString(
reader.getFieldName(0), reader.getFieldName(0),
RTL_TEXTENCODING_UTF8); RTL_TEXTENCODING_UTF8);
@@ -919,8 +711,11 @@ void CppuType::dumpCppuGetTypeMemberDecl(FileStream& o, CppuTypeDecl eDeclFlag)
} }
} }
bool CppuType::isGlobal() const { IdentifierTranslationMode CppuType::isGlobal() const {
return m_typeName.indexOf('/') < 0; if ( m_typeName.indexOf('/') < 0 )
return ITM_GLOBAL;
else
return ITM_NONGLOBAL;
} }
sal_uInt32 CppuType::getMemberCount() sal_uInt32 CppuType::getMemberCount()
@@ -1098,9 +893,10 @@ void CppuType::dumpType(FileStream& o, const OString& type,
{ {
case RT_TYPE_INTERFACE: case RT_TYPE_INTERFACE:
if (bNative) if (bNative)
o << scopedName(m_typeName, relType); o << scopedCppName(m_typeMgr, relType);
else else
o << "::com::sun::star::uno::Reference< " << scopedName(m_typeName, relType) << " >"; o << "::com::sun::star::uno::Reference< "
<< scopedCppName(m_typeMgr, relType) << " >";
break; break;
case RT_TYPE_INVALID: case RT_TYPE_INVALID:
{ {
@@ -1109,7 +905,8 @@ void CppuType::dumpType(FileStream& o, const OString& type,
{ {
o << tmp; o << tmp;
} else } else
throw CannotDumpException("Unknown type '" + relType + "', incomplete type library."); throw CannotDumpException("Unknown type '" + relType +
"', incomplete type library.");
} }
break; break;
case RT_TYPE_STRUCT: case RT_TYPE_STRUCT:
@@ -1117,7 +914,7 @@ void CppuType::dumpType(FileStream& o, const OString& type,
case RT_TYPE_TYPEDEF: case RT_TYPE_TYPEDEF:
case RT_TYPE_EXCEPTION: case RT_TYPE_EXCEPTION:
{ {
o << scopedName(m_typeName, relType); o << scopedCppName(m_typeMgr, relType);
if (!args.empty()) { if (!args.empty()) {
o << "< "; o << "< ";
for (std::vector< rtl::OString >::iterator i(args.begin()); for (std::vector< rtl::OString >::iterator i(args.begin());
@@ -1464,7 +1261,7 @@ sal_Bool InterfaceType::dumpHFile(
o << ("\nnamespace com { namespace sun { namespace star { namespace uno {\n" o << ("\nnamespace com { namespace sun { namespace star { namespace uno {\n"
"class Type;\n} } } }\n\n"); "class Type;\n} } } }\n\n");
if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false)) { if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeMgr, m_typeName, false)) {
o << "\n"; o << "\n";
} }
dumpDeclaration(o); dumpDeclaration(o);
@@ -1480,23 +1277,118 @@ sal_Bool InterfaceType::dumpHFile(
return sal_True; return sal_True;
} }
/* collects all base interface of a given interface.
*/
void collectBases(TypeManager const & manager,
typereg::Reader const & reader,
StringSet & bases)
{
for (sal_Int16 i = 0; i < reader.getSuperTypeCount(); ++i)
{
OString supertype = rtl::OUStringToOString(
reader.getSuperTypeName(i), RTL_TEXTENCODING_UTF8);
if ( ! supertype.equals("com/sun/star/uno/XInterface") ) {
bases.insert(supertype);
typereg::Reader super(manager.getTypeReader(supertype));
collectBases(manager, super, bases);
}
}
}
/* collects ambiguous base interfaces by firstly collecting all bases
from the direct parents and secondly build an intersection of this
collected base sets.
*/
StringSet collectAmbiguousBases(TypeManager const & manager,
typereg::Reader const & reader)
{
std::vector< StringSet > basesets;
for (sal_Int16 i = 0; i < reader.getSuperTypeCount(); ++i)
{
OString superType = rtl::OUStringToOString(
reader.getSuperTypeName(i), RTL_TEXTENCODING_UTF8);
typereg::Reader super(manager.getTypeReader(superType));
StringSet bases;
collectBases(manager, super, bases);
basesets.push_back(bases);
}
StringSet ambiguousbases;
long index=1;
long length = static_cast< long >(basesets.size());
for (std::vector<StringSet>::const_iterator iter(basesets.begin());
iter != basesets.end(); ++iter)
{
for (long i=index; i < length; ++i)
{
std::set_intersection((*iter).begin(), (*iter).end(),
basesets[i].begin(), basesets[i].end(),
std::inserter(
ambiguousbases, ambiguousbases.begin()),
LessString());
}
++index;
}
return ambiguousbases;
}
/* dump the re-declaration of ambiguous base interfaces. It simply declares all
ambiguous methods and attribute methods again to avoid ambiguity.
*/
void InterfaceType::dumpAmbiguousBaseInterfaces(FileStream& o)
{
StringSet ambiguousBases = collectAmbiguousBases(m_typeMgr, m_reader);
if (ambiguousBases.size() > 0)
o << indent() << "// begin re-declaration of ambiguous base "
"interfaces";
for (StringSet::const_iterator i(ambiguousBases.begin());
i != ambiguousBases.end(); ++i)
{
typereg::Reader ambiguousreader(m_typeMgr.getTypeReader(*i));
if (ambiguousreader.isValid()) {
InterfaceType iType(ambiguousreader, *i, m_typeMgr);
o << "\n" << indent() << "// disambiguate "
<< iType.m_typeName.replace('/', '.') << ":";
iType.inc();
iType.dumpAttributes(o);
iType.dumpMethods(o);
}
}
if (ambiguousBases.size() > 0)
o << indent() << "// end re-declaration of ambiguous base "
"interfaces\n";
}
sal_Bool InterfaceType::dumpDeclaration(FileStream& o) sal_Bool InterfaceType::dumpDeclaration(FileStream& o)
throw( CannotDumpException ) throw( CannotDumpException )
{ {
// rtl::OString cppName(translateUnoToCppIdentifier(
// m_name, "interface", ITM_KEYWORDSONLY, &m_name));
// o << "\nclass SAL_NO_VTABLE " << cppName;
o << "\nclass SAL_NO_VTABLE " << m_name; o << "\nclass SAL_NO_VTABLE " << m_name;
for (sal_Int16 i = 0; i < m_reader.getSuperTypeCount(); ++i) { for (sal_Int16 i = 0; i < m_reader.getSuperTypeCount(); ++i) {
o << (i == 0 ? " :" : ",") << " public " o << (i == 0 ? " :" : ",") << " public "
<< scopedName( << scopedCppName(m_typeMgr, rtl::OUStringToOString(
m_typeName, m_reader.getSuperTypeName(i), RTL_TEXTENCODING_UTF8));
rtl::OUStringToOString(
m_reader.getSuperTypeName(i), RTL_TEXTENCODING_UTF8));
} }
o << "\n{\npublic:\n"; o << "\n{\npublic:\n";
inc(); inc();
dumpAmbiguousBaseInterfaces(o);
dumpAttributes(o); dumpAttributes(o);
dumpMethods(o); dumpMethods(o);
@@ -1523,8 +1415,11 @@ sal_Bool InterfaceType::dumpHxxFile(
dumpGetCppuType(o); dumpGetCppuType(o);
// rtl::OString cppName(translateUnoToCppIdentifier(
// m_name, "interface", ITM_KEYWORDSONLY, &m_name));
o << "\n::com::sun::star::uno::Type const & " o << "\n::com::sun::star::uno::Type const & "
<< scopedName(rtl::OString(), m_typeName) << scopedCppName(m_typeMgr, m_typeName)
<< "::static_type(void *) {\n"; << "::static_type(void *) {\n";
inc(); inc();
o << indent() << "return ::getCppuType(static_cast< "; o << indent() << "return ::getCppuType(static_cast< ";
@@ -1647,6 +1542,8 @@ void InterfaceType::dumpMethods(FileStream& o)
} }
dumpType(o, paramType, bConst, bRef); dumpType(o, paramType, bConst, bRef);
// o << " " << translateUnoToCppIdentifier(
// paramName, "param", ITM_KEYWORDSONLY, NULL);
o << " " << paramName; o << " " << paramName;
if (j+1 < (sal_uInt16)paramCount) o << ", "; if (j+1 < (sal_uInt16)paramCount) o << ", ";
@@ -2262,8 +2159,7 @@ void InterfaceType::dumpExceptionSpecification(
out << ", "; out << ", ";
} }
first = false; first = false;
out << scopedName( out << scopedCppName(m_typeMgr,
m_typeName,
rtl::OUStringToOString(name, RTL_TEXTENCODING_UTF8)); rtl::OUStringToOString(name, RTL_TEXTENCODING_UTF8));
} }
} }
@@ -2402,7 +2298,7 @@ sal_Bool ConstantsType::dumpHFile(
includes.dump(o, 0); includes.dump(o, 0);
o << "\n"; o << "\n";
if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, true)) { if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeMgr, m_typeName, true)) {
o << "\n"; o << "\n";
} }
o << "\n"; o << "\n";
@@ -2537,7 +2433,7 @@ sal_Bool StructureType::dumpHFile(
includes.dump(o, 0); includes.dump(o, 0);
o << "\n"; o << "\n";
if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false)) { if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeMgr, m_typeName, false)) {
o << "\n"; o << "\n";
} }
@@ -2581,7 +2477,7 @@ sal_Bool StructureType::dumpDeclaration(FileStream& o)
OSL_ASSERT(base.getLength() > 0); //TODO OSL_ASSERT(base.getLength() > 0); //TODO
} }
if (base.getLength() > 0) { if (base.getLength() > 0) {
o << ": public " << scopedName(m_typeName, base); o << ": public " << scopedCppName(m_typeMgr, base);
} }
o << " {\n"; o << " {\n";
inc(); inc();
@@ -2634,7 +2530,7 @@ sal_Bool StructureType::dumpDeclaration(FileStream& o)
&& type != "hyper" && type != "unsigned hyper") && type != "hyper" && type != "unsigned hyper")
{ {
OSL_ASSERT(!parameterized); OSL_ASSERT(!parameterized);
o << " CPPU_GCC3_ALIGN(" << scopedName(m_typeName, base) << ")"; o << " CPPU_GCC3_ALIGN(" << scopedCppName(m_typeMgr, base) << ")";
} }
o << ";\n"; o << ";\n";
} }
@@ -2661,7 +2557,7 @@ sal_Bool StructureType::dumpHxxFile(
includes.dump(o, &m_typeName); includes.dump(o, &m_typeName);
o << "\n"; o << "\n";
if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false)) { if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeMgr, m_typeName, false)) {
o << "\n"; o << "\n";
} }
o << "\n"; o << "\n";
@@ -2679,7 +2575,7 @@ sal_Bool StructureType::dumpHxxFile(
sal_Bool first = sal_True; sal_Bool first = sal_True;
if (superType.getLength() > 0) if (superType.getLength() > 0)
{ {
o << indent() << ": " << scopedName(m_typeName, superType) << "()\n"; o << indent() << ": " << scopedCppName(m_typeMgr, superType) << "()\n";
first = sal_False; first = sal_False;
} }
@@ -2756,7 +2652,7 @@ sal_Bool StructureType::dumpHxxFile(
sal_Bool first = sal_True; sal_Bool first = sal_True;
if (superType.getLength() > 0) if (superType.getLength() > 0)
{ {
o << indent() << ": " << scopedName(m_typeName, superType) << "("; o << indent() << ": " << scopedCppName(m_typeMgr, superType) << "(";
dumpSuperMember(o, superType, sal_False); dumpSuperMember(o, superType, sal_False);
o << ")\n"; o << ")\n";
first = sal_False; first = sal_False;
@@ -3246,7 +3142,7 @@ sal_Bool ExceptionType::dumpHFile(
includes.dump(o, 0); includes.dump(o, 0);
o << "\n"; o << "\n";
if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false)) { if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeMgr, m_typeName, false)) {
o << "\n"; o << "\n";
} }
@@ -3279,7 +3175,7 @@ sal_Bool ExceptionType::dumpDeclaration(FileStream& o)
m_reader.getSuperTypeName(0), RTL_TEXTENCODING_UTF8); m_reader.getSuperTypeName(0), RTL_TEXTENCODING_UTF8);
} }
if (superType.getLength() > 0) if (superType.getLength() > 0)
o << " : public " << scopedName(m_typeName, superType); o << " : public " << scopedCppName(m_typeMgr, superType);
o << "\n{\npublic:\n"; o << "\n{\npublic:\n";
inc(); inc();
@@ -3345,7 +3241,7 @@ sal_Bool ExceptionType::dumpDeclaration(FileStream& o)
if (i == 0 && superType.getLength() && if (i == 0 && superType.getLength() &&
!fieldType.equals("double") && !fieldType.equals("hyper") && !fieldType.equals("unsigned hyper")) !fieldType.equals("double") && !fieldType.equals("hyper") && !fieldType.equals("unsigned hyper"))
{ {
o << " CPPU_GCC3_ALIGN( " << scopedName(m_typeName, superType) << " )"; o << " CPPU_GCC3_ALIGN( " << scopedCppName(m_typeMgr, superType) << " )";
} }
o << ";\n"; o << ";\n";
} }
@@ -3368,7 +3264,7 @@ sal_Bool ExceptionType::dumpHxxFile(
includes.dump(o, &m_typeName); includes.dump(o, &m_typeName);
o << "\n"; o << "\n";
if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false)) { if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeMgr, m_typeName, false)) {
o << "\n"; o << "\n";
} }
o << "\n"; o << "\n";
@@ -3383,7 +3279,7 @@ sal_Bool ExceptionType::dumpHxxFile(
sal_Bool first = sal_True; sal_Bool first = sal_True;
if (superType.getLength() > 0) if (superType.getLength() > 0)
{ {
o << indent() << ": " << scopedName(m_typeName, superType) << "()\n"; o << indent() << ": " << scopedCppName(m_typeMgr, superType) << "()\n";
first = sal_False; first = sal_False;
} }
@@ -3460,7 +3356,7 @@ sal_Bool ExceptionType::dumpHxxFile(
sal_Bool first = sal_True; sal_Bool first = sal_True;
if (superType.getLength() > 0) if (superType.getLength() > 0)
{ {
o << indent() << ": " << scopedName(m_typeName, superType) << "("; o << indent() << ": " << scopedCppName(m_typeMgr, superType) << "(";
dumpSuperMember(o, superType, sal_False); dumpSuperMember(o, superType, sal_False);
o << ")\n"; o << ")\n";
first = sal_False; first = sal_False;
@@ -3504,7 +3400,7 @@ sal_Bool ExceptionType::dumpHxxFile(
<< " const & the_other)"; << " const & the_other)";
first = true; first = true;
if (superType.getLength() > 0) { if (superType.getLength() > 0) {
o << ": " << scopedName(m_typeName, superType) << "(the_other)"; o << ": " << scopedCppName(m_typeMgr, superType) << "(the_other)";
first = false; first = false;
} }
for (sal_uInt16 i = 0; i < fieldCount; ++i) { for (sal_uInt16 i = 0; i < fieldCount; ++i) {
@@ -3523,7 +3419,7 @@ sal_Bool ExceptionType::dumpHxxFile(
<< ("//TODO: Just like its implicitly-defined counterpart, this function" << ("//TODO: Just like its implicitly-defined counterpart, this function"
" definition is not exception-safe\n"); " definition is not exception-safe\n");
if (superType.getLength() > 0) { if (superType.getLength() > 0) {
o << indent() << scopedName(m_typeName, superType) o << indent() << scopedCppName(m_typeMgr, superType)
<< "::operator =(the_other);\n"; << "::operator =(the_other);\n";
} }
for (sal_uInt16 i = 0; i < fieldCount; ++i) { for (sal_uInt16 i = 0; i < fieldCount; ++i) {
@@ -3628,7 +3524,7 @@ sal_Bool EnumType::dumpHFile(
includes.dump(o, 0); includes.dump(o, 0);
o << "\n"; o << "\n";
if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false)) { if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeMgr, m_typeName, false)) {
o << "\n"; o << "\n";
} }
@@ -3718,7 +3614,7 @@ void EnumType::dumpNormalGetCppuType(FileStream& o)
o << indent() << "typelib_static_enum_type_init( &the_type,\n"; o << indent() << "typelib_static_enum_type_init( &the_type,\n";
inc(31); inc(31);
o << indent() << "\"" << m_typeName.replace('/', '.') << "\",\n" o << indent() << "\"" << m_typeName.replace('/', '.') << "\",\n"
<< indent() << scopedName(OString(), m_typeName) << "_" << indent() << scopedCppName(m_typeMgr, m_typeName) << "_"
<< rtl::OUStringToOString(m_reader.getFieldName(0), RTL_TEXTENCODING_UTF8) << rtl::OUStringToOString(m_reader.getFieldName(0), RTL_TEXTENCODING_UTF8)
<< " );\n"; << " );\n";
dec(31); dec(31);
@@ -3779,7 +3675,7 @@ void EnumType::dumpComprehensiveGetCppuType(FileStream& o)
o << "\n" << indent() << "typelib_typedescription_newEnum( &pTD,\n"; o << "\n" << indent() << "typelib_typedescription_newEnum( &pTD,\n";
inc(); inc();
o << indent() << "sTypeName.pData,\n" o << indent() << "sTypeName.pData,\n"
<< indent() << "(sal_Int32)" << scopedName("", m_typeName, sal_False) << indent() << "(sal_Int32)" << scopedCppName(m_typeMgr, m_typeName, sal_False)
<< "_" << "_"
<< rtl::OUStringToOString(m_reader.getFieldName(0), RTL_TEXTENCODING_UTF8) << rtl::OUStringToOString(m_reader.getFieldName(0), RTL_TEXTENCODING_UTF8)
<< ",\n" << ",\n"
@@ -3831,7 +3727,7 @@ sal_Bool TypeDefType::dumpHFile(
includes.dump(o, 0); includes.dump(o, 0);
o << "\n"; o << "\n";
if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false)) { if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeMgr, m_typeName, false)) {
o << "\n"; o << "\n";
} }
@@ -3981,12 +3877,13 @@ sal_Bool ServiceType::dumpHxxFile(
} }
} }
} }
rtl::OString cppName(translateIdentifier(m_name, "service", isGlobal())); rtl::OString cppName(translateUnoToCppIdentifier(
m_name, "service", isGlobal()));
rtl::OString headerDefine(dumpHeaderDefine(o, "HPP")); rtl::OString headerDefine(dumpHeaderDefine(o, "HPP"));
o << "\n"; o << "\n";
includes.dump(o, 0); includes.dump(o, 0);
o << "\n"; o << "\n";
if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false)) { if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeMgr, m_typeName, false)) {
o << "\n"; o << "\n";
} }
o << "\nclass " << cppName << " {\n"; o << "\nclass " << cppName << " {\n";
@@ -3997,13 +3894,14 @@ sal_Bool ServiceType::dumpHxxFile(
rtl::OUStringToOString( rtl::OUStringToOString(
m_reader.getSuperTypeName(0), RTL_TEXTENCODING_UTF8)); m_reader.getSuperTypeName(0), RTL_TEXTENCODING_UTF8));
rtl::OString fullBaseName(baseName.replace('/', '.')); rtl::OString fullBaseName(baseName.replace('/', '.'));
rtl::OString scopedBaseName(scopedName(rtl::OString(), baseName)); rtl::OString scopedBaseName(scopedCppName(m_typeMgr, baseName));
o << "public:\n"; o << "public:\n";
for (sal_uInt16 i = 0; i < ctors; ++i) { for (sal_uInt16 i = 0; i < ctors; ++i) {
if (isDefaultConstructor(i)) { if (isDefaultConstructor(i)) {
o << indent() << "static ::com::sun::star::uno::Reference< " o << indent() << "static ::com::sun::star::uno::Reference< "
<< scopedBaseName << " > " << scopedBaseName << " > "
<< translateIdentifier("create", "method", false, &cppName) << translateUnoToCppIdentifier(
"create", "method", ITM_NONGLOBAL, &cppName)
<< ("(::com::sun::star::uno::Reference<" << ("(::com::sun::star::uno::Reference<"
" ::com::sun::star::uno::XComponentContext > const &" " ::com::sun::star::uno::XComponentContext > const &"
" the_context) {\n"); " the_context) {\n");
@@ -4064,10 +3962,10 @@ sal_Bool ServiceType::dumpHxxFile(
} else { } else {
o << indent() << "static ::com::sun::star::uno::Reference< " o << indent() << "static ::com::sun::star::uno::Reference< "
<< scopedBaseName << " > " << scopedBaseName << " > "
<< translateIdentifier( << translateUnoToCppIdentifier(
rtl::OUStringToOString( rtl::OUStringToOString(
m_reader.getMethodName(i), RTL_TEXTENCODING_UTF8), m_reader.getMethodName(i), RTL_TEXTENCODING_UTF8),
"method", false, &cppName) "method", ITM_NONGLOBAL, &cppName)
<< ("(::com::sun::star::uno::Reference<" << ("(::com::sun::star::uno::Reference<"
" ::com::sun::star::uno::XComponentContext > const &" " ::com::sun::star::uno::XComponentContext > const &"
" the_context"); " the_context");
@@ -4089,11 +3987,11 @@ sal_Bool ServiceType::dumpHxxFile(
bool byRef = passByReference(type); bool byRef = passByReference(type);
dumpType(o, type, byRef, byRef); dumpType(o, type, byRef, byRef);
o << " " o << " "
<< translateIdentifier( << translateUnoToCppIdentifier(
rtl::OUStringToOString( rtl::OUStringToOString(
m_reader.getMethodParameterName(i, j), m_reader.getMethodParameterName(i, j),
RTL_TEXTENCODING_UTF8), RTL_TEXTENCODING_UTF8),
"param", false); "param", ITM_NONGLOBAL);
} }
o << ") {\n"; o << ") {\n";
inc(); inc();
@@ -4118,11 +4016,11 @@ sal_Bool ServiceType::dumpHxxFile(
for (sal_uInt16 j = 0; j < params; ++j) { for (sal_uInt16 j = 0; j < params; ++j) {
o << indent() << "the_arguments[" << j << "] "; o << indent() << "the_arguments[" << j << "] ";
rtl::OString param( rtl::OString param(
translateIdentifier( translateUnoToCppIdentifier(
rtl::OUStringToOString( rtl::OUStringToOString(
m_reader.getMethodParameterName(i, j), m_reader.getMethodParameterName(i, j),
RTL_TEXTENCODING_UTF8), RTL_TEXTENCODING_UTF8),
"param", false)); "param", ITM_NONGLOBAL));
sal_Int32 rank; sal_Int32 rank;
if (codemaker::UnoType::getSort( if (codemaker::UnoType::getSort(
codemaker::UnoType::decompose( codemaker::UnoType::decompose(
@@ -4171,11 +4069,11 @@ sal_Bool ServiceType::dumpHxxFile(
"::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(\"") "::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(\"")
<< fullName << "\")), "; << fullName << "\")), ";
if (rest) { if (rest) {
o << translateIdentifier( o << translateUnoToCppIdentifier(
rtl::OUStringToOString( rtl::OUStringToOString(
m_reader.getMethodParameterName(i, 0), m_reader.getMethodParameterName(i, 0),
RTL_TEXTENCODING_UTF8), RTL_TEXTENCODING_UTF8),
"param", false); "param", ITM_NONGLOBAL);
} else if (params == 0) { } else if (params == 0) {
o << ("::com::sun::star::uno::Sequence<" o << ("::com::sun::star::uno::Sequence<"
" ::com::sun::star::uno::Any >()"); " ::com::sun::star::uno::Any >()");
@@ -4288,13 +4186,14 @@ sal_Bool SingletonType::dumpHxxFile(
FileStream & o, codemaker::cppumaker::Includes & includes) FileStream & o, codemaker::cppumaker::Includes & includes)
throw (CannotDumpException) throw (CannotDumpException)
{ {
rtl::OString cppName(translateIdentifier(m_name, "singleton", isGlobal())); rtl::OString cppName(translateUnoToCppIdentifier(
m_name, "singleton", isGlobal()));
rtl::OString fullName(m_typeName.replace('/', '.')); rtl::OString fullName(m_typeName.replace('/', '.'));
rtl::OString baseName( rtl::OString baseName(
rtl::OUStringToOString( rtl::OUStringToOString(
m_reader.getSuperTypeName(0), RTL_TEXTENCODING_UTF8)); m_reader.getSuperTypeName(0), RTL_TEXTENCODING_UTF8));
rtl::OString fullBaseName(baseName.replace('/', '.')); rtl::OString fullBaseName(baseName.replace('/', '.'));
rtl::OString scopedBaseName(scopedName(rtl::OString(), baseName)); rtl::OString scopedBaseName(scopedCppName(m_typeMgr, baseName));
rtl::OString headerDefine(dumpHeaderDefine(o, "HPP")); rtl::OString headerDefine(dumpHeaderDefine(o, "HPP"));
o << "\n"; o << "\n";
//TODO: Decide whether the types added to includes should rather be added to //TODO: Decide whether the types added to includes should rather be added to
@@ -4307,14 +4206,14 @@ sal_Bool SingletonType::dumpHxxFile(
includes.addRtlUstringHxx(); includes.addRtlUstringHxx();
includes.dump(o, 0); includes.dump(o, 0);
o << "\n"; o << "\n";
if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false)) { if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeMgr, m_typeName, false)) {
o << "\n"; o << "\n";
} }
o << "\nclass " << cppName << " {\npublic:\n"; o << "\nclass " << cppName << " {\npublic:\n";
inc(); inc();
o << indent() << "static ::com::sun::star::uno::Reference< " o << indent() << "static ::com::sun::star::uno::Reference< "
<< scopedBaseName << " > " << scopedBaseName << " > "
<< translateIdentifier("get", "method", false, &cppName) << translateUnoToCppIdentifier("get", "method", ITM_NONGLOBAL, &cppName)
<< ("(::com::sun::star::uno::Reference<" << ("(::com::sun::star::uno::Reference<"
" ::com::sun::star::uno::XComponentContext > const & context) {\n"); " ::com::sun::star::uno::XComponentContext > const & context) {\n");
inc(); inc();
@@ -4616,6 +4515,7 @@ bool produceType(RegistryKey& rTypeKey, bool bIsExtraType,
//************************************************************************* //*************************************************************************
// scopedName // scopedName
//************************************************************************* //*************************************************************************
/*
OString scopedName(const OString& scope, const OString& type, OString scopedName(const OString& scope, const OString& type,
sal_Bool bNoNameSpace) sal_Bool bNoNameSpace)
{ {
@@ -4631,8 +4531,15 @@ OString scopedName(const OString& scope, const OString& type,
do do
{ {
tmpBuf.append("::"); tmpBuf.append("::");
tmpBuf.append(type.getToken(0, '/', nPos)); OString token(type.getToken(0, '/', nPos));
if (nPos != -1)
tmpBuf.append(translateUnoToCppIndentifier(
token, "module", ITM_KEYWORDSONLY));
else
tmpBuf.append(translateUnoToCppIndentifier(
token, "interface", ITM_KEYWORDSONLY));
} while( nPos != -1 ); } while( nPos != -1 );
return tmpBuf.makeStringAndClear(); return tmpBuf.makeStringAndClear();
} }
*/