kompiler 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,20 @@
1
1
  class PackedBytes
2
- def initialize bytes = ""
2
+ # endianess can be :le or :be
3
+ def initialize bytes = "", endianess: :le
3
4
  @bytes = bytes.dup
5
+ self.endianess = endianess
6
+ end
7
+
8
+ def endianess= new_endianess
9
+ case new_endianess
10
+ when :le
11
+ @pack_endianess_string = "<"
12
+ when :be
13
+ @pack_endianess_string = ">"
14
+ else
15
+ raise "Unknown endianess configuration \"#{new_endianess}\". Must be :le or :be"
16
+ end
17
+ @endianess = new_endianess
4
18
  end
5
19
 
6
20
  def uint8 n
@@ -10,17 +24,17 @@ class PackedBytes
10
24
 
11
25
  def uint16 n
12
26
  n = [n] if n.is_a? Numeric
13
- @bytes << n.pack("S<*")
27
+ @bytes << n.pack("S#{@pack_endianess_string}*")
14
28
  end
15
29
 
16
30
  def uint32 n
17
31
  n = [n] if n.is_a? Numeric
18
- @bytes << n.pack("L<*")
32
+ @bytes << n.pack("L#{@pack_endianess_string}*")
19
33
  end
20
34
 
21
35
  def uint64 n
22
36
  n = [n] if n.is_a? Numeric
23
- @bytes << n.pack("Q<*")
37
+ @bytes << n.pack("Q#{@pack_endianess_string}*")
24
38
  end
25
39
 
26
40
  def bytes bytes, n_bytes=nil
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kompiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyryl Shyshko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-04-06 00:00:00.000000000 Z
11
+ date: 2025-04-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'Kompiler is a low-level, modular and extendable compiler for any architecture.
14
14
  By default Kompiler supports ARMv8-a, but other architecture extensions can be downloaded