class Hakuban::FFI::FFIObjectDescriptor

Attributes

tags_strings[RW]

Public Class Methods

construct(tags,json) click to toggle source
# File lib/hakuban/ffi.rb, line 76
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

Public Instance Methods

json() click to toggle source
# File lib/hakuban/ffi.rb, line 72
def json
        JSON.parse(self[:json].read_string())
end
tags() click to toggle source
# File lib/hakuban/ffi.rb, line 68
def tags
        self[:tags].read_array_of_pointer(self[:tags_count]).map { |string| JSON.parse(string.read_string()) }       # does this copy the string?
end