Changeset View
Changeset View
Standalone View
Standalone View
find-modules/module_generation/PyKF5/KService.py
- This file was added.
1 | # | ||||
---|---|---|---|---|---|
2 | # Copyright 2017 by Shaheed Haque (srhaque@theiet.org) | ||||
3 | # | ||||
4 | # This program is free software; you can redistribute it and/or modify | ||||
5 | # it under the terms of the GNU General Public License as published by | ||||
6 | # the Free Software Foundation; either version 2 of the License, or | ||||
7 | # (at your option) any later version. | ||||
8 | # | ||||
9 | # This program is distributed in the hope that it will be useful, | ||||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
12 | # GNU General Public License for more details. | ||||
13 | # | ||||
14 | # You should have received a copy of the GNU General Public License | ||||
15 | # along with this program; if not, write to the Free Software | ||||
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||||
17 | # 02110-1301 USA. | ||||
18 | # | ||||
19 | """ | ||||
20 | SIP binding customisation for PyKF5.KService. This modules describes: | ||||
21 | | ||||
22 | * Supplementary SIP file generator rules. | ||||
23 | """ | ||||
24 | | ||||
25 | import rule_helpers | ||||
26 | | ||||
27 | | ||||
28 | def _function_rewrite_using_decl(container, function, sip, matcher): | ||||
29 | sip["parameters"] = ["const QString &name"] | ||||
30 | sip["fn_result"] = "QVariant" | ||||
31 | sip["suffix"] = " const" | ||||
32 | | ||||
33 | | ||||
34 | def module_fix_mapped_types(filename, sip, rule): | ||||
35 | # | ||||
36 | # SIP cannot handle duplicate %MappedTypes. | ||||
37 | # | ||||
38 | rule_helpers.modulecode_delete(filename, sip, rule, "QList<QExplicitlySharedDataPointer<KSycocaEntry> >", | ||||
39 | "QList<QVariant>", "QVector<KPluginMetaData>") | ||||
40 | rule_helpers.module_add_includes(filename, sip, rule, "<QExplicitlySharedDataPointer>", "<KService>") | ||||
41 | | ||||
42 | | ||||
43 | def container_rules(): | ||||
44 | return [ | ||||
45 | ["ksycocaentry.h", "KSycocaEntry", ".*", ".*", ".*QSharedData.*", rule_helpers.container_discard_QSharedData_base], | ||||
46 | ["kplugininfo.h", "KPluginInfo", ".*", ".*", ".*", rule_helpers.container_fake_derived_class], | ||||
47 | ] | ||||
48 | | ||||
49 | | ||||
50 | def function_rules(): | ||||
51 | return [ | ||||
52 | # | ||||
53 | # Provide %MethodCode and a C++ signature. | ||||
54 | # | ||||
55 | ["KMimeTypeTrader|KServiceTypeTrader", "preferredService", ".*", ".*", ".*", rule_helpers.function_discard], | ||||
56 | ["KPluginInfo", "KPluginInfo", ".*", ".*", ".*SharedData.*", rule_helpers.function_discard], | ||||
57 | ["KPluginInfo", "service", ".*", ".*", ".*", rule_helpers.function_discard], | ||||
58 | ["KService", "service.*", ".*", ".*", ".*", rule_helpers.function_discard], | ||||
59 | ["KServiceGroup", "root|group|childGroup|addEntry", ".*", ".*", ".*", rule_helpers.function_discard], | ||||
60 | ["KServiceType", "parentType|serviceType", ".*", ".*", ".*", rule_helpers.function_discard], | ||||
61 | ["KSycoca", "stream", ".*", ".*", ".*", rule_helpers.function_discard], | ||||
62 | # | ||||
63 | # No KSycocaFactory or KSycocaFactoryList. | ||||
64 | # | ||||
65 | ["KSycoca", "addFactory|factories", ".*", ".*", ".*", rule_helpers.function_discard], | ||||
66 | # | ||||
67 | # There is no KServiceOffer. | ||||
68 | # | ||||
69 | ["KMimeTypeTrader", "filterMimeTypeOffers", ".*", ".*", ".*KServiceOffer.*", rule_helpers.function_discard], | ||||
70 | ["KServiceTypeTrader", "weightedOffers", ".*", ".*KServiceOffer.*", ".*", rule_helpers.function_discard], | ||||
71 | ["KService", "_k_accessServiceTypes", ".*", ".*", ".*", rule_helpers.function_discard], | ||||
72 | # | ||||
73 | # Rewrite using declaration. | ||||
74 | # | ||||
75 | ["KService", "property", ".*", ".*", "", _function_rewrite_using_decl], | ||||
76 | ] | ||||
77 | | ||||
78 | | ||||
79 | def typedef_rules(): | ||||
80 | return [ | ||||
81 | # | ||||
82 | # There is no KServiceOffer. | ||||
83 | # | ||||
84 | ["k(mime|service)typetrader.h", "KServiceOfferList", ".*", ".*", rule_helpers.typedef_discard], | ||||
85 | ] | ||||
86 | | ||||
87 | | ||||
88 | def typecode(): | ||||
89 | return { | ||||
90 | # DISABLED until I figure out an approach for CTSCC. | ||||
91 | "DISABLED kservicegroup.h::KServiceGroup": { # KServiceGroup : KSycocaEntry | ||||
92 | "code": | ||||
93 | """ | ||||
94 | %ConvertToSubClassCode | ||||
95 | | ||||
96 | if (dynamic_cast<KServiceGroup*>(sipCpp)) | ||||
97 | sipClass = sipClass_KServiceGroup; | ||||
98 | else if (dynamic_cast<KServiceSeparator*>(sipCpp)) | ||||
99 | sipClass = sipClass_KServiceSeparator; | ||||
100 | else | ||||
101 | sipClass = NULL; | ||||
102 | %End | ||||
103 | """ | ||||
104 | }, | ||||
105 | } | ||||
106 | | ||||
107 | | ||||
108 | def modulecode(): | ||||
109 | return { | ||||
110 | "KService/KServicemod.sip": { | ||||
111 | "code": module_fix_mapped_types, | ||||
112 | }, | ||||
113 | } |