annoy-rb 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 70396ca8391b29a97b873c9e19a604cbc7257ce4b78cdf8381be4e892c518b62
4
- data.tar.gz: 56feaa427374443780b141a3edf3707cf350409a229367f052436f773b6d1c75
3
+ metadata.gz: f7232280d8b48fb91e8df376002737365c98025a749ac940c768c8678bbfeed7
4
+ data.tar.gz: 2f877a4dbdc4cde3ed5dea581aa1007ca1f7f084a1984b39715b3955311a7e71
5
5
  SHA512:
6
- metadata.gz: a3c736168dcea72535931d759c849ffc006bfcfecf3cdca704fc0b1859712a810817bfc7581f87dc40754bedea07563dd5ad777ca54b028acc4d5c3dcf3f6671
7
- data.tar.gz: 65ada80b03e1e1ffec4353f7db9c77c2aca8bc79523229b8b52865f38524a272bac10c650d0333b46fee2d13c8109a1fa61ee41d2eb022eaeefdee0509a3bf54
6
+ metadata.gz: 69215b205bb28a0e598232392db21dcafa292f6acda6c163570a5125ee10207d223f673852ffa7de4e92e7a301fc0efaf18399ba411f7f51453f6ef801af3121
7
+ data.tar.gz: 6854842c3f9b88252050980c7ed0341993ffae89457c045dcda8fb21cd462af103fd60522df4e69eaf032f73e618a99dcc079a2741a37c86ae4c9d7d2afec385
@@ -1,3 +1,6 @@
1
+ ## 0.2.2
2
+ - Replace Data_ functions to TypedData_ functions.
3
+
1
4
  ## 0.2.1
2
5
  - Fix to free char array of error message before calling rb_raise.
3
6
  - Fix to use array allocated with ruby_xmalloc instead of vector class in C++.
@@ -42,17 +42,21 @@ template<class T, typename F> class RbAnnoyIndex
42
42
  public:
43
43
  static VALUE annoy_index_alloc(VALUE self) {
44
44
  T* ptr = (T*)ruby_xmalloc(sizeof(T));
45
- return Data_Wrap_Struct(self, NULL, annoy_index_free, ptr);
45
+ return TypedData_Wrap_Struct(self, &annoy_index_type, ptr);
46
46
  };
47
47
 
48
- static void annoy_index_free(T* ptr) {
49
- ptr->~AnnoyIndex();
48
+ static void annoy_index_free(void* ptr) {
49
+ ((T*)ptr)->~AnnoyIndex();
50
50
  ruby_xfree(ptr);
51
51
  };
52
52
 
53
+ static size_t annoy_index_size(const void* ptr) {
54
+ return sizeof(*((T*)ptr));
55
+ };
56
+
53
57
  static T* get_annoy_index(VALUE self) {
54
58
  T* ptr;
55
- Data_Get_Struct(self, T, ptr);
59
+ TypedData_Get_Struct(self, T, &annoy_index_type, ptr);
56
60
  return ptr;
57
61
  };
58
62
 
@@ -79,6 +83,7 @@ template<class T, typename F> class RbAnnoyIndex
79
83
  };
80
84
 
81
85
  private:
86
+ static const rb_data_type_t annoy_index_type;
82
87
 
83
88
  static VALUE _annoy_index_init(VALUE self, VALUE _n_dims) {
84
89
  const int n_dims = NUM2INT(_n_dims);
@@ -308,4 +313,17 @@ template<class T, typename F> class RbAnnoyIndex
308
313
  };
309
314
  };
310
315
 
316
+ template<class T, typename F>
317
+ const rb_data_type_t RbAnnoyIndex<T, F>::annoy_index_type = {
318
+ "RbAnnoyIndex",
319
+ {
320
+ NULL,
321
+ RbAnnoyIndex::annoy_index_free,
322
+ RbAnnoyIndex::annoy_index_size
323
+ },
324
+ NULL,
325
+ NULL,
326
+ RUBY_TYPED_FREE_IMMEDIATELY
327
+ };
328
+
311
329
  #endif /* ANNOY_HPP */
@@ -3,5 +3,5 @@
3
3
  # Annoy.rb is a Ruby wrapper for Annoy (Approximate Nearest Neighbors Oh Yeah).
4
4
  module Annoy
5
5
  # The version of Annoy.rb you are using.
6
- VERSION = '0.2.1'.freeze
6
+ VERSION = '0.2.2'.freeze
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: annoy-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - yoshoku
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-24 00:00:00.000000000 Z
11
+ date: 2020-11-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Annoy.rb is a Ruby binding for the Annoy (Approximate Nearest Neighbors
14
14
  Oh Yeah).
@@ -45,7 +45,7 @@ metadata:
45
45
  source_code_uri: https://github.com/yoshoku/annoy.rb
46
46
  changelog_uri: https://github.com/yoshoku/annoy.rb/blob/master/CHANGELOG.md
47
47
  documentation_uri: https://yoshoku.github.io/annoy.rb/doc/
48
- post_install_message:
48
+ post_install_message:
49
49
  rdoc_options: []
50
50
  require_paths:
51
51
  - lib
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  version: '0'
62
62
  requirements: []
63
63
  rubygems_version: 3.1.4
64
- signing_key:
64
+ signing_key:
65
65
  specification_version: 4
66
66
  summary: Ruby binding for the Annoy (Approximate Nearest Neighbors Oh Yeah).
67
67
  test_files: []