[Ironruby-core] IronRuby for GIMP

Michael Letterle michael.letterle at gmail.com
Thu Oct 30 10:05:21 EDT 2008


FWIW I've used this helper method:

class Array

    def to_clr_arr
        arr = System::Array.CreateInstance self[0].class.to_clr_type,
self.length.to_clr_int
        self.each_with_index { |r, i| arr[i] = r }
        return arr
    end
end

Here's the to_clr_int method:

class Object
    def to_clr_int
        System::Int32.parse(self.to_s)
    end
end

On Thu, Oct 30, 2008 at 12:10 AM, Tomas Matousek <
Tomas.Matousek at microsoft.com> wrote:

> RubyArrays are not implicitly convertible to CLR arrays.
>
> You need something like:
>
> def to_string_vector array
>  list = System::Collections::Generic::List[ClrString].new
>  array.each {|x| list.add(x.to_s.to_clr_string) }
>  list.to_array
> end
>
> Tomas
>
> -----Original Message-----
> From: ironruby-core-bounces at rubyforge.org [mailto:
> ironruby-core-bounces at rubyforge.org] On Behalf Of Jim Deville
> Sent: Wednesday, October 29, 2008 4:04 PM
> To: ironruby-core at rubyforge.org
> Subject: Re: [Ironruby-core] IronRuby for GIMP
>
> Did anyone ever help you with this?
>
> -----Original Message-----
> From: ironruby-core-bounces at rubyforge.org [mailto:
> ironruby-core-bounces at rubyforge.org] On Behalf Of Maurits Rijk
> Sent: Monday, October 27, 2008 8:44 AM
> To: ironruby-core at rubyforge.org
> Subject: [Ironruby-core] IronRuby for GIMP
>
> I'm completely new at IronRuby and I try to use it for writing GIMP
> plug-ins, using my GIMP# library
> (http://sourceforge.net/projects/gimp-sharp/).
>
> I have hacked up the following code:
>
> require "../../lib/gimp-sharp"
> require "mscorlib"
>
> class RubySample < Gimp::Plugin
>
>  def initialize(args)
>    super(args, 'RubySample')
>  end
>
> end
>
> puts ARGV[0]
> RubySample.new(ARGV)
>
> ---
>
> But I get the following error: unknown: wrong number or type of
> arguments for `initialize' (ArgumentError)
>
> The Plugin class has a constructor that takes two arguments: an array of
> strings (the command line arguments) and a string. Does IronRuby have a
> different notion of arrays and/or strings than the CLR? If so, how do I
> convert them?
>
> 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
>
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
>
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
>



-- 
Michael Letterle
[Polymath Prokrammer]
http://blog.prokrams.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20081030/1f529dba/attachment-0001.html>


More information about the Ironruby-core mailing list