mirror of
https://github.com/janet-lang/janet
synced 2025-01-12 16:40:27 +00:00
Update whitespace and some doc strings.
This commit is contained in:
parent
36f92db61e
commit
4713219317
@ -266,7 +266,6 @@ static void marshal_one_fiber(MarshalState *st, JanetFiber *fiber, int flags) {
|
||||
marshal_one(st, janet_wrap_fiber(fiber->child), flags + 1);
|
||||
}
|
||||
|
||||
|
||||
void janet_marshal_int(JanetMarshalContext *ctx, int32_t value) {
|
||||
MarshalState *st = (MarshalState *)(ctx->m_state);
|
||||
pushint(st, value);
|
||||
@ -290,7 +289,6 @@ void janet_marshal_janet(JanetMarshalContext *ctx, Janet x) {
|
||||
#define MARK_SEEN() \
|
||||
janet_table_put(&st->seen, x, janet_wrap_integer(st->nextid++))
|
||||
|
||||
|
||||
static void marshal_one_abstract(MarshalState *st, Janet x, int flags) {
|
||||
void *abstract = janet_unwrap_abstract(x);
|
||||
const JanetAbstractType *at = janet_abstract_type(abstract);
|
||||
@ -306,7 +304,6 @@ static void marshal_one_abstract(MarshalState *st, Janet x, int flags) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* The main body of the marshaling function. Is the main
|
||||
* entry point for the mutually recursive functions. */
|
||||
static void marshal_one(MarshalState *st, Janet x, int flags) {
|
||||
@ -519,7 +516,6 @@ typedef struct {
|
||||
const uint8_t *end;
|
||||
} UnmarshalState;
|
||||
|
||||
|
||||
#define MARSH_EOS(st, data) do { \
|
||||
if ((data) >= (st)->end) janet_panic("unexpected end of source");\
|
||||
} while (0)
|
||||
@ -900,7 +896,6 @@ static const uint8_t *unmarshal_one_fiber(
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
void janet_unmarshal_int(JanetMarshalContext *ctx, int32_t *i) {
|
||||
UnmarshalState *st = (UnmarshalState *)(ctx->u_state);
|
||||
*i = readint(st, &(ctx->data));
|
||||
@ -916,8 +911,6 @@ void janet_unmarshal_size(JanetMarshalContext *ctx, size_t *i) {
|
||||
*i = (size_t)readint(st, &(ctx->data));
|
||||
};
|
||||
|
||||
|
||||
|
||||
void janet_unmarshal_byte(JanetMarshalContext *ctx, uint8_t *b) {
|
||||
UnmarshalState *st = (UnmarshalState *)(ctx->u_state);
|
||||
MARSH_EOS(st, ctx->data);
|
||||
@ -951,10 +944,6 @@ static const uint8_t *unmarshal_one_abstract(UnmarshalState *st, const uint8_t *
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static const uint8_t *unmarshal_one(
|
||||
UnmarshalState *st,
|
||||
const uint8_t *data,
|
||||
|
@ -40,7 +40,6 @@ typedef int64_t ta_int64_t;
|
||||
typedef float ta_float32_t;
|
||||
typedef double ta_float64_t;
|
||||
|
||||
|
||||
static char *ta_type_names[] = {
|
||||
"uint8",
|
||||
"int8",
|
||||
@ -52,7 +51,7 @@ static char *ta_type_names[] = {
|
||||
"int64",
|
||||
"float32",
|
||||
"float64",
|
||||
"any",
|
||||
"any"
|
||||
};
|
||||
|
||||
static size_t ta_type_sizes[] = {
|
||||
@ -68,6 +67,7 @@ static size_t ta_type_sizes[] = {
|
||||
sizeof(ta_float64_t),
|
||||
0,
|
||||
};
|
||||
|
||||
#define TA_COUNT_TYPES (JANET_TARRAY_TYPE_float64 + 1)
|
||||
#define TA_ATOM_MAXSIZE 8
|
||||
#define TA_FLAG_BIG_ENDIAN 1
|
||||
@ -81,8 +81,6 @@ static JanetTArrayType get_ta_type_by_name(const uint8_t *name) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static JanetTArrayBuffer *ta_buffer_init(JanetTArrayBuffer *buf, size_t size) {
|
||||
buf->data = NULL;
|
||||
if (size > 0) {
|
||||
@ -123,7 +121,6 @@ static void ta_buffer_unmarshal(void *p, JanetMarshalContext *ctx) {
|
||||
janet_unmarshal_bytes(ctx, buf->data, buf->size);
|
||||
}
|
||||
|
||||
|
||||
static const JanetAbstractType ta_buffer_type = {
|
||||
"ta/buffer",
|
||||
ta_buffer_gc,
|
||||
@ -134,9 +131,6 @@ static const JanetAbstractType ta_buffer_type = {
|
||||
ta_buffer_unmarshal,
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
static int ta_mark(void *p, size_t s) {
|
||||
(void) s;
|
||||
JanetTArrayView *view = (JanetTArrayView *)p;
|
||||
@ -154,7 +148,6 @@ static void ta_view_marshal(void *p, JanetMarshalContext *ctx) {
|
||||
janet_marshal_janet(ctx, janet_wrap_abstract(view->buffer));
|
||||
}
|
||||
|
||||
|
||||
static void ta_view_unmarshal(void *p, JanetMarshalContext *ctx) {
|
||||
JanetTArrayView *view = (JanetTArrayView *)p;
|
||||
size_t offset;
|
||||
@ -171,17 +164,13 @@ static void ta_view_unmarshal(void *p, JanetMarshalContext *ctx) {
|
||||
view->data = view->buffer->data + offset;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define DEFINE_VIEW_TYPE(thetype) \
|
||||
typedef struct { \
|
||||
JanetTArrayBuffer * buffer; \
|
||||
ta_##thetype##_t * data; \
|
||||
size_t size; \
|
||||
size_t stride; \
|
||||
JanetTArrayType type; \
|
||||
typedef struct { \
|
||||
JanetTArrayBuffer * buffer; \
|
||||
ta_##thetype##_t * data; \
|
||||
size_t size; \
|
||||
size_t stride; \
|
||||
JanetTArrayType type; \
|
||||
} TA_View_##thetype ;
|
||||
|
||||
|
||||
@ -471,7 +460,6 @@ static Janet cfun_typed_array_slice(int32_t argc, Janet *argv) {
|
||||
return janet_wrap_array(array);
|
||||
}
|
||||
|
||||
|
||||
static Janet cfun_typed_array_copy_bytes(int32_t argc, Janet *argv) {
|
||||
janet_arity(argc, 4, 5);
|
||||
JanetTArrayView *src = janet_gettarray_view(argv, 0, JANET_TARRAY_TYPE_any);
|
||||
@ -529,65 +517,57 @@ static Janet cfun_typed_array_swap_bytes(int32_t argc, Janet *argv) {
|
||||
return janet_wrap_nil();
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const JanetReg ta_cfuns[] = {
|
||||
{
|
||||
"tarray/new", cfun_typed_array_new,
|
||||
JDOC("(tarray/new type size [stride = 1 [offset = 0 [tarray | buffer]]] )\n\n"
|
||||
"Create new typed array")
|
||||
"Create new typed array.")
|
||||
},
|
||||
{
|
||||
"tarray/buffer", cfun_typed_array_buffer,
|
||||
JDOC("(tarray/buffer (array | size) )\n\n"
|
||||
"return typed array buffer or create a new buffer ")
|
||||
"Return typed array buffer or create a new buffer.")
|
||||
},
|
||||
{
|
||||
"tarray/length", cfun_typed_array_size,
|
||||
JDOC("(tarray/length (array | buffer) )\n\n"
|
||||
"return typed array or buffer size ")
|
||||
"Return typed array or buffer size.")
|
||||
},
|
||||
{
|
||||
"tarray/properties", cfun_typed_array_properties,
|
||||
JDOC("(tarray/properties array )\n\n"
|
||||
"return typed array properties as a struct")
|
||||
"Return typed array properties as a struct.")
|
||||
},
|
||||
{
|
||||
"tarray/copy-bytes", cfun_typed_array_copy_bytes,
|
||||
JDOC("(tarray/copy-bytes src sindex dst dindex [count=1])\n\n"
|
||||
"copy count elements of src array from index sindex \n"
|
||||
"to dst array at position dindex \n"
|
||||
"memory can overlap"
|
||||
)
|
||||
"Copy count elements of src array from index sindex "
|
||||
"to dst array at position dindex "
|
||||
"memory can overlap.")
|
||||
},
|
||||
{
|
||||
"tarray/swap-bytes", cfun_typed_array_swap_bytes,
|
||||
JDOC("(tarray/swap-bytes src sindex dst dindex [count=1])\n\n"
|
||||
"swap count elements between src array from index sindex \n"
|
||||
"and dst array at position dindex \n"
|
||||
"memory can overlap"
|
||||
)
|
||||
"Swap count elements between src array from index sindex "
|
||||
"and dst array at position dindex "
|
||||
"memory can overlap.")
|
||||
},
|
||||
{
|
||||
"tarray/slice", cfun_typed_array_slice,
|
||||
JDOC("(tarray/slice tarr [, start=0 [, end=(size tarr)]])\n\n"
|
||||
"Takes a slice of typed array from start to end. The range is half"
|
||||
"open, [start, end). Indexes can also be negative, indicating indexing"
|
||||
"from the end of the end of the typed array. By default, start is 0 and end is"
|
||||
"Takes a slice of a typed array from start to end. The range is half "
|
||||
"open, [start, end). Indexes can also be negative, indicating indexing "
|
||||
"from the end of the end of the typed array. By default, start is 0 and end is "
|
||||
"the size of the typed array. Returns a new janet array.")
|
||||
},
|
||||
{
|
||||
"abstract/properties", cfun_abstract_properties,
|
||||
JDOC("(abstract/properties tag)\n\n"
|
||||
"return abstract type properties as a struct")
|
||||
"Returns abstract type properties as a struct.")
|
||||
},
|
||||
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/* Module entry point */
|
||||
void janet_lib_typed_array(JanetTable *env) {
|
||||
janet_core_cfuns(env, NULL, ta_cfuns);
|
||||
|
@ -289,7 +289,7 @@
|
||||
<array>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(\\[ne0zft"\\']|\\x[0-9a-fA-F][0-9a-fA-f])</string>
|
||||
<string>(\\[nevr0zft"\\']|\\x[0-9a-fA-F][0-9a-fA-f])</string>
|
||||
<key>name</key>
|
||||
<string>constant.character.escape.janet</string>
|
||||
</dict>
|
||||
|
Loading…
Reference in New Issue
Block a user