Beispiel #1
0
static tb_object_dictionary_t* tb_object_dictionary_init_base()
{
    // done
    tb_bool_t                   ok = tb_false;
    tb_object_dictionary_t*     dictionary = tb_null;
    do
    {
        // make dictionary
        dictionary = tb_malloc0_type(tb_object_dictionary_t);
        tb_assert_and_check_break(dictionary);

        // init dictionary
        if (!tb_object_init((tb_object_ref_t)dictionary, TB_OBJECT_FLAG_NONE, TB_OBJECT_TYPE_DICTIONARY)) break;

        // init base
        dictionary->base.copy   = tb_object_dictionary_copy;
        dictionary->base.exit   = tb_object_dictionary_exit;
        dictionary->base.clear  = tb_object_dictionary_clear;
        
        // ok
        ok = tb_true;

    } while (0);

    // failed?
    if (!ok)
    {
        // exit it
        if (dictionary) tb_object_exit((tb_object_ref_t)dictionary);
        dictionary = tb_null;
    }

    // ok?
    return dictionary;
}
Beispiel #2
0
static tb_oc_date_t* tb_oc_date_init_base()
{
    // done
    tb_bool_t       ok = tb_false;
    tb_oc_date_t*   date = tb_null;
    do
    {
        // make date
        date = tb_malloc0_type(tb_oc_date_t);
        tb_assert_and_check_break(date);

        // init date
        if (!tb_object_init((tb_object_ref_t)date, TB_OBJECT_FLAG_NONE, TB_OBJECT_TYPE_DATE)) break;

        // init base
        date->base.copy     = tb_oc_date_copy;
        date->base.exit     = tb_oc_date_exit;
        date->base.clear    = tb_oc_date_clear;
        
        // ok
        ok = tb_true;

    } while (0);

    // failed?
    if (!ok)
    {
        // exit it
        if (date) tb_object_exit((tb_object_ref_t)date);
        date = tb_null;
    }

    // ok?
    return date;
}
Beispiel #3
0
static tb_oc_number_t* tb_oc_number_init_base()
{
    // done
    tb_bool_t       ok = tb_false;
    tb_oc_number_t* number = tb_null;
    do
    {
        // make number
        number = tb_malloc0_type(tb_oc_number_t);
        tb_assert_and_check_break(number);

        // init number
        if (!tb_object_init((tb_object_ref_t)number, TB_OBJECT_FLAG_NONE, TB_OBJECT_TYPE_NUMBER)) break;

        // init base
        number->base.copy   = tb_oc_number_copy;
        number->base.exit   = tb_oc_number_exit;
        number->base.clear  = tb_oc_number_clear;
        
        // ok
        ok = tb_true;

    } while (0);

    // failed?
    if (!ok)
    {
        // exit it
        if (number) tb_object_exit((tb_object_ref_t)number);
        number = tb_null;
    }

    // ok?
    return number;
}