diff options
author | hattenberger | 2013-03-27 13:17:19 +0000 |
---|---|---|
committer | hattenberger | 2013-03-27 13:17:19 +0000 |
commit | a17272283c803e13258e5dc6b19533c672ceee18 (patch) | |
tree | 0fa7737e21fe1147c860a84b18676cd99a80fdb1 /trunk/cglibivy.c | |
parent | 003d66dc1fabc063372e4f03265935d0ccaefd78 (diff) | |
download | ivy-ocaml-a17272283c803e13258e5dc6b19533c672ceee18.zip ivy-ocaml-a17272283c803e13258e5dc6b19533c672ceee18.tar.gz ivy-ocaml-a17272283c803e13258e5dc6b19533c672ceee18.tar.bz2 ivy-ocaml-a17272283c803e13258e5dc6b19533c672ceee18.tar.xz |
some fixes in ivy-ocaml tag 1.2
Diffstat (limited to 'trunk/cglibivy.c')
-rw-r--r-- | trunk/cglibivy.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/trunk/cglibivy.c b/trunk/cglibivy.c new file mode 100644 index 0000000..8241b70 --- /dev/null +++ b/trunk/cglibivy.c @@ -0,0 +1,43 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <getopt.h> +#include <Ivy/timer.h> +#include <Ivy/ivychannel.h> +#include <Ivy/ivyglibloop.h> +#include <Ivy/version.h> +#include <glib.h> +#include <caml/mlvalues.h> +#include <caml/fail.h> +#include <caml/callback.h> +#include <caml/memory.h> +#include <caml/alloc.h> + +value ivy_GtkmainLoop(value unit) +{ + g_main_loop_run(g_main_loop_new(NULL, FALSE)); + return Val_unit; +} + +extern void cb_delete_channel(void *delete_read); +extern void cb_read_channel(Channel ch, IVY_HANDLE fd, void *closure); +extern void cb_write_channel(Channel ch, IVY_HANDLE fd, void *closure); + +value ivy_GtkchannelSetUp(value fd, value closure_name) +{ + Channel c; + value * closure = caml_named_value(String_val(closure_name)); + +#if IVYMINOR_VERSION == 8 + c = IvyChannelAdd((IVY_HANDLE)Int_val(fd), (void*)closure, cb_delete_channel, cb_read_channel); +#else + c = IvyChannelAdd((IVY_HANDLE)Int_val(fd), (void*)closure, cb_delete_channel, cb_read_channel, cb_write_channel); +#endif + return Val_int(c); +} + +value ivy_GtkchannelClose(value ch) +{ + IvyChannelRemove((Channel)Long_val(ch)); + return Val_unit; +} |