Beispiel #1
0
int _pSLang_init_sllist (void)
{
   SLang_Class_Type *cl;

   if (SLclass_is_class_defined (SLANG_LIST_TYPE))
     return 0;

   if (NULL == (cl = SLclass_allocate_class ("List_Type")))
     return -1;

   (void) SLclass_set_destroy_function (cl, cl_list_destroy);
   (void) SLclass_set_push_function (cl, cl_list_push);
   (void) SLclass_set_aput_function (cl, _pSLlist_aput);
   (void) SLclass_set_aget_function (cl, _pSLlist_aget);
   (void) SLclass_set_deref_function (cl, cl_list_dereference);
   (void) SLclass_set_string_function (cl, string_method);
   (void) SLclass_set_eqs_function (cl, eqs_method);
   (void) SLclass_set_is_container (cl, 1);

   cl->cl_length = list_length;

   cl->cl_foreach_open = cl_foreach_open;
   cl->cl_foreach_close = cl_foreach_close;
   cl->cl_foreach = cl_foreach;

   if (-1 == SLclass_register_class (cl, SLANG_LIST_TYPE, sizeof (SLang_List_Type), SLANG_CLASS_TYPE_PTR))
     return -1;

   if (-1 == SLadd_intrin_fun_table (Intrin_Table, NULL))
     return -1;

   return 0;
}
static int register_termios_type (void)
{
    SLang_Class_Type *cl;

    if (Termios_Type_Id != 0)
        return 0;

    if (NULL == (cl = SLclass_allocate_class ("Termios_Type")))
        return -1;

    if (-1 == SLclass_set_destroy_function (cl, destroy_termios))
        return -1;

    if (-1 == SLclass_set_deref_function (cl, termios_dereference))
        return -1;

    /* By registering as SLANG_VOID_TYPE, slang will dynamically allocate a
     * type.
     */
    if (-1 == SLclass_register_class (cl, SLANG_VOID_TYPE, sizeof (struct termios), SLANG_CLASS_TYPE_MMT))
        return -1;

    Termios_Type_Id = SLclass_get_class_id (cl);
    if (-1 == SLclass_patch_intrin_fun_table1 (Termios_Intrinsics, DUMMY_TERMIOS_TYPE, Termios_Type_Id))
        return -1;

    return 0;
}