rbs_protobuf 0.3.0 → 1.0.0

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.
@@ -1,3 +1,3 @@
1
1
  module RBSProtobuf
2
- VERSION = "0.3.0"
2
+ VERSION = "1.0.0"
3
3
  end
data/lib/rbs_protobuf.rb CHANGED
@@ -3,7 +3,7 @@ require "rbs_protobuf/version"
3
3
  require "logger"
4
4
 
5
5
  require "protobuf/descriptors"
6
- require "active_support/inflector"
6
+ require "active_support"
7
7
  require "rbs"
8
8
 
9
9
  module RBSProtobuf
@@ -14,6 +14,7 @@ module RBSProtobuf
14
14
  @logger = Logger.new(STDERR)
15
15
  end
16
16
 
17
+ require "rbs_protobuf/name"
17
18
  require "rbs_protobuf/rbs_factory"
18
19
  require "rbs_protobuf/translator/base"
19
20
  require "rbs_protobuf/translator/protobuf_gem"
@@ -7,7 +7,7 @@ sources:
7
7
  path: ".gem_rbs_collection"
8
8
  gems:
9
9
  - name: rbs
10
- version: 2.3.1
10
+ version: 2.3.2
11
11
  source:
12
12
  type: rubygems
13
13
  - name: activesupport
@@ -15,15 +15,7 @@ gems:
15
15
  source:
16
16
  type: git
17
17
  name: ruby/gem_rbs_collection
18
- revision: f43bb5ffee382df94113f44c7555027d7089912a
19
- remote: https://github.com/ruby/gem_rbs_collection.git
20
- repo_dir: gems
21
- - name: protobuf
22
- version: 3.10.3
23
- source:
24
- type: git
25
- name: ruby/gem_rbs_collection
26
- revision: f43bb5ffee382df94113f44c7555027d7089912a
18
+ revision: c7b9329222debd0b8a4a85c0ccdae6588fedd57a
27
19
  remote: https://github.com/ruby/gem_rbs_collection.git
28
20
  repo_dir: gems
29
21
  - name: ast
@@ -31,7 +23,7 @@ gems:
31
23
  source:
32
24
  type: git
33
25
  name: ruby/gem_rbs_collection
34
- revision: f43bb5ffee382df94113f44c7555027d7089912a
26
+ revision: c7b9329222debd0b8a4a85c0ccdae6588fedd57a
35
27
  remote: https://github.com/ruby/gem_rbs_collection.git
36
28
  repo_dir: gems
37
29
  - name: i18n
@@ -39,7 +31,7 @@ gems:
39
31
  source:
40
32
  type: git
41
33
  name: ruby/gem_rbs_collection
42
- revision: f43bb5ffee382df94113f44c7555027d7089912a
34
+ revision: c7b9329222debd0b8a4a85c0ccdae6588fedd57a
43
35
  remote: https://github.com/ruby/gem_rbs_collection.git
44
36
  repo_dir: gems
45
37
  - name: listen
@@ -47,7 +39,7 @@ gems:
47
39
  source:
48
40
  type: git
49
41
  name: ruby/gem_rbs_collection
50
- revision: f43bb5ffee382df94113f44c7555027d7089912a
42
+ revision: c7b9329222debd0b8a4a85c0ccdae6588fedd57a
51
43
  remote: https://github.com/ruby/gem_rbs_collection.git
52
44
  repo_dir: gems
53
45
  - name: parallel
@@ -55,7 +47,7 @@ gems:
55
47
  source:
56
48
  type: git
57
49
  name: ruby/gem_rbs_collection
58
- revision: f43bb5ffee382df94113f44c7555027d7089912a
50
+ revision: c7b9329222debd0b8a4a85c0ccdae6588fedd57a
59
51
  remote: https://github.com/ruby/gem_rbs_collection.git
60
52
  repo_dir: gems
61
53
  - name: rainbow
@@ -63,7 +55,7 @@ gems:
63
55
  source:
64
56
  type: git
65
57
  name: ruby/gem_rbs_collection
66
- revision: f43bb5ffee382df94113f44c7555027d7089912a
58
+ revision: c7b9329222debd0b8a4a85c0ccdae6588fedd57a
67
59
  remote: https://github.com/ruby/gem_rbs_collection.git
68
60
  repo_dir: gems
69
61
  - name: logger
data/rbs_collection.yaml CHANGED
@@ -14,5 +14,6 @@ gems:
14
14
  - name: rbs
15
15
  - name: activesupport
16
16
  - name: protobuf
17
+ ignore: true
17
18
  - name: rbs_protobuf
18
19
  ignore: true
