Update of bug #15696 (project freeciv):

                Priority:               1 - Later => 5 - Normal             
                  Status:                    None => Ready For Test         
         Planned Release:                         => 2.2.1, 2.3.0           
                 Summary: Scripting: Make all fields constant => API: No
writable struct fields, no unprotected C functions or unsafe pointer use

    _______________________________________________________

Follow-up Comment #1:

Finally we take control of all field access on API objects.

No writable struct fields (as mentioned in the initial report).
(Modifications should be made by methods or actions, currently there are very
few of modifying methods.)

Hide '.get' table and tolua.cast and other tolua functions (Allows using
getters of one API class on objects of another class, equivalent to accessing
a struct field after casting to another pointer type, clearly a wild pointer
access).


For 2.2, special methods block is backported as a whole from trunk, so the
definition of the equality (==) operation for API objects rides in on this
patch.

With this change, all pointer use in the API should now be checked and be
indirect. There is a certain (possible, not benchmarked) (performance) cost,
when we proxy field lookup through our 'field_getter' function. This is
however how we can take full control in our Lua layer, but still using tolua.
(We also already use field lookup indirection for one field exported by the
property mechanism, Player.id).

Another cost is that all API classes are hidden from the namespace, so direct
modification is not possible, and introspection is made impossible. This could
possibly be solved.

This change is not critical for 2.2.1, but I feel confident enough to propose
it for 2.2 branch.

(file #9014, file #9015)
    _______________________________________________________

Additional Item Attachment:

File name:
2010041801-S2_2-API-Pointer-safety-in-tolua-accessors-and-tolu.patch Size:4
KB
File name: 2010041801-API-Pointer-safety-in-tolua-accessors-and-tolu.patch
Size:3 KB


    _______________________________________________________

Reply to this item at:

  <http://gna.org/bugs/?15696>

_______________________________________________
  Meddelandet skickades via/av Gna!
  http://gna.org/


_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to