Mixing ObjC and C is possible?

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

On 8/8/07, unbewust [email protected] 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.net/HomePage
“a bridge between the Ruby and the Objective-C languages, allowing you
to manipulate Objective-C objects from Ruby”

On 8 août, 15:09, [email protected] wrote:

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

On 8/8/07, unbewust [email protected] 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:
rubycocoa.com)

What about SWIG?

http://www.swig.org/Doc1.1/HTML/Introduction.html
“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/SWIG.html#n7

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

“Tim P.” [email protected] writes:

On 8/8/07, unbewust [email protected] 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–

On 8 août, 17:32, Sherm P. [email protected] 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

On 8/8/07, unbewust [email protected] 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

On 8 août, 17:09, [email protected] wrote:

SWIG Basics

SWIG and Ruby

ok thanks for swig i’ll look at :wink:

Yvon