Specman Elite provides a lot of flexibility in the interaction between e code and C code.
A special script sn_compile.sh is provided with the Specman Elite installation to compile and link C code and e code in Specman Elite.
The SN_TYPE macro declares an e type in C. Use this macro whenever an e enumerated type or struct must be declared in C.
The SN_LIST macro declares an e list type in C. Use this macro whenever an e list must be declared in C.
An enumerated value name can be specified with the SN_ENUM macro.
The SN_DEFINE macro specifies an e defined name in C. Use this macro whenever an e defined name is to be used in C.
Data can be passed as parameters between e and C. Data of type int, uint, enum, and bool are passed by value (a copy is passed). Data of type struct, list, and string are passed by pointer (by reference).
A struct in e is represented in C as a pointer to a C struct. You access its fields using the -> operator. The name of the C struct field is the same as defined in e. A struct field whose name is a keyword in C (like int or for) is not accessible in C.
There are three ways to call a C routine from e code—a global e routine to be implemented as a C routine, a local e method to be implemented as a C routine or a local e method to be implemented as a dynamic C routine or foreign dynamic C routine. The is C routine keywords are used to implement these e routines. Dynamic C routines are not discussed in this chapter.
Calling an e method from C is done using the SN_DISPATCH macro. You can use SN_DISPATCH in C routines that have been called from e or in C routines called from other C code.
The C export statement exports the e declared type or method to the generated C header file when the e modules are compiled with 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.
You can integrate C++ code with Specman Elite using Specman Elite C interface by means of some special workaround techniques.