Summary: Export specenum_gen enums in the Lua event
scripting API
                 Project: Freeciv
            Submitted by: englabenny
            Submitted on: fredag 2010-04-30 den 17:37
                Category: None
                Priority: 5 - Normal
                  Status: Ready For Test
                 Privacy: Public
             Assigned to: englabenny
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: 2.3.0



With specenum we can easily export enums to lua using runtime name to
value lookup.

(Given progress with Matthias' patches on specenums, this looks like a very
good direction of development. The following patch only exports the events.h
specenum, the only one used in the API right now).

The looked-up value is written back to the lua table and thus every
lookup after the first will be looked up in the lua-side table
(remember, the __index metamethod in Lua is only a fallback).

api_specenum is exported by writing functions against the Lua C API
directly, without using tolua. This because the enum lookup is written
as template only once and can be instantiated for each specenum type.

Scripting API incompatibilities:
  Typos are not preserved (E.E_LOG_ERROR was exported, should have been and
is now E.LOG_ERROR)
  The 'E' table/module is no longer iterable (=introspectable) since it is
dynamically looked up.

I consider these incompatibilities trivial and nothing to worry about.


File Attachments:

Date: fredag 2010-04-30 den 17:37  Name:
2010043002-Export-specenum_gen-enums-in-the-Lua-event-scr.patch  Size: 13 kB 
 By: englabenny



Reply to this item at:


  Meddelandet skickades via/av Gna!

Freeciv-dev mailing list

Reply via email to