python-pickle 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (235) hide show
  1. checksums.yaml +7 -0
  2. data/.document +3 -0
  3. data/.github/workflows/ruby.yml +27 -0
  4. data/.gitignore +5 -0
  5. data/.rspec +1 -0
  6. data/.yardopts +1 -0
  7. data/ChangeLog.md +14 -0
  8. data/Gemfile +15 -0
  9. data/LICENSE.txt +20 -0
  10. data/README.md +149 -0
  11. data/Rakefile +13 -0
  12. data/gemspec.yml +25 -0
  13. data/lib/python/pickle/byte_array.rb +40 -0
  14. data/lib/python/pickle/deserializer.rb +595 -0
  15. data/lib/python/pickle/exceptions.rb +12 -0
  16. data/lib/python/pickle/instruction.rb +52 -0
  17. data/lib/python/pickle/instructions/add_items.rb +26 -0
  18. data/lib/python/pickle/instructions/append.rb +24 -0
  19. data/lib/python/pickle/instructions/appends.rb +26 -0
  20. data/lib/python/pickle/instructions/bin_bytes.rb +32 -0
  21. data/lib/python/pickle/instructions/bin_bytes8.rb +32 -0
  22. data/lib/python/pickle/instructions/bin_float.rb +29 -0
  23. data/lib/python/pickle/instructions/bin_get.rb +27 -0
  24. data/lib/python/pickle/instructions/bin_int1.rb +29 -0
  25. data/lib/python/pickle/instructions/bin_put.rb +29 -0
  26. data/lib/python/pickle/instructions/bin_string.rb +32 -0
  27. data/lib/python/pickle/instructions/bin_unicode.rb +32 -0
  28. data/lib/python/pickle/instructions/bin_unicode8.rb +32 -0
  29. data/lib/python/pickle/instructions/build.rb +24 -0
  30. data/lib/python/pickle/instructions/byte_array8.rb +32 -0
  31. data/lib/python/pickle/instructions/dict.rb +17 -0
  32. data/lib/python/pickle/instructions/dup.rb +24 -0
  33. data/lib/python/pickle/instructions/empty_dict.rb +26 -0
  34. data/lib/python/pickle/instructions/empty_list.rb +26 -0
  35. data/lib/python/pickle/instructions/empty_set.rb +26 -0
  36. data/lib/python/pickle/instructions/empty_tuple.rb +26 -0
  37. data/lib/python/pickle/instructions/ext1.rb +29 -0
  38. data/lib/python/pickle/instructions/ext2.rb +29 -0
  39. data/lib/python/pickle/instructions/ext4.rb +29 -0
  40. data/lib/python/pickle/instructions/float.rb +24 -0
  41. data/lib/python/pickle/instructions/frame.rb +29 -0
  42. data/lib/python/pickle/instructions/frozen_set.rb +26 -0
  43. data/lib/python/pickle/instructions/get.rb +27 -0
  44. data/lib/python/pickle/instructions/global.rb +62 -0
  45. data/lib/python/pickle/instructions/has_length_and_value.rb +58 -0
  46. data/lib/python/pickle/instructions/has_value.rb +50 -0
  47. data/lib/python/pickle/instructions/int.rb +24 -0
  48. data/lib/python/pickle/instructions/list.rb +24 -0
  49. data/lib/python/pickle/instructions/long.rb +24 -0
  50. data/lib/python/pickle/instructions/long1.rb +32 -0
  51. data/lib/python/pickle/instructions/long4.rb +32 -0
  52. data/lib/python/pickle/instructions/long_bin_get.rb +27 -0
  53. data/lib/python/pickle/instructions/mark.rb +24 -0
  54. data/lib/python/pickle/instructions/memoize.rb +26 -0
  55. data/lib/python/pickle/instructions/new_false.rb +24 -0
  56. data/lib/python/pickle/instructions/new_obj.rb +26 -0
  57. data/lib/python/pickle/instructions/new_obj_ex.rb +26 -0
  58. data/lib/python/pickle/instructions/new_true.rb +24 -0
  59. data/lib/python/pickle/instructions/next_buffer.rb +26 -0
  60. data/lib/python/pickle/instructions/none.rb +24 -0
  61. data/lib/python/pickle/instructions/pop.rb +24 -0
  62. data/lib/python/pickle/instructions/pop_mark.rb +24 -0
  63. data/lib/python/pickle/instructions/proto.rb +29 -0
  64. data/lib/python/pickle/instructions/put.rb +24 -0
  65. data/lib/python/pickle/instructions/readonly_buffer.rb +26 -0
  66. data/lib/python/pickle/instructions/reduce.rb +24 -0
  67. data/lib/python/pickle/instructions/set_item.rb +24 -0
  68. data/lib/python/pickle/instructions/set_items.rb +26 -0
  69. data/lib/python/pickle/instructions/short_bin_bytes.rb +32 -0
  70. data/lib/python/pickle/instructions/short_bin_string.rb +32 -0
  71. data/lib/python/pickle/instructions/short_bin_unicode.rb +32 -0
  72. data/lib/python/pickle/instructions/stack_global.rb +26 -0
  73. data/lib/python/pickle/instructions/stop.rb +24 -0
  74. data/lib/python/pickle/instructions/string.rb +24 -0
  75. data/lib/python/pickle/instructions/tuple.rb +24 -0
  76. data/lib/python/pickle/instructions/tuple1.rb +24 -0
  77. data/lib/python/pickle/instructions/tuple2.rb +24 -0
  78. data/lib/python/pickle/instructions/tuple3.rb +24 -0
  79. data/lib/python/pickle/protocol.rb +56 -0
  80. data/lib/python/pickle/protocol0.rb +399 -0
  81. data/lib/python/pickle/protocol1.rb +183 -0
  82. data/lib/python/pickle/protocol2.rb +229 -0
  83. data/lib/python/pickle/protocol3.rb +163 -0
  84. data/lib/python/pickle/protocol4.rb +285 -0
  85. data/lib/python/pickle/protocol5.rb +218 -0
  86. data/lib/python/pickle/py_class.rb +75 -0
  87. data/lib/python/pickle/py_object.rb +141 -0
  88. data/lib/python/pickle/tuple.rb +19 -0
  89. data/lib/python/pickle/version.rb +6 -0
  90. data/lib/python/pickle.rb +226 -0
  91. data/python-pickle.gemspec +62 -0
  92. data/spec/byte_array_spec.rb +54 -0
  93. data/spec/deserializer_spec.rb +1201 -0
  94. data/spec/fixtures/ascii_str_v3.pkl +0 -0
  95. data/spec/fixtures/ascii_str_v4.pkl +0 -0
  96. data/spec/fixtures/ascii_str_v5.pkl +0 -0
  97. data/spec/fixtures/bin_str_v0.pkl +3 -0
  98. data/spec/fixtures/bin_str_v1.pkl +0 -0
  99. data/spec/fixtures/bin_str_v2.pkl +0 -0
  100. data/spec/fixtures/bin_str_v3.pkl +0 -0
  101. data/spec/fixtures/bin_str_v4.pkl +0 -0
  102. data/spec/fixtures/bin_str_v5.pkl +0 -0
  103. data/spec/fixtures/bytearray_v0.pkl +10 -0
  104. data/spec/fixtures/bytearray_v1.pkl +0 -0
  105. data/spec/fixtures/bytearray_v2.pkl +0 -0
  106. data/spec/fixtures/bytearray_v3.pkl +0 -0
  107. data/spec/fixtures/bytearray_v4.pkl +0 -0
  108. data/spec/fixtures/bytearray_v5.pkl +0 -0
  109. data/spec/fixtures/class_v0.pkl +4 -0
  110. data/spec/fixtures/class_v1.pkl +0 -0
  111. data/spec/fixtures/class_v2.pkl +0 -0
  112. data/spec/fixtures/class_v3.pkl +0 -0
  113. data/spec/fixtures/class_v4.pkl +0 -0
  114. data/spec/fixtures/class_v5.pkl +0 -0
  115. data/spec/fixtures/dict_v0.pkl +6 -0
  116. data/spec/fixtures/dict_v1.pkl +0 -0
  117. data/spec/fixtures/dict_v2.pkl +0 -0
  118. data/spec/fixtures/dict_v3.pkl +0 -0
  119. data/spec/fixtures/dict_v4.pkl +0 -0
  120. data/spec/fixtures/dict_v5.pkl +0 -0
  121. data/spec/fixtures/escaped_str_v0.pkl +3 -0
  122. data/spec/fixtures/escaped_str_v1.pkl +0 -0
  123. data/spec/fixtures/escaped_str_v2.pkl +0 -0
  124. data/spec/fixtures/false_v0.pkl +2 -0
  125. data/spec/fixtures/false_v1.pkl +2 -0
  126. data/spec/fixtures/false_v2.pkl +1 -0
  127. data/spec/fixtures/false_v3.pkl +1 -0
  128. data/spec/fixtures/false_v4.pkl +1 -0
  129. data/spec/fixtures/false_v5.pkl +1 -0
  130. data/spec/fixtures/float_v0.pkl +2 -0
  131. data/spec/fixtures/float_v1.pkl +1 -0
  132. data/spec/fixtures/float_v2.pkl +1 -0
  133. data/spec/fixtures/float_v3.pkl +1 -0
  134. data/spec/fixtures/float_v4.pkl +0 -0
  135. data/spec/fixtures/float_v5.pkl +0 -0
  136. data/spec/fixtures/function_v0.pkl +4 -0
  137. data/spec/fixtures/function_v1.pkl +0 -0
  138. data/spec/fixtures/function_v2.pkl +0 -0
  139. data/spec/fixtures/function_v3.pkl +0 -0
  140. data/spec/fixtures/function_v4.pkl +0 -0
  141. data/spec/fixtures/function_v5.pkl +0 -0
  142. data/spec/fixtures/hex_str_v0.pkl +3 -0
  143. data/spec/fixtures/hex_str_v1.pkl +0 -0
  144. data/spec/fixtures/hex_str_v2.pkl +0 -0
  145. data/spec/fixtures/int_v0.pkl +2 -0
  146. data/spec/fixtures/int_v1.pkl +1 -0
  147. data/spec/fixtures/int_v2.pkl +1 -0
  148. data/spec/fixtures/int_v3.pkl +1 -0
  149. data/spec/fixtures/int_v4.pkl +1 -0
  150. data/spec/fixtures/int_v5.pkl +1 -0
  151. data/spec/fixtures/list_v0.pkl +7 -0
  152. data/spec/fixtures/list_v1.pkl +0 -0
  153. data/spec/fixtures/list_v2.pkl +0 -0
  154. data/spec/fixtures/list_v3.pkl +0 -0
  155. data/spec/fixtures/list_v4.pkl +0 -0
  156. data/spec/fixtures/list_v5.pkl +0 -0
  157. data/spec/fixtures/long_v0.pkl +2 -0
  158. data/spec/fixtures/long_v1.pkl +2 -0
  159. data/spec/fixtures/long_v2.pkl +0 -0
  160. data/spec/fixtures/long_v3.pkl +0 -0
  161. data/spec/fixtures/long_v4.pkl +0 -0
  162. data/spec/fixtures/long_v5.pkl +0 -0
  163. data/spec/fixtures/nested_dict_v0.pkl +12 -0
  164. data/spec/fixtures/nested_dict_v1.pkl +0 -0
  165. data/spec/fixtures/nested_dict_v2.pkl +0 -0
  166. data/spec/fixtures/nested_dict_v3.pkl +0 -0
  167. data/spec/fixtures/nested_dict_v4.pkl +0 -0
  168. data/spec/fixtures/nested_dict_v5.pkl +0 -0
  169. data/spec/fixtures/nested_list_v0.pkl +9 -0
  170. data/spec/fixtures/nested_list_v1.pkl +0 -0
  171. data/spec/fixtures/nested_list_v2.pkl +0 -0
  172. data/spec/fixtures/nested_list_v3.pkl +0 -0
  173. data/spec/fixtures/nested_list_v4.pkl +0 -0
  174. data/spec/fixtures/nested_list_v5.pkl +0 -0
  175. data/spec/fixtures/none_v0.pkl +1 -0
  176. data/spec/fixtures/none_v1.pkl +1 -0
  177. data/spec/fixtures/none_v2.pkl +1 -0
  178. data/spec/fixtures/none_v3.pkl +1 -0
  179. data/spec/fixtures/none_v4.pkl +1 -0
  180. data/spec/fixtures/none_v5.pkl +1 -0
  181. data/spec/fixtures/object_v0.pkl +19 -0
  182. data/spec/fixtures/object_v1.pkl +0 -0
  183. data/spec/fixtures/object_v2.pkl +0 -0
  184. data/spec/fixtures/object_v3.pkl +0 -0
  185. data/spec/fixtures/object_v4.pkl +0 -0
  186. data/spec/fixtures/object_v5.pkl +0 -0
  187. data/spec/fixtures/str_v0.pkl +3 -0
  188. data/spec/fixtures/str_v1.pkl +0 -0
  189. data/spec/fixtures/str_v2.pkl +0 -0
  190. data/spec/fixtures/str_v3.pkl +0 -0
  191. data/spec/fixtures/str_v4.pkl +0 -0
  192. data/spec/fixtures/str_v5.pkl +0 -0
  193. data/spec/fixtures/true_v0.pkl +2 -0
  194. data/spec/fixtures/true_v1.pkl +2 -0
  195. data/spec/fixtures/true_v2.pkl +1 -0
  196. data/spec/fixtures/true_v3.pkl +1 -0
  197. data/spec/fixtures/true_v4.pkl +1 -0
  198. data/spec/fixtures/true_v5.pkl +1 -0
  199. data/spec/fixtures/unicode_str_v0.pkl +3 -0
  200. data/spec/fixtures/unicode_str_v1.pkl +0 -0
  201. data/spec/fixtures/unicode_str_v2.pkl +0 -0
  202. data/spec/fixtures/unicode_str_v3.pkl +0 -0
  203. data/spec/fixtures/unicode_str_v4.pkl +0 -0
  204. data/spec/fixtures/unicode_str_v5.pkl +0 -0
  205. data/spec/generate_pickles2.py +41 -0
  206. data/spec/generate_pickles3.py +40 -0
  207. data/spec/integration/load/protocol0_spec.rb +258 -0
  208. data/spec/integration/load/protocol1_spec.rb +258 -0
  209. data/spec/integration/load/protocol2_spec.rb +258 -0
  210. data/spec/integration/load/protocol3_spec.rb +258 -0
  211. data/spec/integration/load/protocol4_spec.rb +258 -0
  212. data/spec/integration/load/protocol5_spec.rb +258 -0
  213. data/spec/integration/parse/protocol0_spec.rb +467 -0
  214. data/spec/integration/parse/protocol1_spec.rb +459 -0
  215. data/spec/integration/parse/protocol2_spec.rb +471 -0
  216. data/spec/integration/parse/protocol3_spec.rb +407 -0
  217. data/spec/integration/parse/protocol4_spec.rb +439 -0
  218. data/spec/integration/parse/protocol5_spec.rb +419 -0
  219. data/spec/pickle_spec.rb +163 -0
  220. data/spec/protocol0_read_instruction_examples.rb +211 -0
  221. data/spec/protocol0_spec.rb +445 -0
  222. data/spec/protocol1_read_instruction_examples.rb +156 -0
  223. data/spec/protocol1_spec.rb +59 -0
  224. data/spec/protocol2_read_instruction_examples.rb +135 -0
  225. data/spec/protocol2_spec.rb +128 -0
  226. data/spec/protocol3_read_instruction_examples.rb +29 -0
  227. data/spec/protocol3_spec.rb +32 -0
  228. data/spec/protocol4_read_instruction_examples.rb +142 -0
  229. data/spec/protocol4_spec.rb +58 -0
  230. data/spec/protocol5_spec.rb +68 -0
  231. data/spec/py_class_spec.rb +62 -0
  232. data/spec/py_object_spec.rb +149 -0
  233. data/spec/spec_helper.rb +3 -0
  234. data/spec/tuple_spec.rb +18 -0
  235. metadata +325 -0
