Nasal/CppBind: Difference between revisions

Jump to navigation Jump to search
m
m (→‎Intro: right, thanks Adrian - it's WIP :-) http://forum.flightgear.org/viewtopic.php?f=66&t=21217#p193362)
Line 3: Line 3:


== Intro ==
== 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.
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++. FlightGear however is mostly written and being developed in C++. For quite a while, that meant that the Nasal APIs were a bit low-level, and sometimes also awkward, to use when making functions, data structures and objects accessible between C++ and Nasal.
 
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.
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.
Line 14: Line 16:


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.
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.  

Navigation menu