Class: Fiddle::Pointer
- Inherits:
-
Object
- Object
- Fiddle::Pointer
- Defined in:
- lib/fiddle_fluidsynth/core_ext/fiddle.rb,
lib/fiddle_fluidsynth/core_ext/fiddle.rb,
lib/fiddle_fluidsynth/core_ext/fiddle.rb
Class Method Summary collapse
- .decode1_dbl(val) ⇒ Object
- .decode1_i(val) ⇒ Object
- .decode1_int(val) ⇒ Object
- .decode_char_ptr2(ptr2) ⇒ Object
- .malloc_char_ptr2(str_ary) ⇒ Object
- .malloc_dbl ⇒ Object
- .malloc_flt ⇒ Object
- .malloc_i ⇒ Object
- .malloc_int ⇒ Object
- .malloc_n(sz:) ⇒ Object
- .malloc_voidp ⇒ Object
- .set_char_ptr2(ptr2, str_ary) ⇒ Object
- .set_dbl(ptr, v) ⇒ Object
- .set_flt(ptr, v) ⇒ Object
- .set_int(ptr, v) ⇒ Object
- .set_voidp(ptr, v) ⇒ Object
- .unpack1(val:, fmt:) ⇒ Object
Instance Method Summary collapse
- #decode1_dbl ⇒ Object
- #decode1_int ⇒ Object (also: #decode1_i)
Class Method Details
.decode1_dbl(val) ⇒ Object
128 129 130 |
# File 'lib/fiddle_fluidsynth/core_ext/fiddle.rb', line 128 def self.decode1_dbl( val ) self.unpack1(val: val, fmt: 'E') end |
.decode1_i(val) ⇒ Object
121 |
# File 'lib/fiddle_fluidsynth/core_ext/fiddle.rb', line 121 def self.decode1_i(val); decode1_int(val); end |
.decode1_int(val) ⇒ Object
118 119 120 |
# File 'lib/fiddle_fluidsynth/core_ext/fiddle.rb', line 118 def self.decode1_int( val ) self.unpack1(val: val, fmt: 'i') end |
.decode_char_ptr2(ptr2) ⇒ Object
136 137 |
# File 'lib/fiddle_fluidsynth/core_ext/fiddle.rb', line 136 def self.decode_char_ptr2( ptr2 ) end |
.malloc_char_ptr2(str_ary) ⇒ Object
70 71 72 73 |
# File 'lib/fiddle_fluidsynth/core_ext/fiddle.rb', line 70 def self.malloc_char_ptr2( str_ary ) ary_size = str_ary.size self.malloc_n(sz: Fiddle.sizeof_voidp*ary_size) end |
.malloc_dbl ⇒ Object
55 56 57 |
# File 'lib/fiddle_fluidsynth/core_ext/fiddle.rb', line 55 def self.malloc_dbl self.malloc_n(sz: Fiddle.sizeof_dbl) end |
.malloc_flt ⇒ Object
60 61 62 |
# File 'lib/fiddle_fluidsynth/core_ext/fiddle.rb', line 60 def self.malloc_flt self.malloc_n(sz: Fiddle.sizeof_flt) end |
.malloc_i ⇒ Object
52 |
# File 'lib/fiddle_fluidsynth/core_ext/fiddle.rb', line 52 def self.malloc_i; self.malloc_int; end |
.malloc_int ⇒ Object
49 50 51 |
# File 'lib/fiddle_fluidsynth/core_ext/fiddle.rb', line 49 def self.malloc_int self.malloc_n(sz: Fiddle.sizeof_int) end |
.malloc_n(sz:) ⇒ Object
44 45 46 |
# File 'lib/fiddle_fluidsynth/core_ext/fiddle.rb', line 44 def self.malloc_n( sz: ) Fiddle::Pointer.malloc(sz) end |
.malloc_voidp ⇒ Object
65 66 67 |
# File 'lib/fiddle_fluidsynth/core_ext/fiddle.rb', line 65 def self.malloc_voidp self.malloc_n(sz: Fiddle.sizeof_voidp) end |
.set_char_ptr2(ptr2, str_ary) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/fiddle_fluidsynth/core_ext/fiddle.rb', line 96 def self.set_char_ptr2(ptr2, str_ary) atr_ary.each_with_index do |str, index| tmp_ptr = Fiddle::Pointer.malloc(str.bytesize + 1) tmp_ptr[0, str.bytesize+1] = "#{str}\0" ptr2[index*Fiddle.sizeof_voidp, Fiddle.sizeof_voidp] = [tmp_ptr.to_i].pack("Q") end ptr2 end |
.set_dbl(ptr, v) ⇒ Object
84 85 86 |
# File 'lib/fiddle_fluidsynth/core_ext/fiddle.rb', line 84 def self.set_dbl(ptr, v) ptr[0, Fiddle.sizeof_dbl] = [v].pack("E") end |
.set_flt(ptr, v) ⇒ Object
88 89 90 |
# File 'lib/fiddle_fluidsynth/core_ext/fiddle.rb', line 88 def self.set_flt(ptr, v) ptr[0, Fiddle.sizeof_flt] = [v].pack("f") end |
.set_int(ptr, v) ⇒ Object
80 81 82 |
# File 'lib/fiddle_fluidsynth/core_ext/fiddle.rb', line 80 def self.set_int(ptr, v) ptr[0, Fiddle.sizeof_int] = [v].pack("i") end |
.set_voidp(ptr, v) ⇒ Object
92 93 94 |
# File 'lib/fiddle_fluidsynth/core_ext/fiddle.rb', line 92 def self.set_voidp(ptr, v) ptr[0, Fiddle.sizeof_voidp] = [v].pack("J") end |
.unpack1(val:, fmt:) ⇒ Object
113 114 115 |
# File 'lib/fiddle_fluidsynth/core_ext/fiddle.rb', line 113 def self.unpack1( val: , fmt: ) val[0, val.size].unpack1(fmt) end |
Instance Method Details
#decode1_dbl ⇒ Object
131 132 133 |
# File 'lib/fiddle_fluidsynth/core_ext/fiddle.rb', line 131 def decode1_dbl self.class.decode1_dbl(self) end |
#decode1_int ⇒ Object Also known as: decode1_i
122 123 124 |
# File 'lib/fiddle_fluidsynth/core_ext/fiddle.rb', line 122 def decode1_int self.class.decode1_i(self) end |