Hi fellow wiki editors!

To help newly registered users get more familiar with the wiki (and maybe older users too) there is now a {{Welcome to the wiki}} template. Have a look at it and feel free to add it to new users discussion pages (and perhaps your own).

I have tried to keep the template short, but meaningful. /Johan G

Changes

Jump to: navigation, search

Howto:Extend Nasal

24 bytes added, 13:54, 16 November 2016
Minor edits
{{Nasal Internals}}
This article is dedicated to describing how to write custom C/C++ extension functions in order to '''extend the [[Nasal]] scripting interpreter''' in FlightGear, for example in order to expose new or existing FlightGear APIs to the Nasal scripting engine, so that Nasal scripts can access additional FlightGear internals.
<!-- Some interesting ideas for extending Nasal this way have been collected at [[Proposals:Nasal related]]. Article was deleted 1 July 2014. /Johan G, 12 December 2014 -->
== Intro ==
In FlightGear, the simplest way to add new extension functions is to look at the existing functions at {{flightgear file|src/Scripting/NasalSys.cxx|l=342}}.
There is a static table of function pointers (named funcs[]) referencing extension functions, along with their corresponding names in Nasal: {{flightgear file|src/Scripting/NasalSys.cxx|l=774797}}.
The following is a copy of the extension function list, taken in 11/2015:
You will need to add your new extension function to this list of static functions, preferably following the existing naming convention (i.e. "f_" prefix).
If your extension functions are likely to be fairly low level, and will thus be provided with a more abstract wrapper in Nasal space, these functions should use a prepended undercore ("_"), such as the {{func link|_fgcommandfgcommand()|pre=_}}, {{func link|_setlistenersetlistener()|pre=_}}, {{func link|_cmdargcmdarg()|pre=_}} and {{func link|_interpolateinterpolate()|pre=_}} functions.
== Extension function signature ==

Navigation menu