20,741
edits
m (→Getting started: make it build) |
m (→Intro: right, thanks Adrian - it's WIP :-) http://forum.flightgear.org/viewtopic.php?f=66&t=21217#p193362) |
||
| Line 2: | Line 2: | ||
{{Stub}} | {{Stub}} | ||
== Intro == | |||
Until FlightGear 2.8, FlightGear's built-in [[Nasal]] scripting engine only provided a C API to expose hooks/bindings to scripting space or to expose scripting space data structures back to C/C++. Thanks to the canvas system, there's now a new bindings framework to be found in simgear/nasal/cppbind. This is fully object oriented and supports modern C++ features. | |||
You will find that most of the "old" code in $FG_SRC/Scripting still uses those old C-APIs for interacting with the Nasal engine. Only the new code, #include'ing <simgear/nasal/cppbind>, uses boost templates to hide 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. You will find the old, low-level APIs explained at [[Howto:Extend Nasal]]. | |||
Meanwhile, we suggest to favor cppbind over the old, low-level, approach, it isn't only much more elegant, but also saves you tons of typing, too - and will do certain error-checking automatically, that you would otherwise have to implement manually. | |||
After working through this article, tome 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 Philosopher, TheTom, Zakalawe or Hooray on the forum - TheTom and Zakalawe can also provide help on using cppbind, having both used it extensively during the last months. | |||
== Objective == | == Objective == | ||
Provide a fully annotated step-by-step introduction to Nasal's cppbind framework. This is mostly based on existing code in SimGear/FlightGear. The cppbind framework itself is to be found $SG_SRC/nasal/cppbind and it's pretty well commented, and makes use of Doxygen strings. If you are already familiar with C++ and SG/FG,, you'll want to check out the unit tests in cppbind_test.cxx. | Provide a fully annotated step-by-step introduction to Nasal's cppbind framework. This is mostly based on existing code in SimGear/FlightGear. The cppbind framework itself is to be found $SG_SRC/nasal/cppbind and it's pretty well commented, and makes use of Doxygen strings. If you are already familiar with C++ and SG/FG,, you'll want to check out the unit tests in cppbind_test.cxx. | ||