How to list all functions and fields in userdata #481
Unanswered
lammermann
asked this question in
Q&A
Replies: 1 comment
-
The best way to do this is to honestly have each userdata implement an __iter metatable (or whatever your Lua uses for this) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello guys,
I try to build a REPL with mlua and rustyline.
When it comes to tab-completion I check if the current prompt could be completed by using the method
for_each
from the tables. For example given the current promptfoo.b
it searches the lua globals forfoo
and then searches all fields infoo
and filters to only those beginning withb
then returningbar
andbaz
as possible completions.This works fine for tables but I could not find something similar for userdata ( I found the method
pairs
in theUserDataMetatable
but it does not seem to return the name of the functions of the userdata).Is there any advice how to get this information from userdata?
Thanks in advance for any hints
Beta Was this translation helpful? Give feedback.
All reactions