[shotwell/ricotz/vala: 2/2] Fix a few vala semantic issues with type-argmunents
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell/ricotz/vala: 2/2] Fix a few vala semantic issues with type-argmunents
- Date: Mon, 1 Aug 2022 15:32:39 +0000 (UTC)
commit 95ef63c4227fda7149eec437b90528a8efca56a3
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Mon Aug 1 17:31:19 2022 +0200
Fix a few vala semantic issues with type-argmunents
src/SortedList.vala | 4 ++--
src/TimedQueue.vala | 2 +-
src/plugins/Plugins.vala | 18 ++++++------------
src/slideshow/TransitionEffects.vala | 2 +-
src/util/string.vala | 8 ++++----
5 files changed, 14 insertions(+), 20 deletions(-)
---
diff --git a/src/SortedList.vala b/src/SortedList.vala
index 20e67712..420190db 100644
--- a/src/SortedList.vala
+++ b/src/SortedList.vala
@@ -142,7 +142,7 @@ public class SortedList<G> : Object, Gee.Traversable<G>, Gee.Iterable<G>, Gee.Co
return list.get(index);
}
- private int binary_search(G search, EqualFunc? equal_func) {
+ private int binary_search(G search, EqualFunc<G>? equal_func) {
assert(cmp != null);
int min = 0;
@@ -181,7 +181,7 @@ public class SortedList<G> : Object, Gee.Traversable<G>, Gee.Iterable<G>, Gee.Co
}
// See notes at index_of for the difference between this method and it.
- public int locate(G search, bool altered, EqualFunc equal_func = direct_equal) {
+ public int locate(G search, bool altered, EqualFunc<G> equal_func = direct_equal) {
if (cmp == null || altered) {
int count = list.size;
for (int ctr = 0; ctr < count; ctr++) {
diff --git a/src/TimedQueue.vala b/src/TimedQueue.vala
index 47faf3c8..4ea6a233 100644
--- a/src/TimedQueue.vala
+++ b/src/TimedQueue.vala
@@ -50,7 +50,7 @@ public class TimedQueue<G> {
// finding a workaround, namely using a delegate:
// https://bugzilla.gnome.org/show_bug.cgi?id=628639
public TimedQueue(uint hold_msec, DequeuedCallback<G> callback,
- owned Gee.EqualDataFunc? equal_func = null, int priority = Priority.DEFAULT) {
+ owned Gee.EqualDataFunc<G>? equal_func = null, int priority = Priority.DEFAULT) {
this.hold_msec = hold_msec;
this.callback = callback;
diff --git a/src/plugins/Plugins.vala b/src/plugins/Plugins.vala
index fc566d38..0eab7050 100644
--- a/src/plugins/Plugins.vala
+++ b/src/plugins/Plugins.vala
@@ -225,7 +225,7 @@ public string? get_pluggable_module_id(Spit.Pluggable needle) {
return (module_rep != null) ? module_rep.spit_module.get_id() : null;
}
-public Gee.Collection<ExtensionPoint> get_extension_points(owned CompareDataFunc? compare_func = null) {
+public Gee.Collection<ExtensionPoint> get_extension_points(owned CompareDataFunc<ExtensionPoint>?
compare_func = null) {
Gee.Collection<ExtensionPoint> sorted = new Gee.TreeSet<ExtensionPoint>((owned) compare_func);
sorted.add_all(extension_points.values);
@@ -233,7 +233,7 @@ public Gee.Collection<ExtensionPoint> get_extension_points(owned CompareDataFunc
}
public Gee.Collection<Spit.Pluggable> get_pluggables_for_type(Type type,
- owned CompareDataFunc? compare_func = null, bool include_disabled = false) {
+ owned CompareDataFunc<Spit.Pluggable>? compare_func = null, bool include_disabled = false) {
// if this triggers it means the extension point didn't register itself at init() time
assert(extension_points.has_key(type));
@@ -294,18 +294,12 @@ public File get_pluggable_module_file(Spit.Pluggable pluggable) {
return (module_rep != null) ? module_rep.file : null;
}
-public int compare_pluggable_names(void *a, void *b) {
- Spit.Pluggable *apluggable = (Spit.Pluggable *) a;
- Spit.Pluggable *bpluggable = (Spit.Pluggable *) b;
-
- return apluggable->get_pluggable_name().collate(bpluggable->get_pluggable_name());
+public int compare_pluggable_names(Spit.Pluggable a, Spit.Pluggable b) {
+ return a.get_pluggable_name().collate(b.get_pluggable_name());
}
-public int compare_extension_point_names(void *a, void *b) {
- ExtensionPoint *apoint = (ExtensionPoint *) a;
- ExtensionPoint *bpoint = (ExtensionPoint *) b;
-
- return apoint->name.collate(bpoint->name);
+public int compare_extension_point_names(ExtensionPoint a, ExtensionPoint b) {
+ return a.name.collate(b.name);
}
private bool is_shared_library(File file) {
diff --git a/src/slideshow/TransitionEffects.vala b/src/slideshow/TransitionEffects.vala
index 635fd79b..7414f853 100644
--- a/src/slideshow/TransitionEffects.vala
+++ b/src/slideshow/TransitionEffects.vala
@@ -71,7 +71,7 @@ public class TransitionEffectsManager {
return effects.keys;
}
- public Gee.Collection<string> get_effect_names(owned CompareDataFunc? comparator = null) {
+ public Gee.Collection<string> get_effect_names(owned CompareDataFunc<string>? comparator = null) {
Gee.Collection<string> effect_names = new Gee.TreeSet<string>((owned) comparator);
foreach (Spit.Transitions.Descriptor desc in effects.values)
effect_names.add(desc.get_pluggable_name());
diff --git a/src/util/string.vala b/src/util/string.vala
index 44bd6174..89424d03 100644
--- a/src/util/string.vala
+++ b/src/util/string.vala
@@ -13,13 +13,13 @@ public inline bool is_string_empty(string? s) {
}
// utf8 case sensitive compare
-public int utf8_cs_compare(void *a, void *b) {
- return ((string) a).collate((string) b);
+public int utf8_cs_compare(string a, string b) {
+ return a.collate(b);
}
// utf8 case insensitive compare
-public int utf8_ci_compare(void *a, void *b) {
- return ((string) a).down().collate(((string) b).down());
+public int utf8_ci_compare(string a, string b) {
+ return a.down().collate(b.down());
}
// utf8 array to string
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]