blob: 5bd4f176f6ed88cf8d2c7b38a1ba5019894b6acc [file] [log] [blame]
Mathieu Chartier28bd2e42016-10-04 13:54:57 -07001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ART_RUNTIME_JVALUE_INL_H_
18#define ART_RUNTIME_JVALUE_INL_H_
19
20#include "jvalue.h"
21
Andreas Gampec5b75642018-05-16 15:12:11 -070022#include "obj_ptr-inl.h"
Mathieu Chartier28bd2e42016-10-04 13:54:57 -070023
24namespace art {
25
26inline void JValue::SetL(ObjPtr<mirror::Object> new_l) {
27 l = new_l.Ptr();
28}
29
Alex Lighte00ec302017-06-16 08:56:43 -070030#define DEFINE_FROM(type, chr) \
31 template <> inline JValue JValue::FromPrimitive(type v) { \
32 JValue res; \
33 res.Set ## chr(v); \
34 return res; \
35 }
36
37DEFINE_FROM(uint8_t, Z);
38DEFINE_FROM(int8_t, B);
39DEFINE_FROM(uint16_t, C);
40DEFINE_FROM(int16_t, S);
41DEFINE_FROM(int32_t, I);
42DEFINE_FROM(int64_t, J);
43DEFINE_FROM(float, F);
44DEFINE_FROM(double, D);
45
46#undef DEFINE_FROM
47
Mathieu Chartier28bd2e42016-10-04 13:54:57 -070048} // namespace art
49
50#endif // ART_RUNTIME_JVALUE_INL_H_