[Ironruby-core] IronRuby for GIMP

Curt Hagenlocher curth at microsoft.com
Thu Oct 30 11:12:08 EDT 2008


"yield" doesn't do in Ruby what it does in C#.

You'll probably need to define your own enumerator class doing something like this:

class ProcedureEnumerator
  include System::Collections::Generic::IEnumerator.of(Procedure)

  def initialize *proc_list
    @proc_list = proc_list
    @pos = 0
  end

  def MoveNext
    @pos = @pos + 1 if @pos < @proc_list.length
    throw :IndexError if @pos < @proc_list.length
  end

  def Reset
    @pos = 0
  end

  def Current
    @proc_list[@pos]
  end
end

def ListProcedure
  ProcedureEnumerator.new(Procedure.new(...))
end

Alternatively, you could create a statically-typed list of Procedure and get an enumerator from that:

list = System::Collections::Generic::List.of(Procedure)
list.add(Procedure.new(...))


Finally, we're shortly going to change the naming policy for overrides of CLS virtual methods.  When this happens, you'll need to define ProcedureEnumerator with the "rubified" method names: move_next, reset and current.


-----Original Message-----
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Maurits Rijk
Sent: Thursday, October 30, 2008 7:45 AM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] IronRuby for GIMP

Nice, the array conversion seems to work quite well. Right now I'm
encountering the next problem. The Plugin base class (C#) has the follow
signature:

protected abstract IEnumerator<Procedure> ListProcedures();

How can I implement this in my IronRuby derived class? Of course I tried
something like:

def ListProcedures
  yield new Procedure(...)
end

However, this method never gets called.

Thanks,

Maurits
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ironruby-core mailing list
Ironruby-core at rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core



More information about the Ironruby-core mailing list