mirror of
https://github.com/aziascreations/PB-MessagePack.git
synced 2026-11-03 17:01:24 +01:00
Added missing core types, Changed names, Fixed minor issues
Update MessagePack.pbi and Test.pb
This commit is contained in:
+260
-187
@@ -23,6 +23,16 @@
|
||||
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------------
|
||||
;- Configurations
|
||||
|
||||
; Scrapped idea
|
||||
;CompilerIf Not Defined(MsgPack_LookupTable_FormatCode, #PB_Constant)
|
||||
; #MsgPack_LookupTable_FormatCode = #False
|
||||
;CompilerEndIf
|
||||
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------------
|
||||
;- Compiler directive
|
||||
|
||||
@@ -40,72 +50,139 @@
|
||||
; ------------------------------------------------------------------------------
|
||||
;- Enumerations
|
||||
|
||||
Enumeration MsgPack_Types
|
||||
#MsgPack_Types_Null
|
||||
#MsgPack_Types_Nil = #MsgPack_Types_Null
|
||||
|
||||
#MsgPack_Types_False
|
||||
#MsgPack_Types_True
|
||||
|
||||
#MsgPack_Types_FixIntPositive
|
||||
#MsgPack_Types_FixIntNegative
|
||||
|
||||
#MsgPack_Types_UInt8
|
||||
#MsgPack_Types_UInt16
|
||||
#MsgPack_Types_UInt32
|
||||
#MsgPack_Types_UInt64
|
||||
|
||||
#MsgPack_Types_Int8
|
||||
#MsgPack_Types_Int16
|
||||
#MsgPack_Types_Int32
|
||||
#MsgPack_Types_Int64
|
||||
Enumeration _MsgPack_DataTypes
|
||||
; ???
|
||||
#MsgPack_DataTypes_Unknown
|
||||
|
||||
#MsgPack_Types_Float32
|
||||
#MsgPack_Types_Float64
|
||||
; nil
|
||||
#MsgPack_DataTypes_Null
|
||||
#MsgPack_DataTypes_Nil = #MsgPack_Types_Null
|
||||
|
||||
; bool family
|
||||
#MsgPack_DataTypes_Boolean
|
||||
|
||||
; int family
|
||||
#MsgPack_DataTypes_FixIntPositive
|
||||
#MsgPack_DataTypes_FixIntNegative
|
||||
|
||||
#MsgPack_DataTypes_UInt8
|
||||
#MsgPack_DataTypes_UInt16
|
||||
#MsgPack_DataTypes_UInt32
|
||||
#MsgPack_DataTypes_UInt64
|
||||
|
||||
#MsgPack_DataTypes_Int8
|
||||
#MsgPack_DataTypes_Int16
|
||||
#MsgPack_DataTypes_Int32
|
||||
#MsgPack_DataTypes_Int64
|
||||
|
||||
#MsgPack_Types_Custom
|
||||
; float family
|
||||
#MsgPack_DataTypes_Float
|
||||
#MsgPack_DataTypes_Double
|
||||
|
||||
; str family
|
||||
#MsgPack_DataTypes_String
|
||||
|
||||
; bin family
|
||||
#MsgPack_DataTypes_Binary
|
||||
|
||||
; array family
|
||||
#MsgPack_DataTypes_Array
|
||||
|
||||
; map family
|
||||
#MsgPack_DataTypes_Map
|
||||
|
||||
; map family
|
||||
#MsgPack_DataTypes_Ext
|
||||
|
||||
; Extensions
|
||||
#MsgPack_DataTypes_Extension
|
||||
EndEnumeration
|
||||
|
||||
Enumeration MsgPack_FormatCodes
|
||||
|
||||
; 1 type byte, nothing else
|
||||
Enumeration _MsgPack_FormatCodes
|
||||
; nil
|
||||
#MsgPack_FormatCode_Null = $C0
|
||||
#MsgPack_FormatCode_Nil = #MsgPack_Types_Null
|
||||
#MsgPack_FormatCode_Nil = #MsgPack_Types_Null
|
||||
|
||||
; 1 type byte, nothing else
|
||||
; bool family
|
||||
#MsgPack_FormatCode_False = $C2
|
||||
|
||||
; 1 type byte, nothing else
|
||||
#MsgPack_FormatCode_True = $C3
|
||||
#MsgPack_FormatCode_True = $C3
|
||||
|
||||
; 1 type byte + 4 data bytes (big-endian IEEE 754 single precision)
|
||||
#MsgPack_FormatCode_Float32 = $CA
|
||||
; int family
|
||||
#MsgPack_FormatCode_FixIntPositive = %00000000 ; 0x00-0x7F
|
||||
#MsgPack_FormatCode_FixIntNegative = %11100000 ; 0xE0-0xFF
|
||||
|
||||
; 1 type byte + 8 data bytes (big-endian IEEE 754 double precision)
|
||||
#MsgPack_FormatCode_Float64 = $CB
|
||||
|
||||
; Special
|
||||
#MsgPack_FormatCode_FixIntPositive = $CC
|
||||
#MsgPack_FormatCode_FixIntNegative = $CC
|
||||
|
||||
#MsgPack_FormatCode_UInt8 = $CC
|
||||
#MsgPack_FormatCode_UInt8 = $CC
|
||||
#MsgPack_FormatCode_UInt16 = $CD
|
||||
#MsgPack_FormatCode_UInt32 = $CE
|
||||
#MsgPack_FormatCode_UInt64 = $CF
|
||||
|
||||
#MsgPack_FormatCode_Int8 = $D0
|
||||
#MsgPack_FormatCode_Int8 = $D0
|
||||
#MsgPack_FormatCode_Int16 = $D1
|
||||
#MsgPack_FormatCode_Int32 = $D2
|
||||
#MsgPack_FormatCode_Int64 = $D3
|
||||
|
||||
|
||||
; float family
|
||||
#MsgPack_FormatCode_Float32 = $CA
|
||||
#MsgPack_FormatCode_Float64 = $CB
|
||||
|
||||
; str family
|
||||
#MsgPack_FormatCode_FixStr = %10100000 ; 0xA0-0xBF
|
||||
#MsgPack_FormatCode_Str8 = $D9
|
||||
#MsgPack_FormatCode_Str16 = $DA
|
||||
#MsgPack_FormatCode_Str32 = $DB
|
||||
|
||||
; bin family
|
||||
#MsgPack_FormatCode_Bin8 = $C4
|
||||
#MsgPack_FormatCode_Bin16 = $C5
|
||||
#MsgPack_FormatCode_Bin32 = $C6
|
||||
|
||||
; array family
|
||||
#MsgPack_FormatCode_FixArray = %10010000 ; 0x90-0x9F
|
||||
#MsgPack_FormatCode_Array16 = $DC
|
||||
#MsgPack_FormatCode_Array32 = $DD
|
||||
|
||||
; map family
|
||||
#MsgPack_FormatCode_FixMap = %10000000 ; 0x80-0x8F
|
||||
#MsgPack_FormatCode_Map16 = $DE
|
||||
#MsgPack_FormatCode_Map32 = $DF
|
||||
|
||||
; fixext family
|
||||
#MsgPack_FormatCode_FixExt1 = $D4
|
||||
#MsgPack_FormatCode_FixExt2 = $D5
|
||||
#MsgPack_FormatCode_FixExt4 = $D6
|
||||
#MsgPack_FormatCode_FixExt8 = $D7
|
||||
#MsgPack_FormatCode_FixExt16 = $D8
|
||||
|
||||
; ext family
|
||||
#MsgPack_FormatCode_Ext8 = $C7
|
||||
#MsgPack_FormatCode_Ext16 = $C8
|
||||
#MsgPack_FormatCode_Ext32 = $C9
|
||||
|
||||
; Tmp
|
||||
#MsgPack_FormatCode_Invalid = $C1
|
||||
EndEnumeration
|
||||
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------------
|
||||
;- Typedefs
|
||||
|
||||
CompilerIf Defined(MsgPack_DataType, #PB_Macro)
|
||||
CompilerError("The typedef macro `MsgPack_DataType` is already defined !")
|
||||
CompilerEndIf
|
||||
Macro MsgPack_DataType : b : EndMacro
|
||||
|
||||
CompilerIf Defined(MsgPack_FormatCode, #PB_Macro)
|
||||
CompilerError("The typedef macro `MsgPack_FormatCode` is already defined !")
|
||||
CompilerEndIf
|
||||
Macro MsgPack_FormatCode : b : EndMacro
|
||||
|
||||
|
||||
; Private structure representing read/write buffers
|
||||
Structure MsgPackThingy
|
||||
|
||||
; ------------------------------------------------------------------------------
|
||||
;- Structures
|
||||
|
||||
Structure MsgPackData
|
||||
; Offset used when reading or writing.
|
||||
BufferOffset.i
|
||||
|
||||
@@ -115,6 +192,9 @@ Structure MsgPackThingy
|
||||
; Temp mechanism for buffer growth.
|
||||
BufferGrowthIncrements.i
|
||||
|
||||
; LastError code (Unused)
|
||||
LastError.i
|
||||
|
||||
; Pointer to a data buffer.
|
||||
; Can be freed by the caller or this module.
|
||||
*Buffer
|
||||
@@ -122,37 +202,14 @@ EndStructure
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; Tmp
|
||||
Procedure MsgPackAAAAA(DataFormatCode.a)
|
||||
|
||||
; FixInts
|
||||
If DataFormatCode & %10000000 = 0
|
||||
ProcedureReturn #MsgPack_Types_FixIntPositive
|
||||
EndIf
|
||||
|
||||
|
||||
If DataFormatCode & %11100000 = %11100000
|
||||
ProcedureReturn #MsgPack_Types_FixIntNegative
|
||||
EndIf
|
||||
|
||||
EndProcedure
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------------
|
||||
;- Macros
|
||||
|
||||
Macro _HasSpaceLeft(MsgPackWrapper, DesiredSize)
|
||||
Macro _MsgPackHasSpaceLeft(MsgPackWrapper, DesiredSize)
|
||||
((MsgPackWrapper\BufferSize >= MsgPackWrapper\BufferOffset) And (MsgPackWrapper\BufferSize - MsgPackWrapper\BufferOffset >= DesiredSize))
|
||||
EndMacro
|
||||
|
||||
Macro _IsAtTheEnd(MsgPackWrapper)
|
||||
Macro _MsgPackIsAtTheEnd(MsgPackWrapper)
|
||||
(MsgPackWrapper\BufferOffset >= MsgPackWrapper\BufferSize)
|
||||
EndMacro
|
||||
|
||||
@@ -161,21 +218,17 @@ EndMacro
|
||||
; ------------------------------------------------------------------------------
|
||||
;- Procedures
|
||||
|
||||
;--> Thingies
|
||||
;-> Thingies
|
||||
|
||||
Procedure.i MsgPackCreateMsgBuffer(InitialSize.i)
|
||||
Debug "########################################"
|
||||
Debug "MsgPackCreateMsgBuffer()"
|
||||
Debug " InitialSize: " + Str(InitialSize)
|
||||
|
||||
Protected *ReturnedValue.MsgPackThingy = #Null
|
||||
Procedure.i MsgPackCreate(InitialSize.i)
|
||||
Protected *ReturnedValue.MsgPackData = #Null
|
||||
|
||||
If InitialSize <= 0
|
||||
DebuggerWarning("Returning #Null, requested size was zero or negative")
|
||||
ProcedureReturn #Null
|
||||
EndIf
|
||||
|
||||
*ReturnedValue = AllocateStructure(MsgPackThingy)
|
||||
*ReturnedValue = AllocateStructure(MsgPackData)
|
||||
|
||||
If *ReturnedValue <> #Null
|
||||
*ReturnedValue\BufferOffset = 0
|
||||
@@ -197,34 +250,26 @@ EndProcedure
|
||||
; Does not copy or take ownership of *Buffer: free it yourself, and pass
|
||||
; FreeDataBuffer = #False to MsgPackFreeMsgBuffer for the wrapper it returns.
|
||||
Procedure.i MsgPackWrapMsgBuffer(*Buffer, BufferSize.i)
|
||||
Debug "########################################"
|
||||
Debug "MsgPackWrapMsgBuffer()"
|
||||
Debug " *Buffer: 0x" + RSet(Hex(*Buffer), SizeOf(Integer) * 2, "0")
|
||||
Debug " BufferSize: " + Str(BufferSize)
|
||||
;If *Buffer
|
||||
; Debug " MemorySize: " + Str(MemorySize(*Buffer))
|
||||
;EndIf
|
||||
|
||||
Protected *ReturnedValue.MsgPackThingy = #Null
|
||||
Protected *ReturnedValue.MsgPackData = #Null
|
||||
|
||||
If *Buffer = #Null Or BufferSize <= 0
|
||||
ProcedureReturn #Null
|
||||
EndIf
|
||||
|
||||
*ReturnedValue = AllocateStructure(MsgPackThingy)
|
||||
*ReturnedValue = AllocateStructure(MsgPackData)
|
||||
If *ReturnedValue = #Null
|
||||
ProcedureReturn #Null
|
||||
EndIf
|
||||
|
||||
*ReturnedValue\BufferOffset = 0
|
||||
*ReturnedValue\BufferSize = BufferSize
|
||||
*ReturnedValue\BufferGrowthIncrements = 0 ; wrapped buffer isn't grown
|
||||
*ReturnedValue\BufferGrowthIncrements = 0
|
||||
*ReturnedValue\Buffer = *Buffer
|
||||
|
||||
ProcedureReturn *ReturnedValue
|
||||
EndProcedure
|
||||
|
||||
Procedure.b MsgPackFreeMsgBuffer(*MsgPackData.MsgPackThingy, FreeDataBuffer.b = #False)
|
||||
Procedure.b MsgPackFree(*MsgPackData.MsgPackData, FreeDataBuffer.b = #False)
|
||||
If Not *MsgPackData
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
@@ -240,18 +285,57 @@ Procedure.b MsgPackFreeMsgBuffer(*MsgPackData.MsgPackThingy, FreeDataBuffer.b =
|
||||
EndProcedure
|
||||
|
||||
|
||||
;-> Iterators
|
||||
|
||||
;--> Read/Write
|
||||
; Tmp
|
||||
; CompilerIf Defined(MsgPack_LookupTable_FormatCode)
|
||||
|
||||
;---> UInt8
|
||||
Procedure.MsgPack_DataType MsgPackNextDataType(DataFormatCode.a)
|
||||
|
||||
; Processing Fix* formats before to speed them up
|
||||
|
||||
Procedure.b MsgPackWriteUInt8(*MsgPackData.MsgPackThingy, Value.a)
|
||||
If DataFormatCode < $0x80
|
||||
; 0x00 - 0x7F
|
||||
ProcedureReturn #MsgPack_FormatCode_FixIntPositive
|
||||
|
||||
ElseIf DataFormatCode < $0x90
|
||||
; 0x80 - 0x8F
|
||||
ProcedureReturn #MsgPack_FormatCode_FixMap
|
||||
|
||||
ElseIf DataFormatCode < $0xA0
|
||||
; 0x90 - 0x9F
|
||||
ProcedureReturn #MsgPack_FormatCode_FixArray
|
||||
|
||||
ElseIf DataFormatCode < $0xC0
|
||||
; 0xA0 - 0xBF
|
||||
ProcedureReturn #MsgPack_FormatCode_FixStr
|
||||
|
||||
ElseIf DataFormatCode < $0xE0
|
||||
; 0xC0 - 0xDF -> Various
|
||||
ProcedureReturn DataFormatCode
|
||||
|
||||
Else
|
||||
; 0xE0 - 0xFF -> ???
|
||||
ProcedureReturn MsgPack_FormatCode_Invalid
|
||||
EndIf
|
||||
|
||||
EndProcedure
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;-> Getters & Setters
|
||||
|
||||
;-> > UInt8
|
||||
|
||||
Procedure.b MsgPackWriteUInt8(*MsgPackData.MsgPackData, Value.a)
|
||||
If Not *MsgPackData
|
||||
DebuggerError("A #Null MsgPackThingy pointer was passed !")
|
||||
DebuggerError("A #Null MsgPackData pointer was passed !")
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
|
||||
If Not _HasSpaceLeft(*MsgPackData, 2)
|
||||
If Not _MsgPackHasSpaceLeft(*MsgPackData, 2)
|
||||
Debug("Growing buffer for UInt8...")
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
@@ -265,15 +349,15 @@ Procedure.b MsgPackWriteUInt8(*MsgPackData.MsgPackThingy, Value.a)
|
||||
EndProcedure
|
||||
|
||||
|
||||
Procedure.a MsgPackReadUInt8(*MsgPackData.MsgPackThingy)
|
||||
Procedure.a MsgPackReadUInt8(*MsgPackData.MsgPackData)
|
||||
Protected ReturnedValue.a = $00
|
||||
|
||||
If Not *MsgPackData
|
||||
DebuggerError("A #Null MsgPackThingy pointer was passed !")
|
||||
DebuggerError("A #Null MsgPackData pointer was passed !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
|
||||
If _IsAtTheEnd(*MsgPackData)
|
||||
If _MsgPackIsAtTheEnd(*MsgPackData)
|
||||
DebuggerError("End of buffer reached, cannot check data format code !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
@@ -285,7 +369,7 @@ Procedure.a MsgPackReadUInt8(*MsgPackData.MsgPackThingy)
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
|
||||
If Not _HasSpaceLeft(*MsgPackData, 2)
|
||||
If Not _MsgPackHasSpaceLeft(*MsgPackData, 2)
|
||||
DebuggerError("End of buffer reached, cannot read out of bounds !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
@@ -298,16 +382,15 @@ EndProcedure
|
||||
|
||||
|
||||
|
||||
;-> > Int8
|
||||
|
||||
;---> Int8
|
||||
|
||||
Procedure.b MsgPackWriteInt8(*MsgPackData.MsgPackThingy, Value.b)
|
||||
Procedure.b MsgPackWriteInt8(*MsgPackData.MsgPackData, Value.b)
|
||||
If Not *MsgPackData
|
||||
DebuggerError("A #Null MsgPackThingy pointer was passed !")
|
||||
DebuggerError("A #Null MsgPackData pointer was passed !")
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
|
||||
If Not _HasSpaceLeft(*MsgPackData, 2)
|
||||
If Not _MsgPackHasSpaceLeft(*MsgPackData, 2)
|
||||
Debug("Growing buffer for Int8...")
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
@@ -321,15 +404,15 @@ Procedure.b MsgPackWriteInt8(*MsgPackData.MsgPackThingy, Value.b)
|
||||
EndProcedure
|
||||
|
||||
|
||||
Procedure.b MsgPackReadInt8(*MsgPackData.MsgPackThingy)
|
||||
Procedure.b MsgPackReadInt8(*MsgPackData.MsgPackData)
|
||||
Protected ReturnedValue.b = $00
|
||||
|
||||
If Not *MsgPackData
|
||||
DebuggerError("A #Null MsgPackThingy pointer was passed !")
|
||||
DebuggerError("A #Null MsgPackData pointer was passed !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
|
||||
If _IsAtTheEnd(*MsgPackData)
|
||||
If _MsgPackIsAtTheEnd(*MsgPackData)
|
||||
DebuggerError("End of buffer reached, cannot check data format code !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
@@ -341,7 +424,7 @@ Procedure.b MsgPackReadInt8(*MsgPackData.MsgPackThingy)
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
|
||||
If Not _HasSpaceLeft(*MsgPackData, 2)
|
||||
If Not _MsgPackHasSpaceLeft(*MsgPackData, 2)
|
||||
DebuggerError("End of buffer reached, cannot read out of bounds !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
@@ -353,17 +436,15 @@ Procedure.b MsgPackReadInt8(*MsgPackData.MsgPackThingy)
|
||||
EndProcedure
|
||||
|
||||
|
||||
;-> > UInt16
|
||||
|
||||
|
||||
;---> UInt16
|
||||
|
||||
Procedure.b MsgPackWriteUInt16(*MsgPackData.MsgPackThingy, Value.u)
|
||||
Procedure.b MsgPackWriteUInt16(*MsgPackData.MsgPackData, Value.u)
|
||||
If Not *MsgPackData
|
||||
DebuggerError("A #Null MsgPackThingy pointer was passed !")
|
||||
DebuggerError("A #Null MsgPackData pointer was passed !")
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
|
||||
If Not _HasSpaceLeft(*MsgPackData, 3)
|
||||
If Not _MsgPackHasSpaceLeft(*MsgPackData, 3)
|
||||
Debug("Growing buffer for UInt16...")
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
@@ -377,15 +458,15 @@ Procedure.b MsgPackWriteUInt16(*MsgPackData.MsgPackThingy, Value.u)
|
||||
EndProcedure
|
||||
|
||||
|
||||
Procedure.u MsgPackReadUInt16(*MsgPackData.MsgPackThingy)
|
||||
Procedure.u MsgPackReadUInt16(*MsgPackData.MsgPackData)
|
||||
Protected ReturnedValue.u = $0000
|
||||
|
||||
If Not *MsgPackData
|
||||
DebuggerError("A #Null MsgPackThingy pointer was passed !")
|
||||
DebuggerError("A #Null MsgPackData pointer was passed !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
|
||||
If _IsAtTheEnd(*MsgPackData)
|
||||
If _MsgPackIsAtTheEnd(*MsgPackData)
|
||||
DebuggerError("End of buffer reached, cannot check data format code !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
@@ -397,7 +478,7 @@ Procedure.u MsgPackReadUInt16(*MsgPackData.MsgPackThingy)
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
|
||||
If Not _HasSpaceLeft(*MsgPackData, 3)
|
||||
If Not _MsgPackHasSpaceLeft(*MsgPackData, 3)
|
||||
DebuggerError("End of buffer reached, cannot read out of bounds !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
@@ -409,17 +490,15 @@ Procedure.u MsgPackReadUInt16(*MsgPackData.MsgPackThingy)
|
||||
EndProcedure
|
||||
|
||||
|
||||
;-> > > Int16
|
||||
|
||||
|
||||
;---> Int16
|
||||
|
||||
Procedure.b MsgPackWriteInt16(*MsgPackData.MsgPackThingy, Value.w)
|
||||
Procedure.b MsgPackWriteInt16(*MsgPackData.MsgPackData, Value.w)
|
||||
If Not *MsgPackData
|
||||
DebuggerError("A #Null MsgPackThingy pointer was passed !")
|
||||
DebuggerError("A #Null MsgPackData pointer was passed !")
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
|
||||
If Not _HasSpaceLeft(*MsgPackData, 3)
|
||||
If Not _MsgPackHasSpaceLeft(*MsgPackData, 3)
|
||||
Debug("Growing buffer for Int16...")
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
@@ -433,15 +512,15 @@ Procedure.b MsgPackWriteInt16(*MsgPackData.MsgPackThingy, Value.w)
|
||||
EndProcedure
|
||||
|
||||
|
||||
Procedure.w MsgPackReadInt16(*MsgPackData.MsgPackThingy)
|
||||
Procedure.w MsgPackReadInt16(*MsgPackData.MsgPackData)
|
||||
Protected ReturnedValue.w = $0000
|
||||
|
||||
If Not *MsgPackData
|
||||
DebuggerError("A #Null MsgPackThingy pointer was passed !")
|
||||
DebuggerError("A #Null MsgPackData pointer was passed !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
|
||||
If _IsAtTheEnd(*MsgPackData)
|
||||
If _MsgPackIsAtTheEnd(*MsgPackData)
|
||||
DebuggerError("End of buffer reached, cannot check data format code !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
@@ -453,7 +532,7 @@ Procedure.w MsgPackReadInt16(*MsgPackData.MsgPackThingy)
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
|
||||
If Not _HasSpaceLeft(*MsgPackData, 3)
|
||||
If Not _MsgPackHasSpaceLeft(*MsgPackData, 3)
|
||||
DebuggerError("End of buffer reached, cannot read out of bounds !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
@@ -465,18 +544,16 @@ Procedure.w MsgPackReadInt16(*MsgPackData.MsgPackThingy)
|
||||
EndProcedure
|
||||
|
||||
|
||||
|
||||
|
||||
;---> UInt32
|
||||
;-> > > UInt32
|
||||
|
||||
; No unsigned Long in PureBasic: value is peeked/poked as-is via .l and returned unchanged.
|
||||
Procedure.b MsgPackWriteUInt32(*MsgPackData.MsgPackThingy, Value.l)
|
||||
Procedure.b MsgPackWriteUInt32(*MsgPackData.MsgPackData, Value.l)
|
||||
If Not *MsgPackData
|
||||
DebuggerError("A #Null MsgPackThingy pointer was passed !")
|
||||
DebuggerError("A #Null MsgPackData pointer was passed !")
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
|
||||
If Not _HasSpaceLeft(*MsgPackData, 5)
|
||||
If Not _MsgPackHasSpaceLeft(*MsgPackData, 5)
|
||||
Debug("Growing buffer for UInt32...")
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
@@ -490,15 +567,15 @@ Procedure.b MsgPackWriteUInt32(*MsgPackData.MsgPackThingy, Value.l)
|
||||
EndProcedure
|
||||
|
||||
|
||||
Procedure.l MsgPackReadUInt32(*MsgPackData.MsgPackThingy)
|
||||
Procedure.l MsgPackReadUInt32(*MsgPackData.MsgPackData)
|
||||
Protected ReturnedValue.l = $00000000
|
||||
|
||||
If Not *MsgPackData
|
||||
DebuggerError("A #Null MsgPackThingy pointer was passed !")
|
||||
DebuggerError("A #Null MsgPackData pointer was passed !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
|
||||
If _IsAtTheEnd(*MsgPackData)
|
||||
If _MsgPackIsAtTheEnd(*MsgPackData)
|
||||
DebuggerError("End of buffer reached, cannot check data format code !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
@@ -510,7 +587,7 @@ Procedure.l MsgPackReadUInt32(*MsgPackData.MsgPackThingy)
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
|
||||
If Not _HasSpaceLeft(*MsgPackData, 5)
|
||||
If Not _MsgPackHasSpaceLeft(*MsgPackData, 5)
|
||||
DebuggerError("End of buffer reached, cannot read out of bounds !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
@@ -522,17 +599,15 @@ Procedure.l MsgPackReadUInt32(*MsgPackData.MsgPackThingy)
|
||||
EndProcedure
|
||||
|
||||
|
||||
;-> > > Int32
|
||||
|
||||
|
||||
;---> Int32
|
||||
|
||||
Procedure.b MsgPackWriteInt32(*MsgPackData.MsgPackThingy, Value.l)
|
||||
Procedure.b MsgPackWriteInt32(*MsgPackData.MsgPackData, Value.l)
|
||||
If Not *MsgPackData
|
||||
DebuggerError("A #Null MsgPackThingy pointer was passed !")
|
||||
DebuggerError("A #Null MsgPackData pointer was passed !")
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
|
||||
If Not _HasSpaceLeft(*MsgPackData, 5)
|
||||
If Not _MsgPackHasSpaceLeft(*MsgPackData, 5)
|
||||
Debug("Growing buffer for Int32...")
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
@@ -546,15 +621,15 @@ Procedure.b MsgPackWriteInt32(*MsgPackData.MsgPackThingy, Value.l)
|
||||
EndProcedure
|
||||
|
||||
|
||||
Procedure.l MsgPackReadInt32(*MsgPackData.MsgPackThingy)
|
||||
Procedure.l MsgPackReadInt32(*MsgPackData.MsgPackData)
|
||||
Protected ReturnedValue.l = $00000000
|
||||
|
||||
If Not *MsgPackData
|
||||
DebuggerError("A #Null MsgPackThingy pointer was passed !")
|
||||
DebuggerError("A #Null MsgPackData pointer was passed !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
|
||||
If _IsAtTheEnd(*MsgPackData)
|
||||
If _MsgPackIsAtTheEnd(*MsgPackData)
|
||||
DebuggerError("End of buffer reached, cannot check data format code !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
@@ -566,7 +641,7 @@ Procedure.l MsgPackReadInt32(*MsgPackData.MsgPackThingy)
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
|
||||
If Not _HasSpaceLeft(*MsgPackData, 5)
|
||||
If Not _MsgPackHasSpaceLeft(*MsgPackData, 5)
|
||||
DebuggerError("End of buffer reached, cannot read out of bounds !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
@@ -578,18 +653,16 @@ Procedure.l MsgPackReadInt32(*MsgPackData.MsgPackThingy)
|
||||
EndProcedure
|
||||
|
||||
|
||||
|
||||
|
||||
;---> UInt64
|
||||
;-> > > UInt64
|
||||
|
||||
; No unsigned Quad in PureBasic: value is peeked/poked as-is via .q and returned unchanged.
|
||||
Procedure.b MsgPackWriteUInt64(*MsgPackData.MsgPackThingy, Value.q)
|
||||
Procedure.b MsgPackWriteUInt64(*MsgPackData.MsgPackData, Value.q)
|
||||
If Not *MsgPackData
|
||||
DebuggerError("A #Null MsgPackThingy pointer was passed !")
|
||||
DebuggerError("A #Null MsgPackData pointer was passed !")
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
|
||||
If Not _HasSpaceLeft(*MsgPackData, 9)
|
||||
If Not _MsgPackHasSpaceLeft(*MsgPackData, 9)
|
||||
Debug("Growing buffer for UInt64...")
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
@@ -603,15 +676,15 @@ Procedure.b MsgPackWriteUInt64(*MsgPackData.MsgPackThingy, Value.q)
|
||||
EndProcedure
|
||||
|
||||
|
||||
Procedure.q MsgPackReadUInt64(*MsgPackData.MsgPackThingy)
|
||||
Procedure.q MsgPackReadUInt64(*MsgPackData.MsgPackData)
|
||||
Protected ReturnedValue.q = 0
|
||||
|
||||
If Not *MsgPackData
|
||||
DebuggerError("A #Null MsgPackThingy pointer was passed !")
|
||||
DebuggerError("A #Null MsgPackData pointer was passed !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
|
||||
If _IsAtTheEnd(*MsgPackData)
|
||||
If _MsgPackIsAtTheEnd(*MsgPackData)
|
||||
DebuggerError("End of buffer reached, cannot check data format code !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
@@ -623,7 +696,7 @@ Procedure.q MsgPackReadUInt64(*MsgPackData.MsgPackThingy)
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
|
||||
If Not _HasSpaceLeft(*MsgPackData, 9)
|
||||
If Not _MsgPackHasSpaceLeft(*MsgPackData, 9)
|
||||
DebuggerError("End of buffer reached, cannot read out of bounds !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
@@ -635,17 +708,15 @@ Procedure.q MsgPackReadUInt64(*MsgPackData.MsgPackThingy)
|
||||
EndProcedure
|
||||
|
||||
|
||||
;-> > > Int64
|
||||
|
||||
|
||||
;---> Int64
|
||||
|
||||
Procedure.b MsgPackWriteInt64(*MsgPackData.MsgPackThingy, Value.q)
|
||||
Procedure.b MsgPackWriteInt64(*MsgPackData.MsgPackData, Value.q)
|
||||
If Not *MsgPackData
|
||||
DebuggerError("A #Null MsgPackThingy pointer was passed !")
|
||||
DebuggerError("A #Null MsgPackData pointer was passed !")
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
|
||||
If Not _HasSpaceLeft(*MsgPackData, 9)
|
||||
If Not _MsgPackHasSpaceLeft(*MsgPackData, 9)
|
||||
Debug("Growing buffer for Int64...")
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
@@ -659,15 +730,15 @@ Procedure.b MsgPackWriteInt64(*MsgPackData.MsgPackThingy, Value.q)
|
||||
EndProcedure
|
||||
|
||||
|
||||
Procedure.q MsgPackReadInt64(*MsgPackData.MsgPackThingy)
|
||||
Procedure.q MsgPackReadInt64(*MsgPackData.MsgPackData)
|
||||
Protected ReturnedValue.q = 0
|
||||
|
||||
If Not *MsgPackData
|
||||
DebuggerError("A #Null MsgPackThingy pointer was passed !")
|
||||
DebuggerError("A #Null MsgPackData pointer was passed !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
|
||||
If _IsAtTheEnd(*MsgPackData)
|
||||
If _MsgPackIsAtTheEnd(*MsgPackData)
|
||||
DebuggerError("End of buffer reached, cannot check data format code !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
@@ -679,7 +750,7 @@ Procedure.q MsgPackReadInt64(*MsgPackData.MsgPackThingy)
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
|
||||
If Not _HasSpaceLeft(*MsgPackData, 9)
|
||||
If Not _MsgPackHasSpaceLeft(*MsgPackData, 9)
|
||||
DebuggerError("End of buffer reached, cannot read out of bounds !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
@@ -691,17 +762,15 @@ Procedure.q MsgPackReadInt64(*MsgPackData.MsgPackThingy)
|
||||
EndProcedure
|
||||
|
||||
|
||||
;-> > > Float32
|
||||
|
||||
|
||||
;---> Float32
|
||||
|
||||
Procedure.b MsgPackWriteFloat32(*MsgPackData.MsgPackThingy, Value.f)
|
||||
Procedure.b MsgPackWriteFloat32(*MsgPackData.MsgPackData, Value.f)
|
||||
If Not *MsgPackData
|
||||
DebuggerError("A #Null MsgPackThingy pointer was passed !")
|
||||
DebuggerError("A #Null MsgPackData pointer was passed !")
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
|
||||
If Not _HasSpaceLeft(*MsgPackData, 5)
|
||||
If Not _MsgPackHasSpaceLeft(*MsgPackData, 5)
|
||||
Debug("Growing buffer for Float32...")
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
@@ -715,15 +784,15 @@ Procedure.b MsgPackWriteFloat32(*MsgPackData.MsgPackThingy, Value.f)
|
||||
EndProcedure
|
||||
|
||||
|
||||
Procedure.f MsgPackReadFloat32(*MsgPackData.MsgPackThingy)
|
||||
Procedure.f MsgPackReadFloat32(*MsgPackData.MsgPackData)
|
||||
Protected ReturnedValue.f = 0.0
|
||||
|
||||
If Not *MsgPackData
|
||||
DebuggerError("A #Null MsgPackThingy pointer was passed !")
|
||||
DebuggerError("A #Null MsgPackData pointer was passed !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
|
||||
If _IsAtTheEnd(*MsgPackData)
|
||||
If _MsgPackIsAtTheEnd(*MsgPackData)
|
||||
DebuggerError("End of buffer reached, cannot check data format code !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
@@ -735,7 +804,7 @@ Procedure.f MsgPackReadFloat32(*MsgPackData.MsgPackThingy)
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
|
||||
If Not _HasSpaceLeft(*MsgPackData, 5)
|
||||
If Not _MsgPackHasSpaceLeft(*MsgPackData, 5)
|
||||
DebuggerError("End of buffer reached, cannot read out of bounds !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
@@ -747,17 +816,15 @@ Procedure.f MsgPackReadFloat32(*MsgPackData.MsgPackThingy)
|
||||
EndProcedure
|
||||
|
||||
|
||||
;-> > > Float64
|
||||
|
||||
|
||||
;---> Float64
|
||||
|
||||
Procedure.b MsgPackWriteFloat64(*MsgPackData.MsgPackThingy, Value.d)
|
||||
Procedure.b MsgPackWriteFloat64(*MsgPackData.MsgPackData, Value.d)
|
||||
If Not *MsgPackData
|
||||
DebuggerError("A #Null MsgPackThingy pointer was passed !")
|
||||
DebuggerError("A #Null MsgPackData pointer was passed !")
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
|
||||
If Not _HasSpaceLeft(*MsgPackData, 9)
|
||||
If Not _MsgPackHasSpaceLeft(*MsgPackData, 9)
|
||||
Debug("Growing buffer for Float64...")
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
@@ -771,15 +838,15 @@ Procedure.b MsgPackWriteFloat64(*MsgPackData.MsgPackThingy, Value.d)
|
||||
EndProcedure
|
||||
|
||||
|
||||
Procedure.d MsgPackReadFloat64(*MsgPackData.MsgPackThingy)
|
||||
Procedure.d MsgPackReadFloat64(*MsgPackData.MsgPackData)
|
||||
Protected ReturnedValue.d = 0.0
|
||||
|
||||
If Not *MsgPackData
|
||||
DebuggerError("A #Null MsgPackThingy pointer was passed !")
|
||||
DebuggerError("A #Null MsgPackData pointer was passed !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
|
||||
If _IsAtTheEnd(*MsgPackData)
|
||||
If _MsgPackIsAtTheEnd(*MsgPackData)
|
||||
DebuggerError("End of buffer reached, cannot check data format code !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
@@ -791,7 +858,7 @@ Procedure.d MsgPackReadFloat64(*MsgPackData.MsgPackThingy)
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
|
||||
If Not _HasSpaceLeft(*MsgPackData, 9)
|
||||
If Not _MsgPackHasSpaceLeft(*MsgPackData, 9)
|
||||
DebuggerError("End of buffer reached, cannot read out of bounds !")
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
@@ -845,3 +912,9 @@ Macro MsgPackReadF32 : MsgPackReadFloat32 : EndMacro
|
||||
;-> Float64
|
||||
Macro MsgPackWriteF64 : MsgPackWriteFloat64 : EndMacro
|
||||
Macro MsgPackReadF64 : MsgPackReadFloat64 : EndMacro
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------------
|
||||
;- DataSection
|
||||
|
||||
; ???
|
||||
|
||||
Reference in New Issue
Block a user