small tweak to proto stuff
This commit is contained in:
1 parent
1ce9410565
commit
e20fb7df90
4 files changed
+35
-18
No files matched your search
@@ -48,10 +48,12 @@ namespace Protobuf
|
||||
strBuffer = CreateObject("roByteArray")
|
||||
strBuffer.FromAsciiString(value)
|
||||
m.WriteVarInt(strBuffer.Count())
|
||||
for i = 0 to strBuffer.Count() - 1
|
||||
m.buffer[m.position + i] = strBuffer[i]
|
||||
end for
|
||||
m.position += strBuffer.Count()
|
||||
m.WriteByteArrayRaw(strBuffer, 0, strBuffer.Count())
|
||||
end function
|
||||
|
||||
function WriteProtoByteArray(value as dynamic) as void
|
||||
m.WriteVarInt(value.Count())
|
||||
m.WriteByteArrayRaw(value, 0, value.Count())
|
||||
end function
|
||||
|
||||
function WriteBool(value as dynamic) as void
|
||||
@@ -61,6 +63,14 @@ namespace Protobuf
|
||||
m.WriteByte(0)
|
||||
end if
|
||||
end function
|
||||
|
||||
function WriteByteArrayRaw(buffer as dynamic, index as dynamic, size as dynamic) as void
|
||||
position = m.position
|
||||
for i = 0 to size - 1
|
||||
m.buffer[position + i] = buffer[index + i]
|
||||
end for
|
||||
m.position += size
|
||||
end function
|
||||
end class
|
||||
|
||||
end namespace
|
||||
@@ -39,12 +39,7 @@ namespace Protobuf
|
||||
|
||||
function EncodeMessage(tag as integer, value as dynamic) as void
|
||||
m.writer.WriteByte((tag << 3) or 2)
|
||||
buffer = CreateObject("roByteArray")
|
||||
buffer.FromBase64String(value.DecodeUriComponent())
|
||||
m.writer.WriteVarInt(buffer.Count())
|
||||
for i = 0 to buffer.Count() - 1
|
||||
m.writer.WriteByte(buffer[i])
|
||||
end for
|
||||
m.writer.WriteProtoByteArray(value)
|
||||
end function
|
||||
|
||||
end class
|
||||
|
||||
Reference in new issue
Block a user