arraybuffer 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/arraybuffer/arraybuffer.c +16 -6
- data/ext/arraybuffer/dataview.c +6 -6
- data/lib/arraybuffer_ext.bundle +0 -0
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a052426f4fef84b44cafc3c99a53b33313f1732419710c41d5101cfc062d7f3c
|
4
|
+
data.tar.gz: '0269d413e2d78f96e310c50d3ad9d9bcc81c2289acf8f80d2f819adc5c4d9653'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36d9f193e7b56cad4cc5b08c7e1569872c3987b3eed51235fd834f838b72e541e416327ef5274cbeddbc68d3722d14578e6f33e934e4ae8af0864b9b4375d326
|
7
|
+
data.tar.gz: 60995a4af7efe4ac38c05c099de41ada09c8368106aac51cb2f1059b66104d54cf5d7a2d1f01fefab3429d1710a8faf867daa0c63d2ec24d50af5030dfac762e
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#include "arraybuffer.h"
|
2
2
|
#include "extconf.h"
|
3
3
|
#include <string.h>
|
4
|
+
#include <ruby/version.h>
|
4
5
|
|
5
6
|
#ifdef HAVE_RUBY_MEMORY_VIEW_H
|
6
7
|
#include <ruby/memory_view.h>
|
@@ -12,7 +13,7 @@ extern VALUE cArrayBuffer;
|
|
12
13
|
struct LLC_ArrayBuffer *bb = (struct LLC_ArrayBuffer*)rb_data_object_get((self))
|
13
14
|
|
14
15
|
#define CHECKBOUNDS(bb, idx) \
|
15
|
-
if (!(bb)->ptr || (idx) < 0 || (idx) >= (bb)->size) { \
|
16
|
+
if (!(bb)->ptr || (idx) < 0 || (unsigned int)(idx) >= (bb)->size) { \
|
16
17
|
rb_raise(rb_eArgError, "Index out of bounds: %d", (idx)); \
|
17
18
|
}
|
18
19
|
|
@@ -61,13 +62,22 @@ t_bb_allocator(VALUE klass) {
|
|
61
62
|
struct LLC_ArrayBuffer *bb = (struct LLC_ArrayBuffer*)xmalloc(sizeof(struct LLC_ArrayBuffer));
|
62
63
|
bb->ptr = NULL;
|
63
64
|
bb->size = 0;
|
64
|
-
bb->backing_str =
|
65
|
+
bb->backing_str = 0;
|
65
66
|
|
66
67
|
return Data_Wrap_Struct(klass, t_bb_gc_mark, t_bb_free, bb);
|
67
68
|
}
|
68
69
|
|
69
|
-
#
|
70
|
-
|
70
|
+
#if (RUBY_API_VERSION_CODE >= 30100)
|
71
|
+
// Ruby 3.1 and later
|
72
|
+
|
73
|
+
#define BB_BACKING_PTR(bb) \
|
74
|
+
(FL_TEST((bb)->backing_str, RSTRING_NOEMBED) ? RSTRING((bb)->backing_str)->as.heap.ptr : RSTRING(bb->backing_str)->as.embed.ary)
|
75
|
+
#else
|
76
|
+
// Before ruby 3.1
|
77
|
+
|
78
|
+
#define BB_BACKING_PTR(bb) \
|
79
|
+
(FL_TEST((bb)->backing_str, RSTRING_NOEMBED) ? RSTRING((bb)->backing_str)->as.heap.ptr : RSTRING(bb->backing_str)->as.ary)
|
80
|
+
#endif
|
71
81
|
|
72
82
|
static void
|
73
83
|
t_bb_reassign_ptr(struct LLC_ArrayBuffer *bb) {
|
@@ -77,7 +87,7 @@ t_bb_reassign_ptr(struct LLC_ArrayBuffer *bb) {
|
|
77
87
|
}
|
78
88
|
|
79
89
|
rb_str_set_len(bb->backing_str, bb->size);
|
80
|
-
bb->ptr = BB_BACKING_PTR(bb);
|
90
|
+
bb->ptr = (unsigned char*)BB_BACKING_PTR(bb);
|
81
91
|
bb->ptr[bb->size] = 0;
|
82
92
|
}
|
83
93
|
|
@@ -129,7 +139,7 @@ t_bb_each(VALUE self) {
|
|
129
139
|
DECLAREBB(self);
|
130
140
|
|
131
141
|
if (rb_block_given_p()) {
|
132
|
-
for (int i = 0; i < bb->size; i++) {
|
142
|
+
for (unsigned int i = 0; i < bb->size; i++) {
|
133
143
|
unsigned int val = (unsigned int)bb->ptr[i];
|
134
144
|
rb_yield(UINT2NUM(val));
|
135
145
|
}
|
data/ext/arraybuffer/dataview.c
CHANGED
@@ -131,8 +131,8 @@ t_dv_initialize(int argc, VALUE *argv, VALUE self) {
|
|
131
131
|
if (offset_val < 0)
|
132
132
|
rb_raise(rb_eArgError, "calculated offset is negative: %d", offset_val);
|
133
133
|
|
134
|
-
dv->offset = (unsigned
|
135
|
-
dv->size = (unsigned
|
134
|
+
dv->offset = (unsigned int)offset_val;
|
135
|
+
dv->size = (unsigned int)size_val;
|
136
136
|
dv->bb_obj = bb_obj;
|
137
137
|
|
138
138
|
if (!keyword_ids[0]) {
|
@@ -214,7 +214,7 @@ t_dv_setoffset(VALUE self, VALUE offset) {
|
|
214
214
|
if (offset_val < 0)
|
215
215
|
rb_raise(rb_eArgError, "calculated offset is negative: %d", offset_val);
|
216
216
|
|
217
|
-
dv->offset = (unsigned
|
217
|
+
dv->offset = (unsigned int)offset_val;
|
218
218
|
return self;
|
219
219
|
}
|
220
220
|
|
@@ -237,13 +237,13 @@ t_dv_setsize(VALUE self, VALUE size) {
|
|
237
237
|
if (size_val < 0)
|
238
238
|
rb_raise(rb_eArgError, "calculated size is negative: %d", size_val);
|
239
239
|
|
240
|
-
dv->size = (unsigned
|
240
|
+
dv->size = (unsigned int)size_val;
|
241
241
|
return self;
|
242
242
|
}
|
243
243
|
|
244
244
|
#define DECLARENCHECKIDX(index) int idx = NUM2INT(index); \
|
245
245
|
if (idx < 0) idx += (int)dv->size; \
|
246
|
-
if (idx < 0 || idx >= dv->size) rb_raise(rb_eArgError, "index out of bounds: %d", idx);
|
246
|
+
if (idx < 0 || idx >= (int)dv->size) rb_raise(rb_eArgError, "index out of bounds: %d", idx);
|
247
247
|
|
248
248
|
#define CHECKBOUNDSBB(v) if ((v) < 0 || (v) >= (bb)->size) \
|
249
249
|
rb_raise(rb_eArgError, "index out of underlying buffer bounds: %d", (v));
|
@@ -263,7 +263,7 @@ t_dv_getbit(VALUE self, VALUE index) {
|
|
263
263
|
int idx = NUM2INT(index);
|
264
264
|
if (idx < 0)
|
265
265
|
idx += (int)dv->size * 8;
|
266
|
-
if (idx < 0 || idx >= dv->size * 8)
|
266
|
+
if (idx < 0 || idx >= (int)dv->size * 8)
|
267
267
|
rb_raise(rb_eArgError, "index out of bounds: %d", idx);
|
268
268
|
|
269
269
|
unsigned int bit_idx = ((unsigned int)idx) & 7;
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arraybuffer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- André Diego Piske
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake-compiler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.2'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.2'
|
27
41
|
description:
|
28
42
|
email:
|
29
43
|
- andrepiske@gmail.com
|
@@ -40,6 +54,7 @@ files:
|
|
40
54
|
- ext/arraybuffer/extconf.rb
|
41
55
|
- extconf.h
|
42
56
|
- lib/arraybuffer.rb
|
57
|
+
- lib/arraybuffer_ext.bundle
|
43
58
|
homepage: https://github.com/andrepiske/rb-arraybuffer
|
44
59
|
licenses:
|
45
60
|
- MIT
|
@@ -53,14 +68,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
53
68
|
requirements:
|
54
69
|
- - ">="
|
55
70
|
- !ruby/object:Gem::Version
|
56
|
-
version: '
|
71
|
+
version: '3.0'
|
57
72
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
73
|
requirements:
|
59
74
|
- - ">="
|
60
75
|
- !ruby/object:Gem::Version
|
61
76
|
version: '0'
|
62
77
|
requirements: []
|
63
|
-
rubygems_version: 3.
|
78
|
+
rubygems_version: 3.5.22
|
64
79
|
signing_key:
|
65
80
|
specification_version: 4
|
66
81
|
summary: An array buffer (a.k.a. byte array) implementation forRuby, implemented natively.
|