--- /dev/null
+%{
+#include <time.h>
+#include "my-person.h"
+%}
+
+class My:Person from Gtk:Object {
+ public char *name;
+ public long dob; /* date of birth as a time_t */
+ public long dod; /* date of death as a time_t */
+
+ private int rounds_in_shotgun; /* number of rounds in our shotgun */
+
+ argument POINTER name
+ get {
+ if(self->name)
+ ARG = g_strdup(self->name);
+ else
+ ARG = NULL;
+ }
+ set {
+ g_free(self->name);
+ if(ARG)
+ self->name = g_strdup(ARG);
+ else
+ self->name = NULL;
+ };
+
+ argument LONG dob get { ARG = self->dob; } set { self->dob = ARG; };
+ argument LONG dod get { ARG = self->dod; } set { self->dod = ARG; };
+
+ init(person)
+ {
+ person->name = g_strdup("Nobody");
+ person->dob = 0;
+ person->dod = 0;
+
+ /* initially we have no rounds in the shotgun */
+ person->_priv->rounds_in_shotgun = 0;
+ }
+
+ /* when the person gets born, sends out a signal, the caller
+ of the signal should provide the date of birth */
+ signal last NONE (LONG)
+ void
+ birth(self, long dob)
+ {
+ self->dob = dob;
+ }
+
+ /* when the person dies, sends out a signal, the caller
+ of the signal should provide the date of death */
+ signal last NONE (LONG)
+ void
+ death(self, long dod)
+ {
+ self->dod = dod;
+ }
+
+ public
+ void
+ load_shotgun(self)
+ {
+ /* add a round to our shotgun */
+ self->_priv->rounds_in_shotgun++;
+ }
+
+ public
+ void
+ shoot_oneself_in_the_head(self)
+ {
+ if(self->_priv->rounds_in_shotgun==0) {
+ g_warning("No rounds in the shotgun!");
+ return;
+ }
+
+ /* one round was fired */
+ self->_priv->rounds_in_shotgun--;
+
+ /* death is imminent if we shoot oneself in the head */
+ death(self,(long)time(NULL));
+ }
+}