[template-glib] eval: add != support for double/double nad string/string
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [template-glib] eval: add != support for double/double nad string/string
- Date: Sat, 23 Apr 2016 00:38:28 +0000 (UTC)
commit abb174396fd05b864bdd6b86594e381f3ee7bf11
Author: Christian Hergert <christian hergert me>
Date: Fri Apr 22 17:38:22 2016 -0700
eval: add != support for double/double nad string/string
src/tmpl-expr-eval.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/src/tmpl-expr-eval.c b/src/tmpl-expr-eval.c
index 44d076e..a73ccb1 100644
--- a/src/tmpl-expr-eval.c
+++ b/src/tmpl-expr-eval.c
@@ -973,6 +973,21 @@ eq_string_string (const GValue *left,
return TRUE;
}
+static gboolean
+ne_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, \
@@ -995,6 +1010,7 @@ SIMPLE_OP_FUNC (lt_double_double, G_TYPE_BOOLEAN, set_boolean, get_double, <,
SIMPLE_OP_FUNC (lte_double_double, G_TYPE_BOOLEAN, set_boolean, get_double, <=, get_double)
SIMPLE_OP_FUNC (gt_double_double, G_TYPE_BOOLEAN, set_boolean, get_double, >, get_double)
SIMPLE_OP_FUNC (eq_double_double, G_TYPE_BOOLEAN, set_boolean, get_double, ==, get_double)
+SIMPLE_OP_FUNC (ne_double_double, G_TYPE_BOOLEAN, set_boolean, get_double, !=, get_double)
SIMPLE_OP_FUNC (gte_double_double, G_TYPE_BOOLEAN, set_boolean, get_double, >=, get_double)
#undef SIMPLE_OP_FUNC
@@ -1019,12 +1035,14 @@ build_dispatch_table (void)
ADD_DISPATCH_FUNC (TMPL_EXPR_UNARY_MINUS, G_TYPE_DOUBLE, 0, unary_minus_double);
ADD_DISPATCH_FUNC (TMPL_EXPR_LT, G_TYPE_DOUBLE, G_TYPE_DOUBLE, lt_double_double);
ADD_DISPATCH_FUNC (TMPL_EXPR_GT, G_TYPE_DOUBLE, G_TYPE_DOUBLE, gt_double_double);
+ ADD_DISPATCH_FUNC (TMPL_EXPR_NE, G_TYPE_DOUBLE, G_TYPE_DOUBLE, ne_double_double);
ADD_DISPATCH_FUNC (TMPL_EXPR_LTE, G_TYPE_DOUBLE, G_TYPE_DOUBLE, lte_double_double);
ADD_DISPATCH_FUNC (TMPL_EXPR_GTE, G_TYPE_DOUBLE, G_TYPE_DOUBLE, gte_double_double);
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);
+ ADD_DISPATCH_FUNC (TMPL_EXPR_NE, G_TYPE_STRING, G_TYPE_STRING, ne_string_string);
#undef ADD_DISPATCH_FUNC
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]