Skip to content

Generate Selene Yaml#43

Merged
HaroldCindy merged 43 commits into
secondlife:mainfrom
tapple:generate-selene
Jan 31, 2026
Merged

Generate Selene Yaml#43
HaroldCindy merged 43 commits into
secondlife:mainfrom
tapple:generate-selene

Conversation

@tapple

@tapple tapple commented Jan 28, 2026

Copy link
Copy Markdown
Contributor

Add a command to generate a selene yaml file for SLua:

python gen_definitions.py lsl_definitions.yaml slua_selene slua_definitions.yaml slua_default.yml

See the generated file and (the diff against vscode plugin)


Part of a set:

@tapple tapple marked this pull request as ready for review January 30, 2026 00:48
@WolfGangS

Copy link
Copy Markdown
Contributor

This commit needs clarifying by linden labs, 2e48833

The pure status of some of these methods is unknown and down to implementation, so no way for external users to know.

Comment thread slua_definitions.yaml
- name: difftime
comment: Returns the difference in seconds between two timestamps.
deprecated: true
comment: Returns the difference in seconds between two timestamps. Same as a - b.

@tapple tapple Jan 30, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I marked os.difftime as deprecated because of the documentation at https://luau.org/library/#os-library:

Calculates the difference in seconds between a and b; provided for compatibility only. Please use a - b instead.

Comment thread slua_definitions.yaml Outdated
- name: decode
comment: Decodes a base64 string to a string, or buffer if asBuffer is true
comment: Decodes a base64 string to a string, or buffer if asBuffer is true.
Returns an empty string/buffer if input is invalid.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It truncates at first error:

print(#llbase64.decode("AAAAAAAAAA&AAAAAAA")) == 7

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed: 94e24d4

Comment thread gen_definitions.py Outdated
def dump_syntax(definitions: LSLDefinitions, pretty: bool = False) -> bytes:
"""Write a syntax file for use by viewers"""
# TODO: add comment about auto-generation time/version like gen_luau_lsp_defs does.
# Requires modifying python-llsd to not add the XML declaration at the start.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's totally okay to just do format_xml(something).split(b'\n', 1) or something like that, that declaration is always going to be there on its own line for any successful output.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@tapple

tapple commented Jan 30, 2026

Copy link
Copy Markdown
Contributor Author

This commit needs clarifying by linden labs, 2e48833

The pure status of some of these methods is unknown and down to implementation, so no way for external users to know.

Reverted: fa9a37e

@HaroldCindy

HaroldCindy commented Jan 31, 2026

Copy link
Copy Markdown
Collaborator

May need some merging with main since I changed some of the typing hints / changed some things to @propertys. No need to rebase, I'm going to squash merge this anyway.

@HaroldCindy HaroldCindy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Generally looks good to me, thanks for sending this in! Just a couple questions, and needs merged.

Comment thread gen_definitions.py
ll_module = [m for m in slua_definitions.modules if m.name == "ll"][0]
header_comment = b"""<!-- SLua (Server Lua) keywonds file for Second Life Viewer.
This file is auto-generated by https://github.com/secondlife/lsl-definitions.
Version: TODO: auto-generate

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's possible to do, but it's some arcane git describe incantation that figure out the current tag or current commit relative to an ancestor tag. Your call on whether you want to do that now or I can do it later, I don't feel strongly about it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the sim capabality already gives them a uuid. I thought it would be that or something like it. Just using Last Updated instead and not bothering making up a version schema is fine too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll leave it to you

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hmm, maybe just put the current lsl-definitions commit SHA, which you can get from git rev-parse HEAD? Having a git SHA is probably more useful than having a version anyway.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Or hmmm. That would be tricky since it would only work if you ran the commands within the repo. Maybe just time at generation is fine then. It's mostly going to be used to visually determine if previously generated data is "old".

Comment thread gen_definitions.py
self.definitions.controls.update(def_dict["controls"])
self.global_scope.update(self.definitions.controls.keys())
# nil, true, false are also valid type literals
self.type_names.update(const["name"] for const in def_dict["builtinConstants"])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This seems a little strange to me, what is this for? Is this meant to include all valid literals? Are bool literals and say, number literals treated differently in type expressions?

@tapple tapple Jan 31, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

are number literals valid in type expressions? my quick and dirty type validator (just tries to make sure types are defined elsewhere in the yaml file) wouldn't work with those right now:

It makes sure every part of a type expression is either:

  1. previously defined in the file (type_names), or
  2. matches a regex that matches the various operators that aren't types. This regex knows about string literals, but not bool literals or number literals.

It's mostly an aid to make sure I actually listed all the valid types within slua_definitions.yaml. I could have added bool literals to the regex, but I added them to known_types instead since they are in the file (keywords_lua.xml needs them). Number literals aren't known to the regex because I didn't think about them until now, and haven't used any. A lot of the lsl functions could be typed with number literals, actually

@tapple tapple Jan 31, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It would probably make more sense to use a custom type function to type a lot of the lsl functions that take number arguments, like:

GetListEntryType: (src: list, index: number) -> range<0, 6>,
GetSimStats: (stat_type: range<0, 26>) -> number,

the syntax is probably wrong as I haven't yet played with type functions, and they might require --fflag LuauSolverV2=true, still in beta

@tapple tapple Jan 31, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

or, even better, auto-generate a bunch of type aliases by adding a family or group field to LSL constants that are part of a set

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Okay, I think putting that in self.type_names is fine for now then.

RE: grouping / enum concerns, there's a couple open issues about it, we'll need to come up with a spec to define certain constants in terms of enums and flags.

@HaroldCindy HaroldCindy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good to me, thanks! I'll handle the generated timestamp comment stuff.

@HaroldCindy HaroldCindy merged commit 38d3d8b into secondlife:main Jan 31, 2026
5 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jan 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants