projects
/
ruby-ecore.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Implemented inspect and the manage* and sniff* methods.
[ruby-ecore.git]
/
src
/
ecore_job
/
rb_job.c
diff --git
a/src/ecore_job/rb_job.c
b/src/ecore_job/rb_job.c
index e0b1691054f4dcc2ab36ec5855cadc6cd0c53e3d..71fe1e3143308f28ed545fc34396b65c6f0c3447 100644
(file)
--- a/
src/ecore_job/rb_job.c
+++ b/
src/ecore_job/rb_job.c
@@
-1,7
+1,7
@@
/*
/*
- * $Id: rb_job.c
27 2004-07-08 18:25:05
Z tilman $
+ * $Id: rb_job.c
77 2004-08-19 17:39:29
Z tilman $
*
*
- * Copyright (C) 2004
Tilman Sauerbeck (tilman at code-monkey de
)
+ * Copyright (C) 2004
ruby-ecore team (see AUTHORS
)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@
-27,62
+27,79
@@
#include "rb_ecore_job.h"
typedef struct {
#include "rb_ecore_job.h"
typedef struct {
- Ecore_Job *
job
;
-
void *cb
;
+ Ecore_Job *
real
;
+
VALUE callback
;
bool deleted;
bool deleted;
-} RbEcoreJob;
-
-static VALUE cJob;
+} RbJob;
static void on_job (void *data)
{
static void on_job (void *data)
{
- Rb
Ecore
Job *job = data;
+ RbJob *job = data;
- rb_funcall (
(VALUE) job->cb
, rb_intern ("call"), 0);
+ rb_funcall (
job->callback
, rb_intern ("call"), 0);
job->deleted = true;
}
job->deleted = true;
}
-static void c_free (RbEcoreJob *job)
+static void c_mark (RbJob *job)
+{
+ rb_gc_mark (job->callback);
+}
+
+static void c_free (RbJob *job)
{
{
- if (job->
job
&& !job->deleted)
- ecore_job_del (job->
job
);
+ if (job->
real
&& !job->deleted)
+ ecore_job_del (job->
real
);
ecore_shutdown ();
free (job);
}
ecore_shutdown ();
free (job);
}
+/*
+ * call-seq:
+ * Ecore::Job::Job.new { block } => job
+ *
+ * Creates an Ecore::Job::Job object.
+ * After execution, the object will be deleted.
+ */
static VALUE c_new (VALUE klass)
{
VALUE self;
static VALUE c_new (VALUE klass)
{
VALUE self;
- Rb
Ecore
Job *job;
+ RbJob *job;
if (!rb_block_given_p ())
return Qnil;
if (!rb_block_given_p ())
return Qnil;
- self = Data_Make_Struct (klass, Rb
EcoreJob, NULL
, c_free, job);
+ self = Data_Make_Struct (klass, Rb
Job, c_mark
, c_free, job);
ecore_init ();
ecore_init ();
- job->cb = (void *) rb_block_proc ();
- job->job = ecore_job_add (on_job, job);
+ job->callback = rb_block_proc ();
+ job->deleted = false;
+ job->real = ecore_job_add (on_job, job);
rb_obj_call_init (self, 0, NULL);
return self;
}
rb_obj_call_init (self, 0, NULL);
return self;
}
+/*
+ * call-seq:
+ * job.delete => nil
+ *
+ * Deletes <i>job</i>.
+ */
static VALUE c_delete (VALUE self)
{
VALUE ret = Qfalse;
static VALUE c_delete (VALUE self)
{
VALUE ret = Qfalse;
- Rb
Ecore
Job *job = NULL;
+ RbJob *job = NULL;
- Data_Get_Struct (self, Rb
Ecore
Job, job);
+ Data_Get_Struct (self, RbJob, job);
- if (job->
job
&& !job->deleted) {
- ecore_job_del (job->
job
);
+ if (job->
real
&& !job->deleted) {
+ ecore_job_del (job->
real
);
job->deleted = true;
job->deleted = true;
- job->
job
= NULL;
+ job->
real
= NULL;
ret = Qtrue;
}
ret = Qtrue;
}
@@
-91,9
+108,8
@@
static VALUE c_delete (VALUE self)
void Init_Job (void)
{
void Init_Job (void)
{
-
cJob
= rb_define_class_under (mJob, "Job", rb_cObject);
+
VALUE c
= rb_define_class_under (mJob, "Job", rb_cObject);
- rb_define_singleton_method (c
Job
, "new", c_new, 0);
- rb_define_method (c
Job
, "delete", c_delete, 0);
+ rb_define_singleton_method (c, "new", c_new, 0);
+ rb_define_method (c, "delete", c_delete, 0);
}
}
-