<commit_before>/***************************************************************************
                          solidhandlers.cpp  -  Solid specific marshallers
                             -------------------
    begin                : 08-06-2008
    copyright            : (C) 2008 by <NAME>
    email                : <EMAIL>
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#include <ruby.h>

#include <qtruby.h>
#include <smokeruby.h>
#include <marshall_macros.h>

#include <solid/device.h>

DEF_VALUELIST_MARSHALLER( SolidDeviceList, QList<Solid::Device>, Solid::Device )

TypeHandler Solid_handlers[] = {
    { "QList<Solid::Device>", marshall_SolidDeviceList },
    { 0, 0 }<commit_msg>* Instead of passing Solid::DeviceInterface::Type enums by value, the Solid api   passes them as const references. So they need special casing. Thanks to David   Palacio for pointing out the problem<commit_after>/***************************************************************************
                          solidhandlers.cpp  -  Solid specific marshallers
                             -------------------
    begin                : 08-06-2008
    copyright            : (C) 2008 by <NAME>
    email                : <EMAIL>
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#include <ruby.h>

#include <qtruby.h>
#include <smokeruby.h>
#include <marshall_macros.h>

#include <solid/device.h>

void marshall_SolidDeviceInterfaceType(Marshall *m) {
    switch(m->action()) {

    case Marshall::FromVALUE:
    {
        VALUE v = *(m->var());

        if (v == Qnil) {
            m->item().s_voidp = 0;
        } else if (TYPE(v) == T_OBJECT) {
            // Both Qt::Enum and Qt::Integer have a value() method, so 'get_qinteger()' can be called ok
            VALUE temp = rb_funcall(qt_internal_module, rb_intern("get_qinteger"), 1, v);
            m->item().s_voidp = new long((long) NUM2LONG(temp));
        } else {
            m->item().s_voidp = new long(NUM2LONG(v));
        }

        m->next();
        if (m->item().s_voidp != 0) {
            delete (long*) m->item().s_voidp;
        }
    }
    break;

    case Marshall::ToVALUE:
    {
        void * ptr = m->item().s_voidp;
        if (ptr == 0) {
            *(m->var()) = Qnil;
        } else {
            *(m->var()) = rb_funcall(qt_internal_module, rb_intern("create_qenum"),
                             2, LONG2NUM(*((long *) ptr)), rb_str_new2(m->type().name()) );
        }
    }
    break;

    default:
        m->unsupported();
        break;
    }
}

DEF_VALUELIST_MARSHALLER( SolidDeviceList, QList<Solid::Device>, Solid::Device )

TypeHandler Solid_handlers[] = {
    { "QList<Solid::Device>", marshall_SolidDeviceList },
    { "Solid::DeviceInterface::Type", marshall_SolidDeviceInterfaceType },
    { "Solid::DeviceInterface::Type&", marshall_SolidDeviceInterfaceType },

    { 0, 0 }
{'fraction_non_alphanumeric': 0.2490412272291467, 'fraction_numerical': 0.009348034515819751, 'mean_word_length': 1.9935437589670015, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4404793', 'n_tokens_mistral': 1109, 'n_tokens_neox': 1005, 'n_words': 259}