From b95266ef3c69a093ecd3b3fd18016801107bfab9 Mon Sep 17 00:00:00 2001 From: kimpure Date: Sun, 3 Nov 2024 01:07:10 +0900 Subject: [PATCH 1/7] type plus --- types/ffi.luau | 239 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 239 insertions(+) diff --git a/types/ffi.luau b/types/ffi.luau index b41875fa..91dcdb11 100644 --- a/types/ffi.luau +++ b/types/ffi.luau @@ -284,13 +284,80 @@ export type CTypeInfo = { signedness: boolean, -- subtype + --[=[ + @within CTypeInfo + @tag Method + @Method ptr + + create a pointer subtype. + + @return pointer subtype + ]=] ptr: (self: CTypeInfo) -> CPtrInfo>, + + --[=[ + @within CTypeInfo + @tag Method + @Method arr + + create an array subtype. + + @param len The length of the array + @return array subtype + ]=] arr: (self: CTypeInfo, len: number) -> CArrInfo, R>, -- realize + --[=[ + @within CTypeInfo + @tag Method + @Method box + + create a box with initial values + + @param table The array of field values + @return A box + ]=] box: (self: CTypeInfo, val: R) -> BoxData, + + --[=[ + @within CTypeInfo + @tag Method + @method readData + + Read a lua table from reference or box. + + @param target Target to read data from + @param offset Offset to read data from + @return A table + ]=] readData: (self: CTypeInfo, target: RefData | BoxData, offset: number?) -> R, + + --[=[ + @within CTypeInfo + @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: CTypeInfo, target: RefData | BoxData, value: R, offset: number?) -> (), + + --[=[ + @within CTypeInfo + @tag Method + @Method copyData + + copy values ​​from the source and paste them into the target. + + @param destination where the data will be pasted + @param src The source data + @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 + ]=] copyData: ( self: CTypeInfo, dst: RefData | BoxData, @@ -298,9 +365,37 @@ export type CTypeInfo = { dstOffset: number?, srcOffset: number? ) -> (), + + --[=[ + @within CTypeInfo + @tag Method + @Method stringifyData + + stringify data. Useful when you need to output numbers that Lua can't handle. + + @param memory to output + @param memory byte offset + ]=] stringifyData: (self: CTypeInfo, target: RefData | BoxData, offset: number?) -> string, -- FIXME: recursive types; 'intoType' should be CTypes + --[=[ + @within CTypeInfo + @tag Method + @Method cast + + casting a value to a different type. + + may result in loss of precision. + + FIXME: recursive types; 'intoType' should be CTypes + + @param type to convert + @param memory to read the value to be converted + @param memory to use the converted value + @param memory byte offset to read + @param memory byte offset to write + ]=] cast: ( self: CTypeInfo, intoType: any, @@ -334,11 +429,55 @@ export type CPtrInfo = { -- subtype -- FIXME: recursive types; result 'any' should be CArrInfo> + --[=[ + @within CPtrInfo + @tag Method + @Method arr + + create an array subtype. + FIXME: recursive types; result 'any' should be CArrInfo> + + @param len The length of the array + @return array subtype + ]=] arr: (self: CPtrInfo, len: number) -> any, + -- FIXME: recursive types; result 'any' should be CPtrInfo> + --[=[ + @within CPtrInfo + @tag Method + @Method ptr + + create a pointer subtype. + FIXME: recursive types; result 'any' should be CPtrInfo> + + @return pointer subtype + ]=] ptr: (self: CPtrInfo) -> any, + --[=[ + @within CPtrInfo + @tag Method + @Method readData + + similar to readData . Reads data in the reference (the memory space pointed to by reference). + + @param Reference to read + @param byte offset + ]=] readRef: (self: CPtrInfo, target: RefData | BoxData, offset: number?) -> RefData, + + --[=[ + @within CPtrInfo + @tag Method + @Method writeData + + similar to writeData. Writes data in the reference (in the memory space pointed to by). + + @param reference to use + @param lua value to use + @param byte offset + ]=] writeRef: ( self: CPtrInfo, target: RefData | BoxData, @@ -379,17 +518,74 @@ export type CArrInfo = { inner: T, -- subtype + --[=[ + @within CArrInfo + @tag Method + @Method ptr + + create a pointer subtype. + FIXME: recursive types; result 'any' should be CPtrInfo> + + @return pointer subtype + ]=] ptr: (self: CArrInfo) -> CPtrInfo>, -- realize + --[=[ + @within CArrInfo + @tag Method + @Method box + + create a box with initial values + + @param table The array of field values + @return A box + ]=] box: (self: CArrInfo, table: { T }) -> BoxData, + + --[=[ + @within CArrInfo + @tag Method + @method readData + + Read a lua table from reference or box. + + @param target Target to read data from + @param offset Offset to read data from + @return A table + ]=] readData: (self: CArrInfo, target: RefData | BoxData, offset: number?) -> { T }, + + --[=[ + @within CArrInfo + @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: CArrInfo, target: RefData | BoxData, value: { R }, target_offset: number? ) -> (), + + --[=[ + @within CArrInfo + @tag Method + @Method copyData + + copy values ​​from the source and paste them into the target. + + @param destination where the data will be pasted + @param src The source data + @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 + ]=] copyData: ( self: CArrInfo, dst: RefData | BoxData, @@ -398,6 +594,16 @@ export type CArrInfo = { srcOffset: number? ) -> (), + --[=[ + @within CArrInfo + @tag Method + @method copyData + + returns the byte offset of the field. + + @param field index + @return byte offset + ]=] offset: (self: CArrInfo, index: number) -> number, } @@ -516,6 +722,18 @@ export type CStructInfo = { table: { any }, offset: number? ) -> (), + --[=[ + @within CSturctInfo + @tag Method + @method copyData + + Copy values from the source and paste them into the target. + + @param destination where the data will be pasted + @param src The source data + @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 + ]=] copyData: ( self: CStructInfo, dst: RefData | BoxData, @@ -524,7 +742,28 @@ export type CStructInfo = { srcOffset: number? ) -> (), + --[=[ + @within CSturctInfo + @tag Method + @method copyData + + returns the byte offset of the field. + + @param field index + @return byte offset + ]=] offset: (self: CStructInfo, index: number) -> number, + + --[=[ + @within CSturctInfo + @tag Method + @method copyData + + returns the field type + + @param field index + @return field type + ]=] field: (self: CStructInfo, index: number) -> CTypes, } From 7856764fd4630e8f3ecf9d3d5a4d89dc6b8d04d1 Mon Sep 17 00:00:00 2001 From: kimpure Date: Tue, 5 Nov 2024 22:02:29 +0900 Subject: [PATCH 2/7] fix --- types/ffi.luau | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/types/ffi.luau b/types/ffi.luau index 91dcdb11..daca4c4c 100644 --- a/types/ffi.luau +++ b/types/ffi.luau @@ -289,7 +289,7 @@ export type CTypeInfo = { @tag Method @Method ptr - create a pointer subtype. + Create a pointer subtype. @return pointer subtype ]=] @@ -300,10 +300,10 @@ export type CTypeInfo = { @tag Method @Method arr - create an array subtype. + Create an array subtype. @param len The length of the array - @return array subtype + @return An array subtype ]=] arr: (self: CTypeInfo, len: number) -> CArrInfo, R>, @@ -435,10 +435,9 @@ export type CPtrInfo = { @Method arr create an array subtype. - FIXME: recursive types; result 'any' should be CArrInfo> @param len The length of the array - @return array subtype + @return An array subtype ]=] arr: (self: CPtrInfo, len: number) -> any, @@ -748,21 +747,21 @@ export type CStructInfo = { @method copyData returns the byte offset of the field. - + @param field index - @return byte offset + @return the byte offset ]=] offset: (self: CStructInfo, index: number) -> number, --[=[ @within CSturctInfo @tag Method - @method copyData + @method field - returns the field type + Get the field type. - @param field index - @return field type + @param index The field index + @return The field type ]=] field: (self: CStructInfo, index: number) -> CTypes, } From c20ef95d6d97800d91cabb32277eeee747cb5f6c Mon Sep 17 00:00:00 2001 From: kimpure Date: Tue, 5 Nov 2024 22:03:49 +0900 Subject: [PATCH 3/7] fix --- types/ffi.luau | 2 -- 1 file changed, 2 deletions(-) diff --git a/types/ffi.luau b/types/ffi.luau index daca4c4c..dcff859f 100644 --- a/types/ffi.luau +++ b/types/ffi.luau @@ -387,8 +387,6 @@ export type CTypeInfo = { casting a value to a different type. may result in loss of precision. - - FIXME: recursive types; 'intoType' should be CTypes @param type to convert @param memory to read the value to be converted From 208bfa1bc729669e0319e6c02690dbbb94997a70 Mon Sep 17 00:00:00 2001 From: kimpure Date: Tue, 5 Nov 2024 22:05:43 +0900 Subject: [PATCH 4/7] fix --- types/ffi.luau | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/ffi.luau b/types/ffi.luau index dcff859f..088952d3 100644 --- a/types/ffi.luau +++ b/types/ffi.luau @@ -313,7 +313,7 @@ export type CTypeInfo = { @tag Method @Method box - create a box with initial values + Create a box with initial values @param table The array of field values @return A box @@ -351,7 +351,7 @@ export type CTypeInfo = { @tag Method @Method copyData - copy values ​​from the source and paste them into the target. + Copy values ​​from the source and paste them into the target. @param destination where the data will be pasted @param src The source data From 8b2fdbc81091e767457a2a96022b2e7c6bfed646 Mon Sep 17 00:00:00 2001 From: kimpure Date: Tue, 5 Nov 2024 22:06:52 +0900 Subject: [PATCH 5/7] move fixme --- types/ffi.luau | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/types/ffi.luau b/types/ffi.luau index 088952d3..2eae29f8 100644 --- a/types/ffi.luau +++ b/types/ffi.luau @@ -446,7 +446,6 @@ export type CPtrInfo = { @Method ptr create a pointer subtype. - FIXME: recursive types; result 'any' should be CPtrInfo> @return pointer subtype ]=] @@ -457,7 +456,7 @@ export type CPtrInfo = { @tag Method @Method readData - similar to readData . Reads data in the reference (the memory space pointed to by reference). + Similar to readData. Reads data in the reference (the memory space pointed to by reference). @param Reference to read @param byte offset @@ -469,7 +468,7 @@ export type CPtrInfo = { @tag Method @Method writeData - similar to writeData. Writes data in the reference (in the memory space pointed to by). + Similar to writeData. Writes data in the reference (in the memory space pointed to by). @param reference to use @param lua value to use @@ -521,7 +520,6 @@ export type CArrInfo = { @Method ptr create a pointer subtype. - FIXME: recursive types; result 'any' should be CPtrInfo> @return pointer subtype ]=] @@ -533,7 +531,7 @@ export type CArrInfo = { @tag Method @Method box - create a box with initial values + Create a box with initial values @param table The array of field values @return A box @@ -576,7 +574,7 @@ export type CArrInfo = { @tag Method @Method copyData - copy values ​​from the source and paste them into the target. + Copy values ​​from the source and paste them into the target. @param destination where the data will be pasted @param src The source data @@ -596,7 +594,7 @@ export type CArrInfo = { @tag Method @method copyData - returns the byte offset of the field. + Get the byte offset of the field. @param field index @return byte offset From a05c598dc3b92098880ddbd0fd6229ec80803490 Mon Sep 17 00:00:00 2001 From: kimpure Date: Wed, 6 Nov 2024 16:17:01 +0900 Subject: [PATCH 6/7] moonwave annotation fix --- types/ffi.luau | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/types/ffi.luau b/types/ffi.luau index 2eae29f8..06bbb30c 100644 --- a/types/ffi.luau +++ b/types/ffi.luau @@ -291,7 +291,7 @@ export type CTypeInfo = { Create a pointer subtype. - @return pointer subtype + @return A pointer subtype ]=] ptr: (self: CTypeInfo) -> CPtrInfo>, @@ -432,7 +432,7 @@ export type CPtrInfo = { @tag Method @Method arr - create an array subtype. + Create an array subtype. @param len The length of the array @return An array subtype @@ -445,34 +445,35 @@ export type CPtrInfo = { @tag Method @Method ptr - create a pointer subtype. + Create a pointer subtype. - @return pointer subtype + @return A pointer subtype ]=] ptr: (self: CPtrInfo) -> any, --[=[ @within CPtrInfo @tag Method - @Method readData + @Method readRef - Similar to readData. Reads data in the reference (the memory space pointed to by reference). + Similar to readData, read a lua value from reference. - @param Reference to read - @param byte offset + @param target Target reference to read data from + @param offset Offset to read data from + @return A lua value ]=] - readRef: (self: CPtrInfo, target: RefData | BoxData, offset: number?) -> RefData, + readRef: (self: CPtrInfo, target: RefData | BoxData, offset: number?) -> any, --[=[ @within CPtrInfo @tag Method - @Method writeData - - Similar to writeData. Writes data in the reference (in the memory space pointed to by). + @Method writeRef + + Similar to writeData, write a lua value into reference. - @param reference to use - @param lua value to use - @param byte offset + @param target Target reference to write data into + @param value Lua data to write + @param offset Offset to write data into ]=] writeRef: ( self: CPtrInfo, @@ -519,9 +520,9 @@ export type CArrInfo = { @tag Method @Method ptr - create a pointer subtype. + Create a pointer subtype. - @return pointer subtype + @return A pointer subtype ]=] ptr: (self: CArrInfo) -> CPtrInfo>, @@ -531,7 +532,7 @@ export type CArrInfo = { @tag Method @Method box - Create a box with initial values + Create a box with initial values. @param table The array of field values @return A box @@ -576,9 +577,9 @@ export type CArrInfo = { Copy values ​​from the source and paste them into the target. - @param destination where the data will be pasted + @param dst where the data will be pasted @param src The source data - @param dstOffset The offset in the destination where the data will be pasted + @param dstOffset The offset in the dst where the data will be pasted @param srcOffset The offset in the source data from where the data will be copied ]=] copyData: ( @@ -592,7 +593,7 @@ export type CArrInfo = { --[=[ @within CArrInfo @tag Method - @method copyData + @method offset Get the byte offset of the field. From a525faabb4aad0a5af12f9bc5865771a52ccbadf Mon Sep 17 00:00:00 2001 From: kimpure Date: Wed, 6 Nov 2024 16:20:08 +0900 Subject: [PATCH 7/7] moonwave annotation fix --- types/ffi.luau | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/ffi.luau b/types/ffi.luau index 06bbb30c..206d26b9 100644 --- a/types/ffi.luau +++ b/types/ffi.luau @@ -597,7 +597,7 @@ export type CArrInfo = { Get the byte offset of the field. - @param field index + @param The element index @return byte offset ]=] offset: (self: CArrInfo, index: number) -> number,