CMOD
What is CMOD?CMOD is the name of a simplified mechanism for writing extensions to the Pike programming language. CMOD files consist of C language code plus simplified function definition elements that handle many of the most tedious tasks associated with module development. A CMOD file is pre-processed by the CMOD precompiler resulting in a standard C file that is then compiled normally.Tasks the CMOD compiler takes care of:
// PIKE INCLUDES MUST BE PRESENT FOR COMPILATION.PIKECLASS fnord
attributes;
{
INHERIT bar
attributes; CVAR int foo;
PIKEVAR mapping m
attributes; DECLARE_STORAGE; // optional PIKEFUN int function_name (int x, CTYPE char * foo)
attribute;
attribute value;
{
C code using 'x' and 'foo'.
RETURN x;
}
INIT
{
// Object initialization code.
} EXIT
{
// Object cleanup code.
}
GC_RECURSE
{
// Code to run under the gc recurse pass.
} GC_CHECK
{
// Code to run under the gc check pass.
} EXTRA
{
// Code for adding extra constants etc.
} OPTIMIZE
{
// Code for optimizing calls that clone the class.
// The node for the call is available in the variable n.
}
}
Multiple CMOD files in a single moduleAt a certain point, a module cannot be reasonably managed as a single source file. Typically, a module will be split into multiple classes, and it is often desirable to have each class be contained in a separate file. The Pike module build system will happily compile multiple CMOD files and link them into a single module shared object. However, a few steps must be taken in order for the resulting object to be functional.Powered by PikeWiki2 |
|||
| gotpike.org | Copyright © 2004 - 2009 | Pike is a trademark of Department of Computer and Information Science, Linköping University | |||