lua-users home
lua-l archive

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


Hi there

 

We’ve extended LUA to support some new value types to store vectors and quaternions in to make it a little better for maths. Along the way, as these new value types contain fields (vec.x, vec.y, etc), we modified the gettable function to read these properties from the lua value. This basically means luaV_gettable now contains an case in its type check statement that says ‘else if ttisvec(t)’, check the field requested and return it (so mynumber = myvec.x or mynumber = myvec[0] work). A lot of this was based off the approach of the existing experimental luavec library.

 

However, on modifying luaV_settable in the same way, we noticed the value passed into the function is const:

 

void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {

 

It then gets cast to a none-const table in the table case.

 

Does anybody have any experience modifying these bits, and any idea as to whether it’s safe to cast away that const so that our lua code can write to the value (allowing myvec.x = 10 for example), or is there a good reason that value is read-only.

 

Cheers

 

-Chris




Please consider the environment before printing this email :-)

This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the sender immediately then delete this email. Any views expressed in this email are solely that of the individual and not representative of the company as a whole.

Media Molecule Limited
Company Reg No 5665849
Registered in England.

______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________