librelist archives

« back to archive

File organisation

File organisation

From:
Noel Warren
Date:
2012-06-29 @ 17:15
Here's a simple little question
  My rice cpp file has over 300 lines and is quickly growing.  How should I
go about subdividing it into seperate files.  One thing that worries me is
that the create_makefile method seems to find my cpp file even when I
mis-spell it.

Re: [rice] File organisation

From:
Jason Roelofs
Date:
2012-06-29 @ 17:30
On Jun 29, 2012, at 1:15 PM, Noel Warren wrote:

> Here's a simple little question
>   My rice cpp file has over 300 lines and is quickly growing.  How 
should I go about subdividing it into seperate files.  One thing that 
worries me is that the create_makefile method seems to find my cpp file 
even when I mis-spell it.

How I set up rb++ to separate files is to put each wrapped class into it's
own cpp file inside of a method that's exposed through a header. Then your
main extension.cpp file simply calls all the various methods. Something 
like this:

myClass.hpp

void wrap_myClass();

myClass.cp

void wrap_myClass() {
   // Rice code for myClass
}

myExtension.cpp

#include myClass.hpp

void init_MyExtension() {
  wrap_myClass();
}

As for create_makefile, I'm pretty sure it's going to find any *.cpp file 
in the directory. The name is simply used for the name of the resulting 
library.

Jason

Re: [rice] File organisation

From:
Noel Warren
Date:
2012-07-02 @ 19:09
2012/6/29 Jason Roelofs <jameskilton@gmail.com>

> On Jun 29, 2012, at 1:15 PM, Noel Warren wrote:
>
> > Here's a simple little question
> >   My rice cpp file has over 300 lines and is quickly growing.  How
> should I go about subdividing it into seperate files.  One thing that
> worries me is that the create_makefile method seems to find my cpp file
> even when I mis-spell it.
>
> How I set up rb++ to separate files is to put each wrapped class into it's
> own cpp file inside of a method that's exposed through a header. Then your
> main extension.cpp file simply calls all the various methods. Something
> like this:
>
> myClass.hpp
>
> void wrap_myClass();
>
> myClass.cp
>
> void wrap_myClass() {
>    // Rice code for myClass
> }
>
> myExtension.cpp
>
> #include myClass.hpp
>
> void init_MyExtension() {
>   wrap_myClass();
> }
>

Worked a charm.  My mouse's scroll wheel is now safe from destruction and
my brain is returning to sanity.  Thanks a million

>
> As for create_makefile, I'm pretty sure it's going to find any *.cpp file
> in the directory. The name is simply used for the name of the resulting
> library.
>
> Ah.  That would explain it.  My bad.  Should read the documentation (Did
read it but then decided to forget what I had read)  before posting
 questions.

> Jason
>