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:- Module initialization and shutdown
- Class definition
- Storage allocation for objects (including modules)
- Function definition and registration
- Variable definition and storage
- Function argument checking and passing
- Return value handling
- Polymorphic function overloading (function variants based on function type signature)Limitations, according to the precompiler:- Parenthesis must match, even within #if 0
- Not all Pike types are supported yet.
- No support for functions that take a variable number of arguments yet.
- RETURN; (void) doesn't work yet
- need a RETURN_NULL; or something.. RETURN 0; might work but may be confusing as RETURN x; will not work if x is zero.
o Comments does not work inside prototypes (?)In short, for most module applications, using CMOD can save you a large amount of time and effort, particularly in the area of avoiding bugs. Function bodies are written using standard C, so programming skills will transfer directly.1. Sample moduleA sample module that can be used as a starting point for further module development can be found at http://buoy.riverweb.com:8080/viewrep/cvs/pike_modules/SampleModuleThis sample module represents a minimal CMOD module with a Pike module over-wrapper. The over-wrapper in this case is non-functional, and is included to show the necessary constants for providing module repository functionality.1. 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
|
|