[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

RDoc of C extensions that extend classes

Brian Schröder

2/11/2005 2:11:00 PM

Hello Group,

I'm having a problem documenting my C extensions. The extension actually
consists of multiple differenct extensions.
One that defines a Class and some Functions on it, and others that
expand the functionality of the class by adding functions to it. When
I'`m running rdoc1.8 on the sourcecode, it documents only those
functions that are defined in the main c-file. The other functions (that
reside in subdirectories) are not documented.

What can I do to make rdoc include the missing functions?

best regards,

Brian


2 Answers

Charles Mills

2/11/2005 4:22:00 PM

0

Brian Schröder wrote:
> Hello Group,
>
> I'm having a problem documenting my C extensions. The extension
actually
> consists of multiple differenct extensions.
> One that defines a Class and some Functions on it, and others that
> expand the functionality of the class by adding functions to it. When

> I'`m running rdoc1.8 on the sourcecode, it documents only those
> functions that are defined in the main c-file. The other functions
(that
> reside in subdirectories) are not documented.
>
> What can I do to make rdoc include the missing functions?
>
There have been a number of patches posted to ruby core regarding rdoc
and C extensions in the last few months. I think one of them addresses
this issue.
But in the meantime you can add the following in the Init_() functions
of each of the C modules that expand the functionality of a class:

#ifdef RDOC_NEVER_DEFINED
cMyClass = rb_define_class(...);
#endif

Do your C modules that extend classes have Init_() functions that are
called from your main init function (init_mylib())?

-Charlie

Brian Schröder

2/11/2005 5:27:00 PM

0

On Sat, 12 Feb 2005 01:25:02 +0900
"Charles Mills" <cmills@freeshell.org> wrote:

> Brian Schröder wrote:
> > Hello Group,
> >
> > I'm having a problem documenting my C extensions. The extension
> actually
> > consists of multiple differenct extensions.
> > One that defines a Class and some Functions on it, and others that
> > expand the functionality of the class by adding functions to it.
> > When
>
> > I'`m running rdoc1.8 on the sourcecode, it documents only those
> > functions that are defined in the main c-file. The other functions
> (that
> > reside in subdirectories) are not documented.
> >
> > What can I do to make rdoc include the missing functions?
> >
> There have been a number of patches posted to ruby core regarding rdoc
> and C extensions in the last few months. I think one of them
> addresses this issue.
> But in the meantime you can add the following in the Init_() functions
> of each of the C modules that expand the functionality of a class:
>
> #ifdef RDOC_NEVER_DEFINED
> cMyClass = rb_define_class(...);
> #endif
>
> Do your C modules that extend classes have Init_() functions that are
> called from your main init function (init_mylib())?
>
> -Charlie
>
>
Thanks for the pointer,

I do not call the init functions from the main init function, but really
create standalone extensions that require the main extension. To make it
all even more complicated (maybe I'm doing it more complicated than I
need?) I require extensions written in ruby, that require the actual c
extensions. Like this:

foo.rb
foo/all.rb
foo/bar.rb
foo/baz.rb
...
foo/so/bar.so
foo/so/baz.so
...

Content of foo/bar.rb
---
require 'foo/so/bar'

class MyClass
...
end
---

Content of foo/all.rb
---
require 'foo/bar'
require 'foo/baz'
...
---

and similar for baz.

So I can choose to include

require 'foo'

for the basic functionality or

require 'foo/bar'

for foo with bar extension

or
require 'foo/bar'
require 'foo/baz'

for foo with bar and baz extension

or even

require 'foo/all'

to include everything.

The c code of the extensions is generated via ruby scripts that
automatically create a c library and its ruby bindings, so it need not
maintain everything by hand.

best regards,

Brian