Class: Hakuban::ObjectDescriptor

Inherits:
FFIObject show all
Defined in:
lib/hakuban/descriptor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from FFIObject

#do_and_drop, #do_and_drop_or_return, #drop, #drop_lock, #drop_release, #dropped?, generate_finalizer, #with_pointer, with_pointers

Constructor Details

#initialize(tags, json) ⇒ ObjectDescriptor

Returns a new instance of ObjectDescriptor.



12
13
14
15
16
17
18
19
20
21
# File 'lib/hakuban/descriptor.rb', line 12

def initialize(tags, json)
	Hakuban::hakuban_initialize
	@json = json.freeze
	@tags = Set.new(tags.map { |tag| tag.kind_of?(TagDescriptor) ? tag : TagDescriptor.new(tag) })
	FFIObject.with_pointers(@tags) { |tag_pointers|
		tag_pointers_array = ::FFI::MemoryPointer.new(:pointer, tag_pointers.size)
		tag_pointers_array.write_array_of_pointer(tag_pointers)
		initialize_pointer(FFI::hakuban_object_descriptor_new(JSON.dump(@json),tag_pointers.size,tag_pointers_array).unwrap,:hakuban_object_descriptor_drop,:hakuban_object_descriptor_clone)
	}
end

Instance Attribute Details

#jsonObject (readonly)

Returns the value of attribute json.



10
11
12
# File 'lib/hakuban/descriptor.rb', line 10

def json
  @json
end

#tagsObject (readonly)

Returns the value of attribute tags.



10
11
12
# File 'lib/hakuban/descriptor.rb', line 10

def tags
  @tags
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



42
43
44
# File 'lib/hakuban/descriptor.rb', line 42

def ==(other)
	@tags == other.tags and @json == other.json
end

#hashObject



48
49
50
# File 'lib/hakuban/descriptor.rb', line 48

def hash
	[@tags.hash, @json.hash].hash
end

#initialize_copy(original) ⇒ Object



24
25
26
27
# File 'lib/hakuban/descriptor.rb', line 24

def initialize_copy(original)
	super
	@tags = original.tags.map(&:clone)
end

#inspectObject



52
53
54
# File 'lib/hakuban/descriptor.rb', line 52

def inspect
	"#<ObjectDescriptor @tags={%s}, @json=%p>"%[self.tags.map(&:inspect).join(","), self.json]
end