+54
-8
lines changedFilter options
+54
-8
lines changed Original file line number Diff line number Diff line change
@@ -13130,7 +13130,7 @@ UPB_API const upb_EnumDef* upb_DefPool_FindEnumByName(const upb_DefPool* s,
13130
13130
const upb_EnumValueDef* upb_DefPool_FindEnumByNameval(const upb_DefPool* s,
13131
13131
const char* sym);
13132
13132
13133
-
const upb_FileDef* upb_DefPool_FindFileByName(const upb_DefPool* s,
13133
+
UPB_API const upb_FileDef* upb_DefPool_FindFileByName(const upb_DefPool* s,
13134
13134
const char* name);
13135
13135
13136
13136
const upb_FileDef* upb_DefPool_FindFileByNameWithSize(const upb_DefPool* s,
Original file line number Diff line number Diff line change
@@ -156,6 +156,7 @@ static VALUE DescriptorPool_lookup(VALUE _self, VALUE name) {
156
156
const upb_EnumDef* enumdef;
157
157
const upb_FieldDef* fielddef;
158
158
const upb_ServiceDef* servicedef;
159
+
const upb_FileDef* filedef;
159
160
160
161
msgdef = upb_DefPool_FindMessageByName(self->symtab, name_str);
161
162
if (msgdef) {
@@ -177,6 +178,11 @@ static VALUE DescriptorPool_lookup(VALUE _self, VALUE name) {
177
178
return get_servicedef_obj(_self, servicedef);
178
179
}
179
180
181
+
filedef = upb_DefPool_FindFileByName(self->symtab, name_str);
182
+
if (filedef) {
183
+
return get_filedef_obj(_self, filedef);
184
+
}
185
+
180
186
return Qnil;
181
187
}
182
188
Original file line number Diff line number Diff line change
@@ -13132,7 +13132,7 @@ UPB_API const upb_EnumDef* upb_DefPool_FindEnumByName(const upb_DefPool* s,
13132
13132
const upb_EnumValueDef* upb_DefPool_FindEnumByNameval(const upb_DefPool* s,
13133
13133
const char* sym);
13134
13134
13135
-
const upb_FileDef* upb_DefPool_FindFileByName(const upb_DefPool* s,
13135
+
UPB_API const upb_FileDef* upb_DefPool_FindFileByName(const upb_DefPool* s,
13136
13136
const char* name);
13137
13137
13138
13138
const upb_FileDef* upb_DefPool_FindFileByNameWithSize(const upb_DefPool* s,
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ class FFI
17
17
attach_function :lookup_extension, :upb_DefPool_FindExtensionByName,[:DefPool, :string], FieldDescriptor
18
18
attach_function :lookup_msg, :upb_DefPool_FindMessageByName, [:DefPool, :string], Descriptor
19
19
attach_function :lookup_service, :upb_DefPool_FindServiceByName, [:DefPool, :string], ServiceDescriptor
20
+
attach_function :lookup_file, :upb_DefPool_FindFileByName, [:DefPool, :string], FileDescriptor
20
21
21
22
# FileDescriptorProto
22
23
attach_function :parse, :FileDescriptorProto_parse, [:binary_string, :size_t, Internal::Arena], :FileDescriptorProto
@@ -56,7 +57,8 @@ def lookup name
56
57
Google::Protobuf::FFI.lookup_msg(@descriptor_pool, name) ||
57
58
Google::Protobuf::FFI.lookup_enum(@descriptor_pool, name) ||
58
59
Google::Protobuf::FFI.lookup_extension(@descriptor_pool, name) ||
59
-
Google::Protobuf::FFI.lookup_service(@descriptor_pool, name)
60
+
Google::Protobuf::FFI.lookup_service(@descriptor_pool, name) ||
61
+
Google::Protobuf::FFI.lookup_file(@descriptor_pool, name)
60
62
end
61
63
62
64
def self.generated_pool
Original file line number Diff line number Diff line change
@@ -18,6 +18,32 @@ class FFI
18
18
class FileDescriptor
19
19
attr :descriptor_pool, :file_def
20
20
21
+
# FFI Interface methods and setup
22
+
extend ::FFI::DataConverter
23
+
native_type ::FFI::Type::POINTER
24
+
25
+
class << self
26
+
prepend Google::Protobuf::Internal::TypeSafety
27
+
include Google::Protobuf::Internal::PointerHelper
28
+
29
+
# @param value [FileDescriptor] FileDescriptor to convert to an FFI native type
30
+
# @param _ [Object] Unused
31
+
def to_native(value, _)
32
+
file_def_ptr = value.nil? ? nil : value.instance_variable_get(:@file_def)
33
+
return ::FFI::Pointer::NULL if file_def_ptr.nil?
34
+
raise "Underlying file_def was null!" if file_def_ptr.null?
35
+
file_def_ptr
36
+
end
37
+
38
+
##
39
+
# @param file_def [::FFI::Pointer] FileDef pointer to be wrapped
40
+
# @param _ [Object] Unused
41
+
def from_native(file_def, _ = nil)
42
+
return nil if file_def.nil? or file_def.null?
43
+
descriptor_from_file_def(file_def)
44
+
end
45
+
end
46
+
21
47
def initialize(file_def, descriptor_pool)
22
48
@descriptor_pool = descriptor_pool
23
49
@file_def = file_def
Original file line number Diff line number Diff line change
@@ -13,7 +13,8 @@ module PointerHelper
13
13
# the pool, and either retrieve the wrapper object for the given pointer
14
14
# or create one. Assumes that the caller is the wrapper class for the
15
15
# given pointer and that it implements `private_constructor`.
16
-
def descriptor_from_file_def(file_def, pointer)
16
+
def descriptor_from_file_def(file_def, pointer = nil)
17
+
pointer = file_def if pointer.nil?
17
18
raise RuntimeError.new "FileDef is nil" if file_def.nil?
18
19
raise RuntimeError.new "FileDef is null" if file_def.null?
19
20
pool_def = Google::Protobuf::FFI.file_def_pool file_def
Original file line number Diff line number Diff line change
@@ -17,8 +17,8 @@
17
17
require 'google/protobuf/ffi/oneof_descriptor'
18
18
require 'google/protobuf/ffi/method_descriptor'
19
19
require 'google/protobuf/ffi/service_descriptor'
20
-
require 'google/protobuf/ffi/descriptor_pool'
21
20
require 'google/protobuf/ffi/file_descriptor'
21
+
require 'google/protobuf/ffi/descriptor_pool'
22
22
require 'google/protobuf/ffi/map'
23
23
require 'google/protobuf/ffi/object_cache'
24
24
require 'google/protobuf/ffi/repeated_field'
Original file line number Diff line number Diff line change
@@ -39,7 +39,6 @@
39
39
import com.google.protobuf.Descriptors.FieldDescriptor;
40
40
import com.google.protobuf.Descriptors.FileDescriptor;
41
41
import com.google.protobuf.Descriptors.ServiceDescriptor;
42
-
import com.google.protobuf.Descriptors.MethodDescriptor;
43
42
import com.google.protobuf.ExtensionRegistry;
44
43
import com.google.protobuf.InvalidProtocolBufferException;
45
44
import java.util.ArrayList;
@@ -164,6 +163,11 @@ protected void registerFileDescriptor(
164
163
for (ServiceDescriptor serviceDescriptor : fd.getServices())
165
164
registerService(context, serviceDescriptor, packageName);
166
165
166
+
RubyFileDescriptor rfd =
167
+
(RubyFileDescriptor) RubyFileDescriptor.getRubyFileDescriptor(context, fd);
168
+
RubyString name = context.runtime.newString(fd.getName());
169
+
symtab.put(name, rfd);
170
+
167
171
// Mark this as a loaded file
168
172
fileDescriptors.add(fd);
169
173
}
Original file line number Diff line number Diff line change
@@ -560,6 +560,13 @@ def test_file_descriptor
560
560
assert_equal "basic_test.proto", file_descriptor.name
561
561
end
562
562
563
+
def test_lookup_filename
564
+
file_descriptor = Google::Protobuf::DescriptorPool.generated_pool.lookup 'basic_test.proto'
565
+
refute_nil file_descriptor
566
+
assert_kind_of Google::Protobuf::FileDescriptor, file_descriptor
567
+
assert_equal "basic_test.proto", file_descriptor.name
568
+
end
569
+
563
570
def test_map_freeze
564
571
m = proto_module::MapMessage.new
565
572
m.map_string_int32['a'] = 5
Original file line number Diff line number Diff line change
@@ -46,8 +46,8 @@ UPB_API const upb_EnumDef* upb_DefPool_FindEnumByName(const upb_DefPool* s,
46
46
const upb_EnumValueDef* upb_DefPool_FindEnumByNameval(const upb_DefPool* s,
47
47
const char* sym);
48
48
49
-
const upb_FileDef* upb_DefPool_FindFileByName(const upb_DefPool* s,
50
-
const char* name);
49
+
UPB_API const upb_FileDef* upb_DefPool_FindFileByName(const upb_DefPool* s,
50
+
const char* name);
51
51
52
52
const upb_FileDef* upb_DefPool_FindFileByNameWithSize(const upb_DefPool* s,
53
53
const char* name,
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4