@@ -21,12 +21,7 @@ class PayloadVisitorGen
2121 #
2222 # @return [String] File code.
2323 def gen_file_code
24- # Collect all the methods of all the classes
25- methods = { }
26- DESCRIPTORS . each do |name |
27- desc = Google ::Protobuf ::DescriptorPool . generated_pool . lookup ( name ) or raise "Unknown name: #{ name } "
28- walk_desc ( desc :, methods :)
29- end
24+ methods = payload_methods
3025
3126 # Build the code for each method
3227 method_bodies = methods . map do |_ , method_hash |
@@ -108,7 +103,7 @@ def initialize(
108103 # @param value [Google::Protobuf::Message] Message to visit.
109104 def run(value)
110105 return unless value.is_a?(Google::Protobuf::MessageExts)
111- method_name = method_name_from_proto_name(value.class.descriptor.name)
106+ method_name = method_name_from_proto_name(value.class.descriptor.name) # steep:ignore NoMethod
112107 send(method_name, value) if respond_to?(method_name, true)
113108 nil
114109 end
@@ -158,8 +153,54 @@ def google_protobuf_any(value)
158153 TEXT
159154 end
160155
156+ # Generate file signature.
157+ #
158+ # @return [String] File signature.
159+ def gen_rbs_code
160+ method_defs = payload_methods . filter_map do |_ , method_hash |
161+ next if method_hash [ :fields ] . empty?
162+
163+ "def #{ method_name_from_desc ( method_hash [ :desc ] ) } : (untyped value) -> void"
164+ end . sort
165+
166+ <<~TEXT
167+ module Temporalio
168+ module Api
169+ class PayloadVisitor
170+ def initialize: (
171+ ?on_enter: untyped,
172+ ?on_exit: untyped,
173+ ?skip_search_attributes: bool,
174+ ?traverse_any: bool
175+ ) { (untyped) -> untyped } -> void
176+ def run: (untyped value) -> nil
177+ def _run_activation: (untyped value) -> void
178+ def _run_activation_completion: (untyped value) -> void
179+
180+ private
181+
182+ def method_name_from_proto_name: (::String name) -> ::String
183+ def api_common_v1_payload: (untyped value) -> untyped
184+ def api_common_v1_payload_repeated: (untyped value) -> untyped
185+ def google_protobuf_any: (untyped value) -> void
186+ #{ method_defs . join ( "\n " ) }
187+ end
188+ end
189+ end
190+ TEXT
191+ end
192+
161193 private
162194
195+ def payload_methods
196+ methods = { }
197+ DESCRIPTORS . each do |name |
198+ desc = Google ::Protobuf ::DescriptorPool . generated_pool . lookup ( name ) or raise "Unknown name: #{ name } "
199+ walk_desc ( desc :, methods :)
200+ end
201+ methods
202+ end
203+
163204 def walk_desc ( desc :, methods :)
164205 case desc
165206 when Google ::Protobuf ::ServiceDescriptor
0 commit comments