|
SWIG/Examples/perl5/variables/
Wrapping C Global Variables$Header: /cvs/projects/SWIG/Examples/perl5/variables/index.html,v 1.1.4.1 2002/04/08 03:55:34 beazley Exp $When a C global variable appears in an interface file, SWIG tries to wrap it using a technique known as "variable linking." The idea is pretty simple---we try to create a Perl variable that magically retrieves or updates the value of the underlying C variable when it is accessed. Click here to see a SWIG interface with some variable declarations in it. Manipulating Variables from PerlAccessing a C global variable from Perl is easy---just reference it like a normal Perl variable. Click here to see a script that updates and prints some global variables.Creating read-only variablesThe %immutable and %mutable directives can be used to specify a collection of read-only variables. For example:The %immutable directive remains in effect until it is explicitly disabled using the %mutable directive.%immutable; int status; double blah; ... %mutable; Notes:
|