ruby-ll 2.1.3-java → 2.2.0-java

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89c182ef352e839ecfda2b083ec8b4ac45b7a4e12883f95b68415f0a5e35fa00
4
- data.tar.gz: cd225a0d1500d4d53b6b9fed8d32a126f06686516d5d9c017f09a2844212cd07
3
+ metadata.gz: f34724cfa8c34362c0c81b731b4ccbe159a1f956e3826de7cc99daf7352397b6
4
+ data.tar.gz: c2450f17e31cd2950b1cca5aa596f942956111c41eb42c8f8e94589096c0bc9e
5
5
  SHA512:
6
- metadata.gz: f66efe32f78dc0e1436b3c342b049e7f648289f822cceb1b0f6d56267389a339aa346f0f8fc3c5efc60d8946a1fb435072f87961690bb80186f0257b7f1232c8
7
- data.tar.gz: 3c2860799c225dd8b6d0be7d98f99beaa780a147cbb11b073f00a6e5c881dd645b46607a2b0141bf8843fb78039ff90fd2f7ed95068887646f3d18b2955c211f
6
+ metadata.gz: 859daa58b50ddccb37b9b3ad7ae626c206c0f79df9a7efd23472b7b187fa5a8313696ed59b14fbec6ec98e039fb9caa31a84398ff504737ce2d17751e90d8971
7
+ data.tar.gz: 130b75ab55334a129f136070557743988481c7bc617b1e28e8e9ed512d9612035744abfda37f8c62682f0e8924200df34cd179b4ab50e0ec1f1d75eba74f0a49
data/ext/c/driver.c CHANGED
@@ -21,8 +21,10 @@ ID id_parser_error;
21
21
  * This function is called automatically when a Driver instance is garbage
22
22
  * collected.
23
23
  */
