Howto:Extend Nasal: Difference between revisions

Jump to navigation Jump to search
m
→‎Status (cppbind): forum2wiki http://forum.flightgear.org/viewtopic.php?f=66&t=21217&p=193362&hilit=cppbind#p193362
m (→‎Status (cppbind): forum2wiki http://forum.flightgear.org/viewtopic.php?f=66&t=21217&p=193362&hilit=cppbind#p193362)
Line 7: Line 7:
The cppbind framework is much more generic and high level than the bare APIs documented here, it includes unit testing support and makes use of modern C++ features like templates and STL support, including SimGear specific types like SGPath/SGGeod etc, its overhead is fairly small (not just performance, but also LoC to create new bindings).
The cppbind framework is much more generic and high level than the bare APIs documented here, it includes unit testing support and makes use of modern C++ features like templates and STL support, including SimGear specific types like SGPath/SGGeod etc, its overhead is fairly small (not just performance, but also LoC to create new bindings).
The cppbind framework is already extensively used by the [[Canvas]] system and the NasalPositioned bindings, both of which are a good place to look for code examples.
The cppbind framework is already extensively used by the [[Canvas]] system and the NasalPositioned bindings, both of which are a good place to look for code examples.
You will find that most of the "old" code in $FG_SRC/Scripting still uses those C-APIs for interacting with the Nasal engine. Only the new code, #include'ing <simgear/nasal/cppbind>, uses boost templates to hide the low level details.
Most of the code in the Nasal subsystem itself (FGNasalSys) also still uses the legacy C APIs - this is just to explain the two approaches, to avoid unnecessary confusion.
Overall, it's a good idea to favor cppbind over the low-level approach documented here, it isn't only much more elegant, but also saves you tons of typing, too 
Some of the more straightforward things to play with would be exposing useful SG/FG classes to Nasal space, such as the SGSubsystem interface to register scripted SGSubsystems, or the autopilot system.
For more technical Nasal questions (C API, internals etc), you'll probably want to refer to the forum, in particular: Philosopher, TheTom, Zakalawe or Hooray - TheTom and Zakalawe can also provide help on using cppbind, having both used it extensively during the last months.


== Scope ==
== Scope ==

Navigation menu