discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss-gnuradio] SWIG only inherits interfaces from smart pointers


From: Ketan Mandke
Subject: [Discuss-gnuradio] SWIG only inherits interfaces from smart pointers
Date: Tue, 27 Nov 2007 18:57:12 -0600

I have been trying to create a GNU Radio project composed of various
swig wrapped modules. In order to explain my problem, the following
subproblem might be useful to know about. I apologize ahead of time
for the length of this email. =)

SUBPROBLEM:
I would like to be able to have class B in module modB inherit from
class A in module modA. This would be implemented across two SWIG
interface files modB.i and modA.i.

// modA.i
#ifndef SWIGIMPORTED
%module modA
#endif

%{
#include <classA.h>
%}
%include  <classA.h>
------------------------------------------------
// modB.i
#ifndef SWIGIMPORTED
%module modB
#endif
%import modA.i

%{
#include <classB.h>
%}
%include  <classB.h>
------------------------------------------------
// classA.h
class A
{ ... }
------------------------------------------------
// classB.h
class B : class A
{ ... }

The problem is that when I compile modB, the python wrapper generated
by SWIG (modB.py) does not give class B any of the inherited functions
from class A. It seems to just ignore class A all together.

If I remove the preprocessor tag "#ifndef ...", the SWIG generated
modB.py then tries to "import modA" which is not necessarily in that
directory. Ideally I would like to have SWIG just look at classA.h and
classB.h and create an interface from those two class definitions.

MAIN PROBLEM:
After trying to accomplish the above task unsuccessfully, I noticed
that the usrp module in gnuradio actually tries to do roughly the same
thing. I noticed, however, that in the SWIG wrapper python code
(usrp1.py) only the smart pointer classes (e.g. usrp1_source_c_sptr)
inherit any of the functions from their respective parents. This
happens even when I create a project (such as gr-howto) outside of the
gnuradio trunk. I am definitely at my wits end with trying to figure
out how to properly wrap my c++ classes with SWIG and could really use
some help.

QUESTION:
Could someone explain what happens when I place "%import 'gnuradio.i'
" into my interface file. Specifically, why does this allow me to
inherit methods from gr_block (and gr_basic_block) only for smart
pointers? Also are there any special SWIG directives that have to be
used to get inheritance to work across multiple modules (e.g.
%module(directors="1") modA )?

ADDITIONAL INFORMATION:
- I'm not getting any compile errors or warnings. The SWIG wrapped
python object just doesn't have the right interface.
- SWIG version: 1.3.31
- GNU Radio version: 3.1.0

Thanks for your help.

-- 
Ketan Mandke




reply via email to

[Prev in Thread] Current Thread [Next in Thread]