Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions autogen/convert_structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ def build_struct(struct):
if size != 1:
row.append('%s, ' % size )
row.append('sizeof(%s), ' % ftype)
if field['is_c_array']:
if is_c_array:
row.append('true')
else: row[-1] = row[-1][:-2]
else: row[-1] = row[-1][:-2]
Expand Down Expand Up @@ -734,22 +734,22 @@ def get_function_signature(function):
with open('autogen/lua_definitions/functions.lua') as f:
lines = f.readlines()
function_params = []
function_return = None
function_returns = []
for line in lines:
if line.startswith('--- @param'):
function_params.append(line.split()[2:4])
elif line.startswith('--- @return'):
function_return = line.split()[2]
function_returns.append(line.split()[2])
elif line.startswith('function'):
sig = 'fun('
sig += ', '.join(['%s: %s' % (param_name, param_type) for param_name, param_type in function_params])
sig += ')'
if function_return:
sig += ': %s' % (function_return)
if function_returns:
sig += ': %s' % (", ".join(function_returns))
function_name = line.replace('(', ' ').split()[1]
function_signatures[function_name] = sig
function_params.clear()
function_return = None
function_returns = []
return function_signatures.get(function, 'function')

def def_struct(struct):
Expand Down
53 changes: 51 additions & 2 deletions autogen/lua_definitions/constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4667,10 +4667,10 @@ MOD_FS_COMPRESSION_MAX = 9
MOD_FS_COMPRESSION_DEFAULT = 1

--- @type integer
MOD_FS_MAX_SIZE = 0x2000000
MOD_FS_MAX_SIZE = 0x8000000

--- @type integer
MOD_FS_MAX_FILES = 0x200
MOD_FS_MAX_FILES = 0x400

--- @type integer
MOD_FS_MAX_PATH = 0x100
Expand All @@ -4681,6 +4681,55 @@ MOD_FS_URI_PREFIX = "modfs:/"
--- @type string
MOD_FS_URI_FORMAT = "modfs:/%s/%s"

MOD_FS_ERR_NONE = 0 --- @type ModFsErrorCode
MOD_FS_ERR_ALLOC_FAILED = 1 --- @type ModFsErrorCode
MOD_FS_ERR_ALREADY_EXISTS = 2 --- @type ModFsErrorCode
MOD_FS_ERR_NOT_FOUND = 3 --- @type ModFsErrorCode
MOD_FS_ERR_INVALID_POINTER = 4 --- @type ModFsErrorCode
MOD_FS_ERR_INVALID_PARAMETER = 5 --- @type ModFsErrorCode
MOD_FS_ERR_FILE_INVALID_INDEX = 6 --- @type ModFsErrorCode
MOD_FS_ERR_FILE_TYPE_NOT_ALLOWED = 7 --- @type ModFsErrorCode
MOD_FS_ERR_TOTAL_SIZE_EXCEEDED = 8 --- @type ModFsErrorCode
MOD_FS_ERR_NUM_FILES_EXCEEDED = 9 --- @type ModFsErrorCode
MOD_FS_ERR_FILEPATH_EMPTY = 10 --- @type ModFsErrorCode
MOD_FS_ERR_FILEPATH_LEN_EXCEEDED = 11 --- @type ModFsErrorCode
MOD_FS_ERR_FILEPATH_RESERVED = 12 --- @type ModFsErrorCode
MOD_FS_ERR_FILEPATH_INVALID_CHAR = 13 --- @type ModFsErrorCode
MOD_FS_ERR_FILEPATH_MALFORMED = 14 --- @type ModFsErrorCode
MOD_FS_ERR_FILEPATH_INVALID_EXTENSION = 15 --- @type ModFsErrorCode
MOD_FS_ERR_READ_INVALID_MODPATH = 16 --- @type ModFsErrorCode
MOD_FS_ERR_READ_ZIP = 17 --- @type ModFsErrorCode
MOD_FS_ERR_READ_PROPERTIES = 18 --- @type ModFsErrorCode
MOD_FS_ERR_READ_FILE_TRUNCATED = 19 --- @type ModFsErrorCode
MOD_FS_ERR_READ_EOF = 20 --- @type ModFsErrorCode
MOD_FS_ERR_WRITE_ZIP = 21 --- @type ModFsErrorCode
MOD_FS_ERR_WRITE_NOT_ACTIVE_MOD = 22 --- @type ModFsErrorCode

