aboutsummaryrefslogtreecommitdiffstats
path: root/e-util/e-sexp.h
diff options
context:
space:
mode:
authorNotZed <NotZed@HelixCode.com>2000-02-29 02:26:24 +0800
committerMichael Zucci <zucchi@src.gnome.org>2000-02-29 02:26:24 +0800
commit5c92a18781a5b43ff0534e519b5dbabb09831e88 (patch)
treefae7c69ef2900979775f921f38112c0845a18743 /e-util/e-sexp.h
parentafd0dcbd68a9ca7af0e127074d293ebe139fb5a7 (diff)
downloadgsoc2013-evolution-5c92a18781a5b43ff0534e519b5dbabb09831e88.tar
gsoc2013-evolution-5c92a18781a5b43ff0534e519b5dbabb09831e88.tar.gz
gsoc2013-evolution-5c92a18781a5b43ff0534e519b5dbabb09831e88.tar.bz2
gsoc2013-evolution-5c92a18781a5b43ff0534e519b5dbabb09831e88.tar.lz
gsoc2013-evolution-5c92a18781a5b43ff0534e519b5dbabb09831e88.tar.xz
gsoc2013-evolution-5c92a18781a5b43ff0534e519b5dbabb09831e88.tar.zst
gsoc2013-evolution-5c92a18781a5b43ff0534e519b5dbabb09831e88.zip
Added. moved from filter-sexp.[ch]
2000-02-28 NotZed <NotZed@HelixCode.com> * e-util/e-sexp.[ch]: Added. moved from filter-sexp.[ch] * e-util/Makefile.am (libeutil_a_SOURCES): Add e-sexp. (noinst_LTLIBRARIES): Changed to a libtool library. * Makefile.am (SUBDIRS): Build e-util before other stuff. (SUBDIRS): Build filter after camel. svn path=/trunk/; revision=1980
Diffstat (limited to 'e-util/e-sexp.h')
-rw-r--r--e-util/e-sexp.h115
1 files changed, 115 insertions, 0 deletions
diff --git a/e-util/e-sexp.h b/e-util/e-sexp.h
new file mode 100644
index 0000000000..a41fdb0b58
--- /dev/null
+++ b/e-util/e-sexp.h
@@ -0,0 +1,115 @@
+/*
+ generic s-exp evaluator class
+*/
+#ifndef _E_SEXP_H
+#define _E_SEXP_H
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#define E_SEXP(obj) GTK_CHECK_CAST (obj, e_sexp_get_type (), ESExp)
+#define E_SEXP_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_sexp_get_type (), ESExpClass)
+#define FILTER_IS_SEXP(obj) GTK_CHECK_TYPE (obj, e_sexp_get_type ())
+
+typedef struct _ESExp ESExp;
+typedef struct _ESExpClass ESExpClass;
+
+typedef struct _ESExpSymbol ESExpSymbol;
+typedef struct _ESExpResult ESExpResult;
+typedef struct _ESExpTerm ESExpTerm;
+
+typedef struct _ESExpResult *(ESExpFunc)(struct _ESExp *sexp,
+ int argc,
+ struct _ESExpResult **argv,
+ void *data);
+
+typedef struct _ESExpResult *(ESExpIFunc)(struct _ESExp *sexp,
+ int argc,
+ struct _ESExpTerm **argv,
+ void *data);
+enum _ESExpResultType {
+ ESEXP_RES_ARRAY_PTR=0, /* type is a ptrarray, what it points to is implementation dependant */
+ 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_UNDEFINED /* unknown type */
+};
+
+struct _ESExpResult {
+ enum _ESExpResultType type;
+ union {
+ GPtrArray *ptrarray;
+ int number;
+ char *string;
+ int bool;
+ } value;
+};
+
+enum _ESExpTermType {
+ ESEXP_TERM_INT = 0, /* integer literal */
+ ESEXP_TERM_BOOL, /* boolean literal */
+ ESEXP_TERM_STRING, /* string literal */
+ ESEXP_TERM_FUNC, /* normal function, arguments are evaluated before calling */
+ ESEXP_TERM_IFUNC, /* immediate function, raw terms are arguments */
+ ESEXP_TERM_VAR, /* variable reference */
+};
+
+struct _ESExpSymbol {
+ int type; /* ESEXP_TERM_FUNC or ESEXP_TERM_VAR */
+ char *name;
+ void *data;
+ union {
+ ESExpFunc *func;
+ ESExpIFunc *ifunc;
+ } f;
+};
+
+struct _ESExpTerm {
+ enum _ESExpTermType type;
+ union {
+ char *string;
+ int number;
+ int bool;
+ struct {
+ struct _ESExpSymbol *sym;
+ struct _ESExpTerm **terms;
+ int termcount;
+ } func;
+ struct _ESExpSymbol *var;
+ } value;
+};
+
+
+
+struct _ESExp {
+ GtkObject object;
+
+ GScanner *scanner; /* for parsing text version */
+ ESExpTerm *tree; /* root of expression tree */
+};
+
+struct _ESExpClass {
+ GtkObjectClass parent_class;
+
+};
+
+guint e_sexp_get_type (void);
+ESExp *e_sexp_new (void);
+void e_sexp_add_function (ESExp *f, int scope, char *name, ESExpFunc *func, void *data);
+void e_sexp_add_ifunction (ESExp *f, int scope, char *name, ESExpIFunc *func, void *data);
+void e_sexp_add_variable (ESExp *f, int scope, char *name, ESExpTerm *value);
+void e_sexp_remove_symbol (ESExp *f, int scope, char *name);
+int e_sexp_set_scope (ESExp *f, int scope);
+
+void e_sexp_input_text (ESExp *f, char *text, int len);
+void e_sexp_input_file (ESExp *f, int fd);
+
+
+void e_sexp_parse (ESExp *f);
+ESExpResult *e_sexp_eval (ESExp *f);
+
+ESExpResult *e_sexp_term_eval (struct _ESExp *f, struct _ESExpTerm *t);
+ESExpResult *e_sexp_result_new (int type);
+void e_sexp_result_free (struct _ESExpResult *t);
+
+#endif /* _E_SEXP_H */