Class: Hakuban::FFI::FFIObjectDescriptor

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/hakuban/ffi.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#tags_stringsObject

Returns the value of attribute tags_strings.



73
74
75
# File 'lib/hakuban/ffi.rb', line 73

def tags_strings
  @tags_strings
end

Class Method Details

.construct(tags, json) ⇒ Object



83
84
85
86
87
88
89
90
91
# File 'lib/hakuban/ffi.rb', line 83

def self.construct(tags,json)
	descriptor = FFIObjectDescriptor.new
	descriptor[:tags_count] = tags.size
	descriptor.tags_strings = tags.map { |tag| FFI::MemoryPointer.from_string(JSON.dump(tag)) }
	descriptor[:tags] = FFI::MemoryPointer.new(:pointer, descriptor.tags_strings.size)
	descriptor[:tags].write_array_of_pointer(descriptor.tags_strings)
	descriptor[:json] = FFI::MemoryPointer.from_string(JSON.dump(json))
	descriptor
end

Instance Method Details

#jsonObject



79
80
81
# File 'lib/hakuban/ffi.rb', line 79

def json
	JSON.parse(self[:json].read_string())
end

#tagsObject



75
76
77
# File 'lib/hakuban/ffi.rb', line 75

def tags
	self[:tags].read_array_of_pointer(self[:tags_count]).map { |string| JSON.parse(string.read_string()) }	# does this copy the string? 
end