mongodb-mongo_ext 0.13 → 0.14.1

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.
data/ext/cbson/cbson.c CHANGED
@@ -50,6 +50,13 @@ static VALUE RegexpOfHolding;
50
50
  static VALUE OrderedHash;
51
51
  static VALUE InvalidName;
52
52
 
53
+ #if HAVE_RUBY_ENCODING_H
54
+ #include "ruby/encoding.h"
55
+ #define STR_NEW(p,n) rb_enc_str_new((p), (n), rb_utf8_encoding())
56
+ #else
57
+ #define STR_NEW(p,n) rb_str_new((p), (n))
58
+ #endif
59
+
53
60
  // this sucks. but for some reason these moved around between 1.8 and 1.9
54
61
  #ifdef ONIGURUMA_H
55
62
  #define IGNORECASE ONIG_OPTION_IGNORECASE
@@ -154,7 +161,7 @@ static void buffer_write_bytes(bson_buffer* buffer, const char* bytes, int size)
154
161
  }
155
162
 
156
163
  static VALUE pack_extra(bson_buffer* buffer, VALUE check_keys) {
157
- return rb_ary_new3(2, INT2NUM((int)buffer), check_keys);
164
+ return rb_ary_new3(2, LL2NUM((long long)buffer), check_keys);
158
165
  }
159
166
 
160
167
  static void write_name_and_type(bson_buffer* buffer, VALUE name, char type) {
@@ -164,7 +171,7 @@ static void write_name_and_type(bson_buffer* buffer, VALUE name, char type) {
164
171
  }
165
172
 
166
173
  static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow_id) {
167
- bson_buffer* buffer = (bson_buffer*)NUM2INT(rb_ary_entry(extra, 0));
174
+ bson_buffer* buffer = (bson_buffer*)NUM2LL(rb_ary_entry(extra, 0));
168
175
  VALUE check_keys = rb_ary_entry(extra, 1);
169
176
 
170
177
  if (TYPE(key) == T_SYMBOL) {
@@ -495,7 +502,7 @@ static VALUE get_value(const char* buffer, int* position, int type) {
495
502
  int value_length;
496
503
  *position += 4;
497
504
  value_length = strlen(buffer + *position);
498
- value = rb_str_new(buffer+ *position, value_length);
505
+ value = STR_NEW(buffer + *position, value_length);
499
506
  *position += value_length + 1;
500
507
  break;
501
508
  }
@@ -509,7 +516,7 @@ static VALUE get_value(const char* buffer, int* position, int type) {
509
516
  int collection_length = strlen(buffer + offset);
510
517
  char id_type;
511
518
 
512
- argv[0] = rb_str_new(buffer + offset, collection_length);
519
+ argv[0] = STR_NEW(buffer + offset, collection_length);
513
520
  offset += collection_length + 1;
514
521
  id_type = buffer[offset];
515
522
  offset += 5;
@@ -599,7 +606,7 @@ static VALUE get_value(const char* buffer, int* position, int type) {
599
606
  case 11:
600
607
  {
601
608
  int pattern_length = strlen(buffer + *position);
602
- VALUE pattern = rb_str_new(buffer + *position, pattern_length);
609
+ VALUE pattern = STR_NEW(buffer + *position, pattern_length);
603
610
  int flags_length, flags = 0, i = 0;
604
611
  char extra[10];
605
612
  VALUE argv[3];
@@ -635,7 +642,7 @@ static VALUE get_value(const char* buffer, int* position, int type) {
635
642
  VALUE collection, str, oid, id, argv[2];
636
643
  *position += 4;
637
644
  collection_length = strlen(buffer + *position);
638
- collection = rb_str_new(buffer + *position, collection_length);
645
+ collection = STR_NEW(buffer + *position, collection_length);
639
646
  *position += collection_length + 1;
640
647
 
641
648
  str = rb_str_new(buffer + *position, 12);
@@ -662,7 +669,7 @@ static VALUE get_value(const char* buffer, int* position, int type) {
662
669
  VALUE code, scope, argv[2];
663
670
  *position += 8;
664
671
  code_length = strlen(buffer + *position);
665
- code = rb_str_new(buffer + *position, code_length);
672
+ code = STR_NEW(buffer + *position, code_length);
666
673
  *position += code_length + 1;
667
674
 
668
675
  memcpy(&scope_size, buffer + *position, 4);
@@ -715,7 +722,7 @@ static VALUE elements_to_hash(const char* buffer, int max) {
715
722
  while (position < max) {
716
723
  int type = (int)buffer[position++];
717
724
  int name_length = strlen(buffer + position);
718
- VALUE name = rb_str_new(buffer + position, name_length);
725
+ VALUE name = STR_NEW(buffer + position, name_length);
719
726
  VALUE value;
720
727
  position += name_length + 1;
721
728
  value = get_value(buffer, &position, type);
data/ext/cbson/extconf.rb CHANGED
@@ -2,6 +2,7 @@ require 'mkmf'
2
2
 
3
3
  have_header("ruby/st.h") || have_header("st.h")
4
4
  have_header("ruby/regex.h") || have_header("regex.h")
5
+ have_header("ruby/encoding.h")
5
6
 
6
7
  dir_config('cbson')
7
8
  create_makefile('mongo_ext/cbson')
@@ -8,13 +8,12 @@ TEST_FILES = []
8
8
  Gem::Specification.new do |s|
9
9
  s.name = 'mongo_ext'
10
10
 
11
- s.version = '0.13'
11
+ s.version = '0.14.1'
12
12
  s.platform = Gem::Platform::RUBY
13
13
  s.summary = 'C extensions for the MongoDB Ruby driver'
14
14
  s.description = 'C extensions to accelerate the MondoDB Ruby driver. For more information about Mongo, see http://www.mongodb.org.'
15
15
 
16
16
  s.require_paths = ['ext']
17
-
18
17
  s.files = PACKAGE_FILES
19
18
  s.test_files = TEST_FILES
20
19
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongodb-mongo_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.13"
4
+ version: 0.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Dirolf