<commit_before>/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
/************************************************

  rbatkstateset.c -

  $Author: mutoh $
  $Date: 2003/12/23 15:59:28 $

  Copyright (C) 2003 <NAME>
************************************************/

#include "rbatk.h"

#define _SELF(s) (ATK_STATE_SET(RVAL2GOBJ(s)))

static VALUE
rbatkstateset_initialize(self)
    VALUE self;
{
    G_INITIALIZE(self, atk_state_set_new());
    return Qnil;
}

static VALUE
rbatkstateset_is_empty(self)
    VALUE self;
{
    return CBOOL2RVAL(atk_state_set_is_empty(_SELF(self)));
}

static VALUE
rbatkstateset_add_state(self, type)
    VALUE self, type;
{
    return CBOOL2RVAL(atk_state_set_add_state(_SELF(self), 
                                              RVAL2GENUM(type, ATK_TYPE_STATE_TYPE)));
}

static VALUE
rbatkstateset_add_states(self, types)
    VALUE self, types;
{
    gint i;
    gint n_types = RARRAY_LEN(types);
    AtkStateType* atypes = g_new(AtkStateType, n_types);

    Check_Type(types, T_ARRAY);

    for (i = 0; i < n_types; i++) {
        atypes[i] = RVAL2GENUM(RARRAY_PTR(types)[i], ATK_TYPE_STATE_TYPE);
    }

    atk_state_set_add_states(_SELF(self), atypes, n_types);
    g_free(atypes);
    return self;
}

static VALUE
rbatkstateset_clear_states(self)
    VALUE self;
{
    atk_state_set_clear_states(_SELF(self));
    return self;
}

static VALUE
rbatkstateset_contains_state(self, type)
    VALUE self, type;
{
    return CBOOL2RVAL(atk_state_set_contains_state(_SELF(self), 
                                                   RVAL2GENUM(type, ATK_TYPE_STATE_TYPE)));
}

static VALUE
rbatkstateset_contains_states(self, types)
    VALUE self, types;
{
    gint i;
    gboolean ret;
    gint n_types = RARRAY_LEN(types);
    AtkStateType* atypes = g_new(AtkStateType, n_types);

    Check_Type(types, T_ARRAY);

    for (i = 0; i < n_types; i++) {
        atypes[i] = RVAL2GENUM(RARRAY_PTR(types)[i], ATK_TYPE_STATE_TYPE);
    }
    
    ret = CBOOL2RVAL(atk_state_set_contains_states(_SELF(self), atypes, n_types));

    g_free(atypes);
    return ret;
}

static VALUE
rbatkstateset_remove_state(self, type)
    VALUE self, type;
{
    return CBOOL2RVAL(atk_state_set_remove_state(_SELF(self), 
                                                 RVAL2GENUM(type, ATK_TYPE_STATE_TYPE)));
}

static VALUE
rbatkstateset_and_sets(self, compare_set)
    VALUE self, compare_set;
{
    return GOBJ2RVAL(atk_state_set_and_sets(_SELF(self), _SELF(compare_set)));
}

static VALUE
rbatkstateset_or_sets(self, compare_set)
    VALUE self, compare_set;
{
    return GOBJ2RVAL(atk_state_set_or_sets(_SELF(self), _SELF(compare_set)));
}

static VALUE
rbatkstateset_xor_sets(self, compare_set)
    VALUE self, compare_set;
{
    return GOBJ2RVAL(atk_state_set_xor_sets(_SELF(self), _SELF(compare_set)));
}

void
Init_atk_state_set()
{
    VALUE stateset = G_DEF_CLASS(ATK_TYPE_STATE_SET, "StateSet", mAtk);

    rb_define_method(stateset, "initialize", rbatkstateset_initialize, 0);<commit_msg>* change to ANSI C style.<commit_after>/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
/************************************************

  rbatkstateset.c -

  $Author: mutoh $
  $Date: 2003/12/23 15:59:28 $

  Copyright (C) 2003 <NAME>
************************************************/

#include "rbatk.h"

#define _SELF(s) (ATK_STATE_SET(RVAL2GOBJ(s)))

static VALUE
rbatkstateset_initialize(VALUE self)
{
    G_INITIALIZE(self, atk_state_set_new());
    return Qnil;
}

static VALUE
rbatkstateset_is_empty(VALUE self)
{
    return CBOOL2RVAL(atk_state_set_is_empty(_SELF(self)));
}

static VALUE
rbatkstateset_add_state(VALUE self, VALUE type)
{
    return CBOOL2RVAL(atk_state_set_add_state(_SELF(self), 
                                              RVAL2GENUM(type, ATK_TYPE_STATE_TYPE)));
}

static VALUE
rbatkstateset_add_states(VALUE self, VALUE types)
{
    gint i;
    gint n_types = RARRAY_LEN(types);
    AtkStateType* atypes = g_new(AtkStateType, n_types);

    Check_Type(types, T_ARRAY);

    for (i = 0; i < n_types; i++) {
        atypes[i] = RVAL2GENUM(RARRAY_PTR(types)[i], ATK_TYPE_STATE_TYPE);
    }

    atk_state_set_add_states(_SELF(self), atypes, n_types);
    g_free(atypes);
    return self;
}

static VALUE
rbatkstateset_clear_states(VALUE self)
{
    atk_state_set_clear_states(_SELF(self));
    return self;
}

static VALUE
rbatkstateset_contains_state(VALUE self, VALUE type)
{
    return CBOOL2RVAL(atk_state_set_contains_state(_SELF(self), 
                                                   RVAL2GENUM(type, ATK_TYPE_STATE_TYPE)));
}

static VALUE
rbatkstateset_contains_states(VALUE self, VALUE types)
{
    gint i;
    gboolean ret;
    gint n_types = RARRAY_LEN(types);
    AtkStateType* atypes = g_new(AtkStateType, n_types);

    Check_Type(types, T_ARRAY);

    for (i = 0; i < n_types; i++) {
        atypes[i] = RVAL2GENUM(RARRAY_PTR(types)[i], ATK_TYPE_STATE_TYPE);
    }
    
    ret = CBOOL2RVAL(atk_state_set_contains_states(_SELF(self), atypes, n_types));

    g_free(atypes);
    return ret;
}

static VALUE
rbatkstateset_remove_state(VALUE self, VALUE type)
{
    return CBOOL2RVAL(atk_state_set_remove_state(_SELF(self), 
                                                 RVAL2GENUM(type, ATK_TYPE_STATE_TYPE)));
}

static VALUE
rbatkstateset_and_sets(VALUE self, VALUE compare_set)
{
    return GOBJ2RVAL(atk_state_set_and_sets(_SELF(self), _SELF(compare_set)));
}

static VALUE
rbatkstateset_or_sets(VALUE self, VALUE compare_set)
{
    return GOBJ2RVAL(atk_state_set_or_sets(_SELF(self), _SELF(compare_set)));
}

static VALUE
rbatkstateset_xor_sets(VALUE self, VALUE compare_set)
{
    return GOBJ2RVAL(atk_state_set_xor_sets(_SELF(self), _SELF(compare_set)));
}

void
Init_atk_state_set()
{
    VALUE stateset = G_DEF_CLASS(ATK_TYPE_STATE_SET, "StateSet", mAtk);

    rb_define_method(stateset, "initialize", rbatkstateset_initialize, 0);
{'fraction_non_alphanumeric': 0.13885608233507676, 'fraction_numerical': 0.011810359372363759, 'mean_word_length': 3.94, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '744957', 'n_tokens_mistral': 2320, 'n_tokens_neox': 2234, 'n_words': 367}