File: [Platon] / libco / libco / co_object.c (download)
Revision 1.6, Sun Mar 30 10:27:05 2003 UTC (21 years ago) by yenar
Changes since 1.5: +35 -400
lines
(really) big cleanup; most code moved into separate 'flavours' [co_object.c, co_object.h]
|
/***{{{*******************************************************************
* This file is part of libco - object library for C *
* Copyright (c) 2002 *
* Peter Rockai (yenar) <yenar@host.sk> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, *
* Boston, MA 02111-1307 USA *
*******************************************************************}}}***/
/* {{{ file description */
/**
* @file co_object.c
* @brief Object definition, creation and manipulation.
**/
/* }}} */
/* {{{ includes */
#include "co_util.h"
#include "co_gettext.h"
#include "co_object.h"
#include "co_exception.h"
#include "co_conv.h"
/* }}} */
#include "co_object.cometa"
/* general object functions */
/* {{{ */
void co_o_cleanup (co o)
{
M (o, delete);
} /* }}} */
/* {{{ */
co_v co_m (co o, co s, co_id_t a, ...)
{
va_list ap;
co_v rv;
va_start (ap, a);
rv = ((co_o_minimal) o) -> msg_handle (o, s, a, ap);
va_end (ap);
return rv;
} /* }}} */
/* {{{ */
co_v co_m_v (co o, co s, co_id_t a, va_list ap)
{
return ((co_o_minimal) o) -> msg_handle (o, s, a, ap);
} /* }}} */
#if 0
/* {{{ */
co_v co_clone_shallow (co this, co self, co_id_t message, va_list ap)
{
//co_o_small head = this;
co dest;
(void) message; (void) self; (void) ap;
CO_RETURN (co, this);
}
/* }}} */
/* {{{ */
co_v co_clone_deep (co this, co self, co_id_t message, va_list ap)
{
co n = M (this, sclone) . _co;
M (n, copy_deep, this); // ask object to copy over its data
CO_RETURN (co, n);
}
/* }}} */
/* {{{ */
co_v co_clone_full (co this, co self, co_id_t message, va_list ap)
{
co n = M (this, dclone) . _co;
((co_o_small) n) -> meth_ar =
co_meth_array_dup (((co_o_small) this) -> meth_ar);
CO_RETURN (co, n);
}
/* }}} */
/* {{{ */
co_v co_clone_clean (co this, co self, co_id_t message, va_list ap)
{
co n = M (this, sclone) . _co;
M (n, clean);
CO_RETURN (co, n);
}
/* }}} */
/* {{{ */
co_v co_clone_clean_full (co this, co self, co_id_t message, va_list ap)
{
co n = M (this, sclone) . _co;
M (n, clean);
((co_o_small) n) -> meth_ar =
co_meth_array_dup (((co_o_small) this) -> meth_ar);
CO_RETURN (co, n);
}
/* }}} */
/* {{{ */
static void __co_del (co o)
/// Delete object (internal).
/**
* Is identical to co_del_f, but internal. Use co_del_f instead.
**/
{
CO_DEBUG (3, "performing object destruction: %p", o);
((co_o_head) o) -> destroy = 1;
CO_EV (o, destroyed);
co_o_destroy (o);
((co_o_small) o) -> msg (o, o, COM (destroy), 0);
} /* }}} */
/* {{{ */
void co_del (co o)
{
if (((co_o_small) o) -> destroy) return; // already being destroyed :)
if (((co_o_small) o) -> msg_depth) {
((co_o_small) o) -> destroy = 1;
CO_DEBUG (3, "postponed object deletion: %p", o);
} else {
CO_DEBUG (3, "immediate object deletion: %p", o);
__co_del (o);
}
} /* }}} */
/* {{{ */
void co_del_f (co o)
{
CO_DEBUG (2, "forcing object deletion: %p", o);
__co_del (o);
} /* }}} */
/* {{{ */
co __co_o_bless (co o)
{
CO_DEBUG (3, "blessing object %p", o);
CO_PUSH (o);
CO_M (o, bless);
return o;
}
/* }}} */
/* {{{ */
co __co_o_bless_p (co o)
{
CO_DEBUG (3, "blessing object %p", o);
CO_M (o, bless);
return o;
}
/* }}} */
#endif /* 0 */
Platon Group <platon@platon.org> http://platon.org/
|