<?php

/**
 *
 * @copyright  2012 so-o.org
 * @version    1
 * @link       http://www.so-o.org
 */

namespace X;

require_once 'So-o.php';

defclass('X', null, 1, array('count'), array('value'), array('initialize', 'new', 'count'), array('free', 'init'));

function c_initialize($self) {
	return sendmsg($self, 'set', 'count', 0);
}

function c_new($self) {
	$i=supersend('new', func_get_args());

	sendmsg($self, 'set', 'count', sendmsg($self, 'get', 'count') + 1);

	return $i;
}

function c_count($self) {
	return sendmsg($self, 'get', 'count');
}

function i_free($self) {
	$count=sendmsg(sendmsg($self, 'class'), 'get', 'count');

	sendmsg(sendmsg($self, 'class'), 'set', 'count', $count - 1);

	supersend('free', func_get_args());
}

function i_init($self, $value=0) {
	supersend('init', func_get_args());

	sendmsg($self, 'set', 'value', $value);

	return $self;
}
