aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/type.h
diff options
context:
space:
mode:
authorGravatar Brendan Taylor <whateley@gmail.com>2011-07-25 19:06:10 +0000
committerGravatar Brendan Taylor <whateley@gmail.com>2011-09-17 17:03:53 +0000
commit65ace942fdabfd6116163a21eec7cd7bbd3cbcb1 (patch)
tree40b1bce4290125bfa3d3695b85fd213f2bb15f77 /src/type.h
parent1cbac1d7fb292adc0e3e07d206370aeb5ac8e7e0 (diff)
introduce getter and setter functions.
some variables didn't always have a value reflecting the browser's internal state. for example, if `default_encoding` was never set then `print @default_encoding` would always print a blank string. this introduces getter functions that ensure the value of a variable is always in sync with the internal state of the browser. also: setters, because sometimes you need to process user input before storing it.
Diffstat (limited to 'src/type.h')
-rw-r--r--src/type.h30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/type.h b/src/type.h
index 20de0b4..eda02c1 100644
--- a/src/type.h
+++ b/src/type.h
@@ -2,6 +2,9 @@
* Uzbl Types
*/
+#ifndef __UZBL_TYPE__
+#define __UZBL_TYPE__
+
enum ptr_type {
TYPE_INT = 1,
TYPE_STR,
@@ -12,15 +15,30 @@ enum ptr_type {
TYPE_STR_ARRAY
};
+// I'm doing this instead of just using "uzbl_value *" because this way our
+// list of variables can be:
+// { .ptr = { .s = &some_char_star }, ... }
+// instead of
+// { .ptr = (uzbl_value *)&some_char_star, ... }
+// which works here, but I suspect has portability issues.
+typedef union uzbl_value_ptr_t {
+ int *i;
+ float *f;
+ gchar **s;
+} uzbl_value_ptr;
+
+/* a really generic function pointer. */
+typedef void (*uzbl_fp)(void);
+
typedef struct {
enum ptr_type type;
- union {
- int *i;
- float *f;
- gchar **s;
- } ptr;
+ uzbl_value_ptr ptr;
int dump;
int writeable;
- /*@null@*/ void (*func)(void);
+
+ /* the various get_/set_ functions cast these back into something useful. */
+ uzbl_fp getter;
+ uzbl_fp setter;
} uzbl_cmdprop;
+#endif