sparsam 0.2.9 → 0.2.10
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 +4 -4
- data/ext/serializer.cpp +5 -11
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c759ead3b6f09dd4e6b1e1754dc0443ea782e37fd717617d4069e5952605bc85
|
|
4
|
+
data.tar.gz: 3734e8cfa8796efdcfe78a702a536672bf88e5e442fdedb1e59b60602b34daaa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9eec207eba73e7fdb9a53edf2de172f34d640cfc15d484804204b929ecdc4caf223eb76a01be496487734ca1af54760fc1e7ad9cf4622e27183e4c4db24fa323
|
|
7
|
+
data.tar.gz: 27a9faadcf29db90b72d14a1b775c10ac9004a31f98562f1906c771a8f923124f1290feef5df5e2e8aefc39912ccaedc2b783b8461573eab71b2afc9770d6f4a
|
data/ext/serializer.cpp
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
extern "C" {
|
|
2
1
|
#include <ruby.h>
|
|
3
2
|
#include <ruby/intern.h>
|
|
4
|
-
}
|
|
5
3
|
#include <ruby/encoding.h>
|
|
6
4
|
#include <stdio.h>
|
|
7
5
|
#include <thrift/protocol/TBinaryProtocol.h>
|
|
@@ -51,6 +49,8 @@ VALUE SetClass;
|
|
|
51
49
|
KlassFieldsCache klassCache; // consider the memory leaked.
|
|
52
50
|
std::unordered_set<VALUE> unions;
|
|
53
51
|
|
|
52
|
+
#define SPARSAM_CHECK_TYPE(x, t, outer_struct, field_sym) if (!(RB_TYPE_P(x, t))) { raise_type_mismatch(outer_struct, field_sym, t, x); }
|
|
53
|
+
|
|
54
54
|
void *serializer_create() { return (void *)(new ThriftSerializer()); }
|
|
55
55
|
|
|
56
56
|
void serializer_free(void *data) {
|
|
@@ -185,12 +185,6 @@ static inline long raise_type_mismatch_as_value(VALUE outer_struct,
|
|
|
185
185
|
return 0;
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
static inline void Sparsam_Check_Type(VALUE x, int t, VALUE outer_struct,
|
|
189
|
-
VALUE field_sym) {
|
|
190
|
-
if (!(RB_TYPE_P(x, t))) {
|
|
191
|
-
raise_type_mismatch(outer_struct, field_sym, t, x);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
188
|
|
|
195
189
|
static inline VALUE make_ruby_bool(bool val) { return val ? Qtrue : Qfalse; }
|
|
196
190
|
|
|
@@ -513,7 +507,7 @@ void ThriftSerializer::writeAny(TType ttype, FieldInfo *field_info,
|
|
|
513
507
|
HANDLE_TYPE(BYTE, Byte, CONVERT_FIXNUM(byte_convert, protocol::T_BYTE))
|
|
514
508
|
|
|
515
509
|
case protocol::T_STRING: {
|
|
516
|
-
|
|
510
|
+
SPARSAM_CHECK_TYPE(actual, T_STRING, outer_struct, field_sym);
|
|
517
511
|
|
|
518
512
|
string data = string(StringValuePtr(actual), RSTRING_LEN(actual));
|
|
519
513
|
if (field_info->isBinaryString) {
|
|
@@ -525,7 +519,7 @@ void ThriftSerializer::writeAny(TType ttype, FieldInfo *field_info,
|
|
|
525
519
|
}
|
|
526
520
|
|
|
527
521
|
case protocol::T_LIST: {
|
|
528
|
-
|
|
522
|
+
SPARSAM_CHECK_TYPE(actual, T_ARRAY, outer_struct, field_sym);
|
|
529
523
|
|
|
530
524
|
long length = RARRAY_LEN(actual);
|
|
531
525
|
TType elem = field_info->elementType->ftype;
|
|
@@ -556,7 +550,7 @@ void ThriftSerializer::writeAny(TType ttype, FieldInfo *field_info,
|
|
|
556
550
|
}
|
|
557
551
|
|
|
558
552
|
case protocol::T_MAP: {
|
|
559
|
-
|
|
553
|
+
SPARSAM_CHECK_TYPE(actual, T_HASH, outer_struct, field_sym);
|
|
560
554
|
|
|
561
555
|
TType keyTType = field_info->keyType->ftype,
|
|
562
556
|
valueTType = field_info->elementType->ftype;
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sparsam
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Airbnb Thrift Developers
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-
|
|
11
|
+
date: 2022-05-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|