next up previous contents
Next: Write the Functions Up: Define the Pike Level Previous: Without CMOD   Contents

With CMOD

The ReversedString realized with CMOD instead looks as follows:
PIKECLASS ReversedString{
   CVAR char reversed_string[50];
   PIKEFUN void create(string input){
       /*write the implementation of
         create here */
   }
   PIKEFUN void write(int nr_of_times){
       /*write the implementation of
         write here */
   }
   INIT{
      /*write the init callback here*/
   }
   EXIT{
      /*write the exit callback here*/ 
   }
}

void pike_module_init(){}
void pike_module_exit(){}
As we can see the declaration is straight forward and do not need that much explanation. The CVAR call results in that storage is added for a fifty character long char array. PIKEFUN adds the method that follows right after the keyword. INIT and EXIT add the init- and exit callback respectively. Finally, pike_module_init() and pike_module_exit need to exist in order for the module to be recognized as a module, they can be kept empty though.

Now, having handled the 'mandatory' parts, let us take a look at the functions that implements the functionality of the module.



2003-03-04