diff options
| author | Martin Braun <martin.braun@ettus.com> | 2015-07-01 13:52:11 -0700 | 
|---|---|---|
| committer | Martin Braun <martin.braun@ettus.com> | 2015-07-14 14:51:32 -0700 | 
| commit | 4b1034b29e57a0b405fc89de4602819a4b8cc970 (patch) | |
| tree | abdb2918d100cb2e959165013bffbd461a66b2c4 /host/lib/convert | |
| parent | 7c6bc34f625e3945458a0a2a281850513a02ef08 (diff) | |
| download | uhd-4b1034b29e57a0b405fc89de4602819a4b8cc970.tar.gz uhd-4b1034b29e57a0b405fc89de4602819a4b8cc970.tar.bz2 uhd-4b1034b29e57a0b405fc89de4602819a4b8cc970.zip  | |
uhd: Replacing Cheetah w/ Mako 0.4.2 (allows Python 3 compat)
Diffstat (limited to 'host/lib/convert')
| -rw-r--r-- | host/lib/convert/gen_convert_general.py | 76 | 
1 files changed, 39 insertions, 37 deletions
diff --git a/host/lib/convert/gen_convert_general.py b/host/lib/convert/gen_convert_general.py index b0790755a..8090f14bd 100644 --- a/host/lib/convert/gen_convert_general.py +++ b/host/lib/convert/gen_convert_general.py @@ -17,92 +17,94 @@  #  TMPL_HEADER = """ -#import time +<% +    import time +%>  /*********************************************************************** - * This file was generated by $file on $time.strftime("%c") + * This file was generated by ${file} on ${time.strftime("%c")}   **********************************************************************/ -\#include "convert_common.hpp" -\#include <uhd/utils/byteswap.hpp> +#include "convert_common.hpp" +#include <uhd/utils/byteswap.hpp>  using namespace uhd::convert;  """  TMPL_CONV_GEN2_ITEM32 = """ -DECLARE_CONVERTER(item32, 1, sc16_item32_$(end), 1, PRIORITY_GENERAL){ +DECLARE_CONVERTER(item32, 1, sc16_item32_${end}, 1, PRIORITY_GENERAL){      const item32_t *input = reinterpret_cast<const item32_t *>(inputs[0]);      item32_t *output = reinterpret_cast<item32_t *>(outputs[0]);      for (size_t i = 0; i < nsamps; i++){ -        output[i] = $(to_wire)(input[i]); +        output[i] = ${to_wire}(input[i]);      }  } -DECLARE_CONVERTER(sc16_item32_$(end), 1, item32, 1, PRIORITY_GENERAL){ +DECLARE_CONVERTER(sc16_item32_${end}, 1, item32, 1, PRIORITY_GENERAL){      const item32_t *input = reinterpret_cast<const item32_t *>(inputs[0]);      item32_t *output = reinterpret_cast<item32_t *>(outputs[0]);      for (size_t i = 0; i < nsamps; i++){ -        output[i] = $(to_host)(input[i]); +        output[i] = ${to_host}(input[i]);      }  }  """  TMPL_CONV_USRP1_COMPLEX = """ -DECLARE_CONVERTER($(cpu_type), $(width), sc16_item16_usrp1, 1, PRIORITY_GENERAL){ -    #for $w in range($width) -    const $(cpu_type)_t *input$(w) = reinterpret_cast<const $(cpu_type)_t *>(inputs[$(w)]); -    #end for +DECLARE_CONVERTER(${cpu_type}, ${width}, sc16_item16_usrp1, 1, PRIORITY_GENERAL){ +    % for w in range(width): +    const ${cpu_type}_t *input${w} = reinterpret_cast<const ${cpu_type}_t *>(inputs[${w}]); +    % endfor      boost::uint16_t *output = reinterpret_cast<boost::uint16_t *>(outputs[0]);      for (size_t i = 0, j = 0; i < nsamps; i++){ -        #for $w in range($width) -        output[j++] = $(to_wire)(boost::uint16_t(boost::int16_t(input$(w)[i].real()$(do_scale)))); -        output[j++] = $(to_wire)(boost::uint16_t(boost::int16_t(input$(w)[i].imag()$(do_scale)))); -        #end for +        % for w in range(width): +        output[j++] = ${to_wire}(boost::uint16_t(boost::int16_t(input${w}[i].real()${do_scale}))); +        output[j++] = ${to_wire}(boost::uint16_t(boost::int16_t(input${w}[i].imag()${do_scale}))); +        % endfor      }  } -DECLARE_CONVERTER(sc16_item16_usrp1, 1, $(cpu_type), $(width), PRIORITY_GENERAL){ +DECLARE_CONVERTER(sc16_item16_usrp1, 1, ${cpu_type}, ${width}, PRIORITY_GENERAL){      const boost::uint16_t *input = reinterpret_cast<const boost::uint16_t *>(inputs[0]); -    #for $w in range($width) -    $(cpu_type)_t *output$(w) = reinterpret_cast<$(cpu_type)_t *>(outputs[$(w)]); -    #end for +    % for w in range(width): +    ${cpu_type}_t *output${w} = reinterpret_cast<${cpu_type}_t *>(outputs[${w}]); +    % endfor      for (size_t i = 0, j = 0; i < nsamps; i++){ -        #for $w in range($width) -        output$(w)[i] = $(cpu_type)_t( -            boost::int16_t($(to_host)(input[j+0]))$(do_scale), -            boost::int16_t($(to_host)(input[j+1]))$(do_scale) +        % for w in range(width): +        output${w}[i] = ${cpu_type}_t( +            boost::int16_t(${to_host}(input[j+0]))${do_scale}, +            boost::int16_t(${to_host}(input[j+1]))${do_scale}          );          j += 2; -        #end for +        % endfor      }  } -DECLARE_CONVERTER(sc8_item16_usrp1, 1, $(cpu_type), $(width), PRIORITY_GENERAL){ +DECLARE_CONVERTER(sc8_item16_usrp1, 1, ${cpu_type}, ${width}, PRIORITY_GENERAL){      const boost::uint16_t *input = reinterpret_cast<const boost::uint16_t *>(inputs[0]); -    #for $w in range($width) -    $(cpu_type)_t *output$(w) = reinterpret_cast<$(cpu_type)_t *>(outputs[$(w)]); -    #end for +    % for w in range(width): +    ${cpu_type}_t *output${w} = reinterpret_cast<${cpu_type}_t *>(outputs[${w}]); +    % endfor      for (size_t i = 0, j = 0; i < nsamps; i++){ -        #for $w in range($width) +        % for w in range(width):          { -        const boost::uint16_t num = $(to_host)(input[j++]); -        output$(w)[i] = $(cpu_type)_t( -            boost::int8_t(num)$(do_scale), -            boost::int8_t(num >> 8)$(do_scale) +        const boost::uint16_t num = ${to_host}(input[j++]); +        output${w}[i] = ${cpu_type}_t( +            boost::int8_t(num)${do_scale}, +            boost::int8_t(num >> 8)${do_scale}          );          } -        #end for +        % endfor      }  }  """  def parse_tmpl(_tmpl_text, **kwargs): -    from Cheetah.Template import Template -    return str(Template(_tmpl_text, kwargs)) +    from mako.template import Template +    return Template(_tmpl_text).render(**kwargs)  if __name__ == '__main__':      import sys, os  | 
