[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Discuss-gnuradio] Q's regarding C++ <-> SWIG <-> Python
From: |
Michael Dickens |
Subject: |
[Discuss-gnuradio] Q's regarding C++ <-> SWIG <-> Python |
Date: |
Fri, 7 Jul 2006 19:24:26 -0400 |
It seems like the "usual" C constructs port easily between C++ /
SWIG / Python: char, short, int, long, float, double. I'm fine in C+
+, but SWIG and Python are new to me, and combining them I generally
take to be an SEP ("someone else's problem", thanks Douglas Adams).
Given my time constraints over the summer, I'm hoping that someone
else knows about these issues, and can provide some definitive
answers. Thanks! - MLD
1) What I need are std::vector's of the usual C types, as well as
references to gr-blocks. In looking through gnuradio-core/src/lib/
general and runtime, it looks like to get a std::vector<int> argument
in the constructor, what I need to do is something like:
const std::vector<int> foo;
but "&foo" won't work? ... at least it didn't for me.
OTOH, I can also so a std::vector<gr_block_sptr>'s via something like:
const std::vector<gr_block_sptr> &foo;
... or at least these seem to be the way things are done in the
code. So no "&" for the usual types, but an "&" for sptr types?
Does this sound correct, or can anyone offer corrections? Can
someone -briefly- explain these further?
2) Is it possible to do a 2d-matrix-like type with something built-in
to Python / SWIG / C++, such as the std::vector<std::vector<int>>?
Clearly I can do a 1d vector (as per (1) above) then mess around with
it internally (which is what I currently do) .. but I would certainly
prefer a better solution.
3) Is it possible to assign default values to only -some- arguments
to the "friend" method? I can see some codes which assign default
values to -all- arguments, while most do none.
4) Can I have multiple constructors, and thus multiple "friend"
methods .. in the SWIG context (clearly I can in just C++, but can
SWIG handle it correctly)? For example, the constructor for a
"feedback" system typically requires 1 more argument than the
"feedforward" system (the feedback portion; both require the
feedforward portion) ... so I can either do 1 block with 2
constructors or create 2 blocks each with 1 constructor, to handle
the different cases.
- [Discuss-gnuradio] Q's regarding C++ <-> SWIG <-> Python,
Michael Dickens <=