[Kde-bindings] branches/work/kdebindings-smoke2
Arno Rehn
kde at arnorehn.de
Thu Jan 31 14:11:06 UTC 2008
SVN commit 769090 by arnorehn:
* Fixed bug in the smoke code generation.
* Added KDE marshallers and resolve_classname_kde.
* Restructured directory and file layout.
* Korundum is now mostly complete, only minor things are still missing.
CCMAIL: kde-bindings at kde.org
M +7 -0 ChangeLog
M +3 -3 kalyptus/kalyptusCxxToSmoke.pm
M +7 -6 ruby/korundum/CMakeLists.txt
M +3 -7 ruby/korundum/example.rb
A ruby/korundum/kdehandlers.cpp [License: GPL (v2+)]
M +53 -5 ruby/korundum/korundum.cpp
D ruby/korundum/korundum.rb
A ruby/korundum/korundum4.rb
A ruby/korundum/lib (directory)
A ruby/korundum/lib/Korundum.rb
M +6 -0 ruby/qsci/qscintilla.rb
M +22 -10 ruby/qtruby/src/lib/Qt/qtruby4.rb
--- branches/work/kdebindings-smoke2/ChangeLog #769089:769090
@@ -1,3 +1,10 @@
+2008-01-31 Arno Rehn <arno at arnorehn.de>
+
+ * Fixed bug in the smoke code generation.
+ * Added KDE marshallers and resolve_classname_kde.
+ * Restructured directory and file layout.
+ * Korundum is now mostly complete, only minor things are still missing.
+
2008-01-29 Arno Rehn <arno at arnorehn.de>
* Fixed wrong method name being taken in smoke.h
--- branches/work/kdebindings-smoke2/kalyptus/kalyptusCxxToSmoke.pm #769089:769090
@@ -329,9 +329,6 @@
{
my( $classNode ) = @_;
my $className = join( "::", kdocAstUtil::heritage($classNode) );
- # return if the class is not in the current module or an ancestor of a class in the module
- return if (defined($excludeClasses{$className}) && !isAncestorOfModuleClass($className) && $className ne 'QMetaObject'); # && $className ne 'Qt');
- $externClasses{$className} = 1 if defined($excludeClasses{$className});
if ( $classNode->{Deprecated}
|| $classNode->{NodeType} eq 'union'
@@ -430,6 +427,9 @@
delete $classNode->{Compound}; # Cheat, to get it excluded from Iter::LocalCompounds
return;
}
+ # return if the class is not in the current module or an ancestor of a class in the module
+ return if (defined($excludeClasses{$className}) && !isAncestorOfModuleClass($className) && $className ne 'QMetaObject'); # && $className ne 'Qt');
+ $externClasses{$className} = 1 if defined($excludeClasses{$className});
my $signalCount = 0;
my $eventHandlerCount = 0;
--- branches/work/kdebindings-smoke2/ruby/korundum/CMakeLists.txt #769089:769090
@@ -1,9 +1,10 @@
include_directories( ${CMAKE_SOURCE_DIR}/smoke ${RUBY_INCLUDE_PATH} ${CMAKE_SOURCE_DIR}/ruby/qtruby/src)
INCLUDE_DIRECTORIES (${QT_INCLUDES})
-set(kde_LIBRARY_SRC korundum.cpp)
-add_library(kde MODULE ${kde_LIBRARY_SRC})
-target_link_libraries(kde ${QT_QTCORE_LIBRARY} ${RUBY_LIBRARY} smokeqt smokekde qtruby4shared)
-set_target_properties(kde PROPERTIES PREFIX "")
-install(TARGETS kde DESTINATION ${CUSTOM_RUBY_SITE_ARCH_DIR})
-install(FILES korundum.rb DESTINATION ${CUSTOM_RUBY_SITE_LIB_DIR})
+set(korundum4_LIBRARY_SRC korundum.cpp kdehandlers.cpp)
+add_library(korundum4 MODULE ${korundum4_LIBRARY_SRC})
+target_link_libraries(korundum4 ${QT_QTCORE_LIBRARY} ${RUBY_LIBRARY} smokeqt smokekde qtruby4shared)
+set_target_properties(korundum4 PROPERTIES PREFIX "")
+install(TARGETS korundum4 DESTINATION ${CUSTOM_RUBY_SITE_ARCH_DIR})
+install(FILES korundum4.rb DESTINATION ${CUSTOM_RUBY_SITE_LIB_DIR}/KDE)
+install(FILES lib/Korundum.rb DESTINATION ${CUSTOM_RUBY_SITE_LIB_DIR})
--- branches/work/kdebindings-smoke2/ruby/korundum/example.rb #769089:769090
@@ -1,20 +1,16 @@
#/usr/bin/ruby
require 'Qt'
-require 'kde'
+require 'Korundum'
-#a = Qt::ByteArray.new("Foobar")
+aboutData = KDE::AboutData.new("example", "example", "example", "0.1")
-aboutData = KDE::AboutData.new("example", "example", KDE::LocalizedString.new, "0.1")
-
KDE::CmdLineArgs.init(ARGV, aboutData)
app = KDE::Application.new
w = KDE::MainWindow.new
+w.centralWidget = KDE::PushButton.new("Hello World!")
w.show
-systray = KDE::SystemTrayIcon.new("error")
-systray.show
-
app.exec
--- branches/work/kdebindings-smoke2/ruby/korundum/korundum.cpp #769089:769090
@@ -4,6 +4,8 @@
#include <QList>
#include <QtDebug>
+#include <klocalizedstring.h>
+
#include <smoke.h>
#include <kde/kde_smoke.h>
@@ -12,6 +14,8 @@
#include <iostream>
+const char* resolve_classname_kde(Smoke* smoke, int classId, void* ptr);
+
VALUE getClassList(VALUE /*self*/)
{
VALUE classList = rb_ary_new();
@@ -22,19 +26,51 @@
return classList;
}
-const char*
-resolve_classname_kde(Smoke* smoke, int classId, void* /*ptr*/)
+static VALUE
+KI18N(VALUE /*self*/, VALUE rstring)
{
- return smoke->binding->className(classId);
+ KLocalizedString* s = new KLocalizedString(ki18n(StringValuePtr(rstring)));
+ smokeruby_object * result = alloc_smokeruby_object(true, kde_Smoke,
+ kde_Smoke->findClass("KLocalizedString").index, s);
+ return set_obj_info("KDE::LocalizedString", result);
}
+static VALUE
+KI18NC(VALUE /*self*/, VALUE comment, VALUE rstring)
+{
+ KLocalizedString* s = new KLocalizedString(ki18nc(StringValuePtr(comment), StringValuePtr(rstring)));
+ smokeruby_object * result = alloc_smokeruby_object(true, kde_Smoke,
+ kde_Smoke->findClass("KLocalizedString").index, s);
+ return set_obj_info("KDE::LocalizedString", result);
+}
+
+static VALUE
+KI18NP(VALUE /*self*/, VALUE singular, VALUE plural)
+{
+ KLocalizedString* s = new KLocalizedString(ki18np(StringValuePtr(singular), StringValuePtr(plural)));
+ smokeruby_object * result = alloc_smokeruby_object(true, kde_Smoke,
+ kde_Smoke->findClass("KLocalizedString").index, s);
+ return set_obj_info("KDE::LocalizedString", result);
+}
+
+static VALUE
+KI18NCP(VALUE /*self*/, VALUE comment, VALUE singular, VALUE plural)
+{
+ KLocalizedString* s = new KLocalizedString(ki18ncp(StringValuePtr(comment), StringValuePtr(singular), StringValuePtr(plural)));
+ smokeruby_object * result = alloc_smokeruby_object(true, kde_Smoke,
+ kde_Smoke->findClass("KLocalizedString").index, s);
+ return set_obj_info("KDE::LocalizedString", result);
+}
+
+extern TypeHandler KDE_handlers[];
+
extern "C" {
VALUE kde_module;
VALUE kde_internal_module;
void
-Init_kde()
+Init_korundum4()
{
rb_require("Qt"); // need to initialize the core runtime first
init_kde_Smoke();
@@ -46,12 +82,24 @@
QtRubyModule module = { "KDE", resolve_classname_kde };
modules[kde_Smoke] = module;
+ install_handlers(KDE_handlers);
+
kde_module = rb_define_module("KDE");
kde_internal_module = rb_define_module_under(kde_module, "Internal");
rb_define_singleton_method(kde_internal_module, "getClassList", (VALUE (*) (...)) getClassList, 0);
+ rb_define_method(rb_cObject, "KI18N", (VALUE (*) (...)) KI18N, 1);
+ rb_define_method(rb_cObject, "KI18NC", (VALUE (*) (...)) KI18NC, 2);
+ rb_define_method(rb_cObject, "KI18NP", (VALUE (*) (...)) KI18NP, 2);
+ rb_define_method(rb_cObject, "KI18NCP", (VALUE (*) (...)) KI18NCP, 3);
- rb_require("korundum.rb");
+ // to keep 'old' source working; I prefer defining these macro-like functions as part of rb_cObject
+ rb_define_singleton_method(kde_module, "ki18n", (VALUE (*) (...)) KI18N, 1);
+ rb_define_singleton_method(kde_module, "ki18nc", (VALUE (*) (...)) KI18NC, 2);
+ rb_define_singleton_method(kde_module, "ki18np", (VALUE (*) (...)) KI18NP, 2);
+ rb_define_singleton_method(kde_module, "ki18ncp", (VALUE (*) (...)) KI18NCP, 3);
+
+ rb_require("KDE/korundum4.rb");
rb_funcall(kde_internal_module, rb_intern("init_all_classes"), 0);
}
--- branches/work/kdebindings-smoke2/ruby/qsci/qscintilla.rb #769089:769090
@@ -5,6 +5,12 @@
module Qsci
module Internal
def self.init_all_classes
+ Qt::Internal::add_normalize_proc(Proc.new do |classname|
+ if classname =~ /^Qsci/
+ now = classname.sub(/^Qsci?(?=[A-Z])/,'Qsci::')
+ end
+ now
+ end)
getClassList.each do |c|
classname = Qt::Internal::normalize_classname(c)
id = Qt::Internal::findClass(c);
--- branches/work/kdebindings-smoke2/ruby/qtruby/src/lib/Qt/qtruby4.rb #769089:769090
@@ -2092,6 +2092,8 @@
@@cpp_names = {}
@@idclass = []
+ @@normalize_procs = []
+
class ModuleIndex
attr_accessor :index
@@ -2120,19 +2122,29 @@
return @@idclass
end
+ def self.add_normalize_proc(func)
+ @@normalize_procs << func
+ end
+
def Internal.normalize_classname(classname)
- if classname =~ /^Qsci/
- now = classname.sub(/^Qsci(?=[A-Z])/,'Qsci::')
- elsif classname =~ /^Qwt/
- now = classname.sub(/^Qwt(?=[A-Z])/,'Qwt::')
- elsif classname =~ /^Q3/
+ @@normalize_procs.each do |func|
+ ret = func.call(classname)
+ if !ret.nil?
+ return ret
+ end
+ end
+# if classname =~ /^Qsci/
+# now = classname.sub(/^Qsci(?=[A-Z])/,'Qsci::')
+# elsif classname =~ /^Qwt/
+# now = classname.sub(/^Qwt(?=[A-Z])/,'Qwt::')
+ if classname =~ /^Q3/
now = classname.sub(/^Q3(?=[A-Z])/,'Qt3::')
elsif classname =~ /^Q/
now = classname.sub(/^Q(?=[A-Z])/,'Qt::')
- elsif classname =~ /^(KConfigSkeleton|KWin)::/
- now = classname.sub(/^K?(?=[A-Z])/,'KDE::')
- elsif classname !~ /::/
- now = classname.sub(/^K?(?=[A-Z])/,'KDE::')
+# elsif classname =~ /^(KConfigSkeleton|KWin)::/
+# now = classname.sub(/^K?(?=[A-Z])/,'KDE::')
+# elsif classname !~ /::/
+# now = classname.sub(/^K?(?=[A-Z])/,'KDE::')
else
now = classname
end
@@ -2765,7 +2777,7 @@
classid = Qt::Internal::ModuleIndex.new(0, 0)
loop do
classid = Qt::Internal::find_pclassid(klass.name)
- break if classid.index > 0
+ break if classid.index
klass = klass.superclass
if klass.nil?
More information about the Kde-bindings
mailing list