google-protobuf 3.7.0 → 3.16.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of google-protobuf might be problematic. Click here for more details.

Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/ext/google/protobuf_c/convert.c +349 -0
  3. data/ext/google/protobuf_c/convert.h +72 -0
  4. data/ext/google/protobuf_c/defs.c +1555 -1228
  5. data/ext/google/protobuf_c/defs.h +107 -0
  6. data/ext/google/protobuf_c/extconf.rb +4 -7
  7. data/ext/google/protobuf_c/map.c +310 -470
  8. data/ext/google/protobuf_c/map.h +66 -0
  9. data/ext/google/protobuf_c/message.c +931 -346
  10. data/ext/google/protobuf_c/message.h +101 -0
  11. data/ext/google/protobuf_c/protobuf.c +384 -51
  12. data/ext/google/protobuf_c/protobuf.h +44 -544
  13. data/ext/google/protobuf_c/repeated_field.c +311 -308
  14. data/ext/google/protobuf_c/repeated_field.h +62 -0
  15. data/ext/google/protobuf_c/ruby-upb.c +8914 -0
  16. data/ext/google/protobuf_c/ruby-upb.h +4452 -0
  17. data/ext/google/protobuf_c/third_party/wyhash/wyhash.h +145 -0
  18. data/lib/google/protobuf/any_pb.rb +1 -1
  19. data/lib/google/protobuf/api_pb.rb +3 -3
  20. data/lib/google/protobuf/duration_pb.rb +1 -1
  21. data/lib/google/protobuf/empty_pb.rb +1 -1
  22. data/lib/google/protobuf/field_mask_pb.rb +1 -1
  23. data/lib/google/protobuf/source_context_pb.rb +1 -1
  24. data/lib/google/protobuf/struct_pb.rb +4 -4
  25. data/lib/google/protobuf/timestamp_pb.rb +1 -1
  26. data/lib/google/protobuf/type_pb.rb +8 -8
  27. data/lib/google/protobuf/well_known_types.rb +8 -2
  28. data/lib/google/protobuf/wrappers_pb.rb +9 -9
  29. data/lib/google/protobuf.rb +70 -0
  30. data/tests/basic.rb +315 -72
  31. data/tests/generated_code_test.rb +0 -0
  32. data/tests/stress.rb +0 -0
  33. metadata +27 -16
  34. data/ext/google/protobuf_c/encode_decode.c +0 -1574
  35. data/ext/google/protobuf_c/storage.c +0 -1019
  36. data/ext/google/protobuf_c/upb.c +0 -17318
  37. data/ext/google/protobuf_c/upb.h +0 -9755
