next up previous contents
Next: With CMOD Up: Write the Functions Previous: Write the Functions   Contents

Without CMOD

reversed_string_create()
This is the function that will be run upon creation of a ReversedString object, because we set that earlier in pike_module_init(). It does the following:
  1. Checks whether the constructor was called with one argument, i.e. if args == 1, throws an exception if not
  2. Checks whether the only argument is a pike_string , throws an exception if not.
  3. Takes the 49 first characters, using the Pike_fp-current_storage pointer, reverses the order of them, and stores them in storage.
  4. Removes one argument from the stack, i.e. does a pop_n_elems(args)

reversed_string_write()
This is just a function to generate some output in order to test if everything in the create function and the storage works. It does the following:
  1. Checks the argument, i.e. check that args == 1 and that the argument is an int.
  2. If the argument check succeeded, then it fetches the argument from the stack, and reads the content of the storage.
  3. Prints the content of the storage on the screen

The callback functions
The init and exit callback functions exist in this module, but since nothing needs to be done in them they are left empty. These functions need to take a struct object* as argument, or else warnings will be generated when the module is compiled.


next up previous contents
Next: With CMOD Up: Write the Functions Previous: Write the Functions   Contents
2003-03-04