Some useful Psion OOP Techniques and classes


Well, here's a starter for this topic

From the category file:

CLASS engine root
{
  ADD eng_init

  PROPERTY
  {
    int state ;
  }
}

From the method file:

#define this (self->engine)
#define STATE (self->engine.state)
#define STATE_MEMBER(self) ((self)->engine.state)
#define ENGINE_MEMBER(self, mem) ((self)->engine.mem)

METHOD int engine_eng_init(PR_ENGINE *self, int state) {
  // self has to be in scope and point to a PR_ENGINE
  // These 3 are equivalent
  // I prefer the first

  // this is the object itself not a pointer as in C++
  this.state = state ;

  // every member needs a define
  STATE = state ;

  // when there may be multiple objects
  STATE_MEMBER(self) = state ;

  // this last one works for all data members of engine
  ENGINE_MEMBER(self, state) = state ;

  return(state) ;
}



Back to My home page
© 1996 J. C. Roux