--- @alias ModFsErrorCode
--- | `MOD_FS_ERR_NONE`
--- | `MOD_FS_ERR_ALLOC_FAILED`
--- | `MOD_FS_ERR_ALREADY_EXISTS`
--- | `MOD_FS_ERR_NOT_FOUND`
--- | `MOD_FS_ERR_INVALID_POINTER`
--- | `MOD_FS_ERR_INVALID_PARAMETER`
--- | `MOD_FS_ERR_FILE_INVALID_INDEX`
--- | `MOD_FS_ERR_FILE_TYPE_NOT_ALLOWED`
--- | `MOD_FS_ERR_TOTAL_SIZE_EXCEEDED`
--- | `MOD_FS_ERR_NUM_FILES_EXCEEDED`
--- | `MOD_FS_ERR_FILEPATH_EMPTY`
--- | `MOD_FS_ERR_FILEPATH_LEN_EXCEEDED`
--- | `MOD_FS_ERR_FILEPATH_RESERVED`
--- | `MOD_FS_ERR_FILEPATH_INVALID_CHAR`
--- | `MOD_FS_ERR_FILEPATH_MALFORMED`
--- | `MOD_FS_ERR_FILEPATH_INVALID_EXTENSION`
--- | `MOD_FS_ERR_READ_INVALID_MODPATH`
--- | `MOD_FS_ERR_READ_ZIP`
--- | `MOD_FS_ERR_READ_PROPERTIES`
--- | `MOD_FS_ERR_READ_FILE_TRUNCATED`
--- | `MOD_FS_ERR_READ_EOF`
--- | `MOD_FS_ERR_WRITE_ZIP`
--- | `MOD_FS_ERR_WRITE_NOT_ACTIVE_MOD`

INT_TYPE_U8 = 0 --- @type ModFsFileIntType
INT_TYPE_U16 = 1 --- @type ModFsFileIntType
INT_TYPE_U32 = 2 --- @type ModFsFileIntType
Expand Down
42 changes: 41 additions & 1 deletion autogen/lua_definitions/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7783,26 +7783,30 @@ end

--- @param modPath? string
--- @return boolean
--- @return ModFsErrorCode err
--- Checks the existence of a modfs at path `modPath` or for the active mod if not provided. Checking for the existence of a private modfs will return false, even if it exists
function mod_fs_exists(modPath)
-- ...
end

--- @param modPath? string
--- @return ModFs
--- @return ModFsErrorCode err
--- Gets the modfs object at path `modPath` or the active mod one if not provided. This function will return nil for a private modfs, even if it exists
function mod_fs_get(modPath)
-- ...
end

--- @param modPath? string
--- @return ModFs
--- @return ModFsErrorCode err
--- Reloads the modfs object at path `modPath`. This function will return nil for a private modfs, even if it exists
function mod_fs_reload(modPath)
-- ...
end

--- @return ModFs
--- @return ModFsErrorCode err
--- Creates a modfs object for the active mod if it doesn't exist. Returns the modfs object on success
function mod_fs_create()
-- ...
Expand All @@ -7811,6 +7815,7 @@ end
--- @param modFs ModFs
--- @param index integer
--- @return string
--- @return ModFsErrorCode err
--- Gets the filename at position `index` of the provided `modFs`
function mod_fs_get_filename(modFs, index)
-- ...
Expand All @@ -7819,6 +7824,7 @@ end
--- @param modFs ModFs
--- @param filepath string
--- @return ModFsFile
--- @return ModFsErrorCode err
--- Gets the file object at path `filepath` of the provided `modFs`. This function will return nil for a private modfs file, even if it exists
function mod_fs_get_file(modFs, filepath)
-- ...
Expand All @@ -7828,6 +7834,7 @@ end
--- @param filepath string
--- @param text boolean
--- @return ModFsFile
--- @return ModFsErrorCode err
--- Creates a new file at path `filepath` for the provided `modFs`. Set `text` to true to treat the file as a pure text file, not a binary file. Returns the created file on success
function mod_fs_create_file(modFs, filepath, text)
-- ...
Expand All @@ -7838,6 +7845,7 @@ end
--- @param newpath string
--- @param overwriteExisting boolean
--- @return boolean
--- @return ModFsErrorCode err
--- Moves the file at path `oldpath` to `newpath` of the provided `modFs`. Set `overwriteExisting` to true to overwrite the file at path `newpath` if it exists. Returns true on success
function mod_fs_move_file(modFs, oldpath, newpath, overwriteExisting)
-- ...
Expand All @@ -7848,6 +7856,7 @@ end
--- @param dstpath string
--- @param overwriteExisting boolean
--- @return boolean
--- @return ModFsErrorCode err
--- Copies the file at path `srcpath` to `dstpath` of the provided `modFs`. Set `overwriteExisting` to true to overwrite the file at path `dstpath` if it exists. Returns true on success
function mod_fs_copy_file(modFs, srcpath, dstpath, overwriteExisting)
-- ...
Expand All @@ -7856,27 +7865,31 @@ end
--- @param modFs ModFs
--- @param filepath string
--- @return boolean
--- @return ModFsErrorCode err
--- Deletes the file at path `filepath` of the provided `modFs`. Returns true on success
function mod_fs_delete_file(modFs, filepath)
-- ...
end

