Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lua static type generation #3697

Open
wants to merge 40 commits into
base: develop
Choose a base branch
from

Conversation

shevernitskiy
Copy link
Contributor

@shevernitskiy shevernitskiy commented Aug 24, 2023

Lua LSP support type hinting. It helps much during development.
Currently there are no type hinting in lua part of codebase. But we can generate type definitions of static part for exposed api by using xml map of structures.

This PR introduces simple python script, that could do it.
To generate definitions just execute script in repo workspace.
There will be generated .luarc.json (config file for Lua LSP) and /types dir which will contain generated definitions and some lsp meta info.

Current issues:

  • script handles inheritance by adding parent members to target class, but vmethods not copied
  • some of complicated stl types not mapped (need to figure out how to do it correctly, or just disable warnings)
image

P.S.: i think it will be reasonable to make definition for global utils methods like curry in place

ci/lua-types.py Outdated
"workspace.ignoreDir": ["build"]
}}\n"""

DF_GLOBAL = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these lists will get out of date. can they be parsed from the XML or generated headers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I parsed these lists traversing df and df.globals by lua script in game. If there is another static option instead, it would be better to use it. Give me a hint:)
More over this is not precise naming, there are some T_name tables, i don't figure out the logic for such a naming.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the best result we should somehow reimplement of exposing logic in LuaWrapper.cpp

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the globals, you can get them from the xml:

fgrep '<global-object' library/xml/df.globals.xml | sed -r "s/.* name='([^']+).*/\1/" | sort

that's shell, but I'm sure you can translate that to python.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ci/ directory is for scripts run in our continuous integration pipeline. this script is not intended for that, but I don't know a better directory to put it in. @lethosor what do you think?

Running this script should be part of the regular build, and should be integrated into our CMakeLists.txt logic. It would need an option guarding it since it introduces a python dependency, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an alternative or an additional option for pure lua devs, it can be separate repo, that will build typing for every dfhack version on new tag in main repo. It is possible as far as script work only with static data. Advanced dev still can trigger script manualy as needed.


# lua typing
.luarc.json
/types
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is types/ the standard location for these types of files? Who reads the output files and is there any setup required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LSP wiki do not specify exact naming or location. Only internal structure (/library, config.json) is strict. Location can be passed as arg (even otside the workspace).
/definitions can be an alternative to /types.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an addition, type hinting do not work in lua file, where _ENV is used. Dunno how to fix it yet.

ci/lua-types.py Outdated Show resolved Hide resolved
ci/lua-types.py Outdated Show resolved Hide resolved
ci/lua-types.py Outdated Show resolved Hide resolved
commit db67ff7
Author: DFHack-Urist via GitHub Actions <63161697+DFHack-Urist@users.noreply.github.com>
Date:   Tue Sep 5 08:56:05 2023 +0000

    Auto-update submodules

    depends/clsocket: master

commit c63906a
Author: Myk Taylor <myk002@yahoo.com>
Date:   Tue Sep 5 01:54:57 2023 -0700

    add clsocket to the update manifest

commit 45640fd
Author: DFHack-Urist via GitHub Actions <63161697+DFHack-Urist@users.noreply.github.com>
Date:   Tue Sep 5 08:26:48 2023 +0000

    Auto-update submodules

    scripts: master

commit 7d128ad
Author: DFHack-Urist via GitHub Actions <63161697+DFHack-Urist@users.noreply.github.com>
Date:   Tue Sep 5 08:10:07 2023 +0000

    Auto-update submodules

    library/xml: master
    scripts: master

commit 49de36d
Merge: 2b2b5a3 9143a8e
Author: Myk <myk.taylor@gmail.com>
Date:   Tue Sep 5 01:09:19 2023 -0700

    Merge pull request DFHack#3737 from Tjudge1/patch-1

    Update strangemood.rst example section

commit 9143a8e
Author: Myk <myk.taylor@gmail.com>
Date:   Tue Sep 5 00:46:00 2023 -0700

    Update docs/plugins/strangemood.rst

commit 2b2b5a3
Merge: 23994de ff3d4c5
Author: Myk <myk.taylor@gmail.com>
Date:   Tue Sep 5 00:42:25 2023 -0700

    Merge pull request DFHack#3739 from myk002/myk_bag

    [createitem] support creating items inside of bags

commit 23994de
Merge: 29ccdcf 9dd8a85
Author: Myk <myk.taylor@gmail.com>
Date:   Tue Sep 5 00:36:12 2023 -0700

    Merge pull request DFHack#3738 from DFHack/pre-commit-ci-update-config

    [pre-commit.ci] pre-commit autoupdate

commit ff3d4c5
Author: Myk Taylor <myk002@yahoo.com>
Date:   Tue Sep 5 00:31:35 2023 -0700

    support creating items inside of bags

commit 9dd8a85
Author: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date:   Tue Sep 5 04:05:29 2023 +0000

    [pre-commit.ci] pre-commit autoupdate

    updates:
    - [github.com/python-jsonschema/check-jsonschema: 0.23.3 → 0.26.3](python-jsonschema/check-jsonschema@0.23.3...0.26.3)
    - [github.com/Lucas-C/pre-commit-hooks: v1.5.1 → v1.5.4](Lucas-C/pre-commit-hooks@v1.5.1...v1.5.4)

commit 29ccdcf
Author: Myk <myk.taylor@gmail.com>
Date:   Mon Sep 4 20:45:53 2023 -0700

    Remove leftover debug print

commit 457a998
Author: dikbutdagrate <73856869+Tjudge1@users.noreply.github.com>
Date:   Mon Sep 4 19:36:01 2023 -0400

    Update strangemood.rst example section

    Updated example to accurately reflect arguments. Compliant with getopt-style parameter syntax.

commit 45770ae
Author: DFHack-Urist via GitHub Actions <63161697+DFHack-Urist@users.noreply.github.com>
Date:   Mon Sep 4 07:13:19 2023 +0000

    Auto-update submodules

    scripts: master

commit d291e2b
Author: DFHack-Urist via GitHub Actions <63161697+DFHack-Urist@users.noreply.github.com>
Date:   Mon Sep 4 00:48:48 2023 +0000

    Auto-update submodules

    scripts: master

commit ed243ca
Merge: 4316879 cbe4f53
Author: Myk <myk.taylor@gmail.com>
Date:   Sun Sep 3 17:47:51 2023 -0700

    Merge pull request DFHack#3730 from myk002/myk_orders_focus_string

    [Gui] add focus string details for orders context

commit cbe4f53
Author: Myk Taylor <myk002@yahoo.com>
Date:   Sun Sep 3 12:50:12 2023 -0700

    add focus string details for orders context

commit 4316879
Author: DFHack-Urist via GitHub Actions <63161697+DFHack-Urist@users.noreply.github.com>
Date:   Sun Sep 3 19:37:07 2023 +0000

    Auto-update submodules

    scripts: master

commit 7d59182
Merge: b2e31e7 1d6ae37
Author: Myk <myk.taylor@gmail.com>
Date:   Sun Sep 3 12:36:24 2023 -0700

    Merge pull request DFHack#3728 from myk002/myk_heat_safety

    [buildingplan] fix and reinstate heat safety filter

commit 1d6ae37
Author: Myk Taylor <myk002@yahoo.com>
Date:   Sun Sep 3 11:49:13 2023 -0700

    fix and reinstate heat safety filter

commit b2e31e7
Merge: d3f99a4 a2b50a8
Author: Myk <myk.taylor@gmail.com>
Date:   Sun Sep 3 10:33:52 2023 -0700

    Merge pull request DFHack#3726 from myk002/myk_buckets

    [buildingplan] handle empty and lye_milk_free flags

commit d3f99a4
Merge: 54d7318 9ddb527
Author: Myk <myk.taylor@gmail.com>
Date:   Sun Sep 3 10:33:30 2023 -0700

    Merge pull request DFHack#3727 from TymurGubayev/patch-8

    keybindings: add `/Default` to `Ctrl-D@dwarfmode gui/design`

commit 9ddb527
Author: Timur Kelman <tymur.gubayev@gmail.com>
Date:   Sun Sep 3 19:24:11 2023 +0200

    keybindings: add `/Default` to `Ctrl-D@dwarfmode gui/design`

commit a2b50a8
Author: Myk Taylor <myk002@yahoo.com>
Date:   Sun Sep 3 07:12:41 2023 -0700

    reorder branches for better readability

commit b8fc6e2
Author: Myk Taylor <myk002@yahoo.com>
Date:   Sun Sep 3 07:12:30 2023 -0700

    add note about handling bags

commit dc22c59
Author: Myk Taylor <myk002@yahoo.com>
Date:   Sun Sep 3 07:11:18 2023 -0700

    update changelog

commit 3f1eac7
Author: Myk Taylor <myk002@yahoo.com>
Date:   Sun Sep 3 07:08:57 2023 -0700

    respect empty and lye_milk_free flags

commit 54d7318
Merge: ce0eb1a 4c93890
Author: Myk <myk.taylor@gmail.com>
Date:   Sat Sep 2 04:51:51 2023 -0700

    Merge pull request DFHack#3724 from myk002/myk_xmldump

    avoid warning about unused config var

commit 4c93890
Author: Myk Taylor <myk002@yahoo.com>
Date:   Sat Sep 2 04:16:21 2023 -0700

    avoid warning about unused config var

commit ce0eb1a
Author: DFHack-Urist via GitHub Actions <63161697+DFHack-Urist@users.noreply.github.com>
Date:   Sat Sep 2 11:18:15 2023 +0000

    Auto-update submodules

    scripts: master

commit c7b84a4
Merge: 9e744de b489fce
Author: Myk <myk.taylor@gmail.com>
Date:   Sat Sep 2 03:30:28 2023 -0700

    Merge pull request DFHack#3723 from myk002/myk_terminal

    clarify error message about the terminal

commit b489fce
Author: Myk Taylor <myk002@yahoo.com>
Date:   Sat Sep 2 03:22:10 2023 -0700

    clarify error message about the terminal

commit 9e744de
Merge: e685e23 874fb55
Author: Myk <myk.taylor@gmail.com>
Date:   Sat Sep 2 03:21:13 2023 -0700

    Merge pull request DFHack#3722 from myk002/myk_dialog

    [dialogs.MessageBox] fix spacing around text when a scrollbar is involved

commit 874fb55
Author: Myk Taylor <myk002@yahoo.com>
Date:   Sat Sep 2 02:41:26 2023 -0700

    fix spacing around messagebox text when a scrollbar is involved

commit e685e23
Merge: 946e68a 6096165
Author: Myk <myk.taylor@gmail.com>
Date:   Sat Sep 2 02:36:27 2023 -0700

    Merge pull request DFHack#3721 from myk002/myk_autobutcher

    [autobutcher] fix handling of ticks parameter

commit 6096165
Author: Myk Taylor <myk002@yahoo.com>
Date:   Sat Sep 2 02:03:03 2023 -0700

    fix handling of ticks parameter

commit 946e68a
Merge: 251fb0b 8e6775a
Author: Myk <myk.taylor@gmail.com>
Date:   Sat Sep 2 01:00:43 2023 -0700

    Merge pull request DFHack#3720 from myk002/myk_stock_doc

    [stockpiles] document stockpiles/logistics overlay

commit 251fb0b
Merge: 2349c6f d9c9c7c
Author: Myk <myk.taylor@gmail.com>
Date:   Sat Sep 2 00:55:45 2023 -0700

    Merge pull request DFHack#3719 from myk002/myk_win64

    unclutter build command

commit d9c9c7c
Author: Myk Taylor <myk002@yahoo.com>
Date:   Sat Sep 2 00:32:51 2023 -0700

    update libzip ref

commit 2349c6f
Author: DFHack-Urist via GitHub Actions <63161697+DFHack-Urist@users.noreply.github.com>
Date:   Sat Sep 2 07:11:38 2023 +0000

    Auto-update submodules

    scripts: master

commit 0bdba60
Author: Myk Taylor <myk002@yahoo.com>
Date:   Fri Sep 1 23:43:49 2023 -0700

    fix build command

commit 15da5f2
Merge: c791560 426099f
Author: Myk <myk.taylor@gmail.com>
Date:   Fri Sep 1 21:31:50 2023 -0700

    Merge pull request DFHack#3718 from myk002/myk_sort_wording

    [sort] label updates for squad sort options

commit 8e6775a
Author: Myk Taylor <myk002@yahoo.com>
Date:   Fri Sep 1 18:45:50 2023 -0700

    document stockpiles/logistics overlay

commit c791560
Merge: 0550562 a3f6447
Author: Myk <myk.taylor@gmail.com>
Date:   Fri Sep 1 18:18:17 2023 -0700

    Merge pull request DFHack#3717 from myk002/myk_ccache

    zero ccache stats between runs

commit 426099f
Author: Myk Taylor <myk002@yahoo.com>
Date:   Fri Sep 1 14:35:55 2023 -0700

    label updates for squad sort options

commit a3f6447
Author: Myk Taylor <myk002@yahoo.com>
Date:   Fri Sep 1 12:45:36 2023 -0700

    light help wording update for Dreamfort blueprints

commit 7abb82d
Author: Myk Taylor <myk002@yahoo.com>
Date:   Fri Sep 1 12:20:52 2023 -0700

    zero ccache stats between runs

    and allow the cache to expand past the persisted max size during the build

commit 0550562
Author: Myk Taylor <myk002@yahoo.com>
Date:   Fri Sep 1 11:44:51 2023 -0700

    bump to 50.09-r3rc3

commit 951c0b5
Merge: 8791825 702992b
Author: Myk <myk.taylor@gmail.com>
Date:   Fri Sep 1 11:28:31 2023 -0700

    Merge pull request DFHack#3715 from myk002/myk_hide_logo_load_game

    [hotkeys] hide the DFHack logo while loading a game

commit 702992b
Author: Myk Taylor <myk002@yahoo.com>
Date:   Thu Aug 31 23:06:05 2023 -0700

    hide the DFHack logo while loading a game

    so the textures don't visibly flicker
    revert this once textures are flicker free

commit 8791825
Author: DFHack-Urist via GitHub Actions <63161697+DFHack-Urist@users.noreply.github.com>
Date:   Fri Sep 1 03:26:52 2023 +0000

    Auto-update submodules

    scripts: master

commit a0cdee7
Merge: c5e5b29 ffc884d
Author: Myk <myk.taylor@gmail.com>
Date:   Thu Aug 31 20:25:56 2023 -0700

    Merge pull request DFHack#3714 from myk002/myk_squadv2

    [sort] implement suggestions from squad assignment screen feedback

commit ffc884d
Author: Myk Taylor <myk002@yahoo.com>
Date:   Thu Aug 31 19:42:02 2023 -0700

    fix migrant wave ordering

    use active index instead of unit id

commit 52543f9
Author: Myk Taylor <myk002@yahoo.com>
Date:   Thu Aug 31 19:14:47 2023 -0700

    clean out unused code/vars

commit afb26b9
Author: Myk Taylor <myk002@yahoo.com>
Date:   Thu Aug 31 19:10:18 2023 -0700

    add requested filters for squad assignment screen

    and redo layout as a vertical panel since there's not enough space
    otherwise

commit c5e5b29
Merge: 940d25a 38ece5a
Author: Myk <myk.taylor@gmail.com>
Date:   Thu Aug 31 18:14:38 2023 -0700

    Merge pull request DFHack#3710 from myk002/myk_tailor

    [tailor] fix status output character encoding

commit 940d25a
Merge: 75df1c0 088fa9a
Author: Myk <myk.taylor@gmail.com>
Date:   Thu Aug 31 18:14:18 2023 -0700

    Merge pull request DFHack#3711 from myk002/myk_instrument_textures

    [Textures] instrument textures module

commit 75df1c0
Merge: 8cffe3b bb79755
Author: Myk <myk.taylor@gmail.com>
Date:   Thu Aug 31 15:27:56 2023 -0700

    Merge pull request DFHack#3713 from lethosor/fix-removejob-gcc-optimization

    Hack to force GCC to invoke cancel_job() through DF's vtable

commit 8cffe3b
Merge: 07e8e83 cf53283
Author: Myk <myk.taylor@gmail.com>
Date:   Thu Aug 31 14:53:06 2023 -0700

    Merge pull request DFHack#3712 from myk002/myk_relwithdebinfo

    remove unneeded modification of CMAKE_CXX_FLAGS_RELWITHDEBINFO

commit bb79755
Author: lethosor <lethosor@gmail.com>
Date:   Thu Aug 31 17:41:52 2023 -0400

    Add test that removeJob() actually removes jobs

commit 40bfb6b
Author: lethosor <lethosor@gmail.com>
Date:   Thu Aug 31 17:24:02 2023 -0400

    Hack to force GCC to invoke cancel_job() through DF's vtable

    GCC appears to be optimizing the call to `cancel_job()` to use the stub in
    *DFHack's* job_handler vtable, which is a no-op. Lua was unaffected because it
    invokes vmethods through method pointers (without knowing the target instance at
    compile time), so use a similar approach here for now.

    As mentioned by @ab9rf on Discord, we should pursue an alternative like asking
    Bay12 to expose the relevant code through a global `std::function` instead of a
    vmethod.

commit cf53283
Author: Myk Taylor <myk002@yahoo.com>
Date:   Thu Aug 31 14:14:45 2023 -0700

    remove unneeded modification of CMAKE_CXX_FLAGS_RELWITHDEBINFO

    -g is already in the flags, we just end up adding it a second time

commit 088fa9a
Author: Myk Taylor <myk002@yahoo.com>
Date:   Thu Aug 31 10:53:43 2023 -0700

    instrument textures module and clean up gui

commit 38ece5a
Author: Myk Taylor <myk002@yahoo.com>
Date:   Thu Aug 31 06:03:52 2023 -0700

    fix status output character encoding

    so dwarf and item names and item descriptions are printed correctly

commit 07e8e83
Merge: 742c8bb 4a788e7
Author: Myk <myk.taylor@gmail.com>
Date:   Wed Aug 30 23:52:18 2023 -0700

    Merge pull request DFHack#3698 from Halifay/advanced_military_sorting

    Enhancing Military Candidate Selection

commit 742c8bb
Author: DFHack-Urist via GitHub Actions <63161697+DFHack-Urist@users.noreply.github.com>
Date:   Thu Aug 31 06:32:03 2023 +0000

    Auto-update submodules

    scripts: master

commit 4a788e7
Author: Myk <myk.taylor@gmail.com>
Date:   Wed Aug 30 23:26:03 2023 -0700

    Apply suggestions from code review

commit 2c97ab9
Author: Mikhail <mpanov@tetrika.school>
Date:   Wed Aug 30 17:16:59 2023 +0300

    Tidying up melee skill and ranged skill funcitons in sort.lua.

commit 5d76498
Merge: db50dd6 47a2202
Author: Myk <myk.taylor@gmail.com>
Date:   Wed Aug 30 03:42:27 2023 -0700

    Merge pull request DFHack#3704 from shevernitskiy/create-delete-textures

    create and delete textures

commit 47a2202
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Wed Aug 30 12:49:48 2023 +0300

    Update docs/dev/Lua API.rst

    Co-authored-by: Myk <myk.taylor@gmail.com>

commit 02d33e5
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Wed Aug 30 12:49:40 2023 +0300

    Update docs/dev/Lua API.rst

    Co-authored-by: Myk <myk.taylor@gmail.com>

commit 6391356
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Wed Aug 30 12:49:28 2023 +0300

    Update docs/dev/Lua API.rst

    Co-authored-by: Myk <myk.taylor@gmail.com>

commit 72a985c
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Wed Aug 30 12:49:17 2023 +0300

    Update docs/dev/Lua API.rst

    Co-authored-by: Myk <myk.taylor@gmail.com>

commit a2d1d41
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Wed Aug 30 12:49:09 2023 +0300

    Update docs/dev/Lua API.rst

    Co-authored-by: Myk <myk.taylor@gmail.com>

commit 14c4e94
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Wed Aug 30 12:49:01 2023 +0300

    Update docs/dev/Lua API.rst

    Co-authored-by: Myk <myk.taylor@gmail.com>

commit 72dbb68
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Wed Aug 30 12:48:54 2023 +0300

    Update docs/dev/Lua API.rst

    Co-authored-by: Myk <myk.taylor@gmail.com>

commit c0ac7ad
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Wed Aug 30 12:48:47 2023 +0300

    Update docs/dev/Lua API.rst

    Co-authored-by: Myk <myk.taylor@gmail.com>

commit 13e0a49
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Wed Aug 30 12:48:36 2023 +0300

    Update docs/dev/Lua API.rst

    Co-authored-by: Myk <myk.taylor@gmail.com>

commit b3d423b
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Wed Aug 30 12:48:26 2023 +0300

    Update docs/dev/Lua API.rst

    Co-authored-by: Myk <myk.taylor@gmail.com>

commit 7ce7bd1
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Wed Aug 30 12:48:14 2023 +0300

    Update docs/dev/Lua API.rst

    Co-authored-by: Myk <myk.taylor@gmail.com>

commit 5c6942a
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Wed Aug 30 10:45:17 2023 +0300

    intendation for example

commit a1fe49e
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Wed Aug 30 10:37:23 2023 +0300

    typo

commit ff82cb2
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Wed Aug 30 10:05:23 2023 +0300

    docs work

commit 26b81cf
Author: Mikhail <mpanov@tetrika.school>
Date:   Wed Aug 30 09:39:13 2023 +0300

    Merged military rating back into one. Adjusted formulas for melee and ranged rating. Added skill effectiveness ratings for ranged and melee. Changed any melee and any ranged to skill effectiveness ratings. Added info about new ratings and research links to the docs.

commit db50dd6
Merge: f2a5d82 e87aefa
Author: Myk <myk.taylor@gmail.com>
Date:   Tue Aug 29 22:42:33 2023 -0700

    Merge pull request DFHack#3708 from ab9rf/5009-treeseedwatch

    seedwatch: ignore tree seeds

commit e87aefa
Author: Kelly Kinkade <kelly.lynn.martin@gmail.com>
Date:   Wed Aug 30 00:08:51 2023 -0500

    seedwatch: changelog

commit c5d3076
Author: Kelly Kinkade <kelly.lynn.martin@gmail.com>
Date:   Wed Aug 30 00:07:30 2023 -0500

    seedwatch: rewrite configuration cleaning

commit 8a015f7
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Wed Aug 30 07:38:21 2023 +0300

    review

commit fa9d2e2
Author: Kelly Kinkade <kelly.lynn.martin@gmail.com>
Date:   Tue Aug 29 22:23:13 2023 -0500

    seedwatch: ignore tree seeds

commit 73af533
Author: Mikhail Panov <mihail52sh@mail.ru>
Date:   Tue Aug 29 10:59:28 2023 +0300

    Update docs/plugins/sort.rst

    Co-authored-by: Myk <myk.taylor@gmail.com>

commit f2a5d82
Author: DFHack-Urist via GitHub Actions <63161697+DFHack-Urist@users.noreply.github.com>
Date:   Tue Aug 29 01:23:03 2023 +0000

    Auto-update submodules

    scripts: master

commit 6c3da51
Merge: fb3ec49 6185df2
Author: Myk <myk.taylor@gmail.com>
Date:   Mon Aug 28 18:13:20 2023 -0700

    Merge pull request DFHack#3707 from myk002/myk_quickfort_by_id

    update quickfort user guide for new take_from semantics

commit fb3ec49
Merge: fe621d5 a8bf8a0
Author: Myk <myk.taylor@gmail.com>
Date:   Mon Aug 28 18:04:30 2023 -0700

    Merge pull request DFHack#3706 from myk002/myk_cage_price

    add in value for units contained in cages

commit 6185df2
Author: Myk Taylor <myk002@yahoo.com>
Date:   Mon Aug 28 17:59:52 2023 -0700

    update quickfort user guide for new take_from semantics

commit a8bf8a0
Author: Myk Taylor <myk002@yahoo.com>
Date:   Mon Aug 28 15:42:56 2023 -0700

    add in value for units contained in cages

commit fe621d5
Merge: 3ce2909 423bba2
Author: Myk <myk.taylor@gmail.com>
Date:   Mon Aug 28 13:48:47 2023 -0700

    Merge pull request DFHack#3705 from myk002/myk_get_any

    pass getAnyStockpile and getAnyCivZone through ZScreens

commit 423bba2
Author: Myk Taylor <myk002@yahoo.com>
Date:   Mon Aug 28 13:27:46 2023 -0700

    pass getAnyStockpile and getAnyCivZone through ZScreens

commit 4b0219e
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Mon Aug 28 10:56:08 2023 +0300

    fix stupid linux build again

commit 51baa0d
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Mon Aug 28 10:46:59 2023 +0300

    fix linux build

commit 6f11812
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Mon Aug 28 10:00:39 2023 +0300

    create and delete textures

commit 3ce2909
Author: DFHack-Urist via GitHub Actions <63161697+DFHack-Urist@users.noreply.github.com>
Date:   Mon Aug 28 06:20:58 2023 +0000

    Auto-update submodules

    library/xml: master
    scripts: master

commit a740c66
Merge: 04dcbe3 4fb6b09
Author: Myk <myk.taylor@gmail.com>
Date:   Sun Aug 27 22:45:52 2023 -0700

    Merge pull request DFHack#3663 from shevernitskiy/dynamic-texture-loading

    feat: dynamic texture loading

commit 4fb6b09
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Mon Aug 28 06:58:30 2023 +0300

    move textures to separate lua module

commit 6c5163a
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Sun Aug 27 22:28:03 2023 +0300

    adjust adopt region reset step

commit c91a02c
Author: Mikhail <mpanov@tetrika.school>
Date:   Sun Aug 27 17:52:09 2023 +0300

    Reworked fallback from rating sortings. Renamed melee potential to solo combat potential. Added group combat potential.

commit 6fcbf48
Author: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date:   Fri Aug 25 13:28:36 2023 +0000

    [pre-commit.ci] auto fixes from pre-commit.com hooks

    for more information, see https://pre-commit.ci

commit 493be93
Merge: 25f2c17 771d7f6
Author: Mikhail <mpanov@tetrika.school>
Date:   Fri Aug 25 16:26:32 2023 +0300

    Fixing conflicts.

commit 25f2c17
Author: Mikhail <mpanov@tetrika.school>
Date:   Fri Aug 25 16:18:20 2023 +0300

    Changed melee and ranged ratings to statistically proven linear formulas.

commit 771d7f6
Author: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date:   Thu Aug 24 15:49:53 2023 +0000

    [pre-commit.ci] auto fixes from pre-commit.com hooks

    for more information, see https://pre-commit.ci

commit 30488dc
Author: Mikhail <mpanov@tetrika.school>
Date:   Thu Aug 24 18:47:42 2023 +0300

    Trailing space again. My bad.

commit aef6064
Author: Mikhail <mpanov@tetrika.school>
Date:   Thu Aug 24 17:18:46 2023 +0300

    Trim trailing whitespace.

commit a1d6828
Author: Mikhail <mpanov@tetrika.school>
Date:   Thu Aug 24 16:26:09 2023 +0300

    Added melee rating, ranged rating, mental stability rating and stress to sorting options on military screen in sort.lua. Added info about new sorting methods to sort.rst. Added name to Authors.rst.

commit c1945f7
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Thu Aug 17 06:32:26 2023 +0300

    fix build err in gcc

commit bbbb8fb
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Tue Aug 15 21:18:52 2023 +0300

    invalid texpos is nil now

commit 2503864
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Tue Aug 15 21:11:06 2023 +0300

    remove unused variable

commit 5cafffa
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Mon Aug 14 13:04:38 2023 +0300

    typos

commit 0e725be
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Mon Aug 14 12:07:27 2023 +0300

    support closure as tile arg to get texpos

commit 900a2c6
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Mon Aug 14 09:02:37 2023 +0300

    invalid texpos is nil for lua

commit 91f4c3d
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Mon Aug 14 08:17:57 2023 +0300

    mirgate preloaded assets to lua

commit 1409af6
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Sun Aug 13 20:09:12 2023 +0300

    expose api to lua

commit 22b0671
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Sun Aug 13 08:33:31 2023 +0300

    review 2

commit 20460fe
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Sun Aug 13 07:40:35 2023 +0300

    tiny refactor texpos methods

commit 4bc3a9b
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Sun Aug 13 07:36:39 2023 +0300

    single quotes

commit 687bd82
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Sat Aug 12 20:05:15 2023 +0300

    pathable & unsuspend specific tile size

commit 46a3454
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Sat Aug 12 17:00:07 2023 +0300

    type alias for gcc

commit b20889e
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Sat Aug 12 16:34:33 2023 +0300

    minor refactor for lua switch

commit fe8bd4f
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Sat Aug 12 16:11:42 2023 +0300

    assets use dynamic texture loading

commit e81a908
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Fri Aug 11 21:40:41 2023 +0300

    review

commit 3e18e2f
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Fri Aug 11 09:50:51 2023 +0300

    eof fix one more time

commit 4bbcc7b
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Fri Aug 11 09:48:03 2023 +0300

    eof fix

commit e21f0f2
Author: shevernitskiy <mahahuha@ya.ru>
Date:   Fri Aug 11 09:14:05 2023 +0300

    dynamic texture loading
@shevernitskiy shevernitskiy marked this pull request as ready for review September 5, 2023 15:25
@shevernitskiy
Copy link
Contributor Author

should be squashed at merge i guess

@shevernitskiy
Copy link
Contributor Author

shevernitskiy commented Sep 8, 2023

I'd like to summarize the interim results.

  • df object typing
    Works almostly correct. Needs to be tested.
    Main caveat: default methods for different kind of entities (may be incorrect, need to clarify logic to add correct pack of methods)

  • dfhack signatures
    Founds methods from module exposing arrays in LuaApi.cpp. Other cases doesn't supported.
    Cepable to found ~75% of signatures in auto mode, ~65% are correct.
    Supports <expose> tag, that can explicitly declare signature for specific method in exposing array.
    Supports <force-expose> tag, that could explicitly declare whatever you want signature (with proper naming).
    Union and default values in signatures supported.
    Main work in this side is manual writing expose tags for missing or incorrect signatures.

  • lua signatures
    This part is about internal lua glue and type hinting between modules and files.
    df and dfhack types available everywhere.
    Parses modules and global scripts to find global functions and variables.
    Can parse class methods in the files, but not internal variables (self. declaration inside functions).
    Constants will be typed correctly if it's literal type (int/string/bool), but will be any in other cases.
    Can do type injection into modules, but not into global scripts.
    Parser could be improved to handle more complicated cases. But the most of work should be on lua scripts side, imo.
    Main utility functions can be annotated at least.

  • docs parsing
    Currently there are ~665 matches on docs parsing. About ~80% are valid.
    Works with signatures in lua and dfhack part.
    Regex pattern can be improved to find more matches.
    Docs can be slightly refactored to be more parsable for regex.

There are possibility to generate docs from typing. Could be useful for df object map i guess.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer if we could get these signatures from Lua API.rst. They're just going to get out of date if put in the cpp files as comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which one?
if you are talking about <expose> tag - it is right near the declared method (it is a part of regex).. so it is hard to forgot about it if you are doing something with this method...
else if about <force-expose> - yes, it is not the best solution... maybe it is easier just make static file with manual annotations.
Lua API.rst could be the source of signatures only if will be more or less strictly formated (in terms of signatures) with proper typing... atm docs can't be the source of typings

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tags are needed only if signature can't be found or found incorrect with auto mode

Copy link
Member

@myk002 myk002 Sep 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I see. that's tricky. The reason I'm concerned is that you don't look at LuaApi.cpp or LuaTools.cpp if you change a function signature. For example, if I change the function signature of an existing function in the Textures module, you don't need to change the WRAPM lines in LuaApi.cpp. They just magically generate a new Lua binding to match the new function signature. Any <expose> tags next to the WRAPM lines won't be seen.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of WRAPM signatures found well by auto search (because it easy search for Module::Function), so if you change signatures somewhere in Textures.cpp, it should be all ok...
tag are needed, where it can't be found accroding this logic, for example if it is wrapper function in LuaApi.cpp
It's a concept, it's hard to discuss such things in here, need live dialogue:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants