Author: kkaempf Date: Fri Apr 11 11:09:46 2008 New Revision: 46388 URL: http://svn.opensuse.org/viewcvs/yast?rev=46388&view=rev Log: Initial SWIG bindings for libyui Added: trunk/libyui-bindings/ trunk/libyui-bindings/CMakeLists.txt trunk/libyui-bindings/README trunk/libyui-bindings/VERSION.cmake trunk/libyui-bindings/libyui-bindings.spec.cmake trunk/libyui-bindings/package/ trunk/libyui-bindings/package/libyui-bindings.changes trunk/libyui-bindings/swig/ trunk/libyui-bindings/swig/CMakeLists.txt trunk/libyui-bindings/swig/ruby/ trunk/libyui-bindings/swig/ruby/CMakeLists.txt trunk/libyui-bindings/swig/ruby/examples/ trunk/libyui-bindings/swig/ruby/examples/hello_world.rb trunk/libyui-bindings/swig/ruby/examples/loading.rb trunk/libyui-bindings/swig/yui.i Added: trunk/libyui-bindings/CMakeLists.txt URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui-bindings/CMakeLists.txt?rev=46388&view=auto ============================================================================== --- trunk/libyui-bindings/CMakeLists.txt (added) +++ trunk/libyui-bindings/CMakeLists.txt Fri Apr 11 11:09:46 2008 @@ -0,0 +1,76 @@ + +# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked +SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH}) +SET(CMAKE_MODULE_PATH ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules ${CMAKE_MODULE_PATH}) + +INCLUDE(${CMAKE_SOURCE_DIR}/VERSION.cmake) + +SET( PACKAGE "libyui-bindings" ) +SET( VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" ) + +SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Language Bindings for libyui") +SET(CPACK_PACKAGE_VENDOR "Novell Inc.") +#SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/ReadMe.txt") +#SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt") +SET(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR}) +SET(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR}) +SET(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH}) + +SET( CPACK_GENERATOR "TBZ2") +SET( CPACK_SOURCE_GENERATOR "TBZ2") +SET( CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE}-${VERSION}" ) + +# The following components are regex's to match anywhere (unless anchored) +# in absolute path + filename to find files or directories to be excluded +# from source tarball. +SET (CPACK_SOURCE_IGNORE_FILES +"/CVS/;/.svn/;/.libs/;/.deps/;.swp$;.#;/#;/build/" +"~$" +"\\\\.cvsignore$" +"/package" +"Makefile\\\\.in$" +) + +INCLUDE(CPack) + +#FIND_PACKAGE(SWIG REQUIRED) +MESSAGE(STATUS "Looking modules in ${CMAKE_MODULE_PATH}") +FIND_PROGRAM(SWIG_EXECUTABLE + NAMES swig-1.3 swig + PATHS ${SWIG_DIR} ${SWIG_DIR}/.. ${SWIG_DIR}/../../bin /usr/bin /usr/local/bin ${CMAKE_INSTALL_PREFIX}/bin +) + +IF ( NOT SWIG_EXECUTABLE ) + MESSAGE( FATAL "SWIG not found." ) +ELSE ( NOT SWIG_EXECUTABLE ) + MESSAGE( STATUS "SWIG found at ${SWIG_EXECUTABLE}" ) +ENDIF ( NOT SWIG_EXECUTABLE ) + +INCLUDE(FindLibyui) +#FIND_PACKAGE(libyui REQUIRED) + +ADD_SUBDIRECTORY(swig) + +ADD_CUSTOM_TARGET( svncheck + COMMAND cd $(CMAKE_SOURCE_DIR) && ! LC_ALL=C svn status --show-updates + --quiet | grep -v '^Status against revision' +) + +SET( SRCPACKAGE_COMMAND + COMMAND ${CMAKE_MAKE_PROGRAM} package_source + COMMAND ${CMAKE_COMMAND} -E copy ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2 ${CMAKE_BINARY_DIR}/package/ + COMMAND ${CMAKE_COMMAND} -E remove ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2 + COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/package/${PACKAGE}.changes" "${CMAKE_BINARY_DIR}/package/${PACKAGE}.changes" +) + +ADD_CUSTOM_TARGET( srcpackage_local + ${SRCPACKAGE_COMMAND} +) + +ADD_CUSTOM_TARGET( srcpackage + COMMAND ${CMAKE_MAKE_PROGRAM} svncheck + ${SRCPACKAGE_COMMAND} +) + +MESSAGE(STATUS "Writing spec file...") +CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/libyui-bindings.spec.cmake ${CMAKE_BINARY_DIR}/package/libyui-bindings.spec @ONLY) Added: trunk/libyui-bindings/README URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui-bindings/README?rev=46388&view=auto ============================================================================== --- trunk/libyui-bindings/README (added) +++ trunk/libyui-bindings/README Fri Apr 11 11:09:46 2008 @@ -0,0 +1,15 @@ + +Attempt to create generated bindings for +libyui. Not restricted to one language. + +Authors: kkaempf@suse.de + +Ruby Notes +========== + +* API tries to follow ruby standards: +* Containers do not implement iterators but: + * each + * to_a + * etc +* lower_case_methods instead of camelCaseMethods \ No newline at end of file Added: trunk/libyui-bindings/VERSION.cmake URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui-bindings/VERSION.cmake?rev=46388&view=auto ============================================================================== --- trunk/libyui-bindings/VERSION.cmake (added) +++ trunk/libyui-bindings/VERSION.cmake Fri Apr 11 11:09:46 2008 @@ -0,0 +1,3 @@ +SET(VERSION_MAJOR "0") +SET(VERSION_MINOR "1") +SET(VERSION_PATCH "0") Added: trunk/libyui-bindings/libyui-bindings.spec.cmake URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui-bindings/libyui-bindings.spec.cmake?rev=46388&view=auto ============================================================================== --- trunk/libyui-bindings/libyui-bindings.spec.cmake (added) +++ trunk/libyui-bindings/libyui-bindings.spec.cmake Fri Apr 11 11:09:46 2008 @@ -0,0 +1,84 @@ +# +# spec file for package libyui-bindings +# +# Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# + +# nodebuginfo + +Name: @PACKAGE@ +Version: @VERSION@ +Release: 0 +License: GPL +Summary: Bindings for libyui +Group: Development/Sources +BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildRequires: cmake gcc-c++ python-devel ruby-devel swig +BuildRequires: libyui-devel >= 3.0.0 +Source: %{name}-%{version}.tar.bz2 + +%description +- + +%prep +%setup -q + +%build +mkdir build +cd build +cmake -DCMAKE_INSTALL_PREFIX=%{prefix} \ + -DLIB=%{_lib} \ + -DCMAKE_VERBOSE_MAKEFILE=TRUE \ + -DCMAKE_C_FLAGS_RELEASE:STRING="%{optflags}" \ + -DCMAKE_CXX_FLAGS_RELEASE:STRING="%{optflags}" \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_SKIP_RPATH=1 \ + .. +make %{?jobs:-j %jobs} + +%install +cd build +make install DESTDIR=$RPM_BUILD_ROOT + +%clean +%{__rm} -rf %{buildroot} + +%package -n ruby-yui +Summary: Ruby bindings for libyui +Group: Development/Languages/Ruby + +%description -n ruby-yui +- + +%files -n ruby-yui +%defattr(-,root,root,-) +%{_libdir}/ruby/vendor_ruby/%{rb_ver}/%{rb_arch}/yui.so + +#%package -n python-yui +#Summary: Python bindings for libyui +#Group: Development/Languages/Python +#%description -n python-yui +#- +# +#%files -n python-yui +#%defattr(-,root,root,-) +#%{_libdir}/python2.5/site-packages/_yui.so +#%{_libdir}/python2.5/site-packages/yui.py + +#%package -n perl-yui +#Summary: Perl bindings for libyui +#Group: Development/Languages/Perl +# +#%description -n perl-yui +#- +# +#%files -n perl-yui +#%defattr(-,root,root,-) +#/usr/lib/perl5/*/*/yui.pm +#/usr/lib/perl5/*/*/yui.so + +%changelog Added: trunk/libyui-bindings/package/libyui-bindings.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui-bindings/package/libyui-bindings.changes?rev=46388&view=auto ============================================================================== --- trunk/libyui-bindings/package/libyui-bindings.changes (added) +++ trunk/libyui-bindings/package/libyui-bindings.changes Fri Apr 11 11:09:46 2008 @@ -0,0 +1,4 @@ +------------------------------------------------------------------- +Fri Apr 11 11:04:54 CEST 2008 - kkaempf@suse.de + +- Initial version, just enough for 'Hello, world!' Added: trunk/libyui-bindings/swig/CMakeLists.txt URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui-bindings/swig/CMakeLists.txt?rev=46388&view=auto ============================================================================== --- trunk/libyui-bindings/swig/CMakeLists.txt (added) +++ trunk/libyui-bindings/swig/CMakeLists.txt Fri Apr 11 11:09:46 2008 @@ -0,0 +1,7 @@ + +ADD_SUBDIRECTORY(ruby) + +#ADD_SUBDIRECTORY(python) + +#ADD_SUBDIRECTORY(perl5) + Added: trunk/libyui-bindings/swig/ruby/CMakeLists.txt URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui-bindings/swig/ruby/CMakeLists.txt?rev=46388&view=auto ============================================================================== --- trunk/libyui-bindings/swig/ruby/CMakeLists.txt (added) +++ trunk/libyui-bindings/swig/ruby/CMakeLists.txt Fri Apr 11 11:09:46 2008 @@ -0,0 +1,38 @@ + +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing") + +FIND_PACKAGE(Ruby REQUIRED) + +EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['vendorarchdir']" OUTPUT_VARIABLE RUBY_VENDOR_ARCH_DIR) + +MESSAGE(STATUS "Ruby executable: ${RUBY_EXECUTABLE}") +MESSAGE(STATUS "Ruby vendor arch dir: ${RUBY_VENDOR_ARCH_DIR}") +MESSAGE(STATUS "Ruby include path: ${RUBY_INCLUDE_PATH}") + +SET( SWIG_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/yui_wrap.cxx" ) +SET( SWIG_INPUT "${CMAKE_CURRENT_SOURCE_DIR}/../yui.i" ) + +ADD_CUSTOM_COMMAND ( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/yui_wrap.cxx + COMMAND ${CMAKE_COMMAND} -E echo_append "Creating wrapper code for ruby..." + COMMAND ${SWIG_EXECUTABLE} -c++ -ruby -autorename -xmlout ${CMAKE_CURRENT_BINARY_DIR}/parse.xml -o ${SWIG_OUTPUT} -I${LIBYUI_INCLUDE_DIR} ${SWIG_INPUT} + COMMAND ${CMAKE_COMMAND} -E echo "Done." + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../*.i +) + +ADD_CUSTOM_TARGET( glue + DEPENDS ${SWIG_OUTPUT} +) + +ADD_LIBRARY( yui SHARED ${SWIG_OUTPUT} ) +SET_TARGET_PROPERTIES( yui PROPERTIES PREFIX "" ) +ADD_DEPENDENCIES( yui glue ) + +INCLUDE_DIRECTORIES( ${RUBY_INCLUDE_PATH} ) +INCLUDE_DIRECTORIES( ${LIBYUI_INCLUDE_DIR} ) +TARGET_LINK_LIBRARIES( yui ${LIBYUI_LIBRARY} ) +TARGET_LINK_LIBRARIES( yui ${RUBY_LIBRARY} ) + +INSTALL(TARGETS yui LIBRARY DESTINATION ${RUBY_VENDOR_ARCH_DIR}) + Added: trunk/libyui-bindings/swig/ruby/examples/hello_world.rb URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui-bindings/swig/ruby/examples/hello_world.rb?rev=46388&view=auto ============================================================================== --- trunk/libyui-bindings/swig/ruby/examples/hello_world.rb (added) +++ trunk/libyui-bindings/swig/ruby/examples/hello_world.rb Fri Apr 11 11:09:46 2008 @@ -0,0 +1,19 @@ +# +# Trivial libyui example +# + +$:.unshift "../../../build/swig/ruby" + +require 'test/unit' + +class LoadTest < Test::Unit::TestCase + def test_hello_world + require 'yui' + dialog = Yui::YUI::widget_factory.create_popup_dialog + vbox = Yui::YUI::widget_factory.create_vbox dialog + Yui::YUI::widget_factory.create_label vbox, "Hello, World!" + Yui::YUI::widget_factory.create_push_button vbox, "&OK" + event = dialog.wait_for_event + dialog.destroy + end +end Added: trunk/libyui-bindings/swig/ruby/examples/loading.rb URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui-bindings/swig/ruby/examples/loading.rb?rev=46388&view=auto ============================================================================== --- trunk/libyui-bindings/swig/ruby/examples/loading.rb (added) +++ trunk/libyui-bindings/swig/ruby/examples/loading.rb Fri Apr 11 11:09:46 2008 @@ -0,0 +1,15 @@ +# +# Test loading of the bindings +# + +$:.unshift "../../../build/swig/ruby" + +# test loading of extension +require 'test/unit' + +class LoadTest < Test::Unit::TestCase + def test_loading + require 'yui' + assert true + end +end Added: trunk/libyui-bindings/swig/yui.i URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui-bindings/swig/yui.i?rev=46388&view=auto ============================================================================== --- trunk/libyui-bindings/swig/yui.i (added) +++ trunk/libyui-bindings/swig/yui.i Fri Apr 11 11:09:46 2008 @@ -0,0 +1,79 @@ +%module yui + +#ifdef SWIGPERL5 +%{ + #undef NORMAL + #undef readdir + #undef Fflush + #undef Mkdir + #undef strerror +%} +#endif + +%{ +/* Includes the header in the wrapper code */ +#include <sstream> +#include <stdexcept> +#include "YaST2/yui/YUI.h" +#include "YaST2/yui/YWidgetFactory.h" +#include "YaST2/yui/YDialog.h" +#include "YaST2/yui/YLayoutBox.h" +#include "YaST2/yui/YEvent.h" + +using namespace std; + +void * +start_ui_thread( void *ui_int ) +{ + return NULL; +} + +%} + +%define DEFINE_PTR_TYPE(name) +%enddef + +%rename("+") "operator+"; +%rename("<<") "operator<<"; +%rename("!=") "operator!="; +%rename("!") "operator!"; +%rename("==") "operator=="; + + +template < typename T > +class intrusive_ptr { + public: + T *operator->(); +}; + + +%include "std_string.i" +%include "std_list.i" +%include "std_set.i" +%include "stl.i" + + +# %include "YApplication.i" +# %include "YWidget.i" +# %include "YWidgetFactory.i" +# %include "YOptionalWidgetFactory.i" +# %include "YEvent.i" +# %include "YBuiltinCaller.i" +# %include "YDialog.i" +# %include "YMacroPlayer.i" +# %include "YMacroRecorder.i" + +#ifdef SWIGPYTHON +%include "python/callbacks.i" +#endif + +class Exception; +%include YUI.h +%ignore YUI::start_ui_thread; + +%include YWidgetFactory.h +%include YWidget.h +%include YSingleChildContainerWidget.h +%include YDialog.h +%include YLayoutBox.h +%include YEvent.h -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org