Repository navigation
Expand file tree
/
Copy pathast_reference_type.cpp
More file actions
76 lines (65 loc) · 2.05 KB
/
Copy pathast_reference_type.cpp
File metadata and controls
76 lines (65 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* copyright (c) 2015 Zhang Rui <bbcallen@gmail.com>
*
* This file is part of jni4android.
*
* jni4android is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* jni4android is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with jni4android; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "ast_reference_type.hpp"
#include "ast_identifier.hpp"
#include "ast_class.hpp"
#include "ast__context.hpp"
using namespace ast;
bool ReferenceType::is_string_type()
{
if (0 == get_name().compare("String")) {
if (0 == _get_java_long_name().compare("java.lang.String")) {
return true;
}
}
return false;
}
j4a::string ReferenceType::_get_java_long_name()
{
Identifier *Identifier = Context::instance()->find_identifier(this, get_name());
if (Identifier) {
if (get_is_array()) {
return Identifier->get_java_long_name() + "[]";
} else {
return Identifier->get_java_long_name();
}
}
return "<unknown>";
}
j4a::string ReferenceType::get_c_type()
{
if (get_is_array())
return "jobjectArray";
if (is_string_type())
return "jstring";
return "jobject";
}
j4a::string ReferenceType::get_c_sign_in_method()
{
Identifier::pointer_type Identifier = Context::instance()->find_identifier(this, get_name());
if (Identifier) {
std::ostringstream os;
if (get_is_array())
os << "[";
os << "L" << Identifier->get_c_jni_sign() << ";";
return os;
}
return "<unknown>";
}