projects
/
ruby-ecore.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
We now use real structs to wrap objects.
[ruby-ecore.git]
/
src
/
ecore
/
rb_timer.c
diff --git
a/src/ecore/rb_timer.c
b/src/ecore/rb_timer.c
index 543a5415f6dcc2c3ad2a423dce81ec361b8d04b1..fa9ab155cb960d0a10482272215e00b945a1fad2 100644
(file)
--- a/
src/ecore/rb_timer.c
+++ b/
src/ecore/rb_timer.c
@@
-1,5
+1,5
@@
/*
/*
- * $Id: rb_timer.c
40 2004-07-25 13:14:34
Z tilman $
+ * $Id: rb_timer.c
50 2004-08-01 10:18:39
Z tilman $
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
*
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
@@
-19,24
+19,24
@@
*/
#include <ruby.h>
*/
#include <ruby.h>
+#include <stdbool.h>
#include <Ecore.h>
#include <Ecore.h>
-#include <stdbool.h>
#include "rb_ecore.h"
typedef struct {
#include "rb_ecore.h"
typedef struct {
- Ecore_Timer *
timer
;
-
void *cb
;
+ Ecore_Timer *
real
;
+
VALUE callback
;
bool deleted;
bool deleted;
-} Rb
Ecore
Timer;
+} RbTimer;
static int on_timer (void *data)
{
VALUE r;
static int on_timer (void *data)
{
VALUE r;
- Rb
Ecore
Timer *timer = data;
+ RbTimer *timer = data;
- r = rb_funcall (
(VALUE) timer->cb
, rb_intern ("call"), 0);
+ r = rb_funcall (
timer->callback
, rb_intern ("call"), 0);
/* if the callback returns false, we return 0 and Ecore
* will remove the timer
/* if the callback returns false, we return 0 and Ecore
* will remove the timer
@@
-47,10
+47,15
@@
static int on_timer (void *data)
return (r != Qfalse);
}
return (r != Qfalse);
}
-static void c_free (RbEcoreTimer *timer)
+static void c_mark (RbTimer *timer)
+{
+ rb_gc_mark (timer->callback);
+}
+
+static void c_free (RbTimer *timer)
{
{
- if (timer->
timer
&& !timer->deleted)
- ecore_timer_del (timer->
timer
);
+ if (timer->
real
&& !timer->deleted)
+ ecore_timer_del (timer->
real
);
ecore_shutdown ();
ecore_shutdown ();
@@
-60,18
+65,18
@@
static void c_free (RbEcoreTimer *timer)
static VALUE c_new (VALUE klass, VALUE interval)
{
VALUE self;
static VALUE c_new (VALUE klass, VALUE interval)
{
VALUE self;
- Rb
EcoreTimer *timer
;
+ Rb
Timer *timer = NULL
;
if (!rb_block_given_p ())
return Qnil;
if (!rb_block_given_p ())
return Qnil;
- self = Data_Make_Struct (klass, Rb
EcoreTimer, NULL
, c_free, timer);
+ self = Data_Make_Struct (klass, Rb
Timer, c_mark
, c_free, timer);
ecore_init ();
ecore_init ();
- timer->c
b = (void *)
rb_block_proc ();
- timer->
timer
= ecore_timer_add (NUM2DBL (interval),
-
on_timer, timer);
+ timer->c
allback =
rb_block_proc ();
+ timer->
real
= ecore_timer_add (NUM2DBL (interval),
+ on_timer, timer);
rb_obj_call_init (self, 0, NULL);
rb_obj_call_init (self, 0, NULL);
@@
-80,13
+85,11
@@
static VALUE c_new (VALUE klass, VALUE interval)
static VALUE c_delete (VALUE self)
{
static VALUE c_delete (VALUE self)
{
- RbEcoreTimer *timer = NULL;
-
- Data_Get_Struct (self, RbEcoreTimer, timer);
+ GET_OBJ (self, RbTimer, timer);
- if (timer->
timer
&& !timer->deleted) {
- ecore_timer_del (timer->
timer
);
- timer->
timer
= NULL;
+ if (timer->
real
&& !timer->deleted) {
+ ecore_timer_del (timer->
real
);
+ timer->
real
= NULL;
timer->deleted = true;
} else
rb_raise (rb_eException, "Timer already deleted!");
timer->deleted = true;
} else
rb_raise (rb_eException, "Timer already deleted!");