ndtypes 0.2.0dev5 → 0.2.0dev6
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/CONTRIBUTING.md +12 -0
- data/Rakefile +8 -0
- data/ext/ruby_ndtypes/GPATH +0 -0
- data/ext/ruby_ndtypes/GRTAGS +0 -0
- data/ext/ruby_ndtypes/GTAGS +0 -0
- data/ext/ruby_ndtypes/extconf.rb +1 -1
- data/ext/ruby_ndtypes/include/ndtypes.h +231 -122
- data/ext/ruby_ndtypes/include/ruby_ndtypes.h +1 -1
- data/ext/ruby_ndtypes/lib/libndtypes.a +0 -0
- data/ext/ruby_ndtypes/lib/libndtypes.so.0.2.0dev3 +0 -0
- data/ext/ruby_ndtypes/ndtypes/Makefile +87 -0
- data/ext/ruby_ndtypes/ndtypes/config.h +68 -0
- data/ext/ruby_ndtypes/ndtypes/config.log +477 -0
- data/ext/ruby_ndtypes/ndtypes/config.status +1027 -0
- data/ext/ruby_ndtypes/ndtypes/doc/_static/style.css +7 -0
- data/ext/ruby_ndtypes/ndtypes/doc/_templates/layout.html +2 -0
- data/ext/ruby_ndtypes/ndtypes/doc/conf.py +40 -4
- data/ext/ruby_ndtypes/ndtypes/doc/images/xndlogo.png +0 -0
- data/ext/ruby_ndtypes/ndtypes/doc/ndtypes/types.rst +1 -1
- data/ext/ruby_ndtypes/ndtypes/doc/requirements.txt +2 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/Makefile +287 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/Makefile.in +20 -4
- data/ext/ruby_ndtypes/ndtypes/libndtypes/Makefile.vc +22 -3
- data/ext/ruby_ndtypes/ndtypes/libndtypes/alloc.c +1 -1
- data/ext/ruby_ndtypes/ndtypes/libndtypes/alloc.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/attr.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/Makefile +73 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bpgrammar.c +246 -229
- data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bpgrammar.h +15 -11
- data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bpgrammar.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bpgrammar.y +38 -28
- data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bplexer.c +91 -91
- data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bplexer.h +1 -1
- data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bplexer.l +4 -3
- data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/bplexer.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/export.c +8 -7
- data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/export.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/import.c +2 -2
- data/ext/ruby_ndtypes/ndtypes/libndtypes/compat/import.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/context.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/copy.c +263 -182
- data/ext/ruby_ndtypes/ndtypes/libndtypes/copy.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/encodings.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/equal.c +67 -7
- data/ext/ruby_ndtypes/ndtypes/libndtypes/equal.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/grammar.c +1112 -1000
- data/ext/ruby_ndtypes/ndtypes/libndtypes/grammar.h +69 -58
- data/ext/ruby_ndtypes/ndtypes/libndtypes/grammar.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/grammar.y +150 -99
- data/ext/ruby_ndtypes/ndtypes/libndtypes/io.c +185 -15
- data/ext/ruby_ndtypes/ndtypes/libndtypes/io.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/lexer.c +301 -276
- data/ext/ruby_ndtypes/ndtypes/libndtypes/lexer.h +1 -1
- data/ext/ruby_ndtypes/ndtypes/libndtypes/lexer.l +9 -4
- data/ext/ruby_ndtypes/ndtypes/libndtypes/lexer.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/libndtypes.a +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/libndtypes.so +1 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/libndtypes.so.0 +1 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/libndtypes.so.0.2.0dev3 +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/match.c +729 -228
- data/ext/ruby_ndtypes/ndtypes/libndtypes/match.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/ndtypes.c +768 -403
- data/ext/ruby_ndtypes/ndtypes/libndtypes/ndtypes.h +1002 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/ndtypes.h.in +231 -122
- data/ext/ruby_ndtypes/ndtypes/libndtypes/ndtypes.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/parsefuncs.c +176 -84
- data/ext/ruby_ndtypes/ndtypes/libndtypes/parsefuncs.h +26 -14
- data/ext/ruby_ndtypes/ndtypes/libndtypes/parsefuncs.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/parser.c +57 -35
- data/ext/ruby_ndtypes/ndtypes/libndtypes/parser.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/primitive.c +420 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/primitive.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/seq.c +8 -8
- data/ext/ruby_ndtypes/ndtypes/libndtypes/seq.h +1 -1
- data/ext/ruby_ndtypes/ndtypes/libndtypes/seq.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/serialize/Makefile +48 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/serialize/deserialize.c +200 -116
- data/ext/ruby_ndtypes/ndtypes/libndtypes/serialize/deserialize.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/serialize/serialize.c +46 -4
- data/ext/ruby_ndtypes/ndtypes/libndtypes/serialize/serialize.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/substitute.c +58 -27
- data/ext/ruby_ndtypes/ndtypes/libndtypes/substitute.h +1 -1
- data/ext/ruby_ndtypes/ndtypes/libndtypes/substitute.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/symtable.c +3 -5
- data/ext/ruby_ndtypes/ndtypes/libndtypes/symtable.h +12 -4
- data/ext/ruby_ndtypes/ndtypes/libndtypes/symtable.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/Makefile +55 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/Makefile.in +8 -8
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/Makefile.vc +5 -5
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/runtest.c +274 -172
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test.h +24 -4
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_array.c +2 -2
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_buffer.c +14 -14
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_match.c +32 -30
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_parse.c +37 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_parse_error.c +36 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_parse_roundtrip.c +16 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_record.c +5 -5
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_typecheck.c +706 -253
- data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_unify.c +132 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/unify.c +703 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/unify.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/util.c +335 -127
- data/ext/ruby_ndtypes/ndtypes/libndtypes/util.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/libndtypes/values.c +2 -2
- data/ext/ruby_ndtypes/ndtypes/libndtypes/values.o +0 -0
- data/ext/ruby_ndtypes/ndtypes/python/ndt_randtype.py +88 -71
- data/ext/ruby_ndtypes/ndtypes/python/ndt_support.py +0 -1
- data/ext/ruby_ndtypes/ndtypes/python/ndtypes/__init__.py +10 -13
- data/ext/ruby_ndtypes/ndtypes/python/ndtypes/_ndtypes.c +395 -314
- data/ext/ruby_ndtypes/ndtypes/python/ndtypes/libndtypes.a +0 -0
- data/ext/ruby_ndtypes/ndtypes/python/ndtypes/libndtypes.so +1 -0
- data/ext/ruby_ndtypes/ndtypes/python/ndtypes/libndtypes.so.0 +1 -0
- data/ext/ruby_ndtypes/ndtypes/python/ndtypes/libndtypes.so.0.2.0dev3 +0 -0
- data/ext/ruby_ndtypes/ndtypes/python/ndtypes/ndtypes.h +1002 -0
- data/ext/ruby_ndtypes/ndtypes/python/ndtypes/pyndtypes.h +15 -33
- data/ext/ruby_ndtypes/ndtypes/python/test_ndtypes.py +340 -132
- data/ext/ruby_ndtypes/ndtypes/setup.py +11 -2
- data/ext/ruby_ndtypes/ruby_ndtypes.c +364 -241
- data/ext/ruby_ndtypes/ruby_ndtypes.h +1 -1
- data/ext/ruby_ndtypes/ruby_ndtypes_internal.h +0 -1
- data/lib/ndtypes.rb +11 -0
- data/lib/ndtypes/version.rb +2 -2
- data/lib/ruby_ndtypes.so +0 -0
- data/ndtypes.gemspec +3 -0
- data/spec/ndtypes_spec.rb +6 -0
- metadata +98 -4
- data/ext/ruby_ndtypes/gc_guard.c +0 -36
- data/ext/ruby_ndtypes/gc_guard.h +0 -12
|
@@ -64,25 +64,37 @@ ndt_attr_t *mk_attr_from_seq(char *name, ndt_string_seq_t *seq, ndt_context_t *c
|
|
|
64
64
|
/* Parser functions for creating types */
|
|
65
65
|
/*****************************************************************************/
|
|
66
66
|
|
|
67
|
-
ndt_t *
|
|
67
|
+
const ndt_t *mk_module(char *name, const ndt_t *type, ndt_context_t *ctx);
|
|
68
|
+
const ndt_t *mk_function(ndt_type_seq_t *in, ndt_type_seq_t *out, ndt_context_t *ctx);
|
|
68
69
|
|
|
69
|
-
ndt_t *mk_fortran(ndt_t *type, ndt_context_t *ctx);
|
|
70
|
-
ndt_t *mk_contig(char *name, ndt_t *type, ndt_context_t *ctx);
|
|
71
|
-
ndt_t *mk_fixed_dim_from_shape(char *v, ndt_t *type, ndt_context_t *ctx);
|
|
72
|
-
ndt_t *mk_fixed_dim_from_attrs(ndt_attr_seq_t *attrs, ndt_t *type, ndt_context_t *ctx);
|
|
70
|
+
const ndt_t *mk_fortran(const ndt_t *type, ndt_context_t *ctx);
|
|
71
|
+
const ndt_t *mk_contig(char *name, ndt_t *type, ndt_context_t *ctx);
|
|
72
|
+
const ndt_t *mk_fixed_dim_from_shape(char *v, const ndt_t *type, ndt_context_t *ctx);
|
|
73
|
+
const ndt_t *mk_fixed_dim_from_attrs(ndt_attr_seq_t *attrs, const ndt_t *type, ndt_context_t *ctx);
|
|
73
74
|
|
|
74
|
-
ndt_t *mk_var_dim(
|
|
75
|
-
ndt_t *mk_var_ellipsis(ndt_t *type, ndt_context_t *ctx);
|
|
75
|
+
const ndt_t *mk_var_dim(ndt_attr_seq_t *seq, const ndt_t *type, bool opt, ndt_context_t *ctx);
|
|
76
|
+
const ndt_t *mk_var_ellipsis(const ndt_t *type, ndt_context_t *ctx);
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
ndt_t *
|
|
79
|
-
ndt_t *mk_record(enum ndt_variadic flag, ndt_field_seq_t *fields, ndt_attr_seq_t *attrs, ndt_context_t *ctx);
|
|
78
|
+
const ndt_t *mk_ellipsis_dim(char *name, const ndt_t *type, ndt_context_t *ctx);
|
|
79
|
+
const ndt_t *mk_symbolic_dim(char *name, const ndt_t *type, ndt_context_t *ctx);
|
|
80
80
|
|
|
81
|
-
ndt_t *
|
|
81
|
+
const ndt_t *mk_array(const ndt_t *type, bool opt, ndt_context_t *ctx);
|
|
82
|
+
const ndt_t *mk_array_ellipsis(const ndt_t *type, ndt_context_t *ctx);
|
|
83
|
+
|
|
84
|
+
ndt_field_t *mk_field(char *name, const ndt_t *type, ndt_attr_seq_t *seq, ndt_context_t *ctx);
|
|
85
|
+
const ndt_t *mk_tuple(enum ndt_variadic flag, ndt_field_seq_t *fields, ndt_attr_seq_t *attrs, bool opt, ndt_context_t *ctx);
|
|
86
|
+
const ndt_t *mk_record(enum ndt_variadic flag, ndt_field_seq_t *fields, ndt_attr_seq_t *attrs, bool opt, ndt_context_t *ctx);
|
|
87
|
+
const ndt_t * mk_union(ndt_field_seq_t *fields, bool opt, ndt_context_t *ctx);
|
|
88
|
+
|
|
89
|
+
const ndt_t *mk_constr(char *name, const ndt_t *type, bool opt, ndt_context_t *ctx);
|
|
90
|
+
const ndt_t *mk_ref(const ndt_t *type, bool opt, ndt_context_t *ctx);
|
|
91
|
+
|
|
92
|
+
const ndt_t *mk_categorical(ndt_value_seq_t *seq, bool opt, ndt_context_t *ctx);
|
|
93
|
+
|
|
94
|
+
const ndt_t *mk_fixed_string(char *v, enum ndt_encoding encoding, bool opt, ndt_context_t *ctx);
|
|
95
|
+
const ndt_t *mk_bytes(ndt_attr_seq_t *seq, bool opt, ndt_context_t *ctx);
|
|
96
|
+
const ndt_t *mk_fixed_bytes(ndt_attr_seq_t *seq, bool opt, ndt_context_t *ctx);
|
|
82
97
|
|
|
83
|
-
ndt_t *mk_fixed_string(char *v, enum ndt_encoding encoding, ndt_context_t *ctx);
|
|
84
|
-
ndt_t *mk_bytes(ndt_attr_seq_t *seq, ndt_context_t *ctx);
|
|
85
|
-
ndt_t *mk_fixed_bytes(ndt_attr_seq_t *seq, ndt_context_t *ctx);
|
|
86
98
|
|
|
87
99
|
|
|
88
100
|
/* END LOCAL SCOPE */
|
|
Binary file
|
|
@@ -63,11 +63,11 @@ ndt_fopen(const char *name, const char *mode)
|
|
|
63
63
|
jmp_buf ndt_lexerror;
|
|
64
64
|
|
|
65
65
|
|
|
66
|
-
static ndt_t *
|
|
67
|
-
_ndt_from_fp(
|
|
66
|
+
static const ndt_t *
|
|
67
|
+
_ndt_from_fp(FILE *fp, ndt_context_t *ctx)
|
|
68
68
|
{
|
|
69
69
|
volatile yyscan_t scanner = NULL;
|
|
70
|
-
ndt_t *ast = NULL;
|
|
70
|
+
const ndt_t *ast = NULL;
|
|
71
71
|
int ret;
|
|
72
72
|
|
|
73
73
|
if (setjmp(ndt_lexerror) == 0) {
|
|
@@ -80,7 +80,7 @@ _ndt_from_fp(ndt_meta_t *m, FILE *fp, ndt_context_t *ctx)
|
|
|
80
80
|
ndt_yyset_in(fp, scanner);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
ret = ndt_yyparse(scanner, &ast,
|
|
83
|
+
ret = ndt_yyparse(scanner, &ast, ctx);
|
|
84
84
|
ndt_yylex_destroy(scanner);
|
|
85
85
|
|
|
86
86
|
if (ret == 2) {
|
|
@@ -99,11 +99,11 @@ _ndt_from_fp(ndt_meta_t *m, FILE *fp, ndt_context_t *ctx)
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
static ndt_t *
|
|
103
|
-
_ndt_from_file(
|
|
102
|
+
static const ndt_t *
|
|
103
|
+
_ndt_from_file(const char *name, ndt_context_t *ctx)
|
|
104
104
|
{
|
|
105
105
|
FILE *fp;
|
|
106
|
-
ndt_t *t;
|
|
106
|
+
const ndt_t *t;
|
|
107
107
|
|
|
108
108
|
if (strcmp(name, "-") == 0) {
|
|
109
109
|
fp = stdin;
|
|
@@ -116,32 +116,26 @@ _ndt_from_file(ndt_meta_t *m, const char *name, ndt_context_t *ctx)
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
t = _ndt_from_fp(
|
|
119
|
+
t = _ndt_from_fp(fp, ctx);
|
|
120
120
|
fclose(fp);
|
|
121
121
|
|
|
122
122
|
return t;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
ndt_t *
|
|
125
|
+
const ndt_t *
|
|
126
126
|
ndt_from_file(const char *name, ndt_context_t *ctx)
|
|
127
127
|
{
|
|
128
|
-
return _ndt_from_file(
|
|
128
|
+
return _ndt_from_file(name, ctx);
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
ndt_t *
|
|
132
|
-
|
|
133
|
-
{
|
|
134
|
-
return _ndt_from_file(m, name, ctx);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
static ndt_t *
|
|
138
|
-
_ndt_from_string(ndt_meta_t *m, const char *input, ndt_context_t *ctx)
|
|
131
|
+
static const ndt_t *
|
|
132
|
+
_ndt_from_string(const char *input, ndt_context_t *ctx)
|
|
139
133
|
{
|
|
140
134
|
volatile yyscan_t scanner = NULL;
|
|
141
135
|
volatile YY_BUFFER_STATE state = NULL;
|
|
142
136
|
char *buffer;
|
|
143
137
|
size_t size;
|
|
144
|
-
ndt_t *ast = NULL;
|
|
138
|
+
const ndt_t *ast = NULL;
|
|
145
139
|
int ret;
|
|
146
140
|
|
|
147
141
|
size = strlen(input);
|
|
@@ -170,7 +164,7 @@ _ndt_from_string(ndt_meta_t *m, const char *input, ndt_context_t *ctx)
|
|
|
170
164
|
state->yy_bs_lineno = 1;
|
|
171
165
|
state->yy_bs_column = 1;
|
|
172
166
|
|
|
173
|
-
ret = ndt_yyparse(scanner, &ast,
|
|
167
|
+
ret = ndt_yyparse(scanner, &ast, ctx);
|
|
174
168
|
ndt_yy_delete_buffer(state, scanner);
|
|
175
169
|
ndt_yylex_destroy(scanner);
|
|
176
170
|
ndt_free(buffer);
|
|
@@ -194,32 +188,27 @@ _ndt_from_string(ndt_meta_t *m, const char *input, ndt_context_t *ctx)
|
|
|
194
188
|
}
|
|
195
189
|
}
|
|
196
190
|
|
|
197
|
-
ndt_t *
|
|
191
|
+
const ndt_t *
|
|
198
192
|
ndt_from_string(const char *input, ndt_context_t *ctx)
|
|
199
193
|
{
|
|
200
|
-
return _ndt_from_string(
|
|
194
|
+
return _ndt_from_string(input, ctx);
|
|
201
195
|
}
|
|
202
196
|
|
|
203
|
-
ndt_t *
|
|
197
|
+
const ndt_t *
|
|
204
198
|
ndt_from_string_v(const char *input, ndt_context_t *ctx)
|
|
205
199
|
{
|
|
206
|
-
ndt_t *t = _ndt_from_string(
|
|
200
|
+
const ndt_t *t = _ndt_from_string(input, ctx);
|
|
207
201
|
if (t == NULL) {
|
|
208
202
|
ndt_err_append(ctx, input);
|
|
209
203
|
}
|
|
210
204
|
return t;
|
|
211
205
|
}
|
|
212
206
|
|
|
213
|
-
ndt_t *
|
|
214
|
-
ndt_from_string_fill_meta(ndt_meta_t *m, const char *input, ndt_context_t *ctx)
|
|
215
|
-
{
|
|
216
|
-
return _ndt_from_string(m, input, ctx);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
ndt_t *
|
|
207
|
+
const ndt_t *
|
|
220
208
|
ndt_from_metadata_and_dtype(const ndt_meta_t *m, const char *dtype, ndt_context_t *ctx)
|
|
221
209
|
{
|
|
222
|
-
ndt_t *t
|
|
210
|
+
const ndt_t *t;
|
|
211
|
+
const ndt_t *type;
|
|
223
212
|
int i;
|
|
224
213
|
|
|
225
214
|
type = ndt_from_string(dtype, ctx);
|
|
@@ -230,17 +219,50 @@ ndt_from_metadata_and_dtype(const ndt_meta_t *m, const char *dtype, ndt_context_
|
|
|
230
219
|
if (ndt_is_abstract(type)) {
|
|
231
220
|
ndt_err_format(ctx, NDT_InvalidArgumentError,
|
|
232
221
|
"cannot create abstract type with offsets");
|
|
233
|
-
|
|
222
|
+
ndt_decref(type);
|
|
223
|
+
return NULL;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
for (i=0, t=type; i < m->ndims; i++, type=t) {
|
|
227
|
+
t = ndt_var_dim(type, m->offsets[i], 0, NULL, false,
|
|
228
|
+
ctx);
|
|
229
|
+
ndt_decref(type);
|
|
230
|
+
if (t == NULL) {
|
|
231
|
+
return NULL;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return t;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const ndt_t *
|
|
239
|
+
ndt_from_metadata_opt_and_dtype(const ndt_meta_t *m, bool *opt, const ndt_t *dtype,
|
|
240
|
+
ndt_context_t *ctx)
|
|
241
|
+
{
|
|
242
|
+
const ndt_t *t;
|
|
243
|
+
const ndt_t *type;
|
|
244
|
+
int i;
|
|
245
|
+
|
|
246
|
+
if (ndt_is_abstract(dtype)) {
|
|
247
|
+
ndt_err_format(ctx, NDT_InvalidArgumentError,
|
|
248
|
+
"cannot create abstract type with offsets");
|
|
249
|
+
ndt_free(opt);
|
|
234
250
|
return NULL;
|
|
235
251
|
}
|
|
236
252
|
|
|
253
|
+
type = dtype;
|
|
254
|
+
ndt_incref(type);
|
|
255
|
+
|
|
237
256
|
for (i=0, t=type; i < m->ndims; i++, type=t) {
|
|
238
|
-
t = ndt_var_dim(type,
|
|
239
|
-
|
|
257
|
+
t = ndt_var_dim(type, m->offsets[i], 0, NULL, opt[i],
|
|
258
|
+
ctx);
|
|
259
|
+
ndt_decref(type);
|
|
240
260
|
if (t == NULL) {
|
|
261
|
+
ndt_free(opt);
|
|
241
262
|
return NULL;
|
|
242
263
|
}
|
|
243
264
|
}
|
|
244
265
|
|
|
266
|
+
ndt_free(opt);
|
|
245
267
|
return t;
|
|
246
268
|
}
|
|
Binary file
|
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* BSD 3-Clause License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2017-2018, plures
|
|
5
|
+
* All rights reserved.
|
|
6
|
+
*
|
|
7
|
+
* Redistribution and use in source and binary forms, with or without
|
|
8
|
+
* modification, are permitted provided that the following conditions are met:
|
|
9
|
+
*
|
|
10
|
+
* 1. Redistributions of source code must retain the above copyright notice,
|
|
11
|
+
* this list of conditions and the following disclaimer.
|
|
12
|
+
*
|
|
13
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
14
|
+
* this list of conditions and the following disclaimer in the documentation
|
|
15
|
+
* and/or other materials provided with the distribution.
|
|
16
|
+
*
|
|
17
|
+
* 3. Neither the name of the copyright holder nor the names of its
|
|
18
|
+
* contributors may be used to endorse or promote products derived from
|
|
19
|
+
* this software without specific prior written permission.
|
|
20
|
+
*
|
|
21
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
22
|
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
23
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
24
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
25
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
26
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
27
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
28
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
29
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
30
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
#ifdef _MSC_VER
|
|
35
|
+
#include <windows.h>
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
#include <stdlib.h>
|
|
39
|
+
#include <string.h>
|
|
40
|
+
#include <stdint.h>
|
|
41
|
+
#include <inttypes.h>
|
|
42
|
+
#include <stdbool.h>
|
|
43
|
+
#include <complex.h>
|
|
44
|
+
#include <assert.h>
|
|
45
|
+
#include "ndtypes.h"
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
/******************************************************************************/
|
|
49
|
+
/* Primitive types */
|
|
50
|
+
/******************************************************************************/
|
|
51
|
+
|
|
52
|
+
typedef bool bool_t;
|
|
53
|
+
#undef bool
|
|
54
|
+
|
|
55
|
+
#define NDT_PRIMITIVE(name, _tag, _access, _flags, _size, _align) \
|
|
56
|
+
static const ndt_t ndt_##name = { \
|
|
57
|
+
.tag = _tag, \
|
|
58
|
+
.access = _access, \
|
|
59
|
+
.flags = _flags, \
|
|
60
|
+
.ndim = 0, \
|
|
61
|
+
.datasize = _size, \
|
|
62
|
+
.align = _align, \
|
|
63
|
+
.refcnt = 1 \
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
#define NDT_PRIMITIVE_LE(name, _tag, _access, _flags, _size, _align) \
|
|
67
|
+
static const ndt_t ndt_##name##_le = { \
|
|
68
|
+
.tag = _tag, \
|
|
69
|
+
.access = _access, \
|
|
70
|
+
.flags = _flags|NDT_LITTLE_ENDIAN, \
|
|
71
|
+
.ndim = 0, \
|
|
72
|
+
.datasize = _size, \
|
|
73
|
+
.align = _align, \
|
|
74
|
+
.refcnt = 1 \
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
#define NDT_PRIMITIVE_BE(name, _tag, _access, _flags, _size, _align) \
|
|
78
|
+
static const ndt_t ndt_##name##_be = { \
|
|
79
|
+
.tag = _tag, \
|
|
80
|
+
.access = _access, \
|
|
81
|
+
.flags = _flags|NDT_BIG_ENDIAN, \
|
|
82
|
+
.ndim = 0, \
|
|
83
|
+
.datasize = _size, \
|
|
84
|
+
.align = _align, \
|
|
85
|
+
.refcnt = 1 \
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
#define NDT_PRIMITIVE_OPT(name, _tag, _access, _flags, _size, _align) \
|
|
89
|
+
static const ndt_t ndt_##name##_opt = { \
|
|
90
|
+
.tag = _tag, \
|
|
91
|
+
.access = _access, \
|
|
92
|
+
.flags = _flags|NDT_OPTION, \
|
|
93
|
+
.ndim = 0, \
|
|
94
|
+
.datasize = _size, \
|
|
95
|
+
.align = _align, \
|
|
96
|
+
.refcnt = 1 \
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
#define NDT_PRIMITIVE_OPT_LE(name, _tag, _access, _flags, _size, _align) \
|
|
100
|
+
static const ndt_t ndt_##name##_opt_le = { \
|
|
101
|
+
.tag = _tag, \
|
|
102
|
+
.access = _access, \
|
|
103
|
+
.flags = _flags|NDT_OPTION|NDT_LITTLE_ENDIAN, \
|
|
104
|
+
.ndim = 0, \
|
|
105
|
+
.datasize = _size, \
|
|
106
|
+
.align = _align, \
|
|
107
|
+
.refcnt = 1 \
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
#define NDT_PRIMITIVE_OPT_BE(name, _tag, _access, _flags, _size, _align) \
|
|
111
|
+
static const ndt_t ndt_##name##_opt_be = { \
|
|
112
|
+
.tag = _tag, \
|
|
113
|
+
.access = _access, \
|
|
114
|
+
.flags = _flags|NDT_OPTION|NDT_BIG_ENDIAN, \
|
|
115
|
+
.ndim = 0, \
|
|
116
|
+
.datasize = _size, \
|
|
117
|
+
.align = _align, \
|
|
118
|
+
.refcnt = 1 \
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
#define NDT_PRIMITIVE_ALL(name, _tag, _size, _align) \
|
|
122
|
+
NDT_PRIMITIVE(name, _tag, Concrete, 0, _size, _align) \
|
|
123
|
+
NDT_PRIMITIVE_LE(name, _tag, Concrete, 0, _size, _align) \
|
|
124
|
+
NDT_PRIMITIVE_BE(name, _tag, Concrete, 0, _size, _align) \
|
|
125
|
+
NDT_PRIMITIVE_OPT(name, _tag, Concrete, 0, _size, _align) \
|
|
126
|
+
NDT_PRIMITIVE_OPT_LE(name, _tag, Concrete, 0, _size, _align) \
|
|
127
|
+
NDT_PRIMITIVE_OPT_BE(name, _tag, Concrete, 0, _size, _align)
|
|
128
|
+
|
|
129
|
+
#define NDT_PRIMITIVE_KIND_ALL(name, _tag) \
|
|
130
|
+
NDT_PRIMITIVE(name, _tag, Abstract, 0, 0, UINT16_MAX) \
|
|
131
|
+
NDT_PRIMITIVE_LE(name, _tag, Abstract, 0, 0, UINT16_MAX) \
|
|
132
|
+
NDT_PRIMITIVE_BE(name, _tag, Abstract, 0, 0, UINT16_MAX) \
|
|
133
|
+
NDT_PRIMITIVE_OPT(name, _tag, Abstract, 0, 0, UINT16_MAX) \
|
|
134
|
+
NDT_PRIMITIVE_OPT_LE(name, _tag, Abstract, 0, 0, UINT16_MAX) \
|
|
135
|
+
NDT_PRIMITIVE_OPT_BE(name, _tag, Abstract, 0, 0, UINT16_MAX)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
NDT_PRIMITIVE_ALL(bool, Bool, sizeof(bool_t), alignof(bool_t))
|
|
139
|
+
|
|
140
|
+
NDT_PRIMITIVE_KIND_ALL(signed_set, SignedKind)
|
|
141
|
+
NDT_PRIMITIVE_ALL(int8, Int8, sizeof(int8_t), alignof(int8_t))
|
|
142
|
+
NDT_PRIMITIVE_ALL(int16, Int16, sizeof(int16_t), alignof(int16_t))
|
|
143
|
+
NDT_PRIMITIVE_ALL(int32, Int32, sizeof(int32_t), alignof(int32_t))
|
|
144
|
+
NDT_PRIMITIVE_ALL(int64, Int64, sizeof(int64_t), alignof(int64_t))
|
|
145
|
+
|
|
146
|
+
NDT_PRIMITIVE_KIND_ALL(unsigned_set, UnsignedKind)
|
|
147
|
+
NDT_PRIMITIVE_ALL(uint8, Uint8, sizeof(uint8_t), alignof(uint8_t))
|
|
148
|
+
NDT_PRIMITIVE_ALL(uint16, Uint16, sizeof(uint16_t), alignof(uint16_t))
|
|
149
|
+
NDT_PRIMITIVE_ALL(uint32, Uint32, sizeof(uint32_t), alignof(uint32_t))
|
|
150
|
+
NDT_PRIMITIVE_ALL(uint64, Uint64, sizeof(uint64_t), alignof(uint64_t))
|
|
151
|
+
|
|
152
|
+
NDT_PRIMITIVE_KIND_ALL(float_set, FloatKind)
|
|
153
|
+
NDT_PRIMITIVE_ALL(bfloat16, BFloat16, 2, 2)
|
|
154
|
+
NDT_PRIMITIVE_ALL(float16, Float16, 2, 2)
|
|
155
|
+
NDT_PRIMITIVE_ALL(float32, Float32, sizeof(float), alignof(float))
|
|
156
|
+
NDT_PRIMITIVE_ALL(float64, Float64, sizeof(double), alignof(double))
|
|
157
|
+
|
|
158
|
+
NDT_PRIMITIVE_KIND_ALL(complex_set, ComplexKind)
|
|
159
|
+
NDT_PRIMITIVE_ALL(bcomplex32, BComplex32, 4, 2)
|
|
160
|
+
NDT_PRIMITIVE_ALL(complex32, Complex32, 4, 2)
|
|
161
|
+
NDT_PRIMITIVE_ALL(complex64, Complex64, sizeof(ndt_complex64_t), alignof(ndt_complex64_t))
|
|
162
|
+
NDT_PRIMITIVE_ALL(complex128, Complex128, sizeof(ndt_complex128_t), alignof(ndt_complex128_t))
|
|
163
|
+
|
|
164
|
+
NDT_PRIMITIVE(str, String, Concrete, NDT_POINTER, sizeof(char *), alignof(char *))
|
|
165
|
+
NDT_PRIMITIVE_OPT(str, String, Concrete, NDT_POINTER, sizeof(char *), alignof(char *))
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
const ndt_t *
|
|
169
|
+
ndt_string(bool_t opt, ndt_context_t *ctx)
|
|
170
|
+
{
|
|
171
|
+
(void)ctx;
|
|
172
|
+
|
|
173
|
+
return opt ? &ndt_str_opt : &ndt_str;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const ndt_t *
|
|
177
|
+
ndt_signed_kind(uint32_t flags, ndt_context_t *ctx)
|
|
178
|
+
{
|
|
179
|
+
return ndt_primitive(SignedKind, flags, ctx);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const ndt_t *
|
|
183
|
+
ndt_unsigned_kind(uint32_t flags, ndt_context_t *ctx)
|
|
184
|
+
{
|
|
185
|
+
return ndt_primitive(UnsignedKind, flags, ctx);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const ndt_t *
|
|
189
|
+
ndt_float_kind(uint32_t flags, ndt_context_t *ctx)
|
|
190
|
+
{
|
|
191
|
+
return ndt_primitive(FloatKind, flags, ctx);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const ndt_t *
|
|
195
|
+
ndt_complex_kind(uint32_t flags, ndt_context_t *ctx)
|
|
196
|
+
{
|
|
197
|
+
return ndt_primitive(ComplexKind, flags, ctx);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const ndt_t *
|
|
201
|
+
ndt_primitive(enum ndt tag, uint32_t flags, ndt_context_t *ctx)
|
|
202
|
+
{
|
|
203
|
+
switch(flags) {
|
|
204
|
+
case 0: {
|
|
205
|
+
switch(tag) {
|
|
206
|
+
case Bool: return &ndt_bool;
|
|
207
|
+
|
|
208
|
+
case SignedKind: return &ndt_signed_set;
|
|
209
|
+
case Int8: return &ndt_int8;
|
|
210
|
+
case Int16: return &ndt_int16;
|
|
211
|
+
case Int32: return &ndt_int32;
|
|
212
|
+
case Int64: return &ndt_int64;
|
|
213
|
+
|
|
214
|
+
case UnsignedKind: return &ndt_unsigned_set;
|
|
215
|
+
case Uint8: return &ndt_uint8;
|
|
216
|
+
case Uint16: return &ndt_uint16;
|
|
217
|
+
case Uint32: return &ndt_uint32;
|
|
218
|
+
case Uint64: return &ndt_uint64;
|
|
219
|
+
|
|
220
|
+
case FloatKind: return &ndt_float_set;
|
|
221
|
+
case BFloat16: return &ndt_bfloat16;
|
|
222
|
+
case Float16: return &ndt_float16;
|
|
223
|
+
case Float32: return &ndt_float32;
|
|
224
|
+
case Float64: return &ndt_float64;
|
|
225
|
+
|
|
226
|
+
case ComplexKind: return &ndt_complex_set;
|
|
227
|
+
case BComplex32: return &ndt_bcomplex32;
|
|
228
|
+
case Complex32: return &ndt_complex32;
|
|
229
|
+
case Complex64: return &ndt_complex64;
|
|
230
|
+
case Complex128: return &ndt_complex128;
|
|
231
|
+
|
|
232
|
+
default: goto value_error_tag;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
case NDT_LITTLE_ENDIAN: {
|
|
237
|
+
switch(tag) {
|
|
238
|
+
case Bool: return &ndt_bool_le;
|
|
239
|
+
|
|
240
|
+
case SignedKind: return &ndt_signed_set_le;
|
|
241
|
+
case Int8: return &ndt_int8_le;
|
|
242
|
+
case Int16: return &ndt_int16_le;
|
|
243
|
+
case Int32: return &ndt_int32_le;
|
|
244
|
+
case Int64: return &ndt_int64_le;
|
|
245
|
+
|
|
246
|
+
case UnsignedKind: return &ndt_unsigned_set_le;
|
|
247
|
+
case Uint8: return &ndt_uint8_le;
|
|
248
|
+
case Uint16: return &ndt_uint16_le;
|
|
249
|
+
case Uint32: return &ndt_uint32_le;
|
|
250
|
+
case Uint64: return &ndt_uint64_le;
|
|
251
|
+
|
|
252
|
+
case FloatKind: return &ndt_float_set_le;
|
|
253
|
+
case BFloat16: return &ndt_bfloat16_le;
|
|
254
|
+
case Float16: return &ndt_float16_le;
|
|
255
|
+
case Float32: return &ndt_float32_le;
|
|
256
|
+
case Float64: return &ndt_float64_le;
|
|
257
|
+
|
|
258
|
+
case ComplexKind: return &ndt_complex_set_le;
|
|
259
|
+
case BComplex32: return &ndt_bcomplex32_le;
|
|
260
|
+
case Complex32: return &ndt_complex32_le;
|
|
261
|
+
case Complex64: return &ndt_complex64_le;
|
|
262
|
+
case Complex128: return &ndt_complex128_le;
|
|
263
|
+
|
|
264
|
+
default: goto value_error_tag;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
case NDT_BIG_ENDIAN: {
|
|
269
|
+
switch(tag) {
|
|
270
|
+
case Bool: return &ndt_bool_be;
|
|
271
|
+
|
|
272
|
+
case SignedKind: return &ndt_signed_set_be;
|
|
273
|
+
case Int8: return &ndt_int8_be;
|
|
274
|
+
case Int16: return &ndt_int16_be;
|
|
275
|
+
case Int32: return &ndt_int32_be;
|
|
276
|
+
case Int64: return &ndt_int64_be;
|
|
277
|
+
|
|
278
|
+
case UnsignedKind: return &ndt_unsigned_set_be;
|
|
279
|
+
case Uint8: return &ndt_uint8_be;
|
|
280
|
+
case Uint16: return &ndt_uint16_be;
|
|
281
|
+
case Uint32: return &ndt_uint32_be;
|
|
282
|
+
case Uint64: return &ndt_uint64_be;
|
|
283
|
+
|
|
284
|
+
case FloatKind: return &ndt_float_set_be;
|
|
285
|
+
case BFloat16: return &ndt_bfloat16_be;
|
|
286
|
+
case Float16: return &ndt_float16_be;
|
|
287
|
+
case Float32: return &ndt_float32_be;
|
|
288
|
+
case Float64: return &ndt_float64_be;
|
|
289
|
+
|
|
290
|
+
case ComplexKind: return &ndt_complex_set_be;
|
|
291
|
+
case BComplex32: return &ndt_bcomplex32_be;
|
|
292
|
+
case Complex32: return &ndt_complex32_be;
|
|
293
|
+
case Complex64: return &ndt_complex64_be;
|
|
294
|
+
case Complex128: return &ndt_complex128_be;
|
|
295
|
+
|
|
296
|
+
default: goto value_error_tag;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
case NDT_OPTION: {
|
|
301
|
+
switch(tag) {
|
|
302
|
+
case Bool: return &ndt_bool_opt;
|
|
303
|
+
|
|
304
|
+
case SignedKind: return &ndt_signed_set_opt;
|
|
305
|
+
case Int8: return &ndt_int8_opt;
|
|
306
|
+
case Int16: return &ndt_int16_opt;
|
|
307
|
+
case Int32: return &ndt_int32_opt;
|
|
308
|
+
case Int64: return &ndt_int64_opt;
|
|
309
|
+
|
|
310
|
+
case UnsignedKind: return &ndt_unsigned_set_opt;
|
|
311
|
+
case Uint8: return &ndt_uint8_opt;
|
|
312
|
+
case Uint16: return &ndt_uint16_opt;
|
|
313
|
+
case Uint32: return &ndt_uint32_opt;
|
|
314
|
+
case Uint64: return &ndt_uint64_opt;
|
|
315
|
+
|
|
316
|
+
case FloatKind: return &ndt_float_set_opt;
|
|
317
|
+
case BFloat16: return &ndt_bfloat16_opt;
|
|
318
|
+
case Float16: return &ndt_float16_opt;
|
|
319
|
+
case Float32: return &ndt_float32_opt;
|
|
320
|
+
case Float64: return &ndt_float64_opt;
|
|
321
|
+
|
|
322
|
+
case ComplexKind: return &ndt_complex_set_opt;
|
|
323
|
+
case BComplex32: return &ndt_bcomplex32_opt;
|
|
324
|
+
case Complex32: return &ndt_complex32_opt;
|
|
325
|
+
case Complex64: return &ndt_complex64_opt;
|
|
326
|
+
case Complex128: return &ndt_complex128_opt;
|
|
327
|
+
|
|
328
|
+
default: goto value_error_tag;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
case NDT_OPTION|NDT_LITTLE_ENDIAN: {
|
|
333
|
+
switch(tag) {
|
|
334
|
+
case Bool: return &ndt_bool_opt_le;
|
|
335
|
+
|
|
336
|
+
case SignedKind: return &ndt_signed_set_opt_le;
|
|
337
|
+
case Int8: return &ndt_int8_opt_le;
|
|
338
|
+
case Int16: return &ndt_int16_opt_le;
|
|
339
|
+
case Int32: return &ndt_int32_opt_le;
|
|
340
|
+
case Int64: return &ndt_int64_opt_le;
|
|
341
|
+
|
|
342
|
+
case UnsignedKind: return &ndt_unsigned_set_opt_le;
|
|
343
|
+
case Uint8: return &ndt_uint8_opt_le;
|
|
344
|
+
case Uint16: return &ndt_uint16_opt_le;
|
|
345
|
+
case Uint32: return &ndt_uint32_opt_le;
|
|
346
|
+
case Uint64: return &ndt_uint64_opt_le;
|
|
347
|
+
|
|
348
|
+
case FloatKind: return &ndt_float_set_opt_le;
|
|
349
|
+
case BFloat16: return &ndt_bfloat16_opt_le;
|
|
350
|
+
case Float16: return &ndt_float16_opt_le;
|
|
351
|
+
case Float32: return &ndt_float32_opt_le;
|
|
352
|
+
case Float64: return &ndt_float64_opt_le;
|
|
353
|
+
|
|
354
|
+
case ComplexKind: return &ndt_complex_set_opt_le;
|
|
355
|
+
case BComplex32: return &ndt_bcomplex32_opt_le;
|
|
356
|
+
case Complex32: return &ndt_complex32_opt_le;
|
|
357
|
+
case Complex64: return &ndt_complex64_opt_le;
|
|
358
|
+
case Complex128: return &ndt_complex128_opt_le;
|
|
359
|
+
default: goto value_error_tag;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
case NDT_OPTION|NDT_BIG_ENDIAN: {
|
|
364
|
+
switch(tag) {
|
|
365
|
+
case Bool: return &ndt_bool_opt_be;
|
|
366
|
+
|
|
367
|
+
case SignedKind: return &ndt_signed_set_opt_be;
|
|
368
|
+
case Int8: return &ndt_int8_opt_be;
|
|
369
|
+
case Int16: return &ndt_int16_opt_be;
|
|
370
|
+
case Int32: return &ndt_int32_opt_be;
|
|
371
|
+
case Int64: return &ndt_int64_opt_be;
|
|
372
|
+
|
|
373
|
+
case UnsignedKind: return &ndt_unsigned_set_opt_be;
|
|
374
|
+
case Uint8: return &ndt_uint8_opt_be;
|
|
375
|
+
case Uint16: return &ndt_uint16_opt_be;
|
|
376
|
+
case Uint32: return &ndt_uint32_opt_be;
|
|
377
|
+
case Uint64: return &ndt_uint64_opt_be;
|
|
378
|
+
|
|
379
|
+
case FloatKind: return &ndt_float_set_opt_be;
|
|
380
|
+
case BFloat16: return &ndt_bfloat16_opt_be;
|
|
381
|
+
case Float16: return &ndt_float16_opt_be;
|
|
382
|
+
case Float32: return &ndt_float32_opt_be;
|
|
383
|
+
case Float64: return &ndt_float64_opt_be;
|
|
384
|
+
|
|
385
|
+
case ComplexKind: return &ndt_complex_set_opt_be;
|
|
386
|
+
case BComplex32: return &ndt_bcomplex32_opt_be;
|
|
387
|
+
case Complex32: return &ndt_complex32_opt_be;
|
|
388
|
+
case Complex64: return &ndt_complex64_opt_be;
|
|
389
|
+
case Complex128: return &ndt_complex128_opt_be;
|
|
390
|
+
|
|
391
|
+
default: goto value_error_tag;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
case NDT_POINTER: {
|
|
396
|
+
switch(tag) {
|
|
397
|
+
case String: return &ndt_str;
|
|
398
|
+
default: goto value_error_tag;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
case NDT_POINTER|NDT_OPTION: {
|
|
403
|
+
switch(tag) {
|
|
404
|
+
case String: return &ndt_str_opt;
|
|
405
|
+
default: goto value_error_tag;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
default:
|
|
410
|
+
goto value_error_flags;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
value_error_tag:
|
|
414
|
+
ndt_err_format(ctx, NDT_ValueError, "not a primitive type");
|
|
415
|
+
return NULL;
|
|
416
|
+
|
|
417
|
+
value_error_flags:
|
|
418
|
+
ndt_err_format(ctx, NDT_ValueError, "invalid type flags");
|
|
419
|
+
return NULL;
|
|
420
|
+
}
|