-
Notifications
You must be signed in to change notification settings - Fork 3
/
field_access.h
85 lines (69 loc) · 1.58 KB
/
field_access.h
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
77
78
79
80
81
82
83
84
85
#pragma once
#include "jni_types.h"
#include "type_signatures.h"
namespace jnipp::field_access {
template<return_type T>
struct instance_field
{
auto operator*() const;
java::field_reference field;
};
template<return_type T>
struct static_field
{
auto operator*() const;
java::static_field_reference field;
};
} // namespace jnipp::field_access
namespace jnipp::wrapping {
template<return_type T>
struct jfield
{
jfield(java::field&& field)
: field(std::move(field))
{
}
template<return_type T2>
/*!
* \brief define as POD or POD array type
* \return
*/
jfield<T2> as()
{
field.signature = type_signature::to_str<T2>();
return {std::move(field)};
}
/*!
* \brief define as Java class type
* \param type
* \return
*/
jfield<return_type::object_> as(std::string const& type)
{
field.signature = type;
field.signature = "L" + type_signature::slashify(field.signature) + ";";
return {std::move(field)};
}
template<return_type T2>
requires(T2 == return_type::object_array_)
/*!
* \brief define as object array
* \param type class name for elements
* \return
*/
jfield<T2> as(std::string const& type)
{
field.signature = type_signature::to_str<T2>(type);
return {std::move(field)};
}
const char* name() const
{
return field.name.c_str();
}
const char* signature() const
{
return field.signature.c_str();
}
java::field field;
};
} // namespace jnipp::wrapping