aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2001-04-04 00:04:53 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2001-04-04 00:04:53 +0800
commit004034cf32130d9cc42233de1ebdfdeb1671cb5a (patch)
tree33fd446a46d798a67b9b8c43c5ee37cd34bb696a
parent0cebe028cbf4d2292740c2b4cfb71efe57b3087e (diff)
downloadgsoc2013-evolution-004034cf32130d9cc42233de1ebdfdeb1671cb5a.tar
gsoc2013-evolution-004034cf32130d9cc42233de1ebdfdeb1671cb5a.tar.gz
gsoc2013-evolution-004034cf32130d9cc42233de1ebdfdeb1671cb5a.tar.bz2
gsoc2013-evolution-004034cf32130d9cc42233de1ebdfdeb1671cb5a.tar.lz
gsoc2013-evolution-004034cf32130d9cc42233de1ebdfdeb1671cb5a.tar.xz
gsoc2013-evolution-004034cf32130d9cc42233de1ebdfdeb1671cb5a.tar.zst
gsoc2013-evolution-004034cf32130d9cc42233de1ebdfdeb1671cb5a.zip
Added ESEXP_RES_TIME for time values. (ESExpResult): Added a "time_t
2001-04-03 Federico Mena Quintero <federico@ximian.com> * e-sexp.h (ESExpResultType): Added ESEXP_RES_TIME for time values. (ESExpResult): Added a "time_t value.time" field. (ESExpTermType): Added ESEXP_TERM_TIME. (ESExpTerm): Added a "time_t value.time" field. * e-sexp.c (e_sexp_result_free): Deal with time values. Also, be more paranoid; added a default clause with g_assert_not_reached(). (term_eval_lt): Deal with time values. (term_eval_gt): Likewise. (term_eval_eq): Likewise. (term_eval_plus): Likewise. (term_eval_sub): Likewise. (e_sexp_term_eval): Likewise. (eval_dump_result): Likewise. (parse_dump_term): Likewise. (parse_term_free): Likewise. svn path=/trunk/; revision=9130
-rw-r--r--e-util/ChangeLog20
-rw-r--r--e-util/e-sexp.c69
-rw-r--r--e-util/e-sexp.h5
3 files changed, 92 insertions, 2 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index e20785e782..5aecd21f5e 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,23 @@
+2001-04-03 Federico Mena Quintero <federico@ximian.com>
+
+ * e-sexp.h (ESExpResultType): Added ESEXP_RES_TIME for time
+ values.
+ (ESExpResult): Added a "time_t value.time" field.
+ (ESExpTermType): Added ESEXP_TERM_TIME.
+ (ESExpTerm): Added a "time_t value.time" field.
+
+ * e-sexp.c (e_sexp_result_free): Deal with time values. Also, be
+ more paranoid; added a default clause with g_assert_not_reached().
+ (term_eval_lt): Deal with time values.
+ (term_eval_gt): Likewise.
+ (term_eval_eq): Likewise.
+ (term_eval_plus): Likewise.
+ (term_eval_sub): Likewise.
+ (e_sexp_term_eval): Likewise.
+ (eval_dump_result): Likewise.
+ (parse_dump_term): Likewise.
+ (parse_term_free): Likewise.
+
2001-04-01 Gediminas Paulauskas <menesis@delfi.lt>
* e-gui-utils.h: new type EPixmap, which is used to cache pixmaps for
diff --git a/e-util/e-sexp.c b/e-util/e-sexp.c
index a1eb51cf01..a4f7c5dd0d 100644
--- a/e-util/e-sexp.c
+++ b/e-util/e-sexp.c
@@ -43,9 +43,15 @@
string = (+ string*)
Concat strings.
+ time_t = (+ time_t*)
+ Add time_t values.
+
int = (- int int*)
Subtract integers from the first.
+ time_t = (- time_t*)
+ Subtract time_t values from the first.
+
Comparison operators:
bool = (< int int)
@@ -55,7 +61,11 @@
bool = (< string string)
bool = (> string string)
bool = (= string string)
- Perform a comparision of 2 integers, or 2 string values.
+
+ bool = (< time_t time_t)
+ bool = (> time_t time_t)
+ bool = (= time_t time_t)
+ Perform a comparision of 2 integers, 2 string values, or 2 time values.
Function flow:
@@ -168,12 +178,15 @@ e_sexp_result_free(struct _ESExp *f, struct _ESExpResult *t)
break;
case ESEXP_RES_BOOL:
case ESEXP_RES_INT:
+ case ESEXP_RES_TIME:
break;
case ESEXP_RES_STRING:
g_free(t->value.string);
break;
case ESEXP_RES_UNDEFINED:
break;
+ default:
+ g_assert_not_reached();
}
e_memchunk_free(f->result_chunks, t);
}
@@ -358,6 +371,9 @@ term_eval_lt(struct _ESExp *f, int argc, struct _ESExpTerm **argv, void *data)
} else if (r1->type == ESEXP_RES_INT) {
r->type = ESEXP_RES_BOOL;
r->value.bool = r1->value.number < r2->value.number;
+ } else if (r1->type == ESEXP_RES_TIME) {
+ r->type = ESEXP_RES_BOOL;
+ r->value.bool = r1->value.time < r2->value.time;
} else if (r1->type == ESEXP_RES_STRING) {
r->type = ESEXP_RES_BOOL;
r->value.bool = strcmp(r1->value.string, r2->value.string) < 0;
@@ -387,6 +403,9 @@ term_eval_gt(struct _ESExp *f, int argc, struct _ESExpTerm **argv, void *data)
} else if (r1->type == ESEXP_RES_INT) {
r->type = ESEXP_RES_BOOL;
r->value.bool = r1->value.number > r2->value.number;
+ } else if (r1->type == ESEXP_RES_TIME) {
+ r->type = ESEXP_RES_BOOL;
+ r->value.bool = r1->value.time > r2->value.time;
} else if (r1->type == ESEXP_RES_STRING) {
r->type = ESEXP_RES_BOOL;
r->value.bool = strcmp(r1->value.string, r2->value.string) > 0;
@@ -414,6 +433,8 @@ term_eval_eq(struct _ESExp *f, int argc, struct _ESExpTerm **argv, void *data)
r->value.bool = r1->value.number == r2->value.number;
} else if (r1->type == ESEXP_RES_BOOL) {
r->value.bool = r1->value.bool == r2->value.bool;
+ } else if (r1->type == ESEXP_RES_TIME) {
+ r->value.bool = r1->value.time == r2->value.time;
} else if (r1->type == ESEXP_RES_STRING) {
r->value.bool = strcmp(r1->value.string, r2->value.string) == 0;
}
@@ -458,7 +479,22 @@ term_eval_plus(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *dat
r->value.string = s->str;
g_string_free(s, FALSE);
break; }
-
+ case ESEXP_RES_TIME: {
+ time_t total;
+
+ total = argv[0]->value.time;
+
+ for (i = 1; i < argc && argv[i]->type == ESEXP_RES_TIME; i++)
+ total += argv[i]->value.time;
+
+ if (i < argc) {
+ e_sexp_resultv_free (f, argc, argv);
+ e_sexp_fatal_error (f, "Invalid types in (+ time_t)");
+ }
+
+ r = e_sexp_result_new (f, ESEXP_RES_TIME);
+ r->value.time = total;
+ break; }
}
}
@@ -491,6 +527,22 @@ term_eval_sub(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data
r = e_sexp_result_new(f, ESEXP_RES_INT);
r->value.number = total;
break; }
+ case ESEXP_RES_TIME: {
+ time_t total;
+
+ total = argv[0]->value.time;
+
+ for (i = 1; i < argc && argv[i]->type == ESEXP_RES_TIME; i++)
+ total -= argv[i]->value.time;
+
+ if (i < argc) {
+ e_sexp_resultv_free (f, argc, argv);
+ e_sexp_fatal_error (f, "Invalid types in (- time_t)");
+ }
+
+ r = e_sexp_result_new (f, ESEXP_RES_TIME);
+ r->value.time = total;
+ break; }
}
}
@@ -570,6 +622,11 @@ e_sexp_term_eval(struct _ESExp *f, struct _ESExpTerm *t)
r = e_sexp_result_new(f, ESEXP_RES_BOOL);
r->value.bool = t->value.bool;
break;
+ case ESEXP_TERM_TIME:
+ r(printf(" (time_t %d)\n", t->value.time));
+ r = e_sexp_result_new (f, ESEXP_RES_TIME);
+ r->value.time = t->value.time;
+ break;
case ESEXP_TERM_IFUNC:
if (t->value.func.sym->f.ifunc)
r = t->value.func.sym->f.ifunc(f, t->value.func.termcount, t->value.func.terms, t->value.func.sym->data);
@@ -623,6 +680,9 @@ eval_dump_result(ESExpResult *r, int depth)
case ESEXP_RES_BOOL:
printf("bool: %c\n", r->value.bool?'t':'f');
break;
+ case ESEXP_RES_TIME:
+ printf("time_t: %ld\n", (long) r->value.time);
+ break;
case ESEXP_RES_UNDEFINED:
printf(" <undefined>\n");
break;
@@ -654,6 +714,9 @@ parse_dump_term(struct _ESExpTerm *t, int depth)
case ESEXP_TERM_BOOL:
printf(" #%c", t->value.bool?'t':'f');
break;
+ case ESEXP_TERM_TIME:
+ printf(" %ld", (long) t->value.time);
+ break;
case ESEXP_TERM_IFUNC:
case ESEXP_TERM_FUNC:
printf(" (function %s\n", t->value.func.sym->name);
@@ -711,6 +774,8 @@ parse_term_free(struct _ESExp *f, struct _ESExpTerm *t)
break;
case ESEXP_TERM_INT:
break;
+ case ESEXP_TERM_TIME:
+ break;
default:
printf("parse_term_free: unknown type: %d\n", t->type);
}
diff --git a/e-util/e-sexp.h b/e-util/e-sexp.h
index 668788f788..d4b8795c3e 100644
--- a/e-util/e-sexp.h
+++ b/e-util/e-sexp.h
@@ -5,6 +5,7 @@
#define _E_SEXP_H
#include <setjmp.h>
+#include <time.h>
#include <glib.h>
#ifdef E_SEXP_IS_GTK_OBJECT
@@ -42,6 +43,7 @@ enum _ESExpResultType {
ESEXP_RES_INT, /* type is a number */
ESEXP_RES_STRING, /* type is a pointer to a single string */
ESEXP_RES_BOOL, /* boolean type */
+ ESEXP_RES_TIME, /* time_t type */
ESEXP_RES_UNDEFINED /* unknown type */
};
@@ -52,6 +54,7 @@ struct _ESExpResult {
int number;
char *string;
int bool;
+ time_t time;
} value;
};
@@ -59,6 +62,7 @@ enum _ESExpTermType {
ESEXP_TERM_INT = 0, /* integer literal */
ESEXP_TERM_BOOL, /* boolean literal */
ESEXP_TERM_STRING, /* string literal */
+ ESEXP_TERM_TIME, /* time_t literal (number of seconds past the epoch) */
ESEXP_TERM_FUNC, /* normal function, arguments are evaluated before calling */
ESEXP_TERM_IFUNC, /* immediate function, raw terms are arguments */
ESEXP_TERM_VAR, /* variable reference */
@@ -80,6 +84,7 @@ struct _ESExpTerm {
char *string;
int number;
int bool;
+ time_t time;
struct {
struct _ESExpSymbol *sym;
struct _ESExpTerm **terms;