1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "sal/config.h"
23 #include "codemaker/commonjava.hxx"
25 #include "codemaker/options.hxx"
26 #include "codemaker/typemanager.hxx"
27 #include "codemaker/unotype.hxx"
29 #include "osl/diagnose.h"
30 #include "rtl/strbuf.h"
31 #include "rtl/string.h"
32 #include "rtl/string.hxx"
33 #include "rtl/ustring.hxx"
34 #include "sal/types.h"
38 namespace codemaker
{ namespace java
{
40 OString
translateUnoToJavaType(
41 codemaker::UnoType::Sort sort
, OString
const & nucleus
, bool referenceType
)
44 if (sort
<= codemaker::UnoType::SORT_ANY
) {
45 OString
const javaTypes
[codemaker::UnoType::SORT_ANY
+ 1][2] = {
46 { "void", "java/lang/Void" },
47 { "boolean", "java/lang/Boolean" },
48 { "byte", "java/lang/Byte" },
49 { "short", "java/lang/Short" },
50 { "short", "java/lang/Short" },
51 { "int", "java/lang/Integer" },
52 { "int", "java/lang/Integer" },
53 { "long", "java/lang/Long" },
54 { "long", "java/lang/Long" },
55 { "float", "java/lang/Float" },
56 { "double", "java/lang/Double" },
57 { "char", "java/lang/Character" },
58 { "java/lang/String", "java/lang/String" },
59 { "com/sun/star/uno/Type", "com/sun/star/uno/Type" },
60 { "java/lang/Object", "java/lang/Object" } };
61 buf
.append(javaTypes
[sort
][referenceType
]);
63 if (nucleus
== "com/sun/star/uno/XInterface") {
64 buf
.append("java/lang/Object");
66 //TODO: check that nucleus is a valid (Java-modified UTF-8)
71 return buf
.makeStringAndClear();
74 OString
translateUnoToJavaIdentifier(
75 OString
const & identifier
, OString
const & prefix
)
77 if (identifier
== "abstract"
78 || identifier
== "assert" // since Java 1.4
79 || identifier
== "boolean"
80 || identifier
== "break"
81 || identifier
== "byte"
82 || identifier
== "case"
83 || identifier
== "catch"
84 || identifier
== "char"
85 || identifier
== "class"
86 || identifier
== "const"
87 || identifier
== "continue"
88 || identifier
== "default"
90 || identifier
== "double"
91 || identifier
== "else"
92 || identifier
== "enum" // probable addition in Java 1.5
93 || identifier
== "extends"
94 || identifier
== "final"
95 || identifier
== "finally"
96 || identifier
== "float"
97 || identifier
== "for"
98 || identifier
== "goto"
100 || identifier
== "implements"
101 || identifier
== "import"
102 || identifier
== "instanceof"
103 || identifier
== "int"
104 || identifier
== "interface"
105 || identifier
== "long"
106 || identifier
== "native"
107 || identifier
== "new"
108 || identifier
== "package"
109 || identifier
== "private"
110 || identifier
== "protected"
111 || identifier
== "public"
112 || identifier
== "return"
113 || identifier
== "short"
114 || identifier
== "static"
115 || identifier
== "strictfp"
116 || identifier
== "super"
117 || identifier
== "switch"
118 || identifier
== "synchronized"
119 || identifier
== "this"
120 || identifier
== "throw"
121 || identifier
== "throws"
122 || identifier
== "transient"
123 || identifier
== "try"
124 || identifier
== "void"
125 || identifier
== "volatile"
126 || identifier
== "while")
128 return prefix
+ "_" + identifier
;
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */