Changes

Jump to: navigation, search

Howto:Extend Nasal

22 bytes removed, 17:16, 22 December 2013
m
== Status (cppbind) ==
As of 03/2013, this article should be considered depreciated, we have [[Nasal/CppBind|a new C++-based API for exposing C/C++ functions/data structures to Nasal and vice versa]] in [https://{{Git file|gitorious.org/|fg/simgear/trees/|next/|simgear/nasal/cppbind |pre=$SG_SRC/nasal/cppbind]}}. Usually, there should be no need to use the bare Nasal APIs anymore for exposing functions/data to Nasal or Nasal-space types to C++, except for people working on the '''cppbind''' framework itself.
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).
All Nasal related articles can be found in the [http://wiki.flightgear.org/index.php/Category:Nasal Nasal category].
'''Note:''' FlightGear's version of the Nasal interpreter is maintained in the [http://www.simgear.org SimGear] git repository, inside the [{{Git file|gitorious.org/|fg/simgear/trees/|next/|simgear/nasal] |pre=$SG_SRC/}} folder, the most important header file detailing the internal Nasal API is "[http://simgear.org/doxygen/nasal_8h-source.html nasal.h]", you will want to check this out for the latest changes and information.
You will probably also want to check out the [{{Git file|gitorious.org/|fg/simgear/trees/|next/|simgear/nasal] |pre=$SG_SRC/}} folder for specific examples on using the various Nasal APIs that are not yet covered here completely.
'''Important:''' As of 05/2009, this article is work in progress, and none of the examples have so far been tested/compiled.
= Intro =
In FlightGear, the simplest way to add new extension functions is to look at the existing functions in [http://{{Git file|gitorious.org/|fg/flightgear/blobs/|next/|src/Scripting/NasalSys.cxx#line482 |482|pre=$FG_SRC/Scripting/NasalSys.cxx](src/Scripting/NasalSys.cxx)}}.
There is a static table of function pointers (named funcs[]) referencing extension functions, along with their corresponding names in Nasal: http://{{Git file|gitorious.org/|fg/flightgear/blobs/|next/|src/Scripting/NasalSys.cxx#line482|482|pre=$FG_SRC/}}
The following is a copy of the extension function list, taken in 05/2009:
The naRef objects can be manipulated using the functions in [http://simgear.org/doxygen/nasal_8h-source.html nasal.h].
For the latest copy of the file, see: http://{{Git file|gitorious.org/|fg/simgear/blobs/|next/|simgear/nasal/nasal.h|pre=$SG_SRC/}}
Basically, you can check the type of the reference with the following naIs*() functions:
= Wrapping C++ Classes as Nasal Objects (cppbind) =
Please see: https://{{Git file|gitorious.org/|fg/simgear/trees/|next/|simgear/nasal/cppbind|pre=$SG_SRC/}}
<!--
'''To be written by Hooray & Zakalawe'''
395
edits

Navigation menu