Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 1 | /* |
| 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 Gampe | c5b7564 | 2018-05-16 15:12:11 -0700 | [diff] [blame] | 22 | #include "obj_ptr-inl.h" |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 23 | |
| 24 | namespace art { |
| 25 | |
| 26 | inline void JValue::SetL(ObjPtr<mirror::Object> new_l) { |
| 27 | l = new_l.Ptr(); |
| 28 | } |
| 29 | |
Alex Light | e00ec30 | 2017-06-16 08:56:43 -0700 | [diff] [blame] | 30 | #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 | |
| 37 | DEFINE_FROM(uint8_t, Z); |
| 38 | DEFINE_FROM(int8_t, B); |
| 39 | DEFINE_FROM(uint16_t, C); |
| 40 | DEFINE_FROM(int16_t, S); |
| 41 | DEFINE_FROM(int32_t, I); |
| 42 | DEFINE_FROM(int64_t, J); |
| 43 | DEFINE_FROM(float, F); |
| 44 | DEFINE_FROM(double, D); |
| 45 | |
| 46 | #undef DEFINE_FROM |
| 47 | |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 48 | } // namespace art |
| 49 | |
| 50 | #endif // ART_RUNTIME_JVALUE_INL_H_ |