Class: Clang::Rbind::String

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/rbind/clang/clang.rb,
lib/rbind/clang/clang_types.rb

Overview

A character string.

The c CXString type is used to return strings from the interface when the ownership of that string might different from one call to the next. Use c clang_getCString() to retrieve the string data and, once finished with the string data, call c clang_disposeString() to free the string.

Fields:

:data

(FFI::Pointer(*Void))

:private_flags

(Integer)

Constant Summary collapse

@@pointer =
Hash.new

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ String

Returns a new instance of String.



275
276
277
278
279
280
# File 'lib/rbind/clang/clang_types.rb', line 275

def initialize(*args)
    super
    # we cannot use auto pointer because string is returned as value
    ObjectSpace.define_finalizer(self, String.method(:finalize))
    @@pointer[self.object_id] = pointer
end

Class Method Details

.finalize(id) ⇒ Object



268
269
270
271
272
273
# File 'lib/rbind/clang/clang_types.rb', line 268

def self.finalize(id)
    Rbind::dispose_string(@@pointer[id])
    @@pointer.delete(id)
rescue => e
    puts e
end

Instance Method Details

#to_sObject



282
283
284
# File 'lib/rbind/clang/clang_types.rb', line 282

def to_s
    Rbind.get_c_string self
end