Previous Section Next Section

16.6 C Export

The C export statement exports the e declared type or method to the generated C header file when compiling the e modules using the sn_compile.sh script. When a struct is exported, it in turn exports all the types of its fields, recursively. Methods of a struct must be exported explicitly. No parameters should appear in the method export statement, even if the method has parameters associated with it. The export statement can appear in any e module (where the types or methods are known). The syntax for the C export statement is as follows:

C export type-name ;
C export type-name.method-name();

Example 16-12 shows a C export statement usage.

Example 16-12 C Export Statement Usage
This example shows the usage of C export statements.
When a struct is exported, all fields of the struct are
recursively exported for use in the C code. However,
methods of the struct must be explicitly exported.
<'
type color: [red, green, blue]; -- Enumerated type
struct packet { -- Struct packet
    add(num: int) is { -- Method of struct packet.
      ...
    };
    ...
};

C export packet; -- Export struct packet for use in C code.
C export packet.add(); -- Export method packet.add() for use in C
                       -- code.
C export color; -- Export enumerated type.
'>
Previous Section Next Section