Skip to content

Commit

Permalink
Add missing types (lune-org#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
qwreey committed Nov 2, 2024
1 parent de7029a commit 37b5557
Showing 1 changed file with 33 additions and 13 deletions.
46 changes: 33 additions & 13 deletions types/ffi.luau
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ export type RefData = {
@param src The source data
@param len The amount of data to copy, in bytes
@param dst_offset The offset in the destination where the data will be pasted
@param src_offset The offset in the source data from where the data will be copied
@param dstOffset The offset in the destination where the data will be pasted
@param srcOffset The offset in the source data from where the data will be copied
]=]
copyFrom: (
self: RefData,
src: BoxData | RefData,
length: number,
dst_offset: number,
src_offset: number
dstOffset: number,
srcOffset: number
) -> (),
}

Expand Down Expand Up @@ -191,15 +191,15 @@ export type BoxData = {
@param src The source data
@param len The amount of data to copy, in bytes
@param dst_offset The offset in the destination where the data will be pasted
@param src_offset The offset in the source data from where the data will be copied
@param dstOffset The offset in the destination where the data will be pasted
@param srcOffset The offset in the source data from where the data will be copied
]=]
copyFrom: (
self: BoxData,
src: BoxData | RefData,
length: number,
dst_offset: number,
src_offset: number
dstOffset: number,
srcOffset: number
) -> (),
}

Expand Down Expand Up @@ -291,14 +291,23 @@ export type CTypeInfo<T, R> = {
box: (self: CTypeInfo<T, R>, val: R) -> BoxData,
readData: (self: CTypeInfo<T, R>, target: RefData | BoxData, offset: number?) -> R,
writeData: (self: CTypeInfo<T, R>, target: RefData | BoxData, value: R, offset: number?) -> (),
copyData: (
self: CTypeInfo<T, R>,
dst: RefData | BoxData,
src: RefData | BoxData,
dstOffset: number?,
srcOffset: number?
) -> (),
stringifyData: (self: CTypeInfo<T, R>, target: RefData | BoxData, offset: number?) -> string,

-- FIXME: recursive types; 'intoType' should be CTypes
cast: (
self: CTypeInfo<T, R>,
intoType: any,
fromData: RefData | BoxData,
intoData: RefData | BoxData
intoData: RefData | BoxData,
fromOffset: number?,
intoOffset: number?
) -> (),
} & { ["__phantom"]: T }
type NumCType<T> = CTypeInfo<T, (number | any)>
Expand Down Expand Up @@ -385,8 +394,8 @@ export type CArrInfo<T, R> = {
self: CArrInfo<T, R>,
dst: RefData | BoxData,
src: RefData | BoxData,
dst_offset: number?,
src_offset: number?
dstOffset: number?,
srcOffset: number?
) -> (),

offset: (self: CArrInfo<T, R>, index: number) -> number,
Expand Down Expand Up @@ -490,6 +499,17 @@ export type CStructInfo = {
@return A table
]=]
readData: (self: CStructInfo, target: RefData | BoxData, offset: number?) -> { any },
--[=[
@within CSturctInfo
@tag Method
@method writeData
Write a lua table into reference or box.
@param target Target to write data into
@param table Lua data to write
@param offset Offset to write data into
]=]
writeData: (
self: CStructInfo,
target: RefData | BoxData,
Expand All @@ -500,8 +520,8 @@ export type CStructInfo = {
self: CStructInfo,
dst: RefData | BoxData,
src: RefData | BoxData,
dst_offset: number?,
src_offset: number?
dstOffset: number?,
srcOffset: number?
) -> (),

offset: (self: CStructInfo, index: number) -> number,
Expand Down

0 comments on commit 37b5557

Please sign in to comment.