Add type hints to layout constants

This commit is contained in:
Joshua Suskalo 2022-01-18 14:15:08 -06:00
parent 6ba905e6bf
commit 104db6b8fd

View file

@ -31,7 +31,8 @@
MemorySegment MemorySegment
ResourceScope ResourceScope
ResourceScope$Handle ResourceScope$Handle
SegmentAllocator))) SegmentAllocator
ValueLayout)))
(defn stack-scope (defn stack-scope
"Constructs a new scope for use only in this thread. "Constructs a new scope for use only in this thread.
@ -209,57 +210,57 @@
(map #(slice segment (* % size) size) (map #(slice segment (* % size) size)
(range num-segments)))) (range num-segments))))
(def big-endian (def ^ByteOrder big-endian
"The big-endian [[ByteOrder]]. "The big-endian [[ByteOrder]].
See [[little-endian]], [[native-endian]]." See [[little-endian]], [[native-endian]]."
ByteOrder/BIG_ENDIAN) ByteOrder/BIG_ENDIAN)
(def little-endian (def ^ByteOrder little-endian
"The little-endian [[ByteOrder]]. "The little-endian [[ByteOrder]].
See [[big-endian]], [[native-endian]]" See [[big-endian]], [[native-endian]]"
ByteOrder/LITTLE_ENDIAN) ByteOrder/LITTLE_ENDIAN)
(def native-endian (def ^ByteOrder native-endian
"The [[ByteOrder]] for the native endianness of the current hardware. "The [[ByteOrder]] for the native endianness of the current hardware.
See [[big-endian]], [[little-endian]]." See [[big-endian]], [[little-endian]]."
(ByteOrder/nativeOrder)) (ByteOrder/nativeOrder))
(def byte-layout (def ^ValueLayout byte-layout
"The [[MemoryLayout]] for a byte in [[native-endian]] [[ByteOrder]]." "The [[MemoryLayout]] for a byte in [[native-endian]] [[ByteOrder]]."
CLinker/C_CHAR) CLinker/C_CHAR)
(def short-layout (def ^ValueLayout short-layout
"The [[MemoryLayout]] for a c-sized short in [[native-endian]] [[ByteOrder]]." "The [[MemoryLayout]] for a c-sized short in [[native-endian]] [[ByteOrder]]."
CLinker/C_SHORT) CLinker/C_SHORT)
(def int-layout (def ^ValueLayout int-layout
"The [[MemoryLayout]] for a c-sized int in [[native-endian]] [[ByteOrder]]." "The [[MemoryLayout]] for a c-sized int in [[native-endian]] [[ByteOrder]]."
CLinker/C_INT) CLinker/C_INT)
(def long-layout (def ^ValueLayout long-layout
"The [[MemoryLayout]] for a c-sized long in [[native-endian]] [[ByteOrder]]." "The [[MemoryLayout]] for a c-sized long in [[native-endian]] [[ByteOrder]]."
CLinker/C_LONG) CLinker/C_LONG)
(def long-long-layout (def ^ValueLayout long-long-layout
"The [[MemoryLayout]] for a c-sized long-long in [[native-endian]] [[ByteOrder]]." "The [[MemoryLayout]] for a c-sized long-long in [[native-endian]] [[ByteOrder]]."
CLinker/C_LONG_LONG) CLinker/C_LONG_LONG)
(def char-layout (def ^ValueLayout char-layout
"The [[MemoryLayout]] for a c-sized char in [[native-endian]] [[ByteOrder]]." "The [[MemoryLayout]] for a c-sized char in [[native-endian]] [[ByteOrder]]."
CLinker/C_CHAR) CLinker/C_CHAR)
(def float-layout (def ^ValueLayout float-layout
"The [[MemoryLayout]] for a c-sized float in [[native-endian]] [[ByteOrder]]." "The [[MemoryLayout]] for a c-sized float in [[native-endian]] [[ByteOrder]]."
CLinker/C_FLOAT) CLinker/C_FLOAT)
(def double-layout (def ^ValueLayout double-layout
"The [[MemoryLayout]] for a c-sized double in [[native-endian]] [[ByteOrder]]." "The [[MemoryLayout]] for a c-sized double in [[native-endian]] [[ByteOrder]]."
CLinker/C_DOUBLE) CLinker/C_DOUBLE)
(def pointer-layout (def ^ValueLayout pointer-layout
"The [[MemoryLayout]] for a native pointer in [[native-endian]] [[ByteOrder]]." "The [[MemoryLayout]] for a native pointer in [[native-endian]] [[ByteOrder]]."
CLinker/C_POINTER) CLinker/C_POINTER)