# Adding Accessor Methods in GR 3.7

**URL:** <https://www.ruby-forum.com/t/adding-accessor-methods-in-gr-3-7/230258>\
**Category:** GNU Radio\
**Created:** [June 6, 2014, 7:46pm UTC](https://www.ruby-forum.com/t/adding-accessor-methods-in-gr-3-7/230258 "2014-06-06T19:46:56Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jason\_sam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7993a0/32.png) [@jason\_sam](https://www.ruby-forum.com/u/jason_sam)\
**Post date:** [June 6, 2014, 7:46pm UTC](https://www.ruby-forum.com/t/adding-accessor-methods-in-gr-3-7/230258/1 "2014-06-06T19:46:56Z")

</div>

I’ve recently converted to GR 3.7, and am currently on 3.7.3.

I have created and run a new block in C++, but now want to add  
an accessor method to the block’s class. I defined it in  
\<new\_class\_name\>\_impl.h , in the public part of the  
class declaration as follows:

```
   float get_samples_per_second(void)
     {
       return d_samples_per_second;
     }

```

This compiles fine, but when I try to access it from  
GRC via a function probe, I get:

AttributeError: ‘acq\_test\_1\_cc\_sptr’ object has no attribute  
‘get\_samples\_per\_second’

Is there some additional 3.7 swig magic I have to go through  
to make this accessor available from python?

@(^.^)@ Ed

---

<div class="post-metadata">

**Author:** ![Ed\_Criscuolo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ac8455/32.png) [@Ed\_Criscuolo](https://www.ruby-forum.com/u/Ed_Criscuolo)\
**Post date:** [June 6, 2014, 7:51pm UTC](https://www.ruby-forum.com/t/adding-accessor-methods-in-gr-3-7/230258/2 "2014-06-06T19:51:39Z")

</div>

On 06/06/2014 07:44 PM, Ed Criscuolo wrote:

> I’ve recently converted to GR 3.7, and am currently on 3.7.3.

Welcome 🙂

> This compiles fine, but when I try to access it from  
> GRC via a function probe, I get:
> 
> AttributeError: ‘acq\_test\_1\_cc\_sptr’ object has no attribute  
> ‘get\_samples\_per\_second’
> 
> Is there some additional 3.7 swig magic I have to go through  
> to make this accessor available from python?

You also need to add the accessor in the include/\*.h file as a virtual  
member function.

M

---

<div class="post-metadata">

**Author:** ![Ed\_Criscuolo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ac8455/32.png) [@Ed\_Criscuolo](https://www.ruby-forum.com/u/Ed_Criscuolo)\
**Post date:** [June 6, 2014, 8:33pm UTC](https://www.ruby-forum.com/t/adding-accessor-methods-in-gr-3-7/230258/3 "2014-06-06T20:33:29Z")

</div>

On 6/6/14 1:50 PM, Martin B. wrote:

> You also need to add the accessor in the include/\*.h file as a virtual  
> member function.

Thanks Martin. That did it, although I had to rerun cmake to get it  
to propagate into the swig files.

@(^.^)@ Ed

---

<div class="post-metadata">

**Author:** ![Ed\_Criscuolo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ac8455/32.png) [@Ed\_Criscuolo](https://www.ruby-forum.com/u/Ed_Criscuolo)\
**Post date:** [June 6, 2014, 9:21pm UTC](https://www.ruby-forum.com/t/adding-accessor-methods-in-gr-3-7/230258/4 "2014-06-06T21:21:49Z")

</div>

On Fri, Jun 6, 2014 at 3:02 PM, Ed Criscuolo  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > to propagate into the swig files.  
> > Prior to this change, I had been moving this OOT module  
> > back and forth successfully between the two systems.
> 
> @(+.+)@ Ed

Can you post more of the output so we can see where this is being  
generated  
(maybe post the build log to pastebin or something)? Off the top of my  
head, that doesn’t look familiar.

Tom

---

<div class="post-metadata">

**Author:** ![Ed\_Criscuolo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ac8455/32.png) [@Ed\_Criscuolo](https://www.ruby-forum.com/u/Ed_Criscuolo)\
**Post date:** [June 6, 2014, 9:04pm UTC](https://www.ruby-forum.com/t/adding-accessor-methods-in-gr-3-7/230258/5 "2014-06-06T21:04:44Z")

</div>

On 6/6/14 2:30 PM, Ed Criscuolo wrote:

> On 6/6/14 1:50 PM, Martin B. wrote:
> 
> > You also need to add the accessor in the include/\*.h file as a virtual  
> > member function.
> 
> Thanks Martin. That did it, although I had to rerun cmake to get it  
> to propagate into the swig files.

Guess I spoke too soon. ☹ Although it worked fine on my OSX platform,  
as soon as I moved it to an Ubuntu 12.04LTS platform and tried to  
build it in a fresh build directory, the cmake ran ok but the make  
failed somewhere in the swig stuff, on a cryptically named xml file  
“\_8\_\_acq\_\_test\_\_1\_\_cc\_8h.xml” with the error

" ‘NoneType’ object has no attribute ‘compounddef’ "

Prior to this change, I had been moving this OOT module  
back and forth successfully between the two systems.

@(+.+)@ Ed

---

<div class="post-metadata">

**Author:** ![Ed\_Criscuolo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ac8455/32.png) [@Ed\_Criscuolo](https://www.ruby-forum.com/u/Ed_Criscuolo)\
**Post date:** [June 6, 2014, 9:52pm UTC](https://www.ruby-forum.com/t/adding-accessor-methods-in-gr-3-7/230258/6 "2014-06-06T21:52:27Z")

</div>

On Fri, Jun 6, 2014 at 3:37 PM, Ed Criscuolo  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > ```
> > You also need to add the accessor in the include/*.h file as
> > 
> > ```
> > 
> > platform,  
> > @(+.+)@ Ed
> 
> [21%] Built target test-tdrss  
> File “/home/edwardc/Gnu-Radio/gr-tdrss/docs/doxygen/swig\_doc.py”, line  
> self.\_parse()  
> line 203, in check\_parsed  
> self.\_parse()  
> File “/home/edwardc/Gnu-Radio/gr-tdrss/docs/doxygen/doxyxml/doxyindex.py”,  
> line 163, in \_parse  
> self.set\_descriptions(self.\_retrieved\_data.compounddef)  
> AttributeError: ‘NoneType’ object has no attribute ‘compounddef’  
> make[2]: \*\*\* [swig/tdrss\_swig\_doc.i] Error 1  
> make[1]: \*\*\* [swig/CMakeFiles/\_tdrss\_swig.dir/all] Error 2  
> make: \*\*\* [all] Error 2  
> edwardc@sdr-dev2:~/Gnu-Radio/gr-tdrss/build$

Ok, looks like your swig files weren’t updated correctly. I’m not sure  
here  
what the exact reason is. When you were converting over to the new 3.7  
api,  
did you use gr\_modtool to create the project space or did you start with  
your current one and modify it? If the former, we’ll have to take a  
closer  
look. If the latter, I’d suggest looking at the swig/tdrss\_swig.i and  
swig/CMakeLists.txt files to see that they were updated correctly.

My guess with why it worked on OSX is that you don’t have doxygen on  
your  
OS X box. If you do -DENABLE\_DOXYGEN=False, that might get passed this  
immediate issue.

Tom

---

<div class="post-metadata">

**Author:** ![Ed\_Criscuolo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ac8455/32.png) [@Ed\_Criscuolo](https://www.ruby-forum.com/u/Ed_Criscuolo)\
**Post date:** [June 6, 2014, 9:39pm UTC](https://www.ruby-forum.com/t/adding-accessor-methods-in-gr-3-7/230258/7 "2014-06-06T21:39:30Z")

</div>

On 6/6/14 3:20 PM, Tom R. wrote:

> ```
> member function.
> "_8 __acq__ test __1__ cc_8h.xml" with the error
> 
> ```
> 
> Can you post more of the output so we can see where this is being  
> generated (maybe post the build log to pastebin or something)? Off the  
> top of my head, that doesn’t look familiar.
> 
> Tom

It’s not real long, so I’ll post it here

================================================  
edwardc@sdr-dev2:~/Gnu-Radio/gr-tdrss/build$ make  
Scanning dependencies of target gnuradio-tdrss  
[5%] Building CXX object  
lib/CMakeFiles/gnuradio-tdrss.dir/acq\_test\_1\_cc\_impl.cc.o  
Linking CXX shared library libgnuradio-tdrss.so  
[10%] Built target gnuradio-tdrss  
Linking CXX executable test-tdrss  
[21%] Built target test-tdrss  
[26%] Built target \_tdrss\_swig\_swig\_tag  
[31%] Built target \_tdrss\_swig\_doc\_tag  
[36%] Generating tdrss\_swig\_doc.i  
Error in xml in file  
/home/edwardc/Gnu-Radio/gr-tdrss/build/swig/tdrss\_swig\_doc\_swig\_docs/xml/\_8\_\_acq\_\_test\_\_1\_\_cc\_8h.xml  
Traceback (most recent call last):  
File “/home/edwardc/Gnu-Radio/gr-tdrss/docs/doxygen/swig\_doc.py”,  
line 255, in   
make\_swig\_interface\_file(di, swigdocfilename,  
custom\_output=custom\_output)  
File “/home/edwardc/Gnu-Radio/gr-tdrss/docs/doxygen/swig\_doc.py”,  
line 198, in make\_swig\_interface\_file  
blocks = di.in\_category(Block)  
File “/home/edwardc/Gnu-Radio/gr-tdrss/docs/doxygen/doxyxml/base.py”,  
line 140, in in\_category  
self.confirm\_no\_error()  
File “/home/edwardc/Gnu-Radio/gr-tdrss/docs/doxygen/doxyxml/base.py”,  
line 206, in confirm\_no\_error  
self.check\_parsed()  
File “/home/edwardc/Gnu-Radio/gr-tdrss/docs/doxygen/doxyxml/base.py”,  
line 203, in check\_parsed  
self.\_parse()  
File  
“/home/edwardc/Gnu-Radio/gr-tdrss/docs/doxygen/doxyxml/doxyindex.py”,  
line 51, in \_parse  
self.\_members += converted.members()  
File “/home/edwardc/Gnu-Radio/gr-tdrss/docs/doxygen/doxyxml/base.py”,  
line 174, in members  
self.confirm\_no\_error()  
File “/home/edwardc/Gnu-Radio/gr-tdrss/docs/doxygen/doxyxml/base.py”,  
line 206, in confirm\_no\_error  
self.check\_parsed()  
File “/home/edwardc/Gnu-Radio/gr-tdrss/docs/doxygen/doxyxml/base.py”,  
line 203, in check\_parsed  
self.\_parse()  
File  
“/home/edwardc/Gnu-Radio/gr-tdrss/docs/doxygen/doxyxml/doxyindex.py”,  
line 163, in \_parse  
self.set\_descriptions(self.\_retrieved\_data.compounddef)  
AttributeError: ‘NoneType’ object has no attribute ‘compounddef’  
make[2]: \*\*\* [swig/tdrss\_swig\_doc.i] Error 1  
make[1]: \*\*\* [swig/CMakeFiles/\_tdrss\_swig.dir/all] Error 2  
make: \*\*\* [all] Error 2  
edwardc@sdr-dev2:~/Gnu-Radio/gr-tdrss/build$

================================================

---

<div class="post-metadata">

**Author:** ![Ed\_Criscuolo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ac8455/32.png) [@Ed\_Criscuolo](https://www.ruby-forum.com/u/Ed_Criscuolo)\
**Post date:** [June 6, 2014, 10:03pm UTC](https://www.ruby-forum.com/t/adding-accessor-methods-in-gr-3-7/230258/8 "2014-06-06T22:03:39Z")

</div>

On 6/6/14 3:50 PM, Tom R. wrote:

> ```
> the make
> 
> [21%] Built target test-tdrss
> custom_output=custom_output)
> line 206, in confirm_no_error
> "/home/edwardc/Gnu-Radio/gr- __tdrss/docs/doxygen/doxyxml/__ base.py",
> File
> 
> ```
> 
> Ok, looks like your swig files weren’t updated correctly. I’m not sure  
> here what the exact reason is. When you were converting over to the new  
> 3.7 api, did you use gr\_modtool to create the project space or did you  
> start with your current one and modify it? If the former, we’ll have to  
> take a closer look. If the latter, I’d suggest looking at the  
> swig/tdrss\_swig.i and swig/CMakeLists.txt files to see that they were  
> updated correctly.

Nope, I started fresh with gr\_modtool for that very reason.  
And when I moved the OOT module to the Ubuntu box, I deleted the build  
directory, recreated it empty, and ran cmake ../ from within it.

> My guess with why it worked on OSX is that you don’t have doxygen on  
> your OS X box. If you do -DENABLE\_DOXYGEN=False, that might get passed  
> this immediate issue.

Nope, I have Doxygen 1.8.5\_3 installed on the Mac. But I’ll try  
disabling Doxygen on the Ubuntu box and see if it gets me past  
this point.

@(^.^)@ Ed