@@ -0,0 +1,145 @@
1
+ /* Copyright 2020 王一 Wang Yi <godspeed_china@yeah.net>
2
+ This is free and unencumbered software released into the public domain. http://unlicense.org/
3
+ See github.com/wangyi-fudan/wyhash/ LICENSE
4
+ */
5
+ #ifndef wyhash_final_version
6
+ #define wyhash_final_version
7
+ //defines that change behavior
8
+ #ifndef WYHASH_CONDOM
9
+ #define WYHASH_CONDOM 1 //0: read 8 bytes before and after boundaries, dangerous but fastest. 1: normal valid behavior 2: extra protection against entropy loss (probability=2^-63), aka. "blind multiplication"
10
+ #endif
11
+ #define WYHASH_32BIT_MUM 0 //faster on 32 bit system
12
+ //includes
13
+ #include <stdint.h>
14
+ #include <string.h>
15
+ #if defined(_MSC_VER) && defined(_M_X64)
16
+ #include <intrin.h>
17
+ #pragma intrinsic(_umul128)
18
+ #endif
19
+ #if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__clang__)
20
+ #define _likely_(x) __builtin_expect(x,1)
21
+ #define _unlikely_(x) __builtin_expect(x,0)
22
+ #else
23
+ #define _likely_(x) (x)
24
+ #define _unlikely_(x) (x)
25
+ #endif
26
+ //mum function
27
+ static inline uint64_t _wyrot(uint64_t x) { return (x>>32)|(x<<32); }
28
+ static inline void _wymum(uint64_t *A, uint64_t *B){
29
+ #if(WYHASH_32BIT_MUM)
30
+ uint64_t hh=(*A>>32)*(*B>>32), hl=(*A>>32)*(unsigned)*B, lh=(unsigned)*A*(*B>>32), ll=(uint64_t)(unsigned)*A*(unsigned)*B;
31
+ #if(WYHASH_CONDOM>1)
32
+ *A^=_wyrot(hl)^hh; *B^=_wyrot(lh)^ll;
33
+ #else
34
+ *A=_wyrot(hl)^hh; *B=_wyrot(lh)^ll;
35
+ #endif
36
+ #elif defined(__SIZEOF_INT128__)
37
+ __uint128_t r=*A; r*=*B;
38
+ #if(WYHASH_CONDOM>1)
39
+ *A^=(uint64_t)r; *B^=(uint64_t)(r>>64);
40
+ #else
41
+ *A=(uint64_t)r; *B=(uint64_t)(r>>64);
42
+ #endif
43
+ #elif defined(_MSC_VER) && defined(_M_X64)
44
+ #if(WYHASH_CONDOM>1)
45
+ uint64_t a, b;
46
+ a=_umul128(*A,*B,&b);
47
+ *A^=a; *B^=b;
48
+ #else
49
+ *A=_umul128(*A,*B,B);
50
+ #endif
51
+ #else
52
+ uint64_t ha=*A>>32, hb=*B>>32, la=(uint32_t)*A, lb=(uint32_t)*B, hi, lo;
53
+ uint64_t rh=ha*hb, rm0=ha*lb, rm1=hb*la, rl=la*lb, t=rl+(rm0<<32), c=t<rl;
54
+ lo=t+(rm1<<32); c+=lo<t; hi=rh+(rm0>>32)+(rm1>>32)+c;
55
+ #if(WYHASH_CONDOM>1)
56
+ *A^=lo; *B^=hi;
57
+ #else
58
+ *A=lo; *B=hi;
59
+ #endif
60
+ #endif
61
+ }
62
+ static inline uint64_t _wymix(uint64_t A, uint64_t B){ _wymum(&A,&B); return A^B; }
63
+ //read functions
64
+ #ifndef WYHASH_LITTLE_ENDIAN
65
+ #if defined(_WIN32) || defined(__LITTLE_ENDIAN__) || (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
66
+ #define WYHASH_LITTLE_ENDIAN 1
67
+ #elif defined(__BIG_ENDIAN__) || (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
68
+ #define WYHASH_LITTLE_ENDIAN 0
69
+ #endif
70
+ #endif
71
+ #if (WYHASH_LITTLE_ENDIAN)
72
+ static inline uint64_t _wyr8(const uint8_t *p) { uint64_t v; memcpy(&v, p, 8); return v;}
73
+ static inline uint64_t _wyr4(const uint8_t *p) { unsigned v; memcpy(&v, p, 4); return v;}
74
+ #elif defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__clang__)
75
+ static inline uint64_t _wyr8(const uint8_t *p) { uint64_t v; memcpy(&v, p, 8); return __builtin_bswap64(v);}
76
+ static inline uint64_t _wyr4(const uint8_t *p) { unsigned v; memcpy(&v, p, 4); return __builtin_bswap32(v);}
77
+ #elif defined(_MSC_VER)
78
+ static inline uint64_t _wyr8(const uint8_t *p) { uint64_t v; memcpy(&v, p, 8); return _byteswap_uint64(v);}
79
+ static inline uint64_t _wyr4(const uint8_t *p) { unsigned v; memcpy(&v, p, 4); return _byteswap_ulong(v);}
80
+ #endif
81
+ static inline uint64_t _wyr3(const uint8_t *p, unsigned k) { return (((uint64_t)p[0])<<16)|(((uint64_t)p[k>>1])<<8)|p[k-1];}
82
+ //wyhash function
83
+ static inline uint64_t _wyfinish16(const uint8_t *p, uint64_t len, uint64_t seed, const uint64_t *secret, uint64_t i){
84
+ #if(WYHASH_CONDOM>0)
85
+ uint64_t a, b;
86
+ if(_likely_(i<=8)){
87
+ if(_likely_(i>=4)){ a=_wyr4(p); b=_wyr4(p+i-4); }
88
+ else if (_likely_(i)){ a=_wyr3(p,i); b=0; }
89
+ else a=b=0;
90
+ }
91
+ else{ a=_wyr8(p); b=_wyr8(p+i-8); }
92
+ return _wymix(secret[1]^len,_wymix(a^secret[1], b^seed));
93
+ #else
94
+ #define oneshot_shift ((i<8)*((8-i)<<3))
95
+ return _wymix(secret[1]^len,_wymix((_wyr8(p)<<oneshot_shift)^secret[1],(_wyr8(p+i-8)>>oneshot_shift)^seed));
96
+ #endif
97
+ }
98
+
99
+ static inline uint64_t _wyfinish(const uint8_t *p, uint64_t len, uint64_t seed, const uint64_t *secret, uint64_t i){
100
+ if(_likely_(i<=16)) return _wyfinish16(p,len,seed,secret,i);
101
+ return _wyfinish(p+16,len,_wymix(_wyr8(p)^secret[1],_wyr8(p+8)^seed),secret,i-16);
102
+ }
103
+
104
+ static inline uint64_t wyhash(const void *key, uint64_t len, uint64_t seed, const uint64_t *secret){
105
+ const uint8_t *p=(const uint8_t *)key;
106
+ uint64_t i=len; seed^=*secret;
107
+ if(_unlikely_(i>64)){
108
+ uint64_t see1=seed;
109
+ do{
110
+ seed=_wymix(_wyr8(p)^secret[1],_wyr8(p+8)^seed)^_wymix(_wyr8(p+16)^secret[2],_wyr8(p+24)^seed);
111
+ see1=_wymix(_wyr8(p+32)^secret[3],_wyr8(p+40)^see1)^_wymix(_wyr8(p+48)^secret[4],_wyr8(p+56)^see1);
112
+ p+=64; i-=64;
113
+ }while(i>64);
114
+ seed^=see1;
115
+ }
116
+ return _wyfinish(p,len,seed,secret,i);
117
+ }
118
+ //utility functions
119
+ static const uint64_t _wyp[5] = {0xa0761d6478bd642full, 0xe7037ed1a0b428dbull, 0x8ebc6af09c88c6e3ull, 0x589965cc75374cc3ull, 0x1d8e4e27c47d124full};
120
+ static inline uint64_t wyhash64(uint64_t A, uint64_t B){ A^=_wyp[0]; B^=_wyp[1]; _wymum(&A,&B); return _wymix(A^_wyp[0],B^_wyp[1]);}
121
+ static inline uint64_t wyrand(uint64_t *seed){ *seed+=_wyp[0]; return _wymix(*seed,*seed^_wyp[1]);}
122
+ static inline double wy2u01(uint64_t r){ const double _wynorm=1.0/(1ull<<52); return (r>>12)*_wynorm;}
123
+ static inline double wy2gau(uint64_t r){ const double _wynorm=1.0/(1ull<<20); return ((r&0x1fffff)+((r>>21)&0x1fffff)+((r>>42)&0x1fffff))*_wynorm-3.0;}
124
+ static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; }
125
+
126
+ static inline void make_secret(uint64_t seed, uint64_t *secret){
127
+ uint8_t c[] = {15, 23, 27, 29, 30, 39, 43, 45, 46, 51, 53, 54, 57, 58, 60, 71, 75, 77, 78, 83, 85, 86, 89, 90, 92, 99, 101, 102, 105, 106, 108, 113, 114, 116, 120, 135, 139, 141, 142, 147, 149, 150, 153, 154, 156, 163, 165, 166, 169, 170, 172, 177, 178, 180, 184, 195, 197, 198, 201, 202, 204, 209, 210, 212, 216, 225, 226, 228, 232, 240 };
128
+ for(size_t i=0;i<5;i++){
129
+ uint8_t ok;
130
+ do{
131
+ ok=1; secret[i]=0;
132
+ for(size_t j=0;j<64;j+=8) secret[i]|=((uint64_t)c[wyrand(&seed)%sizeof(c)])<<j;
133
+ if(secret[i]%2==0){ ok=0; continue; }
134
+ for(size_t j=0;j<i;j++)
135
+ #if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__clang__)
136
+ if(__builtin_popcountll(secret[j]^secret[i])!=32){ ok=0; break; }
137
+ #elif defined(_MSC_VER) && defined(_M_X64)
138
+ if(_mm_popcnt_u64(secret[j]^secret[i])!=32){ ok=0; break; }
139
+ #endif
140
+ if(!ok)continue;
141
+ for(uint64_t j=3;j<0x100000000ull;j+=2) if(secret[i]%j==0){ ok=0; break; }
142
+ }while(!ok);
143
+ }
144
+ }
145
+ #endif
@@ -14,6 +14,6 @@ end
14
14
 
