@@ -935,6 +935,10 @@ cdef class Buffer:
935935 return self ._skip_int(8 , NULL )
936936
937937 cdef int write_binary_double(self , double value) except - 1 :
938+ """
939+ Writes a double value to the buffer in Oracle canonical double floating
940+ point format.
941+ """
938942 cdef:
939943 uint8_t b0, b1, b2, b3, b4, b5, b6, b7
940944 uint64_t all_bits
@@ -973,6 +977,10 @@ cdef class Buffer:
973977 self .write_raw(buf, 8 )
974978
975979 cdef int write_binary_float(self , float value) except - 1 :
980+ """
981+ Writes a float value to the buffer in Oracle canonical floating point
982+ format.
983+ """
976984 cdef:
977985 uint8_t b0, b1, b2, b3
978986 uint32_t all_bits
@@ -1052,6 +1060,10 @@ cdef class Buffer:
10521060
10531061 cdef int write_interval_ds(self , object value,
10541062 bint write_length = True ) except - 1 :
1063+ """
1064+ Writes an interval to the buffer in Oracle Interval Day To Second
1065+ format.
1066+ """
10551067 cdef:
10561068 int32_t days, seconds, fseconds
10571069 char_type buf[11 ]
@@ -1076,6 +1088,9 @@ cdef class Buffer:
10761088
10771089 cdef int write_oracle_date(self , object value, uint8_t length,
10781090 bint write_length = True ) except - 1 :
1091+ """
1092+ Writes a date to the buffer in Oracle Date format.
1093+ """
10791094 cdef:
10801095 unsigned int year
10811096 char_type buf[13 ]
@@ -1103,6 +1118,10 @@ cdef class Buffer:
11031118 self .write_raw(buf, length)
11041119
11051120 cdef int write_oracle_number(self , bytes num_bytes) except - 1 :
1121+ """
1122+ Writes a number in UTF-8 encoded bytes in Oracle Number format to the
1123+ buffer.
1124+ """
11061125 cdef:
11071126 uint8_t num_digits = 0 , digit, num_pairs, pair_num, digits_pos
11081127 bint exponent_is_negative = False , append_sentinel = False
@@ -1268,6 +1287,9 @@ cdef class Buffer:
12681287 self .write_uint64(0 ) # unused
12691288
12701289 cdef int write_raw(self , const char_type * data, ssize_t length) except - 1 :
1290+ """
1291+ Writes raw bytes of the specified length to the buffer.
1292+ """
12711293 cdef ssize_t bytes_to_write
12721294 while True :
12731295 bytes_to_write = min (self ._max_size - self ._pos, length)
@@ -1281,36 +1303,67 @@ cdef class Buffer:
12811303 data += bytes_to_write
12821304
12831305 cdef int write_str(self , str value) except - 1 :
1306+ """
1307+ Writes a string to the buffer as UTF-8 encoded bytes.
1308+ """
12841309 self .write_bytes(value.encode())
12851310
12861311 cdef int write_uint8(self , uint8_t value) except - 1 :
1312+ """
1313+ Writes an 8-bit integer to the buffer.
1314+ """
12871315 if self ._pos + 1 > self ._max_size:
12881316 self ._write_more_data(self ._max_size - self ._pos, 1 )
12891317 self ._data[self ._pos] = value
12901318 self ._pos += 1
12911319
12921320 cdef int write_uint16(self , uint16_t value,
12931321 int byte_order = BYTE_ORDER_MSB) except - 1 :
1322+ """
1323+ Writes a 16-bit integer to the buffer in native format.
1324+ """
12941325 if self ._pos + 2 > self ._max_size:
12951326 self ._write_more_data(self ._max_size - self ._pos, 2 )
12961327 pack_uint16(& self ._data[self ._pos], value, byte_order)
12971328 self ._pos += 2
12981329
12991330 cdef int write_uint32(self , uint32_t value,
13001331 int byte_order = BYTE_ORDER_MSB) except - 1 :
1332+ """
1333+ Writes a 32-bit integer to the buffer in native format.
1334+ """
13011335 if self ._pos + 4 > self ._max_size:
13021336 self ._write_more_data(self ._max_size - self ._pos, 4 )
13031337 pack_uint32(& self ._data[self ._pos], value, byte_order)
13041338 self ._pos += 4
13051339
13061340 cdef int write_uint64(self , uint64_t value,
13071341 byte_order = BYTE_ORDER_MSB) except - 1 :
1342+ """
1343+ Writes a 64-bit integer to the buffer in native format.
1344+ """
13081345 if self ._pos + 8 > self ._max_size:
13091346 self ._write_more_data(self ._max_size - self ._pos, 8 )
13101347 pack_uint64(& self ._data[self ._pos], value, byte_order)
13111348 self ._pos += 8
13121349
1350+ cdef int write_ub2(self , uint16_t value) except - 1 :
1351+ """
1352+ Writes a 16-bit integer to the buffer in universal format.
1353+ """
1354+ if value == 0 :
1355+ self .write_uint8(0 )
1356+ elif value <= UINT8_MAX:
1357+ self .write_uint8(1 )
1358+ self .write_uint8(< uint8_t> value)
1359+ else :
1360+ self .write_uint8(2 )
1361+ self .write_uint16(value)
1362+
13131363 cdef int write_ub4(self , uint32_t value) except - 1 :
1364+ """
1365+ Writes a 32-bit integer to the buffer in universal format.
1366+ """
13141367 if value == 0 :
13151368 self .write_uint8(0 )
13161369 elif value <= UINT8_MAX:
@@ -1324,6 +1377,9 @@ cdef class Buffer:
13241377 self .write_uint32(value)
13251378
13261379 cdef int write_ub8(self , uint64_t value) except - 1 :
1380+ """
1381+ Writes a 64-bit integer to the buffer in universal format.
1382+ """
13271383 if value == 0 :
13281384 self .write_uint8(0 )
13291385 elif value <= UINT8_MAX:
@@ -1334,7 +1390,7 @@ cdef class Buffer:
13341390 self .write_uint16(< uint16_t> value)
13351391 elif value <= UINT32_MAX:
13361392 self .write_uint8(4 )
1337- self .write_uint32(value)
1393+ self .write_uint32(< uint32_t > value)
13381394 else :
13391395 self .write_uint8(8 )
13401396 self .write_uint64(value)
0 commit comments