summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnathan Corgan <johnathan@corganlabs.com>2016-08-16 09:08:13 -0700
committerJohnathan Corgan <johnathan@corganlabs.com>2016-08-16 09:08:13 -0700
commit7e689f27b5ddcf060334ce753ec8d3cf850e9b9a (patch)
tree73bca5612f938a73b95f8a344e75fc67e32a47ce
parent1e0a12429afdddcf56d525d5464213dbe1e20c9f (diff)
parentf65a6f2e2d61875668b0a5ef07495f8558f6dce8 (diff)
Merge branch 'master' into next
-rw-r--r--cmake/msvc/config.h3
-rw-r--r--gnuradio-runtime/lib/sys_paths.cc8
-rw-r--r--gr-audio/lib/portaudio/portaudio_sink.cc4
-rw-r--r--gr-audio/lib/portaudio/portaudio_source.cc4
-rw-r--r--gr-blocks/grc/blocks_pdu_filter.xml5
-rw-r--r--gr-blocks/grc/blocks_pdu_remove.xml1
-rw-r--r--gr-blocks/grc/blocks_pdu_set.xml2
-rw-r--r--gr-blocks/include/gnuradio/blocks/pdu_filter.h3
-rw-r--r--gr-blocks/include/gnuradio/blocks/pdu_remove.h1
-rw-r--r--gr-blocks/include/gnuradio/blocks/pdu_set.h2
-rw-r--r--gr-blocks/lib/pdu_filter_impl.h3
-rw-r--r--gr-blocks/lib/pdu_remove_impl.h1
-rw-r--r--gr-blocks/lib/pdu_set_impl.h2
-rw-r--r--gr-blocks/lib/tcp_server_sink_impl.cc6
-rw-r--r--gr-digital/lib/pfb_clock_sync_fff_impl.cc2
-rw-r--r--gr-dtv/lib/CMakeLists.txt1
-rw-r--r--gr-dtv/lib/dvbt/dvbt_reed_solomon.cc475
-rw-r--r--gr-dtv/lib/dvbt/dvbt_reed_solomon.h70
-rw-r--r--gr-dtv/lib/dvbt/dvbt_reed_solomon_dec_impl.cc69
-rw-r--r--gr-dtv/lib/dvbt/dvbt_reed_solomon_dec_impl.h19
-rw-r--r--gr-dtv/lib/dvbt/dvbt_reed_solomon_enc_impl.cc58
-rw-r--r--gr-dtv/lib/dvbt/dvbt_reed_solomon_enc_impl.h16
-rw-r--r--gr-fec/include/gnuradio/fec/polar_decoder_common.h2
-rw-r--r--gr-fec/lib/polar_decoder_common.cc2
-rw-r--r--gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/doxyindex.py86
-rw-r--r--gr-utils/python/modtool/gr-newmod/docs/doxygen/swig_doc.py143
26 files changed, 332 insertions, 656 deletions
diff --git a/cmake/msvc/config.h b/cmake/msvc/config.h
index 50515104db..99a2ea0f89 100644
--- a/cmake/msvc/config.h
+++ b/cmake/msvc/config.h
@@ -62,4 +62,7 @@ static inline float rintf(float x){return (x > 0.0f)? floorf(x + 0.5f) : ceilf(x
static inline long int random (void) { return rand(); }
static inline void srandom (unsigned int seed) { srand(seed); }
+#define srand48(seed) srand(seed)
+#define drand48() (double(rand()) / RAND_MAX)
+
#endif // _MSC_CONFIG_H_ ]
diff --git a/gnuradio-runtime/lib/sys_paths.cc b/gnuradio-runtime/lib/sys_paths.cc
index 3bf6697bac..f63d7730e4 100644
--- a/gnuradio-runtime/lib/sys_paths.cc
+++ b/gnuradio-runtime/lib/sys_paths.cc
@@ -64,10 +64,16 @@ namespace gr {
return tmp_path();
}
- const char *userconf_path()
+ std::string __userconf_path()
{
boost::filesystem::path p(appdata_path());
p = p / ".gnuradio";
+ return p.string();
+ }
+
+ const char *userconf_path()
+ {
+ static std::string p(__userconf_path());
return p.c_str();
}
diff --git a/gr-audio/lib/portaudio/portaudio_sink.cc b/gr-audio/lib/portaudio/portaudio_sink.cc
index 2397b65442..e6698adb72 100644
--- a/gr-audio/lib/portaudio/portaudio_sink.cc
+++ b/gr-audio/lib/portaudio/portaudio_sink.cc
@@ -24,6 +24,10 @@
#include "config.h"
#endif
+#ifdef _MSC_VER
+#include <io.h>
+#endif
+
#include "audio_registry.h"
#include <portaudio_sink.h>
#include <portaudio_impl.h>
diff --git a/gr-audio/lib/portaudio/portaudio_source.cc b/gr-audio/lib/portaudio/portaudio_source.cc
index 1e1bbfacbb..7f2e8f30b9 100644
--- a/gr-audio/lib/portaudio/portaudio_source.cc
+++ b/gr-audio/lib/portaudio/portaudio_source.cc
@@ -24,6 +24,10 @@
#include "config.h"
#endif
+#ifdef _MSC_VER
+#include <io.h>
+#endif
+
#include "audio_registry.h"
#include <portaudio_source.h>
#include <portaudio_impl.h>
diff --git a/gr-blocks/grc/blocks_pdu_filter.xml b/gr-blocks/grc/blocks_pdu_filter.xml
index 1fb7209500..0e848963de 100644
--- a/gr-blocks/grc/blocks_pdu_filter.xml
+++ b/gr-blocks/grc/blocks_pdu_filter.xml
@@ -10,6 +10,9 @@
<import>from gnuradio import blocks</import>
<import>import pmt</import>
<make>blocks.pdu_filter($k, $v, $invert)</make>
+ <callback>set_key($k)</callback>
+ <callback>set_val($v)</callback>
+ <callback>set_inversion($invert)</callback>
<param>
<name>Key</name>
<key>k</key>
@@ -26,7 +29,7 @@
<name>Invert Filter</name>
<key>invert</key>
<value>False</value>
- <type>enum</type>
+ <type>bool</type>
<option>
<name>No</name>
<key>False</key>
diff --git a/gr-blocks/grc/blocks_pdu_remove.xml b/gr-blocks/grc/blocks_pdu_remove.xml
index ad99445e1d..c71da32fce 100644
--- a/gr-blocks/grc/blocks_pdu_remove.xml
+++ b/gr-blocks/grc/blocks_pdu_remove.xml
@@ -10,6 +10,7 @@
<import>from gnuradio import blocks</import>
<import>import pmt</import>
<make>blocks.pdu_remove($k)</make>
+ <callback>set_key($k)</callback>
<param>
<name>Key</name>
<key>k</key>
diff --git a/gr-blocks/grc/blocks_pdu_set.xml b/gr-blocks/grc/blocks_pdu_set.xml
index 1e7157fa8a..b7a9030622 100644
--- a/gr-blocks/grc/blocks_pdu_set.xml
+++ b/gr-blocks/grc/blocks_pdu_set.xml
@@ -10,6 +10,8 @@
<import>from gnuradio import blocks</import>
<import>import pmt</import>
<make>blocks.pdu_set($k, $v)</make>
+ <callback>set_key($k)</callback>
+ <callback>set_val($v)</callback>
<param>
<name>Key</name>
<key>k</key>
diff --git a/gr-blocks/include/gnuradio/blocks/pdu_filter.h b/gr-blocks/include/gnuradio/blocks/pdu_filter.h
index 1483731042..25dd185934 100644
--- a/gr-blocks/include/gnuradio/blocks/pdu_filter.h
+++ b/gr-blocks/include/gnuradio/blocks/pdu_filter.h
@@ -44,6 +44,9 @@ namespace gr {
* \brief Construct a PDU filter
*/
static sptr make(pmt::pmt_t k, pmt::pmt_t v, bool invert = false);
+ virtual void set_key(pmt::pmt_t key) = 0;
+ virtual void set_val(pmt::pmt_t val) = 0;
+ virtual void set_inversion(bool invert) = 0;
};
} /* namespace blocks */
diff --git a/gr-blocks/include/gnuradio/blocks/pdu_remove.h b/gr-blocks/include/gnuradio/blocks/pdu_remove.h
index 9b8a087e95..f2ab35f7cf 100644
--- a/gr-blocks/include/gnuradio/blocks/pdu_remove.h
+++ b/gr-blocks/include/gnuradio/blocks/pdu_remove.h
@@ -44,6 +44,7 @@ namespace gr {
* \brief Construct a PDU meta remove block
*/
static sptr make(pmt::pmt_t k);
+ virtual void set_key(pmt::pmt_t key) = 0;
};
} /* namespace blocks */
diff --git a/gr-blocks/include/gnuradio/blocks/pdu_set.h b/gr-blocks/include/gnuradio/blocks/pdu_set.h
index cfafc44bdd..ba96492b61 100644
--- a/gr-blocks/include/gnuradio/blocks/pdu_set.h
+++ b/gr-blocks/include/gnuradio/blocks/pdu_set.h
@@ -44,6 +44,8 @@ namespace gr {
* \brief Construct a PDU meta set block
*/
static sptr make(pmt::pmt_t k, pmt::pmt_t v);
+ virtual void set_key(pmt::pmt_t key) = 0;
+ virtual void set_val(pmt::pmt_t val) = 0;
};
} /* namespace blocks */
diff --git a/gr-blocks/lib/pdu_filter_impl.h b/gr-blocks/lib/pdu_filter_impl.h
index 66440ee421..e54b50427c 100644
--- a/gr-blocks/lib/pdu_filter_impl.h
+++ b/gr-blocks/lib/pdu_filter_impl.h
@@ -38,6 +38,9 @@ namespace gr {
public:
pdu_filter_impl(pmt::pmt_t k, pmt::pmt_t v, bool invert);
void handle_msg(pmt::pmt_t msg);
+ void set_key(pmt::pmt_t key) { d_k = key; };
+ void set_val(pmt::pmt_t val) { d_v = val; };
+ void set_inversion(bool invert) { d_invert = invert; };
};
} /* namespace blocks */
diff --git a/gr-blocks/lib/pdu_remove_impl.h b/gr-blocks/lib/pdu_remove_impl.h
index 4492e4b6d9..6f1a7f1b90 100644
--- a/gr-blocks/lib/pdu_remove_impl.h
+++ b/gr-blocks/lib/pdu_remove_impl.h
@@ -36,6 +36,7 @@ namespace gr {
public:
pdu_remove_impl(pmt::pmt_t k);
void handle_msg(pmt::pmt_t msg);
+ void set_key(pmt::pmt_t key) { d_k = key; };
};
} /* namespace blocks */
diff --git a/gr-blocks/lib/pdu_set_impl.h b/gr-blocks/lib/pdu_set_impl.h
index b27315ef4d..3529195aaf 100644
--- a/gr-blocks/lib/pdu_set_impl.h
+++ b/gr-blocks/lib/pdu_set_impl.h
@@ -37,6 +37,8 @@ namespace gr {
public:
pdu_set_impl(pmt::pmt_t k, pmt::pmt_t v);
void handle_msg(pmt::pmt_t msg);
+ void set_key(pmt::pmt_t key) { d_k = key; };
+ void set_val(pmt::pmt_t val) { d_v = val; };
};
} /* namespace blocks */
diff --git a/gr-blocks/lib/tcp_server_sink_impl.cc b/gr-blocks/lib/tcp_server_sink_impl.cc
index 329e798ca8..44f0765cb2 100644
--- a/gr-blocks/lib/tcp_server_sink_impl.cc
+++ b/gr-blocks/lib/tcp_server_sink_impl.cc
@@ -58,10 +58,10 @@ namespace gr {
d_buf(new uint8_t[BUF_SIZE]),
d_writing(0)
{
- std::string s_port = (boost::format("%d") % port).str();
- std::string s_host = host.empty() ? std::string("localhost") : host;
+ std::string s__port = (boost::format("%d") % port).str();
+ std::string s__host = host.empty() ? std::string("localhost") : host;
boost::asio::ip::tcp::resolver resolver(d_io_service);
- boost::asio::ip::tcp::resolver::query query(s_host, s_port,
+ boost::asio::ip::tcp::resolver::query query(s__host, s__port,
boost::asio::ip::resolver_query_base::passive);
d_endpoint = *resolver.resolve(query);
diff --git a/gr-digital/lib/pfb_clock_sync_fff_impl.cc b/gr-digital/lib/pfb_clock_sync_fff_impl.cc
index 09c72495a0..30ef526ad0 100644
--- a/gr-digital/lib/pfb_clock_sync_fff_impl.cc
+++ b/gr-digital/lib/pfb_clock_sync_fff_impl.cc
@@ -66,7 +66,7 @@ namespace gr {
d_osps(osps), d_error(0), d_out_idx(0)
{
if(taps.size() == 0)
- throw std::runtime_error("pfb_clock_sync_ccf: please specify a filter.\n");
+ throw std::runtime_error("pfb_clock_sync_fff: please specify a filter.\n");
// Let scheduler adjust our relative_rate.
enable_update_rate(true);
diff --git a/gr-dtv/lib/CMakeLists.txt b/gr-dtv/lib/CMakeLists.txt
index 7ffcc435de..f051e0bdf2 100644
--- a/gr-dtv/lib/CMakeLists.txt
+++ b/gr-dtv/lib/CMakeLists.txt
@@ -77,7 +77,6 @@ list(APPEND dtv_sources
dvbs2/dvbs2_modulator_bc_impl.cc
dvbs2/dvbs2_physical_cc_impl.cc
dvbt/dvbt_energy_dispersal_impl.cc
- dvbt/dvbt_reed_solomon.cc
dvbt/dvbt_reed_solomon_enc_impl.cc
dvbt/dvbt_convolutional_interleaver_impl.cc
dvbt/dvbt_configure.cc
diff --git a/gr-dtv/lib/dvbt/dvbt_reed_solomon.cc b/gr-dtv/lib/dvbt/dvbt_reed_solomon.cc
deleted file mode 100644
index 7d67a0a81a..0000000000
--- a/gr-dtv/lib/dvbt/dvbt_reed_solomon.cc
+++ /dev/null
@@ -1,475 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2015 Free Software Foundation, Inc.
- *
- * This is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this software; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gnuradio/io_signature.h>
-#include "dvbt_reed_solomon.h"
-#include <iostream>
-#include <stdio.h>
-#include <string.h>
-#include <fstream>
-
-using namespace std;
-
-#define min(a,b) ((a) < (b)) ? (a) : (b)
-
-namespace gr {
- namespace dtv {
-
- void
- dvbt_reed_solomon::gf_init(int p, int m, int gfpoly)
- {
- d_p = p; d_m = m;
-
- //maximum number of elements in the GF(p^m)
- int q = powl(p, m);
-
- d_gf_exp = new unsigned char[q];
- if (d_gf_exp == NULL) {
- std::cout << "Cannot allocate memory for d_gf_exp" << std::endl;
- return;
- }
-
- d_gf_log = new unsigned char[q];
- if (d_gf_log == NULL) {
- std::cout << "Cannot allocate memory for d_gf_log" << std::endl;
- delete [] d_gf_exp;
- return;
- }
-
- int reg_rs = 1;
-
- d_gf_exp[q - 1] = 0;
- d_gf_log[0] = q - 1;
-
- for (int i = 0; i < (q - 1); i++) {
- d_gf_exp[i] = reg_rs;
- d_gf_log[reg_rs] = i;
-
- //This is equvalent with raise to power
- reg_rs = reg_rs << 1;
-
- if (reg_rs & (1 << m)) {
- reg_rs = reg_rs ^ gfpoly;
- }
-
- reg_rs = reg_rs & ((1 << m) - 1);
- }
- }
-
- void
- dvbt_reed_solomon::gf_uninit()
- {
- delete [] d_gf_log;
- delete [] d_gf_exp;
- }
-
- int
- dvbt_reed_solomon::gf_exp(int a)
- {
- return d_gf_exp[a % d_n];
- }
-
- int
- dvbt_reed_solomon::gf_log(int a)
- {
- return d_gf_log[a % d_n];
- }
-
-
- int
- dvbt_reed_solomon::gf_add(int a, int b)
- {
- return (a ^ b);
- }
-
- int
- dvbt_reed_solomon::gf_mul(int a, int b)
- {
- if (a == 0 || b == 0) {
- return 0;
- }
- else {
- return gf_exp(d_gf_log[a] + d_gf_log[b]);
- }
- }
-
- int
- dvbt_reed_solomon::gf_div(int a, int b)
- {
- if (a == 0 || b == 0) {
- return (0);
- }
-
- return (gf_exp(d_n + d_gf_log[a] - d_gf_log[b]));
- }
-
- int
- dvbt_reed_solomon::gf_pow(int a, int power)
- {
- if (a == 0) {
- return (0);
- }
-
- return gf_exp(d_n + d_gf_log[a] + power);
- }
-
- int
- dvbt_reed_solomon::gf_lpow(int power)
- {
- return d_l[power % d_n];
- }
-
- void
- dvbt_reed_solomon::rs_init(int lambda, int n, int k, int t)
- {
- d_n = n; d_k = k; d_t = t;
- // 2t = n - k, dmin = 2t + 1 = n -k + 1
-
- d_l = new unsigned char[d_n + 1];
- if (d_l == NULL) {
- std::cout << "Cannot allocate memory for d_l" << std::endl;
- exit(1);
- }
-
- d_g = new unsigned char[2 * d_t + 1];
- if (d_g == NULL) {
- std::cout << "Cannot allocate memory for d_g" << std::endl;
- delete [] d_l;
- exit(1);
- }
-
- //Generate roots of lambda
- d_l[0] = 1;
-
- for (int i = 1; i <= d_n; i++) {
- d_l[i] = gf_mul(d_l[i - 1], lambda);
- }
-
- //Init Generator polynomial buffer
- for (int i = 0; i <= (2*t); i++) {
- d_g[i] = 0;
- }
-
- //Start with x+lambda^0
- d_g[0] = 1;
-
- //Create generator polynomial
- for (int i = 1; i <= (2 * t); i++) {
- for (int j = i; j > 0; j--) {
- if (d_g[j] != 0) {
- d_g[j] = gf_add(d_g[j - 1], gf_mul(d_g[j], d_l[i - 1]));
- }
- else {
- d_g[j] = d_g[j - 1];
- }
- }
-
- d_g[0] = gf_mul(d_g[0], d_l[i - 1]);
- }
-
- // Init syndrome array
- d_syn = new unsigned char[2 * d_t + 1];
- if (d_syn == NULL) {
- std::cout << "Cannot allocate memory for d_syn" << std::endl;
- delete [] d_g;
- delete [] d_l;
- exit(1);
- }
- }
-
- void
- dvbt_reed_solomon::rs_uninit()
- {
- if (d_syn) {
- delete [] d_syn;
- }
- if (d_g) {
- delete [] d_g;
- }
- if (d_l) {
- delete [] d_l;
- }
- }
-
- int
- dvbt_reed_solomon::rs_encode(unsigned char *data_in, unsigned char *parity)
- {
- memset(parity, 0, 2 * d_t);
-
- for (int i = 0; i < d_k; i++) {
- int feedback = gf_add(data_in[i], parity[0]);
-
- if (feedback != 0) {
- for (int j = 1; j < (2 * d_t); j++) {
- if (d_g[2 * d_t - j] != 0) {
- parity[j] = gf_add(parity[j], gf_mul(feedback, d_g[2 * d_t - j]));
- }
- }
- }
-
- //Shift the register
- memmove(&parity[0], &parity[1], (2 * d_t) - 1);
-
- if (feedback != 0) {
- parity[2 * d_t - 1] = gf_mul(feedback, d_g[0]);
- }
- else {
- parity[2 * d_t - 1] = 0;
- }
- }
-
- return (0);
- }
-
- int
- dvbt_reed_solomon::rs_decode(unsigned char *data, unsigned char *eras, const int no_eras)
- {
- __GR_VLA(unsigned char, sigma, 2 * d_t + 1);
- __GR_VLA(unsigned char, b, 2 * d_t + 1);
- __GR_VLA(unsigned char, T, 2 * d_t + 1);
- __GR_VLA(unsigned char, reg, 2 * d_t + 1);
- __GR_VLA(unsigned char, root, 2 * d_t + 1);
- __GR_VLA(unsigned char, loc, 2 * d_t + 1);
- __GR_VLA(unsigned char, omega, 2 * d_t);
-
- // Compute erasure locator polynomial
- memset(sigma, 0, 2 * d_t + 1);
- sigma[0] = 1;
-
- if (no_eras > 0) {
- // In this case we know the locations of errors
- // Init sigma to be the erasure locator polynomial
- sigma[1] = gf_exp(d_n-1-eras[0]);
-
- for (int i = 1; i < no_eras; i++) {
- int u = d_n-1-eras[i];
-
- for (int j = i+1; j > 0; j--) {
- sigma[j] = gf_add(sigma[j], gf_pow(sigma[j - 1], u));
- }
- }
- }
-
- // Calculate syndrome
-
- for (int j = 0; j < 2 * d_t; j++) {
- d_syn[j] = data[0];
- }
-
- for (int j = 1; j < d_n; j++) {
- for (int i = 0; i < 2 * d_t; i++) {
- d_syn[i] = gf_add(data[j], gf_pow(d_syn[i], i));
- }
- }
-
- int syn_error = 0;
-
- // Verify all syndromes
- for (int i = 0; i < 2 * d_t; i++) {
- syn_error |= d_syn[i];
- }
-
- if (!syn_error) {
- // The syndrome is a codeword
- // Return data unmodified
- return (0);
- }
-
- // Use Modified (errors+erasures) BMA. Algorithm of Berlekamp-Massey
- // S(i)=r(lambda^i)=e(lambda^i)
-
- int r = no_eras;
- int el = no_eras;
-
- memcpy(b, sigma, 2 * d_t + 1);
-
- while (++r <= 2 * d_t) {
- int d_discr = 0;
-
- for (int i = 0; i < r; i++) {
- d_discr = gf_add(d_discr, gf_mul(sigma[i], d_syn[r - i - 1]));
- }
-
- if (d_discr == 0) {
- // b(x) = x * b(x)
- memmove(&b[1], b, 2 * d_t);
- b[0] = 0;
- }
- else {
- T[0] = sigma[0];
-
- // T(x) = sigma(x) + d*x*b(x)
- for (int i = 0; i < 2 * d_t; i++) {
- T[i + 1] = gf_add(sigma[i + 1], gf_mul(d_discr, b[i]));
- }
-
- if (2 * el <= r + no_eras - 1) {
- el = r + no_eras - el;
-
- // b(i) = sigma(i) / discr
- for (int i = 0; i <= 2 * d_t; i++) {
- b[i] = gf_div(sigma[i], d_discr);
- }
- }
- else {
- // b(x) = x*b(x)
- memmove(&b[1], b, 2 * d_t);
- b[0] = 0;
- }
- memcpy(sigma, T, 2 * d_t + 1);
- }
- }
-
- // Compute degree(sigma)
- int deg_sigma = 0;
-
- for (int i = 0; i < 2 * d_t + 1; i++) {
- if (sigma[i] != 0) {
- deg_sigma = i;
- }
- }
-
- // Find the roots of sigma(x) by Chien search
- // Test sum(1)=1+sigma(1)*(lambda^1)+...+sigma(nu)*lambda(^nu)
- // Test sum(2)=1+sigma(1)*(lambda^2)+...+sigma(nu)*lambda(^nu*2)
- // ...
- // Test sum(l)=1+sigma(1)*(lambda^l)+...+sigma(nu)*lambda(^nu*l)
- // in order to see if lambda^(-1) is a root
- // where nu is degree(sigma)
-
- int no_roots = 0;
-
- memcpy(&reg[1], &sigma[1], 2 * d_t);
-
- for (int i = 1; i <= d_n; i++) {
- int q = 1;
-
- for (int j = deg_sigma; j > 0; j--) {
- reg[j] = gf_pow(reg[j], j);
- q = gf_add(q, reg[j]);
- }
-
- if (q != 0) {
- continue;
- }
-
- // We are here when we found roots of the sigma(x)
- // Keep roots in index form
- root[no_roots] = i;
- loc[no_roots] = i - 1;
-
- if (++no_roots == deg_sigma) {
- break;
- }
- }
-
- if (no_roots != deg_sigma) {
- // Uncorrectable error detected
- if (eras) {
- for (int i = 0; i < no_roots; i++)
- eras[i] = loc[i];
- }
-
- return (-1);
- }
-
- // Compute erros+erasures evaluator polynomial
- // omega(x)=sigma(x)S(x) mod (x ^ 2 * t)
- int deg_omega = 0;
-
- for (int i = 0; i < 2 * d_t; i++) {
- int tmp = 0;
- int j = (deg_sigma < i) ? deg_sigma : i;
-
- for(;j >= 0; j--) {
- tmp = gf_add(tmp, gf_mul(d_syn[i - j], sigma[j]));
- }
-
- if(tmp != 0) {
- deg_omega = i;
- }
-
- omega[i] = tmp;
- }
- omega[2 * d_t] = 0;
-
- // Compute error values using Forney formula (poly form)
- // e(j(l))) = (lambda(j(l)) ^ 2) * omega(lambda ^ (-j(l))) / sigma_pr(lambda ^ (-j(l)))
- // where sigma_pr is the formal derivative of sigma
-
- for (int j = no_roots - 1; j >= 0; j--) {
- int num1 = 0;
-
- // roots[] are in index form
- for (int i = deg_omega; i >= 0; i--) {
- num1 = gf_add(num1, gf_pow(omega[i], i * root[j]));
- }
-
- // root[] is in index form
- int num2 = gf_exp(root[j] * (-1) + d_n);
-
- int den = 0;
-
- // sigma[i+1] for i even is the formal derivative lambda_pr of sigma[i]
- int deg_max = min(deg_sigma, 2 * d_t - 1);
-
- for (int i = 1; i <= deg_max; i += 2) {
- if (sigma[i] != 0)
- den = gf_add(den, gf_exp(d_gf_log[sigma[i]] + (i - 1) * root[j]));
- }
-
- if (den == 0) {
- if (eras) {
- for (int i = 0; i < no_roots; i++) {
- eras[i] = loc[i];
- }
- }
- return (-1);
- }
-
- int err = gf_div(gf_mul(num1, num2), den);
-
- data[loc[j]] = gf_add(data[loc[j]], err);
- }
-
- return(no_roots);
- }
-
-
- dvbt_reed_solomon::dvbt_reed_solomon(int p, int m, int gfpoly, int n, int k, int t, int s, int blocks):
- d_p(p), d_m(m), d_gfpoly(gfpoly), d_n(n), d_k(k), d_t(t), d_s(s), d_blocks(blocks)
- {
- gf_init(d_p, d_m, d_gfpoly);
- rs_init(d_p, d_n, d_k, d_t);
- }
-
- dvbt_reed_solomon::~dvbt_reed_solomon()
- {
- rs_uninit();
- gf_uninit();
- }
-
- } /* namespace dtv */
-} /* namespace gr */
-
diff --git a/gr-dtv/lib/dvbt/dvbt_reed_solomon.h b/gr-dtv/lib/dvbt/dvbt_reed_solomon.h
deleted file mode 100644
index b9286d0ffd..0000000000
--- a/gr-dtv/lib/dvbt/dvbt_reed_solomon.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2015 Free Software Foundation, Inc.
- *
- * This is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this software; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_DTV_DVBT_REED_SOLOMON_H
-#define INCLUDED_DTV_DVBT_REED_SOLOMON_H
-
-namespace gr {
- namespace dtv {
-
- class dvbt_reed_solomon
- {
- private:
- int d_p;
- int d_m;
- int d_gfpoly;
- int d_n;
- int d_k;
- int d_t;
- int d_s;
- int d_blocks;
- unsigned char *d_gf_exp;
- unsigned char *d_gf_log;
- unsigned char *d_l;
- unsigned char *d_g;
-
- unsigned char *d_syn;
-
- int gf_add(int a, int b);
- int gf_mul(int a, int b);
- int gf_div(int a, int b);
- int gf_exp(int a);
- int gf_log(int a);
- int gf_pow(int a, int power);
- int gf_lpow(int power);
-
- void gf_init(int p, int m, int gfpoly);
- void gf_uninit();
- void rs_init(int lambda, int n, int k, int t);
- void rs_uninit();
-
- public:
- int rs_encode(unsigned char *data, unsigned char *parity);
- int rs_decode(unsigned char *data, unsigned char *eras, const int no_eras);
-
- dvbt_reed_solomon(int p, int m, int gfpoly, int n, int k, int t, int s, int blocks);
- ~dvbt_reed_solomon();
- };
-
- } // namespace dtv
-} // namespace gr
-
-#endif /* INCLUDED_DTV_DVBT_REED_SOLOMON_H */
-
diff --git a/gr-dtv/lib/dvbt/dvbt_reed_solomon_dec_impl.cc b/gr-dtv/lib/dvbt/dvbt_reed_solomon_dec_impl.cc
index 4a5530cfbe..f2e370a51f 100644
--- a/gr-dtv/lib/dvbt/dvbt_reed_solomon_dec_impl.cc
+++ b/gr-dtv/lib/dvbt/dvbt_reed_solomon_dec_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2015 Free Software Foundation, Inc.
+ * Copyright 2015,2016 Free Software Foundation, Inc.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,6 +29,11 @@
namespace gr {
namespace dtv {
+ static const int rs_init_symsize = 8;
+ static const int rs_init_fcr = 0; // first consecutive root
+ static const int rs_init_prim = 1; // primitive is 1 (alpha)
+ static const int N = (1 << rs_init_symsize) - 1; // 255
+
dvbt_reed_solomon_dec::sptr
dvbt_reed_solomon_dec::make(int p, int m, int gfpoly, int n, int k, int t, int s, int blocks)
{
@@ -43,15 +48,16 @@ namespace gr {
: block("dvbt_reed_solomon_dec",
io_signature::make(1, 1, sizeof(unsigned char) * blocks * (n - s)),
io_signature::make(1, 1, sizeof(unsigned char) * blocks * (k - s))),
- d_p(p), d_m(m), d_gfpoly(gfpoly), d_n(n), d_k(k), d_t(t), d_s(s), d_blocks(blocks),
- d_rs(p, m, gfpoly, n, k, t, s, blocks)
+ d_n(n), d_k(k), d_s(s), d_blocks(blocks)
{
- d_in = new unsigned char[d_n];
- if (d_in == NULL) {
- std::cout << "Cannot allocate memory for d_in" << std::endl;
+ d_rs = init_rs_char(rs_init_symsize, gfpoly, rs_init_fcr, rs_init_prim, (n - k));
+ if (d_rs == NULL) {
+ fprintf(stderr, "Reed-Solomon decoder, Out of memory.\n");
exit(1);
}
- memset(&d_in[0], 0, d_n);
+ d_nerrors_corrected_count = 0;
+ d_bad_packet_count = 0;
+ d_total_packets = 0;
}
/*
@@ -59,7 +65,7 @@ namespace gr {
*/
dvbt_reed_solomon_dec_impl::~dvbt_reed_solomon_dec_impl()
{
- delete [] d_in;
+ free_rs_char(d_rs);
}
void
@@ -69,6 +75,25 @@ namespace gr {
}
int
+ dvbt_reed_solomon_dec_impl::decode (unsigned char &out, const unsigned char &in)
+ {
+ unsigned char tmp[N];
+ int ncorrections;
+
+ // add missing prefix zero padding to message
+ memset(tmp, 0, d_s);
+ memcpy(&tmp[d_s], &in, (d_n - d_s));
+
+ // correct message...
+ ncorrections = decode_rs_char(d_rs, tmp, 0, 0);
+
+ // copy corrected message to output, skipping prefix zero padding
+ memcpy (&out, &tmp[d_s], (d_k - d_s));
+
+ return ncorrections;
+ }
+
+ int
dvbt_reed_solomon_dec_impl::general_work (int noutput_items,
gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
@@ -76,21 +101,23 @@ namespace gr {
{
const unsigned char *in = (const unsigned char *) input_items[0];
unsigned char *out = (unsigned char *) output_items[0];
-
- // We receive only nonzero data
- int in_bsize = d_n - d_s;
- int out_bsize = d_k - d_s;
+ int j = 0;
+ int k = 0;
for (int i = 0; i < (d_blocks * noutput_items); i++) {
- //TODO - zero copy?
- // Set first d_s symbols to zero
- memset(&d_in[0], 0, d_s);
- // Then copy actual data
- memcpy(&d_in[d_s], &in[i * in_bsize], in_bsize);
-
- d_rs.rs_decode(d_in, NULL, 0);
-
- memcpy(&out[i * out_bsize], &d_in[d_s], out_bsize);
+ int nerrors_corrected = decode(out[k], in[j]);
+
+ if (nerrors_corrected == -1) {
+ d_bad_packet_count++;
+ d_nerrors_corrected_count += ((d_n - d_s) - (d_k - d_s)) / 2; // lower bound estimate; most this RS can fix
+ }
+ else {
+ d_nerrors_corrected_count += nerrors_corrected;
+ }
+
+ d_total_packets++;
+ j += (d_n - d_s);
+ k += (d_k - d_s);
}
// Tell runtime system how many input items we consumed on
diff --git a/gr-dtv/lib/dvbt/dvbt_reed_solomon_dec_impl.h b/gr-dtv/lib/dvbt/dvbt_reed_solomon_dec_impl.h
index 951aa4b2a1..2d9b24809d 100644
--- a/gr-dtv/lib/dvbt/dvbt_reed_solomon_dec_impl.h
+++ b/gr-dtv/lib/dvbt/dvbt_reed_solomon_dec_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2015 Free Software Foundation, Inc.
+ * Copyright 2015,2016 Free Software Foundation, Inc.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,7 +22,10 @@
#define INCLUDED_DTV_DVBT_REED_SOLOMON_DEC_IMPL_H
#include <gnuradio/dtv/dvbt_reed_solomon_dec.h>
-#include "dvbt_reed_solomon.h"
+
+extern "C" {
+#include <gnuradio/fec/rs.h>
+}
namespace gr {
namespace dtv {
@@ -30,18 +33,18 @@ namespace gr {
class dvbt_reed_solomon_dec_impl : public dvbt_reed_solomon_dec
{
private:
- int d_p;
- int d_m;
- int d_gfpoly;
int d_n;
int d_k;
- int d_t;
int d_s;
int d_blocks;
- unsigned char * d_in;
+ int d_nerrors_corrected_count;
+ int d_bad_packet_count;
+ int d_total_packets;
+ int d_total_bits;
- dvbt_reed_solomon d_rs;
+ void *d_rs; /* Reed-Solomon characteristics structure */
+ int decode(unsigned char &out, const unsigned char &in);
public:
dvbt_reed_solomon_dec_impl(int p, int m, int gfpoly, int n, int k, int t, int s, int blocks);
diff --git a/gr-dtv/lib/dvbt/dvbt_reed_solomon_enc_impl.cc b/gr-dtv/lib/dvbt/dvbt_reed_solomon_enc_impl.cc
index 561ea08ded..3bc186055d 100644
--- a/gr-dtv/lib/dvbt/dvbt_reed_solomon_enc_impl.cc
+++ b/gr-dtv/lib/dvbt/dvbt_reed_solomon_enc_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2015 Free Software Foundation, Inc.
+ * Copyright 2015,2016 Free Software Foundation, Inc.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,9 +26,15 @@
#include "dvbt_reed_solomon_enc_impl.h"
#include <stdio.h>
+#define MPEG_TS_PKT_LENGTH 188
+
namespace gr {
namespace dtv {
+ static const int rs_init_symsize = 8;
+ static const int rs_init_fcr = 0; // first consecutive root
+ static const int rs_init_prim = 1; // primitive is 1 (alpha)
+
dvbt_reed_solomon_enc::sptr
dvbt_reed_solomon_enc::make(int p, int m, int gfpoly, int n, int k, int t, int s, int blocks)
{
@@ -43,15 +49,19 @@ namespace gr {
: block("dvbt_reed_solomon",
io_signature::make(1, 1, sizeof(unsigned char) * blocks * (k - s)),
io_signature::make(1, 1, sizeof(unsigned char) * blocks * (n - s))),
- d_p(p), d_m(m), d_gfpoly(gfpoly), d_n(n), d_k(k), d_t(t), d_s(s), d_blocks(blocks),
- d_rs(p, m, gfpoly, n, k, t, s, blocks)
+ d_n(n), d_k(k), d_s(s), d_blocks(blocks)
{
- d_in = new unsigned char[d_n];
- if (d_in == NULL) {
- std::cout << "Cannot allocate memory for d_in" << std::endl;
- return;
+ d_rs = init_rs_char(rs_init_symsize, gfpoly, rs_init_fcr, rs_init_prim, (n - k));
+ if (d_rs == NULL) {
+ fprintf(stderr, "Reed-Solomon encoder, Out of memory.\n");
+ exit(1);
+ }
+ d_data = (unsigned char *) malloc(sizeof(unsigned char) * (d_s + MPEG_TS_PKT_LENGTH));
+ if (d_data == NULL) {
+ fprintf(stderr, "Reed-Solomon encoder, Out of memory.\n");
+ free_rs_char(d_rs);
+ exit(1);
}
- memset(&d_in[0], 0, d_n);
}
/*
@@ -59,7 +69,8 @@ namespace gr {
*/
dvbt_reed_solomon_enc_impl::~dvbt_reed_solomon_enc_impl()
{
- delete [] d_in;
+ free(d_data);
+ free_rs_char(d_rs);
}
void
@@ -68,6 +79,18 @@ namespace gr {
ninput_items_required[0] = noutput_items;
}
+ void
+ dvbt_reed_solomon_enc_impl::encode(const unsigned char *in, unsigned char *out)
+ {
+ // Shortened Reed-Solomon: prepend zero bytes to message (discarded after encoding)
+ std::memset(d_data, 0, d_s);
+ std::memcpy(&d_data[d_s], in, MPEG_TS_PKT_LENGTH);
+
+ // Copy input message to output then append Reed-Solomon bits
+ std::memcpy(out, in, MPEG_TS_PKT_LENGTH);
+ encode_rs_char(d_rs, d_data, &out[MPEG_TS_PKT_LENGTH]);
+ }
+
int
dvbt_reed_solomon_enc_impl::general_work (int noutput_items,
gr_vector_int &ninput_items,
@@ -76,18 +99,13 @@ namespace gr {
{
const unsigned char *in = (const unsigned char *) input_items[0];
unsigned char *out = (unsigned char *) output_items[0];
+ int j = 0;
+ int k = 0;
- int in_bsize = d_k - d_s;
- int out_bsize = d_n - d_s;
-
- // We get a superblock of d_blocks blocks
- for (int i = 0; i < (d_blocks * noutput_items); i++) {
- //TODO - zero copy between in/out ?
- memcpy(&d_in[d_s], &in[i * in_bsize], in_bsize);
-
- d_rs.rs_encode(&d_in[0], &d_in[d_k]);
-
- memcpy(&out[i * out_bsize], &d_in[d_s], out_bsize);
+ for (int i = 0; i < noutput_items * d_blocks; i++) {
+ encode(in + j, out + k);
+ j += (d_k - d_s);
+ k += (d_n - d_s);
}
// Tell runtime system how many input items we consumed on
diff --git a/gr-dtv/lib/dvbt/dvbt_reed_solomon_enc_impl.h b/gr-dtv/lib/dvbt/dvbt_reed_solomon_enc_impl.h
index 669ee2761a..47dea875f4 100644
--- a/gr-dtv/lib/dvbt/dvbt_reed_solomon_enc_impl.h
+++ b/gr-dtv/lib/dvbt/dvbt_reed_solomon_enc_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2015 Free Software Foundation, Inc.
+ * Copyright 2015,2016 Free Software Foundation, Inc.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,7 +22,10 @@
#define INCLUDED_DTV_DVBT_REED_SOLOMON_ENC_IMPL_H
#include <gnuradio/dtv/dvbt_reed_solomon_enc.h>
-#include "dvbt_reed_solomon.h"
+
+extern "C" {
+#include <gnuradio/fec/rs.h>
+}
namespace gr {
namespace dtv {
@@ -30,18 +33,15 @@ namespace gr {
class dvbt_reed_solomon_enc_impl : public dvbt_reed_solomon_enc
{
private:
- int d_p;
- int d_m;
- int d_gfpoly;
int d_n;
int d_k;
- int d_t;
int d_s;
int d_blocks;
- unsigned char * d_in;
+ unsigned char *d_data;
- dvbt_reed_solomon d_rs;
+ void *d_rs; /* Reed-Solomon characteristics structure */
+ void encode(const unsigned char *in, unsigned char *out);
public:
dvbt_reed_solomon_enc_impl(int p, int m, int gfpoly, int n, int k, int t, int s, int blocks);
diff --git a/gr-fec/include/gnuradio/fec/polar_decoder_common.h b/gr-fec/include/gnuradio/fec/polar_decoder_common.h
index a39ee4f232..13b25ea19b 100644
--- a/gr-fec/include/gnuradio/fec/polar_decoder_common.h
+++ b/gr-fec/include/gnuradio/fec/polar_decoder_common.h
@@ -68,7 +68,7 @@ namespace gr {
bool set_frame_size(unsigned int frame_size){return false;};
private:
- static BOOST_CONSTEXPR_OR_CONST float D_LLR_FACTOR = -2.19722458f;
+ static BOOST_CONSTEXPR_OR_CONST float D_LLR_FACTOR;
unsigned int d_frozen_bit_counter;
protected:
diff --git a/gr-fec/lib/polar_decoder_common.cc b/gr-fec/lib/polar_decoder_common.cc
index 8fc2e37fb7..1d4a21a191 100644
--- a/gr-fec/lib/polar_decoder_common.cc
+++ b/gr-fec/lib/polar_decoder_common.cc
@@ -34,6 +34,8 @@ namespace gr {
namespace fec {
namespace code {
+ const float polar_decoder_common::D_LLR_FACTOR = -2.19722458f;
+
polar_decoder_common::polar_decoder_common(int block_size, int num_info_bits,
std::vector<int> frozen_bit_positions,
std::vector<char> frozen_bit_values) :
diff --git a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/doxyindex.py b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/doxyindex.py
index 0132ab86fd..78e8153768 100644
--- a/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/doxyindex.py
+++ b/gr-utils/python/modtool/gr-newmod/docs/doxygen/doxyxml/doxyindex.py
@@ -43,13 +43,16 @@ class DoxyIndex(Base):
self._root = index.parse(os.path.join(self._xml_path, 'index.xml'))
for mem in self._root.compound:
converted = self.convert_mem(mem)
- # For files we want the contents to be accessible directly
- # from the parent rather than having to go through the file
- # object.
+ # For files and namespaces we want the contents to be
+ # accessible directly from the parent rather than having
+ # to go through the file object.
if self.get_cls(mem) == DoxyFile:
if mem.name.endswith('.h'):
self._members += converted.members()
self._members.append(converted)
+ elif self.get_cls(mem) == DoxyNamespace:
+ self._members += converted.members()
+ self._members.append(converted)
else:
self._members.append(converted)
@@ -80,13 +83,29 @@ class DoxyCompMem(Base):
self._data['brief_description'] = bd
self._data['detailed_description'] = dd
+ def set_parameters(self, data):
+ vs = [ddc.value for ddc in data.detaileddescription.content_]
+ pls = []
+ for v in vs:
+ if hasattr(v, 'parameterlist'):
+ pls += v.parameterlist
+ pis = []
+ for pl in pls:
+ pis += pl.parameteritem
+ dpis = []
+ for pi in pis:
+ dpi = DoxyParameterItem(pi)
+ dpi._parse()
+ dpis.append(dpi)
+ self._data['params'] = dpis
+
+
class DoxyCompound(DoxyCompMem):
pass
class DoxyMember(DoxyCompMem):
pass
-
class DoxyFunction(DoxyMember):
__module__ = "gnuradio.utils.doxyxml"
@@ -98,10 +117,13 @@ class DoxyFunction(DoxyMember):
return
super(DoxyFunction, self)._parse()
self.set_descriptions(self._parse_data)
- self._data['params'] = []
- prms = self._parse_data.param
- for prm in prms:
- self._data['params'].append(DoxyParam(prm))
+ self.set_parameters(self._parse_data)
+ if not self._data['params']:
+ # If the params weren't set by a comment then just grab the names.
+ self._data['params'] = []
+ prms = self._parse_data.param
+ for prm in prms:
+ self._data['params'].append(DoxyParam(prm))
brief_description = property(lambda self: self.data()['brief_description'])
detailed_description = property(lambda self: self.data()['detailed_description'])
@@ -121,9 +143,39 @@ class DoxyParam(DoxyMember):
self.set_descriptions(self._parse_data)
self._data['declname'] = self._parse_data.declname
+ @property
+ def description(self):
+ descriptions = []
+ if self.brief_description:
+ descriptions.append(self.brief_description)
+ if self.detailed_description:
+ descriptions.append(self.detailed_description)
+ return '\n\n'.join(descriptions)
+
brief_description = property(lambda self: self.data()['brief_description'])
detailed_description = property(lambda self: self.data()['detailed_description'])
- declname = property(lambda self: self.data()['declname'])
+ name = property(lambda self: self.data()['declname'])
+
+class DoxyParameterItem(DoxyMember):
+ """A different representation of a parameter in Doxygen."""
+
+ def _parse(self):
+ if self._parsed:
+ return
+ super(DoxyParameterItem, self)._parse()
+ names = []
+ for nl in self._parse_data.parameternamelist:
+ for pn in nl.parametername:
+ names.append(description(pn))
+ # Just take first name
+ self._data['name'] = names[0]
+ # Get description
+ pd = description(self._parse_data.get_parameterdescription())
+ self._data['description'] = pd
+
+ description = property(lambda self: self.data()['description'])
+ name = property(lambda self: self.data()['name'])
+
class DoxyClass(DoxyCompound):
@@ -139,12 +191,14 @@ class DoxyClass(DoxyCompound):
if self._error:
return
self.set_descriptions(self._retrieved_data.compounddef)
+ self.set_parameters(self._retrieved_data.compounddef)
# Sectiondef.kind tells about whether private or public.
# We just ignore this for now.
self.process_memberdefs()
brief_description = property(lambda self: self.data()['brief_description'])
detailed_description = property(lambda self: self.data()['detailed_description'])
+ params = property(lambda self: self.data()['params'])
Base.mem_classes.append(DoxyClass)
@@ -177,6 +231,16 @@ class DoxyNamespace(DoxyCompound):
kind = 'namespace'
+ def _parse(self):
+ if self._parsed:
+ return
+ super(DoxyNamespace, self)._parse()
+ self.retrieve_data()
+ self.set_descriptions(self._retrieved_data.compounddef)
+ if self._error:
+ return
+ self.process_memberdefs()
+
Base.mem_classes.append(DoxyNamespace)
@@ -227,11 +291,11 @@ class DoxyOther(Base):
__module__ = "gnuradio.utils.doxyxml"
- kinds = set(['variable', 'struct', 'union', 'define', 'typedef', 'enum', 'dir', 'page'])
+ kinds = set(['variable', 'struct', 'union', 'define', 'typedef', 'enum',
+ 'dir', 'page', 'signal', 'slot', 'property'])
@classmethod
def can_parse(cls, obj):
return obj.kind in cls.kinds
Base.mem_classes.append(DoxyOther)
-
diff --git a/gr-utils/python/modtool/gr-newmod/docs/doxygen/swig_doc.py b/gr-utils/python/modtool/gr-newmod/docs/doxygen/swig_doc.py
index 4e1ce2e475..d3536db8d0 100644
--- a/gr-utils/python/modtool/gr-newmod/docs/doxygen/swig_doc.py
+++ b/gr-utils/python/modtool/gr-newmod/docs/doxygen/swig_doc.py
@@ -1,5 +1,5 @@
#
-# Copyright 2010,2011 Free Software Foundation, Inc.
+# Copyright 2010-2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -27,13 +27,10 @@ python docstrings.
"""
-import sys
-
-try:
- from doxyxml import DoxyIndex, DoxyClass, DoxyFriend, DoxyFunction, DoxyFile, base
-except ImportError:
- from gnuradio.doxyxml import DoxyIndex, DoxyClass, DoxyFriend, DoxyFunction, DoxyFile, base
+import sys, time
+from doxyxml import DoxyIndex, DoxyClass, DoxyFriend, DoxyFunction, DoxyFile
+from doxyxml import DoxyOther, base
def py_name(name):
bits = name.split('_')
@@ -56,7 +53,28 @@ class Block(object):
# Check for a parsing error.
if item.error():
return False
- return item.has_member(make_name(item.name()), DoxyFriend)
+ friendname = make_name(item.name())
+ is_a_block = item.has_member(friendname, DoxyFriend)
+ # But now sometimes the make function isn't a friend so check again.
+ if not is_a_block:
+ is_a_block = di.has_member(friendname, DoxyFunction)
+ return is_a_block
+
+class Block2(object):
+ """
+ Checks if doxyxml produced objects correspond to a new style
+ gnuradio block.
+ """
+
+ @classmethod
+ def includes(cls, item):
+ if not isinstance(item, DoxyClass):
+ return False
+ # Check for a parsing error.
+ if item.error():
+ return False
+ is_a_block2 = item.has_member('make', DoxyFunction) and item.has_member('sptr', DoxyOther)
+ return is_a_block2
def utoascii(text):
@@ -83,9 +101,15 @@ def combine_descriptions(obj):
description.append(dd)
return utoascii('\n\n'.join(description)).strip()
+def format_params(parameteritems):
+ output = ['Args:']
+ template = ' {0} : {1}'
+ for pi in parameteritems:
+ output.append(template.format(pi.name, pi.description))
+ return '\n'.join(output)
entry_templ = '%feature("docstring") {name} "{docstring}"'
-def make_entry(obj, name=None, templ="{description}", description=None):
+def make_entry(obj, name=None, templ="{description}", description=None, params=[]):
"""
Create a docstring entry for a swig interface file.
@@ -102,13 +126,16 @@ def make_entry(obj, name=None, templ="{description}", description=None):
return ''
if description is None:
description = combine_descriptions(obj)
+ if params:
+ description += '\n\n'
+ description += utoascii(format_params(params))
docstring = templ.format(description=description)
if not docstring:
return ''
return entry_templ.format(
name=name,
docstring=docstring,
- )
+ )
def make_func_entry(func, name=None, description=None, params=None):
@@ -121,27 +148,31 @@ def make_func_entry(func, name=None, description=None, params=None):
used as the description instead of extracting it from func.
params - a parameter list that overrides using func.params.
"""
- if params is None:
- params = func.params
- params = [prm.declname for prm in params]
- if params:
- sig = "Params: (%s)" % ", ".join(params)
- else:
- sig = "Params: (NONE)"
- templ = "{description}\n\n" + sig
- return make_entry(func, name=name, templ=utoascii(templ),
- description=description)
-
-
-def make_class_entry(klass, description=None):
+ #if params is None:
+ # params = func.params
+ #params = [prm.declname for prm in params]
+ #if params:
+ # sig = "Params: (%s)" % ", ".join(params)
+ #else:
+ # sig = "Params: (NONE)"
+ #templ = "{description}\n\n" + sig
+ #return make_entry(func, name=name, templ=utoascii(templ),
+ # description=description)
+ return make_entry(func, name=name, description=description, params=params)
+
+
+def make_class_entry(klass, description=None, ignored_methods=[], params=None):
"""
Create a class docstring for a swig interface file.
"""
+ if params is None:
+ params = klass.params
output = []
- output.append(make_entry(klass, description=description))
+ output.append(make_entry(klass, description=description, params=params))
for func in klass.in_category(DoxyFunction):
- name = klass.name() + '::' + func.name()
- output.append(make_func_entry(func, name=name))
+ if func.name() not in ignored_methods:
+ name = klass.name() + '::' + func.name()
+ output.append(make_func_entry(func, name=name))
return "\n\n".join(output)
@@ -175,11 +206,33 @@ def make_block_entry(di, block):
# the make function.
output = []
output.append(make_class_entry(block, description=super_description))
- creator = block.get_member(block.name(), DoxyFunction)
output.append(make_func_entry(make_func, description=super_description,
- params=creator.params))
+ params=block.params))
return "\n\n".join(output)
+def make_block2_entry(di, block):
+ """
+ Create class and function docstrings of a new style gnuradio block for a
+ swig interface file.
+ """
+ descriptions = []
+ # For new style blocks all the relevant documentation should be
+ # associated with the 'make' method.
+ class_description = combine_descriptions(block)
+ make_func = block.get_member('make', DoxyFunction)
+ make_description = combine_descriptions(make_func)
+ description = class_description + "\n\nConstructor Specific Documentation:\n\n" + make_description
+ # Associate the combined description with the class and
+ # the make function.
+ output = []
+ output.append(make_class_entry(
+ block, description=description,
+ ignored_methods=['make'], params=make_func.params))
+ makename = block.name() + '::make'
+ output.append(make_func_entry(
+ make_func, name=makename, description=description,
+ params=make_func.params))
+ return "\n\n".join(output)
def make_swig_interface_file(di, swigdocfilename, custom_output=None):
@@ -196,32 +249,52 @@ def make_swig_interface_file(di, swigdocfilename, custom_output=None):
# Create docstrings for the blocks.
blocks = di.in_category(Block)
+ blocks2 = di.in_category(Block2)
+
make_funcs = set([])
for block in blocks:
try:
make_func = di.get_member(make_name(block.name()), DoxyFunction)
- make_funcs.add(make_func.name())
- output.append(make_block_entry(di, block))
+ # Don't want to risk writing to output twice.
+ if make_func.name() not in make_funcs:
+ make_funcs.add(make_func.name())
+ output.append(make_block_entry(di, block))
+ except block.ParsingError:
+ sys.stderr.write('Parsing error for block {0}\n'.format(block.name()))
+ raise
+
+ for block in blocks2:
+ try:
+ make_func = block.get_member('make', DoxyFunction)
+ make_func_name = block.name() +'::make'
+ # Don't want to risk writing to output twice.
+ if make_func_name not in make_funcs:
+ make_funcs.add(make_func_name)
+ output.append(make_block2_entry(di, block))
except block.ParsingError:
- print('Parsing error for block %s' % block.name())
+ sys.stderr.write('Parsing error for block {0}\n'.format(block.name()))
+ raise
# Create docstrings for functions
# Don't include the make functions since they have already been dealt with.
- funcs = [f for f in di.in_category(DoxyFunction) if f.name() not in make_funcs]
+ funcs = [f for f in di.in_category(DoxyFunction)
+ if f.name() not in make_funcs and not f.name().startswith('std::')]
for f in funcs:
try:
output.append(make_func_entry(f))
except f.ParsingError:
- print('Parsing error for function %s' % f.name())
+ sys.stderr.write('Parsing error for function {0}\n'.format(f.name()))
# Create docstrings for classes
block_names = [block.name() for block in blocks]
- klasses = [k for k in di.in_category(DoxyClass) if k.name() not in block_names]
+ block_names += [block.name() for block in blocks2]
+ klasses = [k for k in di.in_category(DoxyClass)
+ if k.name() not in block_names and not k.name().startswith('std::')]
for k in klasses:
try:
output.append(make_class_entry(k))
except k.ParsingError:
- print('Parsing error for class %s' % k.name())
+ sys.stderr.write('Parsing error for class {0}\n'.format(k.name()))
# Docstrings are not created for anything that is not a function or a class.
# If this excludes anything important please add it here.