| 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 "dependencies.h"cxx . . $ `<file>/src/internal/dependencies.h`/ |
| 22 | |
| 23 | #include <injeqt/exception/dependency-on-self.h>cxx . . $ `<file>/include/injeqt/exception/dependency-on-self.h`/ |
| 24 | #include <injeqt/exception/dependency-on-subtype.h>cxx . . $ `<file>/include/injeqt/exception/dependency-on-subtype.h`/ |
| 25 | #include <injeqt/exception/dependency-on-supertype.h>cxx . . $ `<file>/include/injeqt/exception/dependency-on-supertype.h`/ |
| 26 | #include <injeqt/exception/exception.h>cxx . . $ `<file>/include/injeqt/exception/exception.h`/ |
| 27 | #include <injeqt/exception/invalid-dependency.h>cxx . . $ `<file>/include/injeqt/exception/invalid-dependency.h`/ |
| 28 | #include <injeqt/exception/invalid-setter.h>cxx . . $ `<file>/include/injeqt/exception/invalid-setter.h`/ |
| 29 | #include <injeqt/type.h>cxx . . $ `<file>/include/injeqt/type.h`/ |
| 30 | |
| 31 | #include "dependency.h"cxx . . $ `<file>/src/internal/dependency.h`/ |
| 32 | #include "interfaces-utils.h"cxx . . $ `<file>/src/internal/interfaces-utils.h`/ |
| 33 | #include "setter-method.h"cxx . . $ `<file>/src/internal/setter-method.h`/ |
| 34 | #include "type-relations.h"cxx . . $ `<file>/src/internal/type-relations.h`/ |
| 35 | |
| 36 | #include <QtCore/QMetaMethod> |
| 37 | #include <algorithm> |
| 38 | #include <cassert> |
| 39 | #include <set> |
| 40 | |
| 41 | namespace injeqtcxx . . $ injeqt/ { namespace internalcxx . . $ injeqt/internal/ { |
| 42 | |
| 43 | namespacecxx . . $ injeqt/internal/`$anonymous_namespace_src/internal/dependencies.cpp`/ { |
| 44 | |
| 45 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<setter_methodcxx . . $ injeqt/internal/setter_method#> extract_setterscxx . . $ injeqt/internal/`$anonymous_namespace_src/internal/dependencies.cpp`/extract_setters(d5f910850bde50b7).(const types_by_namecxx . . $ injeqt/internal/types_by_name# &known_types, const typecxx . . $ injeqt/v1/type# &for_type) |
| 46 | { |
| 47 | assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(!for_type.is_empty()); |
| 48 | |
| 49 | auto result = stdcxx . . $ std/vector#vector(b1ea180184b47f03).::vectorcxx . . $ std/vector#<setter_methodcxx . . $ injeqt/internal/setter_method#>{}; |
| 50 | |
| 51 | auto meta_object = for_type.meta_objectcxx . . $ injeqt/v1/type#meta_object(216d4151dd9c9333).(); |
| 52 | auto method_count = meta_object->methodCountcxx . . $ QMetaObject#methodCount(455f465bc33b4cdf).(); |
| 53 | for (decltype(method_count) i = 0; i < method_count; i++) |
| 54 | { |
| 55 | auto maybe_setter = meta_object->methodcxx . . $ QMetaObject#method(964508606e32bda3).(i); |
| 56 | if (setter_methodcxx . . $ injeqt/internal/setter_method#::is_setter_tagcxx . . $ injeqt/internal/setter_method#is_setter_tag(7c222eea44a24d43).(maybe_settercxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)..tagcxx . . $ QMetaMethod#tag(a9f41ea0e82d88cf).())) |
| 57 | result.emplace_backcxx . . $ std/vector#emplace_back(b3d147e3bb711c35).(make_setter_methodcxx . . $ injeqt/internal/make_setter_method(5a3e1df2da4658bb).(known_types, maybe_setter)); |
| 58 | } |
| 59 | |
| 60 | return resultcxx . . $ std/vector#vector(b1ea180184b47f03).; |
| 61 | } |
| 62 | |
| 63 | } |
| 64 | |
| 65 | dependenciescxx . . $ injeqt/internal/dependencies# extract_dependenciescxx . . $ injeqt/internal/extract_dependencies(c8c0e98cc48858ad).(const types_by_namecxx . . $ injeqt/internal/types_by_name# &known_types, const typecxx . . $ injeqt/v1/type# &for_type) |
| 66 | { |
| 67 | assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(!for_type.is_empty()); |
| 68 | |
| 69 | auto interfaces = extract_interfacescxx . . $ injeqt/internal/extract_interfaces(859a62e7a8dc5225).(for_type); |
| 70 | auto setters = extract_setterscxx . . $ std/vector#vector(b1ea180184b47f03).(known_types, for_type); |
| 71 | for (auto &&setter : setters) |
| 72 | { |
| 73 | auto parameter_type = setter.parameter_typecxx . . $ injeqt/internal/setter_method#parameter_type(7e9f7f4e42b3414e).(); |
| 74 | if (parameter_type ==cxx . . $ injeqt/v1/`operator==`(24fd26303071bddf). for_type) |
| 75 | throw exceptioncxx . . $ injeqt/v1/exception/dependency_on_self#dependency_on_self(8d4ab0a187bf9331).::dependency_on_selfcxx . . $ injeqt/v1/exception/dependency_on_self#{}; |
| 76 | if (stdcxx . . $ std/::findcxx . . $ std/find(a92da12e15934614).(stdcxx . . $ std/::begincxx . . $ std/begin(8c94f1ffb8cd32fc).(interfaces), stdcxx . . $ std/::endcxx . . $ std/end(898c3e9f99adb426).(interfaces), parameter_type) !=cxx . . $ __gnu_cxx/`operator!=`(d99b0194e00bfb5f). stdcxx . . $ std/::endcxx . . $ std/end(898c3e9f99adb426).(interfaces)) |
| 77 | throw exceptioncxx . . $ injeqt/v1/exception/dependency_on_supertype#dependency_on_supertype(8d4ab0a187bf9331).::dependency_on_supertypecxx . . $ injeqt/v1/exception/dependency_on_supertype#{}; |
| 78 | auto parameter_interfaces = extract_interfacescxx . . $ injeqt/internal/extract_interfaces(859a62e7a8dc5225).(parameter_type); |
| 79 | if (stdcxx . . $ std/::findcxx . . $ std/find(a92da12e15934614).(stdcxx . . $ std/::begincxx . . $ std/begin(8c94f1ffb8cd32fc).(parameter_interfaces), stdcxx . . $ std/::endcxx . . $ std/end(898c3e9f99adb426).(parameter_interfaces), for_type) !=cxx . . $ __gnu_cxx/`operator!=`(d99b0194e00bfb5f). stdcxx . . $ std/::endcxx . . $ std/end(898c3e9f99adb426).(parameter_interfaces)) |
| 80 | throw exceptioncxx . . $ injeqt/v1/exception/dependency_on_subtype#dependency_on_subtype(8d4ab0a187bf9331).::dependency_on_subtypecxx . . $ injeqt/v1/exception/dependency_on_subtype#{}; |
| 81 | } |
| 82 | |
| 83 | auto result = stdcxx . . $ std/vector#vector(b1ea180184b47f03).::vectorcxx . . $ std/vector#<dependencycxx . . $ injeqt/internal/dependency#>{}; |
| 84 | stdcxx . . $ std/::transformcxx . . $ std/transform(da30451c4a040264).(stdcxx . . $ std/::begincxx . . $ std/begin(8c94f1ffb8cd32fc).(setters), stdcxx . . $ std/::endcxx . . $ std/end(898c3e9f99adb426).(setters), stdcxx . . $ std/::back_insertercxx . . $ std/back_inserter(7b559d6bdd90ff74).(result), |
| 85 | [](const setter_methodcxx . . $ injeqt/internal/setter_method# &setter){ return dependencycxx . . $ injeqt/internal/dependency#dependency(28c822c801d90b7b).{setter}; } |
| 86 | ); |
| 87 | |
| 88 | return dependenciescxx . . $ injeqt/internal/sorted_unique_vector#sorted_unique_vector(26e8deb829554aa).{resultcxx . . $ std/vector#vector(a1201200cf0efa42).}; |
| 89 | } |
| 90 | |
| 91 | }} |