xrb 0.7.0 → 0.9.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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/ext/Makefile +6 -6
- data/ext/XRB_Extension.bundle +0 -0
- data/ext/escape.o +0 -0
- data/ext/markup.o +0 -0
- data/ext/query.o +0 -0
- data/ext/tag.o +0 -0
- data/ext/template.o +0 -0
- data/ext/xrb/escape.c +14 -12
- data/ext/xrb/tag.c +109 -26
- data/ext/xrb/template.c +944 -667
- data/ext/xrb/template.rl +44 -5
- data/ext/xrb.o +0 -0
- data/lib/xrb/fallback/markup.rb +24 -25
- data/lib/xrb/fallback/markup.rl +3 -2
- data/lib/xrb/fallback/query.rb +0 -2
- data/lib/xrb/fallback/template.rb +715 -393
- data/lib/xrb/fallback/template.rl +35 -1
- data/lib/xrb/template.rb +1 -3
- data/lib/xrb/version.rb +1 -1
- data/notes.md +0 -0
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +0 -0
- data/ext/mkmf.log +0 -69
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 262e952884557bc231200ca4a520519e9372d5c0aec682bbd92685258a16d115
|
4
|
+
data.tar.gz: c994e66e6a2c440f0e6ff36a5d964995081e17ab4c79792564d42862c306dc98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 006b40e77f38cf875163408b443d7f55a5a464a9658ec812071db7aa196133335281cad0ae9c80f1badbdffe77914660b59592dc0d33b99323d91bae19bad9de
|
7
|
+
data.tar.gz: 8b3dcfb6bee297abfbd1dacf583aed9eddfc0ec61ec99840b9096dccad01446683095394305a44b7eb63e726abc23563bd4f085f39e62afa656aedf45c186961
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/ext/Makefile
CHANGED
@@ -13,12 +13,12 @@ NULLCMD = :
|
|
13
13
|
#### Start of system configuration section. ####
|
14
14
|
|
15
15
|
srcdir = .
|
16
|
-
topdir = /Users/samuel/.rubies/ruby-3.3.
|
16
|
+
topdir = /Users/samuel/.rubies/ruby-3.3.4/include/ruby-3.3.0
|
17
17
|
hdrdir = $(topdir)
|
18
|
-
arch_hdrdir = /Users/samuel/.rubies/ruby-3.3.
|
18
|
+
arch_hdrdir = /Users/samuel/.rubies/ruby-3.3.4/include/ruby-3.3.0/arm64-darwin24
|
19
19
|
PATH_SEPARATOR = :
|
20
20
|
VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby:$(srcdir)/xrb
|
21
|
-
prefix = $(DESTDIR)/Users/samuel/.rubies/ruby-3.3.
|
21
|
+
prefix = $(DESTDIR)/Users/samuel/.rubies/ruby-3.3.4
|
22
22
|
rubysitearchprefix = $(rubylibprefix)/$(sitearch)
|
23
23
|
rubyarchprefix = $(rubylibprefix)/$(arch)
|
24
24
|
rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
|
@@ -106,7 +106,7 @@ RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
|
|
106
106
|
RUBYW_BASE_NAME = rubyw
|
107
107
|
RUBY_BASE_NAME = ruby
|
108
108
|
|
109
|
-
arch = arm64-
|
109
|
+
arch = arm64-darwin24
|
110
110
|
sitearch = $(arch)
|
111
111
|
ruby_version = 3.3.0
|
112
112
|
ruby = $(bindir)/$(RUBY_BASE_NAME)
|
@@ -117,8 +117,8 @@ ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/backward.h $(hdrdir)/ruby/ruby.h
|
|
117
117
|
RM = rm -f
|
118
118
|
RM_RF = rm -fr
|
119
119
|
RMDIRS = rmdir -p
|
120
|
-
MAKEDIRS =
|
121
|
-
INSTALL = /
|
120
|
+
MAKEDIRS = mkdir -p
|
121
|
+
INSTALL = /usr/bin/install -c
|
122
122
|
INSTALL_PROG = $(INSTALL) -m 0755
|
123
123
|
INSTALL_DATA = $(INSTALL) -m 644
|
124
124
|
COPY = cp
|
data/ext/XRB_Extension.bundle
CHANGED
Binary file
|
data/ext/escape.o
CHANGED
Binary file
|
data/ext/markup.o
CHANGED
Binary file
|
data/ext/query.o
CHANGED
Binary file
|
data/ext/tag.o
CHANGED
Binary file
|
data/ext/template.o
CHANGED
Binary file
|
data/ext/xrb/escape.c
CHANGED
@@ -103,38 +103,40 @@ VALUE XRB_Markup_append_string(VALUE buffer, VALUE string) {
|
|
103
103
|
return XRB_Markup_append_buffer(buffer, s, p, end);
|
104
104
|
}
|
105
105
|
|
106
|
-
VALUE XRB_Markup_append_slow(VALUE self, VALUE
|
107
|
-
if (value == Qnil) return Qnil;
|
106
|
+
VALUE XRB_Markup_append_slow(VALUE self, VALUE output, VALUE value) {
|
107
|
+
// if (value == Qnil) return Qnil;
|
108
108
|
|
109
109
|
if (!XRB_Markup_is_markup(value)) {
|
110
|
+
value = rb_funcall(value, id_to_s, 0);
|
110
111
|
value = XRB_Markup_escape_string(Qnil, value);
|
111
112
|
}
|
112
|
-
|
113
|
-
rb_funcall(buffer, id_concat, 1, value);
|
114
113
|
|
115
|
-
|
114
|
+
rb_funcall(output, id_concat, 1, value);
|
115
|
+
|
116
|
+
return output;
|
116
117
|
}
|
117
118
|
|
118
|
-
VALUE XRB_Markup_append(VALUE self, VALUE
|
119
|
+
VALUE XRB_Markup_append(VALUE self, VALUE output, VALUE value) {
|
119
120
|
if (value == Qnil) return Qnil;
|
120
121
|
|
121
|
-
if (RB_TYPE_P(
|
122
|
-
rb_str_modify(
|
122
|
+
if (RB_TYPE_P(output, T_STRING)) {
|
123
|
+
rb_str_modify(output);
|
123
124
|
} else {
|
124
|
-
return XRB_Markup_append_slow(self,
|
125
|
+
return XRB_Markup_append_slow(self, output, value);
|
125
126
|
}
|
126
127
|
|
128
|
+
// The output buffer is a string, so we can append directly:
|
127
129
|
if (XRB_Markup_is_markup(value)) {
|
128
|
-
rb_str_append(
|
130
|
+
rb_str_append(output, value);
|
129
131
|
} else {
|
130
132
|
if (rb_type(value) != T_STRING) {
|
131
133
|
value = rb_funcall(value, id_to_s, 0);
|
132
134
|
}
|
133
135
|
|
134
|
-
XRB_Markup_append_string(
|
136
|
+
XRB_Markup_append_string(output, value);
|
135
137
|
}
|
136
138
|
|
137
|
-
return
|
139
|
+
return output;
|
138
140
|
}
|
139
141
|
|
140
142
|
// Convert markup special characters to entities. May return the original string if no changes were made.
|
data/ext/xrb/tag.c
CHANGED
@@ -50,7 +50,7 @@ inline static VALUE XRB_Tag_prefix_key(VALUE prefix, VALUE key) {
|
|
50
50
|
return buffer;
|
51
51
|
}
|
52
52
|
|
53
|
-
VALUE
|
53
|
+
VALUE XRB_Tag_append_attributes_string(VALUE self, VALUE buffer, VALUE attributes, VALUE prefix);
|
54
54
|
|
55
55
|
static void XRB_Tag_append_tag_attribute(VALUE buffer, VALUE key, VALUE value, VALUE prefix) {
|
56
56
|
// We skip over attributes with nil value:
|
@@ -60,7 +60,7 @@ static void XRB_Tag_append_tag_attribute(VALUE buffer, VALUE key, VALUE value, V
|
|
60
60
|
key = XRB_Tag_prefix_key(prefix, key);
|
61
61
|
|
62
62
|
if (XRB_Tag_valid_attributes(value)) {
|
63
|
-
|
63
|
+
XRB_Tag_append_attributes_string(Qnil, buffer, value, key);
|
64
64
|
} else {
|
65
65
|
rb_str_cat_cstr(buffer, " ");
|
66
66
|
rb_str_append(buffer, key);
|
@@ -73,24 +73,24 @@ static void XRB_Tag_append_tag_attribute(VALUE buffer, VALUE key, VALUE value, V
|
|
73
73
|
}
|
74
74
|
}
|
75
75
|
|
76
|
-
|
76
|
+
struct XRB_Tag_Append_Tag_Attribute_Argument {
|
77
77
|
VALUE buffer;
|
78
78
|
VALUE prefix;
|
79
|
-
}
|
79
|
+
};
|
80
80
|
|
81
81
|
static int XRB_Tag_append_tag_attribute_foreach(VALUE key, VALUE value, VALUE _argument) {
|
82
|
-
|
82
|
+
struct XRB_Tag_Append_Tag_Attribute_Argument * argument = (struct XRB_Tag_Append_Tag_Attribute_Argument *)_argument;
|
83
83
|
|
84
84
|
XRB_Tag_append_tag_attribute(argument->buffer, key, value, argument->prefix);
|
85
85
|
|
86
86
|
return ST_CONTINUE;
|
87
87
|
}
|
88
88
|
|
89
|
-
VALUE
|
89
|
+
VALUE XRB_Tag_append_attributes_string(VALUE self, VALUE buffer, VALUE attributes, VALUE prefix) {
|
90
90
|
int type = rb_type(attributes);
|
91
91
|
|
92
92
|
if (type == T_HASH) {
|
93
|
-
|
93
|
+
struct XRB_Tag_Append_Tag_Attribute_Argument argument = {buffer, prefix};
|
94
94
|
rb_hash_foreach(attributes, &XRB_Tag_append_tag_attribute_foreach, (VALUE)&argument);
|
95
95
|
} else if (type == T_ARRAY) {
|
96
96
|
long i;
|
@@ -114,13 +114,45 @@ VALUE XRB_Tag_append_attributes(VALUE self, VALUE buffer, VALUE attributes, VALU
|
|
114
114
|
return Qnil;
|
115
115
|
}
|
116
116
|
|
117
|
-
|
117
|
+
static size_t XRB_Tag_estimate_attributes_size(VALUE attributes, VALUE prefix) {
|
118
|
+
if (attributes == Qnil) return 0;
|
119
|
+
|
120
|
+
int type = rb_type(attributes);
|
121
|
+
|
122
|
+
if (type == T_HASH) {
|
123
|
+
return rb_hash_size(attributes) * 32;
|
124
|
+
} else if (type == T_ARRAY) {
|
125
|
+
return RARRAY_LEN(attributes) * 32;
|
126
|
+
}
|
127
|
+
|
128
|
+
return 0;
|
129
|
+
}
|
130
|
+
|
131
|
+
VALUE XRB_Tag_append_attributes(VALUE self, VALUE output, VALUE attributes, VALUE prefix) {
|
132
|
+
size_t estimated_size = XRB_Tag_estimate_attributes_size(attributes, prefix);
|
133
|
+
|
134
|
+
// If there are no attributes, we return early:
|
135
|
+
if (estimated_size == 0) return Qnil;
|
136
|
+
|
137
|
+
if (rb_type(output) == T_STRING) {
|
138
|
+
rb_str_modify_expand(output, estimated_size);
|
139
|
+
XRB_Tag_append_attributes_string(self, output, attributes, prefix);
|
140
|
+
} else {
|
141
|
+
VALUE buffer = rb_str_buf_new(estimated_size);
|
142
|
+
XRB_Tag_append_attributes_string(self, buffer, attributes, prefix);
|
143
|
+
rb_funcall(output, id_concat, 1, buffer);
|
144
|
+
}
|
145
|
+
|
146
|
+
return Qnil;
|
147
|
+
}
|
148
|
+
|
149
|
+
VALUE XRB_Tag_append_tag_string(VALUE self, VALUE buffer, VALUE name, VALUE attributes, VALUE content) {
|
118
150
|
StringValue(name);
|
119
151
|
|
120
152
|
rb_str_cat_cstr(buffer, "<");
|
121
153
|
rb_str_buf_append(buffer, name);
|
122
154
|
|
123
|
-
|
155
|
+
XRB_Tag_append_attributes_string(self, buffer, attributes, Qnil);
|
124
156
|
|
125
157
|
if (content == Qnil || content == Qfalse) {
|
126
158
|
rb_str_cat_cstr(buffer, "/>");
|
@@ -139,30 +171,46 @@ VALUE XRB_Tag_append_tag(VALUE self, VALUE buffer, VALUE name, VALUE attributes,
|
|
139
171
|
return Qnil;
|
140
172
|
}
|
141
173
|
|
142
|
-
|
143
|
-
|
174
|
+
static size_t XRB_Tag_estimate_size(VALUE name, VALUE attributes, VALUE content) {
|
175
|
+
size_t estimated_size = (RSTRING_LEN(name) * 2) + XRB_Tag_estimate_attributes_size(attributes, Qnil) + 5;
|
144
176
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
XRB_Tag_append_tag(self, buffer, name, attributes, content);
|
177
|
+
if (rb_type(content) == T_STRING) {
|
178
|
+
estimated_size += RSTRING_LEN(content);
|
179
|
+
}
|
149
180
|
|
150
|
-
return
|
181
|
+
return estimated_size;
|
151
182
|
}
|
152
183
|
|
153
|
-
VALUE
|
154
|
-
|
155
|
-
|
156
|
-
|
184
|
+
VALUE XRB_Tag_append_tag(VALUE self, VALUE output, VALUE name, VALUE attributes, VALUE content) {
|
185
|
+
size_t estimated_size = XRB_Tag_estimate_size(name, attributes, content);
|
186
|
+
|
187
|
+
if (rb_type(output) == T_STRING) {
|
188
|
+
rb_str_modify_expand(output, estimated_size);
|
189
|
+
XRB_Tag_append_tag_string(self, output, name, attributes, content);
|
190
|
+
} else {
|
191
|
+
VALUE buffer = rb_str_buf_new(estimated_size);
|
192
|
+
XRB_Tag_append_tag_string(self, buffer, name, attributes, content);
|
193
|
+
rb_funcall(output, id_concat, 1, buffer);
|
194
|
+
}
|
195
|
+
|
196
|
+
return Qnil;
|
197
|
+
}
|
157
198
|
|
158
|
-
|
199
|
+
VALUE XRB_Tag_format_tag(VALUE self, VALUE name, VALUE attributes, VALUE content) {
|
200
|
+
size_t estimated_size = XRB_Tag_estimate_size(name, attributes, content);
|
159
201
|
|
160
|
-
|
202
|
+
VALUE buffer = rb_str_buf_new(estimated_size);
|
161
203
|
|
204
|
+
XRB_Tag_append_tag_string(self, buffer, name, attributes, content);
|
205
|
+
|
206
|
+
return buffer;
|
207
|
+
}
|
208
|
+
|
209
|
+
VALUE XRB_Tag_write_opening_tag_string(VALUE self, VALUE buffer, VALUE name, VALUE attributes, VALUE closed) {
|
162
210
|
rb_str_cat_cstr(buffer, "<");
|
163
211
|
rb_str_buf_append(buffer, name);
|
164
212
|
|
165
|
-
|
213
|
+
XRB_Tag_append_attributes_string(self, buffer, attributes, Qnil);
|
166
214
|
|
167
215
|
if (closed == Qtrue) {
|
168
216
|
rb_str_cat_cstr(buffer, "/>");
|
@@ -173,17 +221,52 @@ VALUE XRB_Tag_write_opening_tag(VALUE self, VALUE buffer) {
|
|
173
221
|
return Qnil;
|
174
222
|
}
|
175
223
|
|
176
|
-
VALUE
|
224
|
+
VALUE XRB_Tag_write_opening_tag(VALUE self, VALUE output) {
|
177
225
|
VALUE name = rb_struct_getmember(self, id_name);
|
178
|
-
|
179
226
|
StringValue(name);
|
180
227
|
|
181
|
-
|
228
|
+
VALUE attributes = rb_struct_getmember(self, id_attributes);
|
229
|
+
VALUE closed = rb_struct_getmember(self, id_closed);
|
230
|
+
|
231
|
+
// The size of the tag name + attributes + at most 3 characters for the closing tag symbols.
|
232
|
+
size_t estimated_size = RSTRING_LEN(name) + XRB_Tag_estimate_attributes_size(attributes, Qnil) + 3;
|
233
|
+
|
234
|
+
if (rb_type(output) == T_STRING) {
|
235
|
+
rb_str_modify_expand(output, estimated_size);
|
236
|
+
XRB_Tag_write_opening_tag_string(self, output, name, attributes, closed);
|
237
|
+
} else {
|
238
|
+
VALUE buffer = rb_str_buf_new(estimated_size);
|
239
|
+
XRB_Tag_write_opening_tag_string(self, buffer, name, attributes, closed);
|
240
|
+
rb_funcall(output, id_concat, 1, buffer);
|
241
|
+
}
|
182
242
|
|
243
|
+
return Qnil;
|
244
|
+
}
|
245
|
+
|
246
|
+
VALUE XRB_Tag_write_closing_tag_string(VALUE self, VALUE buffer, VALUE name) {
|
183
247
|
rb_str_cat_cstr(buffer, "</");
|
184
248
|
rb_str_buf_append(buffer, name);
|
185
249
|
rb_str_cat_cstr(buffer, ">");
|
186
250
|
|
251
|
+
return buffer;
|
252
|
+
}
|
253
|
+
|
254
|
+
VALUE XRB_Tag_write_closing_tag(VALUE self, VALUE output) {
|
255
|
+
VALUE name = rb_struct_getmember(self, id_name);
|
256
|
+
StringValue(name);
|
257
|
+
|
258
|
+
// The size of the tag name + 3 characters for the closing tag symbols.
|
259
|
+
size_t estimated_size = RSTRING_LEN(name) + 3;
|
260
|
+
|
261
|
+
if (rb_type(output) == T_STRING) {
|
262
|
+
rb_str_modify_expand(output, estimated_size);
|
263
|
+
XRB_Tag_write_closing_tag_string(self, output, name);
|
264
|
+
} else {
|
265
|
+
VALUE buffer = rb_str_buf_new(estimated_size);
|
266
|
+
XRB_Tag_write_closing_tag_string(self, buffer, name);
|
267
|
+
rb_funcall(output, id_concat, 1, buffer);
|
268
|
+
}
|
269
|
+
|
187
270
|
return Qnil;
|
188
271
|
}
|
189
272
|
|