mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
Fix up naming of Base64 and Leb128 functions.
Change-Id: I80a2493d822b59311ba0d7bd68b5ccf0e3b29e6a
This commit is contained in:
@@ -140,7 +140,7 @@ bool MessageReader::Run() {
|
||||
if (!Read16(&id)) return false;
|
||||
if (!Read16(&uid)) return false;
|
||||
unsigned long size;
|
||||
if (!ReadULEB128(&size)) return false;
|
||||
if (!ReadUleb128(&size)) return false;
|
||||
char* params;
|
||||
if (!Read(¶ms, size)) return false;
|
||||
m_handler.GotExecuteRpc(id, uid, params, size);
|
||||
@@ -155,7 +155,7 @@ bool MessageReader::Run() {
|
||||
if (!Read16(&id)) return false;
|
||||
if (!Read16(&uid)) return false;
|
||||
unsigned long size;
|
||||
if (!ReadULEB128(&size)) return false;
|
||||
if (!ReadUleb128(&size)) return false;
|
||||
char* results;
|
||||
if (!Read(&results, size)) return false;
|
||||
m_handler.GotRpcResponse(id, uid, results, size);
|
||||
|
||||
@@ -108,7 +108,7 @@ void MessageWriter::WriteRpc(unsigned int msg_type, unsigned int id,
|
||||
unsigned long len = 0;
|
||||
for (const NT_Value* value = values_start; value != values_end; ++value)
|
||||
len += GetValueSize(*value);
|
||||
WriteULEB128(len);
|
||||
WriteUleb128(len);
|
||||
|
||||
for (const NT_Value* value = values_start; value != values_end; ++value)
|
||||
WriteValue(*value);
|
||||
|
||||
@@ -191,7 +191,7 @@ bool WireDecoder::ReadString(NT_String* str) {
|
||||
str->len = v;
|
||||
} else {
|
||||
unsigned long v;
|
||||
if (!ReadULEB128(&v)) return false;
|
||||
if (!ReadUleb128(&v)) return false;
|
||||
str->len = v;
|
||||
}
|
||||
str->str = (char*)std::malloc(str->len + 1);
|
||||
|
||||
@@ -70,7 +70,9 @@ class WireDecoder {
|
||||
|
||||
bool ReadDouble(double* val);
|
||||
|
||||
bool ReadULEB128(unsigned long* val) { return read_uleb128(m_is, val); }
|
||||
bool ReadUleb128(unsigned long* val) {
|
||||
return ntimpl::ReadUleb128(m_is, val);
|
||||
}
|
||||
|
||||
bool ReadType(NT_Type* type);
|
||||
bool ReadValue(NT_Type type, NT_Value* value);
|
||||
|
||||
@@ -50,9 +50,9 @@ void WireEncoder::ReserveSlow(std::size_t len) {
|
||||
m_end = m_start + newlen;
|
||||
}
|
||||
|
||||
void WireEncoder::WriteULEB128(unsigned long val) {
|
||||
Reserve(size_uleb128(val));
|
||||
m_cur += write_uleb128(m_cur, val);
|
||||
void WireEncoder::WriteUleb128(unsigned long val) {
|
||||
Reserve(SizeUleb128(val));
|
||||
m_cur += ntimpl::WriteUleb128(m_cur, val);
|
||||
}
|
||||
|
||||
void WireEncoder::WriteType(NT_Type type) {
|
||||
@@ -180,7 +180,7 @@ void WireEncoder::WriteValue(const NT_Value& value) {
|
||||
|
||||
std::size_t WireEncoder::GetStringSize(const NT_String& str) {
|
||||
if (m_proto_rev < 0x0300u) return 2 + str.len;
|
||||
return size_uleb128(str.len) + str.len;
|
||||
return SizeUleb128(str.len) + str.len;
|
||||
}
|
||||
|
||||
void WireEncoder::WriteString(const NT_String& str) {
|
||||
@@ -191,7 +191,7 @@ void WireEncoder::WriteString(const NT_String& str) {
|
||||
if (len > 0xffff) len = 0xffff;
|
||||
Write16(len);
|
||||
} else
|
||||
WriteULEB128(len);
|
||||
WriteUleb128(len);
|
||||
|
||||
// contents
|
||||
Reserve(len);
|
||||
|
||||
@@ -59,7 +59,7 @@ class WireEncoder {
|
||||
|
||||
void WriteDouble(double val);
|
||||
|
||||
void WriteULEB128(unsigned long val);
|
||||
void WriteUleb128(unsigned long val);
|
||||
void WriteType(NT_Type type);
|
||||
void WriteValue(const NT_Value& value);
|
||||
void WriteString(const NT_String& str);
|
||||
|
||||
@@ -88,7 +88,7 @@ static const unsigned char pr2six[256] =
|
||||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64
|
||||
};
|
||||
|
||||
std::size_t base64decode_len(const char *bufcoded) {
|
||||
std::size_t Base64DecodeLen(const char *bufcoded) {
|
||||
const unsigned char *bufin = (const unsigned char *)bufcoded;
|
||||
while (pr2six[*(bufin++)] <= 63) {
|
||||
}
|
||||
@@ -99,7 +99,7 @@ std::size_t base64decode_len(const char *bufcoded) {
|
||||
return nbytesdecoded + 1;
|
||||
}
|
||||
|
||||
std::size_t base64decode(char *bufplain, const char *bufcoded) {
|
||||
std::size_t Base64Decode(char *bufplain, const char *bufcoded) {
|
||||
const unsigned char *bufin = (const unsigned char *)bufcoded;
|
||||
while (pr2six[*(bufin++)] <= 63) {
|
||||
}
|
||||
@@ -138,11 +138,11 @@ std::size_t base64decode(char *bufplain, const char *bufcoded) {
|
||||
static const char basis_64[] =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
std::size_t base64encode_len(std::size_t len) {
|
||||
std::size_t Base64EncodeLen(std::size_t len) {
|
||||
return ((len + 2) / 3 * 4) + 1;
|
||||
}
|
||||
|
||||
std::size_t base64encode(char *encoded, const unsigned char *string,
|
||||
std::size_t Base64Encode(char *encoded, const unsigned char *string,
|
||||
std::size_t len) {
|
||||
std::size_t i;
|
||||
char *p = encoded;
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
|
||||
namespace ntimpl {
|
||||
|
||||
std::size_t base64decode_len(const char *bufcoded);
|
||||
std::size_t base64decode(char *bufplain, const char *bufcoded);
|
||||
std::size_t base64encode_len(std::size_t len);
|
||||
std::size_t base64encode(char *encoded, const unsigned char *string,
|
||||
std::size_t Base64DecodeLen(const char *bufcoded);
|
||||
std::size_t Base64Decode(char *bufplain, const char *bufcoded);
|
||||
std::size_t Base64EncodeLen(std::size_t len);
|
||||
std::size_t Base64Encode(char *encoded, const unsigned char *string,
|
||||
std::size_t len);
|
||||
|
||||
} // namespace ntimpl
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace ntimpl {
|
||||
|
||||
/**
|
||||
* size_uleb128 - get size of unsigned LEB128 data
|
||||
* Get size of unsigned LEB128 data
|
||||
* @val: value
|
||||
*
|
||||
* Determine the number of bytes required to encode an unsigned LEB128 datum.
|
||||
@@ -20,7 +20,7 @@ namespace ntimpl {
|
||||
* on the encodings refer to section "7.6 - Variable Length Data". Return
|
||||
* the number of bytes required.
|
||||
*/
|
||||
std::size_t size_uleb128(unsigned long val) {
|
||||
std::size_t SizeUleb128(unsigned long val) {
|
||||
std::size_t count = 0;
|
||||
do {
|
||||
val >>= 7;
|
||||
@@ -30,7 +30,7 @@ std::size_t size_uleb128(unsigned long val) {
|
||||
}
|
||||
|
||||
/**
|
||||
* write_uleb128 - write unsigned LEB128 data
|
||||
* Write unsigned LEB128 data
|
||||
* @addr: the address where the ULEB128 data is to be stored
|
||||
* @val: value to be stored
|
||||
*
|
||||
@@ -39,7 +39,7 @@ std::size_t size_uleb128(unsigned long val) {
|
||||
* encodings refer to section "7.6 - Variable Length Data". Return
|
||||
* the number of bytes written.
|
||||
*/
|
||||
std::size_t write_uleb128(char* addr, unsigned long val) {
|
||||
std::size_t WriteUleb128(char* addr, unsigned long val) {
|
||||
std::size_t count = 0;
|
||||
|
||||
do {
|
||||
@@ -58,7 +58,7 @@ std::size_t write_uleb128(char* addr, unsigned long val) {
|
||||
}
|
||||
|
||||
/**
|
||||
* read_uleb128 - read unsigned LEB128 data
|
||||
* Read unsigned LEB128 data
|
||||
* @addr: the address where the ULEB128 data is stored
|
||||
* @ret: address to store the result
|
||||
*
|
||||
@@ -67,7 +67,7 @@ std::size_t write_uleb128(char* addr, unsigned long val) {
|
||||
* encodings refer to section "7.6 - Variable Length Data". Return
|
||||
* the number of bytes read.
|
||||
*/
|
||||
std::size_t read_uleb128(char* addr, unsigned long* ret) {
|
||||
std::size_t ReadUleb128(char* addr, unsigned long* ret) {
|
||||
unsigned long result = 0;
|
||||
int shift = 0;
|
||||
std::size_t count = 0;
|
||||
@@ -89,7 +89,7 @@ std::size_t read_uleb128(char* addr, unsigned long* ret) {
|
||||
}
|
||||
|
||||
/**
|
||||
* read_uleb128 - read unsigned LEB128 data from a stream
|
||||
* Read unsigned LEB128 data from a stream
|
||||
* @is: the input stream where the ULEB128 data is to be read from
|
||||
* @ret: address to store the result
|
||||
*
|
||||
@@ -98,7 +98,7 @@ std::size_t read_uleb128(char* addr, unsigned long* ret) {
|
||||
* encodings refer to section "7.6 - Variable Length Data". Return
|
||||
* false on stream error, true on success.
|
||||
*/
|
||||
bool read_uleb128(raw_istream& is, unsigned long* ret) {
|
||||
bool ReadUleb128(raw_istream& is, unsigned long* ret) {
|
||||
unsigned long result = 0;
|
||||
int shift = 0;
|
||||
|
||||
|
||||
@@ -14,10 +14,10 @@ namespace ntimpl {
|
||||
|
||||
class raw_istream;
|
||||
|
||||
std::size_t size_uleb128(unsigned long val);
|
||||
std::size_t write_uleb128(char* addr, unsigned long val);
|
||||
std::size_t read_uleb128(char* addr, unsigned long* ret);
|
||||
bool read_uleb128(raw_istream& is, unsigned long* ret);
|
||||
std::size_t SizeUleb128(unsigned long val);
|
||||
std::size_t WriteUleb128(char* addr, unsigned long val);
|
||||
std::size_t ReadUleb128(char* addr, unsigned long* ret);
|
||||
bool ReadUleb128(raw_istream& is, unsigned long* ret);
|
||||
|
||||
} // namespace ntimpl
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
using namespace ntimpl;
|
||||
|
||||
static void write_string(FILE* f, llvm::StringRef str) {
|
||||
static void WriteString(FILE* f, llvm::StringRef str) {
|
||||
fputc('"', f);
|
||||
for (unsigned int i = 0, e = str.size(); i != e; ++i) {
|
||||
unsigned char c = str[i];
|
||||
@@ -91,7 +91,7 @@ const char* NT_SavePersistent(const char* filename) {
|
||||
}
|
||||
|
||||
// name
|
||||
write_string(f, i->getKey());
|
||||
WriteString(f, i->getKey());
|
||||
|
||||
// =
|
||||
fputc('=', f);
|
||||
@@ -105,11 +105,11 @@ const char* NT_SavePersistent(const char* filename) {
|
||||
fprintf(f, "%g", v.data.v_double);
|
||||
break;
|
||||
case NT_STRING:
|
||||
write_string(f, make_StringRef(v.data.v_string));
|
||||
WriteString(f, make_StringRef(v.data.v_string));
|
||||
break;
|
||||
case NT_RAW: {
|
||||
char* buf = new char[base64encode_len(v.data.v_raw.len)];
|
||||
base64encode(buf,
|
||||
char* buf = new char[Base64EncodeLen(v.data.v_raw.len)];
|
||||
Base64Encode(buf,
|
||||
reinterpret_cast<const unsigned char*>(v.data.v_raw.str),
|
||||
v.data.v_raw.len);
|
||||
fputs(buf, f);
|
||||
@@ -130,7 +130,7 @@ const char* NT_SavePersistent(const char* filename) {
|
||||
break;
|
||||
case NT_STRING_ARRAY:
|
||||
for (size_t i = 0; i < v.data.arr_double.size; ++i) {
|
||||
write_string(f, make_StringRef(v.data.arr_string.arr[i]));
|
||||
WriteString(f, make_StringRef(v.data.arr_string.arr[i]));
|
||||
if (i != (v.data.arr_double.size - 1)) fputc(',', f);
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user