lua-users home
lua-l archive

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


After the discussion with Edgar, I have made a couple changes (see
below).  The amount of modified Lua code is now even less.

-Josh

-------------

After the discussion about unified methods, I have copied just the
method table code from the LuaState distribution and put it in a clean
Lua 4.1 Work Beta implementation.

Credit for the method tables implementation goes to Edgar Toernig, who
created the method tables for Sol.  Except for the parser changes and
new VM opcodes, this is 100% Edgar's work.

Documentation can be found in the "Unified Methods" and "Standard
Unified Method Callbacks" sections of
http://www.workspacewhiz.com/Other/LuaState/LuaState.html with the
following differences:

* The LuaState :: operator is now gone.
* Due to parser changes in Lua 4.1 Work Beta (as opposed to Lua 4.1
Alpha), it is no longer possible to:

print(4->sqrt())

The modified directories can be found here.  Just do a diff of the
original Lua 4.1 Work Beta code and this code to see the small number of
differences.

http://workspacewhiz.com/Other/LuaState/Lua41BetaWorkMethodTables.zip

Changes:
====================

lauxlib.*:

* Added luaL_openlibintotable() helper function (Sol).

lua.h:

* Added LUA_NTYPES #define. (Sol)
* Added lua_getmethods(). (Sol)
* Added lua_getdefaultmethods(). (Sol)
* Added lua_setmethods(). (Sol)

lapi.c:

* Implements lua_getmethods(). (Sol)
* Implements lua_getdefaultmethods(). (Sol)
* Implements lua_setmethods(). (Sol)

lcode.*:

* Added function luaK_selfmethod().

ldebug.c:

* Added functions travtable() and travmethods().  (Sol)
* In function getname(), a travmethods() call has been added.  (Sol)

lgc.c:

* Function marktable() has been upgraded to check the methods table.
(Sol)
* markobject() has been upgraded to wander user data's methods.  (Sol)
* checkMbuffer() has been fixed to compile under VC6.

lbaselib.c:

* Added function luaB_methods().  (Sol)
* Default method tables are created.  (Sol)

liolib.c:

* File method table created.  (Sol)

lmathlib.c:

* Number method table created.  (Sol)

lstrlib.c:

* String method table created.  (Sol)

llex.*:

* In luaX_lex(), the case for a - (minus) has been upgraded to check for
a >
  (greater than) symbol following.

lobject.h:

* The struct Udata has a Table* methods member added.  (Sol)
* The struct Table has a Table* methods member added.  (Sol)

lopcodes.*:

* Upgraded to handle the new opcode OP_SELFMETHOD.

lparser.c:

* In primaryexp(), the case TK_POINTSAT has been added.

lstate.c:

* In function f_luaopen(), method tables are built into the global
state.  (Sol)

lstate.h:

* struct global_State has Table* methods[LUA_NTYPES] array added.  (Sol)

lstring.c:

* luaS_newudata() assigns the default userdata method table.  (Sol)

ltable.c:

* luaH_new() assigns the default table method table.  (Sol)
* In function newkey(), settableval() was fixed to compile under VC6.

ltm.*:

* Functions luaT_getmethods() and luaT_setmethods() added.  (Sol)

lvm.c:

* Function luaV_getmethod() added.
* Virtual machine opcode OP_SELFMETHOD implemented.