15
15
  module Google
16
16
  module Protobuf
17
- Any = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Any").msgclass
17
+ Any = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Any").msgclass
18
18
  end
19
19
  end
@@ -34,8 +34,8 @@ end
34
34
 
35
35
  module Google
36
36
  module Protobuf
37
- Api = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Api").msgclass
38
- Method = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Method").msgclass
39
- Mixin = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Mixin").msgclass
37
+ Api = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Api").msgclass
38
+ Method = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Method").msgclass
39
+ Mixin = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Mixin").msgclass
40
40
  end
41
41
  end
@@ -14,6 +14,6 @@ end
14
14
 
15
15
  module Google
16
16
  module Protobuf
17
- Duration = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Duration").msgclass
17
+ Duration = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Duration").msgclass
18
18
  end
19
19
  end
@@ -12,6 +12,6 @@ end
12
12
 
13
13
  module Google
14
14
  module Protobuf
15
- Empty = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Empty").msgclass
15
+ Empty = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Empty").msgclass
16
16
  end
17
17
  end
@@ -13,6 +13,6 @@ end
13
13
 
14
14
  module Google
15
15
  module Protobuf
16
- FieldMask = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldMask").msgclass
16
+ FieldMask = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FieldMask").msgclass
17
17
  end
18
18
  end
