[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Macros for setting / testing / getting value components in lobject.h
- From: Roberto Ierusalimschy <roberto@...>
- Date: Mon, 8 Jun 2015 10:34:17 -0300
> The various macros in lobject.h for setting value and type, checking
> if a type is a given type, or extracting the value component from
> TValue - these are the only ways in which Lua ever manipulates a
> TValue object. So changing these macros as I have done, is all that is
> needed to support a modified TValue component. I guess I am trying to
> understand if there are hidden assumptions elsewhere in the code that
> assumes that TValue has a particular structure.
There should not be hidden assumptions. BTW, Lua 5.2 has the NaN trick
implemented (on top of these macros).
> Another observation while making the changes:
>
> There are a couple of macros later on in lobject.h which directly
> access the tt_ element in TValue rather than using settt_() and
> rttype() - should these be changed to use the macros instead as below:
>
> #define setuservalue(L,u,o) \
> { const TValue *io=(o); Udata *iu = (u); \
> iu->user_ = io->value_; iu->ttuv_ = rttype(io); \
> checkliveness(G(L),io); }
>
>
> #define getuservalue(L,u,o) \
> { TValue *io=(o); const Udata *iu = (u); \
> io->value_ = iu->user_; settt_(io, iu->ttuv_); \
> checkliveness(G(L),io); }
Ok.
-- Roberto