LCOV - code coverage report
Current view: top level - codemaker/source/commonjava - commonjava.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 61 62 98.4 %
Date: 2015-06-13 12:38:46 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : 
      21             : #include "sal/config.h"
      22             : 
      23             : #include "codemaker/commonjava.hxx"
      24             : 
      25             : #include "codemaker/options.hxx"
      26             : #include "codemaker/typemanager.hxx"
      27             : #include "codemaker/unotype.hxx"
      28             : 
      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"
      35             : 
      36             : #include <vector>
      37             : 
      38             : namespace codemaker { namespace java {
      39             : 
      40          94 : OString translateUnoToJavaType(
      41             :     codemaker::UnoType::Sort sort, OString const & nucleus, bool referenceType)
      42             : {
      43          94 :     OStringBuffer buf;
      44          94 :     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        1271 :             { "java/lang/Object", "java/lang/Object" } };
      61        1271 :         buf.append(javaTypes[sort][referenceType]);
      62             :     } else {
      63          53 :         if (nucleus == "com/sun/star/uno/XInterface") {
      64           1 :             buf.append("java/lang/Object");
      65             :         } else {
      66             :             //TODO: check that nucleus is a valid (Java-modified UTF-8)
      67             :             // identifier
      68          52 :             buf.append(nucleus);
      69             :         }
      70             :     }
      71          94 :     return buf.makeStringAndClear();
      72             : }
      73             : 
      74         738 : OString translateUnoToJavaIdentifier(
      75             :     OString const & identifier, OString const & prefix)
      76             : {
      77        1476 :     if (identifier == "abstract"
      78         738 :         || identifier == "assert" // since Java 1.4
      79         738 :         || identifier == "boolean"
      80         738 :         || identifier == "break"
      81         738 :         || identifier == "byte"
      82         738 :         || identifier == "case"
      83         738 :         || identifier == "catch"
      84         738 :         || identifier == "char"
      85         738 :         || identifier == "class"
      86         738 :         || identifier == "const"
      87         738 :         || identifier == "continue"
      88         738 :         || identifier == "default"
      89         738 :         || identifier == "do"
      90         738 :         || identifier == "double"
      91         738 :         || identifier == "else"
      92         738 :         || identifier == "enum" // probable addition in Java 1.5
      93         738 :         || identifier == "extends"
      94         738 :         || identifier == "final"
      95         738 :         || identifier == "finally"
      96         738 :         || identifier == "float"
      97         738 :         || identifier == "for"
      98         738 :         || identifier == "goto"
      99         738 :         || identifier == "if"
     100         738 :         || identifier == "implements"
     101         738 :         || identifier == "import"
     102         738 :         || identifier == "instanceof"
     103         738 :         || identifier == "int"
     104         738 :         || identifier == "interface"
     105         738 :         || identifier == "long"
     106         738 :         || identifier == "native"
     107         738 :         || identifier == "new"
     108         738 :         || identifier == "package"
     109         738 :         || identifier == "private"
     110         738 :         || identifier == "protected"
     111         738 :         || identifier == "public"
     112         738 :         || identifier == "return"
     113         738 :         || identifier == "short"
     114         738 :         || identifier == "static"
     115         738 :         || identifier == "strictfp"
     116         738 :         || identifier == "super"
     117         738 :         || identifier == "switch"
     118         738 :         || identifier == "synchronized"
     119         738 :         || identifier == "this"
     120         738 :         || identifier == "throw"
     121         738 :         || identifier == "throws"
     122         738 :         || identifier == "transient"
     123         738 :         || identifier == "try"
     124         738 :         || identifier == "void"
     125         738 :         || identifier == "volatile"
     126        1476 :         || identifier == "while")
     127             :     {
     128           0 :         return prefix + "_" + identifier;
     129             :     } else {
     130         738 :         return identifier;
     131             :     }
     132             : }
     133             : 
     134             : } }
     135             : 
     136             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11