lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


hi there!

1st of all, its a good idea, i already had this in my mind, but never
gone farer than an idea of what about using them from ffi...

sorry if im saying 100% bullshit, i've never used the c api, used only
a bit of lj ffi, and ive got no a clear vision about the internals,
but i have a kinda weak vision about these, and what could be the
actual problem..... so what i have is only some ideas :D

what i think is that there is no impossible, but whatever someone
would make with these actions, that could mess up things in the stack
- if im right.
i think some kinda wrapper/workaround can solve it.

however i can imagine that it can be used if there is a way to restore
the previous state of the lua stack, and then everything is going fine
after the action. so i think these steps can solve it: make a place
where the actual data will be stored with some simple valid lua, this
can be something like an another lua state that have a complete
accessor (i think there is such a toy out there, if not, then it would
be a nice stuff, it can be made even from pure ffi i think :) ) or a
user data that will be populated. then make a snapshot or some notes
for the only necessary data about the current state of lua. then you
can play whatever you want, or at least some limited stuffs that wont
harm the chance of a nice restore. populate your previously made place
with the new data. restore the previous point, and use your obtained
data as u like it. this is limited to obtain info, however after the
game u can use it for any purpose, so it maybe can give an unlimited
tool for do whatever, but kinda complicated... and also this way one
only can count on what will happen on lua side, so i think this is
still harmful if there is any magic that affects anything outside the
stack, like when you have an isolated data with a setter/getter, but
the original place is not directly accessible on the stack...

an another method is to follow up the changes and make everything fine
on a step by step manner for lua, as you can see all the internal
data, and u know how lua acts, i think you can count everything that
is needed, but i think that it takes a smaller bigger wrapper for
every single api function, so i think this will suffer under harder
tasks, but could be nice for experimenting at least. and maybe it can
even have an even smaller wrapper if any job can be accumulated for
the end of a bunch of the api calls.

and what i didnt calculate on the way is that it requires to play from
the stack from both lua and a kinda related tool for making api calls,
or the latter could be completely separated like a whole handover for
the time it acts, but i believe it is possible, as a lua c function (i
mean something that is accessible from lua side but the func is
defined on c side) can do kinda much anything without the chance of
getting into trouble as anything else than that would like to touch
the stack.

so i think its not impossible, but impossible on the raw way, but
possible if well baked, but this takes a whole expert toolset.

start it in small and achieve 2-3 usable c functions with the right
workaround to make everything smooth and slowly possibilities and the
right path will be crystallized, and wont forget to share the results,
this would be a so much cool toy :)

i hope i could say anything useful that have any relation with the
actual reality :D
bests 4 all! :)