@@ -0,0 +1,45 @@
1
+ module RBSProtobuf
2
+ module Name
3
+ class Class
4
+ attr_reader name: RBS::TypeName
5
+
6
+ def initialize: (RBS::TypeName) -> void
7
+
8
+ def instance_type: (*RBS::Types::t args) -> RBS::Types::ClassInstance
9
+
10
+ def singleton_type: () -> RBS::Types::ClassSingleton
11
+
12
+ def instance_type?: (RBS::Types::t) -> bool
13
+
14
+ def singleton_type?: (RBS::Types::t) -> bool
15
+
16
+ alias [] instance_type
17
+
18
+ def super_class: (*RBS::Types::t args) -> RBS::AST::Declarations::Class::Super
19
+ end
20
+
21
+ class Alias
22
+ attr_reader name: RBS::TypeName
23
+
24
+ def initialize: (RBS::TypeName) -> void
25
+
26
+ def []: (*RBS::Types::t args) -> RBS::Types::Alias
27
+
28
+ def type?: (RBS::Types::t) -> bool
29
+
30
+ alias === type?
31
+ end
32
+
33
+ class Interface
34
+ attr_reader name: RBS::TypeName
35
+
36
+ def initialize: (RBS::TypeName) -> void
37
+
38
+ def []: (*RBS::Types::t args) -> RBS::Types::Interface
39
+
40
+ def type?: (RBS::Types::t) -> bool
41
+
42
+ alias === type?
43
+ end
44
+ end
45
+ end
@@ -1,53 +1,122 @@
1
1
  module RBSProtobuf
2
2
  module Translator
3
3
  class ProtobufGem < Base
4
+ # Protobuf::Field::FieldArray[R, W]
5
+ FIELD_ARRAY: Name::Class
6
+
7
+ # Protobuf::Field::FieldHash[K, RV, WV]
8
+ FIELD_HASH: Name::Class
9
+
10
+ # Protobuf::Enum
11
+ ENUM: Name::Class
12
+
13
+ # Protobuf::Message
14
+ MESSAGE: Name::Class
15
+
16
+ # _ToProto
17
+ TO_PROTO: Name::Interface
18
+
19
+ # Protobuf::field_array[T]
20
+ FIELD_ARRAY_a: Name::Alias
21
+
22
+ # Protobuf::field_hash[K, V]
23
+ FIELD_HASH_a: Name::Alias
24
+
4
25
  attr_reader stderr: IO
5
26
 
27
+ attr_reader accept_nil_writer: bool
28
+
6
29
  def initialize: (
7
30
  untyped input,
8
31
  upcase_enum: bool,
9
32
  nested_namespace: bool,
10
33
  extension: bool | :print | nil,
11
- ?stderr: IO
34
+ accept_nil_writer: bool,
35
+ ?stderr: IO,
12
36
  ) -> void
13
37
 
14
38
  @upcase_enum: bool
15
39
 
16
- @pnested_namespace: bool
40
+ @nested_namespace: bool
17
41
 
18
42
  @extension: bool | :print | nil
19
43
 
44
+ # Returns true if extension should be ignored.
45
+ #
20
46
  def ignore_extension?: () -> bool
21
47
 
48
+ # Returns true if documentation message about extension is requested.
22
49
  def print_extension_message?: () -> bool
23
50
 
51
+ # Returns true if extension should be printed to stderr.
52
+ #
24
53
  def print_extension?: () -> bool
25
54
 
55
+ # Returns true if enum names should be `upcase`.
56
+ #
26
57
  def upcase_enum?: () -> bool
27
58
 
59
+ # Returns true if printing nested namespace is preferred.
60
+ #
28
61
  def nested_namespace?: () -> bool
29
62
 
63
+ # The entry point.
64
+ # Generate RBS declarations from the `file` and returns the string representation of the declarations.
65
+ #
30
66
  def rbs_content: (untyped file) -> String
31
67
 
32
- def message_base_class: () -> RBS::AST::Declarations::Class::Super
68
+ # Returns the class declaration for given message.
69
+ #
70
+ def message_to_decl: (untyped message, prefix: RBS::Namespace, message_path: untyped, source_code_info: untyped, path: Array[Integer]) -> RBS::AST::Declarations::Class
33
71
 
34
- def repeated_field_type: (RBS::Types::t `type`, ?RBS::Types::t wtype) -> RBS::Types::ClassInstance
72
+ # Returns the class declaration for given enum.
73
+ #
74
+ def enum_type_to_decl: (untyped enum_type, prefix: RBS::Namespace, source_code_info: untyped, path: Array[Integer]) -> RBS::AST::Declarations::Class
35
75
 
