Class: Proj::Api::PjParamDescription
- Inherits:
-
FFI::Struct
- Object
- FFI::Struct
- Proj::Api::PjParamDescription
- Defined in:
- lib/api/proj.rb,
lib/proj/pj_param_description.rb
Instance Attribute Summary collapse
-
#retained_ptrs ⇒ Object
Returns the value of attribute retained_ptrs.
Class Method Summary collapse
Instance Method Summary collapse
-
#put_string(field, value) ⇒ Object
Write a string into a :string field and retain the pointer to prevent GC.
Instance Attribute Details
#retained_ptrs ⇒ Object
Returns the value of attribute retained_ptrs.
4 5 6 |
# File 'lib/proj/pj_param_description.rb', line 4 def retained_ptrs @retained_ptrs end |
Class Method Details
.create(name:, auth_name: nil, code: nil, value:, unit_name: nil, unit_conv_factor:, unit_type:) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/proj/pj_param_description.rb', line 6 def self.create(name:, auth_name: nil, code: nil, value:, unit_name: nil, unit_conv_factor:, unit_type:) result = PjParamDescription.new result.retained_ptrs = [] result.put_string(:name, name) result.put_string(:auth_name, auth_name) result.put_string(:code, code) result[:value] = value result.put_string(:unit_name, unit_name) result[:unit_conv_factor] = unit_conv_factor result[:unit_type] = unit_type result end |
Instance Method Details
#put_string(field, value) ⇒ Object
Write a string into a :string field and retain the pointer to prevent GC.
20 21 22 23 24 25 |
# File 'lib/proj/pj_param_description.rb', line 20 def put_string(field, value) return if value.nil? ptr = FFI::MemoryPointer.from_string(value) @retained_ptrs << ptr pointer.put_pointer(offset_of(field), ptr) end |