rbs 4.0.0.dev.2 → 4.0.0.dev.3
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.
- checksums.yaml +4 -4
- data/.clang-format +74 -0
- data/.clangd +2 -0
- data/.github/workflows/c-check.yml +51 -0
- data/.github/workflows/dependabot.yml +1 -1
- data/.github/workflows/ruby.yml +0 -17
- data/.github/workflows/typecheck.yml +0 -2
- data/.gitignore +4 -0
- data/.rubocop.yml +1 -1
- data/.vscode/extensions.json +5 -0
- data/.vscode/settings.json +19 -0
- data/README.md +37 -0
- data/Rakefile +82 -0
- data/config.yml +1 -1
- data/core/enumerable.rbs +9 -0
- data/core/io.rbs +4 -4
- data/core/thread.rbs +0 -7
- data/ext/rbs_extension/ast_translation.c +1008 -1074
- data/ext/rbs_extension/class_constants.c +78 -74
- data/ext/rbs_extension/compat.h +3 -3
- data/ext/rbs_extension/extconf.rb +11 -1
- data/ext/rbs_extension/legacy_location.c +173 -172
- data/ext/rbs_extension/legacy_location.h +3 -3
- data/ext/rbs_extension/main.c +315 -273
- data/include/rbs/ast.h +11 -12
- data/include/rbs/defines.h +11 -12
- data/include/rbs/lexer.h +105 -105
- data/include/rbs/location.h +14 -14
- data/include/rbs/parser.h +21 -19
- data/include/rbs/string.h +3 -3
- data/include/rbs/util/rbs_allocator.h +14 -14
- data/include/rbs/util/rbs_constant_pool.h +3 -3
- data/include/rbs/util/rbs_encoding.h +1 -1
- data/lib/rbs/environment.rb +4 -0
- data/lib/rbs/namespace.rb +0 -7
- data/lib/rbs/parser_aux.rb +5 -0
- data/lib/rbs/type_name.rb +0 -7
- data/lib/rbs/types.rb +3 -1
- data/lib/rbs/unit_test/convertibles.rb +1 -0
- data/lib/rbs/version.rb +1 -1
- data/sig/environment.rbs +3 -0
- data/sig/namespace.rbs +0 -5
- data/sig/parser.rbs +20 -0
- data/sig/typename.rbs +0 -5
- data/sig/types.rbs +4 -1
- data/src/ast.c +216 -214
- data/src/lexer.c +2923 -2675
- data/src/lexstate.c +155 -155
- data/src/location.c +40 -40
- data/src/parser.c +2591 -2586
- data/src/string.c +2 -2
- data/src/util/rbs_allocator.c +7 -9
- data/src/util/rbs_assert.c +9 -9
- data/src/util/rbs_constant_pool.c +5 -7
- data/src/util/rbs_encoding.c +20095 -4056
- data/src/util/rbs_unescape.c +33 -32
- data/stdlib/json/0/json.rbs +9 -43
- data/stdlib/ripper/0/ripper.rbs +3 -0
- data/stdlib/socket/0/addrinfo.rbs +2 -2
- metadata +7 -2
data/src/util/rbs_unescape.c
CHANGED
@@ -6,26 +6,26 @@
|
|
6
6
|
// Define the escape character mappings
|
7
7
|
// TODO: use a switch instead
|
8
8
|
static const struct {
|
9
|
-
const char*
|
10
|
-
const char*
|
9
|
+
const char *from;
|
10
|
+
const char *to;
|
11
11
|
} TABLE[] = {
|
12
|
-
{"\\a", "\a"},
|
13
|
-
{"\\b", "\b"},
|
14
|
-
{"\\e", "\033"},
|
15
|
-
{"\\f", "\f"},
|
16
|
-
{"\\n", "\n"},
|
17
|
-
{"\\r", "\r"},
|
18
|
-
{"\\s", " "},
|
19
|
-
{"\\t", "\t"},
|
20
|
-
{"\\v", "\v"},
|
21
|
-
{"\\\"", "\""},
|
22
|
-
{"\\'", "'"},
|
23
|
-
{"\\\\", "\\"},
|
24
|
-
{"\\", ""}
|
12
|
+
{ "\\a", "\a" },
|
13
|
+
{ "\\b", "\b" },
|
14
|
+
{ "\\e", "\033" },
|
15
|
+
{ "\\f", "\f" },
|
16
|
+
{ "\\n", "\n" },
|
17
|
+
{ "\\r", "\r" },
|
18
|
+
{ "\\s", " " },
|
19
|
+
{ "\\t", "\t" },
|
20
|
+
{ "\\v", "\v" },
|
21
|
+
{ "\\\"", "\"" },
|
22
|
+
{ "\\'", "'" },
|
23
|
+
{ "\\\\", "\\" },
|
24
|
+
{ "\\", "" }
|
25
25
|
};
|
26
26
|
|
27
27
|
// Helper function to convert hex string to integer
|
28
|
-
static int hex_to_int(const char*
|
28
|
+
static int hex_to_int(const char *hex, int length) {
|
29
29
|
int result = 0;
|
30
30
|
for (int i = 0; i < length; i++) {
|
31
31
|
result = result * 16 + (isdigit(hex[i]) ? hex[i] - '0' : tolower(hex[i]) - 'a' + 10);
|
@@ -34,7 +34,7 @@ static int hex_to_int(const char* hex, int length) {
|
|
34
34
|
}
|
35
35
|
|
36
36
|
// Helper function to convert octal string to integer
|
37
|
-
static int octal_to_int(const char*
|
37
|
+
static int octal_to_int(const char *octal, int length) {
|
38
38
|
int result = 0;
|
39
39
|
for (int i = 0; i < length; i++) {
|
40
40
|
result = result * 8 + (octal[i] - '0');
|
@@ -54,32 +54,33 @@ rbs_string_t unescape_string(rbs_allocator_t *allocator, const rbs_string_t stri
|
|
54
54
|
if (!string.start) return RBS_STRING_NULL;
|
55
55
|
|
56
56
|
size_t len = string.end - string.start;
|
57
|
-
const char*
|
57
|
+
const char *input = string.start;
|
58
58
|
|
59
|
-
char*
|
59
|
+
char *output = rbs_allocator_alloc_many(allocator, len + 1, char);
|
60
60
|
if (!output) return RBS_STRING_NULL;
|
61
61
|
|
62
62
|
size_t i = 0, j = 0;
|
63
63
|
while (i < len) {
|
64
64
|
if (input[i] == '\\' && i + 1 < len) {
|
65
65
|
if (is_double_quote) {
|
66
|
-
if (isdigit(input[i+1])) {
|
66
|
+
if (isdigit(input[i + 1])) {
|
67
67
|
// Octal escape
|
68
68
|
int octal_len = 1;
|
69
|
-
while (octal_len < 3 && i + 1 + octal_len < len && isdigit(input[i + 1 + octal_len]))
|
69
|
+
while (octal_len < 3 && i + 1 + octal_len < len && isdigit(input[i + 1 + octal_len]))
|
70
|
+
octal_len++;
|
70
71
|
int value = octal_to_int(input + i + 1, octal_len);
|
71
|
-
output[j++] = (char)value;
|
72
|
+
output[j++] = (char) value;
|
72
73
|
i += octal_len + 1;
|
73
|
-
} else if (input[i+1] == 'x' && i + 3 < len) {
|
74
|
+
} else if (input[i + 1] == 'x' && i + 3 < len) {
|
74
75
|
// Hex escape
|
75
|
-
int hex_len = isxdigit(input[i+3]) ? 2 : 1;
|
76
|
+
int hex_len = isxdigit(input[i + 3]) ? 2 : 1;
|
76
77
|
int value = hex_to_int(input + i + 2, hex_len);
|
77
|
-
output[j++] = (char)value;
|
78
|
+
output[j++] = (char) value;
|
78
79
|
i += hex_len + 2;
|
79
|
-
} else if (input[i+1] == 'u' && i + 5 < len) {
|
80
|
+
} else if (input[i + 1] == 'u' && i + 5 < len) {
|
80
81
|
// Unicode escape
|
81
82
|
int value = hex_to_int(input + i + 2, 4);
|
82
|
-
output[j++] = (char)value;
|
83
|
+
output[j++] = (char) value;
|
83
84
|
i += 6;
|
84
85
|
} else {
|
85
86
|
// Other escapes
|
@@ -98,8 +99,8 @@ rbs_string_t unescape_string(rbs_allocator_t *allocator, const rbs_string_t stri
|
|
98
99
|
}
|
99
100
|
} else {
|
100
101
|
/* Single quote: only escape ' and \ */
|
101
|
-
if (input[i+1] == '\'' || input[i+1] == '\\') {
|
102
|
-
output[j++] = input[i+1];
|
102
|
+
if (input[i + 1] == '\'' || input[i + 1] == '\\') {
|
103
|
+
output[j++] = input[i + 1];
|
103
104
|
i += 2;
|
104
105
|
} else {
|
105
106
|
output[j++] = input[i++];
|
@@ -119,9 +120,9 @@ rbs_string_t rbs_unquote_string(rbs_allocator_t *allocator, rbs_string_t input)
|
|
119
120
|
|
120
121
|
ptrdiff_t start_offset = 0;
|
121
122
|
if (first_char == '"' || first_char == '\'' || first_char == '`') {
|
122
|
-
|
123
|
-
|
124
|
-
|
123
|
+
int bs = rbs_utf8_codelen(first_char);
|
124
|
+
start_offset += bs;
|
125
|
+
byte_length -= 2 * bs;
|
125
126
|
}
|
126
127
|
|
127
128
|
const char *new_start = input.start + start_offset;
|
data/stdlib/json/0/json.rbs
CHANGED
@@ -14,9 +14,6 @@ end
|
|
14
14
|
class JSON::GeneratorError < JSON::JSONError
|
15
15
|
end
|
16
16
|
|
17
|
-
class JSON::UnparserError < JSON::GeneratorError
|
18
|
-
end
|
19
|
-
|
20
17
|
# <!-- rdoc-file=ext/json/lib/json/common.rb -->
|
21
18
|
# This exception is raised if a parser error occurs.
|
22
19
|
#
|
@@ -754,6 +751,7 @@ module JSON
|
|
754
751
|
# opts = JSON.dump_default_options
|
755
752
|
# opts # => {:max_nesting=>false, :allow_nan=>true}
|
756
753
|
#
|
754
|
+
%a{deprecated}
|
757
755
|
def self.dump_default_options: () -> options
|
758
756
|
|
759
757
|
# <!-- rdoc-file=ext/json/lib/json/common.rb -->
|
@@ -761,6 +759,7 @@ module JSON
|
|
761
759
|
# opts = JSON.dump_default_options
|
762
760
|
# opts # => {:max_nesting=>false, :allow_nan=>true}
|
763
761
|
#
|
762
|
+
%a{deprecated}
|
764
763
|
def self.dump_default_options=: (options) -> options
|
765
764
|
|
766
765
|
# <!--
|
@@ -778,12 +777,9 @@ module JSON
|
|
778
777
|
# # Raises SystemStackError (stack level too deep):
|
779
778
|
# JSON.fast_generate(a)
|
780
779
|
#
|
780
|
+
%a{deprecated}
|
781
781
|
def self?.fast_generate: (_ToJson obj, ?options opts) -> String
|
782
782
|
|
783
|
-
alias self.fast_unparse self.fast_generate
|
784
|
-
|
785
|
-
alias fast_unparse fast_generate
|
786
|
-
|
787
783
|
# <!--
|
788
784
|
# rdoc-file=ext/json/lib/json/common.rb
|
789
785
|
# - JSON.generate(obj, opts = nil) -> new_string
|
@@ -830,14 +826,6 @@ module JSON
|
|
830
826
|
|
831
827
|
def self.generator=: (generator generator) -> void
|
832
828
|
|
833
|
-
# <!--
|
834
|
-
# rdoc-file=ext/json/lib/json/common.rb
|
835
|
-
# - iconv(to, from, string)
|
836
|
-
# -->
|
837
|
-
# Encodes string using String.encode.
|
838
|
-
#
|
839
|
-
def self.iconv: (encoding to, encoding from, String string) -> String
|
840
|
-
|
841
829
|
# <!--
|
842
830
|
# rdoc-file=ext/json/lib/json/common.rb
|
843
831
|
# - JSON.load(source, proc = nil, options = {}) -> object
|
@@ -974,7 +962,8 @@ module JSON
|
|
974
962
|
# #<Admin:0x00000000064c41f8
|
975
963
|
# @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
|
976
964
|
#
|
977
|
-
def self?.load: (string | _ReadableIO | _Read source, ?
|
965
|
+
def self?.load: (string | _ReadableIO | _Read source, ?options options) -> untyped
|
966
|
+
| [T] (string | _ReadableIO | _Read source, ^(?) -> T, ?options options) -> T
|
978
967
|
|
979
968
|
# <!--
|
980
969
|
# rdoc-file=ext/json/lib/json/common.rb
|
@@ -1003,6 +992,7 @@ module JSON
|
|
1003
992
|
# opts = JSON.load_default_options
|
1004
993
|
# opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
|
1005
994
|
#
|
995
|
+
%a{deprecated}
|
1006
996
|
def self.load_default_options: () -> options
|
1007
997
|
|
1008
998
|
# <!-- rdoc-file=ext/json/lib/json/common.rb -->
|
@@ -1010,6 +1000,7 @@ module JSON
|
|
1010
1000
|
# opts = JSON.load_default_options
|
1011
1001
|
# opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
|
1012
1002
|
#
|
1003
|
+
%a{deprecated}
|
1013
1004
|
def self.load_default_options=: (options) -> options
|
1014
1005
|
|
1015
1006
|
# <!--
|
@@ -1120,29 +1111,6 @@ module JSON
|
|
1120
1111
|
#
|
1121
1112
|
def self?.pretty_generate: (_ToJson obj, ?options opts) -> untyped
|
1122
1113
|
|
1123
|
-
alias self.pretty_unparse self.pretty_generate
|
1124
|
-
|
1125
|
-
alias pretty_unparse pretty_generate
|
1126
|
-
|
1127
|
-
# Recursively calls passed *Proc* if the parsed data structure is an *Array* or
|
1128
|
-
# *Hash*
|
1129
|
-
#
|
1130
|
-
def self?.recurse_proc: (untyped result) { (*untyped) -> void } -> void
|
1131
|
-
|
1132
|
-
# <!--
|
1133
|
-
# rdoc-file=ext/json/lib/json/common.rb
|
1134
|
-
# - restore(source, proc = nil, options = nil)
|
1135
|
-
# -->
|
1136
|
-
#
|
1137
|
-
alias self.restore self.load
|
1138
|
-
|
1139
|
-
# <!--
|
1140
|
-
# rdoc-file=ext/json/lib/json/common.rb
|
1141
|
-
# - restore(source, proc = nil, options = nil)
|
1142
|
-
# -->
|
1143
|
-
#
|
1144
|
-
alias restore load
|
1145
|
-
|
1146
1114
|
# <!-- rdoc-file=ext/json/lib/json/common.rb -->
|
1147
1115
|
# Sets or Returns the JSON generator state class that is used by JSON.
|
1148
1116
|
#
|
@@ -1152,10 +1120,6 @@ module JSON
|
|
1152
1120
|
# Sets or Returns the JSON generator state class that is used by JSON.
|
1153
1121
|
#
|
1154
1122
|
def self.state=: (state) -> state
|
1155
|
-
|
1156
|
-
alias self.unparse self.generate
|
1157
|
-
|
1158
|
-
alias unparse generate
|
1159
1123
|
end
|
1160
1124
|
|
1161
1125
|
JSON::FAST_STATE_PROTOTYPE: JSON::state
|
@@ -1193,6 +1157,7 @@ module Kernel
|
|
1193
1157
|
# Outputs *objs* to STDOUT as JSON strings in the shortest form, that is in one
|
1194
1158
|
# line.
|
1195
1159
|
#
|
1160
|
+
%a{deprecated}
|
1196
1161
|
def j: (*_ToJson) -> nil
|
1197
1162
|
|
1198
1163
|
# <!--
|
@@ -1202,6 +1167,7 @@ module Kernel
|
|
1202
1167
|
# Outputs *objs* to STDOUT as JSON strings in a pretty format, with indentation
|
1203
1168
|
# and over many lines.
|
1204
1169
|
#
|
1170
|
+
%a{deprecated}
|
1205
1171
|
def jj: (*_ToJson) -> nil
|
1206
1172
|
|
1207
1173
|
# <!--
|
data/stdlib/ripper/0/ripper.rbs
CHANGED
@@ -911,6 +911,7 @@ class Ripper
|
|
911
911
|
|
912
912
|
class CompileError < Error
|
913
913
|
end
|
914
|
+
|
914
915
|
class Error < StandardError
|
915
916
|
end
|
916
917
|
|
@@ -927,6 +928,7 @@ class Ripper
|
|
927
928
|
|
928
929
|
def match: (?untyped n) -> untyped
|
929
930
|
end
|
931
|
+
|
930
932
|
class MatchError < Error
|
931
933
|
end
|
932
934
|
alias self.compile self.new
|
@@ -949,6 +951,7 @@ class Ripper
|
|
949
951
|
|
950
952
|
def map_tokens: (untyped tokens) -> untyped
|
951
953
|
end
|
954
|
+
|
952
955
|
interface _Gets
|
953
956
|
def gets: (?String sep, ?Integer limit) -> String?
|
954
957
|
end
|
@@ -61,8 +61,8 @@ class Addrinfo
|
|
61
61
|
# #=> [#<Addrinfo: 203.178.141.194:80 TCP (www.kame.net)>,
|
62
62
|
# # #<Addrinfo: [2001:200:dff:fff1:216:3eff:feb1:44d7]:80 TCP (www.kame.net)>]
|
63
63
|
#
|
64
|
-
def self.getaddrinfo: (String nodename, ?String | Integer
|
65
|
-
| (String? nodename, ?String | Integer service, ?Symbol? family, ?Symbol | Integer protocol) -> Array[Addrinfo]
|
64
|
+
def self.getaddrinfo: (String nodename, ?(String | Integer)? service, ?(Symbol | Integer)? family, ?Symbol | Integer protocol) -> Array[Addrinfo]
|
65
|
+
| (String? nodename, ?(String | Integer) service, ?(Symbol | Integer)? family, ?Symbol | Integer protocol) -> Array[Addrinfo]
|
66
66
|
|
67
67
|
# <!--
|
68
68
|
# rdoc-file=ext/socket/raddrinfo.c
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0.dev.
|
4
|
+
version: 4.0.0.dev.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Soutaro Matsumoto
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-05-
|
10
|
+
date: 2025-05-19 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: logger
|
@@ -47,7 +47,10 @@ extensions:
|
|
47
47
|
- ext/rbs_extension/extconf.rb
|
48
48
|
extra_rdoc_files: []
|
49
49
|
files:
|
50
|
+
- ".clang-format"
|
51
|
+
- ".clangd"
|
50
52
|
- ".github/dependabot.yml"
|
53
|
+
- ".github/workflows/c-check.yml"
|
51
54
|
- ".github/workflows/comments.yml"
|
52
55
|
- ".github/workflows/dependabot.yml"
|
53
56
|
- ".github/workflows/ruby.yml"
|
@@ -55,6 +58,8 @@ files:
|
|
55
58
|
- ".github/workflows/windows.yml"
|
56
59
|
- ".gitignore"
|
57
60
|
- ".rubocop.yml"
|
61
|
+
- ".vscode/extensions.json"
|
62
|
+
- ".vscode/settings.json"
|
58
63
|
- BSDL
|
59
64
|
- CHANGELOG.md
|
60
65
|
- COPYING
|