24
- void ll_driver_free(DriverState *state)
24
+ void ll_driver_free(void *data)
25
25
  {
26
+ DriverState *state = data;
27
+
26
28
  kv_destroy(state->stack);
27
29
  kv_destroy(state->value_stack);
28
30
 
@@ -33,9 +35,10 @@ void ll_driver_free(DriverState *state)
33
35
  * Marks the objects stored in the driver's internal state, preventing them from
34
36
  * being garbage collected until the next GC run.
35
37
  */
36
- void ll_driver_mark(DriverState *state)
38
+ void ll_driver_mark(void *data)
37
39
  {
38
40
  size_t index;
41
+ DriverState *state = data;
39
42
 
40
43
  FOR(index, kv_size(state->value_stack))
41
44
  {
@@ -43,30 +46,61 @@ void ll_driver_mark(DriverState *state)
43
46
  }
44
47
  }
45
48
 
49
+ static const rb_data_type_t ll_driver_type = {
50
+ "LL::Driver",
51
+ {
52
+ ll_driver_mark,
53
+ ll_driver_free,
54
+ NULL,
55
+ },
56
+ NULL,
57
+ NULL,
58
+ RUBY_TYPED_FREE_IMMEDIATELY,
59
+ };
60
+
46
61
  /**
47
62
  * Allocates a new instance of the Driver class and prepares its internal state.
48
63
  */
49
64
  VALUE ll_driver_allocate(VALUE klass)
50
65
  {
51
- DriverState *state = ALLOC(DriverState);
52
- VALUE config = rb_const_get(klass, id_config_const);
66
+ DriverState *state;
67
+ VALUE config;
68
+ VALUE obj = TypedData_Make_Struct(
69
+ klass,
70
+ DriverState,
71
+ &ll_driver_type,
72
+ state
73
+ );
53
74
 
54
- Data_Get_Struct(config, DriverConfig, state->config);
75
+ config = rb_const_get(klass, id_config_const);
76
+
77
+ TypedData_Get_Struct(config, DriverConfig, &ll_driver_config_type, state->config);
55
78
 
56
79
  kv_init(state->stack);
57
80
  kv_init(state->value_stack);
58
81
 
59
- return Data_Wrap_Struct(klass, ll_driver_mark, ll_driver_free, state);
82
+ return obj;
60
83
  }
61
84
 
62
85
  /**
63
- * Callback function for iterating over every input token and actually parsing
64
- * said input.
86
+ * Callback function for iterating over every input token and parsing it.
87
+ *
88
+ * This function is intended to be used as a block callback for Ruby's
89
+ * `rb_block_call`, and processes a single token per invocation.
65
90
  *
66
91
  * @param token An Array containing the token type as a Symbol and its value.
67
92
  * @param self The Driver instance currently in use.
93
+ * @param argc The number of additional arguments passed to the block.
94
+ * @param argv The array of additional arguments passed to the block.
95
+ * @param block_arg The block argument passed from Ruby (if any).
68
96
  */
69
- VALUE ll_driver_each_token(VALUE token, VALUE self)
97
+ VALUE ll_driver_each_token(
98
+ VALUE token,
99
+ VALUE self,
100
+ int argc,
101
+ const VALUE *argv,
102
+ VALUE block_arg
103
+ )
70
104
  {
71
105
  VALUE method;
72
106
  VALUE action_args;
@@ -89,7 +123,7 @@ VALUE ll_driver_each_token(VALUE token, VALUE self)
89
123
  VALUE type = rb_ary_entry(token, 0);
90
124
  VALUE value = rb_ary_entry(token, 1);
91
125
 
92
- Data_Get_Struct(self, DriverState, state);
126
+ TypedData_Get_Struct(self, DriverState, &ll_driver_type, state);
93
127
 
94
128
  while ( 1 )
95
129
  {
@@ -131,8 +165,8 @@ VALUE ll_driver_each_token(VALUE token, VALUE self)
131
165
  self,
132
166
  id_parser_error,
133
167
  4,
134
- INT2NUM(stack_type),
135
- INT2NUM(stack_value),
168
+ LONG2NUM(stack_type),
169
+ LONG2NUM(stack_value),
136
170
  type,
137
171
  value
138
172
  );
@@ -250,8 +284,8 @@ VALUE ll_driver_each_token(VALUE token, VALUE self)
250
284
  self,
251
285
  id_parser_error,
252
286
  4,
253
- INT2NUM(stack_type),
254
- INT2NUM(stack_value),
287
+ LONG2NUM(stack_type),
288
+ LONG2NUM(stack_value),
255
289
  type,
256
290
  value
257
291
  );
@@ -309,7 +343,7 @@ VALUE ll_driver_parse(VALUE self)
309
343
 
310
344
  DriverState *state;
311
345
 
312
- Data_Get_Struct(self, DriverState, state);
346
+ TypedData_Get_Struct(self, DriverState, &ll_driver_type, state);
313
347
 
314
348
  /* EOF rule */
315
349
  kv_push(long, state->stack, T_EOF);
@@ -326,7 +360,7 @@ VALUE ll_driver_parse(VALUE self)
326
360
  id_each_token,
327
361
  0,
328
362
  NULL,
329
- RUBY_METHOD_FUNC(ll_driver_each_token),
363
+ ll_driver_each_token,
330
364
  self
331
365
  );
332
366
 
@@ -1,11 +1,42 @@
1
1
  #include "driver_config.h"
2
2
 
3
+ void ll_driver_config_mark(void *data)
4
+ {
5
+ DriverConfig *config = data;
6
+
7
+ if ( config->terminals != NULL )
8
+ {
9
+ khint_t key;
10
+
11
+ for (
12
+ key = kh_begin(config->terminals);
13
+ key != kh_end(config->terminals);
14
+ key++
15
+ )
16
+ {
17
+ if ( kh_exist(config->terminals, key) )
18
+ {
19
+ rb_gc_mark((VALUE) kh_key(config->terminals, key));
20
+ }
21
+ }
22
+ }
23
+
24
+ if ( config->action_names != NULL )
25
+ {
26
+ rb_gc_mark_locations(
27
+ config->action_names,
28
+ config->action_names + config->actions_count
29
+ );
30
+ }
31
+ }
32
+
3
33
  /**
4
34
  * Releases memory of the DriverConfig struct and its members.
5
35
  */