36
- def message_to_decl: (untyped message, prefix: RBS::Namespace, message_path: untyped, source_code_info: untyped, path: Array[Integer]) -> RBS::AST::Declarations::Class
76
+ # Returns the class declaration for given extension.
77
+ #
78
+ def extension_to_decl: (untyped extension, prefix: RBS::Namespace, source_code_info: untyped, path: Array[Integer]) -> RBS::AST::Declarations::Class
37
79
 
38
- def field_type: (untyped field, Hash[String, [RBS::Types::t, RBS::Types::t]] maps) -> [RBS::Types::t, RBS::Types::t]
80
+ # Returns service class stub.
81
+ #
82
+ def service_to_decl: (untyped service, prefix: RBS::Namespace, source_code_info: untyped, path: Array[Integer]) -> RBS::AST::Declarations::Class
83
+
84
+ # Returns a triple of types of a field.
85
+ #
86
+ # - The first one is the type of the attribute. (read and write)
87
+ # - The second one is the array of type of additional possibilities for write.
88
+ # - The last one is the type of `initialize` parameter.
89
+ #
90
+ def field_type: (untyped field, Hash[String, [untyped, untyped]] maps) -> [RBS::Types::t, Array[RBS::Types::t], RBS::Types::t]
91
+
92
+ def message_to_proto_type: (RBS::Types::ClassInstance) -> RBS::Types::Interface
93
+
94
+ def message_array_type: (RBS::Types::ClassInstance) -> RBS::Types::Alias
95
+
96
+ def message_field_array_type: (RBS::Types::ClassInstance) -> RBS::Types::Alias
39
97
 
40
- def enum_base_class: () -> RBS::AST::Declarations::Class::Super
98
+ def message_hash_type: (RBS::Types::ClassInstance, RBS::Types::t key) -> RBS::Types::Alias
41
99
 
100
+ def message_field_hash_type: (RBS::Types::ClassInstance, RBS::Types::t key) -> RBS::Types::Alias
101
+
102
+ def message_init_type: (RBS::Types::ClassInstance) -> RBS::Types::Alias
103
+
104
+ # Returns enum names with respect to `#upcase_enum?`.
105
+ #
42
106
  def enum_name: (String name) -> Symbol
43
107
 
44
- def enum_type_to_decl: (untyped enum_type, prefix: RBS::Namespace, source_code_info: untyped, path: Array[Integer]) -> RBS::AST::Declarations::Class
108
+ # Add field to `members`. It adds
109
+ #
110
+ # - `attr_accessor` of the field `name` with `read_type`
111
+ # - Overloads for attribute writer with `write_types`
112
+ #
113
+ def add_field: (Array[RBS::AST::Declarations::Class::member] members, name: Symbol, read_type: RBS::Types::t, write_types: Array[RBS::Types::t], comment: RBS::AST::Comment?) -> void
45
114
 
46
- def extension_to_decl: (String extendee_name, Array[untyped] extensions, prefix: RBS::Namespace, source_code_info: untyped, path: Array[Integer]) -> Array[RBS::AST::Declarations::Class]
115
+ # Returns true if `write_type` is an _interface type_ or an optional type of _interface type_.
116
+ #
117
+ def interface_type?: (RBS::Types::t write_type) -> [RBS::AST::TypeParam, RBS::Types::t]?
47
118
 
48
119
  def service_base_class: () -> RBS::AST::Declarations::Class::Super
49
-
50
- def service_to_decl: (untyped service, prefix: RBS::Namespace, source_code_info: untyped, path: Array[Integer]) -> RBS::AST::Declarations::Class
51
120
  end
52
121
  end
53
122
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs_protobuf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-05 00:00:00.000000000 Z
11
+ date: 2022-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbs
@@ -72,6 +72,7 @@ files:
72
72
  - example/protobuf_gem_example.rb
73
73
  - exe/protoc-gen-rbs
74
74
  - lib/rbs_protobuf.rb
75
+ - lib/rbs_protobuf/name.rb
75
76
  - lib/rbs_protobuf/rbs_factory.rb
76
77
  - lib/rbs_protobuf/translator/base.rb
77
78
  - lib/rbs_protobuf/translator/protobuf_gem.rb
@@ -80,6 +81,7 @@ files:
80
81
  - rbs_collection.yaml
81
82
  - rbs_protobuf.gemspec
82
83
  - sig/rbs_protobuf.rbs
84
+ - sig/rbs_protobuf/name.rbs
83
85
  - sig/rbs_protobuf/rbs_factory.rbs
84
86
  - sig/rbs_protobuf/translator/base.rbs
85
87
  - sig/rbs_protobuf/translator/protobuf_gem.rbs