@@ -13,6 +13,6 @@ end
13
13
 
14
14
  module Google
15
15
  module Protobuf
16
- SourceContext = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.SourceContext").msgclass
16
+ SourceContext = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.SourceContext").msgclass
17
17
  end
18
18
  end
@@ -29,9 +29,9 @@ end
29
29
 
30
30
  module Google
31
31
  module Protobuf
32
- Struct = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Struct").msgclass
33
- Value = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Value").msgclass
34
- ListValue = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.ListValue").msgclass
35
- NullValue = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.NullValue").enummodule
32
+ Struct = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Struct").msgclass
33
+ Value = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Value").msgclass
34
+ ListValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.ListValue").msgclass
35
+ NullValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.NullValue").enummodule
36
36
  end
37
37
  end
@@ -14,6 +14,6 @@ end
14
14
 
15
15
  module Google
16
16
  module Protobuf
17
- Timestamp = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Timestamp").msgclass
17
+ Timestamp = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Timestamp").msgclass
18
18
  end
19
19
  end
@@ -79,13 +79,13 @@ end
79
79
 
80
80
  module Google
81
81
  module Protobuf
82
- Type = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Type").msgclass
83
- Field = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Field").msgclass
84
- Field::Kind = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Field.Kind").enummodule
85
- Field::Cardinality = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Field.Cardinality").enummodule
86
- Enum = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Enum").msgclass
87
- EnumValue = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.EnumValue").msgclass
88
- Option = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Option").msgclass
89
- Syntax = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Syntax").enummodule
82
+ Type = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Type").msgclass
83
+ Field = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Field").msgclass
84
+ Field::Kind = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Field.Kind").enummodule
85
+ Field::Cardinality = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Field.Cardinality").enummodule
86
+ Enum = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Enum").msgclass
87
+ EnumValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.EnumValue").msgclass
88
+ Option = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Option").msgclass
89
+ Syntax = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Syntax").enummodule
90
90
  end
91
91
  end
