mongodb-mongo_ext 0.3 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/cbson/cbson.c +113 -74
- data/mongo-extensions.gemspec +1 -1
- metadata +3 -2
data/ext/cbson/cbson.c
CHANGED
@@ -48,6 +48,19 @@ static VALUE OrderedHash;
|
|
48
48
|
#define EXTENDED RE_OPTION_EXTENDED
|
49
49
|
#endif
|
50
50
|
|
51
|
+
/* TODO we ought to check that the malloc or asprintf was successful
|
52
|
+
* and raise an exception if not. */
|
53
|
+
#ifdef _MSC_VER
|
54
|
+
#define INT2STRING(buffer, i) \
|
55
|
+
{ \
|
56
|
+
int vslength = _scprintf("%d", i) + 1; \
|
57
|
+
*buffer = malloc(vslength); \
|
58
|
+
_snprintf(*buffer, vslength, "%d", i); \
|
59
|
+
}
|
60
|
+
#else
|
61
|
+
#define INT2STRING(buffer, i) asprintf(buffer, "%d", i);
|
62
|
+
#endif
|
63
|
+
|
51
64
|
// this sucks too.
|
52
65
|
#ifndef RREGEXP_SRC_PTR
|
53
66
|
#define RREGEXP_SRC_PTR(r) RREGEXP(r)->str
|
@@ -114,8 +127,8 @@ static void buffer_assure_space(bson_buffer* buffer, int size) {
|
|
114
127
|
|
115
128
|
/* returns offset for writing */
|
116
129
|
static int buffer_save_bytes(bson_buffer* buffer, int size) {
|
117
|
-
buffer_assure_space(buffer, size);
|
118
130
|
int position = buffer->position;
|
131
|
+
buffer_assure_space(buffer, size);
|
119
132
|
buffer->position += size;
|
120
133
|
return position;
|
121
134
|
}
|
@@ -155,10 +168,10 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow
|
|
155
168
|
}
|
156
169
|
|
157
170
|
if (check_keys == Qtrue) {
|
171
|
+
int i;
|
158
172
|
if (RSTRING_LEN(key) > 0 && RSTRING_PTR(key)[0] == '$') {
|
159
173
|
rb_raise(rb_eRuntimeError, "key must not start with '$'");
|
160
174
|
}
|
161
|
-
int i;
|
162
175
|
for (i = 0; i < RSTRING_LEN(key); i++) {
|
163
176
|
if (RSTRING_PTR(key)[i] == '.') {
|
164
177
|
rb_raise(rb_eRuntimeError, "key must not contain '.'");
|
@@ -169,20 +182,23 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow
|
|
169
182
|
switch(TYPE(value)) {
|
170
183
|
case T_BIGNUM:
|
171
184
|
{
|
185
|
+
VALUE as_f;
|
186
|
+
int int_value;
|
172
187
|
if (rb_funcall(value, rb_intern(">"), 1, INT2NUM(2147483647)) == Qtrue ||
|
173
188
|
rb_funcall(value, rb_intern("<"), 1, INT2NUM(-2147483648)) == Qtrue) {
|
174
|
-
rb_raise(rb_eRangeError, "MongoDB can only handle 4-byte ints
|
189
|
+
rb_raise(rb_eRangeError, "MongoDB can only handle 4-byte ints"
|
190
|
+
" - try converting to a double before saving");
|
175
191
|
}
|
176
192
|
write_name_and_type(buffer, key, 0x10);
|
177
|
-
|
178
|
-
|
193
|
+
as_f = rb_funcall(value, rb_intern("to_f"), 0);
|
194
|
+
int_value = NUM2LL(as_f);
|
179
195
|
buffer_write_bytes(buffer, (char*)&int_value, 4);
|
180
196
|
break;
|
181
197
|
}
|
182
198
|
case T_FIXNUM:
|
183
199
|
{
|
184
|
-
write_name_and_type(buffer, key, 0x10);
|
185
200
|
int int_value = FIX2INT(value);
|
201
|
+
write_name_and_type(buffer, key, 0x10);
|
186
202
|
buffer_write_bytes(buffer, (char*)&int_value, 4);
|
187
203
|
break;
|
188
204
|
}
|
@@ -200,8 +216,8 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow
|
|
200
216
|
}
|
201
217
|
case T_FLOAT:
|
202
218
|
{
|
203
|
-
write_name_and_type(buffer, key, 0x01);
|
204
219
|
double d = NUM2DBL(value);
|
220
|
+
write_name_and_type(buffer, key, 0x01);
|
205
221
|
buffer_write_bytes(buffer, (char*)&d, 8);
|
206
222
|
break;
|
207
223
|
}
|
@@ -218,26 +234,29 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow
|
|
218
234
|
}
|
219
235
|
case T_ARRAY:
|
220
236
|
{
|
237
|
+
int start_position, length_location, items, i, obj_length;
|
238
|
+
VALUE* values;
|
239
|
+
|
221
240
|
write_name_and_type(buffer, key, 0x04);
|
222
|
-
|
241
|
+
start_position = buffer->position;
|
223
242
|
|
224
243
|
// save space for length
|
225
|
-
|
244
|
+
length_location = buffer_save_bytes(buffer, 4);
|
226
245
|
|
227
|
-
|
228
|
-
|
229
|
-
int i;
|
246
|
+
items = RARRAY_LEN(value);
|
247
|
+
values = RARRAY_PTR(value);
|
230
248
|
for(i = 0; i < items; i++) {
|
231
249
|
char* name;
|
232
|
-
|
233
|
-
|
250
|
+
VALUE key;
|
251
|
+
INT2STRING(&name, i);
|
252
|
+
key = rb_str_new2(name);
|
234
253
|
write_element(key, values[i], pack_extra(buffer, check_keys));
|
235
254
|
free(name);
|
236
255
|
}
|
237
256
|
|
238
257
|
// write null byte and fill in length
|
239
258
|
buffer_write_bytes(buffer, &zero, 1);
|
240
|
-
|
259
|
+
obj_length = buffer->position - start_position;
|
241
260
|
memcpy(buffer->buffer + length_location, &obj_length, 4);
|
242
261
|
break;
|
243
262
|
}
|
@@ -245,24 +264,25 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow
|
|
245
264
|
{
|
246
265
|
if (strcmp(rb_class2name(RBASIC(value)->klass),
|
247
266
|
"XGen::Mongo::Driver::Code") == 0) {
|
267
|
+
int start_position, length_location, length, total_length;
|
248
268
|
write_name_and_type(buffer, key, 0x0F);
|
249
269
|
|
250
|
-
|
251
|
-
|
270
|
+
start_position = buffer->position;
|
271
|
+
length_location = buffer_save_bytes(buffer, 4);
|
252
272
|
|
253
|
-
|
273
|
+
length = RSTRING_LEN(value) + 1;
|
254
274
|
buffer_write_bytes(buffer, (char*)&length, 4);
|
255
275
|
buffer_write_bytes(buffer, RSTRING_PTR(value), length - 1);
|
256
276
|
buffer_write_bytes(buffer, &zero, 1);
|
257
277
|
write_doc(buffer, rb_funcall(value, rb_intern("scope"), 0), Qfalse);
|
258
278
|
|
259
|
-
|
279
|
+
total_length = buffer->position - start_position;
|
260
280
|
memcpy(buffer->buffer + length_location, &total_length, 4);
|
261
281
|
|
262
282
|
break;
|
263
283
|
} else {
|
264
|
-
write_name_and_type(buffer, key, 0x02);
|
265
284
|
int length = RSTRING_LEN(value) + 1;
|
285
|
+
write_name_and_type(buffer, key, 0x02);
|
266
286
|
buffer_write_bytes(buffer, (char*)&length, 4);
|
267
287
|
buffer_write_bytes(buffer, RSTRING_PTR(value), length - 1);
|
268
288
|
buffer_write_bytes(buffer, &zero, 1);
|
@@ -271,9 +291,9 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow
|
|
271
291
|
}
|
272
292
|
case T_SYMBOL:
|
273
293
|
{
|
274
|
-
write_name_and_type(buffer, key, 0x0E);
|
275
294
|
const char* str_value = rb_id2name(SYM2ID(value));
|
276
295
|
int length = strlen(str_value) + 1;
|
296
|
+
write_name_and_type(buffer, key, 0x0E);
|
277
297
|
buffer_write_bytes(buffer, (char*)&length, 4);
|
278
298
|
buffer_write_bytes(buffer, str_value, length);
|
279
299
|
break;
|
@@ -284,11 +304,11 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow
|
|
284
304
|
const char* cls = rb_class2name(RBASIC(value)->klass);
|
285
305
|
if (strcmp(cls, "XGen::Mongo::Driver::Binary") == 0 ||
|
286
306
|
strcmp(cls, "ByteBuffer") == 0) {
|
287
|
-
write_name_and_type(buffer, key, 0x05);
|
288
307
|
const char subtype = strcmp(cls, "ByteBuffer") ?
|
289
308
|
(const char)FIX2INT(rb_funcall(value, rb_intern("subtype"), 0)) : 2;
|
290
309
|
VALUE string_data = rb_funcall(value, rb_intern("to_s"), 0);
|
291
310
|
int length = RSTRING_LEN(string_data);
|
311
|
+
write_name_and_type(buffer, key, 0x05);
|
292
312
|
if (subtype == 2) {
|
293
313
|
const int other_length = length + 4;
|
294
314
|
buffer_write_bytes(buffer, (const char*)&other_length, 4);
|
@@ -302,9 +322,9 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow
|
|
302
322
|
break;
|
303
323
|
}
|
304
324
|
if (strcmp(cls, "XGen::Mongo::Driver::ObjectID") == 0) {
|
305
|
-
write_name_and_type(buffer, key, 0x07);
|
306
325
|
VALUE as_array = rb_funcall(value, rb_intern("to_a"), 0);
|
307
326
|
int i;
|
327
|
+
write_name_and_type(buffer, key, 0x07);
|
308
328
|
for (i = 0; i < 12; i++) {
|
309
329
|
char byte = (char)FIX2INT(RARRAY_PTR(as_array)[i]);
|
310
330
|
buffer_write_bytes(buffer, &byte, 1);
|
@@ -312,21 +332,23 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow
|
|
312
332
|
break;
|
313
333
|
}
|
314
334
|
if (strcmp(cls, "XGen::Mongo::Driver::DBRef") == 0) {
|
335
|
+
int start_position, length_location, obj_length;
|
336
|
+
VALUE ns, oid;
|
315
337
|
write_name_and_type(buffer, key, 0x03);
|
316
338
|
|
317
|
-
|
339
|
+
start_position = buffer->position;
|
318
340
|
|
319
341
|
// save space for length
|
320
|
-
|
342
|
+
length_location = buffer_save_bytes(buffer, 4);
|
321
343
|
|
322
|
-
|
344
|
+
ns = rb_funcall(value, rb_intern("namespace"), 0);
|
323
345
|
write_element(rb_str_new2("$ref"), ns, pack_extra(buffer, Qfalse));
|
324
|
-
|
346
|
+
oid = rb_funcall(value, rb_intern("object_id"), 0);
|
325
347
|
write_element(rb_str_new2("$id"), oid, pack_extra(buffer, Qfalse));
|
326
348
|
|
327
349
|
// write null byte and fill in length
|
328
350
|
buffer_write_bytes(buffer, &zero, 1);
|
329
|
-
|
351
|
+
obj_length = buffer->position - start_position;
|
330
352
|
memcpy(buffer->buffer + length_location, &obj_length, 4);
|
331
353
|
break;
|
332
354
|
}
|
@@ -340,23 +362,25 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow
|
|
340
362
|
// TODO again, is this really the only way to do this?
|
341
363
|
const char* cls = rb_class2name(RBASIC(value)->klass);
|
342
364
|
if (strcmp(cls, "Time") == 0) {
|
343
|
-
write_name_and_type(buffer, key, 0x09);
|
344
365
|
double t = NUM2DBL(rb_funcall(value, rb_intern("to_f"), 0));
|
345
366
|
long long time_since_epoch = (long long)round(t * 1000);
|
367
|
+
write_name_and_type(buffer, key, 0x09);
|
346
368
|
buffer_write_bytes(buffer, (const char*)&time_since_epoch, 8);
|
347
369
|
break;
|
348
370
|
}
|
349
371
|
}
|
350
372
|
case T_REGEXP:
|
351
373
|
{
|
352
|
-
write_name_and_type(buffer, key, 0x0B);
|
353
|
-
|
354
374
|
int length = RREGEXP_SRC_LEN(value);
|
355
375
|
char* pattern = (char*)RREGEXP_SRC_PTR(value);
|
376
|
+
long flags = RREGEXP(value)->ptr->options;
|
377
|
+
VALUE has_extra;
|
378
|
+
|
379
|
+
write_name_and_type(buffer, key, 0x0B);
|
380
|
+
|
356
381
|
buffer_write_bytes(buffer, pattern, length);
|
357
382
|
buffer_write_bytes(buffer, &zero, 1);
|
358
383
|
|
359
|
-
long flags = RREGEXP(value)->ptr->options;
|
360
384
|
if (flags & IGNORECASE) {
|
361
385
|
char ignorecase = 'i';
|
362
386
|
buffer_write_bytes(buffer, &ignorecase, 1);
|
@@ -370,7 +394,7 @@ static int write_element_allow_id(VALUE key, VALUE value, VALUE extra, int allow
|
|
370
394
|
buffer_write_bytes(buffer, &extended, 1);
|
371
395
|
}
|
372
396
|
|
373
|
-
|
397
|
+
has_extra = rb_funcall(value, rb_intern("respond_to?"), 1, rb_str_new2("extra_options_str"));
|
374
398
|
if (TYPE(has_extra) == T_TRUE) {
|
375
399
|
VALUE extra = rb_funcall(value, rb_intern("extra_options_str"), 0);
|
376
400
|
int old_position = buffer->position;
|
@@ -397,6 +421,7 @@ static int write_element(VALUE key, VALUE value, VALUE extra) {
|
|
397
421
|
static void write_doc(bson_buffer* buffer, VALUE hash, VALUE check_keys) {
|
398
422
|
int start_position = buffer->position;
|
399
423
|
int length_location = buffer_save_bytes(buffer, 4);
|
424
|
+
int length;
|
400
425
|
|
401
426
|
VALUE key = rb_str_new2("_id");
|
402
427
|
if (rb_funcall(hash, rb_intern("has_key?"), 1, key) == Qtrue) {
|
@@ -425,17 +450,18 @@ static void write_doc(bson_buffer* buffer, VALUE hash, VALUE check_keys) {
|
|
425
450
|
|
426
451
|
// write null byte and fill in length
|
427
452
|
buffer_write_bytes(buffer, &zero, 1);
|
428
|
-
|
453
|
+
length = buffer->position - start_position;
|
429
454
|
memcpy(buffer->buffer + length_location, &length, 4);
|
430
455
|
}
|
431
456
|
|
432
457
|
static VALUE method_serialize(VALUE self, VALUE doc, VALUE check_keys) {
|
458
|
+
VALUE result;
|
433
459
|
bson_buffer* buffer = buffer_new();
|
434
460
|
assert(buffer);
|
435
461
|
|
436
462
|
write_doc(buffer, doc, check_keys);
|
437
463
|
|
438
|
-
|
464
|
+
result = rb_str_new(buffer->buffer, buffer->position);
|
439
465
|
buffer_free(buffer);
|
440
466
|
return result;
|
441
467
|
}
|
@@ -454,8 +480,9 @@ static VALUE get_value(const char* buffer, int* position, int type) {
|
|
454
480
|
case 2:
|
455
481
|
case 13:
|
456
482
|
{
|
483
|
+
int value_length;
|
457
484
|
*position += 4;
|
458
|
-
|
485
|
+
value_length = strlen(buffer + *position);
|
459
486
|
value = rb_str_new(buffer+ *position, value_length);
|
460
487
|
*position += value_length + 1;
|
461
488
|
break;
|
@@ -468,9 +495,11 @@ static VALUE get_value(const char* buffer, int* position, int type) {
|
|
468
495
|
int offset = *position + 14;
|
469
496
|
VALUE argv[2];
|
470
497
|
int collection_length = strlen(buffer + offset);
|
498
|
+
char id_type;
|
499
|
+
|
471
500
|
argv[0] = rb_str_new(buffer + offset, collection_length);
|
472
501
|
offset += collection_length + 1;
|
473
|
-
|
502
|
+
id_type = buffer[offset];
|
474
503
|
offset += 5;
|
475
504
|
argv[1] = get_value(buffer, &offset, (int)id_type);
|
476
505
|
value = rb_class_new_instance(2, argv, DBRef);
|
@@ -482,17 +511,19 @@ static VALUE get_value(const char* buffer, int* position, int type) {
|
|
482
511
|
}
|
483
512
|
case 4:
|
484
513
|
{
|
485
|
-
int size;
|
514
|
+
int size, end;
|
486
515
|
memcpy(&size, buffer + *position, 4);
|
487
|
-
|
516
|
+
end = *position + size - 1;
|
488
517
|
*position += 4;
|
489
518
|
|
490
519
|
value = rb_ary_new();
|
491
520
|
while (*position < end) {
|
492
521
|
int type = (int)buffer[(*position)++];
|
493
522
|
int key_size = strlen(buffer + *position);
|
523
|
+
VALUE to_append;
|
524
|
+
|
494
525
|
*position += key_size + 1; // just skip the key, they're in order.
|
495
|
-
|
526
|
+
to_append = get_value(buffer, position, type);
|
496
527
|
rb_ary_push(value, to_append);
|
497
528
|
}
|
498
529
|
(*position)++;
|
@@ -500,17 +531,19 @@ static VALUE get_value(const char* buffer, int* position, int type) {
|
|
500
531
|
}
|
501
532
|
case 5:
|
502
533
|
{
|
503
|
-
int length;
|
534
|
+
int length, subtype;
|
535
|
+
VALUE data, st;
|
536
|
+
VALUE argv[2];
|
504
537
|
memcpy(&length, buffer + *position, 4);
|
505
|
-
|
506
|
-
VALUE data;
|
538
|
+
subtype = (unsigned char)buffer[*position + 4];
|
507
539
|
if (subtype == 2) {
|
508
540
|
data = rb_str_new(buffer + *position + 9, length - 4);
|
509
541
|
} else {
|
510
542
|
data = rb_str_new(buffer + *position + 5, length);
|
511
543
|
}
|
512
|
-
|
513
|
-
|
544
|
+
st = INT2FIX(subtype);
|
545
|
+
argv[0] = data;
|
546
|
+
argv[1] = st;
|
514
547
|
value = rb_class_new_instance(2, argv, Binary);
|
515
548
|
*position += length + 5;
|
516
549
|
break;
|
@@ -536,11 +569,13 @@ static VALUE get_value(const char* buffer, int* position, int type) {
|
|
536
569
|
case 9:
|
537
570
|
{
|
538
571
|
long long millis;
|
572
|
+
VALUE seconds, microseconds;
|
539
573
|
memcpy(&millis, buffer + *position, 8);
|
540
|
-
|
541
|
-
|
574
|
+
seconds = INT2NUM(millis / 1000);
|
575
|
+
microseconds = INT2NUM((millis % 1000) * 1000);
|
542
576
|
|
543
577
|
value = rb_funcall(Time, rb_intern("at"), 2, seconds, microseconds);
|
578
|
+
value = rb_funcall(value, rb_intern("utc"), 0);
|
544
579
|
*position += 8;
|
545
580
|
break;
|
546
581
|
}
|
@@ -553,13 +588,12 @@ static VALUE get_value(const char* buffer, int* position, int type) {
|
|
553
588
|
{
|
554
589
|
int pattern_length = strlen(buffer + *position);
|
555
590
|
VALUE pattern = rb_str_new(buffer + *position, pattern_length);
|
591
|
+
int flags_length, flags = 0, i = 0;
|
592
|
+
char extra[10];
|
593
|
+
VALUE argv[3];
|
556
594
|
*position += pattern_length + 1;
|
557
595
|
|
558
|
-
|
559
|
-
int i = 0;
|
560
|
-
|
561
|
-
int flags = 0;
|
562
|
-
char extra[10];
|
596
|
+
flags_length = strlen(buffer + *position);
|
563
597
|
extra[0] = 0;
|
564
598
|
for (i = 0; i < flags_length; i++) {
|
565
599
|
char flag = buffer[*position + i];
|
@@ -576,28 +610,29 @@ static VALUE get_value(const char* buffer, int* position, int type) {
|
|
576
610
|
strncat(extra, &flag, 1);
|
577
611
|
}
|
578
612
|
}
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
rb_str_new2(extra)
|
583
|
-
};
|
613
|
+
argv[0] = pattern;
|
614
|
+
argv[1] = INT2FIX(flags);
|
615
|
+
argv[2] = rb_str_new2(extra);
|
584
616
|
value = rb_class_new_instance(3, argv, RegexpOfHolding);
|
585
617
|
*position += flags_length + 1;
|
586
618
|
break;
|
587
619
|
}
|
588
620
|
case 12:
|
589
621
|
{
|
622
|
+
int collection_length;
|
623
|
+
VALUE collection, str, oid, id, argv[2];
|
590
624
|
*position += 4;
|
591
|
-
|
592
|
-
|
625
|
+
collection_length = strlen(buffer + *position);
|
626
|
+
collection = rb_str_new(buffer + *position, collection_length);
|
593
627
|
*position += collection_length + 1;
|
594
628
|
|
595
|
-
|
596
|
-
|
597
|
-
|
629
|
+
str = rb_str_new(buffer + *position, 12);
|
630
|
+
oid = rb_funcall(str, rb_intern("unpack"), 1, rb_str_new2("C*"));
|
631
|
+
id = rb_class_new_instance(1, &oid, ObjectID);
|
598
632
|
*position += 12;
|
599
633
|
|
600
|
-
|
634
|
+
argv[0] = collection;
|
635
|
+
argv[1] = id;
|
601
636
|
value = rb_class_new_instance(2, argv, DBRef);
|
602
637
|
break;
|
603
638
|
}
|
@@ -611,17 +646,19 @@ static VALUE get_value(const char* buffer, int* position, int type) {
|
|
611
646
|
}
|
612
647
|
case 15:
|
613
648
|
{
|
649
|
+
int code_length, scope_size;
|
650
|
+
VALUE code, scope, argv[2];
|
614
651
|
*position += 8;
|
615
|
-
|
616
|
-
|
652
|
+
code_length = strlen(buffer + *position);
|
653
|
+
code = rb_str_new(buffer + *position, code_length);
|
617
654
|
*position += code_length + 1;
|
618
655
|
|
619
|
-
int scope_size;
|
620
656
|
memcpy(&scope_size, buffer + *position, 4);
|
621
|
-
|
657
|
+
scope = elements_to_hash(buffer + *position + 4, scope_size - 5);
|
622
658
|
*position += scope_size;
|
623
659
|
|
624
|
-
|
660
|
+
argv[0] = code;
|
661
|
+
argv[1] = scope;
|
625
662
|
value = rb_class_new_instance(2, argv, Code);
|
626
663
|
break;
|
627
664
|
}
|
@@ -659,8 +696,9 @@ static VALUE elements_to_hash(const char* buffer, int max) {
|
|
659
696
|
int type = (int)buffer[position++];
|
660
697
|
int name_length = strlen(buffer + position);
|
661
698
|
VALUE name = rb_str_new(buffer + position, name_length);
|
699
|
+
VALUE value;
|
662
700
|
position += name_length + 1;
|
663
|
-
|
701
|
+
value = get_value(buffer, &position, type);
|
664
702
|
rb_funcall(hash, rb_intern("[]="), 2, name, value);
|
665
703
|
}
|
666
704
|
return hash;
|
@@ -678,12 +716,13 @@ static VALUE method_deserialize(VALUE self, VALUE bson) {
|
|
678
716
|
}
|
679
717
|
|
680
718
|
void Init_cbson() {
|
719
|
+
VALUE driver, CBson;
|
681
720
|
Time = rb_const_get(rb_cObject, rb_intern("Time"));
|
682
721
|
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
722
|
+
driver = rb_const_get(rb_const_get(rb_const_get(rb_cObject,
|
723
|
+
rb_intern("XGen")),
|
724
|
+
rb_intern("Mongo")),
|
725
|
+
rb_intern("Driver"));
|
687
726
|
rb_require("mongo/types/binary");
|
688
727
|
Binary = rb_const_get(driver, rb_intern("Binary"));
|
689
728
|
rb_require("mongo/types/undefined");
|
@@ -699,7 +738,7 @@ void Init_cbson() {
|
|
699
738
|
rb_require("mongo/util/ordered_hash");
|
700
739
|
OrderedHash = rb_const_get(rb_cObject, rb_intern("OrderedHash"));
|
701
740
|
|
702
|
-
|
741
|
+
CBson = rb_define_module("CBson");
|
703
742
|
rb_define_module_function(CBson, "serialize", method_serialize, 2);
|
704
743
|
rb_define_module_function(CBson, "deserialize", method_deserialize, 1);
|
705
744
|
}
|
data/mongo-extensions.gemspec
CHANGED
@@ -7,7 +7,7 @@ TEST_FILES = []
|
|
7
7
|
|
8
8
|
Gem::Specification.new do |s|
|
9
9
|
s.name = 'mongo_ext'
|
10
|
-
s.version = '0.
|
10
|
+
s.version = '0.4.1'
|
11
11
|
s.platform = Gem::Platform::RUBY
|
12
12
|
s.summary = 'C extensions for the MongoDB Ruby driver'
|
13
13
|
s.description = 'C extensions to accelerate the MondoDB Ruby driver. For more information about Mongo, see http://www.mongodb.org.'
|
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:
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Dirolf
|
@@ -28,6 +28,7 @@ files:
|
|
28
28
|
- ext/cbson/extconf.rb
|
29
29
|
has_rdoc: false
|
30
30
|
homepage: http://www.mongodb.org
|
31
|
+
licenses:
|
31
32
|
post_install_message:
|
32
33
|
rdoc_options: []
|
33
34
|
|
@@ -48,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
48
49
|
requirements: []
|
49
50
|
|
50
51
|
rubyforge_project:
|
51
|
-
rubygems_version: 1.
|
52
|
+
rubygems_version: 1.3.5
|
52
53
|
signing_key:
|
53
54
|
specification_version: 2
|
54
55
|
summary: C extensions for the MongoDB Ruby driver
|