diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e7c708..a7ffbd5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,41 @@ -include(icecc.cmake) # this must be the first line! +include(cmake/Macros/icecc.cmake) # this must be the first line! project(pysidebindings) cmake_minimum_required(VERSION 2.6) +set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Macros/ + ${CMAKE_MODULE_PATH}) +find_package(Shiboken 1.1.1 REQUIRED) +find_package(Qt4 4.5.0 REQUIRED) +find_file(GL_H "gl.h" PATH_SUFFIXES "GL") +include(FindQt4Extra) -if(CMAKE_HOST_UNIX) - option(ENABLE_GCC_OPTIMIZATION "Enable specific GCC flags to optimization library size and performance. Only available on Release Mode" 0) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fvisibility=hidden -Wno-strict-aliasing") +set(XVFB_EXEC "") +option(USE_XVFB "Uses xvfb-run with the unit tests to avoid QtGui tests popping windows on the screen." FALSE) +if(USE_XVFB) + find_program(XVFB_RUN NAMES xvfb-run) + if (NOT ${XVFB_RUN} MATCHES "XVFB_RUN-NOTFOUND") + set(XVFB_EXEC ${XVFB_RUN} -a) + message(STATUS "Using xvfb-run to perform QtGui tests.") + endif() +endif() + +option(BUILD_TESTS "Build tests." TRUE) +option(ENABLE_VERSION_SUFFIX "Used to use current version in suffix to generated files. This is used to allow multiples versions installed simultaneous." FALSE) +set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" ) +set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is /lib${LIB_SUFFIX})" FORCE) +if(CMAKE_HOST_APPLE) + set(ALTERNATIVE_QT_INCLUDE_DIR "" CACHE PATH "The Alternative value to QT_INCLUDE_DIR. Necessary to fix bug on cmake 2.8 MACOS users") +endif() + +if(MSVC) + set(CMAKE_CXX_FLAGS "/Zc:wchar_t- /GR /EHsc /DNOCOLOR /DWIN32 /D_WINDOWS /D_SCL_SECURE_NO_WARNINGS") +else() + if(CMAKE_HOST_UNIX AND NOT CYGWIN) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fvisibility=hidden -Wno-strict-aliasing") + endif() set(CMAKE_CXX_FLAGS_DEBUG "-g") + option(ENABLE_GCC_OPTIMIZATION "Enable specific GCC flags to optimization library size and performance. Only available on Release Mode" 0) if(ENABLE_GCC_OPTIMIZATION) set(CMAKE_BUILD_TYPE Release) set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -Os -Wl,-O1") @@ -19,36 +47,35 @@ if(CMAKE_HOST_UNIX) if(CMAKE_HOST_APPLE) if (NOT QT_INCLUDE_DIR) set(QT_INCLUDE_DIR "/Library/Frameworks") - endif() + endif() + if(ALTERNATIVE_QT_INCLUDE_DIR) + set(QT_INCLUDE_DIR ${ALTERNATIVE_QT_INCLUDE_DIR}) + endif() + string(REPLACE " " ":" QT_INCLUDE_DIR ${QT_INCLUDE_DIR}) endif() endif() if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release) + set(CMAKE_BUILD_TYPE ${SHIBOKEN_BUILD_TYPE}) endif() -option(AVOID_PROTECTED_HACK "Avoid protected hack on generated bindings." FALSE) -if(AVOID_PROTECTED_HACK OR WIN32) - add_definitions(-DAVOID_PROTECTED_HACK) - message(STATUS "Avoiding protected hack!") -endif() - -find_package(PythonLibs REQUIRED) -find_package(PythonInterp REQUIRED) -find_package(Shiboken REQUIRED) -find_package(Qt4 4.5.0 REQUIRED) - set(BINDING_NAME PySide) -set(BINDING_API_MAJOR_VERSION "0") -set(BINDING_API_MINOR_VERSION "3") -set(BINDING_API_MICRO_VERSION "2") -set(BINDING_API_VERSION "${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}.${BINDING_API_MICRO_VERSION}") - -set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" ) -set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is /lib${LIB_SUFFIX})" FORCE) - -if (NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release) +set(BINDING_API_MAJOR_VERSION "1") +set(BINDING_API_MINOR_VERSION "1") +set(BINDING_API_MICRO_VERSION "1") +set(BINDING_API_RELEASE_LEVEL "final") # alpha, beta, rc, or final +set(BINDING_API_SERIAL 1) # leave as 0 when release level is final +set(BINDING_API_VERSION "${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}.${BINDING_API_MICRO_VERSION}" CACHE STRING "PySide version" FORCE) +if (BINDING_API_RELEASE_LEVEL STREQUAL "final") + set(BINDING_API_VERSION_FULL "${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}.${BINDING_API_MICRO_VERSION}" + CACHE STRING "PySide version [full]" FORCE) +else() + set(BINDING_API_VERSION_FULL "${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}.${BINDING_API_MICRO_VERSION}~${BINDING_API_RELEASE_LEVEL}${BINDING_API_SERIAL}" + CACHE STRING "PySide version [full]" FORCE) +endif() +set(PYSIDE_QT_VERSION "${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}" CACHE STRING "Qt version used to compile PySide" FORCE) +if(ENABLE_VERSION_SUFFIX) + set(pyside_SUFFIX "-${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}") endif() include(${QT_USE_FILE}) @@ -57,43 +84,41 @@ if (${QTVERSION} VERSION_LESS 4.5.0) endif() # Configure OS support +set(ENABLE_X11 "0") +set(ENABLE_MAC "0") +set(ENABLE_WIN "0") +set(ENABLE_SIMULATOR "0") if(Q_WS_X11) set(ENABLE_X11 "1") - set(ENABLE_MAC "0") - set(ENABLE_WIN "0") if(Q_WS_MAEMO_5) - set(AUTO_OS "MAEMO 5") + set(AUTO_OS "maemo") else() - set(AUTO_OS "X11") + set(AUTO_OS "x11") endif() elseif(Q_WS_MAC) - set(ENABLE_X11 "0") set(ENABLE_MAC "1") - set(ENABLE_WIN "0") - set(AUTO_OS "MAC") + set(AUTO_OS "mac") elseif(Q_WS_WIN) - set(ENABLE_X11 "0") - set(ENABLE_MAC "0") set(ENABLE_WIN "1") - set(AUTO_OS "WIN") + set(AUTO_OS "win") +elseif(Q_WS_SIMULATOR) + set(ENABLE_SIMULATOR "1") + set(AUTO_OS "simulator") else() message(FATAL_ERROR "OS not supported") endif() message(STATUS "Detected OS: ${AUTO_OS}") -# Define supported Qt Version -if(${QT_VERSION_MAJOR} EQUAL 4 AND ${QT_VERSION_MINOR} GREATER 6) - set(SUPPORTED_QT_VERSION 4.7) +if (WIN32) + set(PATH_SEP "\;") else() - set(SUPPORTED_QT_VERSION 4.6) + set(PATH_SEP ":") endif() +# Define supported Qt Version +set(SUPPORTED_QT_VERSION "${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}") + set(BINDING_VERSION ${BINDING_API_VERSION}.${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}) -find_program(GENERATOR generatorrunner REQUIRED) - -if (NOT GENERATOR) - message(FATAL_ERROR "You need to specify GENERATOR variable (-DGENERATOR=value)") -endif() # uninstall target configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake" @@ -103,7 +128,7 @@ add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") -set(ARCHIVE_NAME pyside-qt${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}+${BINDING_API_VERSION}) +set(ARCHIVE_NAME pyside-qt${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}+${BINDING_API_VERSION_FULL}) add_custom_target(dist COMMAND mkdir -p "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}" && git log > "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}/ChangeLog" && @@ -113,21 +138,42 @@ add_custom_target(dist echo "Source package created at ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2.\n" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) -execute_process( - COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; \\ - print sysconfig.get_python_lib(1,0,prefix='${CMAKE_INSTALL_PREFIX}')" - OUTPUT_VARIABLE SITE_PACKAGE - OUTPUT_STRIP_TRAILING_WHITESPACE) if (NOT SITE_PACKAGE) - message(FATAL_ERROR "Could not detect Python module installation directory.") + execute_process( + COMMAND ${SHIBOKEN_PYTHON_INTERPRETER} -c "from distutils import sysconfig; \\ + print(sysconfig.get_python_lib(1,0,prefix='${CMAKE_INSTALL_PREFIX}'))" + OUTPUT_VARIABLE SITE_PACKAGE + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (NOT SITE_PACKAGE) + message(FATAL_ERROR "Could not detect Python module installation directory.") + elseif (APPLE) + message(STATUS "!!! The generated bindings will be installed on ${SITE_PACKAGE}, is it right!?") + endif() endif() -set(GENERATOR_EXTRA_FLAGS --generatorSet=shiboken --enable-parent-ctor-heuristic --enable-pyside-extensions --enable-return-value-heuristic) - -enable_testing() +set(GENERATOR_EXTRA_FLAGS --generator-set=shiboken --enable-parent-ctor-heuristic --enable-pyside-extensions --enable-return-value-heuristic --use-isnull-as-nb_nonzero) +if(WIN32 OR DEFINED AVOID_PROTECTED_HACK) + message(STATUS "PySide will be generated avoiding the protected hack!") + set(GENERATOR_EXTRA_FLAGS ${GENERATOR_EXTRA_FLAGS} --avoid-protected-hack) + add_definitions(-DAVOID_PROTECTED_HACK) +else() + message(STATUS "PySide will be generated using the protected hack!") +endif() add_subdirectory(libpyside) +if(QT_QTUITOOLS_FOUND AND QT_QTDESIGNER_FOUND) + add_subdirectory(plugins) +endif() # project directories -add_subdirectory(${BINDING_NAME}) -add_subdirectory(tests) -add_subdirectory(doc) +add_subdirectory(PySide) +if (BUILD_TESTS) + enable_testing() + add_subdirectory(tests) +endif () + +find_program(DOT_EXEC dot) +if (QT_SRC_DIR AND DOT_EXEC) + add_subdirectory(doc) +else () + message(STATUS "QT_SRC_DIR variable not set or graphviz not found, apidoc generation targets disabled.") +endif() diff --git a/PySide/CMakeLists.txt b/PySide/CMakeLists.txt index 3162cbb..d8371c0 100644 --- a/PySide/CMakeLists.txt +++ b/PySide/CMakeLists.txt @@ -1,83 +1,13 @@ project(pyside) -install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/__init__.py" - DESTINATION "${SITE_PACKAGE}/${BINDING_NAME}") -macro(execute_generator module sources typesystem_path) -add_custom_command(OUTPUT ${${sources}} -COMMAND ${GENERATOR} ${GENERATOR_EXTRA_FLAGS} - ${CMAKE_BINARY_DIR}/PySide/global.h - --include-paths=${pyside_SOURCE_DIR}:${QT_INCLUDE_DIR} - --typesystem-paths=${pyside_SOURCE_DIR}:${typesystem_path} - --output-directory=${CMAKE_CURRENT_BINARY_DIR} - --license-file=${CMAKE_CURRENT_SOURCE_DIR}/../licensecomment.txt - ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_${module}.xml - --api-version=${SUPPORTED_QT_VERSION} -WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} -COMMENT "Running generator for ${module}..." -) -endmacro(execute_generator) +include(PySideModules) # Configure include based on platform configure_file("${CMAKE_CURRENT_SOURCE_DIR}/global.h.in" - "${CMAKE_CURRENT_BINARY_DIR}/global.h" @ONLY) + "${CMAKE_CURRENT_BINARY_DIR}/pyside_global.h" @ONLY) - -# Only add subdirectory if the associated Qt module is found. -macro(HAS_QT_MODULE var name) -if (DISABLE_${name}) - message(STATUS "Generation of ${name} disabled.") -else() - if (${var}) - add_subdirectory(${name}) - execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_BINARY_DIR}/${name}/${name}${CMAKE_DEBUG_POSTFIX}${CMAKE_SHARED_MODULE_SUFFIX}" - "${CMAKE_BINARY_DIR}/PySide/${name}${CMAKE_SHARED_MODULE_SUFFIX}") - else() - message(STATUS "${name} NOT found. ${name} support disabled.") - endif() -endif() -endmacro(HAS_QT_MODULE) - -execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_SOURCE_DIR}/__init__.py" - "${CMAKE_BINARY_DIR}/PySide/__init__.py") -# Try to find QtMultimedia -# TODO: Remove this hack when cmake support QtMultimedia module -if (NOT QT_QTMULTIMEDIA_FOUND AND ${QTVERSION} VERSION_GREATER 4.5.9) - find_path(QT_QTMULTIMEDIA_INCLUDE_DIR QtMultimedia - PATHS ${QT_HEADERS_DIR}/QtMultimedia - ${QT_LIBRARY_DIR}/QtMultimedia.framework/Headers - NO_DEFAULT_PATH) - find_library(QT_QTMULTIMEDIA_LIBRARY QtMultimedia PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - if (QT_QTMULTIMEDIA_INCLUDE_DIR AND QT_QTMULTIMEDIA_LIBRARY) - set(QT_QTMULTIMEDIA_FOUND ON) - endif() -endif () - -# Try to find QtMaemo5 - it has to be done before QtGui to enable some QtMaemo5 flags -# TODO: Remove this hack when cmake support QtMaemo5 module -if (NOT QT_QTMAEMO5_FOUND AND ${QTVERSION} VERSION_GREATER 4.5.9) - find_path(QT_QTMAEMO5_INCLUDE_DIR QtMaemo5 - PATHS ${QT_HEADERS_DIR}/QtMaemo5 - ${QT_LIBRARY_DIR}/QtMaemo5.framework/Headers - NO_DEFAULT_PATH) - find_library(QT_QTMAEMO5_LIBRARY QtMaemo5 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - if (QT_QTMAEMO5_INCLUDE_DIR AND QT_QTMAEMO5_LIBRARY) - set(QT_QTMAEMO5_FOUND ON) - set(Q_WS_MAEMO_5 ON) - endif() -endif () - -# Try to find QtDeclarative -# TODO: Remove this hack when cmake support QtDeclarative module -if (NOT QT_QTDECLARATIVE_FOUND AND ${QTVERSION} VERSION_GREATER 4.6.0) - find_path(QT_QTDECLARATIVE_INCLUDE_DIR QtDeclarative - PATHS ${QT_HEADERS_DIR}/QtDeclarative - ${QT_LIBRARY_DIR}/QtDeclarative.framework/Headers - NO_DEFAULT_PATH) - find_library(QT_QTDECLARATIVE_LIBRARY QtDeclarative PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - if (QT_QTDECLARATIVE_INCLUDE_DIR AND QT_QTDECLARATIVE_LIBRARY) - set(QT_QTDECLARATIVE_FOUND ON) - endif() -endif () +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/__init__.py.in" + "${CMAKE_CURRENT_BINARY_DIR}/__init__.py" @ONLY) HAS_QT_MODULE(QT_QTCORE_FOUND QtCore) HAS_QT_MODULE(QT_QTGUI_FOUND QtGui) @@ -88,7 +18,9 @@ HAS_QT_MODULE(QT_QTXML_FOUND QtXml) HAS_QT_MODULE(QT_QTTEST_FOUND QtTest) HAS_QT_MODULE(QT_QTOPENGL_FOUND QtOpenGL) HAS_QT_MODULE(QT_QTSQL_FOUND QtSql) -HAS_QT_MODULE(QT_QTUITOOLS_FOUND QtUiTools) +if(QT_QTDESIGNER_FOUND) + HAS_QT_MODULE(QT_QTUITOOLS_FOUND QtUiTools) +endif() HAS_QT_MODULE(QT_QTHELP_FOUND QtHelp) HAS_QT_MODULE(QT_QTXMLPATTERNS_FOUND QtXmlPatterns) HAS_QT_MODULE(QT_QTMAEMO5_FOUND QtMaemo5) @@ -97,3 +29,12 @@ HAS_QT_MODULE(QT_QTSCRIPTTOOLS_FOUND QtScriptTools) HAS_QT_MODULE(QT_QTMULTIMEDIA_FOUND QtMultimedia) HAS_QT_MODULE(QT_PHONON_FOUND phonon) HAS_QT_MODULE(QT_QTDECLARATIVE_FOUND QtDeclarative) + +# install +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/__init__.py" + DESTINATION "${SITE_PACKAGE}/${BINDING_NAME}${pyside_SUFFIX}") +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_templates.xml + DESTINATION share/PySide${pyside_SUFFIX}/typesystems) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pyside_global.h + DESTINATION include/${BINDING_NAME}${pyside_SUFFIX}) + diff --git a/PySide/QtCore/CMakeLists.txt b/PySide/QtCore/CMakeLists.txt index 7572519..a2337c0 100644 --- a/PySide/QtCore/CMakeLists.txt +++ b/PySide/QtCore/CMakeLists.txt @@ -1,5 +1,7 @@ project(QtCore) +set(QtCore_gluecode "${CMAKE_CURRENT_SOURCE_DIR}/glue/qeasingcurve_glue.cpp") + if (${QT_VERSION_MAJOR} EQUAL 4 AND ${QT_VERSION_MINOR} LESS 6) set (QtCore_46_SRC ) else() @@ -34,7 +36,14 @@ else() ) endif() - +if(ENABLE_WIN) + set(SPECIFIC_OS_FILES + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/msg_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/point_wrapper.cpp + ) +else() + set(SPECIFIC_OS_FILES "") +endif() set(QtCore_SRC ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qabstracteventdispatcher_wrapper.cpp @@ -49,7 +58,6 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qbitarray_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qbuffer_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qbytearray_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qbytearraymatcher_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qchar_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qchildevent_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qcoreapplication_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qcryptographichash_wrapper.cpp @@ -61,7 +69,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qdiriterator_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qdynamicpropertychangeevent_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qevent_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qeventloop_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/${BINDING_NAME}/QtCore/qfactoryinterface_wrapper.cpp +${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qfactoryinterface_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qfile_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qfileinfo_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qfilesystemwatcher_wrapper.cpp @@ -69,8 +77,6 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qfsfileengine_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qgenericargument_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qgenericreturnargument_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qiodevice_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qlatin1char_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qlatin1string_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qlibraryinfo_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qline_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qlinef_wrapper.cpp @@ -86,6 +92,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qmutex_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qmutexlocker_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qobject_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qpersistentmodelindex_wrapper.cpp +${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qpluginloader_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qpoint_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qpointf_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qprocess_wrapper.cpp @@ -95,16 +102,13 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qrect_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qrectf_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qregexp_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qresource_wrapper.cpp +${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qrunnable_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qsemaphore_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qsettings_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qsignalmapper_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qsize_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qsizef_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qsocketnotifier_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qstring_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qstringlist_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qstringmatcher_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qstringref_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qsysinfo_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qsystemlocale_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qsystemsemaphore_wrapper.cpp @@ -120,6 +124,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qtextencoder_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qtextstream_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qtextstreammanipulator_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qthread_wrapper.cpp +${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qthreadpool_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qtime_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qtimeline_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qtimer_wrapper.cpp @@ -127,7 +132,6 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qtimerevent_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qtranslator_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qurl_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/quuid_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qvariant_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qwaitcondition_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qwritelocker_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qxmlstreamattribute_wrapper.cpp @@ -140,28 +144,30 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qxmlstreamreader_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qxmlstreamwriter_wrapper.cpp ${QtCore_46_SRC} ${QtCore_47_SRC} +${SPECIFIC_OS_FILES} ) -execute_generator(core QtCore_SRC "${CMAKE_CURRENT_BINARY_DIR}") +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/typesystem_core.xml.in" + "${CMAKE_CURRENT_BINARY_DIR}/typesystem_core.xml" @ONLY) -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/${BINDING_NAME}/QtCore/ - ${QT_INCLUDE_DIR} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${PYTHON_INCLUDE_PATH} - ) -add_library(QtCore MODULE ${QtCore_SRC}) -set_property(TARGET QtCore PROPERTY PREFIX "") -target_link_libraries(QtCore - pyside - ${PYTHON_LIBRARIES} +set(QtCore_typesystem_path "${QtCore_SOURCE_DIR}") + +set(QtCore_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/${BINDING_NAME}/QtCore/ + ${QT_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${SHIBOKEN_PYTHON_INCLUDE_DIR}) +set(QtCore_libraries pyside + ${SHIBOKEN_PYTHON_LIBRARIES} ${SHIBOKEN_LIBRARY} - ${QT_QTCORE_LIBRARY} - ) + ${QT_QTCORE_LIBRARY}) -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtCore${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/${BINDING_NAME}) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/pyside_qtcore_python.h - DESTINATION include/PySide/QtCore/) +create_pyside_module(QtCore + QtCore_include_dirs + QtCore_libraries + "" + QtCore_typesystem_path + QtCore_SRC + QtCore_gluecode + ${CMAKE_CURRENT_BINARY_DIR}/typesystem_core.xml) diff --git a/PySide/QtCore/glue/qbytearray_bufferprotocol.cpp b/PySide/QtCore/glue/qbytearray_bufferprotocol.cpp index 4fd1587..acc7bb9 100644 --- a/PySide/QtCore/glue/qbytearray_bufferprotocol.cpp +++ b/PySide/QtCore/glue/qbytearray_bufferprotocol.cpp @@ -15,10 +15,10 @@ static Py_ssize_t SbkQByteArray_segcountproc(PyObject* self, Py_ssize_t* lenp) static Py_ssize_t SbkQByteArray_readbufferproc(PyObject* self, Py_ssize_t segment, void** ptrptr) { - if (segment || Shiboken::cppObjectIsInvalid(self)) + if (segment || !Shiboken::Object::isValid(self)) return -1; - QByteArray* cppSelf = Converter::toCpp(self); + QByteArray* cppSelf = %CONVERTTOCPP[QByteArray*](self); *ptrptr = reinterpret_cast(cppSelf->data()); return cppSelf->size(); } diff --git a/PySide/QtCore/glue/qcoreapplication_init.cpp b/PySide/QtCore/glue/qcoreapplication_init.cpp index f53db03..c92f03e 100644 --- a/PySide/QtCore/glue/qcoreapplication_init.cpp +++ b/PySide/QtCore/glue/qcoreapplication_init.cpp @@ -2,43 +2,23 @@ static int QCoreApplicationArgCount; static char** QCoreApplicationArgValues; -/** - * Called at QtCore module exit - */ -void DeleteQCoreApplicationAtExit() { - if (QCoreApplication::instance()) { - delete QCoreApplication::instance(); - for (int i = 0; i < QCoreApplicationArgCount; ++i) - delete[] QCoreApplicationArgValues[i]; - } -} - -int SbkQCoreApplication_Init(PyObject* self, PyObject* args, PyObject*) +void QCoreApplication_constructor(PyObject* self, PyObject* args, QCoreApplicationWrapper** cptr) { if (QCoreApplication::instance()) { PyErr_SetString(PyExc_RuntimeError, "A QCoreApplication instance already exists."); - return -1; + return; } int numArgs = PyTuple_GET_SIZE(args); - if (numArgs != 1) { + if (numArgs != 1 + || !Shiboken::sequenceToArgcArgv(PyTuple_GET_ITEM(args, 0), &QCoreApplicationArgCount, &QCoreApplicationArgValues, "PySideApp")) { PyErr_BadArgument(); - return -1; + return; } - if (!PySequenceToArgcArgv(PyTuple_GET_ITEM(args, 0), &QCoreApplicationArgCount, &QCoreApplicationArgValues, "PySideApp")) { - PyErr_BadArgument(); - return -1; - } - - void* cptr = new QCoreApplication(QCoreApplicationArgCount, QCoreApplicationArgValues); - Shiboken::setCppPointer(reinterpret_cast(self), - Shiboken::SbkType(), - cptr); - SbkBaseWrapper_setValidCppObject(self, 1); - Shiboken::BindingManager::instance().registerWrapper(reinterpret_cast(self), cptr); + *cptr = new QCoreApplicationWrapper(QCoreApplicationArgCount, QCoreApplicationArgValues); + Shiboken::Object::releaseOwnership(reinterpret_cast(self)); + PySide::registerCleanupFunction(&PySide::destroyQCoreApplication); Py_INCREF(self); - Py_AtExit(DeleteQCoreApplicationAtExit); - return 1; } diff --git a/PySide/QtCore/glue/qeasingcurve_glue.cpp b/PySide/QtCore/glue/qeasingcurve_glue.cpp new file mode 100644 index 0000000..7f56315 --- /dev/null +++ b/PySide/QtCore/glue/qeasingcurve_glue.cpp @@ -0,0 +1,120 @@ +#include +#include +#include +#include + +#include "glue/qeasingcurve_glue.h" + +#define __ECF_ATT_NAME__ "__ecf__" +#define MAX_CUSTOM_FUNCTIONS 10 + +static void deleteData(void* data); + +struct CustomFunctionsData +{ + static CustomFunctionsData m_list[MAX_CUSTOM_FUNCTIONS]; + + PySideEasingCurveFunctor* m_obj; + QEasingCurve::EasingFunction m_func; +}; + +CustomFunctionsData CustomFunctionsData::m_list[MAX_CUSTOM_FUNCTIONS]; + +template +struct CustomFunctions +{ + static void init() + { + CustomFunctionsData data; + data.m_obj = 0; + data.m_func = &CustomFunctions::callback; + CustomFunctionsData::m_list[N] = data; + + CustomFunctions::init(); + } + + static qreal callback(qreal v) + { + return (*CustomFunctionsData::m_list[N].m_obj)(v); + } +}; + +template<> +struct CustomFunctions<0> +{ + static void init() + { + CustomFunctionsData data; + data.m_obj = 0; + data.m_func = &CustomFunctions<0>::callback; + CustomFunctionsData::m_list[0] = data; + } + + static qreal callback(qreal v) + { + return (*CustomFunctionsData::m_list[0].m_obj)(v); + } +}; + +void deleteData(void* data) +{ + delete (PySideEasingCurveFunctor*)(data); +} + +void PySideEasingCurveFunctor::init() +{ + CustomFunctions::init(); +} + +QEasingCurve::EasingFunction PySideEasingCurveFunctor::createCustomFuntion(PyObject* parent, PyObject* pyFunc) +{ + for(int i=0; i < MAX_CUSTOM_FUNCTIONS; i++) { + CustomFunctionsData& data = CustomFunctionsData::m_list[i]; + if (data.m_obj == 0) { + data.m_obj = new PySideEasingCurveFunctor(i, parent, pyFunc); + return data.m_func; + } + } + //PyErr_Format(PyExc_RuntimeError, "PySide only supports %d custom functions simultaneously.", MAX_CUSTOM_FUNCTIONS); + return 0; +} + +PySideEasingCurveFunctor::~PySideEasingCurveFunctor() +{ + + CustomFunctionsData::m_list[m_index].m_obj = 0; + PyObject_SetAttrString(m_parent, __ECF_ATT_NAME__, Py_None); +} + +qreal PySideEasingCurveFunctor::operator()(qreal progress) +{ + Shiboken::GilState state; + PyObject* args = Py_BuildValue("(f)", progress); + PyObject* result = PyObject_CallObject(m_func, args); + qreal cppResult = 0.0; + if (result) { + Shiboken::Conversions::pythonToCppCopy(Shiboken::Conversions::PrimitiveTypeConverter(), result, &cppResult); + Py_DECREF(result); + } + Py_DECREF(args); + return cppResult; +} + +PyObject* PySideEasingCurveFunctor::callable() +{ + Py_INCREF(m_func); + return m_func; +} + +PyObject* PySideEasingCurveFunctor::callable(PyObject* parent) +{ + return PyObject_GetAttrString(parent, __ECF_ATT_NAME__); +} + +PySideEasingCurveFunctor::PySideEasingCurveFunctor(int index, PyObject* parent, PyObject* pyFunc) + : m_parent(parent), m_func(pyFunc), m_index(index) +{ + PyObject_SetAttrString(m_parent, __ECF_ATT_NAME__, m_func); + PySide::WeakRef::create(m_parent, deleteData, this); +} + diff --git a/PySide/QtCore/glue/qeasingcurve_glue.h b/PySide/QtCore/glue/qeasingcurve_glue.h new file mode 100644 index 0000000..282e439 --- /dev/null +++ b/PySide/QtCore/glue/qeasingcurve_glue.h @@ -0,0 +1,27 @@ +#ifndef __QEASINGCURVE_GLUE__ +#define __QEASINGCURVE_GLUE__ + +#include +#include + +class PySideEasingCurveFunctor +{ + public: + static void init(); + static QEasingCurve::EasingFunction createCustomFuntion(PyObject* parent, PyObject* pyFunc); + + qreal operator()(qreal progress); + + PyObject* callable(); //Return New reference + static PyObject* callable(PyObject* parent); //Return New reference + + ~PySideEasingCurveFunctor(); + private: + PyObject* m_parent; + PyObject* m_func; + int m_index; + + PySideEasingCurveFunctor(int index, PyObject* parent, PyObject *pyFunc); +}; + +#endif diff --git a/PySide/QtCore/glue/qobject_connect.cpp b/PySide/QtCore/glue/qobject_connect.cpp index 5b6f254..96bcfb2 100644 --- a/PySide/QtCore/glue/qobject_connect.cpp +++ b/PySide/QtCore/glue/qobject_connect.cpp @@ -1,23 +1,46 @@ -static bool getReceiver(PyObject *callback, QObject **receiver, PyObject **self) +static bool isDecorator(PyObject* method, PyObject* self) { + Shiboken::AutoDecRef methodName(PyObject_GetAttrString(method, "__name__")); + if (!PyObject_HasAttr(self, methodName)) + return true; + Shiboken::AutoDecRef otherMethod(PyObject_GetAttr(self, methodName)); + return reinterpret_cast(otherMethod.object())->im_func != \ + reinterpret_cast(method)->im_func; +} + +static bool getReceiver(QObject *source, const char* signal, PyObject* callback, QObject** receiver, PyObject** self, QByteArray* callbackSig) +{ + bool forceGlobalReceiver = false; if (PyMethod_Check(callback)) { *self = PyMethod_GET_SELF(callback); - if (SbkQObject_Check(*self)) - *receiver = Converter::toCpp(*self); + if (%CHECKTYPE[QObject*](*self)) + *receiver = %CONVERTTOCPP[QObject*](*self); + forceGlobalReceiver = isDecorator(callback, *self); } else if (PyCFunction_Check(callback)) { *self = PyCFunction_GET_SELF(callback); - if (*self && SbkQObject_Check(*self)) - *receiver = Converter::toCpp(*self); + if (*self && %CHECKTYPE[QObject*](*self)) + *receiver = %CONVERTTOCPP[QObject*](*self); } else if (PyCallable_Check(callback)) { // Ok, just a callable object *receiver = 0; *self = 0; } - bool usingGlobalReceiver = !*receiver; + bool usingGlobalReceiver = !*receiver || forceGlobalReceiver; + + // Check if this callback is a overwrite of a non-virtual Qt slot. + if (!usingGlobalReceiver && receiver && self) { + *callbackSig = PySide::Signal::getCallbackSignature(signal, *receiver, callback, usingGlobalReceiver).toAscii(); + const QMetaObject* metaObject = (*receiver)->metaObject(); + int slotIndex = metaObject->indexOfSlot(callbackSig->constData()); + if (slotIndex != -1 && slotIndex < metaObject->methodOffset() && PyMethod_Check(callback)) + usingGlobalReceiver = true; + } + if (usingGlobalReceiver) { PySide::SignalManager& signalManager = PySide::SignalManager::instance(); - *receiver = signalManager.globalReceiver(); + *receiver = signalManager.globalReceiver(source, callback); + *callbackSig = PySide::Signal::getCallbackSignature(signal, *receiver, callback, usingGlobalReceiver).toAscii(); } return usingGlobalReceiver; @@ -25,13 +48,17 @@ static bool getReceiver(PyObject *callback, QObject **receiver, PyObject **self) static bool qobjectConnect(QObject* source, const char* signal, QObject* receiver, const char* slot, Qt::ConnectionType type) { - if (!PySide::checkSignal(signal)) + if (!signal || !slot) + return false; + + if (!PySide::Signal::checkQtSignal(signal)) return false; signal++; - PySide::SignalManager::registerMetaMethod(source, signal, QMetaMethod::Signal); + if (!PySide::SignalManager::registerMetaMethod(source, signal, QMetaMethod::Signal)) + return false; - bool isSignal = PySide::isSignal(slot); + bool isSignal = PySide::Signal::isQtSignal(slot); slot++; PySide::SignalManager::registerMetaMethod(receiver, slot, isSignal ? QMetaMethod::Signal : QMetaMethod::Slot); return QObject::connect(source, signal - 1, receiver, slot - 1, type); @@ -39,58 +66,73 @@ static bool qobjectConnect(QObject* source, const char* signal, QObject* receive static bool qobjectConnectCallback(QObject* source, const char* signal, PyObject* callback, Qt::ConnectionType type) { - if (!PySide::checkSignal(signal)) + if (!signal || !PySide::Signal::checkQtSignal(signal)) return false; signal++; - PySide::SignalManager::registerMetaMethod(source, signal, QMetaMethod::Signal); - int signalIndex = source->metaObject()->indexOfMethod(signal); + int signalIndex = PySide::SignalManager::registerMetaMethodGetIndex(source, signal, QMetaMethod::Signal); + if (signalIndex == -1) + return false; PySide::SignalManager& signalManager = PySide::SignalManager::instance(); // Extract receiver from callback QObject* receiver = 0; PyObject* self = 0; - bool usingGlobalReceiver = getReceiver(callback, &receiver, &self); + QByteArray callbackSig; + bool usingGlobalReceiver = getReceiver(source, signal, callback, &receiver, &self, &callbackSig); if (receiver == 0 && self == 0) return false; const QMetaObject* metaObject = receiver->metaObject(); - const QByteArray callbackSig = PySide::getCallbackSignature(signal, callback, usingGlobalReceiver).toAscii(); const char* slot = callbackSig.constData(); int slotIndex = metaObject->indexOfSlot(slot); + if (slotIndex == -1) { - if (!usingGlobalReceiver && self && !((SbkBaseWrapper*)self)->containsCppWrapper) { + if (!usingGlobalReceiver && self && !Shiboken::Object::hasCppWrapper((SbkObject*)self)) { qWarning() << "You can't add dynamic slots on an object originated from C++."; + if (usingGlobalReceiver) + signalManager.releaseGlobalReceiver(source, receiver); + return false; } - if (usingGlobalReceiver) { - signalManager.addGlobalSlot(slot, callback); - } else { - PySide::SignalManager::registerMetaMethod(receiver, slot, QMetaMethod::Slot); + + if (usingGlobalReceiver) + slotIndex = signalManager.globalReceiverSlotIndex(receiver, slot); + else + slotIndex = PySide::SignalManager::registerMetaMethodGetIndex(receiver, slot, QMetaMethod::Slot); + + if (slotIndex == -1) { + if (usingGlobalReceiver) + signalManager.releaseGlobalReceiver(source, receiver); + + return false; } - slotIndex = metaObject->indexOfSlot(slot); } if (QMetaObject::connect(source, signalIndex, receiver, slotIndex, type)) { + if (usingGlobalReceiver) + signalManager.notifyGlobalReceiver(receiver); #ifndef AVOID_PROTECTED_HACK - source->connectNotify(signal); + source->connectNotify(signal - 1); #else // Need to cast to QObjectWrapper* and call the public version of // connectNotify when avoiding the protected hack. - reinterpret_cast(source)->connectNotify(signal); + reinterpret_cast(source)->connectNotify(signal - 1); #endif - if (usingGlobalReceiver) - signalManager.globalReceiverConnectNotify(source, slotIndex); return true; } + + if (usingGlobalReceiver) + signalManager.releaseGlobalReceiver(source, receiver); + return false; } static bool qobjectDisconnectCallback(QObject* source, const char* signal, PyObject* callback) { - if (!PySide::checkSignal(signal)) + if (!PySide::Signal::checkQtSignal(signal)) return false; PySide::SignalManager& signalManager = PySide::SignalManager::instance(); @@ -98,20 +140,28 @@ static bool qobjectDisconnectCallback(QObject* source, const char* signal, PyObj // Extract receiver from callback QObject* receiver = 0; PyObject* self = 0; - bool usingGlobalReceiver = getReceiver(callback, &receiver, &self); + QByteArray callbackSig; + bool usingGlobalReceiver = getReceiver(NULL, signal, callback, &receiver, &self, &callbackSig); if (receiver == 0 && self == 0) return false; const QMetaObject* metaObject = receiver->metaObject(); - const QByteArray callbackSig = PySide::getCallbackSignature(signal, callback, usingGlobalReceiver).toAscii(); - QByteArray qtSlotName(callbackSig); - qtSlotName = qtSlotName.prepend('1'); + int signalIndex = source->metaObject()->indexOfSignal(++signal); + int slotIndex = -1; - if (QObject::disconnect(source, signal, receiver, qtSlotName.constData())) { - if (usingGlobalReceiver) { - int slotIndex = metaObject->indexOfSlot(callbackSig.constData()); - signalManager.globalReceiverDisconnectNotify(source, slotIndex); - } + slotIndex = metaObject->indexOfSlot(callbackSig); + + if (QMetaObject::disconnectOne(source, signalIndex, receiver, slotIndex)) { + if (usingGlobalReceiver) + signalManager.releaseGlobalReceiver(source, receiver); + + #ifndef AVOID_PROTECTED_HACK + source->disconnectNotify(callbackSig); + #else + // Need to cast to QObjectWrapper* and call the public version of + // connectNotify when avoiding the protected hack. + reinterpret_cast(source)->disconnectNotify(callbackSig); + #endif return true; } return false; diff --git a/PySide/QtCore/glue/qobject_findchild.cpp b/PySide/QtCore/glue/qobject_findchild.cpp index 351aa69..669beac 100644 --- a/PySide/QtCore/glue/qobject_findchild.cpp +++ b/PySide/QtCore/glue/qobject_findchild.cpp @@ -17,14 +17,23 @@ static QObject* _findChildHelper(const QObject* parent, const QString& name, PyT return 0; } -static void _findChildrenHelper(const QObject* parent, const QString& name, PyTypeObject* desiredType, PyObject* result) +static inline bool _findChildrenComparator(const QObject*& child, const QRegExp& name) { - foreach(QObject* child, parent->children()) { + return name.indexIn(child->objectName()) != -1; +} + +static inline bool _findChildrenComparator(const QObject*& child, const QString& name) +{ + return name.isNull() || name == child->objectName(); +} + +template +static void _findChildrenHelper(const QObject* parent, const T& name, PyTypeObject* desiredType, PyObject* result) +{ + foreach(const QObject* child, parent->children()) { Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QObject*](child)); - if (PyType_IsSubtype(pyChild->ob_type, desiredType) - && (name.isNull() || name == child->objectName())) { + if (PyType_IsSubtype(pyChild->ob_type, desiredType) && _findChildrenComparator(child, name)) PyList_Append(result, pyChild); - } _findChildrenHelper(child, name, desiredType, result); } -} \ No newline at end of file +} diff --git a/PySide/QtCore/glue/qstring_bufferprotocol.cpp b/PySide/QtCore/glue/qstring_bufferprotocol.cpp deleted file mode 100644 index 02ca32c..0000000 --- a/PySide/QtCore/glue/qstring_bufferprotocol.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -#if PY_VERSION_HEX < 0x03000000 - -// QByteArray buffer protocol functions -// see: http://www.python.org/dev/peps/pep-3118/ - -extern "C" { - -static Py_ssize_t SbkQString_segcountproc(PyObject* self, Py_ssize_t* lenp) -{ - if (lenp) - *lenp = self->ob_type->tp_as_sequence->sq_length(self); - return 1; -} - -static Py_ssize_t SbkQString_readbufferproc(PyObject* self, Py_ssize_t segment, char** ptrptr) -{ - if (segment || Shiboken::cppObjectIsInvalid(self)) - return -1; - - QString* cppSelf = Converter::toCpp(self); - QByteArray decodedData = cppSelf->toLocal8Bit(); - Shiboken::AutoDecRef decodedString(PyString_FromStringAndSize(decodedData.constData(), decodedData.size())); - - // delete __encodedStr attr if it exists - Shiboken::AutoDecRef attrName(PyString_FromStringAndSize("__encodedStr", sizeof("__encodedStr")-1)); - if (PyObject_HasAttr(self, attrName)) - PyObject_DelAttr(self, attrName); - PyObject_SetAttr(self, attrName, decodedString); - *ptrptr = PyString_AS_STRING(decodedString.object()); - return decodedData.size(); -} - -PyBufferProcs SbkQStringBufferProc = { - /*bf_getreadbuffer*/ 0, - /*bf_getwritebuffer*/ 0, - /*bf_getsegcount*/ &SbkQString_segcountproc, - /*bf_getcharbuffer*/ &SbkQString_readbufferproc -}; - -} - -#endif diff --git a/PySide/QtCore/glue/qstring_hashfunc.cpp b/PySide/QtCore/glue/qstring_hashfunc.cpp deleted file mode 100644 index b2fb6a1..0000000 --- a/PySide/QtCore/glue/qstring_hashfunc.cpp +++ /dev/null @@ -1,6 +0,0 @@ -static long QStringCustomHashFunction(const QString& str) -{ - QByteArray data = str.toUtf8(); - Shiboken::AutoDecRef unicodeObj(PyUnicode_DecodeUTF8(data.constData(), data.length(), 0)); - return unicodeObj->ob_type->tp_hash(unicodeObj); -} diff --git a/PySide/QtCore/qbool_conversions.h b/PySide/QtCore/qbool_conversions.h deleted file mode 100644 index f4fb43f..0000000 --- a/PySide/QtCore/qbool_conversions.h +++ /dev/null @@ -1,16 +0,0 @@ -namespace Shiboken { -template <> -struct Converter : public ValueTypeConverter -{ - using ValueTypeConverter::toPython; - - static PyObject* toPython(const QBool& cppobj) - { - return PyBool_FromLong((bool) cppobj); - } - static QBool toCpp(PyObject* pyobj) - { - return QBool(pyobj == Py_True); - } -}; -} diff --git a/PySide/QtCore/qchar_conversions.h b/PySide/QtCore/qchar_conversions.h deleted file mode 100644 index 6347c93..0000000 --- a/PySide/QtCore/qchar_conversions.h +++ /dev/null @@ -1,30 +0,0 @@ -namespace Shiboken { -inline bool Shiboken::Converter::isConvertible(PyObject* pyObj) -{ - return PyObject_TypeCheck(pyObj, SbkType()) - || SbkPySide_QtCore_QChar_SpecialCharacter_Check(pyObj) - || SbkQLatin1Char_Check(pyObj) - || (PyString_Check(pyObj) && (PyString_Size(pyObj) == 1)) - || PyInt_Check(pyObj); -} - -inline QChar Shiboken::Converter::toCpp(PyObject* pyObj) -{ - if (!Shiboken_TypeCheck(pyObj, QChar)) { - if (SbkPySide_QtCore_QChar_SpecialCharacter_Check(pyObj)) - return QChar(Shiboken::Converter::toCpp(pyObj)); - else if (SbkQLatin1Char_Check(pyObj)) - return QChar(Shiboken::Converter::toCpp(pyObj)); - else if (PyString_Check(pyObj) && PyString_Size(pyObj) == 1) - return QChar(Shiboken::Converter::toCpp(pyObj)); - else if (PyInt_Check(pyObj)) - return QChar(Shiboken::Converter::toCpp(pyObj)); - } - return *Converter::toCpp(pyObj); -} - -inline PyObject* Converter::toPython(const QChar& cppObj) -{ - return ValueTypeConverter::toPython(cppObj); -} -} diff --git a/PySide/QtCore/qhash_conversions.h b/PySide/QtCore/qhash_conversions.h deleted file mode 100644 index f9e2e42..0000000 --- a/PySide/QtCore/qhash_conversions.h +++ /dev/null @@ -1,4 +0,0 @@ -namespace Shiboken { -template -struct Converter > : QtDictConverter > {}; -} diff --git a/PySide/QtCore/qlist_conversions.h b/PySide/QtCore/qlist_conversions.h deleted file mode 100644 index cb1d26b..0000000 --- a/PySide/QtCore/qlist_conversions.h +++ /dev/null @@ -1,4 +0,0 @@ -namespace Shiboken { -template -struct Converter > : StdListConverter > {}; -} diff --git a/PySide/QtCore/qmap_conversions.h b/PySide/QtCore/qmap_conversions.h deleted file mode 100644 index 3153fae..0000000 --- a/PySide/QtCore/qmap_conversions.h +++ /dev/null @@ -1,5 +0,0 @@ -namespace Shiboken { -template -struct Converter > : QtDictConverter > { -}; -} diff --git a/PySide/QtCore/qmultimap_conversions.h b/PySide/QtCore/qmultimap_conversions.h deleted file mode 100644 index 43abd84..0000000 --- a/PySide/QtCore/qmultimap_conversions.h +++ /dev/null @@ -1,5 +0,0 @@ -namespace Shiboken { -template -struct Converter > : QtMultiMapConverter > { -}; -} diff --git a/PySide/QtCore/qpair_conversions.h b/PySide/QtCore/qpair_conversions.h deleted file mode 100644 index 99e9cd8..0000000 --- a/PySide/QtCore/qpair_conversions.h +++ /dev/null @@ -1,4 +0,0 @@ -namespace Shiboken { -template -struct Converter > : StdPairConverter > {}; -} diff --git a/PySide/QtCore/qset_conversions.h b/PySide/QtCore/qset_conversions.h deleted file mode 100644 index c46fef0..0000000 --- a/PySide/QtCore/qset_conversions.h +++ /dev/null @@ -1,4 +0,0 @@ -namespace Shiboken { -template -struct Converter > : QSequenceConverter > {}; -} diff --git a/PySide/QtCore/qstring_conversions.h b/PySide/QtCore/qstring_conversions.h deleted file mode 100644 index 2c59928..0000000 --- a/PySide/QtCore/qstring_conversions.h +++ /dev/null @@ -1,72 +0,0 @@ -namespace Shiboken { -inline bool Converter::isConvertible(PyObject* pyObj) -{ - SbkBaseWrapperType* shiboType = reinterpret_cast(SbkType()); - return PyString_Check(pyObj) - || PyObject_TypeCheck(pyObj, SbkType()) - || PyUnicode_Check(pyObj) - || SbkQByteArray_Check(pyObj) - || SbkQLatin1String_Check(pyObj) - || pyObj == Py_None -#if PY_VERSION_HEX < 0x03000000 - || (pyObj->ob_type->tp_as_buffer - && PyType_HasFeature(pyObj->ob_type, Py_TPFLAGS_HAVE_GETCHARBUFFER) - && pyObj->ob_type->tp_as_buffer->bf_getcharbuffer) -#endif - || SbkQChar_Check(pyObj) - || (shiboType->ext_isconvertible && shiboType->ext_isconvertible(pyObj)); -} - -inline QString Converter::toCpp(PyObject* pyObj) -{ - SbkBaseWrapperType* shiboType = reinterpret_cast(SbkType()); - if (SbkQChar_Check(pyObj)) { - return QString(Converter< QChar >::toCpp(pyObj)); - } else if (SbkQByteArray_Check(pyObj)) { - return QString(Converter< QByteArray >::toCpp(pyObj)); - } else if (SbkQLatin1String_Check(pyObj)) { - return QString(Converter< QLatin1String >::toCpp(pyObj)); - } else if (PyUnicode_Check(pyObj)) { - Py_UNICODE* unicode = PyUnicode_AS_UNICODE(pyObj); -#if defined(Py_UNICODE_WIDE) - // cast as Py_UNICODE can be a different type - return QString::fromUcs4(reinterpret_cast(unicode)); -#else - return QString::fromUtf16(unicode, PyUnicode_GET_SIZE(pyObj)); -#endif - } else if (PyString_Check(pyObj)) { - return QString(Converter< char * >::toCpp(pyObj)); - } else if (pyObj == Py_None) { - return QString(); - } -#if PY_VERSION_HEX < 0x03000000 - // Support for buffer objects on QString constructor - else if (pyObj->ob_type->tp_as_buffer - && PyType_HasFeature(pyObj->ob_type, Py_TPFLAGS_HAVE_GETCHARBUFFER) - && pyObj->ob_type->tp_as_buffer->bf_getcharbuffer) { - QByteArray data; - PyBufferProcs* bufferProcs = pyObj->ob_type->tp_as_buffer; - int segments = bufferProcs->bf_getsegcount(pyObj, 0); - for (int i = 0; i < segments; ++i) { - char* segmentData; - int length = bufferProcs->bf_getcharbuffer(pyObj, i, &segmentData); - if (length == -1) - break; - data.append(segmentData, length); - } - return QString(data); - } -#endif - else if (shiboType->ext_isconvertible && shiboType->ext_tocpp && shiboType->ext_isconvertible(pyObj)) { - QString* cptr = reinterpret_cast(shiboType->ext_tocpp(pyObj)); - std::auto_ptr cptr_auto_ptr(cptr); - return *cptr; - } - return *Converter::toCpp(pyObj); -} - -inline PyObject* Converter::toPython(const QString& cppObj) -{ - return ValueTypeConverter::toPython(cppObj); -} -} diff --git a/PySide/QtCore/qstringlist_conversions.h b/PySide/QtCore/qstringlist_conversions.h deleted file mode 100644 index 9a5ec5f..0000000 --- a/PySide/QtCore/qstringlist_conversions.h +++ /dev/null @@ -1,17 +0,0 @@ -namespace Shiboken -{ -inline bool Converter::isConvertible(PyObject* pyObj) -{ - return StdListConverter::isConvertible(pyObj); -} - -inline QStringList Converter::toCpp(PyObject* pyObj) -{ - return StdListConverter::toCpp(pyObj); -} - -inline PyObject* Converter::toPython(const QStringList& cppObj) -{ - return ValueTypeConverter::toPython(cppObj); -} -} diff --git a/PySide/QtCore/qvariant_conversions.h b/PySide/QtCore/qvariant_conversions.h deleted file mode 100644 index f0f78a0..0000000 --- a/PySide/QtCore/qvariant_conversions.h +++ /dev/null @@ -1,81 +0,0 @@ -// We use this thin wrapper instead of the plain PyObject pointer to avoid conflicts with specializations of T* -// in QVariant. -struct PyQt_PyObject -{ - PyObject* m_me; - PyQt_PyObject(PyObject* me) : m_me(me) {} - PyQt_PyObject() : m_me(Py_None) {} - operator PyObject*() { return m_me; } -}; - -Q_DECLARE_METATYPE(PyQt_PyObject) - -namespace Shiboken { - -// all types are convertible to QVariant -inline bool Converter::isConvertible(PyObject* pyObj) -{ - return true; -} - -inline QVariant Converter::toCpp(PyObject* pyObj) -{ - if (SbkQVariant_Check(pyObj)) - return *Converter::toCpp(pyObj); - - // Primitive types - if (PyBool_Check(pyObj)) { - // QVariant(bool) - return QVariant(Shiboken::Converter::toCpp(pyObj)); - } else if (PyString_CheckExact(pyObj)) { - // QVariant(const char*) - return QVariant(Shiboken::Converter::toCpp(pyObj)); - } else if (PyFloat_CheckExact(pyObj)) { - // QVariant(double) - return QVariant(Shiboken::Converter::toCpp(pyObj)); - } else if (PyInt_CheckExact(pyObj)) { - // QVariant(int) - return QVariant(Shiboken::Converter::toCpp(pyObj)); - } else if (PyLong_CheckExact(pyObj)) { - // QVariant(qlonglong) - return QVariant(Shiboken::Converter::toCpp(pyObj)); - } else if (Shiboken::isShibokenEnum(pyObj)) { - // QVariant(enum) - return QVariant(Shiboken::Converter::toCpp(pyObj)); - } else if (!Shiboken::isShibokenType(pyObj) || Shiboken::isUserType(pyObj)) { - // QVariant(User class) - Py_INCREF(pyObj); - return QVariant::fromValue(pyObj); - } else { - // a class supported by QVariant? - const char* typeName = pyObj->ob_type->tp_name; - // check if the name starts with PySide. - if (!strncmp("PySide.", typeName, 7)) { - // get the type name - const char* lastDot = typeName; - for (int i = 8; typeName[i]; ++i) { - if (typeName[i] == '.') - lastDot = &typeName[i]; - } - lastDot++; - uint typeCode = QMetaType::type(lastDot); - if (!typeCode) {// Try with star at end, for QObject*, QWidget* and QAbstractKinectScroller* - QString typeName(lastDot); - typeName += '*'; - typeCode = QMetaType::type(typeName.toAscii()); - } - if (typeCode) - return QVariant(typeCode, reinterpret_cast(pyObj)->cptr[0]); - } - // Is a shiboken type not known by Qt - Py_INCREF(pyObj); - return QVariant::fromValue(pyObj); - } -} - -inline PyObject* Converter::toPython(const QVariant& cppObj) -{ - return ValueTypeConverter::toPython(cppObj); -} - -} diff --git a/PySide/QtCore/qvector_conversions.h b/PySide/QtCore/qvector_conversions.h deleted file mode 100644 index 0857036..0000000 --- a/PySide/QtCore/qvector_conversions.h +++ /dev/null @@ -1,4 +0,0 @@ -namespace Shiboken { -template -struct Converter > : StdListConverter > {}; -} diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml deleted file mode 100644 index 9711e2d..0000000 --- a/PySide/QtCore/typesystem_core.xml +++ /dev/null @@ -1,2870 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %PYARG_0 = %CONVERTTOPYTHON[long](qAbs(%1)); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PySide::init(module); - - - #include <pyside.h> - - - - - - - - - - - - - - - - - - QPointF p; - %RETURN_TYPE retval = %CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES, &p); - %PYARG_0 = Shiboken::makeTuple(retval, p); - - - - - - - - - - - - - - - - - - - - - - - - - - - - #if PY_VERSION_HEX < 0x03000000 - Shiboken::SbkType<QString>()->tp_as_buffer = &SbkQStringBufferProc; - Shiboken::SbkType<QString>()->tp_flags |= Py_TPFLAGS_HAVE_GETCHARBUFFER; - #endif - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - QByteArray utf8 = %CPPSELF.toUtf8(); - %PYARG_0 = PyUnicode_DecodeUTF8(utf8.data(), utf8.count(), 0); - - - - - return %CPPSELF.count(); - - - - - if (_i < 0 || _i >= %CPPSELF.size()) { - PyErr_SetString(PyExc_IndexError, "index out of bounds"); - return 0; - } - return %CONVERTTOPYTHON[%TYPE](%CPPSELF.at(_i)); - - - - - %CPPSELF.remove(_i, 1); - PyObject* args = Py_BuildValue("(nO)", _i, _value); - PyObject* result = SbkQStringFunc_insert(self, args); - Py_DECREF(args); - Py_XDECREF(result); - return !result ? -1 : 0; - - - - - - - - - - - - - - - - - - - - - - - Implementation note: This constructor is a replacement for - QChar(char), as the char type check also catches numbers, - conflicting with QChar(int). - - - if (PyString_Size(%PYARG_1) == 1) { - char value = %CONVERTTOCPP[char](%PYARG_1); - %0 = new %TYPE(value); - } else { - PyErr_SetString(PyExc_TypeError, "expected string of size 1"); - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - int year, month, day; - %CPPSELF.%FUNCTION_NAME(&year, &month, &day); - %PYARG_0 = Shiboken::makeTuple(year, month, day); - - - - - - - - int yearNumber; - int week = %CPPSELF.%FUNCTION_NAME(&yearNumber); - %PYARG_0 = Shiboken::makeTuple(week, yearNumber); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - return %CPPSELF.size(); - - - - - if (_i < 0 || _i >= %CPPSELF.size()) { - PyErr_SetString(PyExc_IndexError, "index out of bounds"); - return 0; - } - return %CONVERTTOPYTHON[bool](%CPPSELF.at(_i)); - - - - - PyObject* args = Py_BuildValue("(iiO)", _i, 1, _value); - PyObject* result = SbkQBitArrayFunc_setBit(self, args); - Py_DECREF(args); - Py_XDECREF(result); - return !result ? -1 : 0; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%CPPSELF.%FUNCTION_NAME(%1, %2, %PYARG_3)); - - - - - - - - - - - - - - - - - - - - - - - - - - %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%CPPSELF.%FUNCTION_NAME()); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // %FUNCTION_NAME() - disable generation of function call. - %PYARG_0 = %CONVERTTOPYTHON[bool](qobjectConnect(%1, %2, %CPPSELF, %3, %4)); - - - - - // %FUNCTION_NAME() - disable generation of function call. - %PYARG_0 = %CONVERTTOPYTHON[bool](qobjectConnect(%1, %2, %3, %4, %5)); - - - - - - - - - // %FUNCTION_NAME() - disable generation of function call. - %PYARG_0 = %CONVERTTOPYTHON[bool](qobjectConnectCallback(%1, %2, %PYARG_3, %4)); - - - - - - - - - // %FUNCTION_NAME() - disable generation of function call. - %PYARG_0 = %CONVERTTOPYTHON[bool](qobjectConnectCallback(%CPPSELF, %1, %PYARG_2, %3)); - - - - - - - - // %FUNCTION_NAME() - disable generation of function call. - %PYARG_0 = %CONVERTTOPYTHON[bool](qobjectConnect(%CPPSELF, %1, %2, %3, %4)); - - - - - %PYARG_0 = %CONVERTTOPYTHON[bool](PySide::SignalManager::instance().emitSignal(%CPPSELF, %1, %PYARG_2)); - - - - - // %FUNCTION_NAME() - disable generation of function call. - %PYARG_0 = %CONVERTTOPYTHON[bool](qobjectDisconnectCallback(%CPPSELF, %1, %2)); - - - - - // %FUNCTION_NAME() - disable generation of function call. - %PYARG_0 = %CONVERTTOPYTHON[bool](qobjectDisconnectCallback(%1, %2, %3)); - - - - static bool - qobjectInheritsInternal(PyTypeObject *objType, const char *class_name) - { - if (strcmp(objType->tp_name, class_name) == 0) - return true; - - PyTypeObject* base = (objType)->tp_base; - if (base == 0) - return false; - return qobjectInheritsInternal(base, class_name); - } - - - - bool retval = qobjectInheritsInternal(self->ob_type, %1) ? true : %CPPSELF.%FUNCTION_NAME(%1); - %PYARG_0 = %CONVERTTOPYTHON[bool](retval); - - - - - - - - - - %PYARG_0 = %CONVERTTOPYTHON[QObject*](_findChildHelper(%CPPSELF, %2, (PyTypeObject*)%PYARG_1)); - - - - - - - - %PYARG_0 = PyList_New(0); - _findChildrenHelper(%CPPSELF, %2, (PyTypeObject*)%PYARG_1, %PYARG_0); - - - - - - - - - - - - - - - - QString result; - if (QCoreApplication::instance()) { - PyObject *klass = PyObject_GetAttrString(%PYSELF, "__class__"); - PyObject *cname = PyObject_GetAttrString(klass, "__name__"); - result = QString(QCoreApplication::instance()->translate(PyString_AsString(cname), %1, %2, QCoreApplication::CodecForTr, %3)); - - Py_DECREF(klass); - Py_DECREF(cname); - } else { - result = QString(QString::fromLatin1(%1)); - } - %PYARG_0 = %CONVERTTOPYTHON[QString](result); - - - - - - - - - - - - QString result; - if (QCoreApplication::instance()) { - PyObject *klass = PyObject_GetAttrString(%PYSELF, "__class__"); - PyObject *cname = PyObject_GetAttrString(klass, "__name__"); - result = QString(QCoreApplication::instance()->translate(PyString_AsString(cname), %1, %2, QCoreApplication::UnicodeUTF8, %3)); - - Py_DECREF(klass); - Py_DECREF(cname); - } else { - result = QString(QString::fromLatin1(%1)); - } - %PYARG_0 = %CONVERTTOPYTHON[QString](result); - - - - - - // Avoid return +1 because SignalManager connect to "destroyed()" signal to control object timelife - int ret = %CPPSELF.%FUNCTION_NAME(%1); - if (ret > 0 && strcmp(%1, SIGNAL(destroyed())) == 0 && PySide::SignalManager::instance().hasConnectionWith(%CPPSELF)) - ret--; - %PYARG_0 = %CONVERTTOPYTHON[int](ret); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %0 = new %TYPE(%CONVERTTOCPP[QVariant](%PYARG_1)); - - - - - uint typeId = %CPPSELF.userType(); - if (typeId == qMetaTypeId<PyQt_PyObject>()) { - %PYARG_0 = %CPPSELF.value<PyQt_PyObject>(); - } else if (typeId == QVariant::String) { - %PYARG_0 = %CONVERTTOPYTHON[QString](%CPPSELF.toString()); - } else { - %PYARG_0 = Py_None; - Py_INCREF(Py_None); - } - - - - - if (%CPPSELF.isNull()) { - %PYARG_0 = Py_None; - Py_INCREF(Py_None); - } else if (%CPPSELF.userType() == qMetaTypeId<PyQt_PyObject>()) { - // emulate PyQt4 behaviour - PyObject* obj = %CPPSELF.value<PyQt_PyObject>(); - if (PySequence_Check(obj)) - %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE]("QVariantList"); - } - if (!%PYARG_0) - %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%CPPSELF.%FUNCTION_NAME()); - - - - - if (%CPPSELF.userType() == qMetaTypeId<PyQt_PyObject>()) { - PyObject* val = %CPPSELF.value<PyQt_PyObject>(); - if (PySequence_Check(val)) { - %PYARG_0 = val; - Py_INCREF(val); - } else { - %PYARG_0 = Py_None; - Py_INCREF(Py_None); - } - } else { - %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%CPPSELF.%FUNCTION_NAME()); - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - return %CPPSELF.count(); - - - - - if (_i < 0 || _i >= %CPPSELF.size()) { - PyErr_SetString(PyExc_IndexError, "index out of bounds"); - return 0; - } - return %CONVERTTOPYTHON[QString](%CPPSELF.at(_i)); - - - - - PyObject* args = Py_BuildValue("(nO)", _i, _value); - PyObject* result = SbkQStringListFunc_replace(self, args); - Py_DECREF(args); - Py_XDECREF(result); - return !result ? -1 : 0; - - - - - - - - - - - return 0; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - int size = PyString_Size(pyargs[0]); - %0 = new QByteArray(cpp_arg0, size); - - - - - - #if PY_VERSION_HEX < 0x03000000 - Shiboken::SbkType<QByteArray>()->tp_as_buffer = &SbkQByteArrayBufferProc; - Shiboken::SbkType<QByteArray>()->tp_flags |= Py_TPFLAGS_HAVE_GETCHARBUFFER; - #endif - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - char c = PyString_AS_STRING(%PYARG_1)[0]; - if (c) { - %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%CPPSELF.%FUNCTION_NAME(c)); - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %PYARG_0 = PyString_FromString(%CPPSELF.data()); - - - - - return %CPPSELF.count(); - - - - - if (_i < 0 || _i >= %CPPSELF.size()) { - PyErr_SetString(PyExc_IndexError, "index out of bounds"); - return 0; - } else { - char res[2]; - res[0] = %CPPSELF.at(_i); - res[1] = 0; - return PyString_FromString(res); - } - - - - - %CPPSELF.remove(_i, 1); - PyObject* args = Py_BuildValue("(nO)", _i, _value); - PyObject* result = SbkQByteArrayFunc_insert(self, args); - Py_DECREF(args); - Py_XDECREF(result); - return !result ? -1 : 0; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // %FUNCTION_NAME() - disable generation of c++ function call - Shiboken::AutoDecRef emptyTuple(PyTuple_New(0)); - PyObject* pyTimer = Shiboken::SbkType<QTimer>()->tp_new(Shiboken::SbkType<QTimer>(), emptyTuple, 0); - Shiboken::SbkType<QTimer>()->tp_init(pyTimer, emptyTuple, 0); - - QTimer* timer = Converter<QTimer*>::toCpp(pyTimer); - PyObject* result = PyObject_CallMethod(pyTimer, const_cast<char*>("connect"), const_cast<char*>("OsOs"), pyTimer, SIGNAL(timeout()), %PYARG_2, %3); - Py_DECREF(result); - timer->setSingleShot(true); - timer->connect(timer, SIGNAL("timeout()"), timer, SLOT("deleteLater()")); - timer->start(%1); - - - - - // %FUNCTION_NAME() - disable generation of c++ function call - Shiboken::AutoDecRef emptyTuple(PyTuple_New(0)); - PyObject* pyTimer = Shiboken::SbkType<QTimer>()->tp_new(Shiboken::SbkType<QTimer>(), emptyTuple, 0); - Shiboken::SbkType<QTimer>()->tp_init(pyTimer, emptyTuple, 0); - QTimer* timer = Converter<QTimer*>::toCpp(pyTimer); - timer->setSingleShot(true); - timer->connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater())); - PyObject* result = PyObject_CallMethod(pyTimer, const_cast<char*>("connect"), const_cast<char*>("OsO"), pyTimer, SIGNAL(timeout()), pyargs[1]); - Py_DECREF(result); - timer->start(cpp_arg0); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - qint64 pid; - %RETURN_TYPE retval = %TYPE::%FUNCTION_NAME(%1, %2, %3, &pid); - %PYARG_0 = Shiboken::makeTuple(retval, pid); - - - - - - - - - - - -.. class:: QCoreApplication(args) - - Constructs a Qt kernel application. Kernel applications are applications - without a graphical user interface. These type of applications are used - at the console or as server processes. - - The *args* argument is processed by the application, and made available - in a more convenient form by the :meth:`~QCoreApplication.arguments()` - method. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %PYARG_0 = (PyObject*)%CPPSELF.%FUNCTION_NAME(); - if (!%PYARG_0) - %PYARG_0 = Py_None; - Py_XINCREF(%PYARG_0); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // The normal here would be to use the 'reference-count' tag but this - // method is strongly tied to 'setTargetState' since both affect the same - // internal value in QAbstractTransition. - Shiboken::keepReference(reinterpret_cast<SbkBaseWrapper*>(%PYSELF), "setTargetState(QAbstractState*)1", %PYARG_1); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - for(int counter = 0; counter < %CPPSELF.animationCount(); ++counter ) { - PyObject* obj = %CONVERTTOPYTHON[QAbstractAnimation*](%CPPSELF.animationAt(counter)); - Shiboken::setParent(NULL, obj); - Py_DECREF(obj); - } - %CPPSELF.clear(); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - QString signalName(%2); - if (PySide::SignalManager::registerMetaMethod(%1, signalName.mid(1).toAscii().data(), QMetaMethod::Signal)) { - %PYARG_0 = %CONVERTTOPYTHON[QSignalTransition*](%CPPSELF->addTransition(%1, %2, %3)); - } else { - %PYARG_0 = Py_None; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %PYARG_0 = PySet_New(0); - foreach(QAbstractState* abs_state, %CPPSELF.configuration()) { - Shiboken::AutoDecRef obj(%CONVERTTOPYTHON[QAbstractState*](abs_state)); - Shiboken::setParent(self, obj); - PySet_Add(%PYARG_0, obj); - } - - - - - - %PYARG_0 = PyList_New(0); - foreach(QAbstractAnimation* abs_anim, %CPPSELF.defaultAnimations()) { - Shiboken::AutoDecRef obj(%CONVERTTOPYTHON[QAbstractAnimation*](abs_anim)); - Shiboken::setParent(self, obj); - PyList_Append(%PYARG_0, obj); - } - - - - - - - - - - - - - %PYARG_0 = PyString_FromFormat("2%s", QMetaObject::normalizedSignature(%1).constData()); - - - - - - %PYARG_0 = PyString_FromFormat("1%s", QMetaObject::normalizedSignature(%1).constData()); - - - - - (void)%1;%PYARG_0 = %PYARG_1; - - - (void)%1;%PYARG_0 = %PYARG_1; - - - (void)%1;%PYARG_0 = %PYARG_1; - - - (void)%1;%PYARG_0 = %PYARG_1; - - - - extern bool - qRegisterResourceData(int, - const unsigned char *, - const unsigned char *, - const unsigned char *); - - extern bool - qUnregisterResourceData(int, - const unsigned char *, - const unsigned char *, - const unsigned char *); - - - - %PYARG_0 = %CONVERTTOPYTHON[bool](%FUNCTION_NAME(%1, (uchar*)%2, (uchar*)%3, (uchar*)%4)); - - - - - %PYARG_0 = %CONVERTTOPYTHON[bool](%FUNCTION_NAME(%1, (uchar*)%2, (uchar*)%3, (uchar*)%4)); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PySide/QtCore/typesystem_core.xml.in b/PySide/QtCore/typesystem_core.xml.in new file mode 100644 index 0000000..9de2082 --- /dev/null +++ b/PySide/QtCore/typesystem_core.xml.in @@ -0,0 +1,24 @@ + + + + + + diff --git a/PySide/QtCore/typesystem_core_common.xml b/PySide/QtCore/typesystem_core_common.xml new file mode 100644 index 0000000..2e83131 --- /dev/null +++ b/PySide/QtCore/typesystem_core_common.xml @@ -0,0 +1,4097 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + // qFatal doesn't have a stream version, so we do a + // qWarning call followed by a qFatal() call using a + // literal. + qWarning() << %1; + qFatal("[A qFatal() call was made from Python code]"); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + return PyBool_FromLong((bool)%in); + + + + %out = %OUTTYPE(%in == Py_True); + + + + + + + + + bool py2kStrCheck(PyObject* obj) + { + #ifdef IS_PY3K + return false; + #else + return PyString_Check(obj); + #endif + } + + + + + + + const int N = %in.length(); + wchar_t* str = new wchar_t[N]; + %in.toWCharArray(str); + PyObject* %out = PyUnicode_FromWideChar(str, N); + delete[] str; + return %out; + + + + Py_UNICODE* unicode = PyUnicode_AS_UNICODE(%in); + #if defined(Py_UNICODE_WIDE) + // cast as Py_UNICODE can be a different type + %out = QString::fromUcs4((const uint*)unicode); + #else + %out = QString::fromUtf16(unicode, PyUnicode_GET_SIZE(%in)); + #endif + + + #ifndef IS_PY3K + const char* str = %CONVERTTOCPP[const char*](%in); + %out = %OUTTYPE(str); + #endif + + + %out = %OUTTYPE(); + + + + + + + + + const int N = %in.toString().length(); + wchar_t* str = new wchar_t[N]; + %in.toString().toWCharArray(str); + PyObject* %out = PyUnicode_FromWideChar(str, N); + delete[] str; + return %out; + + + + %out = %OUTTYPE(); + + + + + + + + wchar_t c = (wchar_t)%in.unicode(); + return PyUnicode_FromWideChar(&c, 1); + + + + char c = %CONVERTTOCPP[char](%in); + %out = %OUTTYPE(c); + + + int i = %CONVERTTOCPP[int](%in); + %out = %OUTTYPE(i); + + + %out = %OUTTYPE(); + + + + + + + + + + if (!%in.isValid()) + Py_RETURN_NONE; + + if (qstrcmp(%in.typeName(), "QVariantList") == 0) { + QList<QVariant> var = %in.value<QVariantList>(); + return %CONVERTTOPYTHON[QList<QVariant>](var); + } + + if (qstrcmp(%in.typeName(), "QStringList") == 0) { + QStringList var = %in.value<QStringList>(); + return %CONVERTTOPYTHON[QList<QString>](var); + } + + if (qstrcmp(%in.typeName(), "QVariantMap") == 0) { + QMap<QString, QVariant> var = %in.value<QVariantMap>(); + return %CONVERTTOPYTHON[QMap<QString, QVariant>](var); + } + + Shiboken::Conversions::SpecificConverter converter(cppInRef.typeName()); + if (converter) { + void* ptr = cppInRef.data(); + return converter.toPython(ptr); + } + PyErr_Format(PyExc_RuntimeError, "Can't find converter for '%s'.", %in.typeName()); + return 0; + + + + %out = %OUTTYPE(%in == Py_True); + + + %out = %OUTTYPE(); + + + QString in = %CONVERTTOCPP[QString](%in); + %out = %OUTTYPE(in); + + + QByteArray in = %CONVERTTOCPP[QByteArray](%in); + %out = %OUTTYPE(in); + + + double in = %CONVERTTOCPP[double](%in); + %out = %OUTTYPE(in); + + + int in = %CONVERTTOCPP[int](%in); + %out = %OUTTYPE(in); + + + qlonglong in = %CONVERTTOCPP[qlonglong](%in); + %out = %OUTTYPE(in); + + + int in = %CONVERTTOCPP[int](%in); + %out = %OUTTYPE(in); + + + // a class supported by QVariant? + int typeCode; + const char* typeName = QVariant_resolveMetaType(%in->ob_type, &typeCode); + if (!typeCode || !typeName) + return; + QVariant var(typeCode, (void*)0); + Shiboken::Conversions::SpecificConverter converter(typeName); + converter.toCpp(pyIn, var.data()); + %out = var; + + + QVariant ret = QVariant_convertToVariantMap(%in); + %out = ret.isValid() ? ret : QVariant::fromValue<PySide::PyObjectWrapper>(%in); + + + %out = QVariant_convertToVariantList(%in); + + + // Is a shiboken type not known by Qt + %out = QVariant::fromValue<PySide::PyObjectWrapper>(%in); + + + + + + static const char* QVariant_resolveMetaType(PyTypeObject* type, int* typeId) + { + if (PyObject_TypeCheck(type, &SbkObjectType_Type)) { + SbkObjectType* sbkType = (SbkObjectType*)type; + const char* typeName = Shiboken::ObjectType::getOriginalName(sbkType); + if (!typeName) + return 0; + bool valueType = '*' != typeName[qstrlen(typeName) - 1]; + // Do not convert user type of value + if (valueType &∓ Shiboken::ObjectType::isUserType(type)) + return 0; + int obTypeId = QMetaType::type(typeName); + if (obTypeId) { + *typeId = obTypeId; + return typeName; + } + // Do not resolve types to value type + if (valueType) + return 0; + // find in base types + if (type->tp_base) { + return QVariant_resolveMetaType(type->tp_base, typeId); + } else if (type->tp_bases) { + for(int i = 0; i < PyTuple_GET_SIZE(type->tp_bases); ++i) { + const char* derivedName = QVariant_resolveMetaType((PyTypeObject*)PyTuple_GET_ITEM(type->tp_bases, i), typeId); + if (derivedName) + return derivedName; + } + } + } + *typeId = 0; + return 0; + } + static QVariant QVariant_convertToValueList(PyObject* list) + { + if (PySequence_Size(list) < 1) + return QVariant(); + Shiboken::AutoDecRef element(PySequence_GetItem(list, 0)); + int typeId; + const char* typeName = QVariant_resolveMetaType(element.cast<PyTypeObject*>(), &typeId); + if (typeName) { + QByteArray listTypeName("QList<"); + listTypeName += typeName; + listTypeName += '>'; + typeId = QMetaType::type(listTypeName); + if (typeId > 0) { + Shiboken::Conversions::SpecificConverter converter(listTypeName); + if (converter) { + QVariant var(typeId, (void*)0); + converter.toCpp(list, &var); + return var; + } + qWarning() << "Type converter for :" << listTypeName << "not registered."; + } + } + return QVariant(); + } + static bool QVariant_isStringList(PyObject *list) + { + bool allString = true; + Shiboken::AutoDecRef fast(PySequence_Fast(list, "Failed to convert QVariantList")); + Py_ssize_t size = PySequence_Fast_GET_SIZE(fast.object()); + for(int i = 0; i < size; ++i) { + PyObject* item = PySequence_Fast_GET_ITEM(fast.object(), i); + if (!%CHECKTYPE[QString](item)) { + allString = false; + break; + } + } + return allString; + } + static QVariant QVariant_convertToVariantMap(PyObject* map) + { + Py_ssize_t pos = 0; + Shiboken::AutoDecRef keys(PyDict_Keys(map)); + if (!QVariant_isStringList(keys)) + return QVariant(); + PyObject* key; + PyObject* value; + QMap<QString,QVariant> ret; + while (PyDict_Next(map, &pos, &key, &value)) { + QString cppKey = %CONVERTTOCPP[QString](key); + QVariant cppValue = %CONVERTTOCPP[QVariant](value); + ret.insert(cppKey, cppValue); + } + return QVariant(ret); + } + static QVariant QVariant_convertToVariantList(PyObject* list) + { + if (QVariant_isStringList(list)) { + QList<QString > lst = %CONVERTTOCPP[QList<QString>](list); + return QVariant(QStringList(lst)); + } + QVariant valueList = QVariant_convertToValueList(list); + if (valueList.isValid()) + return valueList; + QList<QVariant> lst; + Shiboken::AutoDecRef fast(PySequence_Fast(list, "Failed to convert QVariantList")); + Py_ssize_t size = PySequence_Fast_GET_SIZE(fast.object()); + for (int i = 0; i < size; ++i) { + PyObject* pyItem = PySequence_Fast_GET_ITEM(fast.object(), i); + QVariant item = %CONVERTTOCPP[QVariant](pyItem); + lst.append(item); + } + return QVariant(lst); + } + + + + + + const char* typeName = QVariant::typeToName(%in); + PyObject* %out; + PyTypeObject* pyType = 0; + if (typeName) + pyType = Shiboken::Conversions::getPythonTypeObject(typeName); + %out = pyType ? ((PyObject*)pyType) : Py_None; + Py_INCREF(%out); + return %out; + + + + %out = QVariant::Invalid; + + + const char* typeName; + if (Shiboken::String::checkType((PyTypeObject*)%in)) + typeName = "QString"; + else if (%in == (PyObject*)&PyFloat_Type) + typeName = "double"; // float is a UserType in QVariant. + else if (%in == (PyObject*)&PyLong_Type) + typeName = "int"; // long is a UserType in QVariant. + else if (%in->ob_type == &SbkObjectType_Type) + typeName = Shiboken::ObjectType::getOriginalName((SbkObjectType*)%in); + else + typeName = ((PyTypeObject*)%in)->tp_name; + %out = QVariant::nameToType(typeName); + + + %out = QVariant::nameToType(Shiboken::String::toCString(%in)); + + + %out = QVariant::nameToType("QVariantMap"); + + + const char* typeName; + if (QVariantType_isStringList(%in)) + typeName = "QStringList"; + else + typeName = "QVariantList"; + %out = QVariant::nameToType(typeName); + + + + + + + + Shiboken::Conversions::registerConverterName(SbkPySide_QtCoreTypeConverters[SBK_QTCORE_QMAP_QSTRING_QVARIANT_IDX], "QVariantMap"); + + + + static bool QVariantType_isStringList(PyObject* list) + { + bool allString = true; + Shiboken::AutoDecRef fast(PySequence_Fast(list, "Failed to convert QVariantList")); + Py_ssize_t size = PySequence_Fast_GET_SIZE(fast.object()); + for(int i=0; i < size; i++) { + PyObject* item = PySequence_Fast_GET_ITEM(fast.object(), i); + if (!%CHECKTYPE[QString](item)) { + allString = false; + break; + } + } + return allString; + } + static bool QVariantType_checkAllStringKeys(PyObject* dict) + { + Shiboken::AutoDecRef keys(PyDict_Keys(dict)); + return QVariantType_isStringList(keys); + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PyObject* %out = PyTuple_New(2); + PyTuple_SET_ITEM(%out, 0, %CONVERTTOPYTHON[%INTYPE_0](%in.first)); + PyTuple_SET_ITEM(%out, 1, %CONVERTTOPYTHON[%INTYPE_1](%in.second)); + return %out; + + + + %out.first = %CONVERTTOCPP[%OUTTYPE_0](PySequence_Fast_GET_ITEM(%in, 0)); + %out.second = %CONVERTTOCPP[%OUTTYPE_1](PySequence_Fast_GET_ITEM(%in, 1)); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + double _abs = qAbs(%1); + %PYARG_0 = %CONVERTTOPYTHON[double](_abs); + + + + + namespace PySide { + static QStack<PyObject*> globalPostRoutineFunctions; + void globalPostRoutineCallback() + { + foreach(PyObject* callback, globalPostRoutineFunctions) { + Shiboken::AutoDecRef result(PyObject_CallObject(callback, NULL)); + Py_DECREF(callback); + } + globalPostRoutineFunctions.clear(); + } + void addPostRoutine(PyObject* callback) + { + if (PyCallable_Check(callback)) { + globalPostRoutineFunctions << callback; + Py_INCREF(callback); + } else { + PyErr_SetString(PyExc_TypeError, "qAddPostRoutine: The argument must be a callable object."); + } + } + } // namespace + + + + PySide::addPostRoutine(%1); + + + + qAddPostRoutine(PySide::globalPostRoutineCallback); + + + + QList<QByteArray> version = QByteArray(qVersion()).split('.'); + PyObject* pyQtVersion = PyTuple_New(3); + for (int i = 0; i < 3; ++i) + PyTuple_SET_ITEM(pyQtVersion, i, PyInt_FromLong(version[i].toInt())); + PyModule_AddObject(module, "__version_info__", pyQtVersion); + PyModule_AddStringConstant(module, "__version__", qVersion()); + + + + { // Avoid name clash + Shiboken::AutoDecRef atexit(Shiboken::Module::import("atexit")); + Shiboken::AutoDecRef regFunc(PyObject_GetAttrString(atexit, "register")); + PyObject* shutDownFunc = PyObject_GetAttrString(module, "__moduleShutdown"); + Shiboken::AutoDecRef args(PyTuple_New(1)); + PyTuple_SET_ITEM(args, 0, shutDownFunc); + Shiboken::AutoDecRef retval(PyObject_Call(regFunc, args, 0)); + Q_ASSERT(!retval.isNull()); + } + + + + + PySide::runCleanupFunctions(); + + + + + + Shiboken::Conversions::registerConverterName(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], "unicode"); + Shiboken::Conversions::registerConverterName(SbkPySide_QtCoreTypeConverters[SBK_QSTRING_IDX], "str"); + Shiboken::Conversions::registerConverterName(SbkPySide_QtCoreTypeConverters[SBK_QTCORE_QLIST_QVARIANT_IDX], "QVariantList"); + + PySide::init(module); + Py_AtExit(QtCoreModuleExit); + + + #include <pyside.h> + + + + // Define a global variable to handle qInstallMsgHandler callback + static PyObject* qtmsghandler = 0; + + static void msgHandlerCallback(QtMsgType type, const char* msg) + { + Shiboken::GilState state; + Shiboken::AutoDecRef arglist(PyTuple_New(2)); + PyTuple_SET_ITEM(arglist, 0, %CONVERTTOPYTHON[QtMsgType](type)); + PyTuple_SET_ITEM(arglist, 1, %CONVERTTOPYTHON[const char*](msg)); + Shiboken::AutoDecRef ret(PyObject_CallObject(qtmsghandler, arglist)); + } + static void QtCoreModuleExit() + { + PySide::SignalManager::instance().clear(); + } + + + + if (%PYARG_1 == Py_None) { + qInstallMsgHandler(0); + %PYARG_0 = qtmsghandler ? qtmsghandler : Py_None; + qtmsghandler = 0; + } else if (!PyCallable_Check(%PYARG_1)) { + PyErr_SetString(PyExc_TypeError, "parameter must be callable"); + } else { + %PYARG_0 = qtmsghandler ? qtmsghandler : Py_None; + Py_INCREF(%PYARG_1); + qtmsghandler = %PYARG_1; + qInstallMsgHandler(msgHandlerCallback); + } + + if (%PYARG_0 == Py_None) + Py_INCREF(%PYARG_0); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + namespace PySide { + template<> inline uint hash(const QLine& v) { + return qHash(qMakePair(qMakePair(v.x1(), v.y1()), qMakePair(v.x2(), v.y2()))); + } + }; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + QPointF p; + %RETURN_TYPE retval = %CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES, &p); + %PYARG_0 = PyTuple_New(2); + PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](retval)); + PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QPointF](p)); + + + + + + + Returns a read only buffer object pointing to the segment of data that this resource represents. If the resource is compressed the data returns is compressed and qUncompress() must be used to access the data. If the resource is a directory None is returned. + + + + + + const void* d = %CPPSELF.%FUNCTION_NAME(); + if (d) { + %PYARG_0 = Shiboken::Buffer::newObject(d, %CPPSELF.size()); + } else { + Py_INCREF(Py_None); + %PYARG_0 = Py_None; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %out = %OUTTYPE(); + + + int day = PyDateTime_GET_DAY(%in); + int month = PyDateTime_GET_MONTH(%in); + int year = PyDateTime_GET_YEAR(%in); + %out = %OUTTYPE(year, month, day); + + + + + + + + + + + + + + + + + + + + + + + + + + + if (!PyDateTimeAPI) PySideDateTime_IMPORT; + %PYARG_0 = PyDate_FromDate(%CPPSELF.year(), %CPPSELF.month(), %CPPSELF.day()); + + + + + + + + + + + + + + + + + int year, month, day; + %BEGIN_ALLOW_THREADS + %CPPSELF.%FUNCTION_NAME(&year, &month, &day); + %END_ALLOW_THREADS + %PYARG_0 = PyTuple_New(3); + PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[int](year)); + PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[int](month)); + PyTuple_SET_ITEM(%PYARG_0, 2, %CONVERTTOPYTHON[int](day)); + + + + + + + + + + + int yearNumber; + %BEGIN_ALLOW_THREADS + int week = %CPPSELF.%FUNCTION_NAME(&yearNumber); + %END_ALLOW_THREADS + %PYARG_0 = PyTuple_New(2); + PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[int](week)); + PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[int](yearNumber)); + + + + + + + + + + + + + + + %out = %OUTTYPE(); + + + int day = PyDateTime_GET_DAY(%in); + int month = PyDateTime_GET_MONTH(%in); + int year = PyDateTime_GET_YEAR(%in); + int hour = PyDateTime_DATE_GET_HOUR(%in); + int min = PyDateTime_DATE_GET_MINUTE(%in); + int sec = PyDateTime_DATE_GET_SECOND(%in); + int usec = PyDateTime_DATE_GET_MICROSECOND(%in); + %out = %OUTTYPE(QDate(year, month, day), QTime(hour, min, sec, usec/1000)); + + + + + + + + + + + + + QDate date(%1, %2, %3); + QTime time(%4, %5, %6, %7); + %0 = new %TYPE(date, time, Qt::TimeSpec(%8)); + + + + + QDate date(%1, %2, %3); + QTime time(%4, %5, %6); + %0 = new %TYPE(date, time); + + + + + + + + + + + + + + + + + + + + + QDate date = %CPPSELF.date(); + QTime time = %CPPSELF.time(); + if (!PyDateTimeAPI) PySideDateTime_IMPORT; + %PYARG_0 = PyDateTime_FromDateAndTime(date.year(), date.month(), date.day(), time.hour(), time.minute(), time.second(), time.msec()*1000); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + namespace PySide { + template<> inline uint hash(const QPoint& v) { + return qHash(qMakePair(v.x(), v.y())); + } + }; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + namespace PySide { + template<> inline uint hash(const QRect& v) { + return qHash(qMakePair(qMakePair(v.x(), v.y()), qMakePair(v.width(), v.height()))); + } + }; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + namespace PySide { + template<> inline uint hash(const QSize& v) { + return qHash(qMakePair(v.width(), v.height())); + } + }; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %out = %OUTTYPE(); + + + int hour = PyDateTime_TIME_GET_HOUR(%in); + int min = PyDateTime_TIME_GET_MINUTE(%in); + int sec = PyDateTime_TIME_GET_SECOND(%in); + int usec = PyDateTime_TIME_GET_MICROSECOND(%in); + %out = %OUTTYPE(hour, min, sec, usec/1000); + + + + + + + + + + + + + + + + + + + + + + + + + + + if (!PyDateTimeAPI) PySideDateTime_IMPORT; + %PYARG_0 = PyTime_FromTime(%CPPSELF.hour(), %CPPSELF.minute(), %CPPSELF.second(), %CPPSELF.msec()*1000); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + return %CPPSELF.size(); + + + + + if (_i < 0 || _i >= %CPPSELF.size()) { + PyErr_SetString(PyExc_IndexError, "index out of bounds"); + return 0; + } + bool ret = %CPPSELF.at(_i); + return %CONVERTTOPYTHON[bool](ret); + + + + + PyObject* args = Py_BuildValue("(iiO)", _i, 1, _value); + PyObject* result = Sbk_QBitArrayFunc_setBit(self, args); + Py_DECREF(args); + Py_XDECREF(result); + return !result ? -1 : 0; + + + + + + + + + + + + + + + + + + + + + + %CPPSELF.unlock(); + + + + + + + + + + + + + + %CPPSELF.unlock(); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(%1, %2, %PYARG_3); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + Creates a model index for the given row and column with the internal pointer ptr. + When using a QSortFilterProxyModel, its indexes have their own internal pointer. It is not advisable to access this internal pointer outside of the model. Use the data() function instead. + This function provides a consistent interface that model subclasses must use to create model indexes. + + .. warning:: Because of some Qt/Python itegration rules, the ptr argument do not get the reference incremented during the QModelIndex life time. So it is necessary to keep the object used on ptr argument alive during the whole process. Do not destroy the object if you are not sure about that. + + + + + + + + + + + + + + + + + + + + + + + + %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + // %FUNCTION_NAME() - disable generation of function call. + %RETURN_TYPE %0 = qobjectConnect(%1, %2, %CPPSELF, %3, %4); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + + + + // %FUNCTION_NAME() - disable generation of function call. + %RETURN_TYPE %0 = qobjectConnect(%1, %2, %3, %4, %5); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + + + + + + // %FUNCTION_NAME() - disable generation of function call. + %RETURN_TYPE %0 = qobjectConnectCallback(%1, %2, %PYARG_3, %4); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + + + + + + // %FUNCTION_NAME() - disable generation of function call. + %RETURN_TYPE %0 = qobjectConnectCallback(%CPPSELF, %1, %PYARG_2, %3); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + + + + + // %FUNCTION_NAME() - disable generation of function call. + %RETURN_TYPE %0 = qobjectConnect(%CPPSELF, %1, %2, %3, %4); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + %RETURN_TYPE %0 = PySide::SignalManager::instance().emitSignal(%CPPSELF, %1, %PYARG_2); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + // %FUNCTION_NAME() - disable generation of function call. + %RETURN_TYPE %0 = qobjectDisconnectCallback(%CPPSELF, %1, %2); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + // %FUNCTION_NAME() - disable generation of function call. + %RETURN_TYPE %0 = qobjectDisconnectCallback(%1, %2, %3); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + + QObject* child = _findChildHelper(%CPPSELF, %2, (PyTypeObject*)%PYARG_1); + %PYARG_0 = %CONVERTTOPYTHON[QObject*](child); + + + + + + + + + + + %PYARG_0 = PyList_New(0); + _findChildrenHelper(%CPPSELF, %2, (PyTypeObject*)%PYARG_1, %PYARG_0); + + + + + + + + + + + %PYARG_0 = PyList_New(0); + _findChildrenHelper(%CPPSELF, %2, (PyTypeObject*)%PYARG_1, %PYARG_0); + + + + + + + + + + + + + + + + QString result; + if (QCoreApplication::instance()) { + PyObject *klass = PyObject_GetAttrString(%PYSELF, "__class__"); + PyObject *cname = PyObject_GetAttrString(klass, "__name__"); + result = QString(QCoreApplication::instance()->translate(Shiboken::String::toCString(cname), %1, %2, QCoreApplication::CodecForTr, %3)); + + Py_DECREF(klass); + Py_DECREF(cname); + } else { + result = QString(QString::fromLatin1(%1)); + } + %PYARG_0 = %CONVERTTOPYTHON[QString](result); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + // Avoid return +1 because SignalManager connect to "destroyed()" signal to control object timelife + int ret = %CPPSELF.%FUNCTION_NAME(%1); + if (ret > 0 && ((strcmp(%1, SIGNAL(destroyed())) == 0) || (strcmp(%1, SIGNAL(destroyed(QObject*))) == 0))) + ret -= PySide::SignalManager::instance().countConnectionsWith(%CPPSELF); + + %PYARG_0 = %CONVERTTOPYTHON[int](ret); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <para>URLs can be represented in two forms: encoded or unencoded. The unencoded representation is suitable for showing to users, but the encoded representation is typically what you would send to a web server. For example, the unencoded URL "http://bühler.example.com" would be sent to the server as "http://xn--bhler-kva.example.com/List%20of%20applicants.xml".</para> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Replaces every occurrence of the regular expression in *sourceString* with *after*. + Returns a new Python string with the modified contents. For example: + + :: + + s = "Banana" + re = QRegExp("a[mn]") + s = re.replace(s, "ox") + # s == "Boxoxa" + + + For regular expressions containing capturing parentheses, occurrences of \1, \2, ..., in *after* + are replaced with rx.cap(1), cap(2), ... + + :: + + t = "A <i>bon mot</i>." + re = QRegExp("<i>([^<]*)</i>") + t = re.replace(t, "\\emph{\\1}") + # t == "A \\emph{bon mot}." + + + + %1.replace(*%CPPSELF, %2); + %PYARG_0 = %CONVERTTOPYTHON[QString](%1); + + + + + + + + + + + + + + + + + + + + + + %out = %OUTTYPE(); + + + %out = %OUTTYPE(Shiboken::String::toCString(%in), Shiboken::String::len(%in)); + + + #ifdef IS_PY3K + %out = %OUTTYPE(PyBytes_AS_STRING(%in), PyBytes_GET_SIZE(%in)); + #endif + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Shiboken::AutoDecRef str(PyUnicode_AsASCIIString(%PYARG_1)); + if (!str.isNull()) { + QByteArray b(PyBytes_AS_STRING(str.object()), PyBytes_GET_SIZE (str.object())); + b.prepend(*%CPPSELF); + %PYARG_0 = %CONVERTTOPYTHON[QByteArray](b); + } + + + + + Shiboken::AutoDecRef str(PyUnicode_AsASCIIString(%PYARG_1)); + if (!str.isNull()) { + QByteArray b(PyBytes_AS_STRING(str.object()), PyBytes_GET_SIZE(str.object())); + b.append(*%CPPSELF); + %PYARG_0 = %CONVERTTOPYTHON[QByteArray](b); + } + + + + + QByteArray ba = QByteArray(PyBytes_AS_STRING(%PYARG_1), PyBytes_GET_SIZE(%PYARG_1)) + *%CPPSELF; + %PYARG_0 = %CONVERTTOPYTHON[QByteArray](ba); + + + + + + + QByteArray b(((PyObject*)%PYSELF)->ob_type->tp_name); + PyObject* aux = Shiboken::String::fromStringAndSize(%CPPSELF.constData(), %CPPSELF.size()); + if (PyUnicode_CheckExact(aux)) { + PyObject* tmp = PyUnicode_AsASCIIString(aux); + Py_DECREF(aux); + aux = tmp; + } + b += "('"; + b += QByteArray(PyBytes_AS_STRING(aux), PyBytes_GET_SIZE(aux)); + b += "')"; + %PYARG_0 = Shiboken::String::fromStringAndSize(b.constData(), b.size()); + + + + + + + + + + + + + + + if (PyBytes_Check(%PYARG_1)) { + %0 = new QByteArray(PyBytes_AsString(%PYARG_1), PyBytes_GET_SIZE(%PYARG_1)); + } if (PyUnicode_CheckExact(%PYARG_1)) { + Shiboken::AutoDecRef data(PyUnicode_AsASCIIString(%PYARG_1)); + %0 = new QByteArray(PyBytes_AsString(data.object()), PyBytes_GET_SIZE(data.object())); + } else if (Shiboken::String::check(%PYARG_1)) { + %0 = new QByteArray(Shiboken::String::toCString(%PYARG_1), Shiboken::String::len(%PYARG_1)); + } + + + + + + #if PY_VERSION_HEX < 0x03000000 + Shiboken::SbkType<QByteArray>()->tp_as_buffer = &SbkQByteArrayBufferProc; + Shiboken::SbkType<QByteArray>()->tp_flags |= Py_TPFLAGS_HAVE_GETCHARBUFFER; + #endif + + + + + %PYARG_0 = PyBytes_FromStringAndSize(%CPPSELF.%FUNCTION_NAME(), %CPPSELF.size()); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(PyBytes_AsString(%PYARG_1), PyBytes_GET_SIZE(%PYARG_1)); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + + + + + + + + + + + + + + + + + %PYARG_0 = Shiboken::String::fromStringAndSize(%CPPSELF.constData(), %CPPSELF.size()); + + + + + return %CPPSELF.count(); + + + + + if (_i < 0 || _i >= %CPPSELF.size()) { + PyErr_SetString(PyExc_IndexError, "index out of bounds"); + return 0; + } else { + char res[2]; + res[0] = %CPPSELF.at(_i); + res[1] = 0; + return PyBytes_FromStringAndSize(res, 1); + } + + + + + %CPPSELF.remove(_i, 1); + PyObject* args = Py_BuildValue("(nO)", _i, _value); + PyObject* result = Sbk_QByteArrayFunc_insert(self, args); + Py_DECREF(args); + Py_XDECREF(result); + return !result ? -1 : 0; + + + + + Py_ssize_t max = %CPPSELF.count(); + _i1 = qBound(Py_ssize_t(0), _i1, max); + _i2 = qBound(Py_ssize_t(0), _i2, max); + QByteArray ba; + if (_i1 < _i2) + ba = %CPPSELF.mid(_i1, _i2 - _i1); + return %CONVERTTOPYTHON[QByteArray](ba); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + uchar* ptr = (uchar*) Shiboken::Buffer::getPointer(%PYARG_1); + %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(ptr); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + + + + %PYARG_0 = Shiboken::Buffer::newObject(%CPPSELF.%FUNCTION_NAME(%1, %2, %3), %2, Shiboken::Buffer::ReadWrite); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + QByteArray ba; + ba.resize(%2); + %CPPSELF.%FUNCTION_NAME(ba.data(), ba.size()); + %PYARG_0 = %CONVERTTOPYTHON[QByteArray](ba); + + + + + + + + %RETURN_TYPE %out; + if (PyBytes_Check(%PYARG_0)) { + %out = PyBytes_GET_SIZE((PyObject*)%PYARG_0); + memcpy(%1, PyBytes_AS_STRING((PyObject*)%PYARG_0), %out); + } else if (Shiboken::String::check(%PYARG_0)) { + %out = Shiboken::String::len((PyObject*)%PYARG_0); + memcpy(%1, Shiboken::String::toCString((PyObject*)%PYARG_0), %out); + } + + + + + + QByteArray ba; + ba.resize(%2); + %CPPSELF.%FUNCTION_NAME(ba.data(), ba.size()); + %PYARG_0 = %CONVERTTOPYTHON[QByteArray](ba); + + + + + + + + %RETURN_TYPE %out; + if (!PyBytes_Check(%PYARG_0)) { + %out = -1; + } else { + %out = PyBytes_GET_SIZE((PyObject*)%PYARG_0); + memcpy(%1, PyBytes_AS_STRING((PyObject*)%PYARG_0), %out); + } + + + + + + + + + + + + %CPPSELF.%FUNCTION_NAME(Shiboken::String::toCString(%PYARG_1), Shiboken::String::len(%PYARG_1)); + + + + + + + + + + + + + + + + + + + + + + %CPPSELF.unlock(); + + + + + + + + + + + + + + + + + + + + + + + Shiboken::AutoDecRef fileNo(PyObject_GetAttrString(%PYARG_1, "fileno")); + if (!fileNo.isNull()) { + Shiboken::AutoDecRef fileNoValue(PyObject_CallObject(fileNo, 0)); + if (%CHECKTYPE[int](fileNoValue)) { + int cppFileNoValue = %CONVERTTOCPP[int](fileNoValue); + %0 = new %TYPE(cppFileNoValue, %2, %3); + } + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Py_ssize_t size; + uchar* ptr = (uchar*) Shiboken::Buffer::getPointer(%PYARG_1, &size); + %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(const_cast<const uchar*>(ptr), size); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + + + + + + + + + + + + + + + + // %FUNCTION_NAME() - disable generation of c++ function call + (void) %2; // remove warning about unused variable + Shiboken::AutoDecRef emptyTuple(PyTuple_New(0)); + PyObject* pyTimer = Shiboken::SbkType<QTimer>()->tp_new(Shiboken::SbkType<QTimer>(), emptyTuple, 0); + Shiboken::SbkType<QTimer>()->tp_init(pyTimer, emptyTuple, 0); + + QTimer* timer = %CONVERTTOCPP[QTimer*](pyTimer); + Shiboken::AutoDecRef result( + PyObject_CallMethod(pyTimer, + const_cast<char*>("connect"), + const_cast<char*>("OsOs"), + pyTimer, + SIGNAL(timeout()), + %PYARG_2, + %3) + ); + Shiboken::Object::releaseOwnership((SbkObject*)pyTimer); + Py_XDECREF(pyTimer); + timer->setSingleShot(true); + timer->connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater())); + timer->start(%1); + + + + + // %FUNCTION_NAME() - disable generation of c++ function call + Shiboken::AutoDecRef emptyTuple(PyTuple_New(0)); + PyObject *pyTimer = Shiboken::SbkType<QTimer>()->tp_new(Shiboken::SbkType<QTimer>(), emptyTuple, 0); + Shiboken::SbkType<QTimer>()->tp_init(pyTimer, emptyTuple, 0); + QTimer* timer = %CONVERTTOCPP[QTimer*](pyTimer); + timer->setSingleShot(true); + + if (PyObject_TypeCheck(%2, &PySideSignalInstanceType)) { + PySideSignalInstance* signalInstance = reinterpret_cast<PySideSignalInstance*>(%2); + Shiboken::AutoDecRef signalSignature(Shiboken::String::fromFormat("2%s", PySide::Signal::getSignature(signalInstance))); + Shiboken::AutoDecRef result( + PyObject_CallMethod(pyTimer, + const_cast<char*>("connect"), + const_cast<char*>("OsOO"), + pyTimer, + SIGNAL(timeout()), + PySide::Signal::getObject(signalInstance), + signalSignature.object()) + ); + } else { + Shiboken::AutoDecRef result( + PyObject_CallMethod(pyTimer, + const_cast<char*>("connect"), + const_cast<char*>("OsO"), + pyTimer, + SIGNAL(timeout()), + %PYARG_2) + ); + } + + timer->connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater()), Qt::DirectConnection); + Shiboken::Object::releaseOwnership((SbkObject*)pyTimer); + Py_XDECREF(pyTimer); + timer->start(%1); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + uchar* ptr = (uchar*)Shiboken::Buffer::getPointer(%PYARG_1); + %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(ptr); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + + + + %PYARG_0 = Shiboken::Buffer::newObject(%CPPSELF.%FUNCTION_NAME(%1, %2, %3), %2, Shiboken::Buffer::ReadWrite); + + + + + + QByteArray ba; + ba.resize(%2); + %CPPSELF.%FUNCTION_NAME(ba.data(), ba.size()); + %PYARG_0 = PyBytes_FromStringAndSize(ba.constData(), ba.size()); + + + + + + + + %RETURN_TYPE %out; + if (!Shiboken::String::check(%PYARG_0)) { + %out = -1; + } else { + %out = PyBytes_GET_SIZE((PyObject*)%PYARG_0); + memcpy(%1, PyBytes_AS_STRING((PyObject*)%PYARG_0), %out); + } + + + + + + QByteArray ba; + ba.resize(%2); + %CPPSELF.%FUNCTION_NAME(ba.data(), ba.size()); + %PYARG_0 = PyBytes_FromStringAndSize(ba.constData(), ba.size()); + + + + + + + + %RETURN_TYPE %out; + if (!Shiboken::String::check(%PYARG_0)) { + %out = -1; + } else { + %out = PyBytes_GET_SIZE((PyObject*)%PYARG_0); + memcpy(%1, PyBytes_AS_STRING((PyObject*)%PYARG_0), %out); + } + + + + + + + + + + + + + + + + + + + + + + + + + + + qint64 pid; + %RETURN_TYPE retval = %TYPE::%FUNCTION_NAME(%1, %2, %3, &pid); + %PYARG_0 = PyTuple_New(2); + PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](retval)); + PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[qint64](pid)); + + + + + + + long result; + #ifdef WIN32 + _PROCESS_INFORMATION* procInfo = %CPPSELF.%FUNCTION_NAME(); + result = procInfo ? procInfo->dwProcessId : 0; + #else + result = %CPPSELF.%FUNCTION_NAME(); + #endif + %PYARG_0 = %CONVERTTOPYTHON[long](result); + + + + + + + + + + + + + + + + + + +.. class:: QCoreApplication(args) + + Constructs a Qt kernel application. Kernel applications are applications + without a graphical user interface. These type of applications are used + at the console or as server processes. + + The *args* argument is processed by the application, and made available + in a more convenient form by the :meth:`~QCoreApplication.arguments()` + method. + + + + QCoreApplication_constructor(%PYSELF, args, &%0); + + + + + + + + + + + + QCoreApplication* app = QCoreApplication::instance(); + PyObject* pyApp = Py_None; + if (app) { + pyApp = reinterpret_cast<PyObject*>(Shiboken::BindingManager::instance().retrieveWrapper(app)); + if (!pyApp) + pyApp = %CONVERTTOPYTHON[QCoreApplication*](app); // this will keep app live after python exit (extra ref) + } + %PYARG_0 = pyApp; + Py_XINCREF(%PYARG_0); + + + + + + + + + + + + + + + + + + + + + + + + + + + + long *%out = new long; + %out = 0; + + + + + + %RETURN_TYPE %out = false; + if (PySequence_Check(%PYARG_0) && (PySequence_Size(%PYARG_0) == 2)) { + Shiboken::AutoDecRef pyResult(PySequence_GetItem(%PYARG_0, 0)); + %out = %CONVERTTOCPP[bool](pyResult); + } + + + + %PYARG_0 = PyTuple_New(2); + PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](%0)); + PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[long](*result_out)); + delete result_out; + + + + + + + + + + + + + + + + + + + + + + .. warning:: QSettings.value can return different types (QVariant types) depending on the platform it's running on, so the safest way to use it is always casting the result to the desired type, e.g.: int(settings.value("myKey")) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + QByteArray data; + data.resize(%2); + int result = %CPPSELF.%FUNCTION_NAME(data.data(), data.size()); + if (result == -1) { + Py_INCREF(Py_None); + %PYARG_0 = Py_None; + } else { + %PYARG_0 = PyBytes_FromStringAndSize(data.data(), result); + } + + + + + + + + int r = %CPPSELF.%FUNCTION_NAME(%1, Shiboken::String::len(%PYARG_1)); + %PYARG_0 = %CONVERTTOPYTHON[int](r); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + QString& res = *%0; + %PYARG_0 = %CONVERTTOPYTHON[QString](res); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Shiboken::Object::releaseOwnership(%PYARG_0); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + for(int counter = 0; counter < %CPPSELF.animationCount(); ++counter ) { + QAbstractAnimation* animation = %CPPSELF.animationAt(counter); + PyObject* obj = %CONVERTTOPYTHON[QAbstractAnimation*](animation); + Shiboken::Object::setParent(NULL, obj); + Py_DECREF(obj); + } + %CPPSELF.clear(); + + + + + + + + + + + + + + PySideEasingCurveFunctor::init(); + + + + + QEasingCurve::EasingFunction func = PySideEasingCurveFunctor::createCustomFuntion(%PYSELF, %PYARG_1); + if (func) + %CPPSELF.%FUNCTION_NAME(func); + + + + + //%FUNCTION_NAME() + %PYARG_0 = PySideEasingCurveFunctor::callable(%PYSELF); + + + + + + + + + + + + + + + + + + + + + + + + + <code>machine = QStateMachine() + +s1 = new QState() +s11 = new QState(s1) +s12 = new QState(s1) + +s1h = QHistoryState(s1) +s1h.setDefaultState(s11) + +machine.addState(s1) + +s2 = QState() +machine.addState(s2) + +button = QPushButton() +# Clicking the button will cause the state machine to enter the child state +# that s1 was in the last time s1 was exited, or the history state's default +# state if s1 has never been entered. +s1.addTransition(button.clicked, s1h)</code> + + + + + + + + + + + + + + + + + + + + + + if (PyObject_TypeCheck(%1, &PySideSignalInstanceType)) { + PyObject* dataSource = PySide::Signal::getObject((PySideSignalInstance*) %PYARG_1); + Shiboken::AutoDecRef obType(PyObject_Type(dataSource)); + QObject* sender = %CONVERTTOCPP[QObject*](dataSource); + if (sender) { + const char* dataSignature = PySide::Signal::getSignature((PySideSignalInstance*) %PYARG_1); + QByteArray signature(dataSignature); // Append SIGNAL flag (2) + %0 = new QSignalTransitionWrapper(sender, "2" + signature, %2); + } + } + + + + + + + + + + + + + + + + + + QString signalName(%2); + if (PySide::SignalManager::registerMetaMethod(%1, signalName.mid(1).toAscii().data(), QMetaMethod::Signal)) { + QSignalTransition* %0 = %CPPSELF->addTransition(%1, %2, %3); + %PYARG_0 = %CONVERTTOPYTHON[QSignalTransition*](%0); + } else { + Py_INCREF(Py_None); + %PYARG_0 = Py_None; + } + + + + + + + + + + + + + + + // Obviously the label used by the following goto is a very awkward solution, + // since it refers to a name very tied to the generator implementation. + // Check bug #362 for more information on this + // http://bugs.openbossa.org/show_bug.cgi?id=362 + if (!PyObject_TypeCheck(%1, &PySideSignalInstanceType)) + goto Sbk_%TYPEFunc_%FUNCTION_NAME_TypeError; + PySideSignalInstance* signalInstance = reinterpret_cast<PySideSignalInstance*>(%1); + QObject* sender = %CONVERTTOCPP[QObject*](PySide::Signal::getObject(signalInstance)); + QSignalTransition* %0 = %CPPSELF->%FUNCTION_NAME(sender, PySide::Signal::getSignature(signalInstance), %2); + %PYARG_0 = %CONVERTTOPYTHON[QSignalTransition*](%0); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %PYARG_0 = PySet_New(0); + foreach(QAbstractState* abs_state, %CPPSELF.configuration()) { + Shiboken::AutoDecRef obj(%CONVERTTOPYTHON[QAbstractState*](abs_state)); + Shiboken::Object::setParent(self, obj); + PySet_Add(%PYARG_0, obj); + } + + + + + + + + %PYARG_0 = PyList_New(0); + foreach(QAbstractAnimation* abs_anim, %CPPSELF.defaultAnimations()) { + Shiboken::AutoDecRef obj(%CONVERTTOPYTHON[QAbstractAnimation*](abs_anim)); + Shiboken::Object::setParent(self, obj); + PyList_Append(%PYARG_0, obj); + } + + + + + + + + + + + %PYARG_0 = Shiboken::String::fromFormat("2%s", QMetaObject::normalizedSignature(%1).constData()); + + + + + + %PYARG_0 = Shiboken::String::fromFormat("1%s", QMetaObject::normalizedSignature(%1).constData()); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + extern bool + qRegisterResourceData(int, + const unsigned char *, + const unsigned char *, + const unsigned char *); + + extern bool + qUnregisterResourceData(int, + const unsigned char *, + const unsigned char *, + const unsigned char *); + + + + %RETURN_TYPE %0 = %FUNCTION_NAME(%1, (uchar*)PyBytes_AS_STRING(%PYARG_2), + (uchar*)PyBytes_AS_STRING(%PYARG_3), + (uchar*)PyBytes_AS_STRING(%PYARG_4)); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + %RETURN_TYPE %0 = %FUNCTION_NAME(%1, (uchar*)PyBytes_AS_STRING(%PYARG_2), + (uchar*)PyBytes_AS_STRING(%PYARG_3), + (uchar*)PyBytes_AS_STRING(%PYARG_4)); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PySide/QtCore/typesystem_core_mac.xml b/PySide/QtCore/typesystem_core_mac.xml new file mode 100644 index 0000000..0f9c511 --- /dev/null +++ b/PySide/QtCore/typesystem_core_mac.xml @@ -0,0 +1,23 @@ + + + + + diff --git a/PySide/QtCore/typesystem_core_maemo.xml b/PySide/QtCore/typesystem_core_maemo.xml new file mode 100644 index 0000000..eba223c --- /dev/null +++ b/PySide/QtCore/typesystem_core_maemo.xml @@ -0,0 +1,26 @@ + + + + + + + + diff --git a/PySide/QtCore/typesystem_core_win.xml b/PySide/QtCore/typesystem_core_win.xml new file mode 100644 index 0000000..26c7a82 --- /dev/null +++ b/PySide/QtCore/typesystem_core_win.xml @@ -0,0 +1,57 @@ + + + + + + + + #ifdef IS_PY3K + return PyCapsule_New(%in, 0, 0); + #else + return PyCObject_FromVoidPtr(%in, 0); + #endif + + + + %out = 0; + + + #ifdef IS_PY3K + %out = (%OUTTYPE)PyCapsule_GetPointer(%in, 0); + #else + %out = (%OUTTYPE)PyCObject_AsVoidPtr(%in); + #endif + + + + + + + + + + + + + + + + diff --git a/PySide/QtCore/typesystem_core_x11.xml b/PySide/QtCore/typesystem_core_x11.xml new file mode 100644 index 0000000..eba223c --- /dev/null +++ b/PySide/QtCore/typesystem_core_x11.xml @@ -0,0 +1,26 @@ + + + + + + + + diff --git a/PySide/QtDeclarative/CMakeLists.txt b/PySide/QtDeclarative/CMakeLists.txt index 587e3b5..c9ea931 100644 --- a/PySide/QtDeclarative/CMakeLists.txt +++ b/PySide/QtDeclarative/CMakeLists.txt @@ -1,11 +1,14 @@ project(QtDeclarative) +set(QtDeclarative_registerType "${CMAKE_CURRENT_SOURCE_DIR}/pysideqmlregistertype.cpp") + set(QtDeclarative_SRC ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtDeclarative/qdeclarativecomponent_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtDeclarative/qdeclarativecontext_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtDeclarative/qdeclarativeengine_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtDeclarative/qdeclarativeerror_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtDeclarative/qdeclarativeexpression_wrapper.cpp +${CMAKE_CURRENT_BINARY_DIR}/PySide/QtDeclarative/qdeclarativeextensioninterface_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtDeclarative/qdeclarativeextensionplugin_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtDeclarative/qdeclarativeimageprovider_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtDeclarative/qdeclarativeitem_wrapper.cpp @@ -20,40 +23,40 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtDeclarative/qdeclarativeview_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtDeclarative/qtdeclarative_module_wrapper.cpp ) -execute_generator(declarative QtDeclarative_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtGui_SOURCE_DIR}:${QtDeclarative_SOURCE_DIR}:${QtNetwork_SOURCE_DIR}:${QtNetwork_BINARY_DIR}") +set(QtDeclarative_typesystem_path "${QtCore_SOURCE_DIR}${PATH_SEP}${QtCore_BINARY_DIR}${PATH_SEP}${QtGui_SOURCE_DIR}${PATH_SEP}${QtNetwork_SOURCE_DIR}${PATH_SEP}${QtDeclarative_SOURCE_DIR}${PATH_SEP}${QtGui_BINARY_DIR}") -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ${QT_QTNETWORK_INCLUDE_DIR} - ${QT_QTDECLARATIVE_INCLUDE_DIR} - ${PYTHON_INCLUDE_PATH} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${QtGui_BINARY_DIR}/PySide/QtGui/ - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ${QtNetwork_BINARY_DIR}/PySide/QtNetwork/ - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtDeclarative) -add_library(QtDeclarative MODULE ${QtDeclarative_SRC}) -set_target_properties(QtDeclarative PROPERTIES PREFIX "") -target_link_libraries(QtDeclarative - pyside - ${PYTHON_LIBRARIES} - ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY} - ${QT_QTNETWORK_LIBRARY} - ${QT_QTSCRIPT_LIBRARY} - ${QT_QTSVG_LIBRARY} - ${QT_QTSQL_LIBRARY} - ${QT_QTXMLPATTERNS_LIBRARY} - ${QT_QTOPENGL_LIBRARY} - ${QT_QTDECLARATIVE_LIBRARY}) -add_dependencies(QtDeclarative QtGui) -add_dependencies(QtDeclarative QtNetwork) +set(QtDeclarative_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTGUI_INCLUDE_DIR} + ${QT_QTNETWORK_INCLUDE_DIR} + ${QT_QTDECLARATIVE_INCLUDE_DIR} + ${SHIBOKEN_PYTHON_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${QtGui_BINARY_DIR}/PySide/QtGui/ + ${QtCore_BINARY_DIR}/PySide/QtCore/ + ${QtNetwork_BINARY_DIR}/PySide/QtNetwork/ + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtDeclarative) -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtDeclarative${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtDeclarative/pyside_qtdeclarative_python.h - DESTINATION include/PySide/QtDeclarative/) +set(QtDeclarative_libraries pyside + ${SHIBOKEN_PYTHON_LIBRARIES} + ${QT_QTCORE_LIBRARY} + ${QT_QTGUI_LIBRARY} + ${QT_QTNETWORK_LIBRARY} + ${QT_QTSCRIPT_LIBRARY} + ${QT_QTSVG_LIBRARY} + ${QT_QTSQL_LIBRARY} + ${QT_QTXMLPATTERNS_LIBRARY} + ${QT_QTOPENGL_LIBRARY} + ${QT_QTDECLARATIVE_LIBRARY}) + +set(QtDeclarative_deps QtGui QtNetwork) + +create_pyside_module(QtDeclarative + QtDeclarative_include_dirs + QtDeclarative_libraries + QtDeclarative_deps + QtDeclarative_typesystem_path + QtDeclarative_SRC + QtDeclarative_registerType) diff --git a/PySide/QtDeclarative/pysideqmlregistertype.cpp b/PySide/QtDeclarative/pysideqmlregistertype.cpp new file mode 100644 index 0000000..4efc4bf --- /dev/null +++ b/PySide/QtDeclarative/pysideqmlregistertype.cpp @@ -0,0 +1,366 @@ +/* + * This file is part of the Shiboken Python Bindings Generator project. + * + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * + * Contact: PySide team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "pysideqmlregistertype.h" +// Qt +#include +#include +#include +// shiboken +#include +#include +#include +// pyside +#include +#include +#include + +// auto generated headers +#include "qdeclarativeitem_wrapper.h" +#include "pyside_qtcore_python.h" +#include "pyside_qtdeclarative_python.h" + +#ifndef PYSIDE_MAX_QML_TYPES +// Maximum number of different types the user cna export to QML using qmlRegisterType. +#define PYSIDE_MAX_QML_TYPES 50 +#endif + +// Forward declarations +static void propListMetaCall(PySideProperty* pp, PyObject* self, QMetaObject::Call call, void** args); + + +// All registered python types +static PyObject* pyTypes[PYSIDE_MAX_QML_TYPES]; +static void (*createFuncs[PYSIDE_MAX_QML_TYPES])(void*); + +// Mutex used to avoid race condition on PySide::nextQObjectMemoryAddr +static QMutex nextQmlElementMutex; + +template +struct ElementFactoryBase +{ + static void createInto(void* memory) + { + QMutexLocker locker(&nextQmlElementMutex); + PySide::setNextQObjectMemoryAddr(memory); + Shiboken::GilState state; + PyObject* obj = PyObject_CallObject(pyTypes[N], 0); + if (!obj || PyErr_Occurred()) + PyErr_Print(); + PySide::setNextQObjectMemoryAddr(0); + } +}; + +template +struct ElementFactory : ElementFactoryBase +{ + static void init() + { + createFuncs[N] = &ElementFactoryBase::createInto; + ElementFactory::init(); + } +}; + +template<> +struct ElementFactory<0> : ElementFactoryBase<0> +{ + static void init() + { + createFuncs[0] = &ElementFactoryBase<0>::createInto; + } +}; + +int PySide::qmlRegisterType(PyObject* pyObj, const char* uri, int versionMajor, int versionMinor, const char* qmlName) +{ + using namespace Shiboken; + + static PyTypeObject* qobjectType = Shiboken::Conversions::getPythonTypeObject("QObject*"); + static PyTypeObject* qdeclarativeType = Shiboken::Conversions::getPythonTypeObject("QDeclarativeItem*"); + assert(qobjectType); + static int nextType = 0; + + if (nextType >= PYSIDE_MAX_QML_TYPES) { + PyErr_Format(PyExc_TypeError, "QML doesn't really like language bindings, so you can only export %d types to QML.", PYSIDE_MAX_QML_TYPES); + return -1; + } + + if (!PySequence_Contains(((PyTypeObject*)pyObj)->tp_mro, (PyObject*)qobjectType)) { + PyErr_Format(PyExc_TypeError, "A type inherited from %s expected, got %s.", qobjectType->tp_name, ((PyTypeObject*)pyObj)->tp_name); + return -1; + } + + bool isDeclarativeType = PySequence_Contains(((PyTypeObject*)pyObj)->tp_mro, (PyObject*)qdeclarativeType); + + QMetaObject* metaObject = reinterpret_cast(ObjectType::getTypeUserData(reinterpret_cast(pyObj))); + Q_ASSERT(metaObject); + + // Inc ref the type object, don't worry about dec ref them because there's no way to unregister a QML type + Py_INCREF(pyObj); + + // All ready... now the ugly code begins... :-) + pyTypes[nextType] = pyObj; + + // Init proxy object static meta object + QDeclarativePrivate::RegisterType type; + type.version = 0; + if (isDeclarativeType) { + type.typeId = qMetaTypeId(); + type.listId = qMetaTypeId >(); + + type.attachedPropertiesFunction = QDeclarativePrivate::attachedPropertiesFunc(); + type.attachedPropertiesMetaObject = QDeclarativePrivate::attachedPropertiesMetaObject(); + + type.parserStatusCast = QDeclarativePrivate::StaticCastSelector::cast(); + type.valueSourceCast = QDeclarativePrivate::StaticCastSelector::cast(); + type.valueInterceptorCast = QDeclarativePrivate::StaticCastSelector::cast(); + } else { + type.typeId = qMetaTypeId(); + type.listId = qMetaTypeId >(); + type.attachedPropertiesFunction = QDeclarativePrivate::attachedPropertiesFunc(); + type.attachedPropertiesMetaObject = QDeclarativePrivate::attachedPropertiesMetaObject(); + + type.parserStatusCast = QDeclarativePrivate::StaticCastSelector::cast(); + type.valueSourceCast = QDeclarativePrivate::StaticCastSelector::cast(); + type.valueInterceptorCast = QDeclarativePrivate::StaticCastSelector::cast(); + } + type.objectSize = PySide::getSizeOfQObject(reinterpret_cast(pyObj)); + type.create = createFuncs[nextType]; + type.uri = uri; + type.versionMajor = versionMajor; + type.versionMinor = versionMinor; + type.elementName = qmlName; + type.metaObject = metaObject; + + type.extensionObjectCreate = 0; + type.extensionMetaObject = 0; + type.customParser = 0; + + int qmlTypeId = QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type); + ++nextType; + return qmlTypeId; +} + +extern "C" +{ + +// This is the user data we store in the property. +struct DeclarativeListProperty +{ + PyTypeObject* type; + PyObject* append; + PyObject* at; + PyObject* clear; + PyObject* count; +}; + +static int propListTpInit(PyObject* self, PyObject* args, PyObject* kwds) +{ + static const char *kwlist[] = {"type", "append", "at", "clear", "count", 0}; + PySideProperty* pySelf = reinterpret_cast(self); + DeclarativeListProperty* data = new DeclarativeListProperty; + memset(data, 0, sizeof(DeclarativeListProperty)); + + if (!PyArg_ParseTupleAndKeywords(args, kwds, + "OO|OOO:QtDeclarative.ListProperty", (char**) kwlist, + &data->type, + &data->append, + &data->at, + &data->clear, + &data->count)) { + return 0; + } + PySide::Property::setMetaCallHandler(pySelf, &propListMetaCall); + PySide::Property::setTypeName(pySelf, "QDeclarativeListProperty"); + PySide::Property::setUserData(pySelf, data); + + return 1; +} + +void propListTpFree(void* self) +{ + PySideProperty* pySelf = reinterpret_cast(self); + delete reinterpret_cast(PySide::Property::userData(pySelf)); + // calls base type constructor + Py_TYPE(pySelf)->tp_base->tp_free(self); +} + +PyTypeObject PropertyListType = { + PyVarObject_HEAD_INIT(0, 0) + "ListProperty", /*tp_name*/ + sizeof(PySideProperty), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + 0, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + 0, /*tp_doc */ + 0, /*tp_traverse */ + 0, /*tp_clear */ + 0, /*tp_richcompare */ + 0, /*tp_weaklistoffset */ + 0, /*tp_iter */ + 0, /*tp_iternext */ + 0, /*tp_methods */ + 0, /*tp_members */ + 0, /*tp_getset */ + &PySidePropertyType, /*tp_base */ + 0, /*tp_dict */ + 0, /*tp_descr_get */ + 0, /*tp_descr_set */ + 0, /*tp_dictoffset */ + propListTpInit, /*tp_init */ + 0, /*tp_alloc */ + 0, /*tp_new */ + propListTpFree, /*tp_free */ + 0, /*tp_is_gc */ + 0, /*tp_bases */ + 0, /*tp_mro */ + 0, /*tp_cache */ + 0, /*tp_subclasses */ + 0, /*tp_weaklist */ + 0, /*tp_del */ +}; + +} // extern "C" + +// Implementation of QDeclarativeListProperty::AppendFunction callback +void propListAppender(QDeclarativeListProperty* propList, QDeclarativeItem* item) +{ + Shiboken::GilState state; + + Shiboken::AutoDecRef args(PyTuple_New(2)); + PyTuple_SET_ITEM(args, 0, Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkPySide_QtCoreTypes[SBK_QOBJECT_IDX], propList->object)); + PyTuple_SET_ITEM(args, 1, Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkPySide_QtDeclarativeTypes[SBK_QDECLARATIVEITEM_IDX], item)); + + DeclarativeListProperty* data = reinterpret_cast(propList->data); + Shiboken::AutoDecRef retVal(PyObject_CallObject(data->append, args)); + + if (PyErr_Occurred()) + PyErr_Print(); +} + +// Implementation of QDeclarativeListProperty::CountFunction callback +int propListCount(QDeclarativeListProperty* propList) +{ + Shiboken::GilState state; + + Shiboken::AutoDecRef args(PyTuple_New(1)); + PyTuple_SET_ITEM(args, 0, Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkPySide_QtCoreTypes[SBK_QOBJECT_IDX], propList->object)); + + DeclarativeListProperty* data = reinterpret_cast(propList->data); + Shiboken::AutoDecRef retVal(PyObject_CallObject(data->count, args)); + + // Check return type + int cppResult = 0; + PythonToCppFunc pythonToCpp; + if (PyErr_Occurred()) + PyErr_Print(); + else if ((pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter(), retVal))) + pythonToCpp(retVal, &cppResult); + return cppResult; +} + +// Implementation of QDeclarativeListProperty::AtFunction callback +QDeclarativeItem* propListAt(QDeclarativeListProperty* propList, int index) +{ + Shiboken::GilState state; + + Shiboken::AutoDecRef args(PyTuple_New(2)); + PyTuple_SET_ITEM(args, 0, Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkPySide_QtCoreTypes[SBK_QOBJECT_IDX], propList->object)); + PyTuple_SET_ITEM(args, 1, Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter(), &index)); + + DeclarativeListProperty* data = reinterpret_cast(propList->data); + Shiboken::AutoDecRef retVal(PyObject_CallObject(data->at, args)); + + QDeclarativeItem* result = 0; + if (PyErr_Occurred()) + PyErr_Print(); + else if (PyType_IsSubtype(Py_TYPE(retVal), data->type)) + Shiboken::Conversions::pythonToCppPointer((SbkObjectType*)SbkPySide_QtCoreTypes[SBK_QDECLARATIVEITEM_IDX], retVal, &result); + return result; +} + +// Implementation of QDeclarativeListProperty::ClearFunction callback +void propListClear(QDeclarativeListProperty* propList) +{ + Shiboken::GilState state; + + Shiboken::AutoDecRef args(PyTuple_New(1)); + PyTuple_SET_ITEM(args, 0, Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkPySide_QtCoreTypes[SBK_QOBJECT_IDX], propList->object)); + + DeclarativeListProperty* data = reinterpret_cast(propList->data); + Shiboken::AutoDecRef retVal(PyObject_CallObject(data->clear, args)); + + if (PyErr_Occurred()) + PyErr_Print(); +} + +// qt_metacall specialization for ListProperties +static void propListMetaCall(PySideProperty* pp, PyObject* self, QMetaObject::Call call, void** args) +{ + if (call != QMetaObject::ReadProperty) + return; + + DeclarativeListProperty* data = reinterpret_cast(PySide::Property::userData(pp)); + QObject* qobj; + Shiboken::Conversions::pythonToCppPointer((SbkObjectType*)SbkPySide_QtCoreTypes[SBK_QOBJECT_IDX], self, &qobj); + QDeclarativeListProperty declProp(qobj, data, &propListAppender); + + if (data->count) + declProp.count = &propListCount; + if (data->at) + declProp.at = &propListAt; + if (data->clear) + declProp.clear = &propListClear; + + // Copy the data to the memory location requested by the meta call + void* v = args[0]; + *reinterpret_cast*>(v) = declProp; +} + + +void PySide::initQmlSupport(PyObject* module) +{ + ElementFactory::init(); + + // Export DeclarativeListProperty type + if (PyType_Ready(&PropertyListType) < 0) + return; + + Py_INCREF((PyObject*)&PropertyListType); + PyModule_AddObject(module, PropertyListType.tp_name, (PyObject*)&PropertyListType); + +} + + diff --git a/PySide/QtDeclarative/pysideqmlregistertype.h b/PySide/QtDeclarative/pysideqmlregistertype.h new file mode 100644 index 0000000..aa25200 --- /dev/null +++ b/PySide/QtDeclarative/pysideqmlregistertype.h @@ -0,0 +1,57 @@ +/* + * This file is part of the Shiboken Python Bindings Generator project. + * + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * + * Contact: PySide team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef PYSIDEQMLREGISTERTYPE_H +#define PYSIDEQMLREGISTERTYPE_H + +#include + +struct SbkObjectType; + +namespace PySide +{ + +extern void* nextQmlElementMemoryAddr; + +/** + * Init the QML support doign things like registering QtDeclarative.ListProperty and create the necessary stuff for + * qmlRegisterType. + * + * \param module QtDeclarative python module + */ +void initQmlSupport(PyObject* module); + +/** + * PySide implementation of qmlRegisterType function. + * + * \param pyObj Python type to be registered. + * \param uri QML element uri. + * \param versionMajor QML component major version. + * \param versionMinor QML component minor version. + * \param qmlName QML element name + * \return the metatype id of the registered type. + */ +int qmlRegisterType(PyObject* pyObj, const char* uri, int versionMajor, int versionMinor, const char* qmlName); + +} + +#endif diff --git a/PySide/QtDeclarative/typesystem_declarative.xml b/PySide/QtDeclarative/typesystem_declarative.xml index 30786e2..1bc18ba 100644 --- a/PySide/QtDeclarative/typesystem_declarative.xml +++ b/PySide/QtDeclarative/typesystem_declarative.xml @@ -1,39 +1,169 @@ + - - - + + + This function registers the Python type in the QML system with the name qmlName, in the library imported from uri having the version number composed from versionMajor and versionMinor. + Returns the QML type id. + + For example, this registers a Python class MySliderItem as a QML type named Slider for version 1.0 of a module called "com.mycompany.qmlcomponents": + + :: + + qmlRegisterType(MySliderItem, "com.mycompany.qmlcomponents", 1, 0, "Slider") + + Once this is registered, the type can be used in QML by importing the specified module name and version number: + + :: + + import com.mycompany.qmlcomponents 1.0 + + Slider { ... } + + Note that it's perfectly reasonable for a library to register types to older versions than the actual version of the library. Indeed, it is normal for the new library to allow QML written to previous versions to continue to work, even if more advanced versions of some of its types are available. + + + + int %0 = PySide::qmlRegisterType(%ARGUMENT_NAMES); + %PYARG_0 = %CONVERTTOPYTHON[int](%0); + + + + + + + + + + + + + PySide::initQmlSupport(module); + + + + + + + + + + + + QByteArray key("%FUNCTION_NAME_"); + key.append(%1.toLocal8Bit()); + Shiboken::Object::keepReference(reinterpret_cast<SbkObject*>(%PYSELF), key.constData(), %PYARG_2); + + + + + + + + + + + + + + + + + + + QString errorString; + %BEGIN_ALLOW_THREADS + %RETURN_TYPE ok_ = %CPPSELF.%FUNCTION_NAME(%1, %2, &errorString); + %END_ALLOW_THREADS + %PYARG_0 = PyTuple_New(2); + PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](ok_)); + PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QString](errorString)); + + - - + + + + + + + + + + - - - + + + + + + + + + - + + + + + + + - - - + + + + - + + <code># create our data +ownerData = QDeclarativePropertyMap() +ownerData.insert("name", "John Smith") +ownerData.insert("phone", "555-5555") + +# expose it to the UI layer +view = QDeclarativeView() +ctxt = view.rootContext() +ctxt.setContextProperty("owner", ownerData) + +view.setSource(QUrl.fromLocalFile("main.qml")) +view.show()</code> + - - - + + + + diff --git a/PySide/QtGui/CMakeLists.txt b/PySide/QtGui/CMakeLists.txt index e9f44d7..7625634 100644 --- a/PySide/QtGui/CMakeLists.txt +++ b/PySide/QtGui/CMakeLists.txt @@ -1,62 +1,22 @@ project(QtGui) -# Check QtGui support -macro(CHECK_QT_GUI_MACRO macro_display_name qt_macro module_sources global_sources) - if (DEFINED PYSIDE_${qt_macro}) - if (PYSIDE_${qt_macro}) - list(APPEND ${global_sources} ${${module_sources}}) - endif() - else() - set(SRC_FILE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test${qt_macro}.cxx) - file(WRITE ${SRC_FILE} - "#include \n" - "int main() { \n" - "#ifdef ${qt_macro}\n" - "#error not supported.\n" - "#endif\n" - "}\n") - - try_compile(Q_WORKS ${CMAKE_BINARY_DIR} - ${SRC_FILE} - CMAKE_FLAGS - -DINCLUDE_DIRECTORIES:STRING=${QT_QTGUI_INCLUDE_DIR}\;${QT_INCLUDE_DIR} - -DLINK_LIBRARIES:PATH=${QT_QTGUI_LIBRARY_RELEASE} - OUTPUT_VARIABLE OUTPUT) - - set("PYSIDE_${qt_macro}" ${Q_WORKS} CACHE STRING "Has this Qt module been found by pyside?") - if(Q_WORKS) - message(STATUS "Testing support to ${macro_display_name} -- enabled") - list(APPEND ${global_sources} ${${module_sources}}) - else() - message(STATUS "Testing support to ${macro_display_name} -- disabled") - endif() - endif() -endmacro(CHECK_QT_GUI_MACRO) - if(ENABLE_X11) - set(MODULE_NAME "x11") set(SPECIFIC_OS_FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qx11info_wrapper.cpp - ) + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qx11embedcontainer_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qx11embedwidget_wrapper.cpp + ) if(Q_WS_MAEMO_5) - set(AUTO_OS "MAEMO 5") - set(MODULE_NAME "maemo") set(SPECIFIC_OS_FILES ${SPECIFIC_OS_FILES} ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qabstractkineticscroller_wrapper.cpp ) - endif(Q_WS_MAEMO_5) - -elseif(ENABLE_MAC) - set(MODULE_NAME "mac") - set(SPECIFIC_OS_FILES - ) -endif(ENABLE_X11) - + endif() +endif() if (${QT_VERSION_MAJOR} EQUAL 4 AND ${QT_VERSION_MINOR} LESS 6) - set (QtGui_46_SRC ) + set(QtGui_46_SRC "") else() set(QtGui_46_SRC ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qmatrix2x2_wrapper.cpp @@ -69,6 +29,7 @@ else() ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qmatrix4x3_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qmatrix4x4_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qgesture_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qgestureevent_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qgesturerecognizer_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qgraphicsanchor_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qgraphicsanchorlayout_wrapper.cpp @@ -87,6 +48,8 @@ else() ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qpinchgesture_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qquaternion_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qswipegesture_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qtapandholdgesture_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qtapgesture_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qtilerules_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qtouchevent_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qtouchevent_touchpoint_wrapper.cpp @@ -94,7 +57,34 @@ else() ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qvector3d_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qvector4d_wrapper.cpp ) -endif (${QT_VERSION_MAJOR} EQUAL 4 AND ${QT_VERSION_MINOR} LESS 6) +endif () + +if (${QT_VERSION_MAJOR} EQUAL 4 AND ${QT_VERSION_MINOR} LESS 7) + set(QtGui_47_SRC "") +else() + set(QtGui_47_SRC + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qpainter_pixmapfragment_wrapper.cpp + ) +endif() + +set(QtGui_OPTIONAL_SRC ) +set(QtGui_DROPPED_ENTRIES ) +check_qt_class(QtGui QAbstractPageSetupDialog QtGui_OPTIONAL_SRC QtGui_DROPPED_ENTRIES) +check_qt_class(QtGui QAbstractPrintDialog QtGui_OPTIONAL_SRC QtGui_DROPPED_ENTRIES) +check_qt_class(QtGui QGtkStyle QtGui_OPTIONAL_SRC QtGui_DROPPED_ENTRIES) +check_qt_class(QtGui QPageSetupDialog QtGui_OPTIONAL_SRC QtGui_DROPPED_ENTRIES) +check_qt_class(QtGui QPrintDialog QtGui_OPTIONAL_SRC QtGui_DROPPED_ENTRIES) +check_qt_class(QtGui QPrintEngine QtGui_OPTIONAL_SRC QtGui_DROPPED_ENTRIES) +check_qt_class(QtGui QPrintPreviewDialog QtGui_OPTIONAL_SRC QtGui_DROPPED_ENTRIES) +check_qt_class(QtGui QPrintPreviewWidget QtGui_OPTIONAL_SRC QtGui_DROPPED_ENTRIES) +check_qt_class(QtGui QPrinter QtGui_OPTIONAL_SRC QtGui_DROPPED_ENTRIES) +check_qt_class(QtGui QPrinterInfo QtGui_OPTIONAL_SRC QtGui_DROPPED_ENTRIES) +check_qt_class(QtGui QSessionManager QtGui_OPTIONAL_SRC QtGui_DROPPED_ENTRIES) +check_qt_class(QtGui QSizeGrip QtGui_OPTIONAL_SRC QtGui_DROPPED_ENTRIES) +check_qt_class(QtGui QSystemTrayIcon QtGui_OPTIONAL_SRC QtGui_DROPPED_ENTRIES) +check_qt_class(QtGui QMacStyle QtGui_OPTIONAL_SRC QtGui_DROPPED_ENTRIES) + +qt4_wrap_cpp(QPYTEXTOBJECT_MOC "${pyside_SOURCE_DIR}/qpytextobject.h") set(QtGui_SRC ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qabstractbutton_wrapper.cpp @@ -259,6 +249,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qpen_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qpictureio_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qpicture_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qpixmapcache_wrapper.cpp +${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qpixmapcache_key_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qpixmap_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qplaintextdocumentlayout_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qplaintextedit_wrapper.cpp @@ -268,6 +259,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qpolygon_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qprogressbar_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qprogressdialog_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qproxymodel_wrapper.cpp +${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qpytextobject_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qpushbutton_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qradialgradient_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qradiobutton_wrapper.cpp @@ -411,86 +403,38 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qwizard_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qworkspace_wrapper.cpp ${SPECIFIC_OS_FILES} +${QPYTEXTOBJECT_MOC} ${QtGui_46_SRC} +${QtGui_47_SRC} +${QtGui_OPTIONAL_SRC} ) -#Check GtkStyle -set(QT_GTKSTYLE_SRCS - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qgtkstyle_wrapper.cpp -) -CHECK_QT_GUI_MACRO("GtkStyle" QT_NO_STYLE_GTK QT_GTKSTYLE_SRCS QtGui_SRC) - -#Check SystemTray -set(QT_SYSTEMTRAY_SRCS - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qsystemtrayicon_wrapper.cpp -) -CHECK_QT_GUI_MACRO("SystemTray" QT_NO_SYSTEMTRAYICON QT_SYSTEMTRAY_SRCS QtGui_SRC) - -#Check QT_PRINTDIALOG support -set(QT_PRINTDIALOG_SRCS - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qabstractpagesetupdialog_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qabstractprintdialog_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qpagesetupdialog_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qprintdialog_wrapper.cpp -) -CHECK_QT_GUI_MACRO("PrintDialog Support" QT_NO_PRINTDIALOG QT_PRINTDIALOG_SRCS QtGui_SRC) - -#Check QT_PRITPREVIEW support -set(QT_PRINTPREVIEW_SRCS - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qprintpreviewwidget_wrapper.cpp -) -CHECK_QT_GUI_MACRO("PrintPreview Support" QT_NO_PRINTPREVIEWWIDGET QT_PRINTPREVIEW_SRCS QtGui_SRC) - -#Check QT_PRINTPREVIEWDIALOG support -set(QT_PRINTPREVIEWDIALOG_SRCS - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qprintpreviewdialog_wrapper.cpp -) -CHECK_QT_GUI_MACRO("PrintPreviewDialog Support" QT_NO_PRINTPREVIEWDIALOG QT_PRINTPREVIEWDIALOG_SRCS QtGui_SRC) - -#Check QT_PRINTER -set(QT_PRINTER_SRCS - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qprinter_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qprinterinfo_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qprintengine_wrapper.cpp -) -CHECK_QT_GUI_MACRO("Printer Support" QT_NO_PRINTER QT_PRINTER_SRCS QtGui_SRC) - -#Check QT_SIZEGRIP support -set(QT_SIZEGRIP_SRCS - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qsizegrip_wrapper.cpp -) -CHECK_QT_GUI_MACRO("SizeGrip Support" QT_NO_SIZEGRIP QT_SIZEGRIP_SRCS QtGui_SRC) - -#Check QT_SESSIONMANAGER support -set(QT_SESSIONMANAGER_SRCS - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qsessionmanager_wrapper.cpp -) -CHECK_QT_GUI_MACRO("SessionManager Support" QT_NO_SESSIONMANAGER QT_SESSIONMANAGER_SRCS QtGui_SRC) - -configure_file(typesystem_gui.xml.in +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/typesystem_gui.xml.in" "${CMAKE_CURRENT_BINARY_DIR}/typesystem_gui.xml" @ONLY) -execute_generator(gui QtGui_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtCore_BINARY_DIR}") +set(QtGui_typesystem_path "${QtCore_SOURCE_DIR}${PATH_SEP}${QtCore_BINARY_DIR}${PATH_SEP}${QtGui_SOURCE_DIR}") -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/ - ${QT_INCLUDE_DIR} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${PYTHON_INCLUDE_PATH} - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ) -add_library(QtGui MODULE ${QtGui_SRC}) -set_property(TARGET QtGui PROPERTY PREFIX "") -target_link_libraries(QtGui - pyside - ${PYTHON_LIBRARIES} +set(QtGui_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/ + ${pyside_SOURCE_DIR} + ${QT_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${SHIBOKEN_PYTHON_INCLUDE_DIR} + ${QtCore_BINARY_DIR}/PySide/QtCore/) +set(QtGui_libraries pyside + ${SHIBOKEN_PYTHON_LIBRARIES} ${SHIBOKEN_LIBRARY} - ${QT_QTGUI_LIBRARY} - ) -add_dependencies(QtGui QtCore) + ${QT_QTGUI_LIBRARY}) +set(QtGui_deps "QtCore") -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtGui${CMAKE_DEBUG_POSTFIX}.so DESTINATION "${SITE_PACKAGE}/PySide") -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/pyside_qtgui_python.h - DESTINATION include/PySide/QtGui/) +create_pyside_module(QtGui + QtGui_include_dirs + QtGui_libraries + QtGui_deps + QtGui_typesystem_path + QtGui_SRC + "" + ${CMAKE_CURRENT_BINARY_DIR}/typesystem_gui.xml) + +install(FILES ${pyside_SOURCE_DIR}/qpytextobject.h DESTINATION include/PySide/QtGui/) diff --git a/PySide/QtGui/glue/qapplication_init.cpp b/PySide/QtGui/glue/qapplication_init.cpp index 112b8e0..f2e972a 100644 --- a/PySide/QtGui/glue/qapplication_init.cpp +++ b/PySide/QtGui/glue/qapplication_init.cpp @@ -3,54 +3,48 @@ extern PyObject* moduleQtGui; static int QApplicationArgCount; static char** QApplicationArgValues; +static const char QAPP_MACRO[] = "qApp"; -void DeleteQApplicationAtExit() { - if (QApplication::instance()) { - //disconnect and decref all widgets used on signals before destroy qApp - PySide::SignalManager::instance().clear(); - delete QApplication::instance(); - for (int i = 0; i < QApplicationArgCount; ++i) - delete[] QApplicationArgValues[i]; - } -} - -int SbkQApplication_Init(PyObject* self, PyObject* args, PyObject*) +bool QApplicationConstructorStart(PyObject* argv) { if (QApplication::instance()) { PyErr_SetString(PyExc_RuntimeError, "A QApplication instance already exists."); - return -1; + return false; } - int numArgs = PyTuple_GET_SIZE(args); - if (numArgs != 1) { - PyErr_BadArgument(); - return -1; - } - - if (!PySequenceToArgcArgv(PyTuple_GET_ITEM(args, 0), &QApplicationArgCount, &QApplicationArgValues, "PySideApp")) { - PyErr_BadArgument(); - return -1; - } - - void* cptr = new QApplication(QApplicationArgCount, QApplicationArgValues); - Shiboken::setCppPointer(reinterpret_cast(self), - Shiboken::SbkType(), - cptr); - SbkBaseWrapper_setValidCppObject(self, 1); - Shiboken::BindingManager::instance().registerWrapper(reinterpret_cast(self), cptr); - - // Verify if qApp is in main module - const char QAPP_MACRO[] = "qApp"; - PyObject* localsDict = PyEval_GetLocals(); - if (localsDict) { - PyObject* qAppObj = PyDict_GetItemString(localsDict, QAPP_MACRO); - if (qAppObj) - PyDict_SetItemString(localsDict, QAPP_MACRO, self); - } - PyObject_SetAttrString(moduleQtGui, QAPP_MACRO, self); - - Py_INCREF(self); - Py_AtExit(DeleteQApplicationAtExit); - - return 1; + return Shiboken::sequenceToArgcArgv(argv, &QApplicationArgCount, &QApplicationArgValues, "PySideApp"); +} + +void QApplicationConstructorEnd(PyObject* self) +{ + // Verify if qApp is in main module + PyObject* globalsDict = PyEval_GetGlobals(); + if (globalsDict) { + PyObject* qAppObj = PyDict_GetItemString(globalsDict, QAPP_MACRO); + if (qAppObj) + PyDict_SetItemString(globalsDict, QAPP_MACRO, self); + } + + PyObject_SetAttrString(moduleQtGui, QAPP_MACRO, self); + PySide::registerCleanupFunction(&PySide::destroyQCoreApplication); + Py_INCREF(self); +} + +static void QApplicationConstructor(PyObject* self, PyObject* argv, QApplicationWrapper** cptr) +{ + if (QApplicationConstructorStart(argv)) { + *cptr = new QApplicationWrapper(QApplicationArgCount, QApplicationArgValues); + Shiboken::Object::releaseOwnership(reinterpret_cast(self)); + QApplicationConstructorEnd(self); + } +} + +template +static void QApplicationConstructor(PyObject* self, PyObject* argv, T extraArg, QApplicationWrapper** cptr) +{ + if (QApplicationConstructorStart(argv)) { + *cptr = new QApplicationWrapper(QApplicationArgCount, QApplicationArgValues, extraArg); + Shiboken::Object::releaseOwnership(reinterpret_cast(self)); + QApplicationConstructorEnd(self); + } } diff --git a/PySide/QtGui/glue/qlayout_help_functions.cpp b/PySide/QtGui/glue/qlayout_help_functions.cpp new file mode 100644 index 0000000..b366061 --- /dev/null +++ b/PySide/QtGui/glue/qlayout_help_functions.cpp @@ -0,0 +1,122 @@ +void addLayoutOwnership(QLayout* layout, QLayoutItem* item); +void removeLayoutOwnership(QLayout* layout, QWidget* widget); + +inline QByteArray retrieveObjectName(PyObject* obj) +{ + Shiboken::AutoDecRef objName(PyObject_Str(obj)); + return Shiboken::String::toCString(objName); +} + +inline void addLayoutOwnership(QLayout* layout, QWidget* widget) +{ + //transfer ownership to parent widget + QWidget *lw = layout->parentWidget(); + QWidget *pw = widget->parentWidget(); + + Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QWidget*](widget)); + + //Transfer parent to layout widget + if (pw && lw && pw != lw) + Shiboken::Object::setParent(0, pyChild); + + if (!lw && !pw) { + //keep the reference while the layout is orphan + Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QWidget*](layout)); + Shiboken::Object::keepReference(reinterpret_cast(pyParent.object()), retrieveObjectName(pyParent).data(), pyChild, true); + } else { + if (!lw) + lw = pw; + Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QWidget*](lw)); + Shiboken::Object::setParent(pyParent, pyChild); + } +} + +inline void addLayoutOwnership(QLayout* layout, QLayout* other) +{ + //transfer all children widgets from other to layout parent widget + QWidget* parent = layout->parentWidget(); + if (!parent) { + //keep the reference while the layout is orphan + Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QLayout*](layout)); + Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QLayout*](other)); + Shiboken::Object::keepReference(reinterpret_cast(pyParent.object()), retrieveObjectName(pyParent).data(), pyChild, true); + return; + } + + for (int i=0, i_max=other->count(); i < i_max; i++) { + QLayoutItem* item = other->itemAt(i); + if (PyErr_Occurred() || !item) + return; + addLayoutOwnership(layout, item); + } + + Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QLayout*](layout)); + Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QLayout*](other)); + Shiboken::Object::setParent(pyParent, pyChild); +} + +inline void addLayoutOwnership(QLayout* layout, QLayoutItem* item) +{ + if (!item) + return; + + QWidget* w = item->widget(); + if (w) + addLayoutOwnership(layout, w); + else { + QLayout* l = item->layout(); + if (l) + addLayoutOwnership(layout, l); + } + + Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QLayout*](layout)); + Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QLayoutItem*](item)); + Shiboken::Object::setParent(pyParent, pyChild); +} + +static void removeWidgetFromLayout(QLayout* layout, QWidget* widget) +{ + QWidget* parent = widget->parentWidget(); + + if (!parent) { + //remove reference on layout + Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QWidget*](layout)); + Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QWidget*](widget)); + Shiboken::Object::removeReference(reinterpret_cast(pyParent.object()), retrieveObjectName(pyParent).data(), pyChild); + } else { + //give the ownership to parent + Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QWidget*](parent)); + Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QWidget*](widget)); + Shiboken::Object::setParent(pyParent, pyChild); + } +} + +inline void removeLayoutOwnership(QLayout* layout, QLayoutItem* item) +{ + QWidget* w = item->widget(); + if (w) + removeWidgetFromLayout(layout, w); + else { + QLayout* l = item->layout(); + if (l) + removeLayoutOwnership(layout, l); + } + + Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QLayoutItem*](item)); + Shiboken::Object::invalidate(pyChild); + Shiboken::Object::setParent(0, pyChild); +} + +inline void removeLayoutOwnership(QLayout* layout, QWidget* widget) +{ + if (!widget) + return; + + for (int i=0, i_max=layout->count(); i < i_max; i++) { + QLayoutItem* item = layout->itemAt(i); + if (PyErr_Occurred() || !item) + return; + if (item->widget() == widget) + removeLayoutOwnership(layout, item); + } +} diff --git a/PySide/QtGui/glue/qlayout_help_functions.h b/PySide/QtGui/glue/qlayout_help_functions.h deleted file mode 100644 index 186e0ec..0000000 --- a/PySide/QtGui/glue/qlayout_help_functions.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef QLAYOUT_HELP_FUNCTIONS -#define QLAYOUT_HELP_FUNCTIONS - -void addLayoutOwnership(QLayout *layout, QLayoutItem *item); - -inline void addLayoutOwnership(QLayout *layout, QWidget *widget) -{ - //transfer ownership to parent widget - QWidget *parent = layout->parentWidget(); - if (!parent) - return; - - Shiboken::AutoDecRef pyParent(Shiboken::Converter::toPython(parent)); - Shiboken::AutoDecRef pyChild(Shiboken::Converter::toPython(widget)); - Shiboken::setParent(pyParent, pyChild); -} - -inline void addLayoutOwnership(QLayout *layout, QLayout *other) -{ - //transfer all children widgetes from other to layout parent widget - QWidget *parent = layout->parentWidget(); - if (!parent) - return; - - for (int i=0, i_max=layout->count(); i < i_max; i++) { - addLayoutOwnership(layout, layout->itemAt(i)); - } - - Shiboken::AutoDecRef pyParent(Shiboken::Converter::toPython(layout)); - Shiboken::AutoDecRef pyChild(Shiboken::Converter::toPython(other)); - Shiboken::setParent(pyParent, pyChild); - -} - -inline void addLayoutOwnership(QLayout *layout, QLayoutItem *item) -{ - QWidget *w = item->widget(); - if (w) - addLayoutOwnership(layout, w); - else { - QLayout *l = item->layout(); - if (l) - addLayoutOwnership(layout, l); - } - - Shiboken::AutoDecRef pyParent(Shiboken::Converter::toPython(layout)); - Shiboken::AutoDecRef pyChild(Shiboken::Converter::toPython(item)); - Shiboken::setParent(pyParent, pyChild); -} - -#endif diff --git a/PySide/QtGui/glue/qmenu_glue.cpp b/PySide/QtGui/glue/qmenu_glue.cpp new file mode 100644 index 0000000..0636dfa --- /dev/null +++ b/PySide/QtGui/glue/qmenu_glue.cpp @@ -0,0 +1,21 @@ +inline PyObject* addActionWithPyObject(QMenu* self, const QIcon& icon, const QString& text, PyObject* callback, const QKeySequence& shortcut) +{ + QAction* act = new QAction(text, self); + + if (!icon.isNull()) + act->setIcon(icon); + + if (!shortcut.isEmpty()) + act->setShortcut(shortcut); + + self->addAction(act); + + PyObject* pyAct = %CONVERTTOPYTHON[QAction*](act); + Shiboken::AutoDecRef result(PyObject_CallMethod(pyAct, "connect", "OsO", pyAct, SIGNAL(triggered()), callback)); + if (result.isNull()) { + Py_DECREF(pyAct); + return 0; + } + + return pyAct; +} diff --git a/PySide/QtGui/glue/qmenu_glue.h b/PySide/QtGui/glue/qmenu_glue.h deleted file mode 100644 index 7f0475a..0000000 --- a/PySide/QtGui/glue/qmenu_glue.h +++ /dev/null @@ -1,23 +0,0 @@ - -inline PyObject* -addActionWithPyObject(QMenu *self, const QIcon& icon, const QString& text, PyObject *callback, const QKeySequence &shortcut) -{ - QAction *act = new QAction(text, self); - - if (!icon.isNull()) - act->setIcon(icon); - - if (!shortcut.isEmpty()) - act->setShortcut(shortcut); - - self->addAction(act); - - PyObject *pyAct = Shiboken::Converter::toPython(act); - PyObject* result = PyObject_CallMethod(pyAct, "connect", "OsO", pyAct, SIGNAL(triggered()), callback); - if (result == 0) { - Py_DECREF(pyAct); - return 0; - } - - return pyAct; -} diff --git a/PySide/QtGui/glue/qmenubar_glue.h b/PySide/QtGui/glue/qmenubar_glue.cpp similarity index 87% rename from PySide/QtGui/glue/qmenubar_glue.h rename to PySide/QtGui/glue/qmenubar_glue.cpp index 9568fa8..2326a76 100644 --- a/PySide/QtGui/glue/qmenubar_glue.h +++ b/PySide/QtGui/glue/qmenubar_glue.cpp @@ -5,7 +5,7 @@ addActionWithPyObject(QMenuBar* self, const QString& text, PyObject* callback) self->addAction(act); - PyObject* pyAct = Shiboken::Converter::toPython(act); + PyObject* pyAct = %CONVERTTOPYTHON[QAction*](act); PyObject* result = PyObject_CallMethod(pyAct, "connect", "OsO", pyAct, SIGNAL(triggered(bool)), callback); diff --git a/PySide/QtGui/glue/qtgui_qapp.cpp b/PySide/QtGui/glue/qtgui_qapp.cpp index f893f8e..5148b57 100644 --- a/PySide/QtGui/glue/qtgui_qapp.cpp +++ b/PySide/QtGui/glue/qtgui_qapp.cpp @@ -1,4 +1,10 @@ // Init qApp macro to None. -Py_INCREF(Py_None); -PyModule_AddObject(module, "qApp", Py_None); +if (qApp) { + PyObject* pyApp = %CONVERTTOPYTHON[QApplication*](qApp); + Py_INCREF(pyApp); + PyModule_AddObject(module, "qApp", pyApp); +} else { + Py_INCREF(Py_None); + PyModule_AddObject(module, "qApp", Py_None); +} moduleQtGui = module; diff --git a/PySide/QtGui/glue/qwidget_glue.cpp b/PySide/QtGui/glue/qwidget_glue.cpp new file mode 100644 index 0000000..cfa3f67 --- /dev/null +++ b/PySide/QtGui/glue/qwidget_glue.cpp @@ -0,0 +1,65 @@ +static QString retrieveObjectName(PyObject *obj) +{ + Shiboken::AutoDecRef objName(PyObject_Str(obj)); + return QString(Shiboken::String::toCString(objName)); +} + + +/** + * Tranfer objects ownership from layout to widget + **/ +static inline void qwidgetReparentLayout(QWidget *parent, QLayout *layout) +{ + Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QWidget*](parent)); + + for (int i=0; i < layout->count(); i++) { + QLayoutItem* item = layout->itemAt(i); + if (PyErr_Occurred() || !item) + return; + + QWidget* w = item->widget(); + if (w) { + QWidget* pw = w->parentWidget(); + if (pw != parent) { + Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QWidget*](w)); + Shiboken::Object::setParent(pyParent, pyChild); + } + } else { + QLayout* l = item->layout(); + if (l) + qwidgetReparentLayout(parent, l); + } + } + + Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QLayout*](layout)); + Shiboken::Object::setParent(pyParent, pyChild); + //remove previous references + Shiboken::Object::keepReference(reinterpret_cast(pyChild.object()), qPrintable(retrieveObjectName(pyChild)), Py_None); +} + +static inline void qwidgetSetLayout(QWidget *self, QLayout *layout) +{ + if (!layout || self->layout()) + return; + + QObject* oldParent = layout->parent(); + if (oldParent && oldParent != self) { + if (oldParent->isWidgetType()) { + // remove old parent policy + Shiboken::AutoDecRef pyLayout(%CONVERTTOPYTHON[QLayout*](layout)); + Shiboken::Object::setParent(Py_None, pyLayout); + } else { + PyErr_Format(PyExc_RuntimeError, "QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", when the QLayout already has a parent", + qPrintable(layout->objectName()), self->metaObject()->className(), qPrintable(self->objectName())); + return; + } + } + + if (oldParent != self) { + qwidgetReparentLayout(self, layout); + if (PyErr_Occurred()) + return; + + self->setLayout(layout); + } +} diff --git a/PySide/QtGui/glue/qwidget_glue.h b/PySide/QtGui/glue/qwidget_glue.h deleted file mode 100644 index a6cd3b7..0000000 --- a/PySide/QtGui/glue/qwidget_glue.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Tranfer objects ownership from layout to widget - **/ -static inline void -qwidgetReparentLayout(QWidget *parent, QLayout *layout) -{ - Shiboken::AutoDecRef pyParent(Shiboken::Converter::toPython(parent)); - - for (int i=0; i < layout->count(); i++) - { - QLayoutItem *item = layout->itemAt(i); - QWidget *w = item->widget(); - - if (w) - { - Shiboken::AutoDecRef pyChild(Shiboken::Converter::toPython(w)); - Shiboken::setParent(pyParent, pyChild); - } - else - { - QLayout *l = item->layout(); - if (l) - qwidgetReparentLayout(parent, l); - } - } - - Shiboken::AutoDecRef pyChild(Shiboken::Converter::toPython(layout)); - Shiboken::setParent(pyParent, pyChild); -} - -static inline void -qwidgetSetLayout(QWidget *self, QLayout *layout) -{ - if (self->layout()) - return; - - qwidgetReparentLayout(self, layout); - self->setLayout(layout); -} diff --git a/PySide/QtGui/qpixmap_conversion.h b/PySide/QtGui/qpixmap_conversion.h deleted file mode 100644 index 10b4803..0000000 --- a/PySide/QtGui/qpixmap_conversion.h +++ /dev/null @@ -1,44 +0,0 @@ -namespace Shiboken { -inline bool Converter< QPixmap >::isConvertible(PyObject* pyobj) -{ - if (ValueTypeConverter::isConvertible(pyobj)) - return true; - SbkBaseWrapperType* shiboType = reinterpret_cast(SbkType()); - bool isVariant = SbkQVariant_Check(pyobj); - if (isVariant) { - QVariant var(Converter::toCpp(pyobj)); - return var.type() == QVariant::Pixmap; - } else if (SbkQSize_Check(pyobj) || SbkQString_Check(pyobj)) { - return true; - } else if (shiboType->ext_isconvertible) { - return shiboType->ext_isconvertible(pyobj); - } - return false; - -} - -inline QPixmap Converter< QPixmap >::toCpp(PyObject* pyobj) -{ - SbkBaseWrapperType* shiboType = reinterpret_cast(SbkType()); - bool isVariant = SbkQVariant_Check(pyobj); - if (isVariant) { - QVariant var(Converter::toCpp(pyobj)); - return var.value(); - } else if (SbkQSize_Check(pyobj)) { - return QPixmap(Shiboken::Converter::toCpp(pyobj)); - } else if (SbkQString_Check(pyobj)) { - return QPixmap(Shiboken::Converter::toCpp(pyobj)); - } else if (shiboType->ext_isconvertible && shiboType->ext_tocpp && shiboType->ext_isconvertible(pyobj)) { - QPixmap* cptr = reinterpret_cast(shiboType->ext_tocpp(pyobj)); - std::auto_ptr cptr_auto_ptr(cptr); - return *cptr; - } - - return *Converter::toCpp(pyobj); -} - -inline PyObject* Converter::toPython(const QPixmap& cppObj) -{ - return ValueTypeConverter::toPython(cppObj); -} -} diff --git a/PySide/QtGui/typesystem_gui.xml.in b/PySide/QtGui/typesystem_gui.xml.in index 2dc9676..210b1dc 100644 --- a/PySide/QtGui/typesystem_gui.xml.in +++ b/PySide/QtGui/typesystem_gui.xml.in @@ -1,5 +1,25 @@ + - - + + + diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index f971f25..552636a 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -1,5 +1,38 @@ + + + + + @@ -39,73 +72,97 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - @@ -114,312 +171,49 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + @@ -431,267 +225,621 @@ + + + QTransform _result; + if (QTransform::quadToQuad(%1, %2, _result)) { + %PYARG_0 = %CONVERTTOPYTHON[QTransform](_result); + } else { + Py_INCREF(Py_None); + %PYARG_0 = Py_None; + } + + + + + QTransform _result; + if (QTransform::quadToSquare(%1, _result)) { + %PYARG_0 = %CONVERTTOPYTHON[QTransform](_result); + } else { + Py_INCREF(Py_None); + %PYARG_0 = Py_None; + } + + + + + + QTransform _result; + if (QTransform::squareToQuad(%1, _result)) { + %PYARG_0 = %CONVERTTOPYTHON[QTransform](_result); + } else { + Py_INCREF(Py_None); + %PYARG_0 = Py_None; + } + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - + + + - - - - + + + + + + uchar* buffer = (uchar*) Shiboken::Buffer::getPointer(%PYARG_2); + QBitmap %0 = QBitmap::fromData(%1, buffer, %3); + %PYARG_0 = %CONVERTTOPYTHON[QBitmap](%0); + + - - - - + + + + - - + + + + + + + + + + + + + + + %BEGIN_ALLOW_THREADS + %RETURN_TYPE %0 = %CPPSELF->::%TYPE::%FUNCTION_NAME(&%1, %2); + %END_ALLOW_THREADS + %PYARG_0 = PyTuple_New(2); + PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](%0)); + PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[%ARG1_TYPE](%1)); + + + + + + + + + - + + + - + - + + + + + + + - + + + - - - - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + if (_i < 0 || _i >= %CPPSELF.count()) { + PyErr_SetString(PyExc_IndexError, "index out of bounds"); + return 0; + } + int item = (*%CPPSELF)[_i]; + return %CONVERTTOPYTHON[int](item); + + + + + - + + - + - - - - - + + + + + + + + %PYARG_0 = Shiboken::Buffer::newObject(%CPPSELF.data(), %CPPSELF.size()); + + + + + + + PyObject* %out = Shiboken::Buffer::newObject(%in, size); + + + Py_ssize_t bufferLen; + char* %out = (char*) Shiboken::Buffer::getPointer(%PYARG_1, &bufferLen); + + + + + + uint %out = bufferLen; + + + - - + + - - - + + - - + + + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + const QTextDocument* doc = %CPPSELF.document(); + if (doc) { + Shiboken::AutoDecRef pyDocument(%CONVERTTOPYTHON[QTextDocument*](doc)); + Shiboken::Object::setParent(pyDocument, %PYARG_1); + } + + + + + + + + const QTextDocument* doc = %CPPSELF.document(); + if (doc) { + Shiboken::AutoDecRef pyDocument(%CONVERTTOPYTHON[QTextDocument*](doc)); + Shiboken::Object::setParent(pyDocument, %PYARG_0); + } + + + + + - + + + - - + - + + + + - - + + + + + + PyObject* points = PyList_New(%CPPSELF.count()); + for (int i = 0, max = %CPPSELF.count(); i < max; ++i){ + int x, y; + %CPPSELF.point(i, &x, &y); + QPoint pt = QPoint(x, y); + PyList_SET_ITEM(points, i, %CONVERTTOPYTHON[QPoint](pt)); + } + + + + + + + + - - - + + + + + // %FUNCTION_NAME() + *%CPPSELF << %1; + %PYARG_0 = %CONVERTTOPYTHON[QPolygon*](%CPPSELF); + + + + + // %FUNCTION_NAME() + *%CPPSELF << %1; + %PYARG_0 = %CONVERTTOPYTHON[QPolygon*](%CPPSELF); + + + - + + + + + - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (%1.type() == QVariant::Pixmap) - %0 = new %TYPE(%1.value<QPixmap>()); - else if (%1.type() == QVariant::Image) - %0 = new %TYPE(QPixmap::fromImage(%1.value<QImage>())); - else - PyErr_SetString(PyExc_TypeError, "QVariant must be holding a QPixmap"); - + + + + + + + + + + + + + + if (**%CPPSELF) { + QTreeWidgetItemIterator* %0 = new QTreeWidgetItemIterator((*%CPPSELF)++); + %PYARG_0 = %CONVERTTOPYTHON[QTreeWidgetItemIterator*](%0); + } + - + + + QTreeWidgetItem* %0 = %CPPSELF.operator*(); + %PYARG_0 = %CONVERTTOPYTHON[QTreeWidgetItem*](%0); + Shiboken::Object::releaseOwnership(%PYARG_0); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %0 = new %TYPE(QPixmap::fromImage(%1)); + + + + + + + + + + + + - - + + + - + - const uchar* %out = reinterpret_cast<const uchar*>(PyString_AS_STRING(%PYARG_1)); + const uchar* %out = reinterpret_cast<const uchar*>(PyBytes_AS_STRING(%PYARG_1)); - uint %out = static_cast<uint>(PyString_GET_SIZE(%PYARG_1)); + uint %out = static_cast<uint>(PyBytes_Size(%PYARG_1)); @@ -701,8 +849,36 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -719,35 +895,59 @@ - - - - - - - - - - - - - - - - - - return %CPPSELF.count(); - - - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -761,96 +961,321 @@ - - - + - - - - - - - - - - + + + + + + + + - + + + + + - + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + - - - - - - - - - - - - + + + + + %PYARG_0 = Shiboken::Buffer::newObject(%CPPSELF.%FUNCTION_NAME(), %CPPSELF.byteCount()); + + + + + // byteCount() is only available on Qt4.7, so we use bytesPerLine * height + %PYARG_0 = Shiboken::Buffer::newObject(%CPPSELF.%FUNCTION_NAME(), %CPPSELF.bytesPerLine() * %CPPSELF.height(), Shiboken::Buffer::ReadWrite); + + + + + %PYARG_0 = Shiboken::Buffer::newObject(%CPPSELF.%FUNCTION_NAME(%1), %CPPSELF.bytesPerLine()); + + + + + + + + %PYARG_0 = Shiboken::Buffer::newObject(%CPPSELF.%FUNCTION_NAME(%1), %CPPSELF.bytesPerLine(), Shiboken::Buffer::ReadWrite); + + + + + + + + + + + + + + - + - - + + + + + + + + + + + + + + + + Shiboken::AutoDecRef func(PyObject_GetAttr(%PYSELF, PyTuple_GET_ITEM(%1, 0))); + PyObject* args = PyTuple_GET_ITEM(%1, 1); + %PYARG_0 = PyObject_Call(func, args, NULL); + + + + + switch(%CPPSELF.spec()) { + case QColor::Rgb: + { + qreal r, g, b, a; + %CPPSELF.getRgbF(&r, &g, &b, &a); + %PYARG_0 = Py_BuildValue("(ON(s(ffff)))", Py_TYPE(%PYSELF), PyTuple_New(0), "setRgbF", (float)r, (float)g, (float)b, (float)a); + break; + } + case QColor::Hsv: + { + qreal h, s, v, a; + %CPPSELF.getHsvF(&h, &s, &v, &a); + %PYARG_0 = Py_BuildValue("(ON(s(ffff)))", Py_TYPE(%PYSELF), PyTuple_New(0), "setHsvF", (float)h, (float)s, (float)v, (float)a); + break; + } + case QColor::Cmyk: + { + qreal c, m, y, k, a; + %CPPSELF.getCmykF(&c, &m, &y, &k, &a); + %PYARG_0 = Py_BuildValue("(ON(s(fffff)))", Py_TYPE(%PYSELF), PyTuple_New(0), "setCmykF", (float)c, (float)m, (float)y, (float)k, (float)a); + break; + } + #if QT_VERSION >= 0x040600 + case QColor::Hsl: + { + qreal h, s, l, a; + %CPPSELF.getHslF(&h, &s, &l, &a); + %PYARG_0 = Py_BuildValue("(ON(s(ffff)))", Py_TYPE(%PYSELF), PyTuple_New(0), "setHslF", (float)h, (float)s, (float)l, (float)a); + break; + } + #endif + default: + { + %PYARG_0 = Py_BuildValue("(N(O))", PyObject_Type(%PYSELF), Py_None); + } + } + + + + + + switch(%CPPSELF.spec()) { + case QColor::Rgb: + { + int r, g, b, a; + %CPPSELF.getRgb(&r, &g, &b, &a); + %PYARG_0 = Py_BuildValue("iiii", r, g, b, a); + break; + } + case QColor::Hsv: + { + int h, s, v, a; + %CPPSELF.getHsv(&h, &s, &v, &a); + %PYARG_0 = Py_BuildValue("iiii", h, s, v, a); + break; + } + case QColor::Cmyk: + { + int c, m, y, k, a; + %CPPSELF.getCmyk(&c, &m, &y, &k, &a); + %PYARG_0 = Py_BuildValue("iiiii", c, m, y, k, a); + break; + } + case QColor::Hsl: + { + int h, s, l, a; + %CPPSELF.getHsl(&h, &s, &l, &a); + %PYARG_0 = Py_BuildValue("iiii", h, s, l, a); + break; + } + default: + { + %PYARG_0 = 0; + } + } + + + - - + + if (%1.type() == QVariant::Color) @@ -882,7 +1307,9 @@ - + + + @@ -907,10 +1334,12 @@ - + + + - + @@ -928,10 +1357,12 @@ - + + + - + @@ -949,7 +1380,9 @@ - + + + @@ -970,7 +1403,9 @@ - + + + @@ -991,7 +1426,9 @@ - + + + @@ -1012,7 +1449,9 @@ - + + + @@ -1033,15 +1472,36 @@ - + + + - + + + + + + + + + + + + + + + + + + + + @@ -1097,12 +1557,27 @@ } - - - - + + + + + + + + + + + + + + + + + + + @@ -1187,14 +1662,14 @@ - - - + + + + + + - - - @@ -1216,24 +1691,38 @@ - + + + + + + + + PyObject* userTypeConstant = PyInt_FromLong(QGraphicsItem::UserType); - PyDict_SetItemString(SbkQGraphicsItem_Type.super.ht_type.tp_dict, "UserType", userTypeConstant); + PyDict_SetItemString(Sbk_QGraphicsItem_Type.super.ht_type.tp_dict, "UserType", userTypeConstant); + - - - - - - + + + + + + @@ -1245,13 +1734,14 @@ - - - + + + + @@ -1292,16 +1782,33 @@ - + + + + - QGraphicsItem *item_ = NULL; - %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(&item_); - %PYARG_0 = Shiboken::makeTuple(retval_, item_); + QGraphicsItem *item_ = NULL; + %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(&item_); + %PYARG_0 = PyTuple_New(2); + PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](retval_)); + PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QGraphicsItem*](item_)); + + + + + + + + + + + + @@ -1333,20 +1840,49 @@ + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + - - - - - - + + + + + + @@ -1395,6 +1929,7 @@ + @@ -1410,28 +1945,19 @@ - - - - - - - - - - - + - + + @@ -1449,30 +1975,34 @@ - + - + - + + + - + + - - - - + + + + + @@ -1485,6 +2015,9 @@ + + @@ -1492,11 +2025,17 @@ - - + + + + + + - - + + + + @@ -1510,8 +2049,11 @@ - - + + + + + @@ -1520,8 +2062,11 @@ - + + + + @@ -1555,6 +2100,17 @@ + + + + + + + + + + + @@ -1576,20 +2132,18 @@ - + + + + - - - - - @@ -1597,30 +2151,37 @@ + + + + - - + - + + + + + @@ -1633,39 +2194,53 @@ - - + + + + + - + - + + + Shiboken::Object::releaseOwnership(%PYARG_2); + - + + + //this function is static we need keep ref to default value, to be able to call python virtual functions + static PyObject* _defaultValue = 0; + %CPPSELF.%FUNCTION_NAME(%1); + Py_INCREF(%PYARG_1); + if (_defaultValue) + Py_DECREF(_defaultValue); + + _defaultValue = %PYARG_1; + - - + + + + + + + + + + - - - - - - - - - - @@ -1673,27 +2248,52 @@ + - - - + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + + + + + + + @@ -1738,6 +2338,9 @@ + + + @@ -1748,6 +2351,7 @@ + @@ -1760,9 +2364,7 @@ - - - + @@ -1809,32 +2411,54 @@ + - + + + + + %PYARG_0 = addActionWithPyObject(%CPPSELF, QIcon(), %1, %2, %3); - + + + + + %PYARG_0 = addActionWithPyObject(%CPPSELF, %1, %2, %3, %4); + + + Shiboken::BindingManager& bm = Shiboken::BindingManager::instance(); + PyObject* pyObj; + foreach(QAction* act, %CPPSELF.actions()) { + if ((pyObj = (PyObject*)bm.retrieveWrapper(act)) != 0) { + Py_INCREF(pyObj); + Shiboken::Object::setParent(NULL, pyObj); + Shiboken::Object::invalidate(pyObj); + Py_DECREF(pyObj); + } + } + + + - - - + @@ -1879,43 +2503,57 @@ + + + foreach(QAction *act, %CPPSELF.actions()) { + Shiboken::AutoDecRef pyAct(%CONVERTTOPYTHON[QAction*](act)); + Shiboken::Object::setParent(NULL, pyAct); + Shiboken::Object::invalidate(pyAct); + } + + - + - - - - - - - + + + + QPixmap p; + if (%CPPSELF.%FUNCTION_NAME(%1, &p)) { + %PYARG_0 = %CONVERTTOPYTHON[QPixmap](p); + } else { + %PYARG_0 = Py_None; + Py_INCREF(%PYARG_0); + } + + + + - + - - + + - - - + @@ -1923,14 +2561,9 @@ - - - - - - + @@ -1940,16 +2573,14 @@ Shiboken::AutoDecRef result(PyObject_CallMethod(%PYSELF, "connect", "OsO", %PYSELF, SIGNAL(activated()), %PYARG_3)); if (!result.isNull()) - Shiboken::setParent(%PYARG_2, %PYSELF); + Shiboken::Object::setParent(%PYARG_2, %PYSELF); - - - + @@ -1959,9 +2590,85 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + // Clear parent from the old child + QStandardItem* _i = %CPPSELF->child(%1, %2); + if (_i) { + PyObject* _pyI = %CONVERTTOPYTHON[QStandardItem*](_i); + Shiboken::Object::setParent(0, _pyI); + } + + + + + + + + // Clear parent from the old child + QStandardItem* _i = %CPPSELF->child(%1); + if (_i) { + PyObject* _pyI = %CONVERTTOPYTHON[QStandardItem*](_i); + Shiboken::Object::setParent(0, _pyI); + } + + + + + + + + + + + + + + + + + + + + @@ -1994,9 +2701,19 @@ - - - + + + + + + + + + + + + + @@ -2009,11 +2726,9 @@ - - - - - + + + @@ -2028,27 +2743,17 @@ - - - - - - - - - - - - + - + + + - - + @@ -2083,12 +2788,13 @@ QWidget *_widget = %CPPSELF.widget(%1); if (_widget) { Shiboken::AutoDecRef pyWidget(%CONVERTTOPYTHON[QWidget*](_widget)); - Shiboken::setParent(0, pyWidget); + Shiboken::Object::setParent(0, pyWidget); } + @@ -2108,19 +2814,8 @@ - - - - - - - - - - - - + @@ -2179,7 +2874,65 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2195,11 +2948,12 @@ - + + @@ -2209,7 +2963,9 @@ - + + + @@ -2219,18 +2975,28 @@ + + + + - + + + + + + + @@ -2243,7 +3009,16 @@ - + + + + + + + + + + @@ -2251,10 +3026,14 @@ + - + + + + @@ -2262,22 +3041,85 @@ - + + + + bool ret = !(&%CPPSELF == %1); + %PYARG_0 = %CONVERTTOPYTHON[bool](ret); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2288,19 +3130,18 @@ - + + - - - + @@ -2311,10 +3152,24 @@ + + + removeLayoutOwnership(%CPPSELF, %1); + + + + + removeLayoutOwnership(%CPPSELF, %1); + + + + + + @@ -2350,38 +3205,42 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - addLayoutOwnership(%CPPSELF, %1); - - - - - - - - - addLayoutOwnership(%CPPSELF, %0); - - - - - - - addLayoutOwnership(%CPPSELF, %1); - - + + addLayoutOwnership(%CPPSELF, %2); @@ -2390,35 +3249,22 @@ - - - + - - - - - - - addLayoutOwnership(%CPPSELF, %0); - - + addLayoutOwnership(%CPPSELF, %1); + addLayoutOwnership(%CPPSELF, %1); - - - addLayoutOwnership(%CPPSELF, %1); - - + addLayoutOwnership(%CPPSELF, %2); @@ -2447,52 +3293,88 @@ - - - - - - - addLayoutOwnership(%CPPSELF, %1); + + + + + + + addLayoutOwnership(%CPPSELF, %0); + + + addLayoutOwnership(%CPPSELF, %1); + + + addLayoutOwnership(%CPPSELF, %1); + + + addLayoutOwnership(%CPPSELF, %1); + + + addLayoutOwnership(%CPPSELF, %1); + + + + + + + + + addLayoutOwnership(%CPPSELF, %1); - - - - - - - - addLayoutOwnership(%CPPSELF, %0); - + + + + + + + + + + + + + + + + + + + int a, b, c, d; + %CPPSELF.%FUNCTION_NAME(%1, &a, &b, &c, &d); + %PYARG_0 = PyTuple_New(4); + PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[int](a)); + PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[int](b)); + PyTuple_SET_ITEM(%PYARG_0, 2, %CONVERTTOPYTHON[int](c)); + PyTuple_SET_ITEM(%PYARG_0, 3, %CONVERTTOPYTHON[int](d)); + - - @@ -2500,12 +3382,35 @@ + + + + + - + + + + + + + + + + + + + + + + + + + @@ -2515,7 +3420,6 @@ - @@ -2527,7 +3431,7 @@ int numItems = PySequence_Size(%PYARG_1); - QGraphicsItem *%out[numItems]; + Shiboken::AutoArrayPointer<QGraphicsItem*> %out(numItems); for (int i=0; i < numItems; i++) { %out[i] = %CONVERTTOCPP[QGraphicsItem*](PySequence_Fast_GET_ITEM(%PYARG_1, i)); } @@ -2547,14 +3451,15 @@ Shiboken::AutoDecRef option_object(PyList_New(0)); for (int i=0, max=numItems; i < max; i++) { - PyList_Append(option_object, %CONVERTTOPYTHON[QStyleOptionGraphicsItem](%in[i])); + const QStyleOptionGraphicsItem* item = &%in[i]; + PyList_Append(option_object, %CONVERTTOPYTHON[QStyleOptionGraphicsItem](item)); } - PyObject *%out = option_object.object(); + PyObject* %out = option_object.object(); int numOptions = PySequence_Size(%PYARG_2); - QStyleOptionGraphicsItem %out[numOptions]; + Shiboken::AutoArrayPointer<QStyleOptionGraphicsItem> %out(numOptions); for (int i=0; i < numOptions; i++) { %out[i] = %CONVERTTOCPP[QStyleOptionGraphicsItem](PySequence_Fast_GET_ITEM(%PYARG_1, i)); } @@ -2563,7 +3468,9 @@ - + + + @@ -2572,7 +3479,7 @@ - + @@ -2581,7 +3488,7 @@ - + @@ -2590,7 +3497,7 @@ - + @@ -2599,7 +3506,7 @@ - + @@ -2613,7 +3520,36 @@ + + + + + + + + + + + + + + + + + + QGraphicsItem* parentItem = %1->parentItem(); + Shiboken::AutoDecRef parent(%CONVERTTOPYTHON[QGraphicsItem*](parentItem)); + foreach (QGraphicsItem* item, %1->children()) + Shiboken::Object::setParent(parent, %CONVERTTOPYTHON[QGraphicsItem*](item)); + %BEGIN_ALLOW_THREADS + %CPPSELF.%FUNCTION_NAME(%1); + %END_ALLOW_THREADS + // the arg was destroyed by Qt. + Shiboken::Object::invalidate(%PYARG_1); + + + @@ -2668,24 +3604,24 @@ - + - + - + - + @@ -2696,47 +3632,50 @@ - + - + - + - + - + - + - + - - - + + + %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(%1, %2); + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); + Shiboken::Object::keepReference((SbkObject*)%PYARG_0, "setWidget(QWidget*)1", %PYARG_1); + @@ -2746,9 +3685,21 @@ - - - + + + const QList<QGraphicsItem*> items = %CPPSELF.items(); + Shiboken::BindingManager& bm = Shiboken::BindingManager::instance(); + foreach (QGraphicsItem* item, items) { + SbkObject* obj = bm.retrieveWrapper(item); + if (obj) { + if (reinterpret_cast<PyObject*>(obj)->ob_refcnt > 1) // If the refcnt is 1 the object will vannish anyway. + Shiboken::Object::invalidate(obj); + Shiboken::Object::removeParent(obj); + } + } + %CPPSELF.%FUNCTION_NAME(); + + @@ -2763,13 +3714,16 @@ + + + + - - + @@ -2778,19 +3732,13 @@ - - + - - - - - @@ -2811,78 +3759,87 @@ - + + - - - - + + + QTreeWidgetItem *rootItem = %CPPSELF.invisibleRootItem(); + Shiboken::BindingManager &bm = Shiboken::BindingManager::instance(); + for (int i = 0; i < rootItem->childCount(); ++i) { + QTreeWidgetItem *item = rootItem->child(i); + SbkObject* wrapper = bm.retrieveWrapper(item); + if (wrapper) + Shiboken::Object::setParent(0, reinterpret_cast<PyObject*>(wrapper)); + } + - - + + - + + + + + + + + + - + + - - - - - - - + - - - - - - + + - + - + - - + + + + @@ -2890,20 +3847,12 @@ - + - - - - - - - - - + @@ -2917,51 +3866,44 @@ - - - - - - - + + + - + - + - - - + + + - - - + + - - - + - + - + @@ -2971,12 +3913,12 @@ - + - + @@ -3016,19 +3958,35 @@ + + + + + + // Only call the parent function if this return some value + // the parent can be the TreeWidget + if (%0) + Shiboken::Object::setParent(%PYARG_0, %PYSELF); + + + + + + + + // Only call the parent function if this return some value + // the parent can be the TreeWidgetItem + if (%0) + Shiboken::Object::setParent(%PYARG_0, %PYSELF); + + + + - - - - - - - - - + @@ -3036,116 +3994,214 @@ - + - + - - - - - + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + - + + + + + + + + Shiboken::Object::keepReference(reinterpret_cast<SbkObject*>(%PYSELF), "__style__", %PYARG_1); + + + + + QStyle* myStyle = %CPPSELF->style(); + if (myStyle && qApp) { + %PYARG_0 = %CONVERTTOPYTHON[QStyle*](myStyle); + QStyle *appStyle = qApp->style(); + if (appStyle == myStyle) { + Shiboken::AutoDecRef pyApp(%CONVERTTOPYTHON[QApplication*](qApp)); + Shiboken::Object::setParent(pyApp, %PYARG_0); + Shiboken::Object::releaseOwnership(%PYARG_0); + } else { + Shiboken::Object::keepReference(reinterpret_cast<SbkObject*>(%PYSELF), "__style__", %PYARG_0); + } + } + + + + @@ -3164,49 +4220,85 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - qwidgetSetLayout(%CPPSELF, %1); + // %FUNCTION_NAME() - disable generation of function call. + - - - - - - - - + + + + Returns the window system identifier of the widget. + + Portable in principle, but if you use it you are probably about to do something non-portable. Be careful. + + If a widget is non-native (alien) and winId() is invoked on it, that widget will be provided a native handle. + + On X11 the type returned is long, on other platforms it's void pointer casted to a Python long long. + + This value may change at run-time. An event with type PySide.QtCore.QEvent.WinIdChange will be sent to the widget following a change in window system identifier. + + + + + + + + - - + + + @@ -3215,30 +4307,20 @@ + - - - - - - - - - - - - + @@ -3247,31 +4329,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + + @@ -3280,7 +4414,7 @@ - + @@ -3292,7 +4426,9 @@ - + + @@ -3308,6 +4444,9 @@ + + + @@ -3315,11 +4454,9 @@ - - - - + + @@ -3335,7 +4472,7 @@ - + @@ -3356,15 +4493,18 @@ QWidget* tab = %CPPSELF.widget(%1); if (tab) { - Shiboken::setParent(0, %CONVERTTOPYTHON[QWidget*](tab)); + Shiboken::AutoDecRef pyWidget(%CONVERTTOPYTHON[QWidget*](tab)); %CPPSELF.%FUNCTION_NAME(%1); } - for (int i=0; i < %CPPSELF.count(); i++) - Shiboken::setParent(0, %CONVERTTOPYTHON[QWidget*](%CPPSELF.widget(i))); + for (int i = 0; i < %CPPSELF.count(); i++) { + QWidget* widget = %CPPSELF.widget(i); + Shiboken::AutoDecRef pyWidget(%CONVERTTOPYTHON[QWidget*](widget)); + Shiboken::Object::setParent(0, pyWidget); + } %CPPSELF.%FUNCTION_NAME(); @@ -3389,9 +4529,9 @@ - + - + @@ -3399,36 +4539,40 @@ - + + + - + - + + - - + + - + @@ -3465,16 +4609,15 @@ - - - - - - + + + + + @@ -3486,13 +4629,46 @@ - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -3500,9 +4676,11 @@ + + + - @@ -3552,51 +4730,122 @@ - + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + - + - - - - - - - - - + + + // Clear parent from the old child + QStandardItem* _i = %CPPSELF->item(%1, %2); + if (_i) { + PyObject* _pyI = %CONVERTTOPYTHON[QStandardItem*](_i); + Shiboken::Object::setParent(0, _pyI); + } + + + + + + + + // Clear parent from the old child + QStandardItem* _i = %CPPSELF->item(%1); + if (_i) { + PyObject* _pyI = %CONVERTTOPYTHON[QStandardItem*](_i); + Shiboken::Object::setParent(0, _pyI); + } + + + + + + + + + + + + + + // Clear parent from the old child + QStandardItem* _i = %CPPSELF->verticalHeaderItem(%1); + if (_i) { + PyObject* _pyI = %CONVERTTOPYTHON[QStandardItem*](_i); + Shiboken::Object::setParent(0, _pyI); + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + for(int r=0, r_max = %CPPSELF.rowCount(); r < r_max; r++) { + QList<QStandardItem *> ri = %CPPSELF.takeRow(0); + + PyObject *pyResult = %CONVERTTOPYTHON[QList<QStandardItem * >](ri); + Shiboken::Object::setParent(Py_None, pyResult); + Py_XDECREF(pyResult); + } + + @@ -3605,13 +4854,29 @@ + - + - + + + + + + + + + %BEGIN_ALLOW_THREADS + %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2); + %END_ALLOW_THREADS + %PYARG_0 = PyTuple_New(2); + PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](retval_)); + PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[%ARG1_TYPE](%1)); + + @@ -3659,26 +4924,26 @@ + + + + - - - - - - + + + + - - @@ -3729,14 +4994,10 @@ + - - - - - - + @@ -3744,7 +5005,10 @@ - + + + + @@ -3765,11 +5029,25 @@ - - + + + + + + + + + + + + + + + + @@ -3807,26 +5085,54 @@ - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + @@ -3851,38 +5157,56 @@ - + + + + + - - - - - - - - - - - - - - - - + + +:: + + def callback_int(value_as_int): + print 'int value changed:', repr(value_as_int) + + app = QApplication(sys.argv) + spinbox = QSpinBox() + spinbox.valueChanged[unicode].connect(callback_unicode) + spinbox.show() + sys.exit(app.exec_()) + + + + +:: + + def callback_unicode(value_as_unicode): + print 'unicode value changed:', repr(value_as_unicode) + + app = QApplication(sys.argv) + spinbox = QSpinBox() + spinbox.valueChanged[unicode].connect(callback_unicode) + spinbox.show() + sys.exit(app.exec_()) + + + + - + - + @@ -3901,14 +5225,45 @@ - - - + + + + + + + + + + + + + QAction* action = %CPPSELF.addAction(%1, %2); + %PYARG_0 = %CONVERTTOPYTHON[QAction*](action); + Shiboken::AutoDecRef result(PyObject_CallMethod(%PYARG_0, "connect", "OsO", %PYARG_0, SIGNAL(triggered()), %PYARG_3)); + + + + + + + + + + + + + + QAction* action = %CPPSELF.addAction(%1); + %PYARG_0 = %CONVERTTOPYTHON[QAction*](action); + Shiboken::AutoDecRef result(PyObject_CallMethod(%PYARG_0, "connect", "OsO", %PYARG_0, SIGNAL(triggered()), %PYARG_2)); + + + - + @@ -3939,8 +5294,38 @@ + + + QList<PyObject* > lst; + Shiboken::BindingManager& bm = Shiboken::BindingManager::instance(); + foreach(QToolButton* child, %CPPSELF.findChildren<QToolButton*>()) { + if (bm.hasWrapper(child)) { + PyObject* pyChild = %CONVERTTOPYTHON[QToolButton*](child); + Shiboken::Object::setParent(0, pyChild); + lst << pyChild; + } + } + + //Remove actions + foreach(QAction *act, %CPPSELF.actions()) { + Shiboken::AutoDecRef pyAct(%CONVERTTOPYTHON[QAction*](act)); + Shiboken::Object::setParent(NULL, pyAct); + Shiboken::Object::invalidate(pyAct); + } + + %CPPSELF.clear(); + foreach(PyObject* obj, lst) { + Shiboken::Object::invalidate(reinterpret_cast<SbkObject* >(obj)); + Py_XDECREF(obj); + } + + + + + + @@ -3953,10 +5338,13 @@ + + + @@ -3969,7 +5357,7 @@ - + @@ -3986,27 +5374,22 @@ - + - > - - - - - - - + - - - - + + + + + + @@ -4022,22 +5405,11 @@ - - - - - - - - - - - - - - - + + + + @@ -4050,54 +5422,116 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %BEGIN_ALLOW_THREADS + %CPPSELF.%FUNCTION_NAME(%1.data(), %1.size(), %2); + %END_ALLOW_THREADS + + + + + + %BEGIN_ALLOW_THREADS + %CPPSELF.%FUNCTION_NAME(%1.data(), %1.size(), %2); + %END_ALLOW_THREADS + + + + + + + + + + + + + + + + + + + + + - - + + + + - - - - - - - + - + - + - + - + @@ -4135,17 +5569,14 @@ + + - - - - - - + @@ -4153,6 +5584,8 @@ + + @@ -4162,36 +5595,89 @@ - + + + + QApplicationConstructor(%PYSELF, %1, &%0); + + + + + + QApplicationConstructor(%PYSELF, %1, %2, &%0); + + + + + + QApplicationConstructor(%PYSELF, %1, %2, &%0); + + - + - - - - - - - + + - Shiboken::setParent(%CONVERTTOPYTHON[QApplication*](qApp), %PYARG_1); + Shiboken::Object::setParent(%CONVERTTOPYTHON[QApplication*](qApp), %PYARG_1); - - Shiboken::setParent(%CONVERTTOPYTHON[QApplication*](qApp), %PYARG_0); - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4199,10 +5685,66 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4285,19 +5827,11 @@ - - - - - + + - - - - - @@ -4317,14 +5851,65 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4375,17 +5960,63 @@ - - - + + QWidget* _old = %CPPSELF.widget(); + if (_old) + Shiboken::Object::setParent(NULL, %CONVERTTOPYTHON[QWidget*](_old)); + %CPPSELF.%FUNCTION_NAME(%1); + Shiboken::Object::setParent(%PYSELF, %PYARG_1); + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4446,6 +6077,7 @@ + @@ -4456,9 +6088,8 @@ + - - @@ -4472,32 +6103,609 @@ - + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4519,21 +6727,13 @@ } - - - - - + - const qreal* values = %CPPSELF.constData(); - %PYARG_0 = PyTuple_New(16); - for(int i=0; i < 16; i++) { - PyObject *v = PyFloat_FromDouble(values[i]); - PyTuple_SET_ITEM(%PYARG_0, i, v); - } + + + - @@ -4541,7 +6741,6 @@ - qreal values[16]; %CPPSELF.%FUNCTION_NAME(values); @@ -4553,37 +6752,99 @@ - - - + + + + + + + + + + + + + + + + + + + + if (PySequence_Check(_key)) { + Shiboken::AutoDecRef key(PySequence_Fast(_key, "Invalid matrix index.")); + if (PySequence_Fast_GET_SIZE(key.object()) == 2) { + PyObject* posx = PySequence_Fast_GET_ITEM(key.object(), 0); + PyObject* posy = PySequence_Fast_GET_ITEM(key.object(), 1); + Py_ssize_t x = PyInt_AsSsize_t(posx); + Py_ssize_t y = PyInt_AsSsize_t(posy); + qreal ret = (*%CPPSELF)(x,y); + return %CONVERTTOPYTHON[qreal](ret); + } + } + PyErr_SetString(PyExc_IndexError, "Invalid matrix index."); + return 0; + + - - - - - - - + + + + + + + + + + + + + + + - - + + + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4623,9 +6968,126 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PySide/QtGui/typesystem_gui_mac.xml b/PySide/QtGui/typesystem_gui_mac.xml index b27df0f..b7597b9 100644 --- a/PySide/QtGui/typesystem_gui_mac.xml +++ b/PySide/QtGui/typesystem_gui_mac.xml @@ -1,11 +1,32 @@ + - - + + + + diff --git a/PySide/QtGui/typesystem_gui_maemo.xml b/PySide/QtGui/typesystem_gui_maemo.xml index 0a06c77..f49da9d 100644 --- a/PySide/QtGui/typesystem_gui_maemo.xml +++ b/PySide/QtGui/typesystem_gui_maemo.xml @@ -1,10 +1,30 @@ + - - - - + + + + + diff --git a/PySide/QtGui/typesystem_gui_simulator.xml b/PySide/QtGui/typesystem_gui_simulator.xml new file mode 100644 index 0000000..065e44d --- /dev/null +++ b/PySide/QtGui/typesystem_gui_simulator.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PySide/QtGui/typesystem_gui_win.xml b/PySide/QtGui/typesystem_gui_win.xml new file mode 100644 index 0000000..387964d --- /dev/null +++ b/PySide/QtGui/typesystem_gui_win.xml @@ -0,0 +1,49 @@ + + + + + + + #ifdef IS_PY3K + return PyCapsule_New(%in, 0, 0); + #else + return PyCObject_FromVoidPtr(%in, 0); + #endif + + + + %out = 0; + + + #ifdef IS_PY3K + %out = (%OUTTYPE)PyCapsule_GetPointer(%in, 0); + #else + %out = (%OUTTYPE)PyCObject_AsVoidPtr(%in); + #endif + + + + + + + + + diff --git a/PySide/QtGui/typesystem_gui_x11.xml b/PySide/QtGui/typesystem_gui_x11.xml index 7429874..54d8882 100644 --- a/PySide/QtGui/typesystem_gui_x11.xml +++ b/PySide/QtGui/typesystem_gui_x11.xml @@ -1,14 +1,50 @@ + - - + + + %PYARG_0 = PyLong_FromVoidPtr(%TYPE::%FUNCTION_NAME()); + + + + + %PYARG_0 = PyLong_FromVoidPtr(%CPPSELF.%FUNCTION_NAME()); + + + + + %PYARG_0 = PyLong_FromVoidPtr(%CPPSELF.%FUNCTION_NAME()); + + + + + + + + - - diff --git a/PySide/QtHelp/CMakeLists.txt b/PySide/QtHelp/CMakeLists.txt index 219dfc3..041ef63 100644 --- a/PySide/QtHelp/CMakeLists.txt +++ b/PySide/QtHelp/CMakeLists.txt @@ -15,34 +15,28 @@ set(QtHelp_SRC ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtHelp/qthelp_module_wrapper.cpp ) -execute_generator(help QtHelp_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtGui_SOURCE_DIR}:${QtHelp_SOURCE_DIR}") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ${QT_QTHELP_INCLUDE_DIR} - ${PYTHON_INCLUDE_PATH} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${QtGui_BINARY_DIR}/PySide/QtGui/ - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtHelp) -add_library(QtHelp MODULE ${QtHelp_SRC}) - -set_target_properties(QtHelp PROPERTIES PREFIX "") - -target_link_libraries(QtHelp - pyside - ${PYTHON_LIBRARIES} +set(QtHelp_typesystem_path "${QtCore_SOURCE_DIR}${PATH_SEP}${QtCore_BINARY_DIR}${PATH_SEP}${QtGui_SOURCE_DIR}${PATH_SEP}${QtHelp_SOURCE_DIR}${PATH_SEP}${QtGui_BINARY_DIR}") +set(QtHelp_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTGUI_INCLUDE_DIR} + ${QT_QTHELP_INCLUDE_DIR} + ${SHIBOKEN_PYTHON_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${QtGui_BINARY_DIR}/PySide/QtGui/ + ${QtCore_BINARY_DIR}/PySide/QtCore/ + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtHelp) +set(QtHelp_libraries pyside + ${SHIBOKEN_PYTHON_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTHELP_LIBRARY}) -add_dependencies(QtHelp QtGui) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtHelp${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtHelp/pyside_qthelp_python.h - DESTINATION include/PySide/QtHelp/) - +set(QtHelp_deps QtGui) +create_pyside_module(QtHelp + QtHelp_include_dirs + QtHelp_libraries + QtHelp_deps + QtHelp_typesystem_path + QtHelp_SRC + "") diff --git a/PySide/QtHelp/typesystem_help.xml b/PySide/QtHelp/typesystem_help.xml index e78153f..bc58957 100644 --- a/PySide/QtHelp/typesystem_help.xml +++ b/PySide/QtHelp/typesystem_help.xml @@ -1,10 +1,27 @@ + - - @@ -19,7 +36,9 @@ - + + + diff --git a/PySide/QtMaemo5/CMakeLists.txt b/PySide/QtMaemo5/CMakeLists.txt index ac85ea4..41397f4 100644 --- a/PySide/QtMaemo5/CMakeLists.txt +++ b/PySide/QtMaemo5/CMakeLists.txt @@ -11,47 +11,40 @@ ${CMAKE_CURRENT_BINARY_DIR}/${BINDING_NAME}/QtMaemo5/qmaemo5valuebutton_wrapper. ${CMAKE_CURRENT_BINARY_DIR}/${BINDING_NAME}/QtMaemo5/qtmaemo5_module_wrapper.cpp ) -execute_generator(maemo5 QtMaemo5_SRC - "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtGui_SOURCE_DIR}:${QtMaemo5_SOURCE_DIR}") +set(QtMaemo5_typesystem_path "${QtCore_SOURCE_DIR}${PATH_SEP}${QtCore_BINARY_DIR}${PATH_SEP}${QtGui_SOURCE_DIR}${PATH_SEP}${QtMaemo5_SOURCE_DIR}${PATH_SEP}${QtGui_BINARY_DIR}") # QT_QTMAEMO5_* variables are not defined by CMake if(NOT QT_QTMAEMO5_INCLUDE_DIR) FIND_PATH(QT_QTMAEMO5_INCLUDE_DIR QtMaemo5 PATHS ${QT_HEADERS_DIR}/QtMaemo5 NO_DEFAULT_PATH) -endif(NOT QT_QTMAEMO5_INCLUDE_DIR) +endif() if(NOT QT_QTMAEMO5_LIBRARY) FIND_LIBRARY(QT_QTMAEMO5_LIBRARY QtMaemo5 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) -endif(NOT QT_QTMAEMO5_LIBRARY) +endif() -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ${QT_QTMAEMO5_INCLUDE_DIR} - ${PYTHON_INCLUDE_PATH} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${QtCore_BINARY_DIR}/${BINDING_NAME}/QtCore/ - ${QtGui_BINARY_DIR}/${BINDING_NAME}/QtGui/ - ${CMAKE_CURRENT_BINARY_DIR}/${BINDING_NAME}/QtMaemo5) -add_library(QtMaemo5 MODULE ${QtMaemo5_SRC}) - -set_target_properties(QtMaemo5 PROPERTIES - PREFIX "") - -target_link_libraries(QtMaemo5 - pyside - ${PYTHON_LIBRARIES} +set(QtMaemo5_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTGUI_INCLUDE_DIR} + ${QT_QTMAEMO5_INCLUDE_DIR} + ${SHIBOKEN_PYTHON_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${QtCore_BINARY_DIR}/${BINDING_NAME}/QtCore/ + ${QtGui_BINARY_DIR}/${BINDING_NAME}/QtGui/ + ${CMAKE_CURRENT_BINARY_DIR}/${BINDING_NAME}/QtMaemo5) +set(QtMaemo5_libraries pyside + ${SHIBOKEN_PYTHON_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTMAEMO5_LIBRARY}) +set(QtMaemo5_deps QtGui) -#add_dependencies(QtMaemo5) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtMaemo5${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/${BINDING_NAME}) - -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtMaemo5/pyside_qtmaemo5_python.h - DESTINATION include/${BINDING_NAME}/QtMaemo5/) +create_pyside_module(QtMaemo5 + QtMaemo5_include_dirs + QtMaemo5_libraries + QtMaemo5_deps + QtMaemo5_typesystem_path + QtMaemo5_SRC + "") diff --git a/PySide/QtMaemo5/typesystem_maemo5.xml b/PySide/QtMaemo5/typesystem_maemo5.xml index 9f92793..803404d 100644 --- a/PySide/QtMaemo5/typesystem_maemo5.xml +++ b/PySide/QtMaemo5/typesystem_maemo5.xml @@ -1,9 +1,26 @@ + - - @@ -13,7 +30,7 @@ - + @@ -30,7 +47,7 @@ - + @@ -44,7 +61,7 @@ - + @@ -57,6 +74,7 @@ + @@ -67,5 +85,5 @@ - + diff --git a/PySide/QtMultimedia/CMakeLists.txt b/PySide/QtMultimedia/CMakeLists.txt index cbf0b6f..ea37c80 100644 --- a/PySide/QtMultimedia/CMakeLists.txt +++ b/PySide/QtMultimedia/CMakeLists.txt @@ -17,35 +17,32 @@ set(QtMultimedia_SRC ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtMultimedia/qvideoframe_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtMultimedia/qtmultimedia_module_wrapper.cpp ) +set(QtMultimedia_typesystem_path "${QtCore_SOURCE_DIR}${PATH_SEP}${QtCore_BINARY_DIR}${PATH_SEP}${QtGui_SOURCE_DIR}${PATH_SEP}${QtGui_BINARY_DIR}") -execute_generator(multimedia QtMultimedia_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_SOURCE_DIR}:${QtGui_BINARY_DIR}") +set(QtMultimedia_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtMultimedia/ + ${QT_INCLUDE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTGUI_INCLUDE_DIR} + ${QT_QTMULTIMEDIA_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${SHIBOKEN_PYTHON_INCLUDE_DIR} + ${QtCore_BINARY_DIR}/PySide/QtCore/ + ${QtGui_BINARY_DIR}/PySide/QtGui/) -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtMultimedia/ - ${QT_INCLUDE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ${QT_QTMULTIMEDIA_INCLUDE_DIR} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${PYTHON_INCLUDE_PATH} - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ${QtGui_BINARY_DIR}/PySide/QtGui/ - ) +set(QtMultimedia_libraries pyside + ${SHIBOKEN_PYTHON_LIBRARIES} + ${SHIBOKEN_LIBRARY} + ${QT_QTMULTIMEDIA_LIBRARY} + ${QT_QTGUI_LIBRARY}) -add_library(QtMultimedia MODULE ${QtMultimedia_SRC}) -set_property(TARGET QtMultimedia PROPERTY PREFIX "") -target_link_libraries(QtMultimedia - pyside - ${PYTHON_LIBRARIES} - ${SHIBOKEN_LIBRARY} - ${QT_QTMULTIMEDIA_LIBRARY} - ${QT_QTGUI_LIBRARY} - ) -add_dependencies(QtMultimedia QtGui) +set(QtMultimedia_deps QtGui) -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtMultimedia${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtMultimedia/pyside_qtmultimedia_python.h - DESTINATION include/PySide/QtMultimedia/) +create_pyside_module(QtMultimedia + QtMultimedia_include_dirs + QtMultimedia_libraries + QtMultimedia_deps + QtMultimedia_typesystem_path + QtMultimedia_SRC + "") diff --git a/PySide/QtMultimedia/typesystem_multimedia.xml b/PySide/QtMultimedia/typesystem_multimedia.xml index 1786e70..b1a684f 100644 --- a/PySide/QtMultimedia/typesystem_multimedia.xml +++ b/PySide/QtMultimedia/typesystem_multimedia.xml @@ -1,26 +1,44 @@ + - - - - - - - - - - - - - + + + + + - + + + + + + + + + + + + + + + - - - + + + + diff --git a/PySide/QtNetwork/CMakeLists.txt b/PySide/QtNetwork/CMakeLists.txt index e66fa37..c18d70a 100644 --- a/PySide/QtNetwork/CMakeLists.txt +++ b/PySide/QtNetwork/CMakeLists.txt @@ -1,52 +1,5 @@ project(QtNetwork) -# Check QtNetwork support -macro(CHECK_QT_NETWORK_MACRO macro_display_name qt_macro module_sources global_sources) - if (DEFINED PYSIDE_${qt_macro}) - if (PYSIDE_${qt_macro}) - list(APPEND ${global_sources} ${${module_sources}}) - endif() - else() - set(SRC_FILE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test${qt_macro}.cxx) - file(WRITE ${SRC_FILE} - "#include \n" - "int main() { \n" - "#ifdef ${qt_macro}\n" - "#error not supported.\n" - "#endif\n" - "}\n") - - try_compile(Q_WORKS ${CMAKE_BINARY_DIR} - ${SRC_FILE} - CMAKE_FLAGS - -DINCLUDE_DIRECTORIES:STRING=${QT_QTNETWORK_INCLUDE_DIR}\;${QT_INCLUDE_DIR} - -DLINK_LIBRARIES:PATH=${QT_QTNETWORK_LIBRARY_RELEASE} - OUTPUT_VARIABLE OUTPUT) - - set("PYSIDE_${qt_macro}" ${Q_WORKS} CACHE STRING "Has this Qt module been found by pyside?") - if(Q_WORKS) - message(STATUS "Testing support to ${macro_display_name} -- enabled") - list(APPEND ${global_sources} ${${module_sources}}) - else() - message(STATUS "Testing support to ${macro_display_name} -- disabled") - endif() - endif() -endmacro(CHECK_QT_NETWORK_MACRO) - - -if(Q_WS_X11) - set(MODULE_NAME network_x11) - set(SPECIFIC_OS_FILES - ) - -elseif(Q_WS_MAC) - set(MODULE_NAME network_mac) - set(SPECIFIC_OS_FILES - ) -else() - message(FATAL_ERROR "OS not supported") -endif(Q_WS_X11) - if (${QT_VERSION_MAJOR} EQUAL 4 AND ${QT_VERSION_MINOR} GREATER 6) set (QtNetwork_47_SRC ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qnetworkconfiguration_wrapper.cpp @@ -57,25 +10,39 @@ else() set(QtNetwork_47_SRC ) endif () +set(QtNetwork_OPTIONAL_SRC ) +set(QtNetwork_DROPPED_ENTRIES ) +check_qt_class(QtNetwork QSslCertificate QtNetwork_OPTIONAL_SRC QtNetwork_DROPPED_ENTRIES) +check_qt_class(QtNetwork QSslCipher QtNetwork_OPTIONAL_SRC QtNetwork_DROPPED_ENTRIES) +check_qt_class(QtNetwork QSslConfiguration QtNetwork_OPTIONAL_SRC QtNetwork_DROPPED_ENTRIES) +check_qt_class(QtNetwork QSslError QtNetwork_OPTIONAL_SRC QtNetwork_DROPPED_ENTRIES) +check_qt_class(QtNetwork QSslKey QtNetwork_OPTIONAL_SRC QtNetwork_DROPPED_ENTRIES) +check_qt_class(QtNetwork QSslSocket QtNetwork_OPTIONAL_SRC QtNetwork_DROPPED_ENTRIES) + set(QtNetwork_SRC +${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qabstractnetworkcache_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qabstractsocket_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qauthenticator_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qftp_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qhostaddress_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qhostinfo_wrapper.cpp +${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qhttp_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qhttpheader_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qhttprequestheader_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qhttpresponseheader_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qhttp_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qipv6address_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qlocalserver_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qlocalsocket_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qnetworkaccessmanager_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qnetworkaddressentry_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qnetworkcookiejar_wrapper.cpp +${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qnetworkcachemetadata_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qnetworkcookie_wrapper.cpp +${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qnetworkcookiejar_wrapper.cpp +${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qnetworkdiskcache_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qnetworkinterface_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qnetworkproxy_wrapper.cpp +${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qnetworkproxyfactory_wrapper.cpp +${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qnetworkproxyquery_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qnetworkreply_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qnetworkrequest_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qssl_wrapper.cpp @@ -84,44 +51,33 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qtcpsocket_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qtnetwork_module_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qudpsocket_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qurlinfo_wrapper.cpp -${SPECIFIC_OS_FILES} + ${QtNetwork_47_SRC} +${QtNetwork_OPTIONAL_SRC} ) -set(OPENSSL_SOURCES - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qsslcipher_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qsslkey_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qsslconfiguration_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qsslerror_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qsslsocket_wrapper.cpp -) +set(QtNetwork_typesystem_path "${QtCore_SOURCE_DIR}${PATH_SEP}${QtCore_BINARY_DIR}") +set(QtNetwork_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/ + ${QT_INCLUDE_DIR} + ${QT_QTNETWORK_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${SHIBOKEN_PYTHON_INCLUDE_DIR} + ${QtCore_BINARY_DIR}/PySide/QtCore/) +set(QtNetwork_libraries pyside + ${SHIBOKEN_PYTHON_LIBRARIES} + ${SHIBOKEN_LIBRARY} + ${QT_QTNETWORK_LIBRARY}) -CHECK_QT_NETWORK_MACRO("Network OPENSSL" QT_NO_OPENSSL OPENSSL_SOURCES QtNetwork_SRC) +set(QtNetwork_deps QtCore) -execute_generator(network QtNetwork_SRC "${CMAKE_CURRENT_SOURCE_DIR}:${QtCore_SOURCE_DIR}") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/ - ${QT_INCLUDE_DIR} - ${QT_QTNETWORK_INCLUDE_DIR} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${PYTHON_INCLUDE_PATH} - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ) - -add_library(QtNetwork MODULE ${QtNetwork_SRC}) -set_property(TARGET QtNetwork PROPERTY PREFIX "") -target_link_libraries(QtNetwork - pyside - ${PYTHON_LIBRARIES} - ${SHIBOKEN_LIBRARY} - ${QT_QTNETWORK_LIBRARY} - ) -add_dependencies(QtNetwork QtCore) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtNetwork${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/pyside_qtnetwork_python.h - DESTINATION include/PySide/QtNetwork/) +create_pyside_module(QtNetwork + QtNetwork_include_dirs + QtNetwork_libraries + QtNetwork_deps + QtNetwork_typesystem_path + QtNetwork_SRC + "" + "" + QtNetwork_DROPPED_ENTRIES) diff --git a/PySide/QtNetwork/glue/qudpsocket_read_datagram_glue.cpp b/PySide/QtNetwork/glue/qudpsocket_read_datagram_glue.cpp deleted file mode 100644 index 95ece51..0000000 --- a/PySide/QtNetwork/glue/qudpsocket_read_datagram_glue.cpp +++ /dev/null @@ -1,6 +0,0 @@ - char data[%ARGUMENT_NAMES]; - QHostAddress ha; - quint16 port; - - %RETURN_TYPE retval = %CPPSELF.%FUNCTION_NAME(data, %ARGUMENT_NAMES, &ha, &port); - %PYARG_0 = Shiboken::makeTuple(QByteArray(data, retval), ha, port); diff --git a/PySide/QtNetwork/typesystem_network.xml b/PySide/QtNetwork/typesystem_network.xml index d3f330e..a8327cd 100644 --- a/PySide/QtNetwork/typesystem_network.xml +++ b/PySide/QtNetwork/typesystem_network.xml @@ -1,50 +1,45 @@ + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + @@ -53,6 +48,11 @@ + + + + + @@ -81,7 +81,9 @@ - + + + @@ -94,6 +96,9 @@ + + + @@ -106,7 +111,7 @@ - + @@ -115,6 +120,7 @@ + @@ -128,19 +134,29 @@ - + - + + Shiboken::AutoArrayPointer<char> data(%ARGUMENT_NAMES); + QHostAddress ha; + quint16 port; + %BEGIN_ALLOW_THREADS + %RETURN_TYPE retval = %CPPSELF.%FUNCTION_NAME(data, %ARGUMENT_NAMES, &ha, &port); + %END_ALLOW_THREADS + QByteArray ba(data, retval); + %PYARG_0 = PyTuple_New(3); + PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[QByteArray](ba)); + PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QHostAddress](ha)); + PyTuple_SET_ITEM(%PYARG_0, 2, %CONVERTTOPYTHON[quint16](port)); + - + + + - - - - - + @@ -155,13 +171,30 @@ - + - + + + + + + + + + + + + + + + + + + @@ -169,99 +202,143 @@ - + + + + + - - + + - + - - - + - - - + - - - + - + - + + + + + + + - + - - - - - - + + + return 16; + + + + + if (_i >= 16) { + PyErr_SetString(PyExc_IndexError, "index out of bounds"); + return 0; + } + if (_i < 0) + _i = 16 - qAbs(_i); + + uint item = %CPPSELF.c[_i]; + return %CONVERTTOPYTHON[uint](item); + + + + + return 16; + + + + + if (_i >= 16) { + PyErr_SetString(PyExc_IndexError, "index out of bounds"); + return -1; + } + if (_i < 0) + _i = 16 - qAbs(_i); + quint8 item = %CONVERTTOCPP[quint8](_value); + %CPPSELF.c[_i] = item; + return 0; + + - - - + - - + - + + + + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + diff --git a/PySide/QtOpenGL/CMakeLists.txt b/PySide/QtOpenGL/CMakeLists.txt index 1d79e6c..3f977db 100644 --- a/PySide/QtOpenGL/CMakeLists.txt +++ b/PySide/QtOpenGL/CMakeLists.txt @@ -32,31 +32,27 @@ set(QtOpenGL_SRC ${QtOpenGL_47_SRC} ) -execute_generator(opengl QtOpenGL_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtGui_SOURCE_DIR}:${QtOpenGL_SOURCE_DIR}") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ${QT_QTOPENGL_INCLUDE_DIR} - ${PYTHON_INCLUDE_PATH} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${QtGui_BINARY_DIR}/PySide/QtGui/ - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtOpenGL) -add_library(QtOpenGL MODULE ${QtOpenGL_SRC}) -set_target_properties(QtOpenGL PROPERTIES PREFIX "") -target_link_libraries(QtOpenGL - pyside - ${PYTHON_LIBRARIES} - ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY} - ${QT_QTOPENGL_LIBRARY}) -add_dependencies(QtOpenGL QtGui) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtOpenGL${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtOpenGL/pyside_qtopengl_python.h - DESTINATION include/PySide/QtOpenGL/) - +set(QtOpenGL_typesystem_path "${QtCore_SOURCE_DIR}${PATH_SEP}${QtCore_BINARY_DIR}${PATH_SEP}${QtGui_SOURCE_DIR}${PATH_SEP}${QtOpenGL_SOURCE_DIR}${PATH_SEP}${QtGui_BINARY_DIR}") +set(QtOpenGL_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTGUI_INCLUDE_DIR} + ${QT_QTOPENGL_INCLUDE_DIR} + ${SHIBOKEN_PYTHON_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${QtGui_BINARY_DIR}/PySide/QtGui/ + ${QtCore_BINARY_DIR}/PySide/QtCore/ + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtOpenGL) +set(QtOpenGL_libraries pyside + ${SHIBOKEN_PYTHON_LIBRARIES} + ${QT_QTCORE_LIBRARY} + ${QT_QTGUI_LIBRARY} + ${QT_QTOPENGL_LIBRARY}) +set(QtOpenGL_deps QtGui) +create_pyside_module(QtOpenGL + QtOpenGL_include_dirs + QtOpenGL_libraries + QtOpenGL_deps + QtOpenGL_typesystem_path + QtOpenGL_SRC + "") diff --git a/PySide/QtOpenGL/typesystem_opengl.xml b/PySide/QtOpenGL/typesystem_opengl.xml index c2f3ba3..60a2d18 100644 --- a/PySide/QtOpenGL/typesystem_opengl.xml +++ b/PySide/QtOpenGL/typesystem_opengl.xml @@ -1,35 +1,65 @@ + - - + + + + + + + + + + + + + + - - - - - + + + - - - + + + + @@ -37,18 +67,14 @@ - - - - - - - + - - + + + + + - @@ -67,80 +93,645 @@ - + + + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + - + - int size = %2; - if (size < 0) - size = %1->size(); - %CPPSELF.allocate((const void*) %1->data(), size); + int size = (%2 < 0) ? %1.size() : %2; + %CPPSELF.allocate((const void*) %1.data(), size); - - void *data = %CPPSELF.map(%1); - QByteArray ret; - if (data) - ret.append((const char*)data, %CPPSELF.size()); - %PYARG_0 = %CONVERTTOPYTHON[QByteArray](ret); + + Py_ssize_t dataSize = %CPPSELF.size(); + void* data = %CPPSELF.map(%1); + + if (!data) { + Py_INCREF(Py_None); + %PYARG_0 = Py_None; + } else if (%1 == QGLBuffer::ReadOnly) { + %PYARG_0 = Shiboken::Buffer::newObject(data, dataSize, Shiboken::Buffer::ReadOnly); + } else { + %PYARG_0 = Shiboken::Buffer::newObject(data, dataSize, Shiboken::Buffer::ReadWrite); + } + + + char *data = new char[%3]; bool result = %CPPSELF.read(%1, data, %3); QByteArray ret; if (result) ret.append((const char*)data, %3); - %PYARG_0 = Shiboken::makeTuple(result, ret); + %PYARG_0 = PyTuple_New(2); + PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[bool](result)); + PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QByteArray](ret)); delete[] data; - + - int size = %3; - if (size < 0) - size = %2->size(); - %CPPSELF.write(%1, (const void*) %2->data(), size); + int size = (%3 < 0) ? %2.size() : %3; + %CPPSELF.write(%1, (const void*) %2.data(), size); diff --git a/PySide/QtScript/CMakeLists.txt b/PySide/QtScript/CMakeLists.txt index 6419439..48dc85f 100644 --- a/PySide/QtScript/CMakeLists.txt +++ b/PySide/QtScript/CMakeLists.txt @@ -1,10 +1,10 @@ project(QtScript) -if (${QT_VERSION_MAJOR} EQUAL 4 AND ${QT_VERSION_MINOR} LESS 6) - set (QtCore_46_SRC ) +if (${QT_VERSION_MAJOR} EQUAL 4 AND ${QT_VERSION_MINOR} LESS 7) + set (QtScript_47_SRC ) else() - set(QtScript_46_SRC - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScript/qscriptprogram_wrapper.cpp + set(QtScript_47_SRC + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScript/qscriptprogram_wrapper.cpp ) endif() @@ -22,33 +22,28 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScript/qscriptextensionplugin_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScript/qscriptstring_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScript/qscriptvalue_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScript/qscriptvalueiterator_wrapper.cpp -${QtScript_46_SRC} +${QtScript_47_SRC} ) -execute_generator(script QtScript_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScript - ${QT_INCLUDE_DIR} - ${QT_QTSCRIPT_INCLUDE_DIR} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${PYTHON_INCLUDE_PATH} - ${QtCore_BINARY_DIR}/PySide/QtCore - ) -add_library(QtScript MODULE ${QtScript_SRC}) -set_property(TARGET QtScript PROPERTY PREFIX "") -target_link_libraries(QtScript - pyside - ${PYTHON_LIBRARIES} - ${SHIBOKEN_LIBRARY} - ${QT_QTCORE_LIBRARY} - ${QT_QTSCRIPT_LIBRARY} - ) -add_dependencies(QtScript QtCore) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtScript${CMAKE_DEBUG_POSTFIX}.so DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScript/pyside_qtscript_python.h - DESTINATION include/PySide/QtScript/) - +set(QtScript_typesystem_path "${QtCore_SOURCE_DIR}${PATH_SEP}${QtCore_BINARY_DIR}") +set(QtScript_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScript + ${QT_INCLUDE_DIR} + ${QT_QTSCRIPT_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${SHIBOKEN_PYTHON_INCLUDE_DIR} + ${QtCore_BINARY_DIR}/PySide/QtCore ) +set(QtScript_libraries pyside + ${SHIBOKEN_PYTHON_LIBRARIES} + ${SHIBOKEN_LIBRARY} + ${QT_QTCORE_LIBRARY} + ${QT_QTSCRIPT_LIBRARY}) +set(QtScript_deps QtCore) +create_pyside_module(QtScript + QtScript_include_dirs + QtScript_libraries + QtScript_deps + QtScript_typesystem_path + QtScript_SRC + "") diff --git a/PySide/QtScript/typesystem_script.xml b/PySide/QtScript/typesystem_script.xml index 81ba5b3..d787b22 100644 --- a/PySide/QtScript/typesystem_script.xml +++ b/PySide/QtScript/typesystem_script.xml @@ -1,31 +1,115 @@ + - - - - - - - - - - - - - + + + + - - - - + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + if (%CPPSELF.isVariant() || %CPPSELF.isString()) { + QString format = QString().sprintf("%s(\"%s\")", ((PyObject*)%PYSELF)->ob_type->tp_name, qPrintable(%CPPSELF.toString())); + %PYARG_0 = Shiboken::String::fromCString(qPrintable(format)); + } else { + %PYARG_0 = Shiboken::String::fromCString( + ((PyObject* )%PYSELF)->ob_type->tp_name); + } + + + + + Shiboken::AutoDecRef key(PyObject_Str(_key)); + QVariant res = %CPPSELF.property(Shiboken::String::toCString(key.object())).toVariant(); + if (res.isValid()) { + return %CONVERTTOPYTHON[QVariant](res); + } else { + PyObject* errorType = PyInt_Check(_key) ? PyExc_IndexError : PyExc_KeyError; + PyErr_SetString(errorType, "Key not found."); + return 0; + } + + + + + %PYARG_0 = Shiboken::createWrapper(new QScriptValueIterator(*%CPPSELF), true, true); + + + + + + + + + + + + if (%CPPSELF.hasNext()) { + %CPPSELF.next(); + QString name = %CPPSELF.name(); + QVariant value = %CPPSELF.value().toVariant(); + %PYARG_0 = PyTuple_New(2); + PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[QString](name)); + PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QVariant](value)); + } else { + PyErr_SetNone(PyExc_StopIteration); + } + + + diff --git a/PySide/QtScriptTools/CMakeLists.txt b/PySide/QtScriptTools/CMakeLists.txt index 1d53ff7..0a98042 100644 --- a/PySide/QtScriptTools/CMakeLists.txt +++ b/PySide/QtScriptTools/CMakeLists.txt @@ -5,36 +5,33 @@ set(QtScriptTools_SRC ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScriptTools/qscriptenginedebugger_wrapper.cpp ) -execute_generator(scripttools QtScriptTools_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtScript_SOURCE_DIR}:${QtScriptTools_SOURCE_DIR}") +set(QtScriptTools_typesystem_path "${QtCore_SOURCE_DIR}${PATH_SEP}${QtCore_BINARY_DIR}${PATH_SEP}${QtGui_SOURCE_DIR}${PATH_SEP}${QtScript_SOURCE_DIR}${PATH_SEP}${QtScriptTools_SOURCE_DIR}${PATH_SEP}${QtGui_BINARY_DIR}") -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_GUI_INCLUDE_DIR} - ${QT_QTSCRIPT_INCLUDE_DIR} - ${QT_QTSCRIPTTOOLS_INCLUDE_DIR} - ${PYTHON_INCLUDE_PATH} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ${QtGui_BINARY_DIR}/PySide/QtGui/ - ${QtScript_BINARY_DIR}/PySide/QtScript/ - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScriptTools) +set(QtScriptTools_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_GUI_INCLUDE_DIR} + ${QT_QTSCRIPT_INCLUDE_DIR} + ${QT_QTSCRIPTTOOLS_INCLUDE_DIR} + ${SHIBOKEN_PYTHON_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${QtCore_BINARY_DIR}/PySide/QtCore/ + ${QtGui_BINARY_DIR}/PySide/QtGui/ + ${QtScript_BINARY_DIR}/PySide/QtScript/ + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScriptTools) -add_library(QtScriptTools MODULE ${QtScriptTools_SRC}) -set_target_properties(QtScriptTools PROPERTIES PREFIX "") -target_link_libraries(QtScriptTools - pyside - ${PYTHON_LIBRARIES} - ${QT_QTCORE_LIBRARY} - ${QT_GUI_LIBRARY} - ${QT_QTSCRIPT_LIBRARY} - ${QT_QTSCRIPTTOOLS_LIBRARY}) - -add_dependencies(QtScriptTools QtCore QtScript QtGui) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtScriptTools${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScriptTools/pyside_qtscripttools_python.h - DESTINATION include/PySide/QtScriptTools/) +set(QtScriptTools_libraries pyside + ${SHIBOKEN_PYTHON_LIBRARIES} + ${QT_QTCORE_LIBRARY} + ${QT_GUI_LIBRARY} + ${QT_QTSCRIPT_LIBRARY} + ${QT_QTSCRIPTTOOLS_LIBRARY}) +set(QtScriptTools_deps QtCore QtScript QtGui) +create_pyside_module(QtScriptTools + QtScriptTools_include_dirs + QtScriptTools_libraries + QtScriptTools_deps + QtScriptTools_typesystem_path + QtScriptTools_SRC + "") diff --git a/PySide/QtScriptTools/typesystem_scripttools.xml b/PySide/QtScriptTools/typesystem_scripttools.xml index 45bc04b..5c2b5e0 100644 --- a/PySide/QtScriptTools/typesystem_scripttools.xml +++ b/PySide/QtScriptTools/typesystem_scripttools.xml @@ -1,15 +1,31 @@ + - - - - - - + + + diff --git a/PySide/QtSql/CMakeLists.txt b/PySide/QtSql/CMakeLists.txt index 8040f01..f1dc384 100644 --- a/PySide/QtSql/CMakeLists.txt +++ b/PySide/QtSql/CMakeLists.txt @@ -21,32 +21,27 @@ set(QtSql_SRC ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtSql/qtsql_module_wrapper.cpp ) -execute_generator(sql QtSql_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtGui_SOURCE_DIR}:${QtSql_SOURCE_DIR}") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ${QT_QTSQL_INCLUDE_DIR} - ${PYTHON_INCLUDE_PATH} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ${QtGui_BINARY_DIR}/PySide/QtGui/ - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtSql/) -add_library(QtSql MODULE ${QtSql_SRC}) -set_target_properties(QtSql PROPERTIES PREFIX "") -target_link_libraries(QtSql - pyside - ${PYTHON_LIBRARIES} - ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY} - ${QT_QTSQL_LIBRARY}) - -add_dependencies(QtSql QtGui) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtSql${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtSql/pyside_qtsql_python.h - DESTINATION include/PySide/QtSql/) - +set(QtSql_typesystem_path "${QtCore_SOURCE_DIR}${PATH_SEP}${QtCore_BINARY_DIR}${PATH_SEP}${QtGui_SOURCE_DIR}${PATH_SEP}${QtSql_SOURCE_DIR}${PATH_SEP}${QtGui_BINARY_DIR}") +set(QtSql_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTGUI_INCLUDE_DIR} + ${QT_QTSQL_INCLUDE_DIR} + ${SHIBOKEN_PYTHON_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${QtCore_BINARY_DIR}/PySide/QtCore/ + ${QtGui_BINARY_DIR}/PySide/QtGui/ + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtSql/) +set(QtSql_libraries pyside + ${SHIBOKEN_PYTHON_LIBRARIES} + ${QT_QTCORE_LIBRARY} + ${QT_QTGUI_LIBRARY} + ${QT_QTSQL_LIBRARY}) +set(QtSql_deps QtGui) +create_pyside_module(QtSql + QtSql_include_dirs + QtSql_libraries + QtSql_deps + QtSql_typesystem_path + QtSql_SRC + "") diff --git a/PySide/QtSql/typesystem_sql.xml b/PySide/QtSql/typesystem_sql.xml index 31cc8d3..2efe429 100644 --- a/PySide/QtSql/typesystem_sql.xml +++ b/PySide/QtSql/typesystem_sql.xml @@ -1,4 +1,23 @@ + @@ -7,6 +26,10 @@ + + + + @@ -21,7 +44,6 @@ - @@ -36,6 +58,7 @@ + @@ -44,7 +67,6 @@ - @@ -59,26 +81,26 @@ - - + - - - + - + + + + @@ -91,7 +113,9 @@ + + @@ -112,6 +136,8 @@ + + @@ -119,7 +145,9 @@ + + @@ -129,6 +157,7 @@ + @@ -141,18 +170,4 @@ - - - - - - - - - - - - - - diff --git a/PySide/QtSvg/CMakeLists.txt b/PySide/QtSvg/CMakeLists.txt index 42129c7..eb0f9a2 100644 --- a/PySide/QtSvg/CMakeLists.txt +++ b/PySide/QtSvg/CMakeLists.txt @@ -1,63 +1,35 @@ project(QtSvg) -if(Q_WS_X11) - set(MODULE_NAME svg_x11) - set(SPECIFIC_OS_FILES - ) -elseif(Q_WS_MAC) - set(MODULE_NAME svg_mac) - set(SPECIFIC_OS_FILES - ) -else() - message(FATAL_ERROR "OS not supported") -endif(Q_WS_X11) - -if (${QT_VERSION_MAJOR} EQUAL 4 AND ${QT_VERSION_MINOR} LESS 6) - set (QtSvg_46_SRC ) -else () - set(QtSvg_46_SRC - ) -endif (${QT_VERSION_MAJOR} EQUAL 4 AND ${QT_VERSION_MINOR} LESS 6) - set(QtSvg_SRC ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtSvg/qgraphicssvgitem_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtSvg/qsvggenerator_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtSvg/qsvgrenderer_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtSvg/qsvgwidget_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtSvg/qtsvg_module_wrapper.cpp - -${SPECIFIC_OS_FILES} -${QtSvg_46_SRC} ) -execute_generator(svg QtSvg_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_SOURCE_DIR}:${QtGui_BINARY_DIR}") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtSvg/ - ${QT_INCLUDE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ${QT_QTSVG_INCLUDE_DIR} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${PYTHON_INCLUDE_PATH} - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ${QtGui_BINARY_DIR}/PySide/QtGui/ - ) - -add_library(QtSvg MODULE ${QtSvg_SRC}) -set_property(TARGET QtSvg PROPERTY PREFIX "") -target_link_libraries(QtSvg - pyside - ${PYTHON_LIBRARIES} - ${SHIBOKEN_LIBRARY} - ${QT_QTSVG_LIBRARY} - ${QT_QTGUI_LIBRARY} - ) -add_dependencies(QtSvg QtGui) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtSvg${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtSvg/pyside_qtsvg_python.h - DESTINATION include/PySide/QtSvg/) +set(QtSvg_typesystem_path "${QtCore_SOURCE_DIR}${PATH_SEP}${QtCore_BINARY_DIR}${PATH_SEP}${QtGui_SOURCE_DIR}${PATH_SEP}${QtGui_BINARY_DIR}") +set(QtSvg_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtSvg/ + ${QT_INCLUDE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTGUI_INCLUDE_DIR} + ${QT_QTSVG_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${SHIBOKEN_PYTHON_INCLUDE_DIR} + ${QtCore_BINARY_DIR}/PySide/QtCore/ + ${QtGui_BINARY_DIR}/PySide/QtGui/) +set(QtSvg_libraries pyside + ${SHIBOKEN_PYTHON_LIBRARIES} + ${SHIBOKEN_LIBRARY} + ${QT_QTSVG_LIBRARY} + ${QT_QTGUI_LIBRARY}) +set(QtSvg_deps QtGui) +create_pyside_module(QtSvg + QtSvg_include_dirs + QtSvg_libraries + QtSvg_deps + QtSvg_typesystem_path + QtSvg_SRC + "") diff --git a/PySide/QtSvg/typesystem_svg.xml b/PySide/QtSvg/typesystem_svg.xml index 5cc1b51..0592fc6 100644 --- a/PySide/QtSvg/typesystem_svg.xml +++ b/PySide/QtSvg/typesystem_svg.xml @@ -1,4 +1,23 @@ + @@ -8,7 +27,7 @@ - + diff --git a/PySide/QtTest/CMakeLists.txt b/PySide/QtTest/CMakeLists.txt index e6e2953..bf86ad5 100644 --- a/PySide/QtTest/CMakeLists.txt +++ b/PySide/QtTest/CMakeLists.txt @@ -1,51 +1,42 @@ project(QtTest) -if(Q_WS_X11) - set(MODULE_NAME test_x11) - set(SPECIFIC_OS_FILES - ) -elseif(Q_WS_MAC) - set(MODULE_NAME test_mac) - set(SPECIFIC_OS_FILES - ) +if (${QT_VERSION_MAJOR} EQUAL 4 AND ${QT_VERSION_MINOR} LESS 6) + set(QtTest_46_SRC "") else() - message(FATAL_ERROR "OS not supported") -endif(Q_WS_X11) + set(QtTest_46_SRC + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtTest/qtest_pysideqtoucheventsequence_wrapper.cpp + ) +endif() set(QtTest_SRC ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtTest/qtest_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtTest/qttest_module_wrapper.cpp -${SPECIFIC_OS_FILES} +${QtTest_46_SRC} ) -execute_generator(test QtTest_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_SOURCE_DIR}:${QtGui_BINARY_DIR}") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtTest/ - ${QT_INCLUDE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ${QT_QTTEST_INCLUDE_DIR} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${PYTHON_INCLUDE_PATH} - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ${QtGui_BINARY_DIR}/PySide/QtGui/ - ) - -add_library(QtTest MODULE ${QtTest_SRC}) -set_property(TARGET QtTest PROPERTY PREFIX "") -target_link_libraries(QtTest - ${PYTHON_LIBRARIES} - ${SHIBOKEN_LIBRARY} - ${QT_QTTEST_LIBRARY} - ${QT_QTGUI_LIBRARY} - ${QT_QTCORE_LIBRARY} - ) -add_dependencies(QtTest QtGui) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtTest${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtTest/pyside_qttest_python.h - DESTINATION include/PySide/QtTest/) +set(QtTest_typesystem_path "${QtCore_SOURCE_DIR}${PATH_SEP}${QtCore_BINARY_DIR}${PATH_SEP}${QtGui_SOURCE_DIR}${PATH_SEP}${QtGui_BINARY_DIR}") +set(QtTest_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtTest/ + ${QT_INCLUDE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTGUI_INCLUDE_DIR} + ${QT_QTTEST_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${SHIBOKEN_PYTHON_INCLUDE_DIR} + ${QtCore_BINARY_DIR}/PySide/QtCore/ + ${QtGui_BINARY_DIR}/PySide/QtGui/) +set(QtTest_libraries pyside + ${SHIBOKEN_PYTHON_LIBRARIES} + ${SHIBOKEN_LIBRARY} + ${QT_QTTEST_LIBRARY} + ${QT_QTGUI_LIBRARY} + ${QT_QTCORE_LIBRARY}) +set(QtTest_deps QtGui) +create_pyside_module(QtTest + QtTest_include_dirs + QtTest_libraries + QtTest_deps + QtTest_typesystem_path + QtTest_SRC + "") diff --git a/PySide/QtTest/typesystem_test.xml b/PySide/QtTest/typesystem_test.xml index cbf8add..4a1a72c 100644 --- a/PySide/QtTest/typesystem_test.xml +++ b/PySide/QtTest/typesystem_test.xml @@ -1,4 +1,23 @@ + @@ -6,6 +25,8 @@ + + @@ -16,24 +37,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - diff --git a/PySide/QtUiTools/CMakeLists.txt b/PySide/QtUiTools/CMakeLists.txt index eaea414..89d2988 100644 --- a/PySide/QtUiTools/CMakeLists.txt +++ b/PySide/QtUiTools/CMakeLists.txt @@ -5,35 +5,34 @@ set(QtUiTools_SRC ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtUiTools/quiloader_wrapper.cpp ) -execute_generator(uitools QtUiTools_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtGui_SOURCE_DIR}:${QtXml_SOURCE_DIR}:${QtUiTools_SOURCE_DIR}") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ${QT_QTXML_INCLUDE_DIR} - ${QT_QTUITOOLS_INCLUDE_DIR} - ${PYTHON_INCLUDE_PATH} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ${QtXml_BINARY_DIR}/PySide/QtXml/ - ${QtGui_BINARY_DIR}/PySide/QtGui/ - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtUiTools) - -add_library(QtUiTools MODULE ${QtUiTools_SRC}) -set_target_properties(QtUiTools PROPERTIES PREFIX "") -target_link_libraries(QtUiTools - pyside - ${PYTHON_LIBRARIES} - ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY} - ${QT_QTUITOOLS_LIBRARY}) - -add_dependencies(QtUiTools QtGui QtXml) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtUiTools${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtUiTools/pyside_qtuitools_python.h - DESTINATION include/PySide/QtUiTools/) +set(QtUiTools_typesystem_path "${QtCore_SOURCE_DIR}${PATH_SEP}${QtCore_BINARY_DIR}${PATH_SEP}${QtGui_SOURCE_DIR}${PATH_SEP}${QtXml_SOURCE_DIR}${PATH_SEP}${QtUiTools_SOURCE_DIR}${PATH_SEP}${QtGui_BINARY_DIR}") +set(QtUiTools_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTGUI_INCLUDE_DIR} + ${QT_QTXML_INCLUDE_DIR} + ${QT_QTDESIGNER_INCLUDE_DIR} + ${QT_QTUITOOLS_INCLUDE_DIR} + ${SHIBOKEN_PYTHON_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${plugins_SOURCE_DIR} + ${QtCore_BINARY_DIR}/PySide/QtCore/ + ${QtXml_BINARY_DIR}/PySide/QtXml/ + ${QtGui_BINARY_DIR}/PySide/QtGui/ + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtUiTools) +set(QtUiTools_libraries pyside + uiplugin + ${SHIBOKEN_PYTHON_LIBRARIES} + ${QT_QTUITOOLS_LIBRARY} + ${QT_QTDESIGNER_LIBRARY} + ${QT_QTCORE_LIBRARY} + ${QT_QTGUI_LIBRARY}) +set(QtUiTools_deps QtGui QtXml) +create_pyside_module(QtUiTools + QtUiTools_include_dirs + QtUiTools_libraries + QtUiTools_deps + QtUiTools_typesystem_path + QtUiTools_SRC + "") diff --git a/PySide/QtUiTools/glue/plugins.h b/PySide/QtUiTools/glue/plugins.h new file mode 100644 index 0000000..78e5a20 --- /dev/null +++ b/PySide/QtUiTools/glue/plugins.h @@ -0,0 +1,47 @@ +/* + * This file is part of the PySide project. + * + * Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). + * + * Contact: PySide team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _PLUGIN_H_ +#define _PLUGIN_H_ + +#include +#include "customwidgets.h" + +inline void registerCustomWidget(PyObject* obj) +{ + static PyCustomWidgets* plugin = 0; + + if (plugin == 0) { + foreach(QObject* o, QPluginLoader::staticInstances()) { + plugin = qobject_cast(o); + if (plugin) + break; + } + } + + if (!plugin) + qDebug() << "Failed to load uiloader plugin."; + else + plugin->registerWidgetType(obj); +} + +#endif diff --git a/PySide/QtUiTools/glue/uitools_loadui.cpp b/PySide/QtUiTools/glue/uitools_loadui.cpp new file mode 100644 index 0000000..829adf7 --- /dev/null +++ b/PySide/QtUiTools/glue/uitools_loadui.cpp @@ -0,0 +1,52 @@ +/* + * Based on code provided by: + * Antonio Valentino + * Frédéric + */ + +#include +#include +#include +#include + +static void createChildrenNameAttributes(PyObject* root, QObject* object) +{ + foreach (QObject* child, object->children()) { + const QByteArray name = child->objectName().toLocal8Bit(); + + if (!name.isEmpty() && !name.startsWith("_") && !name.startsWith("qt_")) { + bool hasAttr = PyObject_HasAttrString(root, name.constData()); + if (!hasAttr) { + Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[QObject*](child)); + PyObject_SetAttrString(root, name.constData(), pyChild); + } + createChildrenNameAttributes(root, child); + } + createChildrenNameAttributes(root, child); + } +} + +static PyObject* QUiLoadedLoadUiFromDevice(QUiLoader* self, QIODevice* dev, QWidget* parent) +{ + QWidget* wdg = self->load(dev, parent); + + if (wdg) { + PyObject* pyWdg = %CONVERTTOPYTHON[QWidget*](wdg); + createChildrenNameAttributes(pyWdg, wdg); + if (parent) { + Shiboken::AutoDecRef pyParent(%CONVERTTOPYTHON[QWidget*](parent)); + Shiboken::Object::setParent(pyParent, pyWdg); + } + return pyWdg; + } + + if (!PyErr_Occurred()) + PyErr_SetString(PyExc_RuntimeError, "Unable to open/read ui device"); + return 0; +} + +static PyObject* QUiLoaderLoadUiFromFileName(QUiLoader* self, const QString& uiFile, QWidget* parent) +{ + QFile fd(uiFile); + return QUiLoadedLoadUiFromDevice(self, &fd, parent); +} diff --git a/PySide/QtUiTools/typesystem_uitools.xml b/PySide/QtUiTools/typesystem_uitools.xml index c155bff..08e98bd 100644 --- a/PySide/QtUiTools/typesystem_uitools.xml +++ b/PySide/QtUiTools/typesystem_uitools.xml @@ -1,50 +1,126 @@ - + + + - + + + + + + Q_IMPORT_PLUGIN(uiplugin); + + + + + + + Registers a Python created custom widget to QUiLoader, so it can be recognized when + loading a `.ui` file. The custom widget type is passed via the ``customWidgetType`` argument. + This is needed when you want to override a virtual method of some widget in the interface, + since duck punching will not work with widgets created by QUiLoader based on the contents + of the `.ui` file. + + (Remember that `duck punching virtual methods is an invitation for your own demise! + <http://www.pyside.org/docs/shiboken/wordsofadvice.html#duck-punching-and-virtual-methods>`_) + + Let's see an obvious example. If you want to create a new widget it's probable you'll end up + overriding :class:`~PySide.QtGui.QWidget`'s :meth:`~PySide.QtGui.QWidget.paintEvent` method. + + .. code-block:: python + + class Circle(QWidget): + def paintEvent(self, event): + painter = QPainter(self) + painter.setPen(self.pen) + painter.setBrush(QBrush(self.color)) + painter.drawEllipse(event.rect().center(), 20, 20) + + # ... + + loader = QUiLoader() + loader.registerCustomWidget(Circle) + circle = loader.load('circle.ui') + circle.show() + + # ... + + + registerCustomWidget(%PYARG_1); + %CPPSELF.addPluginPath(""); // force reload widgets + + + - + - + - + - + + - - + + + - - - - - + - QFile f(%1); - if (f.open(QIODevice::ReadOnly | QIODevice::Text)) - %PYARG_0 = %CONVERTTOPYTHON[QWidget*](%CPPSELF.load(&f, %2)); - else - PyErr_SetString(PyExc_RuntimeError, "Unable to open ui file"); + // Avoid calling the original function: %CPPSELF.%FUNCTION_NAME() + %PYARG_0 = QUiLoadedLoadUiFromDevice(%CPPSELF, %1, %2); + + + + + + + + + + + + + + // Avoid calling the original function: %CPPSELF.%FUNCTION_NAME() + %PYARG_0 = QUiLoaderLoadUiFromFileName(%CPPSELF, %1, %2); diff --git a/PySide/QtWebKit/CMakeLists.txt b/PySide/QtWebKit/CMakeLists.txt index 09f5bfa..74d89f8 100644 --- a/PySide/QtWebKit/CMakeLists.txt +++ b/PySide/QtWebKit/CMakeLists.txt @@ -1,17 +1,5 @@ project(QtWebKit) -if(Q_WS_X11) - set(MODULE_NAME webkit_x11) - set(SPECIFIC_OS_FILES - ) -elseif(Q_WS_MAC) - set(MODULE_NAME webkit_mac) - set(SPECIFIC_OS_FILES - ) -else() - message(FATAL_ERROR "OS not supported") -endif(Q_WS_X11) - if (${QT_VERSION_MAJOR} EQUAL 4 AND ${QT_VERSION_MINOR} LESS 6) set (QtWebKit_46_SRC ) else () @@ -19,9 +7,11 @@ else () ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebKit/qwebelement_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebKit/qwebelementcollection_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebKit/qwebinspector_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebKit/qwebpage_errorpageextensionoption_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebKit/qwebpage_errorpageextensionreturn_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebKit/qgraphicswebview_wrapper.cpp ) -endif (${QT_VERSION_MAJOR} EQUAL 4 AND ${QT_VERSION_MINOR} LESS 6) +endif () set(QtWebKit_SRC ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebKit/qtwebkit_module_wrapper.cpp @@ -32,6 +22,10 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebKit/qwebhistoryitem_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebKit/qwebhistory_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebKit/qwebhittestresult_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebKit/qwebpage_wrapper.cpp +${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebKit/qwebpage_choosemultiplefilesextensionoption_wrapper.cpp +${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebKit/qwebpage_choosemultiplefilesextensionreturn_wrapper.cpp +${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebKit/qwebpage_extensionoption_wrapper.cpp +${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebKit/qwebpage_extensionreturn_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebKit/qwebpluginfactory_mimetype_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebKit/qwebpluginfactory_plugin_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebKit/qwebpluginfactory_wrapper.cpp @@ -40,42 +34,35 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebKit/qwebsettings_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebKit/qwebview_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebKit/webcore_wrapper.cpp -${SPECIFIC_OS_FILES} ${QtWebKit_46_SRC} ) -execute_generator(webkit QtWebKit_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtNetwork_SOURCE_DIR}") +set(QtWebKit_typesystem_path "${QtCore_SOURCE_DIR}${PATH_SEP}${QtCore_BINARY_DIR}${PATH_SEP}${QtGui_SOURCE_DIR}${PATH_SEP}${QtNetwork_SOURCE_DIR}${PATH_SEP}${QtGui_BINARY_DIR}") +set(QtWebkit_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebkit/ + ${QT_INCLUDE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTGUI_INCLUDE_DIR} + ${QT_QTNETWORK_INCLUDE_DIR} + ${QT_QTWEBKIT_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${SHIBOKEN_PYTHON_INCLUDE_DIR} + ${QtCore_BINARY_DIR}/PySide/QtCore/ + ${QtGui_BINARY_DIR}/PySide/QtGui/ + ${QtNetwork_BINARY_DIR}/PySide/QtNetwork/ ) +set(QtWebKit_libraries pyside + ${SHIBOKEN_PYTHON_LIBRARIES} + ${SHIBOKEN_LIBRARY} + ${QT_QTWEBKIT_LIBRARY} + ${QT_QTNETWORK_LIBRARY} + ${QT_QTGUI_LIBRARY}) +set(QtWebKit_deps QtGui QtNetwork) +create_pyside_module(QtWebKit + QtWebkit_include_dirs + QtWebKit_libraries + QtWebKit_deps + QtWebKit_typesystem_path + QtWebKit_SRC + "") -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebkit/ - ${QT_INCLUDE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ${QT_QTNETWORK_INCLUDE_DIR} - ${QT_QTWEBKIT_INCLUDE_DIR} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${PYTHON_INCLUDE_PATH} - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ${QtGui_BINARY_DIR}/PySide/QtGui/ - ${QtNetwork_BINARY_DIR}/PySide/QtNetwork/ - ) - -add_library(QtWebKit MODULE ${QtWebKit_SRC}) -set_property(TARGET QtWebKit PROPERTY PREFIX "") -target_link_libraries(QtWebKit - pyside - ${PYTHON_LIBRARIES} - ${SHIBOKEN_LIBRARY} - ${QT_QTWEBKIT_LIBRARY} - ${QT_QTNETWORK_LIBRARY} - ${QT_QTGUI_LIBRARY} - ) -add_dependencies(QtWebKit QtGui) -add_dependencies(QtWebKit QtNetwork) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtWebKit${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebKit/pyside_qtwebkit_python.h - DESTINATION include/PySide/QtWebKit/) diff --git a/PySide/QtWebKit/typesystem_webkit.xml b/PySide/QtWebKit/typesystem_webkit.xml index dd3b5ba..86b8431 100644 --- a/PySide/QtWebKit/typesystem_webkit.xml +++ b/PySide/QtWebKit/typesystem_webkit.xml @@ -1,4 +1,23 @@ + @@ -6,60 +25,208 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + SbkObject* _pyReturn = reinterpret_cast<SbkObject*>(%PYARG_0); + if (!Shiboken::Object::hasParentInfo(_pyReturn)) + Shiboken::Object::setParent(%PYSELF, %PYARG_0); + + + - - + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + QString _local; + QString* %4 = &_local; + + + + + + Shiboken::AutoDecRef pyRes(PySequence_GetItem(%PYARG_0, 0)); + Shiboken::AutoDecRef pyStr(PySequence_GetItem(%PYARG_0, 1)); + %RETURN_TYPE %out = %CONVERTTOCPP[%RETURN_TYPE](pyRes); + *%4 = %CONVERTTOCPP[QString](pyStr); + + + %PYARG_0 = PyTuple_New(2); + PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](%0)); + PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QString](*%4)); + + + + + + + static int _signalIndex = -1; + static QMetaMethod _m; + + if (_signalIndex == -1) { + _signalIndex = QWebPage::staticMetaObject.indexOfSlot("shouldInterruptJavaScript()"); + _m = QWebPage::staticMetaObject.method(_signalIndex); + } + + if (_signalIndex == id) { + Shiboken::GilState gil; + PyObject* self = (PyObject*)Shiboken::BindingManager::instance().retrieveWrapper(this); + if (self) { + Shiboken::AutoDecRef _pyMethod(PyObject_GetAttrString(self, "shouldInterruptJavaScript")); + return PySide::SignalManager::callPythonMetaMethod(_m, args, _pyMethod, false); + } + } + + + - - - + + + + + + + + + + + - - - - + + + + + + + + + return %CPPSELF.count(); + + + + + if (_i < 0 || _i >= %CPPSELF.count()) { + PyErr_SetString(PyExc_IndexError, "index out of bounds"); + return 0; + } + QWebElement element = %CPPSELF.at(_i); + return %CONVERTTOPYTHON[QWebElement](element); + + + diff --git a/PySide/QtWebKit/typesystem_webkit_simulator.xml b/PySide/QtWebKit/typesystem_webkit_simulator.xml new file mode 100644 index 0000000..ff195be --- /dev/null +++ b/PySide/QtWebKit/typesystem_webkit_simulator.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + diff --git a/PySide/QtXml/CMakeLists.txt b/PySide/QtXml/CMakeLists.txt index 6ee39d7..3e5a7c7 100644 --- a/PySide/QtXml/CMakeLists.txt +++ b/PySide/QtXml/CMakeLists.txt @@ -35,31 +35,26 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtXml/qxmlreader_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtXml/qxmlsimplereader_wrapper.cpp ) -execute_generator(xml QtXml_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtXml - ${CMAKE_SOURCE_DIR} - ${QT_INCLUDE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTXML_INCLUDE_DIR} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${PYTHON_INCLUDE_PATH} - ${QtCore_BINARY_DIR}/PySide/QtCore - ) -add_library(QtXml MODULE ${QtXml_SRC}) -set_property(TARGET QtXml PROPERTY PREFIX "") -target_link_libraries(QtXml - pyside - ${PYTHON_LIBRARIES} - ${SHIBOKEN_LIBRARY} - ${QT_QTXML_LIBRARY} - ) -add_dependencies(QtXml QtCore) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtXml${CMAKE_DEBUG_POSTFIX}.so DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtXml/pyside_qtxml_python.h - DESTINATION include/PySide/QtXml/) - +set(QtXml_typesystem_path "${QtCore_SOURCE_DIR}${PATH_SEP}${QtCore_BINARY_DIR}") +set(QtXml_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtXml + ${CMAKE_SOURCE_DIR} + ${QT_INCLUDE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTXML_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${SHIBOKEN_PYTHON_INCLUDE_DIR} + ${QtCore_BINARY_DIR}/PySide/QtCore) +set(QtXml_libraries pyside + ${SHIBOKEN_PYTHON_LIBRARIES} + ${SHIBOKEN_LIBRARY} + ${QT_QTXML_LIBRARY}) +set(QtXml_deps QtCore) +create_pyside_module(QtXml + QtXml_include_dirs + QtXml_libraries + QtXml_deps + QtXml_typesystem_path + QtXml_SRC + "") diff --git a/PySide/QtXml/typesystem_xml.xml b/PySide/QtXml/typesystem_xml.xml index 5c0811e..19b1520 100644 --- a/PySide/QtXml/typesystem_xml.xml +++ b/PySide/QtXml/typesystem_xml.xml @@ -1,4 +1,23 @@ + @@ -8,46 +27,26 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - @@ -62,6 +61,9 @@ + + + @@ -79,6 +81,9 @@ + + + @@ -96,6 +101,9 @@ + + + @@ -113,6 +121,9 @@ + + + @@ -130,6 +141,9 @@ + + + @@ -147,6 +161,9 @@ + + + @@ -164,6 +181,9 @@ + + + @@ -181,80 +201,42 @@ + + + - - - - - - - - - - - - - - - - - - - - + + + + - + - - - + - + + - - - + + + - - - - + - - - - - - - - - - - - - + - @@ -272,8 +254,8 @@ @@ -290,9 +272,13 @@ - QXmlInputSource* _qxmlinputsource_arg_ = 0; - %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(%1, %2, _qxmlinputsource_arg_); - %PYARG_0 = Shiboken::makeTuple(%0, _qxmlinputsource_arg_); + QXmlInputSource* _qxmlinputsource_arg_ = 0; + %BEGIN_ALLOW_THREADS + %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(%1, %2, _qxmlinputsource_arg_); + %END_ALLOW_THREADS + %PYARG_0 = PyTuple_New(2); + PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](%0)); + PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QXmlInputSource*](_qxmlinputsource_arg_)); @@ -313,23 +299,19 @@ - QXmlInputSource* _qxmlinputsource_arg_ = 0; - %RETURN_TYPE %0 = %CPPSELF.%TYPE::%FUNCTION_NAME(%1, %2, _qxmlinputsource_arg_); - %PYARG_0 = Shiboken::makeTuple(%0, _qxmlinputsource_arg_); + QXmlInputSource* _qxmlinputsource_arg_ = 0; + %BEGIN_ALLOW_THREADS + %RETURN_TYPE %0 = %CPPSELF.%TYPE::%FUNCTION_NAME(%1, %2, _qxmlinputsource_arg_); + %END_ALLOW_THREADS + %PYARG_0 = PyTuple_New(2); + PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](%0)); + PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QXmlInputSource*](_qxmlinputsource_arg_)); - - @@ -432,9 +414,5 @@ - - - - diff --git a/PySide/QtXmlPatterns/CMakeLists.txt b/PySide/QtXmlPatterns/CMakeLists.txt index 73c6e1d..6efa4b0 100644 --- a/PySide/QtXmlPatterns/CMakeLists.txt +++ b/PySide/QtXmlPatterns/CMakeLists.txt @@ -26,28 +26,25 @@ set(QtXmlPatterns_SRC ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtXmlPatterns/qxmlserializer_wrapper.cpp ${QtXmlPatterns_46_SRC} ) - -execute_generator(xmlpatterns QtXmlPatterns_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTXMLPATTERNS_INCLUDE_DIR} - ${PYTHON_INCLUDE_PATH} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtXmlPatterns) -add_library(QtXmlPatterns MODULE ${QtXmlPatterns_SRC}) -set_target_properties(QtXmlPatterns PROPERTIES PREFIX "") -target_link_libraries(QtXmlPatterns - pyside - ${PYTHON_LIBRARIES} - ${QT_QTCORE_LIBRARY} - ${QT_QTXMLPATTERNS_LIBRARY}) -add_dependencies(QtXmlPatterns QtCore) -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtXmlPatterns${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtXmlPatterns/pyside_qtxmlpatterns_python.h - DESTINATION include/PySide/QtXmlPatterns/) +set(QtXmlPatterns_typesystem_path "${QtCore_SOURCE_DIR}${PATH_SEP}${QtCore_BINARY_DIR}") +set(QtXmlPatterns_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTXMLPATTERNS_INCLUDE_DIR} + ${SHIBOKEN_PYTHON_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${QtCore_BINARY_DIR}/PySide/QtCore/ + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtXmlPatterns) +set(QtXmlPatterns_libraries pyside + ${SHIBOKEN_PYTHON_LIBRARIES} + ${QT_QTCORE_LIBRARY} + ${QT_QTXMLPATTERNS_LIBRARY}) +set(QtXmlPatterns_deps QtCore) +create_pyside_module(QtXmlPatterns + QtXmlPatterns_include_dirs + QtXmlPatterns_libraries + QtXmlPatterns_deps + QtXmlPatterns_typesystem_path + QtXmlPatterns_SRC + "") diff --git a/PySide/QtXmlPatterns/typesystem_xmlpatterns.xml b/PySide/QtXmlPatterns/typesystem_xmlpatterns.xml index 4f10bda..d3ae58f 100644 --- a/PySide/QtXmlPatterns/typesystem_xmlpatterns.xml +++ b/PySide/QtXmlPatterns/typesystem_xmlpatterns.xml @@ -1,24 +1,51 @@ + - - - - - - - - - + + + + + + + + + QXmlSchema* %0 = new QXmlSchema(%CPPSELF.schema()); + %PYARG_0 = %CONVERTTOPYTHON[QXmlSchema*](%0); + + + - + + + + + @@ -30,11 +57,19 @@ + + + + + + + - - + + + @@ -48,13 +83,19 @@ + - + + + + + + + - - - + + diff --git a/PySide/__init__.py b/PySide/__init__.py deleted file mode 100644 index d9db08e..0000000 --- a/PySide/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__all__ = ['QtCore', 'QtGui', 'QtNetwork', 'QtOpenGL', 'QtSql', 'QtSvg', 'QtTest', 'QtWebKit', 'QtScript'] diff --git a/PySide/__init__.py.in b/PySide/__init__.py.in new file mode 100644 index 0000000..da6cd69 --- /dev/null +++ b/PySide/__init__.py.in @@ -0,0 +1,3 @@ +__all__ = ['QtCore', 'QtGui', 'QtNetwork', 'QtOpenGL', 'QtSql', 'QtSvg', 'QtTest', 'QtWebKit', 'QtScript'] +__version__ = "@BINDING_API_VERSION_FULL@" +__version_info__ = (@BINDING_API_MAJOR_VERSION@, @BINDING_API_MINOR_VERSION@, @BINDING_API_MICRO_VERSION@, "@BINDING_API_RELEASE_LEVEL@", @BINDING_API_SERIAL@) diff --git a/PySide/global.h.in b/PySide/global.h.in index c9c8ba8..acd30d0 100644 --- a/PySide/global.h.in +++ b/PySide/global.h.in @@ -5,12 +5,6 @@ ** This file is part of the QtCore module of the Qt Toolkit, plus some ** modifications by PySide team. ** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software @@ -19,19 +13,6 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. ** @@ -39,8 +20,9 @@ #undef QT_NO_STL #undef QT_NO_STL_WCHAR +#define Q_BYTE_ORDER // used to enable QSysInfo.Endian detection on MacOSX -#include +#include "@QT_QTCORE_INCLUDE_DIR@/qnamespace.h" QT_BEGIN_HEADER @@ -337,1171 +319,101 @@ QT_END_HEADER #elif @ENABLE_MAC@ #define Q_WS_MAC #elif @ENABLE_WIN@ + #include "pysidewtypes.h" #define Q_WS_WIN +#elif @ENABLE_SIMULATOR@ + #define Q_WS_SIMULATOR #endif // There are symbols in Qt that exist in Debug but // not in release #define QT_NO_DEBUG -#include -#if @ENABLE_MAC@ +#include "@QT_QTCORE_INCLUDE_DIR@/QtCore" +#if @ENABLE_MAC@ || @ENABLE_WIN@ + // Workaround to parse the QApplication header + #define Q_INTERNAL_QAPP_SRC #undef qdoc #endif -#include +#include "@QT_QTGUI_INCLUDE_DIR@/QtGui" +#include "qpytextobject.h" // PySide class #if @ENABLE_X11@ - #include + #include "@QT_QTGUI_INCLUDE_DIR@/QX11Info" + #include "@QT_QTGUI_INCLUDE_DIR@/QX11EmbedContainer" + #include "@QT_QTGUI_INCLUDE_DIR@/QX11EmbedWidget" +#elif @ENABLE_MAC@ + #include "@QT_QTGUI_INCLUDE_DIR@/qmacstyle_mac.h" #endif -#include -#include -#include -#include -#include -#include +#include "@QT_QTXML_INCLUDE_DIR@/QtXml" +#include "@QT_QTUITOOLS_INCLUDE_DIR@/QtUiTools" +#include "@QT_QTNETWORK_INCLUDE_DIR@/QtNetwork" +#include "@QT_QTSCRIPT_INCLUDE_DIR@/QtScript" +#include "@QT_QTSCRIPTTOOLS_INCLUDE_DIR@/QtScriptTools" +#include "@QT_QTMULTIMEDIA_INCLUDE_DIR@/QtMultimedia" #include -#include +#include "@QT_QTDECLARATIVE_INCLUDE_DIR@/QtDeclarative" // QT_GUI_LIB must be defined to QSqlRelationalDelegate become visible #define QT_GUI_LIB #undef Q_DECLARE_INTERFACE -#include -#include +#include "@QT_QTSQL_INCLUDE_DIR@/QtSql" +#include "@QT_QTSVG_INCLUDE_DIR@/QtSvg" -#ifndef QT_NO_XMLPATTERNS -# include +#if @QT_QTXMLPATTERNS_FOUND@ +# include "@QT_QTXMLPATTERNS_INCLUDE_DIR@/QtXmlPatterns" #endif -#ifndef QT_NO_WEBKIT -# include +#if @QT_QTWEBKIT_FOUND@ +# include "@QT_QTWEBKIT_INCLUDE_DIR@/QtWebKit" #endif -#ifndef QT_NO_TEST -# include +#if @QT_QTTEST_FOUND@ +# include "@QT_QTTEST_INCLUDE_DIR@/QtTest" +#if @QT_VERSION_MINOR@ > 5 +# include "pysideqtesttouch.h" +#endif #endif // Phonon #include "phonon/pyside_phonon.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "@QT_PHONON_INCLUDE_DIR@/abstractaudiooutput.h" +#include "@QT_PHONON_INCLUDE_DIR@/abstractmediastream.h" +#include "@QT_PHONON_INCLUDE_DIR@/abstractvideooutput.h" +#include "@QT_PHONON_INCLUDE_DIR@/addoninterface.h" +#include "@QT_PHONON_INCLUDE_DIR@/audiooutput.h" +#include "@QT_PHONON_INCLUDE_DIR@/audiooutputinterface.h" +#include "@QT_PHONON_INCLUDE_DIR@/backendcapabilities.h" +#include "@QT_PHONON_INCLUDE_DIR@/backendinterface.h" +#include "@QT_PHONON_INCLUDE_DIR@/effect.h" +#include "@QT_PHONON_INCLUDE_DIR@/effectinterface.h" +#include "@QT_PHONON_INCLUDE_DIR@/effectparameter.h" +#include "@QT_PHONON_INCLUDE_DIR@/effectwidget.h" +#include "@QT_PHONON_INCLUDE_DIR@/mediacontroller.h" +#include "@QT_PHONON_INCLUDE_DIR@/medianode.h" +#include "@QT_PHONON_INCLUDE_DIR@/mediaobject.h" +#include "@QT_PHONON_INCLUDE_DIR@/mediaobjectinterface.h" +#include "@QT_PHONON_INCLUDE_DIR@/mediasource.h" +#include "@QT_PHONON_INCLUDE_DIR@/objectdescription.h" +#include "@QT_PHONON_INCLUDE_DIR@/objectdescriptionmodel.h" +#include "@QT_PHONON_INCLUDE_DIR@/path.h" +#include "@QT_PHONON_INCLUDE_DIR@/phonon_export.h" +#include "@QT_PHONON_INCLUDE_DIR@/phonondefs.h" +#include "@QT_PHONON_INCLUDE_DIR@/phononnamespace.h" +#include "@QT_PHONON_INCLUDE_DIR@/platformplugin.h" +#include "@QT_PHONON_INCLUDE_DIR@/seekslider.h" +#include "@QT_PHONON_INCLUDE_DIR@/streaminterface.h" +#include "@QT_PHONON_INCLUDE_DIR@/videoplayer.h" +#include "@QT_PHONON_INCLUDE_DIR@/videowidget.h" +#include "@QT_PHONON_INCLUDE_DIR@/videowidgetinterface.h" +#include "@QT_PHONON_INCLUDE_DIR@/volumefadereffect.h" +#include "@QT_PHONON_INCLUDE_DIR@/volumefaderinterface.h" +#include "@QT_PHONON_INCLUDE_DIR@/volumeslider.h" //QtHelp need be included after QtSql -#include +#include "@QT_QTHELP_INCLUDE_DIR@/QtHelp" #ifndef QT_NO_OPENGL -#define GL_ACCUM 0x0100 -#define GL_LOAD 0x0101 -#define GL_RETURN 0x0102 -#define GL_MULT 0x0103 -#define GL_ADD 0x0104 - -/* AlphaFunction */ -#define GL_NEVER 0x0200 -#define GL_LESS 0x0201 -#define GL_EQUAL 0x0202 -#define GL_LEQUAL 0x0203 -#define GL_GREATER 0x0204 -#define GL_NOTEQUAL 0x0205 -#define GL_GEQUAL 0x0206 -#define GL_ALWAYS 0x0207 - -/* AttribMask */ -#define GL_CURRENT_BIT 0x00000001 -#define GL_POINT_BIT 0x00000002 -#define GL_LINE_BIT 0x00000004 -#define GL_POLYGON_BIT 0x00000008 -#define GL_POLYGON_STIPPLE_BIT 0x00000010 -#define GL_PIXEL_MODE_BIT 0x00000020 -#define GL_LIGHTING_BIT 0x00000040 -#define GL_FOG_BIT 0x00000080 -#define GL_DEPTH_BUFFER_BIT 0x00000100 -#define GL_ACCUM_BUFFER_BIT 0x00000200 -#define GL_STENCIL_BUFFER_BIT 0x00000400 -#define GL_VIEWPORT_BIT 0x00000800 -#define GL_TRANSFORM_BIT 0x00001000 -#define GL_ENABLE_BIT 0x00002000 -#define GL_COLOR_BUFFER_BIT 0x00004000 -#define GL_HINT_BIT 0x00008000 -#define GL_EVAL_BIT 0x00010000 -#define GL_LIST_BIT 0x00020000 -#define GL_TEXTURE_BIT 0x00040000 -#define GL_SCISSOR_BIT 0x00080000 -#define GL_ALL_ATTRIB_BITS 0x000fffff - -/* BeginMode */ -#define GL_POINTS 0x0000 -#define GL_LINES 0x0001 -#define GL_LINE_LOOP 0x0002 -#define GL_LINE_STRIP 0x0003 -#define GL_TRIANGLES 0x0004 -#define GL_TRIANGLE_STRIP 0x0005 -#define GL_TRIANGLE_FAN 0x0006 -#define GL_QUADS 0x0007 -#define GL_QUAD_STRIP 0x0008 -#define GL_POLYGON 0x0009 - -/* BlendingFactorDest */ -#define GL_ZERO 0 -#define GL_ONE 1 -#define GL_SRC_COLOR 0x0300 -#define GL_ONE_MINUS_SRC_COLOR 0x0301 -#define GL_SRC_ALPHA 0x0302 -#define GL_ONE_MINUS_SRC_ALPHA 0x0303 -#define GL_DST_ALPHA 0x0304 -#define GL_ONE_MINUS_DST_ALPHA 0x0305 - -/* BlendingFactorSrc */ -/* GL_ZERO */ -/* GL_ONE */ -#define GL_DST_COLOR 0x0306 -#define GL_ONE_MINUS_DST_COLOR 0x0307 -#define GL_SRC_ALPHA_SATURATE 0x0308 -/* GL_SRC_ALPHA */ -/* GL_ONE_MINUS_SRC_ALPHA */ -/* GL_DST_ALPHA */ -/* GL_ONE_MINUS_DST_ALPHA */ - -/* Boolean */ -#define GL_TRUE 1 -#define GL_FALSE 0 - -/* ClearBufferMask */ -/* GL_COLOR_BUFFER_BIT */ -/* GL_ACCUM_BUFFER_BIT */ -/* GL_STENCIL_BUFFER_BIT */ -/* GL_DEPTH_BUFFER_BIT */ - -/* ClientArrayType */ -/* GL_VERTEX_ARRAY */ -/* GL_NORMAL_ARRAY */ -/* GL_COLOR_ARRAY */ -/* GL_INDEX_ARRAY */ -/* GL_TEXTURE_COORD_ARRAY */ -/* GL_EDGE_FLAG_ARRAY */ - -/* ClipPlaneName */ -#define GL_CLIP_PLANE0 0x3000 -#define GL_CLIP_PLANE1 0x3001 -#define GL_CLIP_PLANE2 0x3002 -#define GL_CLIP_PLANE3 0x3003 -#define GL_CLIP_PLANE4 0x3004 -#define GL_CLIP_PLANE5 0x3005 - -/* ColorMaterialFace */ -/* GL_FRONT */ -/* GL_BACK */ -/* GL_FRONT_AND_BACK */ - -/* ColorMaterialParameter */ -/* GL_AMBIENT */ -/* GL_DIFFUSE */ -/* GL_SPECULAR */ -/* GL_EMISSION */ -/* GL_AMBIENT_AND_DIFFUSE */ - -/* ColorPointerType */ -/* GL_BYTE */ -/* GL_UNSIGNED_BYTE */ -/* GL_SHORT */ -/* GL_UNSIGNED_SHORT */ -/* GL_INT */ -/* GL_UNSIGNED_INT */ -/* GL_FLOAT */ -/* GL_DOUBLE */ - -/* CullFaceMode */ -/* GL_FRONT */ -/* GL_BACK */ -/* GL_FRONT_AND_BACK */ - -/* DataType */ -#define GL_BYTE 0x1400 -#define GL_UNSIGNED_BYTE 0x1401 -#define GL_SHORT 0x1402 -#define GL_UNSIGNED_SHORT 0x1403 -#define GL_INT 0x1404 -#define GL_UNSIGNED_INT 0x1405 -#define GL_FLOAT 0x1406 -#define GL_2_BYTES 0x1407 -#define GL_3_BYTES 0x1408 -#define GL_4_BYTES 0x1409 -#define GL_DOUBLE 0x140A - -/* DepthFunction */ -/* GL_NEVER */ -/* GL_LESS */ -/* GL_EQUAL */ -/* GL_LEQUAL */ -/* GL_GREATER */ -/* GL_NOTEQUAL */ -/* GL_GEQUAL */ -/* GL_ALWAYS */ - -/* DrawBufferMode */ -#define GL_NONE 0 -#define GL_FRONT_LEFT 0x0400 -#define GL_FRONT_RIGHT 0x0401 -#define GL_BACK_LEFT 0x0402 -#define GL_BACK_RIGHT 0x0403 -#define GL_FRONT 0x0404 -#define GL_BACK 0x0405 -#define GL_LEFT 0x0406 -#define GL_RIGHT 0x0407 -#define GL_FRONT_AND_BACK 0x0408 -#define GL_AUX0 0x0409 -#define GL_AUX1 0x040A -#define GL_AUX2 0x040B -#define GL_AUX3 0x040C - -/* Enable */ -/* GL_FOG */ -/* GL_LIGHTING */ -/* GL_TEXTURE_1D */ -/* GL_TEXTURE_2D */ -/* GL_LINE_STIPPLE */ -/* GL_POLYGON_STIPPLE */ -/* GL_CULL_FACE */ -/* GL_ALPHA_TEST */ -/* GL_BLEND */ -/* GL_INDEX_LOGIC_OP */ -/* GL_COLOR_LOGIC_OP */ -/* GL_DITHER */ -/* GL_STENCIL_TEST */ -/* GL_DEPTH_TEST */ -/* GL_CLIP_PLANE0 */ -/* GL_CLIP_PLANE1 */ -/* GL_CLIP_PLANE2 */ -/* GL_CLIP_PLANE3 */ -/* GL_CLIP_PLANE4 */ -/* GL_CLIP_PLANE5 */ -/* GL_LIGHT0 */ -/* GL_LIGHT1 */ -/* GL_LIGHT2 */ -/* GL_LIGHT3 */ -/* GL_LIGHT4 */ -/* GL_LIGHT5 */ -/* GL_LIGHT6 */ -/* GL_LIGHT7 */ -/* GL_TEXTURE_GEN_S */ -/* GL_TEXTURE_GEN_T */ -/* GL_TEXTURE_GEN_R */ -/* GL_TEXTURE_GEN_Q */ -/* GL_MAP1_VERTEX_3 */ -/* GL_MAP1_VERTEX_4 */ -/* GL_MAP1_COLOR_4 */ -/* GL_MAP1_INDEX */ -/* GL_MAP1_NORMAL */ -/* GL_MAP1_TEXTURE_COORD_1 */ -/* GL_MAP1_TEXTURE_COORD_2 */ -/* GL_MAP1_TEXTURE_COORD_3 */ -/* GL_MAP1_TEXTURE_COORD_4 */ -/* GL_MAP2_VERTEX_3 */ -/* GL_MAP2_VERTEX_4 */ -/* GL_MAP2_COLOR_4 */ -/* GL_MAP2_INDEX */ -/* GL_MAP2_NORMAL */ -/* GL_MAP2_TEXTURE_COORD_1 */ -/* GL_MAP2_TEXTURE_COORD_2 */ -/* GL_MAP2_TEXTURE_COORD_3 */ -/* GL_MAP2_TEXTURE_COORD_4 */ -/* GL_POINT_SMOOTH */ -/* GL_LINE_SMOOTH */ -/* GL_POLYGON_SMOOTH */ -/* GL_SCISSOR_TEST */ -/* GL_COLOR_MATERIAL */ -/* GL_NORMALIZE */ -/* GL_AUTO_NORMAL */ -/* GL_VERTEX_ARRAY */ -/* GL_NORMAL_ARRAY */ -/* GL_COLOR_ARRAY */ -/* GL_INDEX_ARRAY */ -/* GL_TEXTURE_COORD_ARRAY */ -/* GL_EDGE_FLAG_ARRAY */ -/* GL_POLYGON_OFFSET_POINT */ -/* GL_POLYGON_OFFSET_LINE */ -/* GL_POLYGON_OFFSET_FILL */ - -/* ErrorCode */ -#define GL_NO_ERROR 0 -#define GL_INVALID_ENUM 0x0500 -#define GL_INVALID_VALUE 0x0501 -#define GL_INVALID_OPERATION 0x0502 -#define GL_STACK_OVERFLOW 0x0503 -#define GL_STACK_UNDERFLOW 0x0504 -#define GL_OUT_OF_MEMORY 0x0505 - -/* FeedBackMode */ -#define GL_2D 0x0600 -#define GL_3D 0x0601 -#define GL_3D_COLOR 0x0602 -#define GL_3D_COLOR_TEXTURE 0x0603 -#define GL_4D_COLOR_TEXTURE 0x0604 - -/* FeedBackToken */ -#define GL_PASS_THROUGH_TOKEN 0x0700 -#define GL_POINT_TOKEN 0x0701 -#define GL_LINE_TOKEN 0x0702 -#define GL_POLYGON_TOKEN 0x0703 -#define GL_BITMAP_TOKEN 0x0704 -#define GL_DRAW_PIXEL_TOKEN 0x0705 -#define GL_COPY_PIXEL_TOKEN 0x0706 -#define GL_LINE_RESET_TOKEN 0x0707 - -/* FogMode */ -/* GL_LINEAR */ -#define GL_EXP 0x0800 -#define GL_EXP2 0x0801 - - -/* FogParameter */ -/* GL_FOG_COLOR */ -/* GL_FOG_DENSITY */ -/* GL_FOG_END */ -/* GL_FOG_INDEX */ -/* GL_FOG_MODE */ -/* GL_FOG_START */ - -/* FrontFaceDirection */ -#define GL_CW 0x0900 -#define GL_CCW 0x0901 - -/* GetMapTarget */ -#define GL_COEFF 0x0A00 -#define GL_ORDER 0x0A01 -#define GL_DOMAIN 0x0A02 - -/* GetPixelMap */ -/* GL_PIXEL_MAP_I_TO_I */ -/* GL_PIXEL_MAP_S_TO_S */ -/* GL_PIXEL_MAP_I_TO_R */ -/* GL_PIXEL_MAP_I_TO_G */ -/* GL_PIXEL_MAP_I_TO_B */ -/* GL_PIXEL_MAP_I_TO_A */ -/* GL_PIXEL_MAP_R_TO_R */ -/* GL_PIXEL_MAP_G_TO_G */ -/* GL_PIXEL_MAP_B_TO_B */ -/* GL_PIXEL_MAP_A_TO_A */ - -/* GetPointerTarget */ -/* GL_VERTEX_ARRAY_POINTER */ -/* GL_NORMAL_ARRAY_POINTER */ -/* GL_COLOR_ARRAY_POINTER */ -/* GL_INDEX_ARRAY_POINTER */ -/* GL_TEXTURE_COORD_ARRAY_POINTER */ -/* GL_EDGE_FLAG_ARRAY_POINTER */ - -/* GetTarget */ -#define GL_CURRENT_COLOR 0x0B00 -#define GL_CURRENT_INDEX 0x0B01 -#define GL_CURRENT_NORMAL 0x0B02 -#define GL_CURRENT_TEXTURE_COORDS 0x0B03 -#define GL_CURRENT_RASTER_COLOR 0x0B04 -#define GL_CURRENT_RASTER_INDEX 0x0B05 -#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06 -#define GL_CURRENT_RASTER_POSITION 0x0B07 -#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08 -#define GL_CURRENT_RASTER_DISTANCE 0x0B09 -#define GL_POINT_SMOOTH 0x0B10 -#define GL_POINT_SIZE 0x0B11 -#define GL_POINT_SIZE_RANGE 0x0B12 -#define GL_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_LINE_SMOOTH 0x0B20 -#define GL_LINE_WIDTH 0x0B21 -#define GL_LINE_WIDTH_RANGE 0x0B22 -#define GL_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_LINE_STIPPLE 0x0B24 -#define GL_LINE_STIPPLE_PATTERN 0x0B25 -#define GL_LINE_STIPPLE_REPEAT 0x0B26 -#define GL_LIST_MODE 0x0B30 -#define GL_MAX_LIST_NESTING 0x0B31 -#define GL_LIST_BASE 0x0B32 -#define GL_LIST_INDEX 0x0B33 -#define GL_POLYGON_MODE 0x0B40 -#define GL_POLYGON_SMOOTH 0x0B41 -#define GL_POLYGON_STIPPLE 0x0B42 -#define GL_EDGE_FLAG 0x0B43 -#define GL_CULL_FACE 0x0B44 -#define GL_CULL_FACE_MODE 0x0B45 -#define GL_FRONT_FACE 0x0B46 -#define GL_LIGHTING 0x0B50 -#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 -#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 -#define GL_LIGHT_MODEL_AMBIENT 0x0B53 -#define GL_SHADE_MODEL 0x0B54 -#define GL_COLOR_MATERIAL_FACE 0x0B55 -#define GL_COLOR_MATERIAL_PARAMETER 0x0B56 -#define GL_COLOR_MATERIAL 0x0B57 -#define GL_FOG 0x0B60 -#define GL_FOG_INDEX 0x0B61 -#define GL_FOG_DENSITY 0x0B62 -#define GL_FOG_START 0x0B63 -#define GL_FOG_END 0x0B64 -#define GL_FOG_MODE 0x0B65 -#define GL_FOG_COLOR 0x0B66 -#define GL_DEPTH_RANGE 0x0B70 -#define GL_DEPTH_TEST 0x0B71 -#define GL_DEPTH_WRITEMASK 0x0B72 -#define GL_DEPTH_CLEAR_VALUE 0x0B73 -#define GL_DEPTH_FUNC 0x0B74 -#define GL_ACCUM_CLEAR_VALUE 0x0B80 -#define GL_STENCIL_TEST 0x0B90 -#define GL_STENCIL_CLEAR_VALUE 0x0B91 -#define GL_STENCIL_FUNC 0x0B92 -#define GL_STENCIL_VALUE_MASK 0x0B93 -#define GL_STENCIL_FAIL 0x0B94 -#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 -#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 -#define GL_STENCIL_REF 0x0B97 -#define GL_STENCIL_WRITEMASK 0x0B98 -#define GL_MATRIX_MODE 0x0BA0 -#define GL_NORMALIZE 0x0BA1 -#define GL_VIEWPORT 0x0BA2 -#define GL_MODELVIEW_STACK_DEPTH 0x0BA3 -#define GL_PROJECTION_STACK_DEPTH 0x0BA4 -#define GL_TEXTURE_STACK_DEPTH 0x0BA5 -#define GL_MODELVIEW_MATRIX 0x0BA6 -#define GL_PROJECTION_MATRIX 0x0BA7 -#define GL_TEXTURE_MATRIX 0x0BA8 -#define GL_ATTRIB_STACK_DEPTH 0x0BB0 -#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1 -#define GL_ALPHA_TEST 0x0BC0 -#define GL_ALPHA_TEST_FUNC 0x0BC1 -#define GL_ALPHA_TEST_REF 0x0BC2 -#define GL_DITHER 0x0BD0 -#define GL_BLEND_DST 0x0BE0 -#define GL_BLEND_SRC 0x0BE1 -#define GL_BLEND 0x0BE2 -#define GL_LOGIC_OP_MODE 0x0BF0 -#define GL_INDEX_LOGIC_OP 0x0BF1 -#define GL_COLOR_LOGIC_OP 0x0BF2 -#define GL_AUX_BUFFERS 0x0C00 -#define GL_DRAW_BUFFER 0x0C01 -#define GL_READ_BUFFER 0x0C02 -#define GL_SCISSOR_BOX 0x0C10 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_INDEX_CLEAR_VALUE 0x0C20 -#define GL_INDEX_WRITEMASK 0x0C21 -#define GL_COLOR_CLEAR_VALUE 0x0C22 -#define GL_COLOR_WRITEMASK 0x0C23 -#define GL_INDEX_MODE 0x0C30 -#define GL_RGBA_MODE 0x0C31 -#define GL_DOUBLEBUFFER 0x0C32 -#define GL_STEREO 0x0C33 -#define GL_RENDER_MODE 0x0C40 -#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 -#define GL_POINT_SMOOTH_HINT 0x0C51 -#define GL_LINE_SMOOTH_HINT 0x0C52 -#define GL_POLYGON_SMOOTH_HINT 0x0C53 -#define GL_FOG_HINT 0x0C54 -#define GL_TEXTURE_GEN_S 0x0C60 -#define GL_TEXTURE_GEN_T 0x0C61 -#define GL_TEXTURE_GEN_R 0x0C62 -#define GL_TEXTURE_GEN_Q 0x0C63 -#define GL_PIXEL_MAP_I_TO_I 0x0C70 -#define GL_PIXEL_MAP_S_TO_S 0x0C71 -#define GL_PIXEL_MAP_I_TO_R 0x0C72 -#define GL_PIXEL_MAP_I_TO_G 0x0C73 -#define GL_PIXEL_MAP_I_TO_B 0x0C74 -#define GL_PIXEL_MAP_I_TO_A 0x0C75 -#define GL_PIXEL_MAP_R_TO_R 0x0C76 -#define GL_PIXEL_MAP_G_TO_G 0x0C77 -#define GL_PIXEL_MAP_B_TO_B 0x0C78 -#define GL_PIXEL_MAP_A_TO_A 0x0C79 -#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0 -#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1 -#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2 -#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3 -#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4 -#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5 -#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6 -#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7 -#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8 -#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9 -#define GL_UNPACK_SWAP_BYTES 0x0CF0 -#define GL_UNPACK_LSB_FIRST 0x0CF1 -#define GL_UNPACK_ROW_LENGTH 0x0CF2 -#define GL_UNPACK_SKIP_ROWS 0x0CF3 -#define GL_UNPACK_SKIP_PIXELS 0x0CF4 -#define GL_UNPACK_ALIGNMENT 0x0CF5 -#define GL_PACK_SWAP_BYTES 0x0D00 -#define GL_PACK_LSB_FIRST 0x0D01 -#define GL_PACK_ROW_LENGTH 0x0D02 -#define GL_PACK_SKIP_ROWS 0x0D03 -#define GL_PACK_SKIP_PIXELS 0x0D04 -#define GL_PACK_ALIGNMENT 0x0D05 -#define GL_MAP_COLOR 0x0D10 -#define GL_MAP_STENCIL 0x0D11 -#define GL_INDEX_SHIFT 0x0D12 -#define GL_INDEX_OFFSET 0x0D13 -#define GL_RED_SCALE 0x0D14 -#define GL_RED_BIAS 0x0D15 -#define GL_ZOOM_X 0x0D16 -#define GL_ZOOM_Y 0x0D17 -#define GL_GREEN_SCALE 0x0D18 -#define GL_GREEN_BIAS 0x0D19 -#define GL_BLUE_SCALE 0x0D1A -#define GL_BLUE_BIAS 0x0D1B -#define GL_ALPHA_SCALE 0x0D1C -#define GL_ALPHA_BIAS 0x0D1D -#define GL_DEPTH_SCALE 0x0D1E -#define GL_DEPTH_BIAS 0x0D1F -#define GL_MAX_EVAL_ORDER 0x0D30 -#define GL_MAX_LIGHTS 0x0D31 -#define GL_MAX_CLIP_PLANES 0x0D32 -#define GL_MAX_TEXTURE_SIZE 0x0D33 -#define GL_MAX_PIXEL_MAP_TABLE 0x0D34 -#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 -#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 -#define GL_MAX_NAME_STACK_DEPTH 0x0D37 -#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 -#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 -#define GL_MAX_VIEWPORT_DIMS 0x0D3A -#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B -#define GL_SUBPIXEL_BITS 0x0D50 -#define GL_INDEX_BITS 0x0D51 -#define GL_RED_BITS 0x0D52 -#define GL_GREEN_BITS 0x0D53 -#define GL_BLUE_BITS 0x0D54 -#define GL_ALPHA_BITS 0x0D55 -#define GL_DEPTH_BITS 0x0D56 -#define GL_STENCIL_BITS 0x0D57 -#define GL_ACCUM_RED_BITS 0x0D58 -#define GL_ACCUM_GREEN_BITS 0x0D59 -#define GL_ACCUM_BLUE_BITS 0x0D5A -#define GL_ACCUM_ALPHA_BITS 0x0D5B -#define GL_NAME_STACK_DEPTH 0x0D70 -#define GL_AUTO_NORMAL 0x0D80 -#define GL_MAP1_COLOR_4 0x0D90 -#define GL_MAP1_INDEX 0x0D91 -#define GL_MAP1_NORMAL 0x0D92 -#define GL_MAP1_TEXTURE_COORD_1 0x0D93 -#define GL_MAP1_TEXTURE_COORD_2 0x0D94 -#define GL_MAP1_TEXTURE_COORD_3 0x0D95 -#define GL_MAP1_TEXTURE_COORD_4 0x0D96 -#define GL_MAP1_VERTEX_3 0x0D97 -#define GL_MAP1_VERTEX_4 0x0D98 -#define GL_MAP2_COLOR_4 0x0DB0 -#define GL_MAP2_INDEX 0x0DB1 -#define GL_MAP2_NORMAL 0x0DB2 -#define GL_MAP2_TEXTURE_COORD_1 0x0DB3 -#define GL_MAP2_TEXTURE_COORD_2 0x0DB4 -#define GL_MAP2_TEXTURE_COORD_3 0x0DB5 -#define GL_MAP2_TEXTURE_COORD_4 0x0DB6 -#define GL_MAP2_VERTEX_3 0x0DB7 -#define GL_MAP2_VERTEX_4 0x0DB8 -#define GL_MAP1_GRID_DOMAIN 0x0DD0 -#define GL_MAP1_GRID_SEGMENTS 0x0DD1 -#define GL_MAP2_GRID_DOMAIN 0x0DD2 -#define GL_MAP2_GRID_SEGMENTS 0x0DD3 -#define GL_TEXTURE_1D 0x0DE0 -#define GL_TEXTURE_2D 0x0DE1 -#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0 -#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1 -#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2 -#define GL_SELECTION_BUFFER_POINTER 0x0DF3 -#define GL_SELECTION_BUFFER_SIZE 0x0DF4 -/* GL_TEXTURE_BINDING_1D */ -/* GL_TEXTURE_BINDING_2D */ -/* GL_VERTEX_ARRAY */ -/* GL_NORMAL_ARRAY */ -/* GL_COLOR_ARRAY */ -/* GL_INDEX_ARRAY */ -/* GL_TEXTURE_COORD_ARRAY */ -/* GL_EDGE_FLAG_ARRAY */ -/* GL_VERTEX_ARRAY_SIZE */ -/* GL_VERTEX_ARRAY_TYPE */ -/* GL_VERTEX_ARRAY_STRIDE */ -/* GL_NORMAL_ARRAY_TYPE */ -/* GL_NORMAL_ARRAY_STRIDE */ -/* GL_COLOR_ARRAY_SIZE */ -/* GL_COLOR_ARRAY_TYPE */ -/* GL_COLOR_ARRAY_STRIDE */ -/* GL_INDEX_ARRAY_TYPE */ -/* GL_INDEX_ARRAY_STRIDE */ -/* GL_TEXTURE_COORD_ARRAY_SIZE */ -/* GL_TEXTURE_COORD_ARRAY_TYPE */ -/* GL_TEXTURE_COORD_ARRAY_STRIDE */ -/* GL_EDGE_FLAG_ARRAY_STRIDE */ -/* GL_POLYGON_OFFSET_FACTOR */ -/* GL_POLYGON_OFFSET_UNITS */ - -/* GetTextureParameter */ -/* GL_TEXTURE_MAG_FILTER */ -/* GL_TEXTURE_MIN_FILTER */ -/* GL_TEXTURE_WRAP_S */ -/* GL_TEXTURE_WRAP_T */ -#define GL_TEXTURE_WIDTH 0x1000 -#define GL_TEXTURE_HEIGHT 0x1001 -#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 -#define GL_TEXTURE_BORDER_COLOR 0x1004 -#define GL_TEXTURE_BORDER 0x1005 -/* GL_TEXTURE_RED_SIZE */ -/* GL_TEXTURE_GREEN_SIZE */ -/* GL_TEXTURE_BLUE_SIZE */ -/* GL_TEXTURE_ALPHA_SIZE */ -/* GL_TEXTURE_LUMINANCE_SIZE */ -/* GL_TEXTURE_INTENSITY_SIZE */ -/* GL_TEXTURE_PRIORITY */ -/* GL_TEXTURE_RESIDENT */ - -/* HintMode */ -#define GL_DONT_CARE 0x1100 -#define GL_FASTEST 0x1101 -#define GL_NICEST 0x1102 - -/* HintTarget */ -/* GL_PERSPECTIVE_CORRECTION_HINT */ -/* GL_POINT_SMOOTH_HINT */ -/* GL_LINE_SMOOTH_HINT */ -/* GL_POLYGON_SMOOTH_HINT */ -/* GL_FOG_HINT */ -/* GL_PHONG_HINT */ - -/* IndexPointerType */ -/* GL_SHORT */ -/* GL_INT */ -/* GL_FLOAT */ -/* GL_DOUBLE */ - -/* LightModelParameter */ -/* GL_LIGHT_MODEL_AMBIENT */ -/* GL_LIGHT_MODEL_LOCAL_VIEWER */ -/* GL_LIGHT_MODEL_TWO_SIDE */ - -/* LightName */ -#define GL_LIGHT0 0x4000 -#define GL_LIGHT1 0x4001 -#define GL_LIGHT2 0x4002 -#define GL_LIGHT3 0x4003 -#define GL_LIGHT4 0x4004 -#define GL_LIGHT5 0x4005 -#define GL_LIGHT6 0x4006 -#define GL_LIGHT7 0x4007 - -/* LightParameter */ -#define GL_AMBIENT 0x1200 -#define GL_DIFFUSE 0x1201 -#define GL_SPECULAR 0x1202 -#define GL_POSITION 0x1203 -#define GL_SPOT_DIRECTION 0x1204 -#define GL_SPOT_EXPONENT 0x1205 -#define GL_SPOT_CUTOFF 0x1206 -#define GL_CONSTANT_ATTENUATION 0x1207 -#define GL_LINEAR_ATTENUATION 0x1208 -#define GL_QUADRATIC_ATTENUATION 0x1209 - -/* InterleavedArrays */ -/* GL_V2F */ -/* GL_V3F */ -/* GL_C4UB_V2F */ -/* GL_C4UB_V3F */ -/* GL_C3F_V3F */ -/* GL_N3F_V3F */ -/* GL_C4F_N3F_V3F */ -/* GL_T2F_V3F */ -/* GL_T4F_V4F */ -/* GL_T2F_C4UB_V3F */ -/* GL_T2F_C3F_V3F */ -/* GL_T2F_N3F_V3F */ -/* GL_T2F_C4F_N3F_V3F */ -/* GL_T4F_C4F_N3F_V4F */ - -/* ListMode */ -#define GL_COMPILE 0x1300 -#define GL_COMPILE_AND_EXECUTE 0x1301 - -/* ListNameType */ -/* GL_BYTE */ -/* GL_UNSIGNED_BYTE */ -/* GL_SHORT */ -/* GL_UNSIGNED_SHORT */ -/* GL_INT */ -/* GL_UNSIGNED_INT */ -/* GL_FLOAT */ -/* GL_2_BYTES */ -/* GL_3_BYTES */ -/* GL_4_BYTES */ - -/* LogicOp */ -#define GL_CLEAR 0x1500 -#define GL_AND 0x1501 -#define GL_AND_REVERSE 0x1502 -#define GL_COPY 0x1503 -#define GL_AND_INVERTED 0x1504 -#define GL_NOOP 0x1505 -#define GL_XOR 0x1506 -#define GL_OR 0x1507 -#define GL_NOR 0x1508 -#define GL_EQUIV 0x1509 -#define GL_INVERT 0x150A -#define GL_OR_REVERSE 0x150B -#define GL_COPY_INVERTED 0x150C -#define GL_OR_INVERTED 0x150D -#define GL_NAND 0x150E -#define GL_SET 0x150F - -/* MapTarget */ -/* GL_MAP1_COLOR_4 */ -/* GL_MAP1_INDEX */ -/* GL_MAP1_NORMAL */ -/* GL_MAP1_TEXTURE_COORD_1 */ -/* GL_MAP1_TEXTURE_COORD_2 */ -/* GL_MAP1_TEXTURE_COORD_3 */ -/* GL_MAP1_TEXTURE_COORD_4 */ -/* GL_MAP1_VERTEX_3 */ -/* GL_MAP1_VERTEX_4 */ -/* GL_MAP2_COLOR_4 */ -/* GL_MAP2_INDEX */ -/* GL_MAP2_NORMAL */ -/* GL_MAP2_TEXTURE_COORD_1 */ -/* GL_MAP2_TEXTURE_COORD_2 */ -/* GL_MAP2_TEXTURE_COORD_3 */ -/* GL_MAP2_TEXTURE_COORD_4 */ -/* GL_MAP2_VERTEX_3 */ -/* GL_MAP2_VERTEX_4 */ - -/* MaterialFace */ -/* GL_FRONT */ -/* GL_BACK */ -/* GL_FRONT_AND_BACK */ - -/* MaterialParameter */ -#define GL_EMISSION 0x1600 -#define GL_SHININESS 0x1601 -#define GL_AMBIENT_AND_DIFFUSE 0x1602 -#define GL_COLOR_INDEXES 0x1603 -/* GL_AMBIENT */ -/* GL_DIFFUSE */ -/* GL_SPECULAR */ - -/* MatrixMode */ -#define GL_MODELVIEW 0x1700 -#define GL_PROJECTION 0x1701 -#define GL_TEXTURE 0x1702 - -/* MeshMode1 */ -/* GL_POINT */ -/* GL_LINE */ - -/* MeshMode2 */ -/* GL_POINT */ -/* GL_LINE */ -/* GL_FILL */ - -/* NormalPointerType */ -/* GL_BYTE */ -/* GL_SHORT */ -/* GL_INT */ -/* GL_FLOAT */ -/* GL_DOUBLE */ - -/* PixelCopyType */ -#define GL_COLOR 0x1800 -#define GL_DEPTH 0x1801 -#define GL_STENCIL 0x1802 - -/* PixelFormat */ -#define GL_COLOR_INDEX 0x1900 -#define GL_STENCIL_INDEX 0x1901 -#define GL_DEPTH_COMPONENT 0x1902 -#define GL_RED 0x1903 -#define GL_GREEN 0x1904 -#define GL_BLUE 0x1905 -#define GL_ALPHA 0x1906 -#define GL_RGB 0x1907 -#define GL_RGBA 0x1908 -#define GL_LUMINANCE 0x1909 -#define GL_LUMINANCE_ALPHA 0x190A - -/* PixelMap */ -/* GL_PIXEL_MAP_I_TO_I */ -/* GL_PIXEL_MAP_S_TO_S */ -/* GL_PIXEL_MAP_I_TO_R */ -/* GL_PIXEL_MAP_I_TO_G */ -/* GL_PIXEL_MAP_I_TO_B */ -/* GL_PIXEL_MAP_I_TO_A */ -/* GL_PIXEL_MAP_R_TO_R */ -/* GL_PIXEL_MAP_G_TO_G */ -/* GL_PIXEL_MAP_B_TO_B */ -/* GL_PIXEL_MAP_A_TO_A */ - -/* PixelStore */ -/* GL_UNPACK_SWAP_BYTES */ -/* GL_UNPACK_LSB_FIRST */ -/* GL_UNPACK_ROW_LENGTH */ -/* GL_UNPACK_SKIP_ROWS */ -/* GL_UNPACK_SKIP_PIXELS */ -/* GL_UNPACK_ALIGNMENT */ -/* GL_PACK_SWAP_BYTES */ -/* GL_PACK_LSB_FIRST */ -/* GL_PACK_ROW_LENGTH */ -/* GL_PACK_SKIP_ROWS */ -/* GL_PACK_SKIP_PIXELS */ -/* GL_PACK_ALIGNMENT */ - -/* PixelTransfer */ -/* GL_MAP_COLOR */ -/* GL_MAP_STENCIL */ -/* GL_INDEX_SHIFT */ -/* GL_INDEX_OFFSET */ -/* GL_RED_SCALE */ -/* GL_RED_BIAS */ -/* GL_GREEN_SCALE */ -/* GL_GREEN_BIAS */ -/* GL_BLUE_SCALE */ -/* GL_BLUE_BIAS */ -/* GL_ALPHA_SCALE */ -/* GL_ALPHA_BIAS */ -/* GL_DEPTH_SCALE */ -/* GL_DEPTH_BIAS */ - -/* PixelType */ -#define GL_BITMAP 0x1A00 -/* GL_BYTE */ -/* GL_UNSIGNED_BYTE */ -/* GL_SHORT */ -/* GL_UNSIGNED_SHORT */ -/* GL_INT */ -/* GL_UNSIGNED_INT */ -/* GL_FLOAT */ - -/* PolygonMode */ -#define GL_POINT 0x1B00 -#define GL_LINE 0x1B01 -#define GL_FILL 0x1B02 - -/* ReadBufferMode */ -/* GL_FRONT_LEFT */ -/* GL_FRONT_RIGHT */ -/* GL_BACK_LEFT */ -/* GL_BACK_RIGHT */ -/* GL_FRONT */ -/* GL_BACK */ -/* GL_LEFT */ -/* GL_RIGHT */ -/* GL_AUX0 */ -/* GL_AUX1 */ -/* GL_AUX2 */ -/* GL_AUX3 */ - -/* RenderingMode */ -#define GL_RENDER 0x1C00 -#define GL_FEEDBACK 0x1C01 -#define GL_SELECT 0x1C02 - -/* ShadingModel */ -#define GL_FLAT 0x1D00 -#define GL_SMOOTH 0x1D01 - - -/* StencilFunction */ -/* GL_NEVER */ -/* GL_LESS */ -/* GL_EQUAL */ -/* GL_LEQUAL */ -/* GL_GREATER */ -/* GL_NOTEQUAL */ -/* GL_GEQUAL */ -/* GL_ALWAYS */ - -/* StencilOp */ -/* GL_ZERO */ -#define GL_KEEP 0x1E00 -#define GL_REPLACE 0x1E01 -#define GL_INCR 0x1E02 -#define GL_DECR 0x1E03 -/* GL_INVERT */ - -/* StringName */ -#define GL_VENDOR 0x1F00 -#define GL_RENDERER 0x1F01 -#define GL_VERSION 0x1F02 -#define GL_EXTENSIONS 0x1F03 - -/* TextureCoordName */ -#define GL_S 0x2000 -#define GL_T 0x2001 -#define GL_R 0x2002 -#define GL_Q 0x2003 - -/* TexCoordPointerType */ -/* GL_SHORT */ -/* GL_INT */ -/* GL_FLOAT */ -/* GL_DOUBLE */ - -/* TextureEnvMode */ -#define GL_MODULATE 0x2100 -#define GL_DECAL 0x2101 -/* GL_BLEND */ -/* GL_REPLACE */ - -/* TextureEnvParameter */ -#define GL_TEXTURE_ENV_MODE 0x2200 -#define GL_TEXTURE_ENV_COLOR 0x2201 - -/* TextureEnvTarget */ -#define GL_TEXTURE_ENV 0x2300 - -/* TextureGenMode */ -#define GL_EYE_LINEAR 0x2400 -#define GL_OBJECT_LINEAR 0x2401 -#define GL_SPHERE_MAP 0x2402 - -/* TextureGenParameter */ -#define GL_TEXTURE_GEN_MODE 0x2500 -#define GL_OBJECT_PLANE 0x2501 -#define GL_EYE_PLANE 0x2502 - -/* TextureMagFilter */ -#define GL_NEAREST 0x2600 -#define GL_LINEAR 0x2601 - -/* TextureMinFilter */ -/* GL_NEAREST */ -/* GL_LINEAR */ -#define GL_NEAREST_MIPMAP_NEAREST 0x2700 -#define GL_LINEAR_MIPMAP_NEAREST 0x2701 -#define GL_NEAREST_MIPMAP_LINEAR 0x2702 -#define GL_LINEAR_MIPMAP_LINEAR 0x2703 - -/* TextureParameterName */ -#define GL_TEXTURE_MAG_FILTER 0x2800 -#define GL_TEXTURE_MIN_FILTER 0x2801 -#define GL_TEXTURE_WRAP_S 0x2802 -#define GL_TEXTURE_WRAP_T 0x2803 -/* GL_TEXTURE_BORDER_COLOR */ -/* GL_TEXTURE_PRIORITY */ - -/* TextureTarget */ -/* GL_TEXTURE_1D */ -/* GL_TEXTURE_2D */ -/* GL_PROXY_TEXTURE_1D */ -/* GL_PROXY_TEXTURE_2D */ - -/* TextureWrapMode */ -#define GL_CLAMP 0x2900 -#define GL_REPEAT 0x2901 - -/* VertexPointerType */ -/* GL_SHORT */ -/* GL_INT */ -/* GL_FLOAT */ -/* GL_DOUBLE */ - -/* ClientAttribMask */ -#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001 -#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 -#define GL_CLIENT_ALL_ATTRIB_BITS 0xffffffff - -/* polygon_offset */ -#define GL_POLYGON_OFFSET_FACTOR 0x8038 -#define GL_POLYGON_OFFSET_UNITS 0x2A00 -#define GL_POLYGON_OFFSET_POINT 0x2A01 -#define GL_POLYGON_OFFSET_LINE 0x2A02 -#define GL_POLYGON_OFFSET_FILL 0x8037 - -/* texture */ -#define GL_ALPHA4 0x803B -#define GL_ALPHA8 0x803C -#define GL_ALPHA12 0x803D -#define GL_ALPHA16 0x803E -#define GL_LUMINANCE4 0x803F -#define GL_LUMINANCE8 0x8040 -#define GL_LUMINANCE12 0x8041 -#define GL_LUMINANCE16 0x8042 -#define GL_LUMINANCE4_ALPHA4 0x8043 -#define GL_LUMINANCE6_ALPHA2 0x8044 -#define GL_LUMINANCE8_ALPHA8 0x8045 -#define GL_LUMINANCE12_ALPHA4 0x8046 -#define GL_LUMINANCE12_ALPHA12 0x8047 -#define GL_LUMINANCE16_ALPHA16 0x8048 -#define GL_INTENSITY 0x8049 -#define GL_INTENSITY4 0x804A -#define GL_INTENSITY8 0x804B -#define GL_INTENSITY12 0x804C -#define GL_INTENSITY16 0x804D -#define GL_R3_G3_B2 0x2A10 -#define GL_RGB4 0x804F -#define GL_RGB5 0x8050 -#define GL_RGB8 0x8051 -#define GL_RGB10 0x8052 -#define GL_RGB12 0x8053 -#define GL_RGB16 0x8054 -#define GL_RGBA2 0x8055 -#define GL_RGBA4 0x8056 -#define GL_RGB5_A1 0x8057 -#define GL_RGBA8 0x8058 -#define GL_RGB10_A2 0x8059 -#define GL_RGBA12 0x805A -#define GL_RGBA16 0x805B -#define GL_TEXTURE_RED_SIZE 0x805C -#define GL_TEXTURE_GREEN_SIZE 0x805D -#define GL_TEXTURE_BLUE_SIZE 0x805E -#define GL_TEXTURE_ALPHA_SIZE 0x805F -#define GL_TEXTURE_LUMINANCE_SIZE 0x8060 -#define GL_TEXTURE_INTENSITY_SIZE 0x8061 -#define GL_PROXY_TEXTURE_1D 0x8063 -#define GL_PROXY_TEXTURE_2D 0x8064 - -/* texture_object */ -#define GL_TEXTURE_PRIORITY 0x8066 -#define GL_TEXTURE_RESIDENT 0x8067 -#define GL_TEXTURE_BINDING_1D 0x8068 -#define GL_TEXTURE_BINDING_2D 0x8069 - -/* vertex_array */ -#define GL_VERTEX_ARRAY 0x8074 -#define GL_NORMAL_ARRAY 0x8075 -#define GL_COLOR_ARRAY 0x8076 -#define GL_INDEX_ARRAY 0x8077 -#define GL_TEXTURE_COORD_ARRAY 0x8078 -#define GL_EDGE_FLAG_ARRAY 0x8079 -#define GL_VERTEX_ARRAY_SIZE 0x807A -#define GL_VERTEX_ARRAY_TYPE 0x807B -#define GL_VERTEX_ARRAY_STRIDE 0x807C -#define GL_NORMAL_ARRAY_TYPE 0x807E -#define GL_NORMAL_ARRAY_STRIDE 0x807F -#define GL_COLOR_ARRAY_SIZE 0x8081 -#define GL_COLOR_ARRAY_TYPE 0x8082 -#define GL_COLOR_ARRAY_STRIDE 0x8083 -#define GL_INDEX_ARRAY_TYPE 0x8085 -#define GL_INDEX_ARRAY_STRIDE 0x8086 -#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A -#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C -#define GL_VERTEX_ARRAY_POINTER 0x808E -#define GL_NORMAL_ARRAY_POINTER 0x808F -#define GL_COLOR_ARRAY_POINTER 0x8090 -#define GL_INDEX_ARRAY_POINTER 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093 -#define GL_V2F 0x2A20 -#define GL_V3F 0x2A21 -#define GL_C4UB_V2F 0x2A22 -#define GL_C4UB_V3F 0x2A23 -#define GL_C3F_V3F 0x2A24 -#define GL_N3F_V3F 0x2A25 -#define GL_C4F_N3F_V3F 0x2A26 -#define GL_T2F_V3F 0x2A27 -#define GL_T4F_V4F 0x2A28 -#define GL_T2F_C4UB_V3F 0x2A29 -#define GL_T2F_C3F_V3F 0x2A2A -#define GL_T2F_N3F_V3F 0x2A2B -#define GL_T2F_C4F_N3F_V3F 0x2A2C -#define GL_T4F_C4F_N3F_V4F 0x2A2D - -/* Extensions */ -#define GL_EXT_vertex_array 1 -#define GL_EXT_bgra 1 -#define GL_EXT_paletted_texture 1 -#define GL_WIN_swap_hint 1 -#define GL_WIN_draw_range_elements 1 -// #define GL_WIN_phong_shading 1 -// #define GL_WIN_specular_fog 1 - -/* EXT_vertex_array */ -#define GL_VERTEX_ARRAY_EXT 0x8074 -#define GL_NORMAL_ARRAY_EXT 0x8075 -#define GL_COLOR_ARRAY_EXT 0x8076 -#define GL_INDEX_ARRAY_EXT 0x8077 -#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 -#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 -#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A -#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B -#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C -#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D -#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E -#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F -#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 -#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 -#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 -#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 -#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 -#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 -#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 -#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 -#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A -#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B -#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C -#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D -#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E -#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F -#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 -#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 -#define GL_DOUBLE_EXT GL_DOUBLE - -/* EXT_bgra */ -#define GL_BGR_EXT 0x80E0 -#define GL_BGRA_EXT 0x80E1 - -/* EXT_paletted_texture */ - -/* These must match the GL_COLOR_TABLE_*_SGI enumerants */ -#define GL_COLOR_TABLE_FORMAT_EXT 0x80D8 -#define GL_COLOR_TABLE_WIDTH_EXT 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE_EXT 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE_EXT 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE_EXT 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE_EXT 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE_EXT 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80DF - -#define GL_COLOR_INDEX1_EXT 0x80E2 -#define GL_COLOR_INDEX2_EXT 0x80E3 -#define GL_COLOR_INDEX4_EXT 0x80E4 -#define GL_COLOR_INDEX8_EXT 0x80E5 -#define GL_COLOR_INDEX12_EXT 0x80E6 -#define GL_COLOR_INDEX16_EXT 0x80E7 - -/* WIN_draw_range_elements */ -#define GL_MAX_ELEMENTS_VERTICES_WIN 0x80E8 -#define GL_MAX_ELEMENTS_INDICES_WIN 0x80E9 - -/* WIN_phong_shading */ -#define GL_PHONG_WIN 0x80EA -#define GL_PHONG_HINT_WIN 0x80EB - -/* WIN_specular_fog */ -#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC - -/* For compatibility with OpenGL v1.0 */ -#define GL_LOGIC_OP GL_INDEX_LOGIC_OP -#define GL_TEXTURE_COMPONENTS GL_TEXTURE_INTERNAL_FORMAT -#include +#include <@GL_H@> +#include <@QT_QTOPENGL_INCLUDE_DIR@/QtOpenGL> #endif // QT_NO_OPENGL diff --git a/PySide/licensecomment.txt b/PySide/licensecomment.txt index fdf9745..dfeef80 100644 --- a/PySide/licensecomment.txt +++ b/PySide/licensecomment.txt @@ -1,7 +1,7 @@ /* * This file is part of PySide: Python for Qt * - * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + * Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies). * * Contact: PySide team * diff --git a/PySide/phonon/CMakeLists.txt b/PySide/phonon/CMakeLists.txt index 01b1f6a..0564029 100644 --- a/PySide/phonon/CMakeLists.txt +++ b/PySide/phonon/CMakeLists.txt @@ -1,5 +1,14 @@ project(phonon) +# workaround for a cmake bug under MacOSX, it finds phonon but not the include path +if (NOT QT_PHONON_INCLUDE_DIR AND CMAKE_HOST_APPLE) + set(QT_PHONON_INCLUDE_DIR "${QT_LIBRARY_DIR}/phonon.framework/Headers") +endif () + +set(phonon_OPTIONAL_SRC ) +set(phonon_DROPPED_ENTRIES ) +check_qt_class(phonon VideoCaptureDevice phonon_OPTIONAL_SRC phonon_DROPPED_ENTRIES Phonon ObjectDescription) + set(phonon_SRC ${CMAKE_CURRENT_BINARY_DIR}/PySide/phonon/phonon_abstractaudiooutput_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/phonon/phonon_abstractmediastream_wrapper.cpp @@ -37,32 +46,33 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/phonon/phonon_volumefaderinterface_wrapper.cp ${CMAKE_CURRENT_BINARY_DIR}/PySide/phonon/phonon_volumeslider_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/phonon/phonon_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/phonon/phonon_backendcapabilities_notifierwrapper_wrapper.cpp +${phonon_OPTIONAL_SRC} ) -execute_generator(phonon phonon_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtGui_SOURCE_DIR}:${phonon_SOURCE_DIR}") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ${QT_PHONON_INCLUDE_DIR} - ${PYTHON_INCLUDE_PATH} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${QtGui_BINARY_DIR}/PySide/QtGui/ - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ${CMAKE_CURRENT_BINARY_DIR}/PySide/phonon) -add_library(phonon MODULE ${phonon_SRC}) -set_target_properties(phonon PROPERTIES PREFIX "") -target_link_libraries(phonon - pyside - ${PYTHON_LIBRARIES} +set(phonon_typesystem_path "${QtCore_SOURCE_DIR}${PATH_SEP}${QtCore_BINARY_DIR}${PATH_SEP}${QtGui_SOURCE_DIR}${PATH_SEP}${phonon_SOURCE_DIR}${PATH_SEP}${QtGui_BINARY_DIR}") +set(phonon_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTGUI_INCLUDE_DIR} + ${QT_PHONON_INCLUDE_DIR} + ${SHIBOKEN_PYTHON_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${QtGui_BINARY_DIR}/PySide/QtGui/ + ${QtCore_BINARY_DIR}/PySide/QtCore/ + ${CMAKE_CURRENT_BINARY_DIR}/PySide/phonon) +set(phonon_libraries pyside + ${SHIBOKEN_PYTHON_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_PHONON_LIBRARY}) -add_dependencies(phonon QtGui) +set(phonon_deps QtGui) -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/phonon${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/phonon/pyside_phonon_python.h - DESTINATION include/PySide/phonon/) +create_pyside_module(phonon + phonon_include_dirs + phonon_libraries + phonon_deps + phonon_typesystem_path + phonon_SRC + "" + "" + phonon_DROPPED_ENTRIES) diff --git a/PySide/phonon/typesystem_phonon.xml b/PySide/phonon/typesystem_phonon.xml index 1a2a486..509e053 100644 --- a/PySide/phonon/typesystem_phonon.xml +++ b/PySide/phonon/typesystem_phonon.xml @@ -1,4 +1,23 @@ + @@ -18,164 +37,279 @@ + + + + Phonon::BackendCapabilities::NotifierWrapper* Phonon::BackendCapabilities::NotifierWrapper::m_instance = 0; + Phonon::BackendCapabilities::Notifier* Phonon::BackendCapabilities::NotifierWrapper::m_notifier = 0; + + + + + Phonon::BackendCapabilities::NotifierWrapper *_notifierWrapper = Phonon::BackendCapabilities::NotifierWrapper::notifier(); + %PYARG_0 = %CONVERTTOPYTHON[Phonon::BackendCapabilities::NotifierWrapper*](_notifierWrapper); + + + + + + + +.. class: Notifier + + Notifications about backend capabilities + +.. method:: capabilitiesChanged() + + This signal is emitted if the capabilities have changed. This can happen if the user has requested a backend change. + +.. method:: availableAudioOutputDevicesChanged() + + This signal is emitted when audio capture devices were plugged or unplugged. + + Check :meth:`PySide.phonon.BackendCapabilities.availableAudioOutputDevices` to get the current list of available devices. + +.. method:: availableAudioCaptureDevicesChanged() + + This signal is emitted when audio capture devices were plugged or unplugged. + + Check :meth:`PySide.phonon.BackendCapabilities.availableAudioCaptureDevices` to get the current list of available devices. + + + + + + + + + + + + PySideSignal* signal_item; + + signal_item = PySide::Signal::newObject("capabilitiesChanged", "void", NULL); + PyDict_SetItemString(Sbk_Phonon_BackendCapabilities_NotifierWrapper_Type.super.ht_type.tp_dict, "capabilitiesChanged", (PyObject*)signal_item); + Py_DECREF((PyObject*)signal_item); + + signal_item = PySide::Signal::newObject("availableAudioOutputDevicesChanged", "void", NULL); + PyDict_SetItemString( Sbk_Phonon_BackendCapabilities_NotifierWrapper_Type.super.ht_type.tp_dict, "availableAudioOutputDevicesChanged", (PyObject*)signal_item); + Py_DECREF((PyObject*)signal_item); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - Phonon::BackendCapabilities::NotifierWrapper* Phonon::BackendCapabilities::NotifierWrapper::m_instance = 0; - Phonon::BackendCapabilities::Notifier* Phonon::BackendCapabilities::NotifierWrapper::m_notifier = 0; - - - - - Phonon::BackendCapabilities::NotifierWrapper *_notifierWrapper = Phonon::BackendCapabilities::NotifierWrapper::notifier(); - %PYARG_0 = %CONVERTTOPYTHON[Phonon::BackendCapabilities::NotifierWrapper*](_notifierWrapper); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PySide/pysideqtesttouch.h b/PySide/pysideqtesttouch.h new file mode 100644 index 0000000..fa7d2e4 --- /dev/null +++ b/PySide/pysideqtesttouch.h @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtTest module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef PYSIDEQTESTTOUCH_H +#define PYSIDEQTESTTOUCH_H + +#include +#include +#include +#include +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace QTest +{ + + class PySideQTouchEventSequence + { + public: + ~PySideQTouchEventSequence() + { + commit(); + } + + PySideQTouchEventSequence* press(int touchId, const QPoint &pt, QWidget *widget = 0) + { + QTouchEvent::TouchPoint &p = point(touchId); + p.setScreenPos(mapToScreen(widget, pt)); + p.setState(Qt::TouchPointPressed); + return this; + } + + PySideQTouchEventSequence* move(int touchId, const QPoint &pt, QWidget *widget = 0) + { + QTouchEvent::TouchPoint &p = point(touchId); + p.setScreenPos(mapToScreen(widget, pt)); + p.setState(Qt::TouchPointMoved); + return this; + } + + PySideQTouchEventSequence* release(int touchId, const QPoint &pt, QWidget *widget = 0) + { + QTouchEvent::TouchPoint &p = point(touchId); + p.setScreenPos(mapToScreen(widget, pt)); + p.setState(Qt::TouchPointReleased); + return this; + } + + PySideQTouchEventSequence* stationary(int touchId) + { + QTouchEvent::TouchPoint &p = point(touchId); + p.setState(Qt::TouchPointStationary); + return this; + } + + void commit() + { + qt_translateRawTouchEvent(targetWidget, deviceType, points.values()); + targetWidget = 0; + points.clear(); + } + + private: + PySideQTouchEventSequence(QWidget *widget, QTouchEvent::DeviceType aDeviceType) + : targetWidget(widget), deviceType(aDeviceType) + { + } + + PySideQTouchEventSequence(const PySideQTouchEventSequence &v); + + void operator=(const PySideQTouchEventSequence&); + + QTouchEvent::TouchPoint &point(int touchId) + { + if (!points.contains(touchId)) + points[touchId] = QTouchEvent::TouchPoint(touchId); + return points[touchId]; + } + + QPoint mapToScreen(QWidget *widget, const QPoint &pt) + { + if (widget) + return widget->mapToGlobal(pt); + return targetWidget ? targetWidget->mapToGlobal(pt) : pt; + } + + QMap points; + QWidget *targetWidget; + QTouchEvent::DeviceType deviceType; + friend PySideQTouchEventSequence* generateTouchEvent(QWidget *, QTouchEvent::DeviceType); + }; + + inline + PySideQTouchEventSequence* generateTouchEvent(QWidget *widget = 0, + QTouchEvent::DeviceType deviceType = QTouchEvent::TouchScreen) + { + return new PySideQTouchEventSequence(widget, deviceType); + } + +} + +QT_END_NAMESPACE + +#endif // PYSIDEQTESTTOUCH_H diff --git a/PySide/pysidewtypes.h b/PySide/pysidewtypes.h new file mode 100644 index 0000000..4d9d4f0 --- /dev/null +++ b/PySide/pysidewtypes.h @@ -0,0 +1,27 @@ +#ifndef __PYSIDEWTYPES__ +#define __PYSIDEWTYPES__ + +typedef struct HWND__ *HWND; +typedef unsigned UINT; +typedef long LONG; +typedef unsigned long DWORD; +typedef UINT WPARAM; +typedef LONG LPARAM; + +struct POINT +{ + LONG x; + LONG y; +}; + +struct MSG +{ + HWND hwnd; + UINT message; + WPARAM wParam; + LPARAM lParam; + DWORD time; + POINT pt; +}; + +#endif diff --git a/PySide/qpytextobject.cpp b/PySide/qpytextobject.cpp new file mode 100644 index 0000000..90462f5 --- /dev/null +++ b/PySide/qpytextobject.cpp @@ -0,0 +1,33 @@ +/* + * This file is part of the PySide project. + * + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * + * Contact: PySide team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "qpytextobject.h" + +/*! + \class QPyTextObject + \brief Workaround to make possible use QTextObjectInterface on PySide. + \ingroup richtext-processing + Due to the technical details of how to bind C++ classes to Python, you need to use this class when you need to implement + your own QTextObjectInterface rather than create a class inheriting from QObject and QTextObjectInterface. + + \sa QTextObjectInterface +*/ diff --git a/PySide/qpytextobject.h b/PySide/qpytextobject.h new file mode 100644 index 0000000..6616270 --- /dev/null +++ b/PySide/qpytextobject.h @@ -0,0 +1,40 @@ +/* + * This file is part of the PySide project. + * + * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * + * Contact: PySide team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef QPYTEXTOBJECT +#define QPYTEXTOBJECT + +#include +#include + +class QPyTextObject : public QObject, public QTextObjectInterface +{ + Q_OBJECT + Q_INTERFACES(QTextObjectInterface) +public: + QPyTextObject(QObject* parent = 0) : QObject(parent) {} + void drawObject(QPainter* painter, const QRectF& rect, QTextDocument* doc, int posInDocument, const QTextFormat& format ) = 0; + QSizeF intrinsicSize(QTextDocument* doc, int posInDocument, const QTextFormat& format ) = 0; +}; +#endif + + diff --git a/PySide/typesystem_templates.xml b/PySide/typesystem_templates.xml index 3badcf2..2903ae4 100644 --- a/PySide/typesystem_templates.xml +++ b/PySide/typesystem_templates.xml @@ -1,50 +1,109 @@ + + + + +