@@ -72,8 +72,14 @@ module Google
72
72
  end
73
73
 
74
74
  Timestamp.class_eval do
75
- def to_time
76
- Time.at(self.to_f)
75
+ if RUBY_VERSION < "2.5"
76
+ def to_time
77
+ Time.at(self.to_f)
78
+ end
79
+ else
80
+ def to_time
81
+ Time.at(seconds, nanos, :nanosecond)
82
+ end
77
83
  end
78
84
 
79
85
  def from_time(time)
@@ -37,14 +37,14 @@ end
37
37
 
38
38
  module Google
39
39
  module Protobuf
40
- DoubleValue = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.DoubleValue").msgclass
41
- FloatValue = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FloatValue").msgclass
42
- Int64Value = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Int64Value").msgclass
43
- UInt64Value = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.UInt64Value").msgclass
44
- Int32Value = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Int32Value").msgclass
45
- UInt32Value = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.UInt32Value").msgclass
46
- BoolValue = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.BoolValue").msgclass
47
- StringValue = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.StringValue").msgclass
48
- BytesValue = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.BytesValue").msgclass
40
+ DoubleValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.DoubleValue").msgclass
41
+ FloatValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.FloatValue").msgclass
42
+ Int64Value = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Int64Value").msgclass
43
+ UInt64Value = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.UInt64Value").msgclass
44
+ Int32Value = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Int32Value").msgclass
45
+ UInt32Value = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.UInt32Value").msgclass
46
+ BoolValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.BoolValue").msgclass
47
+ StringValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.StringValue").msgclass
48
+ BytesValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.BytesValue").msgclass
49
49
  end
50
50
  end
@@ -50,6 +50,76 @@ else
50
50
  rescue LoadError
51
51
  require 'google/protobuf_c'
52
52
  end
53
+
54
+ module Google
55
+ module Protobuf
56
+ module Internal
57
+ def self.infer_package(names)
58
+ # Package is longest common prefix ending in '.', if any.
59
+ if not names.empty?
60
+ min, max = names.minmax
61
+ last_common_dot = nil
62
+ min.size.times { |i|
63
+ if min[i] != max[i] then break end
64
+ if min[i] == ?. then last_common_dot = i end
65
+ }
66
+ if last_common_dot
67
+ return min.slice(0, last_common_dot)
68
+ end
69
+ end
70
+
71
+ nil
72
+ end
73
+
74
+ class NestingBuilder
75
+ def initialize(msg_names, enum_names)
76
+ @to_pos = {nil=>nil}
77
+ @msg_children = Hash.new { |hash, key| hash[key] = [] }
78
+ @enum_children = Hash.new { |hash, key| hash[key] = [] }
79
+
80
+ msg_names.each_with_index { |name, idx| @to_pos[name] = idx }
81
+ enum_names.each_with_index { |name, idx| @to_pos[name] = idx }
82
+
83
+ msg_names.each { |name| @msg_children[parent(name)] << name }
84
+ enum_names.each { |name| @enum_children[parent(name)] << name }
85
+ end
86
+
87
+ def build(package)
88
+ return build_msg(package)
89
+ end
90
+
91
+ private
92
+ def build_msg(msg)
93
+ return {
94
+ :pos => @to_pos[msg],
95
+ :msgs => @msg_children[msg].map { |child| build_msg(child) },
96
+ :enums => @enum_children[msg].map { |child| @to_pos[child] },
97
+ }
98
+ end
99
+
100
+ private
101
+ def parent(name)
102
+ idx = name.rindex(?.)
103
+ if idx
104
+ return name.slice(0, idx)
105
+ else
106
+ return nil
107
+ end
108
+ end
109
+ end
110
+
111
+ def self.fixup_descriptor(package, msg_names, enum_names)
112
+ if package.nil?
113
+ package = self.infer_package(msg_names + enum_names)
114
+ end
115
+
116
+ nesting = NestingBuilder.new(msg_names, enum_names).build(package)
117
+
118
+ return package, nesting
119
+ end
120
+ end
121
+ end
122
+ end
53
123
  end
54
124
 
55
125
  require 'google/protobuf/repeated_field'