Exemplo n.º 1
0
def toBufferMethodStructAccess(element, name=None):
    if isinstance(element, filter.Primitive):
        type = str(element.type)
    else:
        type = str(element.subtype.name)
    if name == None:
        name = filter.variableName(element.name)
    if type in filter.PRIMITIVES:
        return "new %s(%s).toBuffer(buffer)" % \
            (filter.PRIMITIVES[type].name,
             name)
    else:
        return "%s.toBuffer(buffer)" % name
Exemplo n.º 2
0
def toBufferMethodStructAccess(element, name=None):
	if isinstance(element, filter.Primitive):
		type = str(element.type)
	else:
		type = str(element.subtype.name)
	if name == None:
		name = filter.variableName(element.name)
	if type in filter.PRIMITIVES:
		return "new %s(%s).toBuffer(buffer)" % \
						(filter.PRIMITIVES[type].name,
						 name)
	else:
		return "%s.toBuffer(buffer)" % name
Exemplo n.º 3
0
def toBufferMethod(element, name=None):
    if isinstance(element, filter.Primitive):
        type = str(element.type)
    else:
        type = str(element.subtype.name)
    if name == None:
        name = filter.variableName(element.name)
    if type in filter.PRIMITIVES:
        if type == "Bool":
            return "buffer.put((byte) (%s ? 1 : 0))" % name
        else:
            return "buffer.put%s((%s) %s)" % \
               (filter.PRIMITIVES[type].accessor,
                filter.PRIMITIVES[type].equivalent,
                name)
    else:
        return "%s.toBuffer(buffer)" % name
Exemplo n.º 4
0
def toBufferMethod(element, name=None):
	if isinstance(element, filter.Primitive):
		type = str(element.type)
	else:
		type = str(element.subtype.name)
	if name == None:
		name = filter.variableName(element.name)
	if type in filter.PRIMITIVES:
		if type == "Bool":
			return "buffer.put((byte) (%s ? 1 : 0))" % name
		else:
			return "buffer.put%s((%s) %s)" % \
						(filter.PRIMITIVES[type].accessor,
						 filter.PRIMITIVES[type].equivalent,
						 name)
	else:
		return "%s.toBuffer(buffer)" % name