qr_reader-native 0.0.1
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 +7 -0
- data/LICENSE-mruby.txt +22 -0
- data/LICENSE-spinel.txt +19 -0
- data/LICENSE.txt +21 -0
- data/README.md +61 -0
- data/ext/qr_reader_native/SPINEL_VERSION +1 -0
- data/ext/qr_reader_native/extconf.rb +8 -0
- data/ext/qr_reader_native/mruby/error.h +13 -0
- data/ext/qr_reader_native/mruby/internal.h +145 -0
- data/ext/qr_reader_native/mruby/string.h +22 -0
- data/ext/qr_reader_native/mruby.h +93 -0
- data/ext/qr_reader_native/mruby_shim.h +118 -0
- data/ext/qr_reader_native/qr_reader_native.c +13513 -0
- data/ext/qr_reader_native/qr_reader_native.h +29 -0
- data/ext/qr_reader_native/qr_reader_native_ext.c +598 -0
- data/ext/qr_reader_native/re_cased.h +71 -0
- data/ext/qr_reader_native/re_compile.c +5784 -0
- data/ext/qr_reader_native/re_ctype.h +3540 -0
- data/ext/qr_reader_native/re_exec.c +2190 -0
- data/ext/qr_reader_native/re_internal.h +671 -0
- data/ext/qr_reader_native/re_prop.h +4629 -0
- data/ext/qr_reader_native/re_spinel.c +363 -0
- data/ext/qr_reader_native/re_spinel.h +22 -0
- data/ext/qr_reader_native/re_spinel_utf8.inc +97 -0
- data/ext/qr_reader_native/re_utf8.c +156 -0
- data/ext/qr_reader_native/sp_alloc.c +1447 -0
- data/ext/qr_reader_native/sp_alloc.h +1196 -0
- data/ext/qr_reader_native/sp_argf.h +33 -0
- data/ext/qr_reader_native/sp_array.c +1052 -0
- data/ext/qr_reader_native/sp_array.h +456 -0
- data/ext/qr_reader_native/sp_bigint.c +5826 -0
- data/ext/qr_reader_native/sp_bigint.h +117 -0
- data/ext/qr_reader_native/sp_cold.c +5259 -0
- data/ext/qr_reader_native/sp_compat.h +402 -0
- data/ext/qr_reader_native/sp_core.c +818 -0
- data/ext/qr_reader_native/sp_core.h +56 -0
- data/ext/qr_reader_native/sp_crypto.c +877 -0
- data/ext/qr_reader_native/sp_crypto.h +169 -0
- data/ext/qr_reader_native/sp_dtoa.c +1533 -0
- data/ext/qr_reader_native/sp_dtoa.h +29 -0
- data/ext/qr_reader_native/sp_encoding_names.h +172 -0
- data/ext/qr_reader_native/sp_enum.h +86 -0
- data/ext/qr_reader_native/sp_exc.c +1185 -0
- data/ext/qr_reader_native/sp_exc.h +186 -0
- data/ext/qr_reader_native/sp_exc_ctx.h +56 -0
- data/ext/qr_reader_native/sp_fiber.c +889 -0
- data/ext/qr_reader_native/sp_fiber.h +162 -0
- data/ext/qr_reader_native/sp_fiber_ctx.h +84 -0
- data/ext/qr_reader_native/sp_format.c +695 -0
- data/ext/qr_reader_native/sp_format.h +83 -0
- data/ext/qr_reader_native/sp_gc.c +1793 -0
- data/ext/qr_reader_native/sp_gc.h +762 -0
- data/ext/qr_reader_native/sp_hash.c +131 -0
- data/ext/qr_reader_native/sp_hash.h +131 -0
- data/ext/qr_reader_native/sp_inspect.c +215 -0
- data/ext/qr_reader_native/sp_inspect.h +128 -0
- data/ext/qr_reader_native/sp_io.c +1676 -0
- data/ext/qr_reader_native/sp_io.h +272 -0
- data/ext/qr_reader_native/sp_iobuffer.c +1014 -0
- data/ext/qr_reader_native/sp_iobuffer.h +167 -0
- data/ext/qr_reader_native/sp_marshal.c +487 -0
- data/ext/qr_reader_native/sp_marshal.h +60 -0
- data/ext/qr_reader_native/sp_net.c +1029 -0
- data/ext/qr_reader_native/sp_net.h +205 -0
- data/ext/qr_reader_native/sp_pack.c +1254 -0
- data/ext/qr_reader_native/sp_poly_cold.c +1220 -0
- data/ext/qr_reader_native/sp_proc.c +410 -0
- data/ext/qr_reader_native/sp_proc.h +327 -0
- data/ext/qr_reader_native/sp_process.c +547 -0
- data/ext/qr_reader_native/sp_process_status.c +211 -0
- data/ext/qr_reader_native/sp_process_status.h +66 -0
- data/ext/qr_reader_native/sp_random.c +287 -0
- data/ext/qr_reader_native/sp_random.h +52 -0
- data/ext/qr_reader_native/sp_range.h +144 -0
- data/ext/qr_reader_native/sp_re.c +1379 -0
- data/ext/qr_reader_native/sp_re.h +186 -0
- data/ext/qr_reader_native/sp_re_names.h +59 -0
- data/ext/qr_reader_native/sp_sched.c +4044 -0
- data/ext/qr_reader_native/sp_sched.h +295 -0
- data/ext/qr_reader_native/sp_slab.c +1507 -0
- data/ext/qr_reader_native/sp_str.c +1462 -0
- data/ext/qr_reader_native/sp_str.h +306 -0
- data/ext/qr_reader_native/sp_str_crypt.c +23 -0
- data/ext/qr_reader_native/sp_string.c +92 -0
- data/ext/qr_reader_native/sp_string.h +253 -0
- data/ext/qr_reader_native/sp_system.c +78 -0
- data/ext/qr_reader_native/sp_system.h +18 -0
- data/ext/qr_reader_native/sp_time.c +860 -0
- data/ext/qr_reader_native/sp_time.h +100 -0
- data/ext/qr_reader_native/sp_types.h +292 -0
- data/ext/qr_reader_native/spinel_rt.h +19017 -0
- data/ext/qr_reader_native/unicase.c +399 -0
- data/ext/qr_reader_native/unicase.h +901 -0
- data/lib/qr_reader/native.rb +6 -0
- metadata +153 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
** @file mruby/bigint.h - Multi-precision Integer
|
|
3
|
+
**
|
|
4
|
+
** See Copyright Notice in mruby.h
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
#ifndef MRUBY_BIGINT_H
|
|
8
|
+
#define MRUBY_BIGINT_H
|
|
9
|
+
/*
|
|
10
|
+
* FREE GMP - a public domain implementation of a subset of the
|
|
11
|
+
* gmp library
|
|
12
|
+
*
|
|
13
|
+
* I hereby place the file in the public domain.
|
|
14
|
+
*
|
|
15
|
+
* Do whatever you want with this code. Change it. Sell it. Claim you
|
|
16
|
+
* wrote it.
|
|
17
|
+
* Bugs, complaints, flames, rants: please send email to
|
|
18
|
+
* Mark Henderson <markh@wimsey.bc.ca>
|
|
19
|
+
* I'm already aware that fgmp is considerably slower than gmp
|
|
20
|
+
*
|
|
21
|
+
* CREDITS:
|
|
22
|
+
* Paul Rouse <par@r-cube.demon.co.uk> - generic bugfixes, mpz_sqrt and
|
|
23
|
+
* mpz_sqrtrem, and modifications to get fgmp to compile on a system
|
|
24
|
+
* with int and long of different sizes (specifically MS-DOS,286 compiler)
|
|
25
|
+
* Also see the file "notes" included with the fgmp distribution, for
|
|
26
|
+
* more credits.
|
|
27
|
+
*
|
|
28
|
+
* VERSION 1.0 - beta 5
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
#include <sys/types.h>
|
|
32
|
+
|
|
33
|
+
#ifdef MRB_NO_MPZ64BIT
|
|
34
|
+
typedef uint16_t mp_limb;
|
|
35
|
+
typedef uint32_t mp_dbl_limb;
|
|
36
|
+
typedef int32_t mp_dbl_limb_signed;
|
|
37
|
+
#define MPZ_DIG_SIZE 16
|
|
38
|
+
#else
|
|
39
|
+
typedef uint32_t mp_limb;
|
|
40
|
+
typedef uint64_t mp_dbl_limb;
|
|
41
|
+
typedef int64_t mp_dbl_limb_signed;
|
|
42
|
+
#define MPZ_DIG_SIZE 32
|
|
43
|
+
#endif
|
|
44
|
+
|
|
45
|
+
#define RBIGINT_EMBED_SIZE_MAX ((sizeof(void*) * 3) / sizeof(mp_limb))
|
|
46
|
+
|
|
47
|
+
typedef struct _mpz_t {
|
|
48
|
+
mp_limb *p;
|
|
49
|
+
short sn;
|
|
50
|
+
size_t sz;
|
|
51
|
+
} mpz_t;
|
|
52
|
+
|
|
53
|
+
struct RBigint {
|
|
54
|
+
MRB_OBJECT_HEADER;
|
|
55
|
+
union {
|
|
56
|
+
mpz_t heap;
|
|
57
|
+
mp_limb ary[RBIGINT_EMBED_SIZE_MAX];
|
|
58
|
+
} as;
|
|
59
|
+
};
|
|
60
|
+
#define RBIGINT(v) ((struct RBigint*)mrb_ptr(v))
|
|
61
|
+
|
|
62
|
+
/*
|
|
63
|
+
* flags of struct RBigint
|
|
64
|
+
*
|
|
65
|
+
* 6..: UNUSED
|
|
66
|
+
* 4..5: sign flags
|
|
67
|
+
* 00: negative (<--> -1)
|
|
68
|
+
* 01: zero (<--> 0)
|
|
69
|
+
* 10: positive (<--> +1)
|
|
70
|
+
* 11: UNUSED
|
|
71
|
+
* 0..3: size of embedded array; 15 means used with heap
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
#define RBIGINT_EMBED_SIZE_MASK 0x0f
|
|
75
|
+
#define RBIGINT_EMBED_SIZE_OVER RBIGINT_EMBED_SIZE_MASK
|
|
76
|
+
#define RBIGINT_EMBED_SIZE_SHIFT 0
|
|
77
|
+
#define RBIGINT_EMBED_SIGN_MASK 0x03
|
|
78
|
+
#define RBIGINT_EMBED_SIGN_SHIFT 4
|
|
79
|
+
|
|
80
|
+
#define RBIGINT_ARY(m) (RBIGINT_EMBED_P(m) ? RBIGINT_EMBED_ARY(m) : RBIGINT_HEAP_ARY(m))
|
|
81
|
+
#define RBIGINT_SIGN(m) (RBIGINT_EMBED_P(m) ? RBIGINT_EMBED_SIGN(m) : RBIGINT_HEAP_SIGN(m))
|
|
82
|
+
#define RBIGINT_SIZE(m) (RBIGINT_EMBED_P(m) ? RBIGINT_EMBED_SIZE(m) : RBIGINT_HEAP_SIZE(m))
|
|
83
|
+
|
|
84
|
+
#define RBIGINT_HEAP_ARY(m) ((m)->as.heap.p)
|
|
85
|
+
#define RBIGINT_HEAP_SIGN(m) ((m)->as.heap.sn)
|
|
86
|
+
#define RBIGINT_HEAP_SIZE(m) ((m)->as.heap.sz)
|
|
87
|
+
#define RBIGINT_SET_HEAP(m) do { \
|
|
88
|
+
(m)->flags |= RBIGINT_EMBED_SIZE_OVER << RBIGINT_EMBED_SIZE_SHIFT; \
|
|
89
|
+
} while (0)
|
|
90
|
+
#define RBIGINT_SET_HEAP_SIGN(m, s) do { \
|
|
91
|
+
(m)->as.heap.sn = (s); \
|
|
92
|
+
} while (0)
|
|
93
|
+
#define RBIGINT_SET_HEAP_SIZE(m, s) do { \
|
|
94
|
+
(m)->as.heap.sz = (s); \
|
|
95
|
+
} while (0)
|
|
96
|
+
|
|
97
|
+
#define RBIGINT_EMBED_P(m) ((((m)->flags >> RBIGINT_EMBED_SIZE_SHIFT) & RBIGINT_EMBED_SIZE_MASK) < RBIGINT_EMBED_SIZE_OVER)
|
|
98
|
+
#define RBIGINT_EMBED_ARY(m) ((m)->as.ary)
|
|
99
|
+
#define RBIGINT_EMBED_SIGN(m) ((short)(((m)->flags >> RBIGINT_EMBED_SIGN_SHIFT) & RBIGINT_EMBED_SIGN_MASK) - 1)
|
|
100
|
+
#define RBIGINT_EMBED_SIZE(m) (size_t)(((m)->flags >> RBIGINT_EMBED_SIZE_SHIFT) & RBIGINT_EMBED_SIZE_MASK)
|
|
101
|
+
#define RBIGINT_SET_EMBED_ZERO(m) do { \
|
|
102
|
+
(m)->flags &= ~(RBIGINT_EMBED_SIZE_MASK << RBIGINT_EMBED_SIZE_SHIFT); \
|
|
103
|
+
} while (0)
|
|
104
|
+
#define RBIGINT_SET_EMBED_SIGN(m, s) do { \
|
|
105
|
+
(m)->flags = ((((s) + 1) & RBIGINT_EMBED_SIGN_MASK) << RBIGINT_EMBED_SIGN_SHIFT) | \
|
|
106
|
+
((m)->flags & ~(RBIGINT_EMBED_SIGN_MASK << RBIGINT_EMBED_SIGN_SHIFT)); \
|
|
107
|
+
} while (0)
|
|
108
|
+
#define RBIGINT_SET_EMBED_SIZE(m, s) do { \
|
|
109
|
+
size_t s_tmp = (s); \
|
|
110
|
+
mrb_assert((s_tmp) <= RBIGINT_EMBED_SIZE_MAX); \
|
|
111
|
+
RBIGINT_SET_EMBED_ZERO(m); \
|
|
112
|
+
(m)->flags |= (s_tmp) << RBIGINT_EMBED_SIZE_SHIFT; \
|
|
113
|
+
} while (0)
|
|
114
|
+
|
|
115
|
+
mrb_static_assert_object_size(struct RBigint);
|
|
116
|
+
|
|
117
|
+
#endif /* MRUBY_BIGINT_H */
|