bson_ext 1.0.9 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +23 -0
- data/ext/cbson/cbson.c +31 -36
- data/ext/cbson/version.h +1 -1
- metadata +28 -35
- data/ext/lib/bson_ext.rb +0 -1
data/Rakefile
CHANGED
@@ -13,6 +13,29 @@ require 'rbconfig'
|
|
13
13
|
include Config
|
14
14
|
ENV['TEST_MODE'] = 'TRUE'
|
15
15
|
|
16
|
+
task :java do
|
17
|
+
Rake::Task['build:java'].invoke
|
18
|
+
Rake::Task['test:ruby'].invoke
|
19
|
+
end
|
20
|
+
|
21
|
+
namespace :build do
|
22
|
+
desc "Build the java extensions."
|
23
|
+
task :java do
|
24
|
+
puts "Building Java extensions..."
|
25
|
+
java_dir = File.join(File.dirname(__FILE__), 'ext', 'java')
|
26
|
+
jar_dir = File.join(java_dir, 'jar')
|
27
|
+
|
28
|
+
jruby_jar = File.join(jar_dir, 'jruby.jar')
|
29
|
+
mongo_jar = File.join(jar_dir, 'mongo.jar')
|
30
|
+
bson_jar = File.join(jar_dir, 'bson.jar')
|
31
|
+
|
32
|
+
src_base = File.join(java_dir, 'src')
|
33
|
+
|
34
|
+
system("javac -Xlint:unchecked -classpath #{jruby_jar}:#{mongo_jar}:#{bson_jar} #{File.join(src_base, 'org', 'jbson', '*.java')}")
|
35
|
+
system("cd #{src_base} && jar cf #{File.join(jar_dir, 'jbson.jar')} #{File.join('.', 'org', 'jbson', '*.class')}")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
16
39
|
desc "Test the MongoDB Ruby driver."
|
17
40
|
task :test do
|
18
41
|
puts "\nThis option has changed."
|
data/ext/cbson/cbson.c
CHANGED
@@ -75,7 +75,6 @@ static ID lt_operator;
|
|
75
75
|
static ID gt_operator;
|
76
76
|
|
77
77
|
static VALUE Binary;
|
78
|
-
static VALUE ObjectID;
|
79
78
|
static VALUE ObjectId;
|
80
79
|
static VALUE DBRef;
|
81
80
|
static VALUE Code;
|
@@ -324,37 +323,14 @@ static int write_element(VALUE key, VALUE value, VALUE extra, int allow_id) {
|
|
324
323
|
}
|
325
324
|
case T_STRING:
|
326
325
|
{
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
if (length_location == -1) {
|
336
|
-
rb_raise(rb_eNoMemError, "failed to allocate memory in buffer.c");
|
337
|
-
}
|
338
|
-
|
339
|
-
length = RSTRING_LEN(value) + 1;
|
340
|
-
SAFE_WRITE(buffer, (char*)&length, 4);
|
341
|
-
SAFE_WRITE(buffer, RSTRING_PTR(value), length - 1);
|
342
|
-
SAFE_WRITE(buffer, &zero, 1);
|
343
|
-
write_doc(buffer, rb_funcall(value, rb_intern("scope"), 0), Qfalse, Qfalse);
|
344
|
-
|
345
|
-
total_length = buffer_get_position(buffer) - start_position;
|
346
|
-
SAFE_WRITE_AT_POS(buffer, length_location, (const char*)&total_length, 4);
|
347
|
-
break;
|
348
|
-
} else {
|
349
|
-
int length;
|
350
|
-
write_name_and_type(buffer, key, 0x02);
|
351
|
-
value = TO_UTF8(value);
|
352
|
-
length = RSTRING_LEN(value) + 1;
|
353
|
-
SAFE_WRITE(buffer, (char*)&length, 4);
|
354
|
-
write_utf8(buffer, value, 0);
|
355
|
-
SAFE_WRITE(buffer, &zero, 1);
|
356
|
-
break;
|
357
|
-
}
|
326
|
+
int length;
|
327
|
+
write_name_and_type(buffer, key, 0x02);
|
328
|
+
value = TO_UTF8(value);
|
329
|
+
length = RSTRING_LEN(value) + 1;
|
330
|
+
SAFE_WRITE(buffer, (char*)&length, 4);
|
331
|
+
write_utf8(buffer, value, 0);
|
332
|
+
SAFE_WRITE(buffer, &zero, 1);
|
333
|
+
break;
|
358
334
|
}
|
359
335
|
case T_SYMBOL:
|
360
336
|
{
|
@@ -388,7 +364,7 @@ static int write_element(VALUE key, VALUE value, VALUE extra, int allow_id) {
|
|
388
364
|
SAFE_WRITE(buffer, RSTRING_PTR(string_data), length);
|
389
365
|
break;
|
390
366
|
}
|
391
|
-
if (
|
367
|
+
if (strcmp(cls, "BSON::ObjectId") == 0) {
|
392
368
|
VALUE as_array = rb_funcall(value, rb_intern("to_a"), 0);
|
393
369
|
int i;
|
394
370
|
write_name_and_type(buffer, key, 0x07);
|
@@ -422,6 +398,28 @@ static int write_element(VALUE key, VALUE value, VALUE extra, int allow_id) {
|
|
422
398
|
SAFE_WRITE_AT_POS(buffer, length_location, (const char*)&obj_length, 4);
|
423
399
|
break;
|
424
400
|
}
|
401
|
+
if (strcmp(cls, "BSON::Code") == 0) {
|
402
|
+
buffer_position length_location, start_position, total_length;
|
403
|
+
int length;
|
404
|
+
write_name_and_type(buffer, key, 0x0F);
|
405
|
+
|
406
|
+
start_position = buffer_get_position(buffer);
|
407
|
+
length_location = buffer_save_space(buffer, 4);
|
408
|
+
if (length_location == -1) {
|
409
|
+
rb_raise(rb_eNoMemError, "failed to allocate memory in buffer.c");
|
410
|
+
}
|
411
|
+
|
412
|
+
VALUE code_str = rb_funcall(value, rb_intern("code"), 0);
|
413
|
+
length = RSTRING_LEN(code_str) + 1;
|
414
|
+
SAFE_WRITE(buffer, (char*)&length, 4);
|
415
|
+
SAFE_WRITE(buffer, RSTRING_PTR(code_str), length - 1);
|
416
|
+
SAFE_WRITE(buffer, &zero, 1);
|
417
|
+
write_doc(buffer, rb_funcall(value, rb_intern("scope"), 0), Qfalse, Qfalse);
|
418
|
+
|
419
|
+
total_length = buffer_get_position(buffer) - start_position;
|
420
|
+
SAFE_WRITE_AT_POS(buffer, length_location, (const char*)&total_length, 4);
|
421
|
+
break;
|
422
|
+
}
|
425
423
|
if (strcmp(cls, "BSON::MaxKey") == 0) {
|
426
424
|
write_name_and_type(buffer, key, 0x7f);
|
427
425
|
break;
|
@@ -918,8 +916,6 @@ void Init_cbson() {
|
|
918
916
|
bson = rb_const_get(rb_cObject, rb_intern("BSON"));
|
919
917
|
rb_require("bson/types/binary");
|
920
918
|
Binary = rb_const_get(bson, rb_intern("Binary"));
|
921
|
-
rb_require("bson/types/objectid");
|
922
|
-
ObjectID = rb_const_get(bson, rb_intern("ObjectID"));
|
923
919
|
rb_require("bson/types/object_id");
|
924
920
|
ObjectId = rb_const_get(bson, rb_intern("ObjectId"));
|
925
921
|
rb_require("bson/types/dbref");
|
@@ -948,7 +944,6 @@ void Init_cbson() {
|
|
948
944
|
Digest = rb_const_get(rb_cObject, rb_intern("Digest"));
|
949
945
|
DigestMD5 = rb_const_get(Digest, rb_intern("MD5"));
|
950
946
|
|
951
|
-
rb_define_method(ObjectID, "generate", objectid_generate, 0);
|
952
947
|
rb_define_method(ObjectId, "generate", objectid_generate, 0);
|
953
948
|
|
954
949
|
if (gethostname(hostname, MAX_HOSTNAME_LENGTH) != 0) {
|
data/ext/cbson/version.h
CHANGED
metadata
CHANGED
@@ -1,21 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bson_ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 5
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
version: 1.0.9
|
6
|
+
- 1
|
7
|
+
- 1
|
8
|
+
version: "1.1"
|
11
9
|
platform: ruby
|
12
10
|
authors:
|
13
|
-
- Mike Dirolf
|
11
|
+
- Mike Dirolf
|
14
12
|
autorequire:
|
15
13
|
bindir: bin
|
16
14
|
cert_chain: []
|
17
15
|
|
18
|
-
date: 2010-
|
16
|
+
date: 2010-10-04 00:00:00 -04:00
|
19
17
|
default_executable:
|
20
18
|
dependencies: []
|
21
19
|
|
@@ -24,21 +22,20 @@ email: mongodb-dev@googlegroups.com
|
|
24
22
|
executables: []
|
25
23
|
|
26
24
|
extensions:
|
27
|
-
- ext/cbson/extconf.rb
|
25
|
+
- ext/cbson/extconf.rb
|
28
26
|
extra_rdoc_files: []
|
29
27
|
|
30
28
|
files:
|
31
|
-
- Rakefile
|
32
|
-
- bson_ext.gemspec
|
33
|
-
- ext/cbson/extconf.rb
|
34
|
-
- ext/
|
35
|
-
- ext/cbson/
|
36
|
-
- ext/cbson/
|
37
|
-
- ext/cbson/
|
38
|
-
- ext/cbson/
|
39
|
-
- ext/cbson/
|
40
|
-
|
41
|
-
has_rdoc: false
|
29
|
+
- Rakefile
|
30
|
+
- bson_ext.gemspec
|
31
|
+
- ext/cbson/extconf.rb
|
32
|
+
- ext/cbson/buffer.c
|
33
|
+
- ext/cbson/cbson.c
|
34
|
+
- ext/cbson/encoding_helpers.c
|
35
|
+
- ext/cbson/buffer.h
|
36
|
+
- ext/cbson/encoding_helpers.h
|
37
|
+
- ext/cbson/version.h
|
38
|
+
has_rdoc: true
|
42
39
|
homepage: http://www.mongodb.org
|
43
40
|
licenses: []
|
44
41
|
|
@@ -46,29 +43,25 @@ post_install_message:
|
|
46
43
|
rdoc_options: []
|
47
44
|
|
48
45
|
require_paths:
|
49
|
-
- ext
|
46
|
+
- ext
|
50
47
|
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
-
none: false
|
52
48
|
requirements:
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
version: "0"
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
segments:
|
52
|
+
- 0
|
53
|
+
version: "0"
|
59
54
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
-
none: false
|
61
55
|
requirements:
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
version: "0"
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
68
61
|
requirements: []
|
69
62
|
|
70
63
|
rubyforge_project:
|
71
|
-
rubygems_version: 1.3.
|
64
|
+
rubygems_version: 1.3.6
|
72
65
|
signing_key:
|
73
66
|
specification_version: 3
|
74
67
|
summary: C extensions for Ruby BSON.
|
data/ext/lib/bson_ext.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
puts "hello world"
|