Skip to content

Commit

Permalink
Merge pull request #390 from Mr-Auto/return-refrence-fix
Browse files Browse the repository at this point in the history
fix issue with returning self reference not counting as lua owned object
  • Loading branch information
Dregu authored Jul 30, 2024
2 parents 76b9067 + 81137f5 commit 700eb24
Show file tree
Hide file tree
Showing 29 changed files with 336 additions and 227 deletions.
76 changes: 51 additions & 25 deletions docs/game_data/spel2.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions docs/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,20 +365,20 @@ def print_lf(lf):

print("int | vector:find(any value) | Searches for the value in vector, returns index of the item in vector or nil if not found, only available for simple values that are comparable")
print("int | span:find(any value) | Searches for the value in span, returns index of the item in span or nil if not found, only available for simple values that are comparable")
print("any | set:find(any value) | Searches for the value in set, returns the value itself or nil if not found, only available for simple values that are comparable")
print("any | set:find(any key) | Searches for the value in set, returns the value itself or nil if not found, only available for simple values that are comparable")
print("any | map:find(any key) | Searches for the key in map, returns the value itself or nil if not found, only available for simple keys that are comparable")

print("nil | vector:erase(int index) | Removes element at given index, the rest of elements shift down so that the vector stays contiguous")
print("nil | set:erase(any value) | Removes element from set")
print("nil | map:erase(any key) | Removes element from map by key")
print("nil | set:erase(any key) | Removes element from set")
print("nil | map:erase(any key) | Removes element from map")

print("nil | vector:clear() | Removes all elements from vector")
print("nil | set:clear() | Removes all elements from set")
print("nil | map:clear() | Removes all elements from map")

print("nil | vector:insert(int index, any element) | Inserts element at given index, the rest of elements shift up in index")
print("nil | set:insert(int order, any element) | The order param doesn't acutally matter and can be set to nil")
print("nil | map:insert(any key, any value) | unsure, probably easier to just use `map[key] = value`")
print("nil | set:insert(int order, any key) | The order param doesn't acutally matter and can be set to nil")
print("nil | map:insert(any key, any value)? | unsure, probably easier to just use `map[key] = value`")


print("# Functions")
Expand Down
14 changes: 5 additions & 9 deletions docs/generate_emmylua.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@
"u16string": "string",
"char16_t*": "string",
"string_view": "string",
"pair": "tuple",
"std::pair": "tuple",
"std::": "",
"sol::": "",
"unsigned": "",
" = nullopt": "",
"void": "",
"constexpr": "",
"inline": "",
"inline ": "",
"[[nodiscard]]": "",
"[[maybe_unused]]": "",
"self_return<&": "",
">()": "",
"...va:": "...ent_type:",
"set<": "Array<",
"span<": "Array<",
Expand Down Expand Up @@ -297,8 +300,6 @@ def main():
else ""
)
if "function" in var and var["function"]:
# if var["name"] == "clear_behaviors":
# gu.breakpoint()
signature = var["signature"]
m = re.search(r"\s*(.*)\s+([^\(]*)\((.*)\)", signature)
if m:
Expand Down Expand Up @@ -442,12 +443,10 @@ def main():
print(
"""local MAX_PLAYERS = 4
---@alias in_port_t number
---@class Logic
---@alias OnlinePlayerShort any
---@alias UdpServer any
---@alias Texture any
---@alias SpearDanglerAnimFrames any
---@alias OnlineLobbyScreenPlayer any
---@alias SoundCallbackFunction function"""
Expand All @@ -464,13 +463,10 @@ def main():

# Replace some things
final_replace_stuff = {
" ---@field menu_text_opacity number\n ---@field menu_text_opacity number": "---@field menu_text_opacity number",
"---@field find_all_short_tile_codes fun(self, layer: LAYER, short_tile_code: SHORT_TILE_CODE): Array<tuple<integer, integer, LAYER>>": "---@field find_all_short_tile_codes fun(self, layer: LAYER, short_tile_code: SHORT_TILE_CODE): integer[][]",
"---@field keysdown boolean [] @size: ImGuiKey_COUNT": "---@field keysdown boolean[] @size: ImGuiKey_COUNT. Note: lua starts indexing at 1, you need `keysdown[string.byte('A') + 1]` to find the A key.",
"---@field keydown any @keydown": "---@field keydown fun(key: number | string): boolean",
"---@field keypressed any @keypressed": "---@field keypressed fun(key: number | string, repeat?: boolean ): boolean",
"---@field keyreleased any @keyreleased": "---@field keyreleased fun(key: number | string): boolean",
"---@field gamepad any @sol::property([](){g_WantUpdateHasGamepad=true;returnget_gamepad()/**/;})": "---@field gamepad Gamepad",
"---@field user_data fun(self): nil": "---@field user_data table?",
"""---@param number> p tuple<number,
---@return Vec2
Expand Down
Loading

0 comments on commit 700eb24

Please sign in to comment.