@@ -0,0 +1,27 @@
1
+ require 'python/pickle/instruction'
2
+ require 'python/pickle/instructions/has_value'
3
+
4
+ module Python
5
+ module Pickle
6
+ module Instructions
7
+ #
8
+ # Represents the `GET` instruction.
9
+ #
10
+ class Get < Instruction
11
+
12
+ include HasValue
13
+
14
+ #
15
+ # Initializes the `GET` instruction.
16
+ #
17
+ # @param [Integer] value
18
+ # The `GET` instruction's value.
19
+ #
20
+ def initialize(value)
21
+ super(:GET,value)
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,62 @@
1
+ require 'python/pickle/instruction'
2
+ require 'python/pickle/instructions/has_value'
3
+
4
+ module Python
5
+ module Pickle
6
+ module Instructions
7
+ class Global < Instruction
8
+
9
+ # The global object namespace.
10
+ #
11
+ # @return [String]
12
+ attr_reader :namespace
13
+
14
+ # The global object name.
15
+ #
16
+ # @return [String]
17
+ attr_reader :name
18
+
19
+ #
20
+ # Initializes the `GLOBAL` instruction.
21
+ #
22
+ # @param [String] namespace
23
+ # The namespace name for the global object.
24
+ #
25
+ # @param [String] name
26
+ # The name of the global object.
27
+ #
28
+ def initialize(namespace,name)
29
+ super(:GLOBAL)
30
+
31
+ @namespace = namespace
32
+ @name = name
33
+ end
34
+
35
+ #
36
+ # Compares the `GLOBAL` instruction to another instruction.
37
+ #
38
+ # @param [Instruction] other
39
+ # The other instruction to compare against.
40
+ #
41
+ # @return [Boolean]
42
+ # Indicates whether the other instruction matches this one.
43
+ #
44
+ def ==(other)
45
+ super(other) && \
46
+ (@namespace == other.namespace) && \
47
+ (@name == other.name)
48
+ end
49
+
50
+ #
51
+ # Converts the `GLOBAL` instructions to a String.
52
+ #
53
+ # @return [String]
54
+ #
55
+ def to_s
56
+ "#{super} #{@namespace}.#{@name}"
57
+ end
58
+
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,58 @@
1
+ module Python
2
+ module Pickle
3
+ module Instructions
4
+ #
5
+ # A mixin which adds a length and a value to an instruction class.
6
+ #
7
+ module HasLengthAndValue
8
+ # The length of the value associated with the instruction.
9
+ #
10
+ # @return [Integer]
11
+ attr_reader :length
12
+
13
+ # The value associated with the instruction.
14
+ #
15
+ # @return [Object]
16
+ attr_reader :value
17
+
18
+ #
19
+ # Initializes the instruction.
20
+ #
21
+ # @param [Symbol] opcode
22
+ #
23
+ # @param [Object] value
24
+ #
25
+ def initialize(opcode,length,value)
26
+ super(opcode)
27
+
28
+ @value = value
29
+ @length = length
30
+ end
31
+
32
+ #
33
+ # Compares the instruction to another instruction.
34
+ #
35
+ # @param [Instruction] other
36
+ # The other instruction to compare against.
37
+ #
38
+ # @return [Boolean]
39
+ # Indicates whether the other instruction matches this one.
40
+ #
41
+ def ==(other)
42
+ super(other) &&
43
+ other.kind_of?(HasLengthAndValue) &&
44
+ (@length == other.length && @value == other.value)
45
+ end
46
+
47
+ #
48
+ # Converts the instruction to a String.
49
+ #
50
+ # @return [String]
51
+ #
52
+ def to_s
53
+ "#{super} #{@length.inspect} #{@value.inspect}"
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,50 @@
1
+ module Python
2
+ module Pickle
3
+ module Instructions
4
+ #
5
+ # A mixin which adds a value to an instruction class.
6
+ #
7
+ module HasValue
8
+ # The value associated with the instruction.
9
+ #
10
+ # @return [Object]
11
+ attr_reader :value
12
+
13
+ #
14
+ # Initializes the instruction.
15
+ #
16
+ # @param [Symbol] opcode
17
+ #
18
+ # @param [Object] value
19
+ #
20
+ def initialize(opcode,value)
21
+ super(opcode)
22
+
23
+ @value = value
24
+ end
25
+
26
+ #
27
+ # Compares the instruction to another instruction.
28
+ #
29
+ # @param [Instruction] other
30
+ # The other instruction to compare against.
31
+ #
32
+ # @return [Boolean]
33
+ # Indicates whether the other instruction matches this one.
34
+ #
35
+ def ==(other)
36
+ super(other) && other.kind_of?(HasValue) && (@value == other.value)
37
+ end
38
+
39
+ #
40
+ # Converts the instruction to a String.
41
+ #
42
+ # @return [String]
43
+ #
44
+ def to_s
45
+ "#{super} #{@value.inspect}"
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,24 @@
1
+ require 'python/pickle/instruction'
2
+ require 'python/pickle/instructions/has_value'
3
+
4
+ module Python
5
+ module Pickle
6
+ module Instructions
7
+ class Int < Instruction
8
+
9
+ include HasValue
10
+
11
+ #
12
+ # Initializes the `INT` instruction.
13
+ #
14
+ # @param [Integer] value
15
+ # The `INT` instruction's value.
16
+ #
17
+ def initialize(value)
18
+ super(:INT,value)
19
+ end
20
+
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ require 'python/pickle/instruction'
2
+
3
+ module Python
4
+ module Pickle
5
+ module Instructions
6
+ #
7
+ # Represents a pickle `LIST` instruction.
8
+ #
9
+ class List < Instruction
10
+
11
+ #
12
+ # Initializes the `LIST` instruction.
13
+ #
14
+ def initialize
15
+ super(:LIST)
16
+ end
17
+
18
+ end
19
+
20
+ # The `LIST` instruction.
21
+ LIST = List.new
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ require 'python/pickle/instruction'
2
+ require 'python/pickle/instructions/has_value'
3
+
4
+ module Python
5
+ module Pickle
6
+ module Instructions
7
+ class Long < Instruction
8
+
9
+ include HasValue
10
+
11
+ #
12
+ # Initializes the `LONG` instruction.
13
+ #
14
+ # @param [Integer] value
15
+ # The `LONG` instruction's value.
16
+ #
17
+ def initialize(value)
18
+ super(:LONG,value)
19
+ end
20
+
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,32 @@
1
+ require 'python/pickle/instruction'
2
+ require 'python/pickle/instructions/has_length_and_value'
3
+
4
+ module Python
5
+ module Pickle
6
+ module Instructions
7
+ #
8
+ # Represents the `LONG1` instruction.
9
+ #
10
+ # @note introduces in protocol 1.
11
+ #
12
+ class Long1 < Instruction
13
+
14
+ include HasLengthAndValue
15
+
16
+ #
17
+ # Initializes the `LONG1` instruction.
18
+ #
19
+ # @param [Integer] length
20
+ # The length of the `LONG1` value in bytes.
21
+ #
22
+ # @param [Long1] value
23
+ # The `LONG1` instruction's value.
24
+ #
25
+ def initialize(length,value)
26
+ super(:LONG1,length,value)
27
+ end
28
+
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ require 'python/pickle/instruction'
2
+ require 'python/pickle/instructions/has_length_and_value'
3
+
4
+ module Python
5
+ module Pickle
6
+ module Instructions
7
+ #
8
+ # Represents the `LONG4` instruction.
9
+ #
10
+ # @note introduces in protocol 1.
11
+ #
12
+ class Long4 < Instruction
13
+
14
+ include HasLengthAndValue
15
+
16
+ #
17
+ # Initializes the `LONG4` instruction.
18
+ #
19
+ # @param [Integer] length
20
+ # The length of the `LONG4` value in bytes.
21
+ #
22
+ # @param [Long4] value
23
+ # The `LONG4` instruction's value.
24
+ #
25
+ def initialize(length,value)
26
+ super(:LONG4,length,value)
27
+ end
28
+
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,27 @@
1
+ require 'python/pickle/instruction'
2
+ require 'python/pickle/instructions/has_value'
3
+
4
+ module Python
5
+ module Pickle
6
+ module Instructions
7
+ #
8
+ # Represents the `LONG_BINGET` instruction.
9
+ #
10
+ class LongBinGet < Instruction
11
+
12
+ include HasValue
13
+
14
+ #
15
+ # Initializes the `LONG_BINGET` instruction.
16
+ #
17
+ # @param [Integer] value
18
+ # The `LONG_BINGET` instruction's value.
19
+ #
20
+ def initialize(value)
21
+ super(:LONG_BINGET,value)
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,24 @@
1
+ require 'python/pickle/instruction'
2
+
3
+ module Python
4
+ module Pickle
5
+ module Instructions
6
+ #
7
+ # Represents a pickle `MARK` instruction.
8
+ #
9
+ class Mark < Instruction
10
+
11
+ #
12
+ # Initializes the `MARK` instruction.
13
+ #
14
+ def initialize
15
+ super(:MARK)
16
+ end
17
+
18
+ end
19
+
20
+ # The `MARK` instruction.
21
+ MARK = Mark.new
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,26 @@
1
+ require 'python/pickle/instruction'
2
+
3
+ module Python
4
+ module Pickle
5
+ module Instructions
6
+ #
7
+ # Represents a pickle `MEMOIZE` instruction.
8
+ #
9
+ # @note introduced in protocol 4.
10
+ #
11
+ class Memoize < Instruction
12
+
13
+ #
14
+ # Initializes the `MEMOIZE` instruction.
15
+ #
16
+ def initialize
17
+ super(:MEMOIZE)
18
+ end
19
+
20
+ end
21
+
22
+ # The `MEMOIZE` instruction.
23
+ MEMOIZE = Memoize.new
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,24 @@
1
+ require 'python/pickle/instruction'
2
+
3
+ module Python
4
+ module Pickle
5
+ module Instructions
6
+ #
7
+ # Represents a pickle `NEWFALSE` instruction.
8
+ #
9
+ class NewFalse < Instruction
10
+
11
+ #
12
+ # Initializes the `NEWFALSE` instruction.
13
+ #
14
+ def initialize
15
+ super(:NEWFALSE)
16
+ end
17
+
18
+ end
19
+
20
+ # The `NEWFALSE` instruction.
21
+ NEWFALSE = NewFalse.new
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,26 @@
1
+ require 'python/pickle/instruction'
2
+
3
+ module Python
4
+ module Pickle
5
+ module Instructions
6
+ #
7
+ # Represents a pickle `NEWOBJ` instruction.
8
+ #
9
+ # @note introduced in protocol 2.
10
+ #
11
+ class NewObj < Instruction
12
+
13
+ #
14
+ # Initializes the `NEWOBJ` instruction.
15
+ #
16
+ def initialize
17
+ super(:NEWOBJ)
18
+ end
19
+
20
+ end
21
+
22
+ # The `NEWOBJ` instruction.
23
+ NEWOBJ = NewObj.new
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ require 'python/pickle/instruction'
2
+
3
+ module Python
4
+ module Pickle
5
+ module Instructions
6
+ #
7
+ # Represents a pickle `NEWOBJ_EX` instruction.
8
+ #
9
+ # @note introduced in protocol 3.
10
+ #
11
+ class NewObjEx < Instruction
12
+
13
+ #
14
+ # Initializes the `NEWOBJ_EX` instruction.
15
+ #
16
+ def initialize
17
+ super(:NEWOBJ_EX)
18
+ end
19
+
20
+ end
21
+
22
+ # The `NEWOBJ_EX` instruction.
23
+ NEWOBJ_EX = NewObjEx.new
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,24 @@
1
+ require 'python/pickle/instruction'
2
+
3
+ module Python
4
+ module Pickle
5
+ module Instructions
6
+ #
7
+ # Represents a pickle `NEWTRUE` instruction.
8
+ #
9
+ class NewTrue < Instruction
10
+
11
+ #
12
+ # Initializes the `NEWTRUE` instruction.
13
+ #
14
+ def initialize
15
+ super(:NEWTRUE)
16
+ end
17
+
18
+ end
19
+
20
+ # The `NEWTRUE` instruction.
21
+ NEWTRUE = NewTrue.new
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,26 @@
1
+ require 'python/pickle/instruction'
2
+
3
+ module Python
4
+ module Pickle
5
+ module Instructions
6
+ #
7
+ # Represents a pickle `NEXT_BUFFER` instruction.
8
+ #
9
+ # @note introduced in protocol 4.
10
+ #
11
+ class NextBuffer < Instruction
12
+
13
+ #
14
+ # Initializes the `NEXT_BUFFER` instruction.
15
+ #
16
+ def initialize
17
+ super(:NEXT_BUFFER)
18
+ end
19
+
20
+ end
21
+
22
+ # The `NEXT_BUFFER` instruction.
23
+ NEXT_BUFFER = NextBuffer.new
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,24 @@
1
+ require 'python/pickle/instruction'
2
+
3
+ module Python
4
+ module Pickle
5
+ module Instructions
6
+ #
7
+ # Represents a pickle `NONE` instruction.
8
+ #
9
+ class None < Instruction
10
+
11
+ #
12
+ # Initializes the `NONE` instruction.
13
+ #
14
+ def initialize
15
+ super(:NONE)
16
+ end
17
+
18
+ end
19
+
20
+ # The `NONE` instruction.
21
+ NONE = None.new
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ require 'python/pickle/instruction'
2
+
3
+ module Python
4
+ module Pickle
5
+ module Instructions
6
+ #
7
+ # Represents a pickle `POP` instruction.
8
+ #
9
+ class Pop < Instruction
10
+
11
+ #
12
+ # Initializes the `POP` instruction.
13
+ #
14
+ def initialize
15
+ super(:POP)
16
+ end
17
+
18
+ end
19
+
20
+ # The `POP` instruction.
21
+ POP = Pop.new
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ require 'python/pickle/instruction'
2
+
3
+ module Python
4
+ module Pickle
5
+ module Instructions
6
+ #
7
+ # Represents a pickle `POP_MARK` instruction.
8
+ #
9
+ class PopMark < Instruction
10
+
11
+ #
12
+ # Initializes the `POP_MARK` instruction.
13
+ #
14
+ def initialize
15
+ super(:POP_MARK)
16
+ end
17
+
18
+ end
19
+
20
+ # The `POP_MARK` instruction.
21
+ POP_MARK = PopMark.new
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,29 @@
1
+ require 'python/pickle/instruction'
2
+ require 'python/pickle/instructions/has_value'
3
+
4
+ module Python
5
+ module Pickle
6
+ module Instructions
7
+ #
8
+ # Represents the `PROTO` instruction.
9
+ #
10
+ # @note introduces in protocol 2.
11
+ #
12
+ class Proto < Instruction
13
+
14
+ include HasValue
15
+
16
+ #
17
+ # Initializes the `PROTO` instruction.
18
+ #
19
+ # @param [Proto] value
20
+ # The `PROTO` instruction's value.
21
+ #
22
+ def initialize(value)
23
+ super(:PROTO,value)
24
+ end
25
+
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,24 @@
1
+ require 'python/pickle/instruction'
2
+ require 'python/pickle/instructions/has_value'
3
+
4
+ module Python
5
+ module Pickle
6
+ module Instructions
7
+ class Put < Instruction
8
+
9
+ include HasValue
10
+
11
+ #
12
+ # Initializes the `PUT` instruction.
13
+ #
14
+ # @param [Integer] value
15
+ # The `PUT` instruction's value.
16
+ #
17
+ def initialize(value)
18
+ super(:PUT,value)
19
+ end
20
+
21
+ end
22
+ end
23
+ end
24
+ end