sparsam 0.2.9 → 0.2.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/ext/serializer.cpp +5 -11
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34cdf5f3a73cda371b8a1275369af0063e525d0951f44c23a12e02e6dfa3c519
4
- data.tar.gz: f5d7efaf6389491e9ceab33839b828fb26757d8b84b8cc3ba9cf87b509716e13
3
+ metadata.gz: c759ead3b6f09dd4e6b1e1754dc0443ea782e37fd717617d4069e5952605bc85
4
+ data.tar.gz: 3734e8cfa8796efdcfe78a702a536672bf88e5e442fdedb1e59b60602b34daaa
5
5
  SHA512:
6
- metadata.gz: c2482ca31e496f3e1fb2597eaf7eb8f83e2f5545d7b2f8165840c5b394b4f63ce522bff6c2d18e11287803cc739ad279b97cf45f97efa1bbdd2f29c5594c8fc2
7
- data.tar.gz: 62c14e98d040e76fdf6d9a886c0b138e25f0e8b9b901445b000f6c9fed12947c7537749a24f5601fc84d4e920b6b18b816fbcbe946aa525242de57d269698abd
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
- Sparsam_Check_Type(actual, T_STRING, outer_struct, field_sym);
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
- Sparsam_Check_Type(actual, T_ARRAY, outer_struct, field_sym);
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
- Sparsam_Check_Type(actual, T_HASH, outer_struct, field_sym);
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.9
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-01-14 00:00:00.000000000 Z
11
+ date: 2022-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec