-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfield_access_impl.h
65 lines (60 loc) · 2.61 KB
/
field_access_impl.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
#pragma once
#include "class_constructor.h"
#include "class_wrapper.h"
#include "field_access.h"
namespace jnipp::field_access {
template<return_type T>
inline auto instance_field<T>::operator*() const
{
if constexpr(T == return_type::bool_)
return GetJNI()->GetBooleanField(field.instance, *field.field);
else if constexpr(T == return_type::byte_)
return GetJNI()->GetByteField(field.instance, *field.field);
else if constexpr(T == return_type::char_)
return GetJNI()->GetCharField(field.instance, *field.field);
else if constexpr(T == return_type::short_)
return GetJNI()->GetShortField(field.instance, *field.field);
else if constexpr(T == return_type::int_)
return GetJNI()->GetIntField(field.instance, *field.field);
else if constexpr(T == return_type::long_)
return GetJNI()->GetLongField(field.instance, *field.field);
else if constexpr(T == return_type::float_)
return GetJNI()->GetFloatField(field.instance, *field.field);
else if constexpr(T == return_type::double_)
return GetJNI()->GetDoubleField(field.instance, *field.field);
else if constexpr(T == return_type::object_)
return wrapping::jobject(java::object{
{},
GetJNI()->GetObjectField(field.instance, *field.field),
});
else
return java::value();
}
template<return_type T>
inline auto static_field<T>::operator*() const
{
if constexpr(T == return_type::bool_)
return GetJNI()->GetStaticBooleanField(field.clazz, *field.field);
else if constexpr(T == return_type::byte_)
return GetJNI()->GetStaticByteField(field.clazz, *field.field);
else if constexpr(T == return_type::char_)
return GetJNI()->GetStaticCharField(field.clazz, *field.field);
else if constexpr(T == return_type::short_)
return GetJNI()->GetStaticShortField(field.clazz, *field.field);
else if constexpr(T == return_type::int_)
return GetJNI()->GetStaticIntField(field.clazz, *field.field);
else if constexpr(T == return_type::long_)
return GetJNI()->GetStaticLongField(field.clazz, *field.field);
else if constexpr(T == return_type::float_)
return GetJNI()->GetStaticFloatField(field.clazz, *field.field);
else if constexpr(T == return_type::double_)
return GetJNI()->GetStaticDoubleField(field.clazz, *field.field);
else if constexpr(T == return_type::object_)
return wrapping::jobject(java::object{
{},
GetJNI()->GetStaticObjectField(field.clazz, *field.field),
});
else
return java::value();
}
} // namespace jnipp::field_access