bson_ext 1.6.2 → 1.6.4
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/Rakefile +17 -4
- data/bson_ext.gemspec +1 -1
- data/ext/cbson/bson_buffer.h +1 -0
- data/ext/cbson/cbson.c +23 -8
- data/ext/cbson/encoding_helpers.c +1 -1
- data/ext/cbson/encoding_helpers.h +1 -1
- data/ext/cbson/version.h +1 -1
- metadata +8 -5
data/Rakefile
CHANGED
@@ -7,19 +7,32 @@ end
|
|
7
7
|
require 'fileutils'
|
8
8
|
require 'rake/testtask'
|
9
9
|
require 'rake'
|
10
|
+
require 'rake/extensiontask'
|
11
|
+
require 'rake/javaextensiontask'
|
10
12
|
|
11
13
|
begin
|
12
14
|
require 'git'
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
begin
|
15
|
+
require 'devkit'
|
17
16
|
require 'ci/reporter/rake/test_unit'
|
18
17
|
rescue LoadError
|
19
18
|
end
|
20
19
|
|
21
20
|
ENV['TEST_MODE'] = 'TRUE'
|
22
21
|
|
22
|
+
Rake::ExtensionTask.new('cbson') do |ext|
|
23
|
+
ext.lib_dir = "lib/bson_ext"
|
24
|
+
end
|
25
|
+
|
26
|
+
#Rake::JavaExtensionTask.new('jbson') do |ext| # not yet functional
|
27
|
+
# ext.ext_dir = 'ext/src/org/jbson'
|
28
|
+
#end
|
29
|
+
|
30
|
+
desc "Compiles and tests MongoDB Ruby driver w/ C extensions."
|
31
|
+
task :c do
|
32
|
+
Rake::Task['compile:cbson'].invoke
|
33
|
+
Rake::Task['test:c'].invoke
|
34
|
+
end
|
35
|
+
|
23
36
|
task :java do
|
24
37
|
Rake::Task['build:java'].invoke
|
25
38
|
Rake::Task['test:ruby'].invoke
|
data/bson_ext.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.has_rdoc = false
|
20
20
|
s.extensions << 'ext/cbson/extconf.rb'
|
21
21
|
|
22
|
-
s.
|
22
|
+
s.authors = ['Mike Dirolf', 'Kyle Banker', 'Tyler Brock', 'Gary Murakami']
|
23
23
|
s.email = 'mongodb-dev@googlegroups.com'
|
24
24
|
s.homepage = 'http://www.mongodb.org'
|
25
25
|
s.add_dependency('bson', "~> #{BSON::VERSION}")
|
data/ext/cbson/bson_buffer.h
CHANGED
@@ -32,6 +32,7 @@ bson_buffer_t bson_buffer_new(void);
|
|
32
32
|
/* Set the max size for this buffer.
|
33
33
|
* Note: this is not a hard limit. */
|
34
34
|
void bson_buffer_set_max_size(bson_buffer_t buffer, int max_size);
|
35
|
+
int bson_buffer_get_max_size(bson_buffer_t buffer);
|
35
36
|
|
36
37
|
/* Free the memory allocated for `buffer`.
|
37
38
|
* Return non-zero on failure. */
|
data/ext/cbson/cbson.c
CHANGED
@@ -21,6 +21,7 @@
|
|
21
21
|
*/
|
22
22
|
|
23
23
|
#include "ruby.h"
|
24
|
+
#include "version.h"
|
24
25
|
|
25
26
|
/* Ensure compatibility with early releases of Ruby 1.8.5 */
|
26
27
|
#ifndef RSTRING_PTR
|
@@ -108,10 +109,8 @@ static int max_bson_size;
|
|
108
109
|
} \
|
109
110
|
_str; \
|
110
111
|
})
|
111
|
-
#define TO_UTF8(string) rb_str_export_to_enc((string), rb_utf8_encoding())
|
112
112
|
#else
|
113
113
|
#define STR_NEW(p,n) rb_str_new((p), (n))
|
114
|
-
#define TO_UTF8(string) (string)
|
115
114
|
#endif
|
116
115
|
|
117
116
|
static void write_utf8(bson_buffer_t buffer, VALUE string, char check_null) {
|
@@ -124,8 +123,7 @@ static void write_utf8(bson_buffer_t buffer, VALUE string, char check_null) {
|
|
124
123
|
bson_buffer_free(buffer);
|
125
124
|
rb_raise(InvalidStringEncoding, "String not valid UTF-8");
|
126
125
|
}
|
127
|
-
string
|
128
|
-
SAFE_WRITE(buffer, RSTRING_PTR(string), RSTRING_LEN(string));
|
126
|
+
SAFE_WRITE(buffer, RSTRING_PTR(string), (int)RSTRING_LEN(string));
|
129
127
|
}
|
130
128
|
|
131
129
|
// this sucks. but for some reason these moved around between 1.8 and 1.9
|
@@ -435,10 +433,14 @@ static int write_element(VALUE key, VALUE value, VALUE extra, int allow_id) {
|
|
435
433
|
break;
|
436
434
|
}
|
437
435
|
if (strcmp(cls, "BSON::Timestamp") == 0) {
|
436
|
+
unsigned int seconds;
|
437
|
+
unsigned int increment;
|
438
|
+
|
438
439
|
write_name_and_type(buffer, key, 0x11);
|
439
|
-
|
440
|
+
|
441
|
+
seconds = NUM2UINT(
|
440
442
|
rb_funcall(value, rb_intern("seconds"), 0));
|
441
|
-
|
443
|
+
increment = NUM2UINT(
|
442
444
|
rb_funcall(value, rb_intern("increment"), 0));
|
443
445
|
|
444
446
|
SAFE_WRITE(buffer, (const char*)&increment, 4);
|
@@ -742,10 +744,23 @@ static VALUE get_value(const char* buffer, int* position, int type) {
|
|
742
744
|
}
|
743
745
|
case 9:
|
744
746
|
{
|
745
|
-
|
747
|
+
int64_t millis;
|
746
748
|
memcpy(&millis, buffer + *position, 8);
|
747
749
|
|
748
|
-
|
750
|
+
// Support 64-bit time values in 32 bit environments in Ruby > 1.9
|
751
|
+
// Note: rb_time_num_new is not available pre Ruby 1.9
|
752
|
+
#if RUBY_API_VERSION_CODE >= 10900
|
753
|
+
#define add(x,y) (rb_funcall((x), '+', 1, (y)))
|
754
|
+
#define mul(x,y) (rb_funcall((x), '*', 1, (y)))
|
755
|
+
#define quo(x,y) (rb_funcall((x), rb_intern("quo"), 1, (y)))
|
756
|
+
VALUE d, timev;
|
757
|
+
d = LL2NUM(1000LL);
|
758
|
+
timev = add(LL2NUM(millis / 1000), quo(LL2NUM(millis % 1000), d));
|
759
|
+
value = rb_time_num_new(timev, Qnil);
|
760
|
+
#else
|
761
|
+
value = rb_time_new(millis / 1000, (millis % 1000) * 1000);
|
762
|
+
#endif
|
763
|
+
|
749
764
|
value = rb_funcall(value, utc_method, 0);
|
750
765
|
*position += 8;
|
751
766
|
break;
|
@@ -87,7 +87,7 @@ static unsigned char isLegalUTF8(const unsigned char* source, int length) {
|
|
87
87
|
return 1;
|
88
88
|
}
|
89
89
|
|
90
|
-
result_t check_string(const unsigned char* string, const
|
90
|
+
result_t check_string(const unsigned char* string, const long length,
|
91
91
|
const char check_utf8, const char check_null) {
|
92
92
|
int position = 0;
|
93
93
|
/* By default we go character by character. Will be different for checking
|
data/ext/cbson/version.h
CHANGED
metadata
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bson_ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Mike Dirolf
|
9
|
+
- Kyle Banker
|
10
|
+
- Tyler Brock
|
11
|
+
- Gary Murakami
|
9
12
|
autorequire:
|
10
13
|
bindir: bin
|
11
14
|
cert_chain: []
|
12
|
-
date: 2012-
|
15
|
+
date: 2012-06-06 00:00:00.000000000 Z
|
13
16
|
dependencies:
|
14
17
|
- !ruby/object:Gem::Dependency
|
15
18
|
name: bson
|
@@ -18,7 +21,7 @@ dependencies:
|
|
18
21
|
requirements:
|
19
22
|
- - ~>
|
20
23
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.6.
|
24
|
+
version: 1.6.4
|
22
25
|
type: :runtime
|
23
26
|
prerelease: false
|
24
27
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +29,7 @@ dependencies:
|
|
26
29
|
requirements:
|
27
30
|
- - ~>
|
28
31
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.6.
|
32
|
+
version: 1.6.4
|
30
33
|
description: C extensions to accelerate the Ruby BSON serialization. For more information
|
31
34
|
about BSON, see http://bsonspec.org. For information about MongoDB, see http://www.mongodb.org.
|
32
35
|
email: mongodb-dev@googlegroups.com
|
@@ -64,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
67
|
version: '0'
|
65
68
|
requirements: []
|
66
69
|
rubyforge_project:
|
67
|
-
rubygems_version: 1.8.
|
70
|
+
rubygems_version: 1.8.24
|
68
71
|
signing_key:
|
69
72
|
specification_version: 3
|
70
73
|
summary: C extensions for Ruby BSON.
|