示例#1
0
 def __init__(self, dqti):
     self.value_name = result_cpp_value_name
     self.is_pointer = dqti.dir_qual.is_pointer
     self.is_reference = dqti.dir_qual.is_reference
     self.is_mutable_ref = dqti.dir_qual.is_mutable_ref
     self.is_mutable_ptr = dqti.dir_qual.is_mutable_ptr
     self.conv = ConvCodec(dqti, result_cpp_value_name)
示例#2
0
class ParamCodec:
    def __init__(self, dqti, name):
        self.value_name = ValueName(name)
        self.is_pointer = dqti.dir_qual.is_pointer
        self.is_mutable_indirect = dqti.dir_qual.is_mutable_indirect
        self.conv = ConvCodec(dqti, self.value_name.cpp)

    def __eq__(self, other):
        if not (self.value_name == other.value_name):
            return False
        if not (self.is_pointer == other.is_pointer):
            return False
        if not (self.is_mutable_indirect == other.is_mutable_indirect):
            return False
        if not (self.conv == other.conv):
            return False
        return True

    @property
    def will_promote(self):
        return self.conv.will_promote

    @property
    def type_info(self):
        return self.conv.type_info

    @property
    def reference_prefix(self):
        return self.conv.reference_prefix

    @property
    def take_pointer_prefix(self):
        return self.conv.take_pointer_prefix

    @property
    def deref_pointer_prefix(self):
        return self.conv.deref_pointer_prefix

    def _render(self, obj, lang):
        return self.type_info._render("param", obj, lang, {
            "param": self,
        })

    def render_validate_edk(self):
        return self.conv.render_validate_edk()

    def render_edk(self):
        return self._render("edk", "cpp")

    def render_edk_to_lib_decl(self):
        return self._render("edk_to_lib_decl", "cpp")

    def render_kl(self):
        return self._render("kl", "kl")

    def render_lib(self):
        return self._render("lib", "cpp")

    def render_lib_to_edk(self):
        return self._render("lib_to_edk", "cpp")
示例#3
0
import numpy as np
from conv_codec import ConvCodec
import utils
import os

M = np.array([[1, 0, 0, 0, 1, 1, 1, 1], [1, 0, 0, 1, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 0, 1], [1, 0, 1, 1, 0, 1, 1, 1],
              [1, 0, 1, 1, 1, 1, 1, 1], [1, 1, 0, 0, 0, 1, 0, 1], [1, 1, 0, 1, 0, 1, 1, 1], [1, 1, 0, 1, 1, 1, 1, 1],
              [1, 1, 1, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 0, 1, 1]])

conv_codec = ConvCodec(M)
text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque sed quam augue.'

R = 5

word_bin = utils.str2bin(text)
word_symbol_arr = utils.transform(word_bin)
conv_encoded_symbols = conv_codec.encode(word_symbol_arr)

repetition_encoded = np.repeat(conv_encoded_symbols, R)

np.savetxt('input.txt', repetition_encoded)

os.system("python3 client.py --input_file=input.txt --output_file=output.txt "
          "--srv_hostname=iscsrv72.epfl.ch --srv_port=80")

output = np.loadtxt('output.txt')

repetition_decoded = np.mean(np.reshape(output, (-1, R)), axis=1)

conv_decoded_symbol_arr = conv_codec.decode(repetition_decoded)
conv_decoded = utils.inv_transform(conv_decoded_symbol_arr)
示例#4
0
 def __init__(self, dqti, name):
     self.value_name = ValueName(name)
     self.is_pointer = dqti.dir_qual.is_pointer
     self.is_mutable_indirect = dqti.dir_qual.is_mutable_indirect
     self.conv = ConvCodec(dqti, self.value_name.cpp)