Howto:Extend Nasal: Difference between revisions

Jump to navigation Jump to search
m
Line 25: Line 25:
In FlightGear, the simplest way to add new extension functions is to look at the existing functions in [http://cvs.flightgear.org/viewvc/source/src/Scripting/ $FG_SRC/Scripting]/NasalSys.cxx (src/Scripting/NasalSys.cxx).
In FlightGear, the simplest way to add new extension functions is to look at the existing functions in [http://cvs.flightgear.org/viewvc/source/src/Scripting/ $FG_SRC/Scripting]/NasalSys.cxx (src/Scripting/NasalSys.cxx).


There is a static table of function pointers referencing extension functions, along with their corresponding names in Nasal.  
There is a static table of function pointers (named funcs[]) referencing extension functions, along with their corresponding names in Nasal.  
The following is a copy of the extension function list, taken in 05/2009:
The following is a copy of the extension function list, taken in 05/2009:


Line 52: Line 52:
   };
   };


So, the basic format is "name", function_pointer - whereas "name" refers to the internal name used by Nasal and its script, and "function_pointer" has to use the right function signature and is a pointer to the implementation of the Nasal function in C/C++ code space:
So, the basic format is "name" (string), function_pointer - whereas "name" refers to the internal name used by Nasal and its scripts, and "function_pointer" has to use the right function signature and is a pointer to the implementation of the Nasal function in C/C++ code space:


  // The function signature for an extension function:
  // The function signature for an extension function:
2,561

edits

Navigation menu