mirror of
https://github.com/janet-lang/janet
synced 2024-11-29 11:29:54 +00:00
fix C format
This commit is contained in:
parent
c81bf42f6b
commit
632b920e97
@ -926,7 +926,7 @@ void janet_unmarshal_byte(JanetMarshalContext *ctx, uint8_t *b) {
|
|||||||
|
|
||||||
void janet_unmarshal_bytes(JanetMarshalContext *ctx, uint8_t *dest, int32_t len) {
|
void janet_unmarshal_bytes(JanetMarshalContext *ctx, uint8_t *dest, int32_t len) {
|
||||||
UnmarshalState *st = (UnmarshalState *)(ctx->u_state);
|
UnmarshalState *st = (UnmarshalState *)(ctx->u_state);
|
||||||
MARSH_EOS(st, ctx->data+len-1);
|
MARSH_EOS(st, ctx->data + len - 1);
|
||||||
memcpy(dest, ctx->data, len);
|
memcpy(dest, ctx->data, len);
|
||||||
ctx->data += len;
|
ctx->data += len;
|
||||||
}
|
}
|
||||||
|
@ -293,19 +293,19 @@ static int is_ta_anytype(Janet x) {
|
|||||||
|
|
||||||
static int is_ta_type(Janet x, JanetTArrayType type) {
|
static int is_ta_type(Janet x, JanetTArrayType type) {
|
||||||
return (janet_checktype(x, JANET_ABSTRACT) && (type < TA_COUNT_TYPES) &&
|
return (janet_checktype(x, JANET_ABSTRACT) && (type < TA_COUNT_TYPES) &&
|
||||||
(janet_abstract_type(janet_unwrap_abstract(x))== &ta_array_types[type])) ? 1 : 0;
|
(janet_abstract_type(janet_unwrap_abstract(x)) == &ta_array_types[type])) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define CASE_TYPE_INITIALIZE(type) case JANET_TARRAY_TYPE_##type : ta_init_##type(view,buffer,size,offset,stride); break
|
#define CASE_TYPE_INITIALIZE(type) case JANET_TARRAY_TYPE_##type : ta_init_##type(view,buffer,size,offset,stride); break
|
||||||
|
|
||||||
JanetTArrayBuffer * janet_tarray_buffer(size_t size) {
|
JanetTArrayBuffer *janet_tarray_buffer(size_t size) {
|
||||||
JanetTArrayBuffer *buf = (JanetTArrayBuffer *)janet_abstract(&ta_buffer_type, sizeof(JanetTArrayBuffer));
|
JanetTArrayBuffer *buf = (JanetTArrayBuffer *)janet_abstract(&ta_buffer_type, sizeof(JanetTArrayBuffer));
|
||||||
ta_buffer_init(buf, size);
|
ta_buffer_init(buf, size);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
JanetTArrayView * janet_tarray_view(JanetTArrayType type,size_t size,size_t stride,size_t offset,JanetTArrayBuffer *buffer) {
|
JanetTArrayView *janet_tarray_view(JanetTArrayType type, size_t size, size_t stride, size_t offset, JanetTArrayBuffer *buffer) {
|
||||||
JanetTArrayView *view = janet_abstract(&ta_array_types[type], sizeof(JanetTArrayView));
|
JanetTArrayView *view = janet_abstract(&ta_array_types[type], sizeof(JanetTArrayView));
|
||||||
switch (type) {
|
switch (type) {
|
||||||
CASE_TYPE_INITIALIZE(uint8);
|
CASE_TYPE_INITIALIZE(uint8);
|
||||||
@ -318,7 +318,8 @@ JanetTArrayView * janet_tarray_view(JanetTArrayType type,size_t size,size_t stri
|
|||||||
CASE_TYPE_INITIALIZE(int64);
|
CASE_TYPE_INITIALIZE(int64);
|
||||||
CASE_TYPE_INITIALIZE(float32);
|
CASE_TYPE_INITIALIZE(float32);
|
||||||
CASE_TYPE_INITIALIZE(float64);
|
CASE_TYPE_INITIALIZE(float64);
|
||||||
default : janet_panic("bad typed array type");
|
default :
|
||||||
|
janet_panic("bad typed array type");
|
||||||
|
|
||||||
}
|
}
|
||||||
return view;
|
return view;
|
||||||
@ -330,20 +331,20 @@ JanetTArrayBuffer *janet_gettarray_buffer(const Janet *argv, int32_t n) {
|
|||||||
return (JanetTArrayBuffer *)janet_getabstract(argv, n, &ta_buffer_type);
|
return (JanetTArrayBuffer *)janet_getabstract(argv, n, &ta_buffer_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
int janet_is_tarray_view(Janet x,JanetTArrayType type) {
|
int janet_is_tarray_view(Janet x, JanetTArrayType type) {
|
||||||
return (type==JANET_TARRAY_TYPE_any) ? is_ta_anytype(x) : is_ta_type(x,type);
|
return (type == JANET_TARRAY_TYPE_any) ? is_ta_anytype(x) : is_ta_type(x, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
int janet_tarray_type_size(JanetTArrayType type) {
|
int janet_tarray_type_size(JanetTArrayType type) {
|
||||||
return (type<TA_COUNT_TYPES)? ta_type_sizes[type] : 0 ;
|
return (type < TA_COUNT_TYPES) ? ta_type_sizes[type] : 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
JanetTArrayView * janet_gettarray_view(const Janet *argv, int32_t n,JanetTArrayType type) {
|
JanetTArrayView *janet_gettarray_view(const Janet *argv, int32_t n, JanetTArrayType type) {
|
||||||
if (janet_is_tarray_view(argv[n],type)) {
|
if (janet_is_tarray_view(argv[n], type)) {
|
||||||
return (JanetTArrayView *)janet_unwrap_abstract(argv[n]);
|
return (JanetTArrayView *)janet_unwrap_abstract(argv[n]);
|
||||||
} else {
|
} else {
|
||||||
janet_panicf("bad slot #%d, expected typed array of type %s, got %v",
|
janet_panicf("bad slot #%d, expected typed array of type %s, got %v",
|
||||||
n, (type <= JANET_TARRAY_TYPE_any) ? ta_type_names[type] : "?" , argv[n]);
|
n, (type <= JANET_TARRAY_TYPE_any) ? ta_type_names[type] : "?", argv[n]);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -374,7 +375,7 @@ static Janet cfun_typed_array_new(int32_t argc, Janet *argv) {
|
|||||||
buffer = (JanetTArrayBuffer *)janet_getabstract(argv, 4, &ta_buffer_type);
|
buffer = (JanetTArrayBuffer *)janet_getabstract(argv, 4, &ta_buffer_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
JanetTArrayView * view =janet_tarray_view(type,size,stride,offset,buffer);
|
JanetTArrayView *view = janet_tarray_view(type, size, stride, offset, buffer);
|
||||||
return janet_wrap_abstract(view);
|
return janet_wrap_abstract(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,9 +433,9 @@ static Janet cfun_abstract_properties(int32_t argc, Janet *argv) {
|
|||||||
|
|
||||||
static Janet cfun_typed_array_copy_bytes(int32_t argc, Janet *argv) {
|
static Janet cfun_typed_array_copy_bytes(int32_t argc, Janet *argv) {
|
||||||
janet_arity(argc, 4, 5);
|
janet_arity(argc, 4, 5);
|
||||||
JanetTArrayView *src = janet_gettarray_view(argv,0,JANET_TARRAY_TYPE_any);
|
JanetTArrayView *src = janet_gettarray_view(argv, 0, JANET_TARRAY_TYPE_any);
|
||||||
size_t index_src = (size_t)janet_getinteger(argv, 1);
|
size_t index_src = (size_t)janet_getinteger(argv, 1);
|
||||||
JanetTArrayView *dst = janet_gettarray_view(argv,2,JANET_TARRAY_TYPE_any);
|
JanetTArrayView *dst = janet_gettarray_view(argv, 2, JANET_TARRAY_TYPE_any);
|
||||||
size_t index_dst = (size_t)janet_getinteger(argv, 3);
|
size_t index_dst = (size_t)janet_getinteger(argv, 3);
|
||||||
size_t count = (argc == 5) ? (size_t)janet_getinteger(argv, 4) : 1;
|
size_t count = (argc == 5) ? (size_t)janet_getinteger(argv, 4) : 1;
|
||||||
size_t src_atom_size = ta_type_sizes[src->type];
|
size_t src_atom_size = ta_type_sizes[src->type];
|
||||||
@ -459,9 +460,9 @@ static Janet cfun_typed_array_copy_bytes(int32_t argc, Janet *argv) {
|
|||||||
|
|
||||||
static Janet cfun_typed_array_swap_bytes(int32_t argc, Janet *argv) {
|
static Janet cfun_typed_array_swap_bytes(int32_t argc, Janet *argv) {
|
||||||
janet_arity(argc, 4, 5);
|
janet_arity(argc, 4, 5);
|
||||||
JanetTArrayView *src = janet_gettarray_view(argv,0,JANET_TARRAY_TYPE_any);
|
JanetTArrayView *src = janet_gettarray_view(argv, 0, JANET_TARRAY_TYPE_any);
|
||||||
size_t index_src = (size_t)janet_getinteger(argv, 1);
|
size_t index_src = (size_t)janet_getinteger(argv, 1);
|
||||||
JanetTArrayView *dst = janet_gettarray_view(argv,2,JANET_TARRAY_TYPE_any);
|
JanetTArrayView *dst = janet_gettarray_view(argv, 2, JANET_TARRAY_TYPE_any);
|
||||||
size_t index_dst = (size_t)janet_getinteger(argv, 3);
|
size_t index_dst = (size_t)janet_getinteger(argv, 3);
|
||||||
size_t count = (argc == 5) ? (size_t)janet_getinteger(argv, 4) : 1;
|
size_t count = (argc == 5) ? (size_t)janet_getinteger(argv, 4) : 1;
|
||||||
size_t src_atom_size = ta_type_sizes[src->type];
|
size_t src_atom_size = ta_type_sizes[src->type];
|
||||||
|
@ -1297,12 +1297,12 @@ typedef struct {
|
|||||||
JanetTArrayType type;
|
JanetTArrayType type;
|
||||||
} JanetTArrayView;
|
} JanetTArrayView;
|
||||||
|
|
||||||
JANET_API JanetTArrayBuffer * janet_tarray_buffer(size_t size);
|
JANET_API JanetTArrayBuffer *janet_tarray_buffer(size_t size);
|
||||||
JANET_API JanetTArrayView * janet_tarray_view(JanetTArrayType type,size_t size,size_t stride,size_t offset,JanetTArrayBuffer *buffer);
|
JANET_API JanetTArrayView *janet_tarray_view(JanetTArrayType type, size_t size, size_t stride, size_t offset, JanetTArrayBuffer *buffer);
|
||||||
JANET_API int janet_is_tarray_view(Janet x,JanetTArrayType type);
|
JANET_API int janet_is_tarray_view(Janet x, JanetTArrayType type);
|
||||||
JANET_API int janet_tarray_type_size(JanetTArrayType type);
|
JANET_API int janet_tarray_type_size(JanetTArrayType type);
|
||||||
JANET_API JanetTArrayBuffer * janet_gettarray_buffer(const Janet *argv, int32_t n);
|
JANET_API JanetTArrayBuffer *janet_gettarray_buffer(const Janet *argv, int32_t n);
|
||||||
JANET_API JanetTArrayView * janet_gettarray_view(const Janet *argv, int32_t n,JanetTArrayType type);
|
JANET_API JanetTArrayView *janet_gettarray_view(const Janet *argv, int32_t n, JanetTArrayType type);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user