File: [Platon] / libco / libco / co_o_small.h (download)
Revision 1.1, Sun Mar 30 10:26:58 2003 UTC (21 years ago) by yenar
add implementation of basic object flavour: 'small' - mostly comes
from co_object.c, with some improvements [co_o_small.c, co_o_small.h]
|
/***{{{*******************************************************************
* This file is part of libco - object library for C *
* Copyright (c) 2002, 2003 *
* 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_o_small.h
* @brief Implementation of "small" object flavour.
**/
/* }}} */
#ifndef __CO_O_SMALL_H__
#define __CO_O_SMALL_H__
#include "co_object.h"
#include "co_type.h"
#include "co_exception.h"
#include "co_string.h"
#define CO_METH(x, y, ...) co_v x ## _ ## y \
(co_o_minimal this CO_POSSIBLY_UNUSED, co self CO_POSSIBLY_UNUSED, \
co_id_t message CO_POSSIBLY_UNUSED, va_list ap CO_POSSIBLY_UNUSED)
#define CO_METH_INI(x, y) CO_METH_INI_ ## x ## _ ## y
/* {{{ */
struct co_meth_entry
/// Method table entry.
{
co_id_t message;
co_message_handler handler;
};
CO_TYPEDEF (co_meth_entry);
/* }}} */
/* {{{ */
struct co_meth_array
/// Method table.
{
size_t size;
size_t n;
co_meth_entry meth;
};
CO_TYPEDEF (co_meth_array);
/* }}} */
/* {{{ */
#define CO_HEAD_EX_SMALL \
co_meth_array meth_ar; \
unsigned msg_depth:17; \
int destroy:1;
/* }}} */
/* {{{ */
struct co_o_small
{
CO_HEAD;
CO_HEAD_EX_SMALL;
};
CO_TYPEDEF (co_o_small);
/* }}} */
/// Create new method table (internal).
/** @internal */
void *co_meth_array_new (void);
/// Duplicate existing method table (internal).
void *co_meth_array_dup (co_meth_array src);
void co_meth_array_free (co_meth_array ar);
/// Add new item to (pre-existing) method table.
co_id_t co_meth_add (co_meth_array ar, co_id_t message,
co_message_handler handl);
/// Check if method is present in object.
co_v co_has_method (co o, co s, co_id_t a, va_list ap);
void co_o_small_bless (co _o);
co co_o_small_new (void);
co_v co_o_small_delete (co _o, co self, co_id_t message, va_list ap);
co_v co_o_small_destroy (co _o, co self, co_id_t message, va_list ap);
void co_o_small_copy (co_o_small dest, co_o_small src);
co_v co_o_small_clone_min (co this, co self, co_id_t message, va_list ap);
co_v co_o_small_clone (co this, co self, co_id_t message, va_list ap);
co_v co_o_small_clone_deep (co this, co self, co_id_t message, va_list ap);
#endif /* __CO_O_SMALL_H__ */
Platon Group <platon@platon.org> http://platon.org/
|