[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[C ext to Ruby] mixing ObjC and C is possible ???

unbewust

8/8/2007 12:56:00 PM

hey all, i'd like to mixe ObjC and C into a C extension to Ruby.

the ObjC part (seticon for MacOS X) comes from MacOSXUtils, and works
fine.

for the C ext 2 Ruby part i've allready tested successfully the
squeleton of my class it works.

the last thing i have to do is to compil everything alltogether BUT
HERE, i get probs from gcc which doesn't like the "@" symbol used in
the *.h and *.m files coming from the ObjC side.

presently i'm using, thru an extconf.rb file, mkmf to produce the
Makefile.

i think the prob arroses here.

is there a way to get that working by modifying, manually, for ex, the
Makefile, or, proceed in two steps ???


Yvon

7 Answers

brabuhr

8/8/2007 1:10:00 PM

0

On 8/8/07, unbewust <yvon.thoraval@gmail.com> wrote:
> hey all, i'd like to mixe ObjC and C into a C extension to Ruby.
>
> the ObjC part (seticon for MacOS X) comes from MacOSXUtils, and works
> fine.

Have you looked at:
http://rubycocoa.sourceforge.ne...
"a bridge between the Ruby and the Objective-C languages, allowing you
to manipulate Objective-C objects from Ruby"

unbewust

8/8/2007 1:26:00 PM

0

On 8 ao?t, 15:09, brab...@gmail.com wrote:
> On 8/8/07, unbewust <yvon.thora...@gmail.com> wrote:
>
> > hey all, i'd like to mixe ObjC and C into a C extension to Ruby.
>
> > the ObjC part (seticon for MacOS X) comes from MacOSXUtils, and works
> > fine.
>
> Have you looked at:
> http://rubycocoa.sourceforge.ne...
> "a bridge between the Ruby and the Objective-C languages, allowing you
> to manipulate Objective-C objects from Ruby"

i know RubyCocoa and use it i've even used ObjC in RubyCocoa but here
i need to write a C ext to ruby being, somehow a wrapper of an ObjC
API...

thanks for your answer !

Yvon

Tim Pease

8/8/2007 2:54:00 PM

0

On 8/8/07, unbewust <yvon.thoraval@gmail.com> wrote:
>
> i know RubyCocoa and use it i've even used ObjC in RubyCocoa but here
> i need to write a C ext to ruby being, somehow a wrapper of an ObjC
> API...
>

I think what brabhur was suggesting was to look at the RubyCocoa
source code for some insight into how that project was able to call
ObjC from a Ruby extension.

Blessings,
TwP

brabuhr

8/8/2007 3:09:00 PM

0

On 8/8/07, unbewust <yvon.thora...@gmail.com> wrote:
> > hey all, i'd like to mixe ObjC and C into a C extension to Ruby.
> >
> > the ObjC part (seticon for MacOS X) comes from MacOSXUtils, and works
> > fine.
>
> i know RubyCocoa and use it i've even used ObjC in RubyCocoa but here
> i need to write a C ext to ruby being, somehow a wrapper of an ObjC
> API...

(left off my previous message:
http://www.rubycocoa.com/ruby-extensions-with-r...)

What about SWIG?

http://www.swig.org/Doc1.1/HTML/Introdu...
"SWIG is a code development tool that makes it possible to quickly
build powerful scripting language interfaces to C, C++, or Objective-C
programs."

http://www.swig.org/Doc1.1/HTML/SW...

http://www.swig.org/Doc1.3...

Sherm Pendley

8/8/2007 3:32:00 PM

0

"Tim Pease" <tim.pease@gmail.com> writes:

> On 8/8/07, unbewust <yvon.thoraval@gmail.com> wrote:
>>
>> i know RubyCocoa and use it i've even used ObjC in RubyCocoa but here
>> i need to write a C ext to ruby being, somehow a wrapper of an ObjC
>> API...
>>
>
> I think what brabhur was suggesting was to look at the RubyCocoa
> source code for some insight into how that project was able to call
> ObjC from a Ruby extension.

My solution for calling ObjC from Perl XS extensions was to tell GCC to
compile .c files (generated from .xs files and thus not easy to rename
to .m without patching the utility that generates them) as Objective-C.
The compiler flag for that is, surprisingly enough, -ObjC.

How to apply the -ObjC compiler flag when building Ruby extensions is a
question for someone with more Ruby expertise than me. Sorry!

sherm--

--
Web Hosting by West Virginians, for West Virginians: http://...
Cocoa programming in Perl: http://camelbones.sourc...

unbewust

8/8/2007 6:21:00 PM

0

On 8 ao?t, 17:09, brab...@gmail.com wrote:
> On 8/8/07, unbewust <yvon.thora...@gmail.com> wrote:
>
> > > hey all, i'd like to mixe ObjC and C into a C extension to Ruby.
>
> > > the ObjC part (seticon for MacOS X) comes from MacOSXUtils, and works
> > > fine.
>
> > i know RubyCocoa and use it i've even used ObjC in RubyCocoa but here
> > i need to write a C ext to ruby being, somehow a wrapper of an ObjC
> > API...
>
> (left off my previous message:
> http://www.rubycocoa.com/ruby-extensions-with-r...)
>
> What about SWIG?
>
> http://www.swig.org/Doc1.1/HTML/Introdu...
> "SWIG is a code development tool that makes it possible to quickly
> build powerful scripting language interfaces to C, C++, or Objective-C
> programs."
>
> http://www.swig.org/Doc1.1/HTML/SW...
>
> http://www.swig.org/Doc1.3...

ok thanks for swig i'll look at ;-)

Yvon

unbewust

8/8/2007 6:23:00 PM

0

On 8 ao?t, 17:32, Sherm Pendley <spamt...@dot-app.org> wrote:

> My solution for calling ObjC from Perl XS extensions was to tell GCC to
> compile .c files (generated from .xs files and thus not easy to rename
> to .m without patching the utility that generates them) as Objective-C.
> The compiler flag for that is, surprisingly enough, -ObjC.

Thanks for this tip !!!

> How to apply the -ObjC compiler flag when building Ruby extensions is a
> question for someone with more Ruby expertise than me. Sorry!
>


it's really easy to do C ext for ruby ...

Yvon