--- @param modFs ModFs
--- @return boolean
--- @return ModFsErrorCode err
--- Deletes all files of the provided `modFs`. Returns true on success
function mod_fs_clear(modFs)
-- ...
end

--- @param modFs ModFs
--- @return boolean
--- @return ModFsErrorCode err
--- Saves the provided `modFs` to persistent storage. Returns true on success
function mod_fs_save(modFs)
-- ...
end

--- @param modFs ModFs
--- @return boolean
--- @return ModFsErrorCode err
--- Removes the provided `modFs` from persistent storage and deletes its object. Returns true on success
function mod_fs_delete(modFs)
-- ...
Expand All @@ -7885,13 +7898,15 @@ end
--- @param modFs ModFs
--- @param pub boolean
--- @return boolean
--- @return ModFsErrorCode err
--- Marks the provided `modFs` as public (i.e. readable by other mods). Returns true on success
function mod_fs_set_public(modFs, pub)
-- ...
end

--- @param file ModFsFile
--- @return boolean
--- @return ModFsErrorCode err
--- Reads a boolean from a binary modfs `file`
function mod_fs_file_read_bool(file)
-- ...
Expand All @@ -7900,6 +7915,7 @@ end
--- @param file ModFsFile
--- @param intType ModFsFileIntType
--- @return integer
--- @return ModFsErrorCode err
--- Reads an integer from a binary modfs `file`. `intType` must be one of the `INT_TYPE_*` constants
function mod_fs_file_read_integer(file, intType)
-- ...
Expand All @@ -7908,6 +7924,7 @@ end
--- @param file ModFsFile
--- @param floatType ModFsFileFloatType
--- @return number
--- @return ModFsErrorCode err
--- Reads an floating-point number from a binary modfs `file`. `floatType` must be one of the `FLOAT_TYPE_*` constants
function mod_fs_file_read_number(file, floatType)
-- ...
Expand All @@ -7916,20 +7933,23 @@ end
--- @param file ModFsFile
--- @param length integer
--- @return string
--- @return ModFsErrorCode err
--- Reads a bytestring of `length` bytes from a binary modfs `file`
function mod_fs_file_read_bytes(file, length)
-- ...
end

--- @param file ModFsFile
--- @return string
--- @return ModFsErrorCode err
--- Reads a string from a binary modfs `file`, or read the whole content of a text modfs `file`
function mod_fs_file_read_string(file)
-- ...
end

