librelist archives

« back to archive

Moving code from C to Ruby

Moving code from C to Ruby

From:
Steve Klabnik
Date:
2012-01-04 @ 18:33
Hey all!

So, I don't have this 100% working yet, but check out this commit:
https://github.com/shoes/shoes/commit/4d3fa85e0e6f2862e15e85736e830f18a2cf219e

Basically, I tried to extract out Shoes::Color from being all C to
being all Ruby. I have it compiling now, but when I try to build, I
get this:

mkdir -p dist/pango
cp -r /usr/local/Cellar/pango/1.28.4/lib/pango/1.6.0/modules dist/pango
rake aborted!
Permission denied - dist/pango/modules/pango-arabic-fc.so

I have no idea why it's getting upset about pango modules. I didn't
change any of that! Anyway, so, more work to be done, but I thought
you might find it interesting, and I wanted to get your thoughts.

If I'm successful, I'm going to keep extracting stuff up.

Re: Moving code from C to Ruby

From:
Steve Klabnik
Date:
2012-01-04 @ 18:35
Oh, and it failed on travis, but in a different way:
http://travis-ci.org/#!/shoes/shoes/builds/478371 Must have missed a
reference somewhere.

Re: [shoes] Moving code from C to Ruby

From:
Tobias Pfeiffer
Date:
2012-01-04 @ 19:28
Hey!

No idea about the error, but interested on the stuff you want to get 
from C to ruby. Any plans or guidelines on what you want to extract from 
C to Ruby? So what ou wanna have as ruby and what shall stay C?

Greetings,
Tobi

On 01/04/2012 07:33 PM, Steve Klabnik wrote:
> Hey all!
>
> So, I don't have this 100% working yet, but check out this commit:
> https://github.com/shoes/shoes/commit/4d3fa85e0e6f2862e15e85736e830f18a2cf219e
>
> Basically, I tried to extract out Shoes::Color from being all C to
> being all Ruby. I have it compiling now, but when I try to build, I
> get this:
>
> mkdir -p dist/pango
> cp -r /usr/local/Cellar/pango/1.28.4/lib/pango/1.6.0/modules dist/pango
> rake aborted!
> Permission denied - dist/pango/modules/pango-arabic-fc.so
>
> I have no idea why it's getting upset about pango modules. I didn't
> change any of that! Anyway, so, more work to be done, but I thought
> you might find it interesting, and I wanted to get your thoughts.
>
> If I'm successful, I'm going to keep extracting stuff up.

Re: [shoes] Moving code from C to Ruby

From:
Steve Klabnik
Date:
2012-01-04 @ 19:52
> No idea about the error,

The Travis one is because I forgot to modify the Linux and Windows
files; I just did the Mac.

> but interested on the stuff you want to get
> from C to ruby. Any plans or guidelines on what you want to extract from
> C to Ruby? So what ou wanna have as ruby and what shall stay C?

I'm going to write more about this once I'm successful, but basically,
everything that's not in the shoes_native_* namespace should be able
to be converted to Ruby.

Re: [shoes] Moving code from C to Ruby

From:
Steve Klabnik
Date:
2012-01-05 @ 19:56
Okay, so I have a first version up here:
https://github.com/shoes/shoes/tree/c_to_ruby

The strangest thing is happening to me, though: it's not actually
running my Ruby. Even though I pulled out all of the C, when I run
this program:

Shoes.app do
  c1 = rgb 255, 120, 0
  c2 = rgb 0, 255, 120
  c3 = rgb 255, 120, 0
  c4 = rgb 20, 20, 20

  stack do
    if c1 == c2
      para "c1 == c2 (undesired behaviour)"
    else
      para "c1 != c2 (desired behaviour)"
    end

    if c1 == c3
      para "c1 == c3 (desired behaviour)"
    else
      para "c1 != c3 (undesired behaviour)"
    end

    if c1 > c4
      para "c1 > c4 (desired behaviour)"
    else
      para "c1 <= c4 (undesired behaviour)"
    end
  end

end

I get the old C behavior. Not my new Ruby behavior. I put alerts into
the Ruby, and they don't show up either.

