From a67e43cd26211de407ce756ad945d86316b23dd7 Mon Sep 17 00:00:00 2001 From: retropikzel Date: Tue, 5 Aug 2025 09:34:30 +0300 Subject: [PATCH] Fixing stklos --- foreign/c.sld | 1 + foreign/c/primitives/stklos.scm | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/foreign/c.sld b/foreign/c.sld index 6d2babc..b37e81a 100644 --- a/foreign/c.sld +++ b/foreign/c.sld @@ -147,6 +147,7 @@ cpointer-data-set! cpointer-set! cpointer-ref + c-size-of void?)) (export ; calculate-struct-size-and-offsets ;struct-make diff --git a/foreign/c/primitives/stklos.scm b/foreign/c/primitives/stklos.scm index 2d244d1..f188f67 100644 --- a/foreign/c/primitives/stklos.scm +++ b/foreign/c/primitives/stklos.scm @@ -72,7 +72,7 @@ (type->native-type return-type)))))) ; FIXME -(define size-of-type +#;(define size-of-type (lambda (type) (cond ((equal? type 'int8) 1) ((equal? type 'uint8) 1) @@ -94,6 +94,28 @@ ((equal? type 'double) 8) ((equal? type 'pointer) 8)))) +(define size-of-type + (lambda (type) + (cond ((equal? type 'int8) (c-size-of :int8)) + ((equal? type 'uint8) (c-size-of :uint8)) + ((equal? type 'int16) (c-size-of :int16)) + ((equal? type 'uint16) (c-size-of :uint16)) + ((equal? type 'int32) (c-size-of :int32)) + ((equal? type 'uint32) (c-size-of :uint32)) + ((equal? type 'int64) (c-size-of :int64)) + ((equal? type 'uint64) (c-size-of :uint64)) + ((equal? type 'char) (c-size-of :char)) + ((equal? type 'unsigned-char) (c-size-of :uchar)) + ((equal? type 'short) (c-size-of :short)) + ((equal? type 'unsigned-short) (c-size-of :ushort)) + ((equal? type 'int) (c-size-of :int)) + ((equal? type 'unsigned-int) (c-size-of :uint)) + ((equal? type 'long) (c-size-of :long)) + ((equal? type 'unsigned-long) (c-size-of :ulong)) + ((equal? type 'float) (c-size-of :float)) + ((equal? type 'double) (c-size-of :double)) + ((equal? type 'pointer) (c-size-of :pointer))))) + (define c-bytevector-u8-set! (lambda (pointer offset value) (cpointer-set! pointer :uint8 value offset)))