1 /*
2  * Copyright (C) 2022 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_WELL_KNOWN_CLASSES_INL_H_
18 #define ART_RUNTIME_WELL_KNOWN_CLASSES_INL_H_
19 
20 #include "well_known_classes.h"
21 
22 #include "art_field-inl.h"
23 #include "art_method-inl.h"
24 
25 namespace art HIDDEN {
26 namespace detail {
27 
28 template <typename MemberType, MemberType** kMember>
29 template <ReadBarrierOption kReadBarrierOption>
Get()30 ObjPtr<mirror::Class> ClassFromMember<MemberType, kMember>::Get() {
31   return (*kMember)->template GetDeclaringClass<kReadBarrierOption>();
32 }
33 
34 template <typename MemberType, MemberType** kMember>
35 mirror::Class* ClassFromMember<MemberType, kMember>::operator->() const {
36   return Get().Ptr();
37 }
38 
39 template <typename MemberType, MemberType** kMember>
40 inline bool operator==(const ClassFromMember<MemberType, kMember> lhs, ObjPtr<mirror::Class> rhs) {
41   return lhs.Get() == rhs;
42 }
43 
44 template <typename MemberType, MemberType** kMember>
45 inline bool operator==(ObjPtr<mirror::Class> lhs, const ClassFromMember<MemberType, kMember> rhs) {
46   return rhs == lhs;
47 }
48 
49 template <typename MemberType, MemberType** kMember>
50 bool operator!=(const ClassFromMember<MemberType, kMember> lhs, ObjPtr<mirror::Class> rhs) {
51   return !(lhs == rhs);
52 }
53 
54 template <typename MemberType, MemberType** kMember>
55 bool operator!=(ObjPtr<mirror::Class> lhs, const ClassFromMember<MemberType, kMember> rhs) {
56   return !(rhs == lhs);
57 }
58 
59 }  // namespace detail
60 }  // namespace art
61 
62 #endif  // ART_RUNTIME_WELL_KNOWN_CLASSES_INL_H_
63