Am I missing something? I did the whole clean thing, rebuilt, all of
that. The Ruby code does show up in the resulting .app.

Re: [shoes] Moving code from C to Ruby

From:
Chuck Remes
Date:
2012-01-05 @ 21:21
On Jan 5, 2012, at 1:56 PM, Steve Klabnik wrote:

> Okay, so I have a first version up here:
> https://github.com/shoes/shoes/tree/c_to_ruby
> 
> The strangest thing is happening to me, though: it's not actually
> running my Ruby. Even though I pulled out all of the C, when I run
> this program:
> 
> Am I missing something? I did the whole clean thing, rebuilt, all of
> that. The Ruby code does show up in the resulting .app.

It's possible that the makefile is fubar. You should remove the *.o files by hand.

  % find ./path/to/topoftree -name "*.o" -print0 | xargs -0 rm

And then try building again.

cr

Re: [shoes] Moving code from C to Ruby

From:
Steve Klabnik
Date:
2012-01-05 @ 21:25
There aren't any .o files. I hand-rm'd dist/.

Re: [shoes] Moving code from C to Ruby

From:
Tobias Pfeiffer
Date:
2012-01-05 @ 21:27
I'll try to give it a try tomorrow

On 01/05/2012 10:25 PM, Steve Klabnik wrote:
> There aren't any .o files. I hand-rm'd dist/.

Re: [shoes] Moving code from C to Ruby

From:
Steve Klabnik
Date:
2012-01-05 @ 21:29
> I'll try to give it a try tomorrow

Awesome. Note that it's still failing on Travis:
http://travis-ci.org/#!/shoes/shoes/builds/482673

So you might need to do a little bit of screwing around with it, if
you're doing stuff on Linux or Windows.

Re: [shoes] Moving code from C to Ruby

From:
Tobias Pfeiffer
Date:
2012-01-06 @ 23:57
On 01/05/2012 10:29 PM, Steve Klabnik wrote:
>> I'll try to give it a try tomorrow
> Awesome. Note that it's still failing on Travis:
> http://travis-ci.org/#!/shoes/shoes/builds/482673
>
> So you might need to do a little bit of screwing around with it, if
> you're doing stuff on Linux or Windows.
With my lack of knowledge of the concrete shoes implementation and C 
screwing around unfortunately isn't so easy, I get the following error: 
https://gist.github.com/1573067

I believe it's the following line:
shoes/native/gtk.c:1196:46: error: ‘cColor’ undeclared (first use in 
this function)

I guess I need to tell shoes somewhere to use the ruby version instead 
of the C version - but where?

Thanks and good night everyone!
Tobi

Re: [shoes] Moving code from C to Ruby

From:
Steve Klabnik
Date:
2012-01-07 @ 01:58
Ah! add a 'extern VALUE cColor' to the top of gtk.h

Re: [shoes] Moving code from C to Ruby

From:
Tobias Pfeiffer
Date:
2012-01-11 @ 16:39
Sorry for being so late, lots of university stuff to do...

There is no gtk.h :-( I put it in native.h instead (I hope that's ok?) 
but I still get an error

(where I as a non Cer thin the error comes from)
shoes/native/gtk.c:1094:15: error: ‘_color’ undeclared (first use in 
this function)

(full error log for more knoledgable people)
https://gist.github.com/1595531

Tobi



On 01/07/2012 02:58 AM, Steve Klabnik wrote:
> Ah! add a 'extern VALUE cColor' to the top of gtk.h

Re: [shoes] Moving code from C to Ruby

From:
Tobias Pfeiffer
Date:
2012-01-05 @ 21:35
On 01/05/2012 10:29 PM, Steve Klabnik wrote:
>> I'll try to give it a try tomorrow
> Awesome. Note that it's still failing on Travis:
> http://travis-ci.org/#!/shoes/shoes/builds/482673
>
> So you might need to do a little bit of screwing around with it, if
> you're doing stuff on Linux or Windows.
Linux. First finishing a paper until 16:00 and explaining why I think 
that the task is bad and hasn't been thought through, then meetup with 
friends and then some open source, sounds like a good day ;-)