Exemplo n.º 1
0
def filter_subtype(value):
    """ value needs to be parser.structure.SubType """
    type = filter.typeName(value.subtype.name)
    variable = filter.variableName(value.name)
    if value.subtype.isArray:
        return "%s %s[%s]" % (type, variable, value.subtype.count)
    else:
        return "%s %s" % (type, variable)
Exemplo n.º 2
0
def filter_subtype(value):
    """ value needs to be parser.structure.SubType """
    type = filter.typeName(value.subtype.name)
    variable = filter.variableName(value.name)
    if value.subtype.isArray:
        return "%s %s[%s]" % (type, variable, value.subtype.count)
    else:
        return "%s %s" % (type, variable)
Exemplo n.º 3
0
def filter_array_constructor(class_, default=True):
    if default: return ""

    memcpyList = []
    for item in class_.iter():
        if not item.subtype.isArray: continue
        name = filter.variableName(item.name)
        type = filter.typeName(item.subtype.name)
        count = item.subtype.count

        memcpyList.append("memcpy(this->%s, %s, %s * sizeof(%s));" %
                          (name, name, count, type))

    return " ".join(memcpyList)
Exemplo n.º 4
0
def filter_initialization_list(class_, default=True):
    initList = []
    for item in class_.iter():
        if item.subtype.isArray:
            raise builder.BuilderException(
                "Array handling is incomplete " "right now! Could not generate code for %s" % item
            )
        else:
            type = filter.typeName(item.subtype.name)
            name = filter.variableName(item.name)

            if default:
                initList.append("%s()" % name)
            else:
                initList.append("%s(%s)" % (name, name))

    return ", ".join(initList)
Exemplo n.º 5
0
def filter_constructor(class_, default=True):
	if default:
		return "%s()" % filter.typeName(class_.name)
	else:
		parameter = []
		for item in class_.iter():
			if item.subtype.isArray:
				raise builder.BuilderException("Array handling is incomplete " \
						"right now! Could not generate code for %s" % item)
			else:
				type = filter.typeName(item.subtype.name)
				name = filter.variableName(item.name)
				
				parameter.append("%s %s" % (type, name))
		
		if len(parameter) > 0:
			return "%s(%s)" % (filter.typeName(class_.name), ", ".join(parameter))
		else:
			return ""
Exemplo n.º 6
0
def filter_initialization_list(class_, default=True):
    initList = []
    for item in class_.iter():
        type = filter.typeName(item.subtype.name)
        name = filter.variableName(item.name)
        if item.value is not None:
            defaultValue = item.value
        else:
            defaultValue = ''

        if default:
            initList.append("%s(%s)" % (name, defaultValue))
        else:
            if item.subtype.isArray: continue
            initList.append("%s(%s)" % (name, name))

    if len(initList):
        return ": " + ", ".join(initList)
    return ""
Exemplo n.º 7
0
def filter_initialization_list(class_, default=True):
    initList = []
    for item in class_.iter():
        if item.subtype.isArray:
            raise builder.BuilderException("Array handling is incomplete " \
              "right now! Could not generate code for %s" % item)
        else:
            type = filter.typeName(item.subtype.name)
            name = filter.variableName(item.name)
            if item.value is not None:
                defaultValue = item.value
            else:
                defaultValue = ''

            if default:
                initList.append("%s(%s)" % (name, defaultValue))
            else:
                initList.append("%s(%s)" % (name, name))

    return ", ".join(initList)
Exemplo n.º 8
0
def filter_constructor(class_, default=True):
    if default:
        return "%s()" % filter.typeName(class_.name)
    else:
        parameter = []
        for item in class_.iter():
            if item.subtype.isArray:
                raise builder.BuilderException("Array handling is incomplete " \
                  "right now! Could not generate code for %s" % item)
            else:
                type = filter.typeName(item.subtype.name)
                name = filter.variableName(item.name)

                parameter.append("%s %s" % (type, name))

        if len(parameter) > 0:
            return "%s(%s)" % (filter.typeName(
                class_.name), ", ".join(parameter))
        else:
            return ""
Exemplo n.º 9
0
def filter_constructor(class_, default=True):
    if default:
        return "constexpr %s()" % filter.typeName(class_.name)
    else:
        parameter = []
        is_constexpr = True
        for item in class_.iter():
            type = filter.typeName(item.subtype.name)
            if item.subtype.isArray:
                type += " *"
                is_constexpr = False
            name = filter.variableName(item.name)

            parameter.append("%s %s" % (type, name))

        if len(parameter) > 0:
            return "%s%s(%s)" % ("constexpr " if is_constexpr else "",
                                 filter.typeName(
                                     class_.name), ", ".join(parameter))
        else:
            return ""