Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Ruby > Re: Ruby/DL (wa...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 70 of 71 Topic 12688 of 51534
Post > Topic >>

Re: Ruby/DL (was Re: The real Ruby vs. Python.)

by Jamis Buck <jgb3@[EMAIL PROTECTED] > Oct 29, 2004 at 12:30 AM

Michael DeHaan wrote:
> Speaking of Ruby/DL, I have a question ...
> 
> Supposing I have a library that demands control of an event loop.  
> Examples could include GLUT (glutMainLoop) or SDL, but maybe it's
> something else.    What ways are there in Ruby/DL to call back into
> Ruby code from the C library?

Ruby/DL does sup****t callbacks, but only a fixed number of them (10, by 
default, unless you compile the DL extension yourself and specify 
otherwise):

   module Stuff
     extend DL::Im****table
     dlload "..."

     extern "int fn_with_cb( void* )"

     def my_callback( x, y, z )
       do_something_with( x, y, z )
     end

     CALLBACK = callback( "int my_callback( int x, int y, int z )" )
   end

   Stuff.fn_with_cb( Stuff::CALLBACK )

There is an example in the libc.rb file in the sample subdirectory of 
the DL directory in the Ruby source distribution.

- Jamis

> 
> Is this even possible, or do I have to write Swig/XS for this?   Up
> until this point I haven't had a need for XS/Swig, so I've typically
> gone the Ruby/DL route (in what few Ruby apps I've written), or I've
> used Inline::C (awesome module, BTW) in Perl.
> 
> Anyhow, ruby-sdl and ruby-opengl may exist, but occasionally I take
> some pleasure in reinventing wheels...or at least in knowing how to.  
> In fact, ruby-opengl might be a good example after all.    I'd really
> like to stay down in C code for longer lengths of time, so this is a
> case where writing one's own bindings may be useful.
> 
> --Michael DeHaan
> 
> On Thu, 28 Oct 2004 07:49:01 +0900, gabriele renzi
> <rff_rff@[EMAIL PROTECTED]
> wrote:
> 
>>Jamis Buck ha scritto:
>>
>>
>>
>>>Besides which: Ruby/DL is often touted as a great way to write
extension
>>>libraries. Are there any examples of libraries that have been written
>>>using Ruby/DL instead of C? I've never seen any, much to my own
>>>frustration when I would like a good example of Ruby/DL usage. :(
>>>
>>
>>well I can only remember the htmltidy library, never looked at it,
anyway :/
>>
>>
> 
> 
> .
> 


-- 
Jamis Buck
jgb3@[EMAIL PROTECTED]

 




 71 Posts in Topic:
The real Ruby vs. Python.
Abe Vionas_MailingList &l  2004-10-27 23:11:19 
Re: The real Ruby vs. Python.
James Edward Gray II <  2004-10-27 23:23:25 
Re: The real Ruby vs. Python.
David Ross <dross@[EMA  2004-10-27 23:29:29 
Unix vs Windows [was: The real Ruby vs. Python.]
"Curt Hibbs" &l  2004-10-28 00:29:06 
Re: Unix vs Windows [was: The real Ruby vs. Python.]
David Ross <dross@[EMA  2004-10-28 01:05:55 
Re: Unix vs Windows [was: The real Ruby vs. Python.]
Kaspar Schiess <eule@[  2004-10-28 17:10:25 
Re: Unix vs Windows [was: The real Ruby vs. Python.]
Aredridel <aredridel@[  2004-10-28 02:32:29 
Re: Unix vs Windows [was: The real Ruby vs. Python.]
David Ross <dross@[EMA  2004-10-30 13:17:41 
Re: The real Ruby vs. Python.
Alexander Kellett <rub  2004-10-27 23:39:48 
Re: The real Ruby vs. Python.
Howard Lewis Ship <hls  2004-10-27 23:48:23 
Re: The real Ruby vs. Python.
"trans. (T. Onoma)&  2004-10-28 00:07:10 
Re: The real Ruby vs. Python.
Alexander Kellett <rub  2004-10-28 00:18:31 
Re: The real Ruby vs. Python.
=?UTF-8?B?SmFuIEtyw7xnZXI  2004-10-28 00:39:41 
Re: The real Ruby vs. Python.
Matt Mower <matt.mower  2004-10-27 23:51:33 
Re: The real Ruby vs. Python.
David Ross <dross@[EMA  2004-10-28 00:03:14 
Re: The real Ruby vs. Python.
Alexander Kellett <rub  2004-10-28 00:11:07 
Re: The real Ruby vs. Python.
David Ross <dross@[EMA  2004-10-28 00:25:37 
Re: The real Ruby vs. Python.
gabriele renzi <rff_rf  2004-10-27 21:27:57 
Re: The real Ruby vs. Python.
David Ross <dross@[EMA  2004-10-28 06:33:16 
Re: The real Ruby vs. Python.
"trans. (T. Onoma)&  2004-10-27 23:55:01 
Re: The real Ruby vs. Python.
Justin Rudd <justin.ru  2004-10-28 00:18:58 
Re: The real Ruby vs. Python.
gabriele renzi <rff_rf  2004-10-27 21:36:50 
Re: The real Ruby vs. Python.
Justin Rudd <justin.ru  2004-10-28 00:22:11 
Re: The real Ruby vs. Python.
Howard Lewis Ship <hls  2004-10-28 00:50:29 
Re: The real Ruby vs. Python.
Matt Mower <matt.mower  2004-10-28 00:55:37 
Gems as key? Re: The real Ruby vs. Python.
"Its Me" <it  2004-10-27 16:04:54 
Re: Gems as key? Re: The real Ruby vs. Python.
David Ross <dross@[EMA  2004-10-28 01:12:24 
Re: The real Ruby vs. Python.
Austin Ziegler <halost  2004-10-28 01:57:16 
Re: The real Ruby vs. Python.
Austin Ziegler <halost  2004-10-28 02:00:43 
Re: The real Ruby vs. Python.
Joao Pedrosa <joaopedr  2004-10-28 02:38:03 
Re: Gems as key? Re: The real Ruby vs. Python.
Michael DeHaan <michae  2004-10-28 02:45:07 
Re: Gems as key? Re: The real Ruby vs. Python.
"Curt Hibbs" &l  2004-10-28 03:00:08 
Re: Gems as key? Re: The real Ruby vs. Python.
"Curt Hibbs" &l  2004-10-28 03:06:50 
Re: Gems as key? Re: The real Ruby vs. Python.
"trans. (T. Onoma)&  2004-10-28 03:30:25 
Re: Gems as key? Re: The real Ruby vs. Python.
David Ross <dross@[EMA  2004-10-28 04:32:55 
Re: Gems as key? Re: The real Ruby vs. Python.
gabriele renzi <rff_rf  2004-10-27 21:45:40 
Re: Gems as key? Re: The real Ruby vs. Python.
dross@[EMAIL PROTECTED]   2004-10-28 03:35:34 
Re: Gems as key? Re: The real Ruby vs. Python.
dross@[EMAIL PROTECTED]   2004-10-28 03:32:00 
Re: Gems as key? Re: The real Ruby vs. Python.
Eivind Eklund <eeklund  2004-10-28 03:48:10 
Re: Gems as key? Re: The real Ruby vs. Python.
"Its Me" <it  2004-10-27 20:48:17 
Re: Gems as key? Re: The real Ruby vs. Python.
Mauricio =?iso-8859-1?Q?F  2004-10-28 07:34:59 
Re: Gems as key? Re: The real Ruby vs. Python.
"trans. (T. Onoma)&  2004-10-28 09:38:11 
Re: Gems as key? Re: The real Ruby vs. Python.
David Ross <dross@[EMA  2004-10-28 10:13:35 
Re: Gems as key? Re: The real Ruby vs. Python.
David Ross <dross@[EMA  2004-10-28 10:22:18 
Re: Gems as key? Re: The real Ruby vs. Python.
Andreas Schwarz <usene  2004-10-28 06:38:25 
Re: Gems as key? Re: The real Ruby vs. Python.
David Ross <dross@[EMA  2004-10-28 13:48:16 
Re: Gems as key? Re: The real Ruby vs. Python.
Mauricio =?iso-8859-1?Q?F  2004-10-28 20:44:21 
Re: Gems as key? Re: The real Ruby vs. Python.
"David A. Black"  2004-10-28 21:08:08 
Re: Gems as key? Re: The real Ruby vs. Python.
Mauricio =?iso-8859-1?Q?F  2004-10-28 22:14:41 
Re: Gems as key? Re: The real Ruby vs. Python.
Ara.T.Howard@[EMAIL PROTE  2004-10-28 07:53:29 
Re: Gems as key? Re: The real Ruby vs. Python.
Mauricio =?iso-8859-1?Q?F  2004-10-29 02:46:05 
Re: Gems as key? Re: The real Ruby vs. Python.
Chad Fowler <chad@[EMA  2004-10-28 23:31:05 
Cooperation between RubyGems and RPA (Ruby Production Archive)
Mauricio =?iso-8859-1?Q?F  2004-10-29 05:13:27 
Re: Gems as key? Re: The real Ruby vs. Python.
Bill Guindon <agorilla  2004-10-29 01:16:56 
Re: Gems as key? Re: The real Ruby vs. Python.
Gavin Sinclair <gsincl  2004-10-29 01:59:46 
Re: Gems as key? Re: The real Ruby vs. Python.
vruz <horacio.lopez@[E  2004-10-29 02:05:05 
Re: Gems as key? Re: The real Ruby vs. Python.
Hal Fulton <hal9000@[E  2004-10-29 06:33:31 
Re: Gems as key? Re: The real Ruby vs. Python.
Eivind Eklund <eeklund  2004-10-29 02:43:10 
Re: Gems as key? Re: The real Ruby vs. Python.
Chad Fowler <chad@[EMA  2004-10-29 03:06:17 
Cooperation between RubyGems and RPA (Ruby Production Archive)
Mauricio =?iso-8859-1?Q?F  2004-10-28 11:09:54 
Re: Gems as key? Re: The real Ruby vs. Python.
ggarramuno@[EMAIL PROTECT  2004-10-29 05:45:25 
Re: Gems as key? Re: The real Ruby vs. Python.
Eivind Eklund <eeklund  2004-10-28 04:03:15 
Re: The real Ruby vs. Python.
djberg96@[EMAIL PROTECTED  2004-10-27 12:41:46 
Ruby/DL (was Re: The real Ruby vs. Python.)
Jamis Buck <jgb3@[EMAI  2004-10-28 06:53:39 
Re: Ruby/DL (was Re: The real Ruby vs. Python.)
gabriele renzi <rff_rf  2004-10-27 22:44:19 
Re: Ruby/DL (was Re: The real Ruby vs. Python.)
Bill Atkins <batkins57  2004-10-28 07:44:25 
Re: Gems as key? Re: The real Ruby vs. Python.
Chad Fowler <chadfowle  2004-10-28 11:03:53 
Re: Gems as key? Re: The real Ruby vs. Python.
Eivind Eklund <eeklund  2004-10-28 21:09:33 
Re: Ruby/DL (was Re: The real Ruby vs. Python.)
Michael DeHaan <michae  2004-10-28 21:51:43 
Re: Ruby/DL (was Re: The real Ruby vs. Python.)
Jamis Buck <jgb3@[EMAI  2004-10-29 00:30:30 
Re: Ruby/DL (was Re: The real Ruby vs. Python.)
Guillaume Marcais <gus  2004-10-29 02:06:17 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Oct 7 16:13:32 CDT 2008.