| 1 | /* |
| 2 | * %injeqt copyright begin% |
| 3 | * Copyright 2014 Rafał Malinowski ([email protected]) |
| 4 | * %injeqt copyright end% |
| 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2.1 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | |
| 21 | #include "interfaces-utils.h"cxx . . $ `<file>/src/internal/interfaces-utils.h`/ |
| 22 | |
| 23 | #include <injeqt/type.h>cxx . . $ `<file>/include/injeqt/type.h`/ |
| 24 | |
| 25 | #include <QtCore/QMetaObject> |
| 26 | #include <cassert> |
| 27 | |
| 28 | namespace injeqtcxx . . $ injeqt/ { namespace internalcxx . . $ injeqt/internal/ { |
| 29 | |
| 30 | namespacecxx . . $ injeqt/internal/`$anonymous_namespace_src/internal/interfaces-utils.cpp`/ |
| 31 | { |
| 32 | |
| 33 | bool is_qobjectcxx . . $ injeqt/internal/`$anonymous_namespace_src/internal/interfaces-utils.cpp`/is_qobject(95c881fc70a704e).(const QMetaObjectcxx . . $ QMetaObject# * const meta_object) |
| 34 | { |
| 35 | return !meta_object->superClasscxx . . $ QMetaObject#superClass(216d4151dd9c9333).(); |
| 36 | } |
| 37 | |
| 38 | } |
| 39 | |
| 40 | typescxx . . $ injeqt/internal/types# extract_interfacescxx . . $ injeqt/internal/extract_interfaces(859a62e7a8dc5225).(const typecxx . . $ injeqt/v1/type# &for_type) |
| 41 | { |
| 42 | assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(!for_type.is_empty()); |
| 43 | |
| 44 | auto result = stdcxx . . $ std/vector#vector(b1ea180184b47f03).::vectorcxx . . $ std/vector#<typecxx . . $ injeqt/v1/type#>{}; |
| 45 | auto meta_object = for_type.meta_objectcxx . . $ injeqt/v1/type#meta_object(216d4151dd9c9333).(); |
| 46 | while (meta_object && !is_qobjectcxx . . $ injeqt/internal/`$anonymous_namespace_src/internal/interfaces-utils.cpp`/is_qobject(95c881fc70a704e).(meta_object)) |
| 47 | { |
| 48 | result.emplace_backcxx . . $ std/vector#emplace_back(b3d147e3bb711c35).(meta_object); |
| 49 | meta_object = meta_object->superClasscxx . . $ QMetaObject#superClass(216d4151dd9c9333).(); |
| 50 | } |
| 51 | |
| 52 | return typescxx . . $ injeqt/internal/sorted_unique_vector#sorted_unique_vector(26e8deb829554aa).{resultcxx . . $ std/vector#vector(a1201200cf0efa42).}; |
| 53 | } |
| 54 | |
| 55 | bool implementscxx . . $ injeqt/internal/implements(24fd26303071bddf).(const typecxx . . $ injeqt/v1/type# &implementation, const typecxx . . $ injeqt/v1/type# &interface) |
| 56 | { |
| 57 | assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(!implementation.is_empty()); |
| 58 | assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(!interface.is_empty()); |
| 59 | |
| 60 | auto interfaces = extract_interfacescxx . . $ injeqt/internal/extract_interfaces(859a62e7a8dc5225).(implementation); |
| 61 | return stdcxx . . $ std/::findcxx . . $ std/find(a92da12e15934614).(stdcxx . . $ std/::begincxx . . $ std/begin(8c94f1ffb8cd32fc).(interfaces), stdcxx . . $ std/::endcxx . . $ std/end(898c3e9f99adb426).(interfaces), interface) !=cxx . . $ __gnu_cxx/`operator!=`(d99b0194e00bfb5f). stdcxx . . $ std/::endcxx . . $ std/end(898c3e9f99adb426).(interfaces); |
| 62 | } |
| 63 | |
| 64 | }} |