Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Thursday, March 28, 2024

File: [Platon] / libco / test / event.c (download)

Revision 1.1, Sun Mar 30 10:27:32 2003 UTC (21 years ago) by yenar

simple event test [event.c]

/***{{{*******************************************************************
 * This file is part of libco - object library for C                     *
 * Copyright (c) 2002 Peter Rockai (yenar) <yenar@host.sk>               *
 *                                                                       *
 * This program is free software; you can redistribute it and/or         *
 * modify it under the terms of the GNU General Public                   *
 * License as published by the Free Software Foundation; either          *
 * version 2 of the License, or (at your option) any later version.      *
 *                                                                       *
 * This program 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     *
 * General Public License for more details.                              *
 *                                                                       *
 * You should have received a copy of the GNU General Public License     *
 * along with this program; see the file COPYING.  If not, write to      *
 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,      *
 * Boston, MA 02111-1307, USA.                                           *
 *******************************************************************}}}***/
/* {{{ file description */
/**
 * @file object.c
 * @brief Test libco's object engine. Quite simple, for now.
 **/
/* }}} */

/* {{{ includes */
#include "co_o_default.h"
#include "test_util.h"
#include "co_conv.h"
/* }}} */

/* {{{ */
CO_OBJECT (person, default)
{
    CO_ATTR (int, id);
};
/* }}} */

#include "event.cometa"

/* {{{ */
CO_METH (person, init)
{
    person td;
    td = new (person_s);
    this -> data = td;
    cox_pop (td);
}
/* }}} */

/* {{{ */
CO_METH (person, getid)
{
    CO_METH_INI (person, getid);
    CO_RETURN (int, CO_A (int, self, id));
}
/* }}} */
/* {{{ */
CO_METH (person, default)
{
    CO_METH_INI (person, default);
    CO_DEBUG (1, "called");
    CO_RETURN (int, 0);
}
/* }}} */

/* {{{ */ int main (void)
{
    co tst1, tst2;
    int i;
    co super;
    super = co_init ();
    __co_file_init_event_c (super);

    tst1 = person_new ();
    tst2 = person_new ();

    CO_CNT (tst1, event1, tst2, message1);
    CO_CNT (tst2, event2, tst1, message2);

    M (tst1, event, COE (event1));
    M (tst2, event, COE (event2));

/*#define CHKF \
    if (((co_o_head) tst1) -> msg_proc) \
        error (1, "flag not reset"); \
    if (((co_o_head) tst2) -> msg_proc) \
        error (1, "flag not reset");

    // create new test object
    tst1 = CO_NEW (test_obj1);
    tst2 = CO_NEW (test_obj2);
    if (!tst1) error (1, "test object 1 creation failed\n");
    if (!tst2) error (1, "test object 2 creation failed\n");
    cox_pop (tst2);
    cox_pop (tst1);

    // test return status of CO_M
    if (CO_M (tst1, reload) . _int != 1) error (2, "eh\n");
    CO_M (tst1, draw);

    *//*CO_CNT (tst1, cancel, tst1, save);
    CO_CNT (tst1, ok, tst1, reload);
    for (i = 0; i < 200; i ++) {
        COX_TRY {
            CO_EV (tst1, ok);
            CO_EV (tst1, ok);
            CO_EV (tst1, cancel);
        } COX_CATCH (err) {
            CHKF;
        } COX_CATCH_END;
    }
    CHKF;
    // test program behaviour when handling destruction events
    CO_CNT (tst1, destroyed, tst2, destroy);
    CO_CNT (tst2, ok, tst1, destroy);
    CO_EV (tst2, ok);*/

    //CO_M (tst1, destroy);
    CO_M (super, exit, 0);

    //if (CO_DESTROY (tst1)) (4, "CO_DESTROY failed\n");
    //if (tst1) error (5, "CO_DESTROY did not set tst to NULL\n");
    return 0;
} /* }}} */

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top