mirror of
				https://github.com/janet-lang/janet
				synced 2025-11-04 09:33:02 +00:00 
			
		
		
		
	Remove typed arrays from the core.
Typed arrays will instead live in an external jpm nodule. Also, changes have been made to `jpm` to allow other natives to use the typedarray headers.
This commit is contained in:
		@@ -288,6 +288,11 @@ typedef struct {
 | 
			
		||||
    JANET_CURRENT_CONFIG_BITS })
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* What to do when out of memory */
 | 
			
		||||
#ifndef JANET_OUT_OF_MEMORY
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#define JANET_OUT_OF_MEMORY do { fprintf(stderr, "janet out of memory\n"); exit(1); } while (0)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/***** END SECTION CONFIG *****/
 | 
			
		||||
 | 
			
		||||
@@ -1856,59 +1861,6 @@ typedef struct {
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef JANET_TYPED_ARRAY
 | 
			
		||||
 | 
			
		||||
extern JANET_API const JanetAbstractType janet_ta_view_type;
 | 
			
		||||
extern JANET_API const JanetAbstractType janet_ta_buffer_type;
 | 
			
		||||
 | 
			
		||||
typedef enum {
 | 
			
		||||
    JANET_TARRAY_TYPE_U8,
 | 
			
		||||
    JANET_TARRAY_TYPE_S8,
 | 
			
		||||
    JANET_TARRAY_TYPE_U16,
 | 
			
		||||
    JANET_TARRAY_TYPE_S16,
 | 
			
		||||
    JANET_TARRAY_TYPE_U32,
 | 
			
		||||
    JANET_TARRAY_TYPE_S32,
 | 
			
		||||
    JANET_TARRAY_TYPE_U64,
 | 
			
		||||
    JANET_TARRAY_TYPE_S64,
 | 
			
		||||
    JANET_TARRAY_TYPE_F32,
 | 
			
		||||
    JANET_TARRAY_TYPE_F64
 | 
			
		||||
} JanetTArrayType;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
    uint8_t *data;
 | 
			
		||||
    size_t size;
 | 
			
		||||
    int32_t flags;
 | 
			
		||||
} JanetTArrayBuffer;
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
    union {
 | 
			
		||||
        void *pointer;
 | 
			
		||||
        uint8_t *u8;
 | 
			
		||||
        int8_t *s8;
 | 
			
		||||
        uint16_t *u16;
 | 
			
		||||
        int16_t *s16;
 | 
			
		||||
        uint32_t *u32;
 | 
			
		||||
        int32_t *s32;
 | 
			
		||||
        uint64_t *u64;
 | 
			
		||||
        int64_t *s64;
 | 
			
		||||
        float *f32;
 | 
			
		||||
        double *f64;
 | 
			
		||||
    } as;
 | 
			
		||||
    JanetTArrayBuffer *buffer;
 | 
			
		||||
    size_t size;
 | 
			
		||||
    size_t stride;
 | 
			
		||||
    JanetTArrayType type;
 | 
			
		||||
} JanetTArrayView;
 | 
			
		||||
 | 
			
		||||
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 int janet_is_tarray_view(Janet x, JanetTArrayType type);
 | 
			
		||||
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);
 | 
			
		||||
JanetTArrayView *janet_gettarray_any(const Janet *argv, int32_t n);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef JANET_INT_TYPES
 | 
			
		||||
 | 
			
		||||
extern JANET_API const JanetAbstractType janet_s64_type;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user