Example #1
0
def get_distinct_members(Descr):
    # '0' to make sure, that it works on an empty sequence too.
    TL = Descr.type_name_length_max()
    NL = Descr.variable_name_length_max()
    txt = ""
    for name, type_code in Descr.distinct_db.items():
        txt += __member(type_code, TL, name, NL)
    txt += action_info.get_return_to_source_reference()
    return txt
Example #2
0
def get_distinct_members(Descr):
    # '0' to make sure, that it works on an empty sequence too.
    TL = Descr.type_name_length_max()
    NL = Descr.variable_name_length_max()
    txt = ""
    for name, type_code in Descr.distinct_db.items():
        txt += __member(type_code, TL, name, NL)
    txt += action_info.get_return_to_source_reference()
    return txt
Example #3
0
def get_union_members(Descr):
    # '0' to make sure, that it works on an empty sequence too.
    TL = Descr.type_name_length_max()
    NL = Descr.variable_name_length_max()
    if len(Descr.union_db) == 0: return ""
    
    txt = "    union {\n"
    for name, type_descr in Descr.union_db.items():
        if type(type_descr) == dict:
            txt += "        struct {\n"
            for sub_name, sub_type in type_descr.items():
                txt += __member(sub_type, TL, sub_name, NL, IndentationOffset=" " * 8)
            txt += "\n        } %s;\n" % name
        else:
            txt += __member(type_descr, TL, name, NL, IndentationOffset=" " * 4) + "\n"
    txt += "    } content;\n"
    txt += action_info.get_return_to_source_reference()
    return txt
Example #4
0
def get_setter_getter(Descr):
    """NOTE: All names are unique even in combined unions."""
    TL = Descr.type_name_length_max()
    NL = Descr.variable_name_length_max()
    variable_db = Descr.get_member_db()
    txt = ""
    for variable_name, info in variable_db.items():
        type_code = info[0]
        access = info[1]
        type_str = type_code.get_pure_code()
        my_def = "    %s%s get_%s() const %s{ return %s; }" \
               % (type_str,      " " * (TL - len(type_str)),
                  variable_name, " " * ((NL + TL)- len(variable_name)),
                  access)
        txt += type_code.adorn_with_source_reference(my_def,
                                                     ReturnToSourceF=False)

        type_str = type_str.strip()
        type_str = type_str.replace("\t", " ")
        while type_str.find("  ") != -1:
            type_str = type_str.replace("  ", " ")
        if type_str not in [
                "char", "unsigned char", "singed char", "short",
                "unsigned short", "singed short", "int", "unsigned int",
                "singed int", "long", "unsigned long", "singed long", "float",
                "unsigned float", "singed float", "double", "unsigned double",
                "singed double", "size_t", "uintptr_t", "ptrdiff_t"
        ]:
            type_str += "&"

        my_def = "    void%s set_%s(%s Value) %s{ %s = Value; }" \
               % (" " * (TL - len("void")),
                  variable_name, type_str, " " * (NL + TL - (len(type_str) + len(variable_name))),
                  access)
        txt += type_code.adorn_with_source_reference(my_def,
                                                     ReturnToSourceF=False)

    txt += action_info.get_return_to_source_reference()
    return txt
Example #5
0
def get_union_members(Descr):
    # '0' to make sure, that it works on an empty sequence too.
    TL = Descr.type_name_length_max()
    NL = Descr.variable_name_length_max()
    if len(Descr.union_db) == 0: return ""

    txt = "    union {\n"
    for name, type_descr in Descr.union_db.items():
        if type(type_descr) == dict:
            txt += "        struct {\n"
            for sub_name, sub_type in type_descr.items():
                txt += __member(sub_type,
                                TL,
                                sub_name,
                                NL,
                                IndentationOffset=" " * 8)
            txt += "\n        } %s;\n" % name
        else:
            txt += __member(
                type_descr, TL, name, NL, IndentationOffset=" " * 4) + "\n"
    txt += "    } content;\n"
    txt += action_info.get_return_to_source_reference()
    return txt
Example #6
0
def get_setter_getter(Descr):
    """NOTE: All names are unique even in combined unions."""
    TL = Descr.type_name_length_max()
    NL = Descr.variable_name_length_max()
    variable_db = Descr.get_member_db()
    txt = ""
    for variable_name, info in variable_db.items():
        type_code = info[0]
        access    = info[1]
        type_str  = type_code.get_pure_code()
        my_def = "    %s%s get_%s() const %s{ return %s; }" \
               % (type_str,      " " * (TL - len(type_str)), 
                  variable_name, " " * ((NL + TL)- len(variable_name)), 
                  access)
        txt += type_code.adorn_with_source_reference(my_def, ReturnToSourceF=False)

        type_str = type_str.strip()
        type_str = type_str.replace("\t", " ")
        while type_str.find("  ") != -1:
            type_str = type_str.replace("  ", " ")
        if type_str not in ["char", "unsigned char", "singed char",
                            "short", "unsigned short", "singed short",
                            "int", "unsigned int", "singed int",
                            "long", "unsigned long", "singed long",
                            "float", "unsigned float", "singed float",
                            "double", "unsigned double", "singed double",
                            "size_t", "uintptr_t", "ptrdiff_t"]:
            type_str += "&"

        my_def = "    void%s set_%s(%s Value) %s{ %s = Value; }" \
               % (" " * (TL - len("void")), 
                  variable_name, type_str, " " * (NL + TL - (len(type_str) + len(variable_name))), 
                  access)
        txt += type_code.adorn_with_source_reference(my_def, ReturnToSourceF=False)

    txt += action_info.get_return_to_source_reference()
    return txt