[template-glib] eval: add string equality to dispatch table
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [template-glib] eval: add string equality to dispatch table
- Date: Fri, 22 Apr 2016 11:11:19 +0000 (UTC)
commit 28da98eecdd42967ad04542c6f7115b3fe7c8266
Author: Christian Hergert <chergert redhat com>
Date: Fri Apr 22 04:11:05 2016 -0700
eval: add string equality to dispatch table
src/tmpl-expr-eval.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/src/tmpl-expr-eval.c b/src/tmpl-expr-eval.c
index f7b637a..44d076e 100644
--- a/src/tmpl-expr-eval.c
+++ b/src/tmpl-expr-eval.c
@@ -958,6 +958,21 @@ add_string_string (const GValue *left,
return TRUE;
}
+static gboolean
+eq_string_string (const GValue *left,
+ const GValue *right,
+ GValue *return_value,
+ GError **error)
+{
+ const gchar *left_str = g_value_get_string (left);
+ const gchar *right_str = g_value_get_string (right);
+
+ g_value_init (return_value, G_TYPE_BOOLEAN);
+ g_value_set_boolean (return_value, 0 == g_strcmp0 (left_str, right_str));
+
+ return TRUE;
+}
+
#define SIMPLE_OP_FUNC(func_name, ret_type, set_func, get_left, op, get_right) \
static gboolean \
func_name (const GValue *left, \
@@ -1009,6 +1024,7 @@ build_dispatch_table (void)
ADD_DISPATCH_FUNC (TMPL_EXPR_EQ, G_TYPE_DOUBLE, G_TYPE_DOUBLE, eq_double_double);
ADD_DISPATCH_FUNC (TMPL_EXPR_MUL, G_TYPE_STRING, G_TYPE_DOUBLE, mul_string_double);
ADD_DISPATCH_FUNC (TMPL_EXPR_MUL, G_TYPE_DOUBLE, G_TYPE_STRING, mul_double_string);
+ ADD_DISPATCH_FUNC (TMPL_EXPR_EQ, G_TYPE_STRING, G_TYPE_STRING, eq_string_string);
#undef ADD_DISPATCH_FUNC
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]