6
- void ll_driver_config_free(DriverConfig *config)
36
+ void ll_driver_config_free(void *data)
7
37
  {
8
38
  long rindex;
39
+ DriverConfig *config = data;
9
40
 
10
41
  FOR(rindex, config->rules_count)
11
42
  {
@@ -23,22 +54,36 @@ void ll_driver_config_free(DriverConfig *config)
23
54
  free(config->action_names);
24
55
  free(config->action_arg_amounts);
25
56
 
26
- kh_destroy(int64_map, config->terminals);
57
+ if ( config->terminals != NULL )
58
+ {
59
+ kh_destroy(int64_map, config->terminals);
60
+ }
27
61
 
28
62
  free(config);
29
63
  }
30
64
 
65
+ const rb_data_type_t ll_driver_config_type = {
66
+ "LL::DriverConfig",
67
+ {
68
+ ll_driver_config_mark,
69
+ ll_driver_config_free,
70
+ NULL,
71
+ },
72
+ NULL,
73
+ NULL,
74
+ RUBY_TYPED_FREE_IMMEDIATELY,
75
+ };
76
+
31
77
  /**
32
78
  * Allocates a new DriverConfig.
33
79
  */
34
80
  VALUE ll_driver_config_allocate(VALUE klass)
35
81
  {
36
- DriverConfig *config = ALLOC(DriverConfig);
37
-
38
- return Data_Wrap_Struct(
82
+ DriverConfig *config;
83
+ return TypedData_Make_Struct(
39
84
  klass,
40
- NULL,
41
- ll_driver_config_free,
85
+ DriverConfig,
86
+ &ll_driver_config_type,
42
87
  config
43
88
  );
44
89
  }
@@ -59,7 +104,7 @@ VALUE ll_driver_config_set_terminals(VALUE self, VALUE array)
59
104
  DriverConfig *config;
60
105
  long count = RARRAY_LEN(array);
61
106
 
62
- Data_Get_Struct(self, DriverConfig, config);
107
+ TypedData_Get_Struct(self, DriverConfig, &ll_driver_config_type, config);
63
108
 
64
109
  config->terminals = kh_init(int64_map);
65
110
 
@@ -89,7 +134,7 @@ VALUE ll_driver_config_set_rules(VALUE self, VALUE array)
89
134
  VALUE row;
90
135
  long row_count = RARRAY_LEN(array);
91
136
 
92
- Data_Get_Struct(self, DriverConfig, config);
137
+ TypedData_Get_Struct(self, DriverConfig, &ll_driver_config_type, config);
93
138
 
94
139
  config->rules = ALLOC_N(long*, row_count);
95
140
  config->rule_lengths = ALLOC_N(long, row_count);
@@ -129,7 +174,7 @@ VALUE ll_driver_config_set_table(VALUE self, VALUE array)
129
174
  DriverConfig *config;
130
175
  long row_count = RARRAY_LEN(array);
131
176
 
132
- Data_Get_Struct(self, DriverConfig, config);
177
+ TypedData_Get_Struct(self, DriverConfig, &ll_driver_config_type, config);
133
178
 
134
179
  config->table = ALLOC_N(long*, row_count);
135
180
 
@@ -164,7 +209,7 @@ VALUE ll_driver_config_set_actions(VALUE self, VALUE array)
164
209
  DriverConfig *config;
165
210
  long row_count = RARRAY_LEN(array);
166
211
 
167
- Data_Get_Struct(self, DriverConfig, config);
212
+ TypedData_Get_Struct(self, DriverConfig, &ll_driver_config_type, config);
168
213
 
169
214
  config->action_names = ALLOC_N(VALUE, row_count);
170
215
  config->action_arg_amounts = ALLOC_N(long, row_count);
@@ -50,4 +50,6 @@ typedef struct
50
50
 
51
51
  extern void Init_ll_driver_config();
52
52
 
53
+ extern const rb_data_type_t ll_driver_config_type;
54
+
53
55
  #endif
@@ -15,7 +15,7 @@ import org.jruby.RubyFixnum;
15
15
 
16
16
  import org.jruby.anno.JRubyClass;
17
17
  import org.jruby.anno.JRubyMethod;
18
- import org.jruby.runtime.Arity;
18
+ import org.jruby.runtime.Signature;
19
19
  import org.jruby.runtime.Helpers;
20
20
  import org.jruby.runtime.ThreadContext;
21
21
  import org.jruby.runtime.ObjectAllocator;
@@ -307,7 +307,7 @@ public class Driver extends RubyObject
307
307
  CallBlock19.newCallClosure(
308
308
  this,
309
309
  this.metaClass,
310
- Arity.NO_ARGUMENTS,
310
+ Signature.NO_ARGUMENTS,
311
311
  callback,
312
312
  context
313
313
  )
data/lib/libll.jar CHANGED
Binary file
data/lib/ll/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module LL
2
- VERSION = '2.1.3'
2
+ VERSION = '2.2.0'
3
3
  end # LL
metadata CHANGED
@@ -1,22 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-ll
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.3
4
+ version: 2.2.0
5
5
  platform: java
6
6
  authors:
7
7
  - Yorick Peterse
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-06-10 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
13
+ name: ast
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
18
  version: '0'
19
- name: ast
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
@@ -25,12 +24,12 @@ dependencies:
25
24
  - !ruby/object:Gem::Version
26
25
  version: '0'
27
26
  - !ruby/object:Gem::Dependency
27
+ name: ansi
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: '0'
33
- name: ansi
34
33
  type: :runtime
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
@@ -39,12 +38,12 @@ dependencies:
39
38
  - !ruby/object:Gem::Version
40
39
  version: '0'
41
40
  - !ruby/object:Gem::Dependency
41
+ name: rake
42
42
  requirement: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0'
47
- name: rake
48
47
  type: :development
49
48
  prerelease: false
50
49
  version_requirements: !ruby/object:Gem::Requirement
@@ -53,12 +52,12 @@ dependencies:
53
52
  - !ruby/object:Gem::Version
54
53
  version: '0'
55
54
  - !ruby/object:Gem::Dependency
55
+ name: rspec
56
56
  requirement: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '3.0'
61
- name: rspec
62
61
  type: :development
63
62
  prerelease: false
64
63
  version_requirements: !ruby/object:Gem::Requirement
@@ -67,12 +66,12 @@ dependencies:
67
66
  - !ruby/object:Gem::Version
68
67
  version: '3.0'
69
68
  - !ruby/object:Gem::Dependency
69
+ name: yard
70
70
  requirement: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
- name: yard
76
75
  type: :development
77
76
  prerelease: false
78
77
  version_requirements: !ruby/object:Gem::Requirement
@@ -81,12 +80,12 @@ dependencies:
81
80
  - !ruby/object:Gem::Version
82
81
  version: '0'
83
82
  - !ruby/object:Gem::Dependency
83
+ name: simplecov
84
84
  requirement: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - ">="
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
- name: simplecov
90
89
  type: :development
91
90
  prerelease: false
92
91
  version_requirements: !ruby/object:Gem::Requirement
@@ -95,12 +94,12 @@ dependencies:
95
94
  - !ruby/object:Gem::Version
96
95
  version: '0'
97
96
  - !ruby/object:Gem::Dependency
97
+ name: kramdown
98
98
  requirement: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - ">="
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
- name: kramdown
104
103
  type: :development
105
104
  prerelease: false
106
105
  version_requirements: !ruby/object:Gem::Requirement
@@ -109,12 +108,12 @@ dependencies:
109
108
  - !ruby/object:Gem::Version
110
109
  version: '0'
111
110
  - !ruby/object:Gem::Dependency
111
+ name: benchmark-ips
112
112
  requirement: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
116
  version: '2.0'
117
- name: benchmark-ips
118
117
  type: :development
119
118
  prerelease: false
120
119
  version_requirements: !ruby/object:Gem::Requirement
@@ -123,12 +122,12 @@ dependencies:
123
122
  - !ruby/object:Gem::Version
124
123
  version: '2.0'
125
124
  - !ruby/object:Gem::Dependency
125
+ name: rake-compiler
126
126
  requirement: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - ">="
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
- name: rake-compiler
132
131
  type: :development
133
132
  prerelease: false
134
133
  version_requirements: !ruby/object:Gem::Requirement
@@ -193,7 +192,6 @@ homepage: https://github.com/yorickpeterse/ruby-ll
193
192
  licenses:
194
193
  - MPL-2.0
195
194
  metadata: {}
196
- post_install_message:
197
195
  rdoc_options: []
198
196
  require_paths:
199
197
  - lib
@@ -208,8 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
206
  - !ruby/object:Gem::Version
209
207
  version: '0'
210
208
  requirements: []
211
- rubygems_version: 3.3.26
212
- signing_key:
209
+ rubygems_version: 4.0.3
213
210
  specification_version: 4
214
211
  summary: An LL(1) parser generator for Ruby.
215
212
  test_files: []