aboutsummaryrefslogtreecommitdiff
path: root/civyloop.c
diff options
context:
space:
mode:
authorhattenberger2011-01-03 17:39:47 +0000
committerhattenberger2011-01-03 17:39:47 +0000
commit93717e0b2c10f79f0456db95a1ab018d15cdbc41 (patch)
tree9f894c6dd8eb2f65424927f30604c8efc7008b69 /civyloop.c
parent45995c724ad89b4f782721e7ac21445295c2453b (diff)
downloadivy-ocaml-93717e0b2c10f79f0456db95a1ab018d15cdbc41.zip
ivy-ocaml-93717e0b2c10f79f0456db95a1ab018d15cdbc41.tar.gz
ivy-ocaml-93717e0b2c10f79f0456db95a1ab018d15cdbc41.tar.bz2
ivy-ocaml-93717e0b2c10f79f0456db95a1ab018d15cdbc41.tar.xz
Update the latest version of ivy-ocaml
Diffstat (limited to 'civyloop.c')
-rw-r--r--civyloop.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/civyloop.c b/civyloop.c
index 0414654..4ff0a93 100644
--- a/civyloop.c
+++ b/civyloop.c
@@ -2,9 +2,10 @@
#include <string.h>
#include <stdio.h>
#include <getopt.h>
-#include <ivy.h>
-#include <ivyloop.h>
-#include <timer.h>
+#include <Ivy/ivy.h>
+#include <Ivy/ivyloop.h>
+#include <Ivy/timer.h>
+#include <Ivy/version.h>
#include <caml/mlvalues.h>
#include <caml/fail.h>
#include <caml/callback.h>
@@ -13,14 +14,18 @@
value ivy_mainLoop(value unit)
{
- IvyMainLoop (0);
+#if IVYMINOR_VERSION == 8
+ IvyMainLoop (NULL,NULL);
+#else
+ IvyMainLoop ();
+#endif
return Val_unit;
}
void timer_cb(TimerId id, void *data, unsigned long delta)
{
value closure = *(value*)data;
- callback(closure, Val_int((int) id));
+ callback(closure, Val_long(id));
}
value ivy_timerRepeatafter(value nb_ticks,value delay, value closure_name)
@@ -33,8 +38,9 @@ value ivy_timerRepeatafter(value nb_ticks,value delay, value closure_name)
/* Data associated to Channel callbacks is the couple of delete and
read closures */
-void cb_delete_channel(void *delete_read);
-void cb_read_channel(Channel ch, HANDLE fd, void *closure);
+extern void cb_delete_channel(void *delete_read);
+extern void cb_read_channel(Channel ch, HANDLE fd, void *closure);
+extern void cb_write_channel(Channel ch, HANDLE fd, void *closure);
value ivy_channelSetUp(value fd, value closure_name)
@@ -42,19 +48,23 @@ value ivy_channelSetUp(value fd, value closure_name)
Channel c;
value * closure = caml_named_value(String_val(closure_name));
- c = IvyChannelSetUp((HANDLE)Int_val(fd), (void*)closure, cb_delete_channel, cb_read_channel);
+#if IVYMINOR_VERSION == 8
+ c = IvyChannelAdd((HANDLE)Int_val(fd), (void*)closure, cb_delete_channel, cb_read_channel);
+#else
+ c = IvyChannelAdd((HANDLE)Int_val(fd), (void*)closure, cb_delete_channel, cb_read_channel, cb_write_channel);
+#endif
return Val_int(c);
}
value ivy_timerRemove(value t)
{
- TimerRemove((TimerId)Int_val(t));
+ TimerRemove((TimerId)Long_val(t));
return Val_unit;
}
value ivy_channelClose(value ch)
{
- IvyChannelClose((Channel)Int_val(ch));
+ IvyChannelRemove((Channel)Long_val(ch));
return Val_unit;
}