--- @param file ModFsFile
--- @return string
--- @return ModFsErrorCode err
--- Reads a line from a text modfs `file`
function mod_fs_file_read_line(file)
-- ...
Expand All @@ -7938,6 +7958,7 @@ end
--- @param file ModFsFile
--- @param value boolean
--- @return boolean
--- @return ModFsErrorCode err
--- Writes a boolean to a binary modfs `file`. Returns true on success
function mod_fs_file_write_bool(file, value)
-- ...
Expand All @@ -7947,6 +7968,7 @@ end
--- @param value integer
--- @param intType ModFsFileIntType
--- @return boolean
--- @return ModFsErrorCode err
--- Writes an integer to a binary modfs `file`. `intType` must be one of the `INT_TYPE_*` constants. Returns true on success
function mod_fs_file_write_integer(file, value, intType)
-- ...
Expand All @@ -7956,6 +7978,7 @@ end
--- @param value number
--- @param floatType ModFsFileFloatType
--- @return boolean
--- @return ModFsErrorCode err
--- Writes an floating-point number to a binary modfs `file`. `floatType` must be one of the `FLOAT_TYPE_*` constants. Returns true on success
function mod_fs_file_write_number(file, value, floatType)
-- ...
Expand All @@ -7964,6 +7987,7 @@ end
--- @param file ModFsFile
--- @param bytestring string
--- @return boolean
--- @return ModFsErrorCode err
--- Writes a bytestring to a modfs `file`. Returns true on success
function mod_fs_file_write_bytes(file, bytestring)
-- ...
Expand All @@ -7972,6 +7996,7 @@ end
--- @param file ModFsFile
--- @param str string
--- @return boolean
--- @return ModFsErrorCode err
--- Writes a string to a modfs `file`. Returns true on success
function mod_fs_file_write_string(file, str)
-- ...
Expand All @@ -7980,6 +8005,7 @@ end
--- @param file ModFsFile
--- @param str string
--- @return boolean
--- @return ModFsErrorCode err
--- Writes a line to a text modfs `file`. Returns true on success
function mod_fs_file_write_line(file, str)
-- ...
Expand All @@ -7989,6 +8015,7 @@ end
--- @param offset integer
--- @param origin ModFsFileSeek
--- @return boolean
--- @return ModFsErrorCode err
--- Sets the current position of a modfs `file`.<br>
--- If `origin` is `FILE_SEEK_SET`, file position is set to `offset`.<br>
--- If `origin` is `FILE_SEEK_CUR`, `offset` is added to file current position.<br>
Expand All @@ -8000,6 +8027,7 @@ end

--- @param file ModFsFile
--- @return boolean
--- @return ModFsErrorCode err
--- Sets the current position of a modfs `file` to its beginning.<br>
--- Returns true on success
function mod_fs_file_rewind(file)
Expand All @@ -8008,6 +8036,7 @@ end

--- @param file ModFsFile
--- @return boolean
--- @return ModFsErrorCode err
--- Returns true if the provided modfs `file` has reached its end of file
function mod_fs_file_is_eof(file)
-- ...
Expand All @@ -8017,6 +8046,7 @@ end
--- @param byte integer
--- @param length integer
--- @return boolean
--- @return ModFsErrorCode err
--- Fills a modfs `file` with `byte` repeated `length` times. Returns true on success
function mod_fs_file_fill(file, byte, length)
-- ...
Expand All @@ -8025,6 +8055,7 @@ end
--- @param file ModFsFile
--- @param length integer
--- @return boolean
--- @return ModFsErrorCode err
--- Erases `length` bytes or characters from a modfs `file`. Returns true on success
function mod_fs_file_erase(file, length)
-- ...
Expand All @@ -8033,6 +8064,7 @@ end
--- @param file ModFsFile
--- @param text boolean
--- @return boolean
--- @return ModFsErrorCode err
--- Marks the provided modfs `file` as text. Returns true on success
function mod_fs_file_set_text_mode(file, text)
-- ...
Expand All @@ -8041,6 +8073,7 @@ end
--- @param file ModFsFile
--- @param pub boolean
--- @return boolean
--- @return ModFsErrorCode err
--- Marks the provided modfs `file` as public (i.e. readable by other mods). Returns true on success
function mod_fs_file_set_public(file, pub)
-- ...
Expand All @@ -8049,7 +8082,8 @@ end
--- @param file ModFsFile
--- @param level integer
--- @return boolean
--- Sets the compression level of the provided modfs `file`. Must be between 0 (no compression) and 9 (most compression). Returns true on success.
--- @return ModFsErrorCode err
--- Sets the compression level of the provided modfs `file`. Must be between 0 (no compression) and 9 (most compression). Returns true on success
function mod_fs_file_set_compression(file, level)
-- ...
end
Expand All @@ -8060,6 +8094,12 @@ function mod_fs_hide_errors(hide)
-- ...
end

--- @return ModFsErrorCode
--- Returns the last error code raised by `mod_fs` functions
function mod_fs_get_last_error_code()
-- ...
end

--- @return string
--- Returns the last error message generated by `mod_fs` functions or nil if no error occurred
function mod_fs_get_last_error()
Expand Down
Loading
Loading