~kubuntu-members/korundum/4.11

« back to all changes in this revision

Viewing changes to qtscript/qtscript.cpp

  • Committer: Ian Monroe
  • Date: 2010-11-21 15:55:01 UTC
  • Revision ID: git-v1:c37670e4e3c59f5eb2ba112f5341a5e706217f6f
Split up Smoke into Qt and KDE directories. 
Move libsmoke stuff into the generator directory
Split up Ruby into qtruby and korundum directories

svn path=/trunk/KDE/kdebindings/ruby/; revision=1199320

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
                          qtscript.cpp  -  QtScript ruby extension
3
 
                             -------------------
4
 
    begin                : 11-07-2008
5
 
    copyright            : (C) 2008 by Richard Dale
6
 
    email                : richard.j.dale@gmail.com
7
 
 ***************************************************************************/
8
 
 
9
 
/***************************************************************************
10
 
 *                                                                         *
11
 
 *   This program is free software; you can redistribute it and/or modify  *
12
 
 *   it under the terms of the GNU General Public License as published by  *
13
 
 *   the Free Software Foundation; either version 2 of the License, or     *
14
 
 *   (at your option) any later version.                                   *
15
 
 *                                                                         *
16
 
 ***************************************************************************/
17
 
 
18
 
#include <ruby.h>
19
 
 
20
 
#include <QHash>
21
 
#include <QList>
22
 
#include <QtDebug>
23
 
 
24
 
#include <smoke/qtscript_smoke.h>
25
 
 
26
 
#include <qtruby.h>
27
 
 
28
 
#include <iostream>
29
 
 
30
 
static VALUE getClassList(VALUE /*self*/)
31
 
{
32
 
    VALUE classList = rb_ary_new();
33
 
    for (int i = 1; i <= qtscript_Smoke->numClasses; i++) {
34
 
        if (qtscript_Smoke->classes[i].className && !qtscript_Smoke->classes[i].external)
35
 
            rb_ary_push(classList, rb_str_new2(qtscript_Smoke->classes[i].className));
36
 
    }
37
 
    return classList;
38
 
}
39
 
 
40
 
const char*
41
 
resolve_classname_qtscript(smokeruby_object * o)
42
 
{
43
 
    return qtruby_modules[o->smoke].binding->className(o->classId);
44
 
}
45
 
 
46
 
extern TypeHandler QtScript_handlers[];
47
 
 
48
 
extern "C" {
49
 
 
50
 
VALUE qtscript_module;
51
 
VALUE qtscript_internal_module;
52
 
 
53
 
static QtRuby::Binding binding;
54
 
 
55
 
Q_DECL_EXPORT void
56
 
Init_qtscript()
57
 
{
58
 
    init_qtscript_Smoke();
59
 
 
60
 
    binding = QtRuby::Binding(qtscript_Smoke);
61
 
 
62
 
    smokeList << qtscript_Smoke;
63
 
 
64
 
    QtRubyModule module = { "QtScript", resolve_classname_qtscript, 0, &binding };
65
 
    qtruby_modules[qtscript_Smoke] = module;
66
 
 
67
 
    install_handlers(QtScript_handlers);
68
 
 
69
 
    qtscript_module = rb_define_module("QtScript");
70
 
    qtscript_internal_module = rb_define_module_under(qtscript_module, "Internal");
71
 
 
72
 
    rb_define_singleton_method(qtscript_internal_module, "getClassList", (VALUE (*) (...)) getClassList, 0);
73
 
 
74
 
    rb_require("qtscript/qtscript.rb");
75
 
    rb_funcall(qtscript_internal_module, rb_intern("init_all_classes"), 0);
76
 
}
77
 
 
78
 
}