summaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorkr.angelov <kr.angelov@gmail.com>2013-09-17 13:45:37 +0000
committerkr.angelov <kr.angelov@gmail.com>2013-09-17 13:45:37 +0000
commitd1e6a9c2ba8eafe7a08b81707dd2a3150dae8b7b (patch)
tree4d46ec6eb5bb095cb23d218dcd186776b74a7281 /src/runtime
parent2a49e4e1d64ef2df0bb2a8a3822f7fa1048e687f (diff)
added order and equality for strings in libgu
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/c/gu/string.c31
-rw-r--r--src/runtime/c/gu/string.h19
2 files changed, 35 insertions, 15 deletions
diff --git a/src/runtime/c/gu/string.c b/src/runtime/c/gu/string.c
index 26b4f1f80..fb002d167 100644
--- a/src/runtime/c/gu/string.c
+++ b/src/runtime/c/gu/string.c
@@ -421,6 +421,17 @@ gu_string_eq(GuString s1, GuString s2)
}
+static bool
+gu_string_eq_fn(GuEquality* self, const void* p1, const void* p2)
+{
+ (void) self;
+ const GuString* sp1 = p1;
+ const GuString* sp2 = p2;
+ return gu_string_eq(*sp1, *sp2);
+}
+
+GuEquality gu_string_equality[1] = { { gu_string_eq_fn } };
+
int
gu_string_cmp(GuString s1, GuString s2)
{
@@ -478,21 +489,23 @@ gu_string_cmp(GuString s1, GuString s2)
return 0;
}
-static GuHash
-gu_string_hasher_hash(GuHasher* self, const void* p)
+static int
+gu_string_cmp_fn(GuOrder* self, const void* p1, const void* p2)
{
(void) self;
- const GuString* sp = p;
- return gu_string_hash(0, *sp);
+ const GuString* sp1 = p1;
+ const GuString* sp2 = p2;
+ return gu_string_cmp(*sp1, *sp2);
}
-static bool
-gu_string_eq_fn(GuEquality* self, const void* p1, const void* p2)
+GuOrder gu_string_order[1] = { { gu_string_cmp_fn } };
+
+static GuHash
+gu_string_hasher_hash(GuHasher* self, const void* p)
{
(void) self;
- const GuString* sp1 = p1;
- const GuString* sp2 = p2;
- return gu_string_eq(*sp1, *sp2);
+ const GuString* sp = p;
+ return gu_string_hash(0, *sp);
}
GuHasher gu_string_hasher[1] = {
diff --git a/src/runtime/c/gu/string.h b/src/runtime/c/gu/string.h
index 4d309d20b..ea4792b11 100644
--- a/src/runtime/c/gu/string.h
+++ b/src/runtime/c/gu/string.h
@@ -81,6 +81,19 @@ gu_string_is_prefix(GuString s1, GuString s2);
#endif // GU_STRING_H_
+#if defined(GU_FUN_H_) && !defined(GU_STRING_H_FUN_)
+#define GU_STRING_H_FUN_
+bool
+gu_string_eq(GuString s1, GuString s2);
+
+extern GuEquality gu_string_equality[1];
+
+int
+gu_string_cmp(GuString s1, GuString s2);
+
+extern GuOrder gu_string_order[1];
+#endif
+
#if defined(GU_HASH_H_) && !defined(GU_STRING_H_HASH_)
#define GU_STRING_H_HASH_
@@ -88,12 +101,6 @@ GuHash
gu_string_hash(GuHash h, GuString s);
extern GuHasher gu_string_hasher[1];
-
-bool
-gu_string_eq(GuString s1, GuString s2);
-
-int
-gu_string_cmp(GuString s1, GuString s2);
#endif
#ifdef GU_TYPE_H_