Howto:Extend Nasal: Difference between revisions

Jump to navigation Jump to search
m
Line 397: Line 397:


There's a plan to eventually generalize and unify all those helpers in FGPositioned.cxx and provide them as part of the FGNasalSys class (or some custom abstract base class that C++ classes should implement to expose objects to Nasal), so that they automatically become available to all users of the Nasal subsystem, just by implementing a certain interface. By exposing objects with methods, rather than plain variables, it will be possible to compute results lazily.
There's a plan to eventually generalize and unify all those helpers in FGPositioned.cxx and provide them as part of the FGNasalSys class (or some custom abstract base class that C++ classes should implement to expose objects to Nasal), so that they automatically become available to all users of the Nasal subsystem, just by implementing a certain interface. By exposing objects with methods, rather than plain variables, it will be possible to compute results lazily.
Such an abstract base class should feature:
* virtual constructor to set up: dtor, ghost name, ghost getter
* virtual destructor function to delete Nasal ghosts
* mapping helper to map C++ functions with SG/STL return types to Nasal data structures (std::string, std::vector, std::map)
* lazy getter
* helper: hashset()
* helper: stringToNasal
* helper: to set up valid parents vector for inheritance to work properly


Looking at the code in [http://gitorious.org/fg/flightgear/blobs/78afdb3c2227e75fc1542b3992dcea26181d98cf/src/Scripting/NasalPositioned.cxx#line139 NasalPositioned.cxx]:
Looking at the code in [http://gitorious.org/fg/flightgear/blobs/78afdb3c2227e75fc1542b3992dcea26181d98cf/src/Scripting/NasalPositioned.cxx#line139 NasalPositioned.cxx]:

Navigation menu