X-Git-Url: http://git.code-monkey.de/?p=ruby-ecore.git;a=blobdiff_plain;f=src%2Fecore_job%2Frb_job.c;h=5c4ff46c00cc55620c414ac9abacb77b28c8ce95;hp=d4348cffb0660f8c6ebb598eaddd0f8e6583e960;hb=d907bd016f15dc5be72d12ee1742047eafc2abae;hpb=f805cf241a9d1fb9765892f0af48ede8359e9b65 diff --git a/src/ecore_job/rb_job.c b/src/ecore_job/rb_job.c index d4348cf..5c4ff46 100644 --- a/src/ecore_job/rb_job.c +++ b/src/ecore_job/rb_job.c @@ -1,7 +1,7 @@ /* - * $Id: rb_job.c 50 2004-08-01 10:18:39Z tilman $ + * $Id: rb_job.c 351 2006-02-10 15:25:40Z 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 @@ -55,26 +55,44 @@ static void c_free (RbJob *job) free (job); } -static VALUE c_new (VALUE klass) +static VALUE c_alloc (VALUE klass) { - VALUE self; - RbJob *job; + RbJob *job = NULL; - if (!rb_block_given_p ()) - return Qnil; + ecore_init (); - self = Data_Make_Struct (klass, RbJob, c_mark, c_free, job); + return Data_Make_Struct (klass, RbJob, c_mark, c_free, job); +} - ecore_init (); +/* + * call-seq: + * Ecore::Job::Job.new { block } => job + * + * Creates an Ecore::Job::Job object. + * After execution, the object will be deleted. + */ +static VALUE c_init (VALUE self) +{ + RbJob *job = NULL; + + if (!rb_block_given_p ()) + rb_raise (rb_eStandardError, "block missing"); + + Data_Get_Struct (self, RbJob, 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; } +/* + * call-seq: + * job.delete => nil + * + * Deletes job. + */ static VALUE c_delete (VALUE self) { VALUE ret = Qfalse; @@ -96,6 +114,7 @@ void Init_Job (void) { VALUE c = rb_define_class_under (mJob, "Job", rb_cObject); - rb_define_singleton_method (c, "new", c_new, 0); + rb_define_alloc_func (c, c_alloc); + rb_define_method (c, "initialize", c_init, 0); rb_define_method (c, "delete", c_delete, 0); }