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

U

unbewust

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
 
T

Tim Pease

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
 
B

brabuhr

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-rubycocoa/2)

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
 
U

unbewust

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,962
Messages
2,570,134
Members
46,690
Latest member
MacGyver

Latest Threads

Top