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 
22 #include "obj_ptr-inl.h"
23 
24 namespace art {
25 
SetL(ObjPtr<mirror::Object> new_l)26 inline void JValue::SetL(ObjPtr<mirror::Object> new_l) {
27   l = new_l.Ptr();
28 }
29 
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 
48 }  // namespace art
49 
50 #endif  // ART_RUNTIME_JVALUE_INL_H_
51