1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
module Puppet::Pops
module Serialization
module Extension
# 0x00 - 0x0F are reserved for low-level serialization / tabulation extensions
# Tabulation internal to the low level protocol reader/writer
INNER_TABULATION = 0x00
# Tabulation managed by the serializer / deserializer
TABULATION = 0x01
# 0x10 - 0x1F are reserved for structural extensions
ARRAY_START = 0x10
MAP_START = 0x11
PCORE_OBJECT_START = 0x12
OBJECT_START = 0x13
SENSITIVE_START = 0x14
# 0x20 - 0x2f reserved for special extension objects
DEFAULT = 0x20
COMMENT = 0x21
# 0x30 - 0x7f reserved for mapping of specific runtime classes
REGEXP = 0x30
TYPE_REFERENCE = 0x31
SYMBOL = 0x32
TIME = 0x33
TIMESPAN = 0x34
VERSION = 0x35
VERSION_RANGE = 0x36
BINARY = 0x37
BASE64 = 0x38
URI = 0x39
# Marker module indicating whether or not an instance is tabulated or not
module NotTabulated; end
# Marker module for objects that starts a sequence, i.e. ArrayStart, MapStart, and PcoreObjectStart
module SequenceStart; end
# The class that triggers the use of the DEFAULT extension. It doesn't have any payload
class Default
include NotTabulated
INSTANCE = Default.new
end
# The class that triggers the use of the TABULATION extension. The payload is the tabulation index
class Tabulation
include NotTabulated
attr_reader :index
def initialize(index)
@index = index
end
end
# Tabulation internal to the protocol reader/writer
class InnerTabulation < Tabulation
end
# The class that triggers the use of the MAP_START extension. The payload is the map size (number of entries)
class MapStart
include NotTabulated
include SequenceStart
attr_reader :size
def initialize(size)
@size = size
end
# Sequence size is twice the map size since each entry is written as key and value
def sequence_size
@size * 2
end
end
# The class that triggers the use of the ARRAY_START extension. The payload is the array size
class ArrayStart
include NotTabulated
include SequenceStart
attr_reader :size
def initialize(size)
@size = size
end
def sequence_size
@size
end
end
# The class that triggers the use of the SENSITIVE_START extension. It has no payload
class SensitiveStart
include NotTabulated
INSTANCE = SensitiveStart.new
end
# The class that triggers the use of the PCORE_OBJECT_START extension. The payload is the name of the object type
# and the number of attributes in the instance.
class PcoreObjectStart
include SequenceStart
attr_reader :type_name, :attribute_count
def initialize(type_name, attribute_count)
@type_name = type_name
@attribute_count = attribute_count
end
def hash
@type_name.hash * 29 + attribute_count.hash
end
def eql?(o)
o.is_a?(PcoreObjectStart) && o.type_name == @type_name && o.attribute_count == @attribute_count
end
alias == eql?
def sequence_size
@attribute_count
end
end
class ObjectStart
include SequenceStart
attr_reader :attribute_count
def initialize(attribute_count)
@attribute_count = attribute_count
end
def hash
attribute_count.hash
end
def eql?(o)
o.is_a?(ObjectStart) && o.attribute_count == @attribute_count
end
alias == eql?
def sequence_size
@attribute_count
end
end
# The class that triggers the use of the COMMENT extension. The payload is comment text
class Comment
attr_reader :comment
def initialize(comment)
@comment = comment
end
def hash
@comment.hash
end
def eql?(o)
o.is_a?(Comment) && o.comment == @comment
end
alias == eql?
end
end
end
end
|