diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..3ddee02 --- /dev/null +++ b/.clang-format @@ -0,0 +1,66 @@ +--- +BasedOnStyle: WebKit +Language: Cpp +Standard: Cpp11 + +IndentWidth: 4 +SpacesBeforeTrailingComments: 1 +UseTab: Never +TabWidth: 4 +ContinuationIndentWidth: 4 +MaxEmptyLinesToKeep: 3 +BreakBeforeBinaryOperators: NonAssignment +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakConstructorInitializersBeforeComma: true + +BreakBeforeBraces: Custom +BraceWrapping: + AfterClass: true + AfterControlStatement: false + AfterEnum: false + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: true + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + +AccessModifierOffset: -4 +ExperimentalAutoDetectBinPacking: false +IndentFunctionDeclarationAfterType: false +ConstructorInitializerIndentWidth: 4 +AlignEscapedNewlinesLeft: false +AlignTrailingComments: false +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AllowShortFunctionsOnASingleLine: false +AllowShortEnumsOnASingleLine: false # requires clang-format 11 +AlignAfterOpenBracket: true +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: true +BinPackParameters: true +ColumnLimit: 100 +Cpp11BracedListStyle: false +DerivePointerBinding: false +IndentCaseLabels: false +NamespaceIndentation: None +ObjCSpaceBeforeProtocolList: true +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 60 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerBindsToType: false +SpaceAfterTemplateKeyword: false +SpaceAfterControlStatementKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceInEmptyParentheses: false +SpacesInAngles: false +SpacesInCStyleCastParentheses: true +SpacesInParentheses: false +... diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..d7bf63b --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,49 @@ +# +# This file is part of Dartagnan. +# +# SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +# Author: Sérgio Martins +# +# SPDX-License-Identifier: MIT + +# Instructions: +# docker build -t dartagnan . +# docker run -it -v /data/sources/dart/dartagnan/:/dartagnan/ -u 1000:1000 dartagnan +# cd /dartagnan/ && cmake --preset=dev -DCMAKE_INSTALL_PREFIX=/dartagnan/build-dev/installed/ +# cd build-dev && ninja && ninja install +# cd .. && dart pub get && dart run_tests.dart + +# To publish in docker hub: +# docker build -t dartagnan . +# docker run -it dartagnan # and exit +# docker ps # to check sha +# docker export -o mycontainer.tar +# docker import mycontainer.tar +# docker images # to check sha +# docker tag iamsergio/ci-dartagnan +# docker push iamsergio/ci-dartagnan + +FROM ubuntu:23.04 +MAINTAINER Sergio Martins (sergio.martins@kdab.com) + +ENV TZ=Europe/Berlin +ENV LC_CTYPE=C.UTF-8 +ENV PATH=$PATH:/home/ubuntu/flutter/bin/:/home/ubuntu/flutter/bin/cache/dart-sdk/bin/:/dartagnan/build-dev/installed/bin/ +ENV LD_LIBRARY_PATH=/dartagnan/build-dev/tests/generated/TestBindings/ +ENV DARTAGNAN_CLANG_FORMAT=clang-format-15 + +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +RUN apt update -qq && apt install -y vim build-essential software-properties-common lld git cmake ninja-build python3 \ + python3-dev clang llvm libclang-15-dev libxslt-dev mesa-common-dev libglu1-mesa-dev libglib2.0-dev libfontconfig \ + libxkbcommon-dev mesa-utils libgl1-mesa-dev libglu1-mesa-dev nlohmann-json3-dev clang-format-15 qt6-base-dev wget curl \ + file unzip zip which xz-utils + +RUN ln -sf /usr/lib/x86_64-linux-gnu/libasan.so.8 /usr/lib/libasan.so +RUN ln -sf /usr/bin/qmake6 /usr/bin/qmake + +WORKDIR /home/ubuntu +USER ubuntu +RUN git config --global advice.detachedHead false +RUN git clone https://github.com/flutter/flutter.git -b 3.19.5 +RUN flutter --version diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..7ac3e8f --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,37 @@ +{ + "name": "dartagnan", + "build": { + "dockerfile": "Dockerfile" + }, + "runArgs": [ + "--cap-add=SYS_PTRACE", + "--security-opt", + "seccomp=unconfined" + ], + "workspaceMount": "source=${localWorkspaceFolder}/,target=/dartagnan/,type=bind", + "workspaceFolder": "/dartagnan", + "customizations": { + "vscode": { + "extensions": [ + "vadimcn.vscode-lldb", + "llvm-vs-code-extensions.vscode-clangd", + "Dart-Code.dart-code", + "Dart-Code.flutter", + "mhutchie.git-graph", + "Gruntfuggly.todo-tree", + "ms-vscode.cmake-tools" + ], + "settings": { + "terminal.integrated.shell.linux": "/bin/bash", + "workbench.colorTheme": "Visual Studio Light" + } + } + }, + "mounts": [ + "source=${localEnv:HOME}/Qt/6.3.1/gcc_64/,target=/Qt/,type=bind", + "source=/data/installation/flutter/flutter-3.13/,target=/flutter/,type=bind", + "source=/data/sources/kddockwidgets/,target=/kddockwidgets/,type=bind", + "source=${localEnv:HOME}/.pub-cache/,target=/home/user/.pub-cache/,type=bind" + ], + "remoteUser": "ubuntu" +} \ No newline at end of file diff --git a/.github/actions/dartagnan/Dockerfile b/.github/actions/dartagnan/Dockerfile new file mode 100644 index 0000000..b52d18b --- /dev/null +++ b/.github/actions/dartagnan/Dockerfile @@ -0,0 +1,16 @@ +# +# This file is part of Dartagnan. +# +# SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company +# Author: Sérgio Martins +# +# SPDX-License-Identifier: MIT + +# Dockerfile for dartagnan GitHub Action +# Based over .devcontainer/Dockerfile + +FROM iamsergio/ci-dartagnan +MAINTAINER Sergio Martins (sergio.martins@kdab.com) + +COPY entrypoint.sh /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] diff --git a/.github/actions/dartagnan/action.yml b/.github/actions/dartagnan/action.yml new file mode 100644 index 0000000..d0190d4 --- /dev/null +++ b/.github/actions/dartagnan/action.yml @@ -0,0 +1,9 @@ +# SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company +# +# SPDX-License-Identifier: MIT + +name: 'build-dartagnan' +description: 'Builds Dartagnan' +runs: + using: 'docker' + image: 'Dockerfile' diff --git a/.github/actions/dartagnan/entrypoint.sh b/.github/actions/dartagnan/entrypoint.sh new file mode 100755 index 0000000..530bf3c --- /dev/null +++ b/.github/actions/dartagnan/entrypoint.sh @@ -0,0 +1,16 @@ +#!/bin/sh -l + +# SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company +# +# SPDX-License-Identifier: MIT +cd /github/workspace/ || exit 1 + +export TZ=Europe/Berlin +export LC_CTYPE=C.UTF-8 +export PATH=$PATH:/home/ubuntu/flutter/bin/:/home/ubuntu/flutter/bin/cache/dart-sdk/bin/:/dartagnan/build-dev/installed/bin/ +export LD_LIBRARY_PATH=/dartagnan/build-dev/tests/generated/TestBindings/ +export DARTAGNAN_CLANG_FORMAT=clang-format-15 + +cmake --preset=dev -DCMAKE_INSTALL_PREFIX=/dartagnan/build-dev/installed/ && \ +cd build-dev && ninja && ninja install && ctest -j1 --output-on-failure + diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..f6ee814 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,25 @@ +# SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company +# +# SPDX-License-Identifier: MIT + +name: Build + +on: + schedule: + - cron: '0 3 * * *' + workflow_dispatch: + pull_request: + push: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + with: + submodules: true + + - name: Build and Test + uses: ./.github/actions/dartagnan diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8b01219 --- /dev/null +++ b/.gitignore @@ -0,0 +1,25 @@ +*.log +.ninja_deps +.ninja_log +build.ninja +.vscode/launch.json +*depends +qrc_dartagnan.cpp +libdartagnan.a +CMakeFiles/ +cmake_install.cmake +CMakeCache.txt +build/ +.packages +libTestTarget.so +libMyBindings.so +.dart_tool +/build-dev +/build-release +CMakeLists.txt.user +/a +*.exe +compile_commands.json +.cache +main.aot +CTestCostData.txt diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e779f6b --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "3rdparty/shiboken"] + path = 3rdparty/shiboken + url = https://github.com/KDABLabs/pyside2-setup.git diff --git a/3rdparty/shiboken b/3rdparty/shiboken new file mode 160000 index 0000000..b6de222 --- /dev/null +++ b/3rdparty/shiboken @@ -0,0 +1 @@ +Subproject commit b6de222697268dbe4b458f7c6458423fc252a831 diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..ec35348 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,80 @@ +# This file is part of Dartagnan. +# +# SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +# SPDX-License-Identifier: MIT + +cmake_minimum_required(VERSION 3.9) +project(dartagnan) + + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + +add_subdirectory(3rdparty/shiboken) + +find_package(Qt6Core 6.1 REQUIRED) + +set(dartagnan_SRCS + src/dartagnan.cpp + src/dart_ffi_typedefs.cpp + + src/Logging.cpp + + # Generators + src/generator_base.cpp + src/generator_dart.cpp + src/generator_cppwrapper_impl.cpp + src/generator_cppwrapper_header.cpp + + # Helpers to convert types between languages + src/type_conversions/to_dart.cpp + src/type_conversions/to_C.cpp + src/type_conversions/to_CppWrapper.cpp + + # The actual printers + src/printers/printers.cpp + src/printers/ExternC_HeaderPrinter.cpp + src/printers/ExternC_ImplPrinter.cpp + src/printers/Dart_printer.cpp + src/printers/Cpp_ImplPrinter.cpp + src/printers/Cpp_HeaderPrinter.cpp +) + +qt_add_resources(DARTAGNAN_RESOURCES dartagnan.qrc) + +add_library(dartagnanlib STATIC ${dartagnan_SRCS} ${DARTAGNAN_RESOURCES}) + +target_include_directories(dartagnanlib + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/src/type_conversions/ + ${CMAKE_CURRENT_SOURCE_DIR}/src/printers + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/shiboken/sources/shiboken6/generator/ + 3rdparty/shiboken/sources/shiboken6/ApiExtractor/ ) + +target_link_libraries(dartagnanlib Qt${QT_MAJOR_VERSION}::Core) + +option(DARTAGNAN_DEVELOPER_BUILD "Enables tests" OFF) + +if (DARTAGNAN_DEVELOPER_BUILD) + option(RUN_DART_PUB_GET "Runs \"dart pub get\" for convenience. Required for running run_tests.dart" ON) + enable_testing() + add_subdirectory(tests) + add_test(NAME tests COMMAND dart run_tests.dart ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + if (RUN_DART_PUB_GET) + add_custom_command( + TARGET dartagnanlib + POST_BUILD + COMMAND dart + ARGS pub get + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + endif() +endif() + +add_executable(dartagnan src/main.cpp) +target_link_libraries(dartagnan Qt6::Core) +install(TARGETS dartagnan + DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..44ebe91 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "configurePresets": [ + { + "name": "dev", + "displayName": "dev", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build-dev", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON", + "DARTAGNAN_DEVELOPER_BUILD": "ON" + } + }, + { + "name": "release", + "displayName": "release", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build-release", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON" + } + } + ] +} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e3a4ebd --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Sergio Martins + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..82cfc2c --- /dev/null +++ b/README.md @@ -0,0 +1,68 @@ +# Dartagnan + +![Build Status](https://github.com/iamsergio/dartagnan/actions/workflows/build.yml/badge.svg) + +Dartagnan is a POC of C++ Dart bindings generator. +Unlike other generators, Dartagnan preserves OOP semantics when crossing language barrier. +A Dart class can inherit from a C++ class, override virtual methods and still get dynamic dispatch working. +In other words, whether the base class is Dart or C++ is irrelevant from the user's prespective, as inheritance +still works as supposed to. + +## Example + +```cpp +#include + +class Animal { +public: + // non-virtual! for example purposes + void eat() { + std::cout << "eat from C++"; + openMouth(); + closeMouth(); + } + + virtual void openMouth() { + std::cout << "openMouth from C++"; + } + + virtual void closeMouth() { + std::cout << "closeMouth from C++"; + } +}; +``` + +```dart +class MyDartAlligator extends MyBindings.Animal { + @override + void openMouth() { + print("openMouth from Dart"); + } +} + +main() { + final alligator = MyDartAlligator(); + + /// This will call C++ eat() via FFI + /// which in turn will call into Dart to invoke openMouth() + /// closeMouth() will be C++ to C++ directly, as it's not overridden in Dart + alligator.eat(); + + // Prints: + // eat from C++ + // openMouth from Dart + // closeMouth from C++ +} +``` + +## Problems + +- Passing small and trivial-destructible structs to C++ is allocating memory. They should be passed via registers, or at the very least stack. + +- C++ is complex, Dartagnan often breaks and needs patches with complex projects. + +- The POC code is a mess, specially after shoehorning C++ template support. + +- Dartagnan is based on shiboken's Api-extractor, which is a LLVM-based C++ parser. Api extractor brings in Qt as a dependency. + +- Rebasing over new shiboken, newer LLVM and newer Qt often causes regressions. diff --git a/TODO b/TODO new file mode 100644 index 0000000..64d75ac --- /dev/null +++ b/TODO @@ -0,0 +1,12 @@ +- Deleting temporary variables. They currently leak. +- When overriding virtual C++ methods in dart, we only support int and void return types (yet). +- Support nested C++ namespaces +- Support global functions +- Enums: + - Support global enums + - Support "enum class" + - Support other storage than int + - Figure out how to initialize enumerators in Dart. Currently we're working + around it with a class. +- Support classes having protected members, currently the C wrapper can't access them. +- Support forwarding argument when catching signals, currently arguments are lost diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..7861ec3 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,5 @@ +analyzer: + errors: + non_native_function_type_argument_to_pointer: ignore + implicit_dynamic_return: ignore + must_be_a_native_function_type: ignore \ No newline at end of file diff --git a/cmake/ECM/modules/BSD-3-Clause.txt b/cmake/ECM/modules/BSD-3-Clause.txt new file mode 100644 index 0000000..d583b4a --- /dev/null +++ b/cmake/ECM/modules/BSD-3-Clause.txt @@ -0,0 +1,28 @@ +Copyright (c) . All rights reserved. + +This license applies to the CMake ECM modules only. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors +may be used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/cmake/ECM/modules/ECMEnableSanitizers.cmake b/cmake/ECM/modules/ECMEnableSanitizers.cmake new file mode 100644 index 0000000..e04c831 --- /dev/null +++ b/cmake/ECM/modules/ECMEnableSanitizers.cmake @@ -0,0 +1,156 @@ +#.rst: +# ECMEnableSanitizers +# ------------------- +# +# Enable compiler sanitizer flags. +# +# The following sanitizers are supported: +# +# - Address Sanitizer +# - Memory Sanitizer +# - Thread Sanitizer +# - Leak Sanitizer +# - Undefined Behaviour Sanitizer +# +# All of them are implemented in Clang, depending on your version, and +# there is an work in progress in GCC, where some of them are currently +# implemented. +# +# This module will check your current compiler version to see if it +# supports the sanitizers that you want to enable +# +# Usage +# ===== +# +# Simply add:: +# +# include(ECMEnableSanitizers) +# +# to your ``CMakeLists.txt``. Note that this module is included in +# KDECompilerSettings, so projects using that module do not need to also +# include this one. +# +# The sanitizers are not enabled by default. Instead, you must set +# ``ECM_ENABLE_SANITIZERS`` (either in your ``CMakeLists.txt`` or on the +# command line) to a semicolon-separated list of sanitizers you wish to enable. +# The options are: +# +# - address +# - memory +# - thread +# - leak +# - undefined +# - fuzzer +# +# The sanitizers "address", "memory" and "thread" are mutually exclusive. You +# cannot enable two of them in the same build. +# +# "leak" requires the "address" sanitizer. +# +# .. note:: +# +# To reduce the overhead induced by the instrumentation of the sanitizers, it +# is advised to enable compiler optimizations (``-O1`` or higher). +# +# Example +# ======= +# +# This is an example of usage:: +# +# mkdir build +# cd build +# cmake -DECM_ENABLE_SANITIZERS='address;leak;undefined' .. +# +# .. note:: +# +# Most of the sanitizers will require Clang. To enable it, use:: +# +# -DCMAKE_CXX_COMPILER=clang++ +# +# Since 1.3.0. + +#============================================================================= +# SPDX-FileCopyrightText: 2014 Mathieu Tarral +# +# SPDX-License-Identifier: BSD-3-Clause + +# MACRO check_compiler_version +#----------------------------- +macro (check_compiler_version gcc_required_version clang_required_version) + if ( + ( + CMAKE_CXX_COMPILER_ID MATCHES "GNU" + AND + CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${gcc_required_version} + ) + OR + ( + CMAKE_CXX_COMPILER_ID MATCHES "Clang" + AND + CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${clang_required_version} + ) + ) + # error ! + message(FATAL_ERROR "You ask to enable the sanitizer ${CUR_SANITIZER}, + but your compiler ${CMAKE_CXX_COMPILER_ID} version ${CMAKE_CXX_COMPILER_VERSION} + does not support it ! + You should use at least GCC ${gcc_required_version} or Clang ${clang_required_version} + (99.99 means not implemented yet)") + endif () +endmacro () + +# MACRO check_compiler_support +#------------------------------ +macro (enable_sanitizer_flags sanitize_option) + if (${sanitize_option} MATCHES "address") + check_compiler_version("4.8" "3.1") + set(XSAN_COMPILE_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls") + set(XSAN_LINKER_FLAGS "asan") + elseif (${sanitize_option} MATCHES "thread") + check_compiler_version("4.8" "3.1") + set(XSAN_COMPILE_FLAGS "-fsanitize=thread") + set(XSAN_LINKER_FLAGS "tsan") + elseif (${sanitize_option} MATCHES "memory") + check_compiler_version("99.99" "3.1") + set(XSAN_COMPILE_FLAGS "-fsanitize=memory") + elseif (${sanitize_option} MATCHES "leak") + check_compiler_version("4.9" "3.4") + set(XSAN_COMPILE_FLAGS "-fsanitize=leak") + set(XSAN_LINKER_FLAGS "lsan") + elseif (${sanitize_option} MATCHES "undefined") + check_compiler_version("4.9" "3.1") + set(XSAN_COMPILE_FLAGS "-fsanitize=undefined -fno-omit-frame-pointer -fno-optimize-sibling-calls") + elseif (${sanitize_option} MATCHES "fuzzer") + check_compiler_version("99.99" "6.0") + set(XSAN_COMPILE_FLAGS "-fsanitize=fuzzer") + else () + message(FATAL_ERROR "Compiler sanitizer option \"${sanitize_option}\" not supported.") + endif () +endmacro () + +if (ECM_ENABLE_SANITIZERS) + if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # for each element of the ECM_ENABLE_SANITIZERS list + foreach ( CUR_SANITIZER ${ECM_ENABLE_SANITIZERS} ) + # lowercase filter + string(TOLOWER ${CUR_SANITIZER} CUR_SANITIZER) + # check option and enable appropriate flags + enable_sanitizer_flags ( ${CUR_SANITIZER} ) + # TODO: GCC will not link pthread library if enabled ASan + if(CMAKE_C_COMPILER_ID MATCHES "Clang") + set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${XSAN_COMPILE_FLAGS}" ) + endif() + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${XSAN_COMPILE_FLAGS}" ) + if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + link_libraries(${XSAN_LINKER_FLAGS}) + endif() + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + string(REPLACE "-Wl,--no-undefined" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") + string(REPLACE "-Wl,--no-undefined" "" CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}") + endif () + endforeach() + else() + message(STATUS "Tried to enable sanitizers (-DECM_ENABLE_SANITIZERS=${ECM_ENABLE_SANITIZERS}), \ +but compiler (${CMAKE_CXX_COMPILER_ID}) does not have sanitizer support") + endif() +endif() diff --git a/dartagnan.qrc b/dartagnan.qrc new file mode 100644 index 0000000..6b1b800 --- /dev/null +++ b/dartagnan.qrc @@ -0,0 +1,8 @@ + + + snippets/pubspec.yaml + snippets/LibraryLoader.dart + snippets/methodIsOverridden.dart + snippets/ValueWrapper.h + + diff --git a/pubspec.lock b/pubspec.lock new file mode 100644 index 0000000..7f601c3 --- /dev/null +++ b/pubspec.lock @@ -0,0 +1,21 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + path: + dependency: "direct main" + description: + name: path + sha256: "2ad4cddff7f5cc0e2d13069f2a3f7a73ca18f66abd6f5ecf215219cdb3638edb" + url: "https://pub.dev" + source: hosted + version: "1.8.0" + pedantic: + dependency: "direct dev" + description: + name: pedantic + sha256: "8f6460c77a98ad2807cd3b98c67096db4286f56166852d0ce5951bb600a63594" + url: "https://pub.dev" + source: hosted + version: "1.11.0" +sdks: + dart: ">=2.17.0 <4.0.0" diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 0000000..96bf448 --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,11 @@ +name: DartagnanTests +description: The test runner app +# version: 1.0.0 +# homepage: https://www.kdab.com +environment: + sdk: '>=2.17.0 <3.0.0' + +dev_dependencies: + pedantic: ^1.9.0 +dependencies: + path: ^1.7.0 diff --git a/run_tests.dart b/run_tests.dart new file mode 100644 index 0000000..6f39237 --- /dev/null +++ b/run_tests.dart @@ -0,0 +1,273 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +import 'dart:io'; +import 'dart:io' show Platform; +import 'package:path/path.dart'; + +import 'utils.dart' as Utils; + +String s_buildDir = ""; +String s_targetLib = ""; +String s_bindingsLib = ""; +String s_bindingsBuildDir = ""; +bool s_printOnly = false; // Dry run, only prints commands +bool s_addReadabilityTags = false; +bool s_useGDB = false; // Will run shiboken under GDB +bool s_useASAN = false; +bool s_useLSAN = true; +bool s_runShiboken = true; +bool s_useSymbolizationWorkaround = true; + +Map s_envVars = Map.from(Platform.environment); + +final String s_sourcePath = dirname(Platform.script.toFilePath()); +final String s_testsPath = "${s_sourcePath}/tests"; +final String s_bindingsSourceDir = "${s_testsPath}/generated/"; + +final String s_testsDartExecutable = "${s_testsPath}/app/bin/main.dart"; +final String s_testsDartAOTExecutable = "${s_testsPath}/app/bin/main.aot"; + +Future runShiboken() async { + final String cmd = + "${s_buildDir}/3rdparty/shiboken/sources/shiboken6/generator/shiboken6"; + final args = [ + "--output-directory=${s_testsPath}/generated/", + "--generator-set=dart", + "--skip-deprecated", + "--clang-option=-DDARTAGNAN_BINDINGS_RUN" + ] + + Utils.includeArguments() + + ["bindings_global.h", "typesystem.xml"]; + + Map env = { + if (s_addReadabilityTags) 'DARTAGNAN_READABILITY_TAGS': '1' + }; + + return Utils.runCommand(cmd, args, + workingDirectory: s_testsPath, + printOnly: s_printOnly, + useGDB: s_useGDB, + env: env); +} + +Future getPackages() { + return Utils.getPackages( + workingDirectory: "${s_testsPath}/app", printOnly: s_printOnly); +} + +Future runTests() async { + if (!File(s_testsDartExecutable).existsSync()) { + print("File ${s_testsDartExecutable} does not exist!"); + return 1; + } + + // Build performance improvement: + // Save the timestamps, so we can restore them for every file which was + // generated with the same content as before. No point in rebuilding those. + final savedTimestamps = await Utils.TimeStamps('tests/generated'); + if (!Platform.isWindows) + savedTimestamps.create(); // Not implemented on windows + + /// If dartagnan already ran, then the tests don't need to + final bool runCodeFormat = + !Platform.environment.containsKey('DARTAGNAN_RUNS_CODE_FORMAT'); + + // Run shiboken to generate the bindings + if (s_runShiboken) { + final shibokenResult = await runShiboken(); + if (shibokenResult != 0) { + print( + "Failed to generate the bindings. Shiboken failed with code ${shibokenResult}"); + savedTimestamps.restoreTimeStamps(); + return -1; + } + + if (runCodeFormat) { + if (await Utils.runDartFormat(s_bindingsSourceDir, + printOnly: s_printOnly) != + 0) { + print("Failed to run dart format"); + savedTimestamps.restoreTimeStamps(); + return -1; + } + + if (await Utils.runClangFormat( + "${s_bindingsSourceDir}/TestBindings/dart/ffi/") != + 0) { + print("Failed to run clangformat"); + savedTimestamps.restoreTimeStamps(); + return -1; + } + } + + await savedTimestamps.restoreTimeStamps(); + + // Build the generated bindings lib + var cmakeExtraArgs = []; + + if (s_useASAN) { + cmakeExtraArgs = ["-DECM_ENABLE_SANITIZERS='address;undefined'"]; + } + + if (await Utils.runCommand( + "cmake", + [ + "-B", + "${s_bindingsBuildDir}", + "-S", + "${s_bindingsSourceDir}", + "-G", + "Ninja", + "-DCMAKE_BUILD_TYPE=Debug", + ] + + cmakeExtraArgs) != + 0) { + print("Fail to configure bindings lib"); + return -1; + } + + if (await Utils.runCommand("cmake", ["--build", "${s_bindingsBuildDir}"]) != + 0) { + print("Fail to build bindings lib"); + return -1; + } + + if (!File(s_bindingsLib).existsSync()) { + print("Could not find ${s_bindingsLib}"); + return -1; + } + + if (await getPackages() != 0) { + print("Failed to get packages"); + return -1; + } + } + + if (await Utils.runCommand( + "dart", ["compile", "aot-snapshot", s_testsDartExecutable]) != + 0) { + print("Failed to compile aot-snapshot"); + return 1; + } + + var env = s_envVars; + if (s_useASAN || s_useLSAN) { + env['LD_PRELOAD'] = '/usr/lib/libasan.so'; + env['ASAN_OPTIONS'] = 'new_delete_type_mismatch=0'; + + if (s_printOnly) { + for (String key in ["LD_PRELOAD", "LSAN_OPTIONS", "ASAN_OPTIONS"]) + print("ENV ${key}=${env[key]}"); + } + } + + if (Platform.isMacOS) { + // DYLD_LIBRARY_PATH doesn't work on mac by default anymore + env['DARTAGNAN_BINDINGSLIB_PATH'] = "${s_bindingsBuildDir}/TestBindings"; + if (s_printOnly) { + print( + "ENV DARTAGNAN_BINDINGSLIB_PATH=${env['DARTAGNAN_BINDINGSLIB_PATH']}"); + } + } + + return Utils.runCommand( + "dartaotruntime", + [ + s_testsDartAOTExecutable, + if (s_useSymbolizationWorkaround) "--symbolization-workaround" + ], + env: env, + printOnly: s_printOnly); +} + +void printUsage() { + print( + " Usage: \$ dart run_tests.dart [--asan] [--no-lsan] [--tags] [--no-shiboken] [--symbolization-workaround] "); +} + +bool setupPaths(String buildDir) { + s_buildDir = Directory(buildDir).absolute.path; + s_targetLib = "${s_buildDir}/tests/${Utils.normalizedLibName("TestTarget")}"; + + s_bindingsBuildDir = "${s_buildDir}/tests/generated/"; + s_bindingsLib = + "${s_bindingsBuildDir}/TestBindings/${Utils.normalizedLibName("TestBindings")}"; + + if (!File(s_targetLib).existsSync()) { + print("Could not find ${s_targetLib}"); + return false; + } + + final String libraryPathStr = s_envVars[Utils.s_libraryPathEnvVariable] ?? ""; + + var libraryPaths = libraryPathStr.split(Utils.s_listSeparator); + libraryPaths += [ + "${s_buildDir}/tests/generated/TestBindings/", + "${s_buildDir}/tests" + ]; + + s_envVars[Utils.s_libraryPathEnvVariable] = + libraryPaths.join(Utils.s_listSeparator); + return true; +} + +Future main(List args_) async { + String buildDir = ""; + + List args = List.from(args_); + s_printOnly = args.contains("--print"); + s_useGDB = args.contains("--gdb"); + s_useASAN = args.contains("--asan"); + s_useLSAN = !args.contains("--no-lsan") && Platform.isLinux; + s_addReadabilityTags = args.contains("--tags"); + s_runShiboken = !args.contains("--no-shiboken"); + s_useSymbolizationWorkaround = args.contains("--symbolization-workaround"); + + if (s_useASAN && !Platform.isLinux) { + print("--asan is only supported on Linux. Patches accepted."); + return -1; + } + + if (s_addReadabilityTags && !s_runShiboken) { + print("--tags requires a shiboken run"); + return -1; + } + + args.remove("--print"); + args.remove("--gdb"); + args.remove("--asan"); + args.remove("--no-lsan"); + args.remove("--tags"); + args.remove("--no-shiboken"); + args.remove("--symbolization-workaround"); + + if (args.length > 1 || args.contains("help") || args.contains("--help")) { + printUsage(); + return 0; + } else if (args.length == 1) { + buildDir = args.first; + } else { + print("No build dir was passed. Assuming build-dev/"); + buildDir = "${s_sourcePath}/build-dev"; + } + + if (!setupPaths(buildDir)) { + print( + "Did you build the bindings ? Make sure you're using a developer-build, or just pass --preset=dev to cmake when configuring."); + return -2; + } + + final int result = await runTests(); + print(""); + + if (result == 0) { + print("Success!! "); + } else { + print("Error!! code = $result"); + } + + exit(result); +} diff --git a/snippets/LibraryLoader.dart b/snippets/LibraryLoader.dart new file mode 100644 index 0000000..feee20d --- /dev/null +++ b/snippets/LibraryLoader.dart @@ -0,0 +1,37 @@ +import 'dart:ffi' as ffi; +import 'dart:io' show Platform; + +String bindingsLibraryName(String name) { + if (Platform.isWindows) return "${name}.dll"; + if (Platform.isMacOS) return "lib${name}.dylib"; + return "lib${name}.so"; +} + +class Library { + var _dylib; + + ffi.DynamicLibrary get dylib { + return _dylib; + } + + static var _library = null; + + factory Library.instance() { + // Singleton impl. + if (_library == null) _library = Library._(); + return _library; + } + + Library._() { + // DYLD_LIBRARY_PATH doesn't work by default on newer macOS. Instead + // introduce our own env variable for the same use case + var bindingsPath = Platform.environment["DARTAGNAN_BINDINGSLIB_PATH"] ?? ""; + + var libraryPath = bindingsLibraryName("%1"); + if (!bindingsPath.isEmpty) { + libraryPath = bindingsPath + "/" + libraryPath; + } + + _dylib = ffi.DynamicLibrary.open(libraryPath); + } +} diff --git a/snippets/ValueWrapper.h b/snippets/ValueWrapper.h new file mode 100644 index 0000000..b06aeb5 --- /dev/null +++ b/snippets/ValueWrapper.h @@ -0,0 +1,13 @@ + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} diff --git a/snippets/methodIsOverridden.dart b/snippets/methodIsOverridden.dart new file mode 100644 index 0000000..fc7e0ef --- /dev/null +++ b/snippets/methodIsOverridden.dart @@ -0,0 +1,8 @@ +bool dartMethodIsOverridden(String methodName) { + final InstanceMirror reflectedClass = reflect(this); + final methods = reflectedClass.type.instanceMembers; + final methodMirror = methods[Symbol(methodName)]; + + String str = methodMirror?.owner?.qualifiedName.toString(); + return str != "Symbol(\".%1\")"; +} diff --git a/snippets/pubspec.yaml b/snippets/pubspec.yaml new file mode 100644 index 0000000..dc9a64d --- /dev/null +++ b/snippets/pubspec.yaml @@ -0,0 +1,13 @@ +name: %1 +description: %2 + +environment: + sdk: '>=2.17.0 <3.0.0' + +dependencies: + ffi: + intl: + meta: + +dev_dependencies: + pedantic: ^1.9.0 diff --git a/src/Logging.cpp b/src/Logging.cpp new file mode 100644 index 0000000..fe94ad0 --- /dev/null +++ b/src/Logging.cpp @@ -0,0 +1,8 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#include "Logging.h" + +Q_LOGGING_CATEGORY(discarding, "kdab.dartagnan.discarding", QtDebugMsg) diff --git a/src/Logging.h b/src/Logging.h new file mode 100644 index 0000000..43e9419 --- /dev/null +++ b/src/Logging.h @@ -0,0 +1,10 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#pragma once + +#include + +Q_DECLARE_LOGGING_CATEGORY(discarding) diff --git a/src/dart_ffi_typedefs.cpp b/src/dart_ffi_typedefs.cpp new file mode 100644 index 0000000..78439a6 --- /dev/null +++ b/src/dart_ffi_typedefs.cpp @@ -0,0 +1,163 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#include "dart_ffi_typedefs.h" +#include "type_conversions/to_dart.h" + +#include + +FFITypedefs::FFITypedefs() +{ + m_typedefs << "// tag=1053\n"; + m_typedefs << "typedef void_Func_voidstar = void Function(ffi.Pointer);"; + m_typedefs << "typedef void_Func_voidstar_FFI = ffi.Void Function(ffi.Pointer);"; + + m_typedefs << "typedef RegisterMethodIsReimplementedCallback = void " + "Function(ffi.Pointer, ffi.Pointer, int);"; + m_typedefs << "typedef RegisterMethodIsReimplementedCallback_FFI = ffi.Void " + "Function(ffi.Pointer, ffi.Pointer, ffi.Int32);"; + + m_typedefs << "typedef SignalHandler = void Function(ffi.Pointer, ffi.Pointer, " + "ffi.Pointer);"; + m_typedefs << "typedef SignalHandler_FFI = ffi.Void Function(ffi.Pointer, " + "ffi.Pointer, ffi.Pointer);"; +} + +const QStringList FFITypedefs::typedefs() const +{ + return m_typedefs; +} + +FFITypedefs &FFITypedefs::instance() +{ + static FFITypedefs s_instance; + return s_instance; +} + +void FFITypedefs::addDartFunctionTypedef(const AbstractMetaFunction *func) +{ + const AbstractMetaTypeList templateInstantiations = Dartagnan::instantiationsForFunction(func); + + if (templateInstantiations.isEmpty() && !Dartagnan::hasTemplateArguments(func)) { + addDartFunctionTypedef(func, {}); + } else { + for (AbstractMetaType templateInstantiation : templateInstantiations) { + addDartFunctionTypedef(func, templateInstantiation); + } + } +} + +void FFITypedefs::addDartFunctionTypedef(const AbstractMetaFunction *func, + AbstractMetaType templateInstantiation) +{ + const QString typedefstr = functionTypedef(func, templateInstantiation); + if (m_typedefs.contains(typedefstr)) + return; + + m_typedefs << typedefstr; + m_typedefs << ffiFunctionTypedef(func, templateInstantiation); +} + +QString FFITypedefs::functionTypedef(const AbstractMetaFunction *func, + AbstractMetaType templateInstantiation) const +{ + const QString returnType = + ToDartConversions::type(func, ToDartConversions::Option::ForTypedef, templateInstantiation); + const AbstractMetaArgumentList arguments = func->arguments(); + QStringList memberTypes; + if (!func->isStatic() && !func->isConstructor()) + memberTypes << "ffi.Pointer"; // 'this' pointer + + for (AbstractMetaArgument argument : arguments) { + AbstractMetaType actualType = Dartagnan::actualType(argument.type(), templateInstantiation); + memberTypes << ToDartConversions::type( + actualType, + ToDartConversions::Options(ToDartConversions::Option::NoBool) + | ToDartConversions::Option::ForTypedef); + } + + return QStringLiteral("typedef %1 = %2 Function(%3);") + .arg(typedefName(func, templateInstantiation), returnType, memberTypes.join(",")); +} + +QString FFITypedefs::ffiFunctionTypedef(const AbstractMetaFunction *func, + AbstractMetaType templateInstantiation) const +{ + const QString returnTypeFFI = ToDartConversions::typeForFFI(func, templateInstantiation); + if (returnTypeFFI.isEmpty()) { + qWarning() << Q_FUNC_INFO << "Failed to get type for function" << func->name(); + return {}; + } + + QStringList memberTypesFFI; + if (!func->isStatic() && !func->isConstructor()) + memberTypesFFI << "ffi.Pointer"; // 'this' pointer + + const AbstractMetaArgumentList arguments = func->arguments(); + for (AbstractMetaArgument argument : arguments) + memberTypesFFI << ToDartConversions::typeForFFI(argument.type(), templateInstantiation); + + + return QStringLiteral("typedef %1 = %2 Function(%3);") + .arg(ToDartConversions::mangle(ffiTypedefName(func, templateInstantiation)), returnTypeFFI, + memberTypesFFI.join(",")); +} + +QString FFITypedefs::typedefName(const AbstractMetaFunction *method, + AbstractMetaType templateInstantiation) +{ + const QString returnType = + ToDartConversions::type(method, + ToDartConversions::Options(ToDartConversions::Option::ForTypedef) + | ToDartConversions::Option::ForTypedefName, + templateInstantiation); + + QStringList memberTypes; + if (!method->isStatic() && !method->isConstructor() && method->ownerClass()) { + // When calling a method we need to pass 'this' + memberTypes << "ffi.Pointer"; + } + + const AbstractMetaArgumentList arguments = method->arguments(); + for (AbstractMetaArgument argument : arguments) { + + AbstractMetaType actualType = Dartagnan::actualType(argument.type(), templateInstantiation); + memberTypes << ToDartConversions::type( + actualType, + ToDartConversions::Options(ToDartConversions::Option::ForTypedef) + | ToDartConversions::Option::ForTypedefName); + } + + const QString memberTypesTypedef = + memberTypes.isEmpty() ? QString("void") : memberTypes.join("_"); + + return QStringLiteral("%1_Func_%2") + .arg(ToDartConversions::mangle(returnType), ToDartConversions::mangle(memberTypesTypedef)); +} + +QString FFITypedefs::ffiTypedefName(const AbstractMetaFunction *func, + AbstractMetaType templateInstantiation) +{ + const QString returnType = + ToDartConversions::type(func, + ToDartConversions::Options(ToDartConversions::Option::ForTypedef) + | ToDartConversions::Option::ForTypedefName, + templateInstantiation); + + QStringList memberTypesFFI; + if (!func->isStatic() && !func->isConstructor() && func->ownerClass()) + memberTypesFFI << "voidstar"; // 'this' is the first argument for members + + const AbstractMetaArgumentList arguments = func->arguments(); + for (AbstractMetaArgument argument : arguments) { + memberTypesFFI << ToDartConversions::typeForFFI(argument.type(), templateInstantiation); + } + + const QString memberTypesTypedefFFI = + memberTypesFFI.isEmpty() ? QString("void") : memberTypesFFI.join("_"); + + return ToDartConversions::mangle( + QStringLiteral("%1_Func_%2_FFI").arg(returnType, memberTypesTypedefFFI)); +} diff --git a/src/dart_ffi_typedefs.h b/src/dart_ffi_typedefs.h new file mode 100644 index 0000000..a90ce06 --- /dev/null +++ b/src/dart_ffi_typedefs.h @@ -0,0 +1,54 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#pragma once + +#include "dartagnan.h" + +/// @brief Class to help generate the TypeHelpers.dart, which has a list of FFI function typedefs +class FFITypedefs +{ +public: + /// @brief It's a singleton + static FFITypedefs &instance(); + + /// @brief Adds the needed FFI typedefs for the specified method + + void addDartFunctionTypedef(const AbstractMetaFunction *func); + + void addDartFunctionTypedef(const AbstractMetaFunction *func, + AbstractMetaType templateInstantiation); + + /** + * @brief returns the list of typefefs that should go into TypeHelpers.dart + * Example: + * "typedef int_Func_void = int Function();" + * "typedef int_Func_void_FFI = ffi.Int32 Function();" + */ + const QStringList typedefs() const; + + /// Returns the name portion of the typedef + /// If the typedef was "typedef A = B" this function would return: A + static QString typedefName(const AbstractMetaFunction *, + AbstractMetaType templateInstantiation); + + /// Like typedefName() but with FFI types + static QString ffiTypedefName(const AbstractMetaFunction *method, + AbstractMetaType templateInstantiation); + +private: + FFITypedefs(); + + /// Returns the complete typedef + QString functionTypedef(const AbstractMetaFunction *func, + AbstractMetaType templateInstantiation) const; + + /// Returns the complete ffi typedef + QString ffiFunctionTypedef(const AbstractMetaFunction *func, + AbstractMetaType templateInstantiation) const; + + /// @brief list of typedefs to dump into our TypeHelpers.dart file + QStringList m_typedefs; +}; diff --git a/src/dartagnan.cpp b/src/dartagnan.cpp new file mode 100644 index 0000000..37ce297 --- /dev/null +++ b/src/dartagnan.cpp @@ -0,0 +1,1005 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#include "dartagnan.h" +#include "Logging.h" +#include "apiextractor.h" +#include "generator_base.h" +#include "generator_dart.h" +#include "to_dart.h" +#include "typedatabase.h" + +#include + +#include + +using namespace Dartagnan; + +static QHash s_functionIds; + +static bool methodHasSameSignatureInAllBases(const AbstractMetaFunction *method) +{ + if (!method->isVirtual() || method->isAbstract()) + return true; + + const QString sig = method->minimalSignature(); + const int minArgCount = method->actualMinimumArgumentCount(); + + auto metaClass = method->ownerClass(); + for (auto base : metaClass->baseClasses()) { + for (auto func : base->functions()) { + if (func->minimalSignature() == sig) { + if (!methodHasSameSignatureInAllBases(func.get())) + return false; + if (func->actualMinimumArgumentCount() != minArgCount) { + return false; + } + } + } + } + + return true; +} + +bool Dartagnan::acceptsMethod(const AbstractMetaFunction *func, RejectedMethods rejectedMethods) +{ + if (func->name() == "toString") { + // This conflicts with Dart's Object.toString() + return false; + } + + if (func->name() == "is") { + // "is" is a reserved word in Dart + return false; + } + + if (func->name() == "qt_getEnumName") { + // TODO: Uncomment and fix failures + return false; + } + + auto ownerClass = func->ownerClass(); + auto declaringClass = func->declaringClass(); + auto implementingClass = func->implementingClass(); + + if (ownerClass->name() == "QList") { + if (func->name() == "constData" || func->name() == "data") { + // TODO: Uncomment and fix failures + qCDebug(discarding) << Q_FUNC_INFO << "Discarding QList data method"; + return false; + } + } + + if (func->isStatic()) { + if (auto metaClass = func->ownerClass()) { + auto instantiations = DartGenerator::instance()->templateHash().value(metaClass); + if (!instantiations.isEmpty()) { + qCDebug(discarding) << Q_FUNC_INFO << "Discarding static function" + << func->signature() << ", Which has template instantiations"; + return false; + } + } + } + + if (!methodHasSameSignatureInAllBases(func)) { + qCDebug(discarding) + << Q_FUNC_INFO + << "Discarding overridden function which has different default arguments in bases" + << func->signature(); + return false; + } + + if (func->isVirtual() && (rejectedMethods & RejectedMethod_VirtualFunctionExistingInBaseClass) + && ownerClass != declaringClass) { + if (!func->isAbstract()) { + qCDebug(discarding) << Q_FUNC_INFO + << "Discarding virtual function already present in base class" + << func->signature() + << "class=" << (ownerClass ? ownerClass->name() : "") + << "declaring=" << (declaringClass ? declaringClass->name() : "") + << "implementing=" + << (implementingClass ? implementingClass->name() : ""); + return false; + } + } else if (!func->isVirtual() && ownerClass != declaringClass && declaringClass + && implementingClass && ownerClass != implementingClass) { + qCDebug(discarding) << Q_FUNC_INFO << "Discarding function already present in base class" + << func->signature() + << "class=" << (ownerClass ? ownerClass->name() : "") + << "declaring=" << (declaringClass ? declaringClass->name() : "") + << "implementing=" + << (implementingClass ? implementingClass->name() : ""); + return false; + } + + if ((rejectedMethods & RejectedMethod_Deprecated) && func->isDeprecated()) { + qCDebug(discarding) << Q_FUNC_INFO << "Discarding deprecated" << func->signature(); + return false; + } + + if ((rejectedMethods & RejectedMethod_PureVirtual) && func->isAbstract()) { + qCDebug(discarding) << Q_FUNC_INFO << "Discarding pure-virtual" << func->signature(); + return false; + } + + if ((rejectedMethods & RejectedMethod_CopyCtor) && func->isCopyConstructor()) { + qCDebug(discarding) << Q_FUNC_INFO << "Discarding copy-ctor" << func->signature(); + return false; + } + + if ((rejectedMethods & RejectedMethod_MoveCtor) && isMoveConstructor(*func)) { + qCDebug(discarding) << Q_FUNC_INFO << "Discarding move-ctor" << func->signature(); + return false; + } + + if ((rejectedMethods & RejectedMethod_Private) && func->isPrivate()) { + qCDebug(discarding) << Q_FUNC_INFO << "Discarding private" << func->signature(); + return false; + } + + if ((rejectedMethods & RejectedMethod_AbstractClassCtor) && func->isConstructor()) { + const AbstractMetaClass *metaClass = func->ownerClass(); + if (metaClass->isAbstract()) { + qCDebug(discarding) << Q_FUNC_INFO << "Discarding abstract class" << func->signature(); + + return false; + } + } + + if ((rejectedMethods & RejectedMethod_ExplicitlyBlacklistedAbstractClassCtor) + && func->isConstructor()) { + const AbstractMetaClass *metaClass = func->ownerClass(); + const bool classIsReallyAbstract = + DartagnanGeneratorBase::m_optionsFromJson.pureVirtualClassOverrides.contains( + metaClass->qualifiedCppName()); + + if (classIsReallyAbstract) { + + qCDebug(discarding) << Q_FUNC_INFO + << "Discarding ctor from class mentioned in dartagnan.json" + << func->signature(); + + return false; + } + } + + if (rejectedMethods & RejectedMethod_ReceivingTemplate) { + for (auto arg : func->arguments()) { + if (arg.type().typeUsagePattern() == AbstractMetaType::TemplateArgument) { + qCDebug(discarding) << Q_FUNC_INFO << "Discarding" << func->signature() + << "Which receives template argument"; + return false; + } + } + } + + if (functionIsRemoved(func)) { + qCDebug(discarding) << Q_FUNC_INFO << "Discarding removed function" << func->signature(); + return false; + } + + if (func->functionType() == AbstractMetaFunction::CopyConstructorFunction) { + qCDebug(discarding) << Q_FUNC_INFO << "Discarding copy-ctor" << func->signature(); + return false; + } + + if (func->name() == "swap") { + // Not working. unneeded ? anyway don't want o spend time on it + qCDebug(discarding) << Q_FUNC_INFO << "Discarding swap()"; + return false; + } + + if (func->name().startsWith(QLatin1String("operator"))) { + return false; + } + + if (Dartagnan::hasTemplateArguments(func)) { + if (!func->ownerClass()) { + // TODO: Support function templates too + qCDebug(discarding) << Q_FUNC_INFO + << "Discarding non-method function with template arguments" + << func->signature(); + return false; + } + + auto templateHash = DartGenerator::instance()->templateHash(); + if (!templateHash.contains(func->ownerClass())) { + qCDebug(discarding) << Q_FUNC_INFO + << "Discarding method with no template instantiations" + << func->signature(); + return false; + } + } + + auto type = func->type(); + const QStringList unsupportedTypes = { "short", "long", "qint64" }; + + for (auto arg : func->arguments()) { + const QString sig = arg.type().cppSignature(); + if ((rejectedMethods & RejectedMethod_UnsupportedDartType) + && unsupportedTypes.contains(sig)) { + // Not supported, for now. + qCDebug(discarding) << Q_FUNC_INFO << "Discarding function with unsupported argments"; + return false; + } + + if (sig.contains("**") || sig.contains("[]")) { + qCDebug(discarding) << Q_FUNC_INFO + << "Pointer to pointer and array syntax not supported yet" + << "Discarding" << func->signature(); + return false; + } + + if (sig.contains("&&")) { + qCDebug(discarding) << Q_FUNC_INFO << "Discarding moves" << func->signature(); + return false; + } + + const QString argTypeName = arg.type().name(); + if (argTypeName == "string" || argTypeName == "wstring" || argTypeName == "std::string" + || argTypeName == "std::wstring" || argTypeName == "std::map" + || argTypeName == "std::string_view") { // Just startsWith("std::") ? + // Not yet supported. We must do the conversions to dart String + // Clunky but disposable code, will be removed. + return false; + } + + if (argTypeName.contains(" ")) { + // Not yet supported. For example "unassigned int" + return false; + } + + if (arg.type().typeUsagePattern() == AbstractMetaType::NativePointerPattern + && argTypeName != "char") { + qCDebug(discarding) << Q_FUNC_INFO << "Discarding" << func->signature() + << " as it has pointer to native type" << arg.type().name(); + return false; + } + } + + if (func->isOperatorOverload()) { + return false; + } + + for (auto arg : func->arguments()) { + if (arg.type().cppSignature() == "char") { + qCDebug(discarding) << Q_FUNC_INFO << "Char not supported." << func->signature(); + return false; // TODO: support char + } + } + + if (func->signature().contains("&&")) { + qCDebug(discarding) << Q_FUNC_INFO << "Discarding" << func->signature(); + return false; + } + + if (!hasType(type)) + return true; + + // Validate return types now: + + const QString returnTypeSig = type.cppSignature(); + + if (returnTypeSig == "std::string" || returnTypeSig == "std::wstring" + || returnTypeSig.startsWith("std::vector") || returnTypeSig.startsWith("std::map")) { + // Not yet supported. Will require implicit conversions + qCDebug(discarding) << Q_FUNC_INFO << "Discarding function with unsupported types" + << func->signature(); + return false; + } + + if ((rejectedMethods & RejectedMethod_UnsupportedDartType) + && unsupportedTypes.contains(returnTypeSig)) { + qCDebug(discarding) << Q_FUNC_INFO << "Discarding function with unsupported types" + << func->signature(); + return false; + } + + if (returnTypeSig.contains("**") || returnTypeSig.contains("[]")) { + qCDebug(discarding) << Q_FUNC_INFO + << "Pointer to pointer and array syntax not supported yet" + << "Discarding" << func->signature(); + return false; + } + + if (type.name().contains(" ")) { + qCDebug(discarding) << Q_FUNC_INFO << "Types with spaces are not supported yet" + << returnTypeSig; + return false; + } + + if ((rejectedMethods & RejectedMethod_ReturningTemplate) + && !func->type().instantiations().isEmpty() && func->type().hasTemplateChildren()) { + qCDebug(discarding) << Q_FUNC_INFO << "Discarding returning template" << func->signature(); + return false; + } + + if ((rejectedMethods & RejectedMethod_ReturningTemplateArgument) + && func->type().typeUsagePattern() == AbstractMetaType::TemplateArgument) { + qCDebug(discarding) << Q_FUNC_INFO << "Discarding returning template arg" + << func->signature(); + return false; + } + + if (type.isPrimitive() && !type.isConstant() && isReference(type)) { + // For example a function returning "int &" + // How do we handle this in dart ? + qCDebug(discarding) << Q_FUNC_INFO << "Discarding primitive non-const ref" + << func->signature(); + return false; + } + + if (type.typeUsagePattern() == AbstractMetaType::NativePointerPattern && type.isConstant() + && type.name() == "char") { + // Supporting "const char*" as return type for now. + // TODO: Support returning other things via pointer. + return true; + } + + switch (type.typeUsagePattern()) { + case AbstractMetaType::PrimitivePattern: + case AbstractMetaType::FlagsPattern: + case AbstractMetaType::EnumPattern: + case AbstractMetaType::ValuePattern: + case AbstractMetaType::ObjectPattern: + case AbstractMetaType::ValuePointerPattern: + case AbstractMetaType::ContainerPattern: + case AbstractMetaType::SmartPointerPattern: + case AbstractMetaType::VoidPattern: + case AbstractMetaType::TemplateArgument: + return true; + case AbstractMetaType::NativePointerAsArrayPattern: + case AbstractMetaType::VarargsPattern: + case AbstractMetaType::ArrayPattern: + case AbstractMetaType::NonTypeTemplateArgument: + case AbstractMetaType::NativePointerPattern: + // TODO: Support these + qCDebug(discarding) << Q_FUNC_INFO << "Discarding" << func->name() + << "; pattern=" << type.typeUsagePattern(); + return false; + } + + return true; +} + +bool Dartagnan::functionIsRemoved(const AbstractMetaFunction *method) +{ + const FunctionModificationList modifs = method->modifications(); + for (const auto &modif : modifs) { + if (modif.isRemoveModifier()) { + qCDebug(discarding) << Q_FUNC_INFO << "Discarding" << method->name(); + return true; + } + } + + return false; +} + +bool Dartagnan::SeenFunctions::functionWasSeen(const AbstractMetaFunction *func) const +{ + return m_seenFunctions.contains(completeFunctionSig(func)); +} + +void Dartagnan::SeenFunctions::markAsSeen(const AbstractMetaFunction *func) +{ + m_seenFunctions.insert(completeFunctionSig(func)); +} + +QString Dartagnan::SeenFunctions::completeFunctionSig(const AbstractMetaFunction *method) const +{ + QString ret = + QString("%1::%2").arg(method->ownerClass()->qualifiedCppName(), method->signature()); + ret.replace(") const", ")"); + + return ret; +} + +QString Dartagnan::exportsHeaderFilename() +{ + if (DartagnanGeneratorBase::m_optionsFromJson.exportsHeaderName.isEmpty()) { + return QStringLiteral("%1_exports.h").arg(TypeDatabase::instance()->defaultPackageName()); + } else { + return DartagnanGeneratorBase::m_optionsFromJson.exportsHeaderName; + } +} + +QString Dartagnan::exportMacroName() +{ + if (DartagnanGeneratorBase::m_optionsFromJson.exportsMacroName.isEmpty()) { + return QStringLiteral("%1_EXPORT").arg(TypeDatabase::instance()->defaultPackageName()); + } else { + return DartagnanGeneratorBase::m_optionsFromJson.exportsMacroName; + } +} + +bool Dartagnan::typeIsConstCharPtr(AbstractMetaType type) +{ + return type.isConstant() && type.name() == "char" + && type.typeUsagePattern() == AbstractMetaType::NativePointerPattern; +} + +QString Dartagnan::baseMostBaseClass(const AbstractMetaClass *metaClass) +{ + if (auto bc = metaClass->baseClass()) + return baseMostBaseClass(bc); + + return ToDartConversions::scopedNameForType(metaClass); +} + +QString Dartagnan::emptyReturnStatementFor(const AbstractMetaFunction *method) +{ + QString result = + QString("std::cerr << \"%1: Warning: Calling pure-virtual\\n\";\n").arg(method->name()); + + if (method->isVoid()) { + result += "return;"; + } else { + result += "return {};"; + } + + return result; +} + +const AbstractMetaClass *Dartagnan::classForType(AbstractMetaType type) +{ + return AbstractMetaClass::findClass(DartGenerator::instance()->api().classes(), + type.typeEntry()); +} + +const AbstractMetaClass *Dartagnan::classForName(const QString &name) +{ + for (const AbstractMetaClass *c : DartGenerator::instance()->api().classes()) { + if (c->name() == name) + return c; + } + return nullptr; +} + +AbstractMetaEnum Dartagnan::enumForType(AbstractMetaType metaEnum) +{ + for (auto metaClass : DartGenerator::instance()->api().classes()) { + for (auto e : metaClass->enums()) { + if (e.typeEntry() == metaEnum.typeEntry()) + return e; + } + } + + for (auto e : DartGenerator::instance()->api().globalEnums()) { + if (e.typeEntry() == metaEnum.typeEntry()) + return e; + } + + return {}; +} + +bool Dartagnan::needsGarbageCollection(const AbstractMetaClass *metaClass) +{ + if (metaClass->isNamespace() || metaClass->isPolymorphic()) + return false; + + return true; +} + +const AbstractMetaFunction *Dartagnan::baseMethodForFunction(const AbstractMetaFunction *method) +{ + if (!method->isVirtual() || method->declaringClass() == method->ownerClass()) { + return method; + } + + const QString sig = method->minimalSignature(); + for (auto m : method->declaringClass()->functions()) { + if (m->minimalSignature() == sig) + return m.get(); + } + + qWarning() << Q_FUNC_INFO << "Couldn't find base method for" << method->signature() + << method->ownerClass()->name() << method->declaringClass()->name(); + return method; +} + +int Dartagnan::idForFunction(const AbstractMetaFunction *func) +{ + if (func->isDestructor()) + return int(SpecialFunctionId::Destructor); + + auto f = Dartagnan::baseMethodForFunction(func); + return s_functionIds.value(f, int(SpecialFunctionId::Invalid)); +} + +void Dartagnan::createFunctionIdCache() +{ + if (!s_functionIds.isEmpty()) { + // Already filled by other generators + return; + } + + auto generator = DartGenerator::instance(); + static int s_nextId = 0; + + for (const AbstractMetaClass *metaClass : generator->api().classes()) { + for (auto f : metaClass->functions()) { + auto func = f.get(); + auto baseFunc = Dartagnan::baseMethodForFunction(func); + if (baseFunc == func) { // if it's different then it will be handled in the base class + s_functionIds[func] = s_nextId++; + } + } + } + + for (auto func : generator->api().globalFunctions()) { + s_functionIds[func.get()] = s_nextId++; + } +} + +int Dartagnan::indexOfTemplateArg(const AbstractMetaClass *metaClass, + AbstractMetaType templateArgument) +{ + if (!metaClass || !hasType(templateArgument)) + return -1; + + if (templateArgument.typeUsagePattern() != AbstractMetaType::TemplateArgument) + return -1; + + const QString templateArgName = templateArgument.name(); + + // args is for example: T, G, W + // templateArgument is for example: W + // The result index for the above example would be: 2 + const auto args = metaClass->templateArguments(); + + auto it = std::find_if(args.cbegin(), args.cend(), [templateArgName](const TypeEntry *te) { + return templateArgName == te->name(); + }); + + return it == args.cend() ? -1 : std::distance(args.cbegin(), it); +} + +AbstractMetaType Dartagnan::instantiationForTemplateArgument(AbstractMetaType classInstantiation, + AbstractMetaType templateArgument) +{ + if (!hasType(classInstantiation)) + return {}; + + const AbstractMetaClass *metaClass = classForType(classInstantiation); + + const int index = indexOfTemplateArg(metaClass, templateArgument); + const int numArgs = classInstantiation.instantiations().size(); + + if (index >= 0 && index < numArgs) { + return classInstantiation.instantiations().at(index); + } else { + qWarning() << Q_FUNC_INFO << "Failed to find instantiation for" + << "; classInstantiation=" << classInstantiation.cppSignature() + << "; templateArg=" << templateArgument.cppSignature() << "; index=" << index + << "; numArgs=" << numArgs << "; metaClass=" << metaClass; + Q_ASSERT(false); + + return {}; + } +} + +QVector +Dartagnan::instantiationsForTemplateArguments(AbstractMetaType classInstantiation, + AbstractMetaType classTemplate) +{ + if (!classTemplate.hasTemplateChildren()) + return {}; + + QVector result; + + for (auto t : classTemplate.instantiations()) { + result << instantiationForTemplateArgument(classInstantiation, t); + } + + return result; +} + +QString Dartagnan::instantiationsTextForTemplateArguments(AbstractMetaType classInstantiation, + AbstractMetaType classTemplate, + TemplateFormatOptions formatOptions) +{ + QStringList args; + const QVector instantiatedArgs = + instantiationsForTemplateArguments(classInstantiation, classTemplate); + + for (const AbstractMetaType &t : instantiatedArgs) { + args << t.cppSignature(); + } + + QString result = args.join(","); + + if (formatOptions & TemplateFormatOption::IncludeBraces) + result = QString("<%1>").arg(result); + + if (formatOptions & TemplateFormatOption::IncludeClassName) + result = QString("%1%2").arg(classTemplate.name(), result); + + return result; +} + +AbstractMetaTypeList Dartagnan::instantiationsForFunction(const AbstractMetaFunction *func) +{ + const AbstractMetaClass *metaClass = func->ownerClass(); + if (!metaClass || metaClass->isNamespace()) { + // TODO: We don't support function templates yet + return {}; + } + + if (!hasTemplateArguments(func)) + return {}; + + const auto templateHash = DartGenerator::instance()->templateHash(); + return templateHash.value(metaClass); +} + +bool Dartagnan::returnsTemplateArgument(const AbstractMetaFunction *func) +{ + return func && hasType(func->type()) + && func->type().typeUsagePattern() == AbstractMetaType::TemplateArgument; +} + +bool Dartagnan::receivesTemplateArgument(const AbstractMetaFunction *func) +{ + if (!func) + return false; + + const auto args = func->arguments(); + return std::any_of(args.cbegin(), args.cend(), [](AbstractMetaArgument arg) { + return arg.type().typeUsagePattern() == AbstractMetaType::TemplateArgument; + }); +} + +bool Dartagnan::hasTemplateArguments(const AbstractMetaFunction *func) +{ + return returnsTemplateArgument(func) || receivesTemplateArgument(func); +} + +bool Dartagnan::typeIsRef(AbstractMetaType type) +{ + return hasType(type) && isReference(type); +} + +bool Dartagnan::typeIsValue(AbstractMetaType type) +{ + return hasType(type) && type.isValue() && !isReference(type); +} + +AbstractMetaType Dartagnan::actualType(AbstractMetaType type, + AbstractMetaType templateInstantiation) +{ + if (!hasType(templateInstantiation)) + return type; + + AbstractMetaType actualType = type; + if (hasType(actualType) + && actualType.typeUsagePattern() == AbstractMetaType::TemplateArgument) { + actualType = Dartagnan::instantiationForTemplateArgument(templateInstantiation, actualType); + Q_ASSERT(hasType(actualType)); + } + + return actualType; +} + +EnumRegistry &EnumRegistry::instance() +{ + static EnumRegistry s_enumRegistry; + return s_enumRegistry; +} + +void EnumRegistry::registerEnum(AbstractMetaEnum metaEnum, const AbstractMetaClass *context) +{ + // Maps c++ to dart enumerator names, for example: + // "Qt::HighEventPriority" -> "Qt_EventPriority.HighEventPriority" + + const auto enumerators = metaEnum.values(); + for (auto enumerator : enumerators) { + const QString dartName = ToDartConversions::enumeratorName(metaEnum, &enumerator); + + auto cppName = [context, &enumerator, &metaEnum](bool extraQualify) { + QString cppName; + + if (extraQualify) + cppName = QString("%1::%2").arg(metaEnum.name(), enumerator.name()); + else + cppName = enumerator.name(); + + // Append namespace or owner class + if (context) + cppName = QString("%1::%2").arg(context->qualifiedCppName(), cppName); + + + return cppName; + }; + + /// If we have func(Enum = Foo) shiboken gives us Enum::Foo as the default argument + /// even if it's not an enum class, so register both variants: + m_enumNameMapping.insert(cppName(true), dartName); + m_enumNameMapping.insert(cppName(false), dartName); + } +} + +QString EnumRegistry::dartNameForCppEnumerator(const QString &cppEnumerator, + const AbstractMetaClass *context) +{ + auto it = m_enumNameMapping.constFind(cppEnumerator); + if (it != m_enumNameMapping.cend()) + return *it; + + // Let's see if the context can help + if (context) { + // A function can have default argument enumerator which is not fully qualified + // Example + // void func(int e = MyEnumerator0). + // MyEnumerator0 might belong to a class, so we need to prefix the class name + + QString result = dartNameForCppEnumerator( + QString("%1::%2").arg(context->qualifiedCppName(), cppEnumerator), nullptr); + + if (!result.isEmpty()) + return result; + + // Try with the base class as context: + for (auto base : context->baseClasses()) { + result = dartNameForCppEnumerator(cppEnumerator, base); + if (!result.isEmpty()) + return result; + } + + // Let's tackle another case: It's only smi-qualified, for example + // MyClass::MyEnumerator , missing namespace. Here we don't want to prefix the class + // qualified name otherwise we would get Namespace::MyClass::MyClass::MyEnumerator + // So first get the enumerator without any class prefix + const QStringList splitted = cppEnumerator.split("::"); + if (splitted.size() >= 2) { + return dartNameForCppEnumerator( + QString("%1::%2").arg(context->qualifiedCppName(), splitted.last()), nullptr); + } + } + + return QString(); +} + +bool Dartagnan::usesReadabilityTags() +{ + static const bool uses = qEnvironmentVariableIsSet("DARTAGNAN_READABILITY_TAGS"); + return uses; +} + +bool Dartagnan::generatesQDebugStatements() +{ + return qEnvironmentVariableIsSet("DARTAGNAN_GENERATES_QDEBUGS"); +} + +int Dartagnan::numBaseClasses_recursive(const AbstractMetaClass *metaClass) +{ + const auto bases = metaClass->baseClasses(); + int numBases = bases.size(); + for (auto base : metaClass->baseClasses()) { + numBases += numBaseClasses_recursive(base); + } + + return numBases; +} + +bool Dartagnan::firstBaseClassIsPolymorphic(const AbstractMetaClass *metaClass) +{ + auto bases = metaClass->baseClasses(); + return !bases.isEmpty() && bases.first()->isPolymorphic(); +} + +bool Dartagnan::classIsFirstBaseInHierarchy(const AbstractMetaClass *derived, + const AbstractMetaClass *targetBase) +{ + if (derived == targetBase) + return true; + + const auto bases = derived->baseClasses(); + return !bases.isEmpty() && classIsFirstBaseInHierarchy(bases.first(), targetBase); + + return false; +} + +int Dartagnan::overloadNumberInOwnerClass(const AbstractMetaFunction *func) +{ + const AbstractMetaClass *metaClass = func->ownerClass(); + if (!metaClass) + return 0; + + int index = 0; + + for (auto f : metaClass->functions()) { + if (f.get() == func) + break; + + if (f->name() == func->name()) + index++; + } + + return index; +} + +static bool classInheritsFrom(const AbstractMetaClass *child, const AbstractMetaClass *maybeParent) +{ + const auto bases = child->baseClasses(); + if (bases.contains(maybeParent)) + return true; + + for (auto base : bases) { + if (classInheritsFrom(base, maybeParent)) + return true; + } + + return false; +} + +void Dartagnan::sortTemplatesByHierarchy(QList &classes) +{ + std::sort(classes.begin(), classes.end(), + [](const AbstractMetaType &a, const AbstractMetaType &b) { + auto instantitionsA = a.instantiations(); + auto instantitionsB = b.instantiations(); + + if (instantitionsA.size() > instantitionsB.size()) { + return true; + } else if (instantitionsA.size() < instantitionsB.size()) { + return false; + } else if (instantitionsA.isEmpty()) { + return a.cppSignature().compare(b.cppSignature()) < 0; + } else if (instantitionsA.size() != 1) { + // Maybe we can improve this case + return a.cppSignature().compare(b.cppSignature()) < 0; + } else { + const AbstractMetaClass *classA = classForType(instantitionsA.first()); + const AbstractMetaClass *classB = classForType(instantitionsB.first()); + + if (classA && !classB) { + return true; + } else if (!classA && classB) { + return false; + } else if (!classA && !classB) { + return a.cppSignature().compare(b.cppSignature()) < 0; + } else { + if (classInheritsFrom(classA, classB)) { + return true; + } else if (classInheritsFrom(classB, classA)) { + return false; + } else { + return a.cppSignature().compare(b.cppSignature()) < 0; + } + } + } + }); +} + +bool Dartagnan::hasType(AbstractMetaType t) +{ + return t.typeEntry() != nullptr && !t.isVoid(); +} + +bool Dartagnan::returnsValue(const AbstractMetaFunction &f) +{ + return hasType(f.type()) && f.type().isValue() && !Dartagnan::returnsByRef(f); +} + +bool Dartagnan::returnsByRef(const AbstractMetaFunction &f) +{ + return hasType(f.type()) && isReference(f.type()); +} + +bool Dartagnan::returnsPrimitive(const AbstractMetaFunction &f) +{ + return hasType(f.type()) && f.type().isPrimitive(); +} + +bool Dartagnan::returnsConst(const AbstractMetaFunction &f) +{ + return hasType(f.type()) && f.type().isConstant(); +} + +bool Dartagnan::isMoveConstructor(const AbstractMetaFunction &f) +{ + return f.functionType() == AbstractMetaFunction::MoveConstructorFunction; +} + +bool Dartagnan::isCopyOrMoveConstructor(const AbstractMetaFunction &f) +{ + return f.isCopyConstructor() || isMoveConstructor(f); +} + +bool Dartagnan::isReference(AbstractMetaType t) +{ + return t.cppSignature().contains(QLatin1String("&")); +} + +bool Dartagnan::isNonConstReference(AbstractMetaType t) +{ + return !t.isConstant() && isReference(t); +} + +bool Dartagnan::isBool(AbstractMetaType t) +{ + return t.name() == QLatin1String("bool"); +} + +DartOverloadRegistry &DartOverloadRegistry::instance() +{ + static DartOverloadRegistry s_instance; + return s_instance; +} + +QString DartOverloadRegistry::nameForMethod(const AbstractMetaFunction *func) const +{ + if (func->functionType() == AbstractMetaFunction::GetAttroFunction + || func->functionType() == AbstractMetaFunction::SetAttroFunction) { + return func->name(); + } + + if (!func->declaringClass()) + return func->name(); + + // Simple name is for example: "QWidget.resize" + // or even "MyScope.QWidget.resize" if using scopes + const QString scopedClassName = ToDartConversions::scopedNameForType(func->declaringClass()); + const QString simpleName = scopedClassName + "." + func->name(); + + // Complete name is for example: "QWidget.resize(int,int)" + const QString completeName = func->declaringClass()->name() + "." + func->minimalSignature(); + + + QHash &overloads = m_methodsOverloads[simpleName]; + if (overloads.contains(completeName)) { + + return overloads.value(completeName); + } + + auto newNameGenerator = [func](int index) { + if (func->isConstructor()) { + return QString("%1.ctor%2").arg(func->name()).arg(index); + } else { + return QString("%1_%2").arg(func->name()).arg(index); + } + }; + + if (overloads.isEmpty()) { + // The first overload gets to keep its natural name + const int index = overloadNumberInOwnerClass(func); + QString name = func->name(); + + if (index > 0 && !func->isConstructor() && func->implementingClass()->baseClass()) { + // Fixes the following case (for example): + // BaseClass with: foo(int) + // DerivedClass with: foo(int) and foo(int,int) + // foo(int) would be hashed as BaseClass.foo + // and foo(int,int) would be hashed as DerivedClass.foo, getting index 0 too. + // DerivedClass would then have two methods with the same name in dart, which is + // illegal + name = newNameGenerator(index); + } + overloads.insert(completeName, name); + } else { + int index = overloads.size() + 1; + while (true) { + const QString newName = newNameGenerator(index); + const bool containsValue = overloads.constFind(newName) != overloads.constEnd(); + if (!containsValue) { + overloads.insert(completeName, newName); + break; + } + + ++index; + } + } + + return overloads.value(completeName); +} + +bool Dartagnan::hasPureVirtualMethods(const DartagnanOptions &opts, + const AbstractMetaClass *metaClass) +{ + if (metaClass->isAbstract()) + return true; + + return opts.pureVirtualClassOverrides.contains(metaClass->qualifiedCppName()); +} diff --git a/src/dartagnan.h b/src/dartagnan.h new file mode 100644 index 0000000..4efc0b2 --- /dev/null +++ b/src/dartagnan.h @@ -0,0 +1,261 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#pragma once + +#ifdef QT_NO_CAST_FROM_ASCII +#undef QT_NO_CAST_FROM_ASCII +#endif + +#include "abstractmetafunction.h" +#include "abstractmetalang.h" +#include "apiextractorresult.h" +#include "modifications.h" +#include "parser/enumvalue.h" +#include "textstream.h" +#include "typesystem.h" + +#include + +#define ADD_READBILITY_TAG(X) \ + if (Dartagnan::usesReadabilityTags()) \ + s << "\n//tag=" << X << "\n"; + +struct DartagnanOptions; + +namespace Dartagnan { + +enum class SpecialFunctionId { + Invalid = -1, + Destructor = -2, + Finalizer = -3 +}; + +enum RejectedMethod { + RejectedMethod_Deprecated = 1, + RejectedMethod_CopyCtor = 2, + RejectedMethod_MoveCtor = 4, + RejectedMethod_PureVirtual = 8, + RejectedMethod_AbstractClassCtor = 16, + RejectedMethod_Private = 32, + RejectedMethod_ReturningTemplate = 64, // TODO: Remove once supported + RejectedMethod_ReceivingTemplate = 128, + RejectedMethod_ReturningTemplateArgument = 256, + RejectedMethod_VirtualFunctionExistingInBaseClass = 512, + RejectedMethod_UnsupportedDartType = 1024, + RejectedMethod_ExplicitlyBlacklistedAbstractClassCtor = 2048, + RejectedMethod_Default = RejectedMethod_Deprecated | RejectedMethod_CopyCtor + | RejectedMethod_MoveCtor | RejectedMethod_Private + | RejectedMethod_ExplicitlyBlacklistedAbstractClassCtor +}; + +enum GeneratedCodeType { + GeneratedCodeType_Unknown = 0, + GeneratedCodeType_FFI_C_header = 1, + GeneratedCodeType_FFI_C_impl = 2, + GeneratedCodeType_Cppwrapper_header = 4, + GeneratedCodeType_Cppwrapper_impl = 8, + GeneratedCodeType_Dart = 16, + GeneratedCodeType_CppwrapperVirtualCallback = 32 | GeneratedCodeType_Cppwrapper_impl, + GeneratedCodeType_FFI_C = GeneratedCodeType_FFI_C_header | GeneratedCodeType_FFI_C_impl, + GeneratedCodeType_Cppwrapper = + GeneratedCodeType_Cppwrapper_impl | GeneratedCodeType_Cppwrapper_header +}; + + +enum class FunctionFormatOption { + Default = 0, + TemplateArgs = 1, // Like "" + TemplateParams = 2, // An instantiatiation like "" + DefaultArgumentExpr = 4, // Includes the default argument expr, for example: "= 4" + ImplicitThisAs1stParams = 8, // Adds "void*" as the first method parameter + ExportMacro = 16, + StringInsteadOfQString = 32, + ForSignalHandler = 64, /// Uses the name of the signal handler instead of method's name. "foo" + /// -> "onFoo". + QualifiedWithScope = 128 /// Prepends with "." +}; +Q_DECLARE_FLAGS(FunctionFormatOptions, FunctionFormatOption) + +enum class TemplateFormatOption { + None = 0, + IncludeBraces = 1, + IncludeClassName = 2 | IncludeBraces +}; +Q_DECLARE_FLAGS(TemplateFormatOptions, TemplateFormatOption) + +using RejectedMethods = int; + +/// @brief Returns whether the type is "const char *" +bool typeIsConstCharPtr(AbstractMetaType); + +/// @brief Returns if the type is a valid and non-void type +bool hasType(AbstractMetaType); + +bool returnsValue(const AbstractMetaFunction &); +bool returnsByRef(const AbstractMetaFunction &); +bool returnsPrimitive(const AbstractMetaFunction &); +bool returnsConst(const AbstractMetaFunction &); +bool isMoveConstructor(const AbstractMetaFunction &); +bool isCopyOrMoveConstructor(const AbstractMetaFunction &); +bool isReference(AbstractMetaType); +bool isNonConstReference(AbstractMetaType); +bool isBool(AbstractMetaType); + +bool usesReadabilityTags(); + +/** + * @brief Returns whether we should add a binding to this function or not + */ +bool acceptsMethod(const AbstractMetaFunction *func, + RejectedMethods rejectedMethods = RejectedMethod_Default); + +/** + * Returns whether a function is removed in the typesystem xml file. + * Example: + */ +bool functionIsRemoved(const AbstractMetaFunction *method); + +/// @brief Returns the filename for the exports headers +QString exportsHeaderFilename(); + +/// @brief Returns the name of the export macro +QString exportMacroName(); + +/// @brief Returns the first base class in the hierarchy, the root +QString baseMostBaseClass(const AbstractMetaClass *metaClass); + +QString emptyReturnStatementFor(const AbstractMetaFunction *method); + +/// @brief value types are garbage collected +bool needsGarbageCollection(const AbstractMetaClass *metaClass); + +/// @brief Returns the number of base classes up the hierarchy +int numBaseClasses_recursive(const AbstractMetaClass *metaClass); + +class SeenFunctions +{ +public: + /** + * @brief C++ supports several methods having the same signature, only diverging on ending on + * & and &&. But we only want 1 signature. + */ + bool functionWasSeen(const AbstractMetaFunction *) const; + void markAsSeen(const AbstractMetaFunction *); + +private: + QString completeFunctionSig(const AbstractMetaFunction *) const; + QSet m_seenFunctions; +}; + +/// @brief Returns the class that represents the specified type +const AbstractMetaClass *classForType(AbstractMetaType); +const AbstractMetaClass *classForName(const QString &); + +AbstractMetaEnum enumForType(AbstractMetaType); + +void createFunctionIdCache(); + +/// Returns a unique numeric id for the specified id +int idForFunction(const AbstractMetaFunction *); + +/// Returns the base-most method this method overrides +const AbstractMetaFunction *baseMethodForFunction(const AbstractMetaFunction *); + +/// Returns the index of the template argument within the template +/// For example, if the class is MyTemplate, and templateArgument is Z, then this function +/// returns 1 + +int indexOfTemplateArg(const AbstractMetaClass *metaClass, AbstractMetaType templateArgument); +AbstractMetaType instantiationForTemplateArgument(AbstractMetaType classInstantiation, + AbstractMetaType templateArgument); + +/// @brief Receives for example and returns +/// @param classInstantiation, a template instantiation, for example MyTemplate +/// @param classTemplate, a class template, for example MyTemplate + +QVector instantiationsForTemplateArguments(AbstractMetaType classInstantiation, + AbstractMetaType classTemplate); + +/// @brief Like instantiationsForTemplateArguments but returns a QString +/// for example, "MyTemplate" +QString instantiationsTextForTemplateArguments(AbstractMetaType classInstantiation, + AbstractMetaType classTemplate, + TemplateFormatOptions = {}); + +/// @brief Returns the template instantiations for the specified function +/// Returns an empty list if the function doesn't return or receive any template arguments +AbstractMetaTypeList instantiationsForFunction(const AbstractMetaFunction *func); + +/// @brief Returns whether the specified function returns a template argument +bool returnsTemplateArgument(const AbstractMetaFunction *func); + +/// @brief Returns whether the specified function receives a template argument by argument +bool receivesTemplateArgument(const AbstractMetaFunction *func); + +/// @brief Returns whether the specified function receives a template argument by argument or +/// returns one +bool hasTemplateArguments(const AbstractMetaFunction *func); + +bool typeIsRef(AbstractMetaType type); + +bool typeIsValue(AbstractMetaType type); + +AbstractMetaType actualType(AbstractMetaType type, AbstractMetaType templateInstantiation); + +/// @brief Returns whether the env var 'DARTAGNAN_GENERATES_QDEBUGS" env is set +/// If true, then function calls in the generated code will have some qDebug() +/// This is just for debugging during development of Dartagnan itself +bool generatesQDebugStatements(); + +/// @brief Returns whether the first base class is is polymorphic +bool firstBaseClassIsPolymorphic(const AbstractMetaClass *); + +bool classIsFirstBaseInHierarchy(const AbstractMetaClass *derived, const AbstractMetaClass *base); + +/// @brief Returns the index of the overload in its owner class +/// for example, for class with two methods: foo(int) and foo(char) +/// it would return 0 for the 1st one, and 1 for the 2nd method. +/// Doesn't go up the base class. +int overloadNumberInOwnerClass(const AbstractMetaFunction *func); + +/// Sorts the list of classes putting the most derived ones first +// So QWidget before QObject, etc. +void sortTemplatesByHierarchy(QList &); + +/// Returns whether the specified class has pure virtual methods +bool hasPureVirtualMethods(const DartagnanOptions &, const AbstractMetaClass *); + +class EnumRegistry +{ +public: + static EnumRegistry &instance(); + void registerEnum(AbstractMetaEnum, const AbstractMetaClass *context); + + // Returns for example "Qt_EventPriority.HighEventPriority" for "Qt::HighEventPriority" + // Context gives a bit of help, since cppEnumerator might be only "HighEventPriority", + // so context allows us get a more qualified name + QString dartNameForCppEnumerator(const QString &cppEnumerator, + const AbstractMetaClass *context); + +private: + EnumRegistry() = default; + /// Contains C++ to Dart enumerator mapping + /// Example: "Qt::Foo" -> "Qt.FooEnum.Foo" + QHash m_enumNameMapping; +}; + +class DartOverloadRegistry +{ +public: + static DartOverloadRegistry &instance(); + + QString nameForMethod(const AbstractMetaFunction *) const; + +private: + mutable QHash> m_methodsOverloads; +}; + +} // namespace Dartagnan diff --git a/src/generator_base.cpp b/src/generator_base.cpp new file mode 100644 index 0000000..2779b00 --- /dev/null +++ b/src/generator_base.cpp @@ -0,0 +1,422 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#include "generator_base.h" +#include "apiextractor.h" +#include "printers.h" +#include "type_conversions/to_C.h" +#include "typedatabase.h" +#include "typesystem.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DartagnanOptions DartagnanGeneratorBase::m_optionsFromJson = {}; + +static bool runFormatter(const QString &formatter, const QStringList &arguments) +{ + if (QProcess::execute(formatter, arguments) != 0) { + qWarning() << Q_FUNC_INFO << "Error running" << formatter << arguments; + return false; + } + + return true; +} + +static bool runDartFormatter(const QString &filename) +{ + QString cmd = "dart"; + QStringList args = { "format", "--fix", filename }; + +#ifdef Q_OS_WIN + cmd = "cmd.exe"; + args = QStringList { "/C", "dart" } + args; +#endif + + return runFormatter(cmd, args); +} + +static QString clangFormatExecutable() +{ + const QString defaultClangFormat = "clang-format"; + return qEnvironmentVariable("DARTAGNAN_CLANG_FORMAT", defaultClangFormat); +} + +DartagnanGeneratorBase::~DartagnanGeneratorBase() +{ + for (QTextStream *ts : m_textStreams) { + delete ts->device(); + delete ts; + } + + m_textStreams.clear(); +} + +QHash> +DartagnanGeneratorBase::templateHash() const +{ + return m_templateHash; +} + +bool DartagnanGeneratorBase::finishGeneration() +{ + // Format the generated dart files + for (const QString &filename : m_generatedFileNames) { + if (!formatFile(filename)) { + qWarning() << Q_FUNC_INFO << "Error formating file" << filename; + return false; + } + } + + return true; +} + +bool DartagnanGeneratorBase::doSetup() +{ + Dartagnan::createFunctionIdCache(); + constructTemplateHash(); + + QFileInfo info(typeSystemFileName()); + const QString dartagnanConfig = QStringLiteral("%1/dartagnan.json").arg(info.absolutePath()); + + QFile file(dartagnanConfig); + if (file.exists()) { + if (!file.open(QIODevice::ReadOnly)) { + qWarning() << Q_FUNC_INFO << "Failed to open" << dartagnanConfig; + return false; + } + + auto doc = QJsonDocument::fromJson(file.readAll()); + QJsonObject obj = doc.object(); + m_optionsFromJson.targetLinkLibraries = + obj.value(QStringLiteral("target_link_libraries")).toString(); + + m_optionsFromJson.exportsHeaderName = + obj.value(QStringLiteral("exportsHeaderName")).toString(); + + m_optionsFromJson.exportsMacroName = + obj.value(QStringLiteral("exportsMacroName")).toString(); + + m_optionsFromJson.qStringToDartCode = + obj.value(QStringLiteral("QStringToDartCode")).toString(); + + m_optionsFromJson.createCMakeLists = + obj.value(QStringLiteral("createCMakeLists")).toBool(true); + + m_optionsFromJson.bindingsLibrary = + obj.value(QStringLiteral("bindingsLibrary")).toString(dartPackageName()); + + m_optionsFromJson.supportsQtSignals = + obj.value(QStringLiteral("supportsQtSignals")).toBool(true); + + for (auto value : obj.value(QStringLiteral("pureVirtualClassOverrides")).toArray()) { + m_optionsFromJson.pureVirtualClassOverrides.append(value.toString()); + } + + for (auto value : obj.value(QStringLiteral("namespaces")).toArray()) { + DartagnanOptions::Scope scope; + + scope.name = value.toObject().value("name").toString(); + if (scope.name.isEmpty()) + qFatal("Scopes in dartagnan.json need to have a name"); + + for (auto t : value.toObject().value("types").toArray()) { + scope.types.append(t.toString()); + } + + m_optionsFromJson.scopes.append(scope); + } + } + + return true; +} + +QString DartagnanGeneratorBase::absoluteFileNameForContext(const GeneratorContext &context) const +{ + const QString scope = m_optionsFromJson.scopeForType(context.metaClass()); + + if (scope.isEmpty()) + return QStringLiteral("%1/%2/%3") + .arg(outputDirectory(), packageName(), fileNameForContext(context)); + + + return QStringLiteral("%1/%2/%3/%4") + .arg(outputDirectory(), packageName(), scope, fileNameForContext(context)); +} + +QString DartagnanGeneratorBase::readSnippet(const QString &name) +{ + // TODO: Cache + + const QString filename = QStringLiteral(":/snippets/%1").arg(name); + QFile file(filename); + file.open(QIODevice::ReadOnly); + + return file.readAll(); +} + +bool DartagnanGeneratorBase::createFile(const QString &filename, const QString &contents) +{ + QFile file(filename); + if (!file.open(QIODevice::WriteOnly)) + return false; + + file.write(contents.toUtf8()); + return true; +} + +QTextStream *DartagnanGeneratorBase::streamForFileName(const QString &filename) const +{ + auto it = m_textStreams.find(filename); + if (it != m_textStreams.end()) + return *it; + + QFileInfo info(filename); + QDir dir; + dir.mkpath(info.absolutePath()); + + auto file = new QFile(filename); + if (!file->open(QIODevice::WriteOnly)) { + qWarning() << Q_FUNC_INFO << "Could not open" << filename << file->errorString(); + delete file; + return nullptr; + } + + auto ts = new QTextStream(file); + m_textStreams.insert(filename, ts); + return ts; +} + +bool DartagnanGeneratorBase::formatFile(const QString &filename) +{ + if (!qEnvironmentVariableIsSet("DARTAGNAN_RUNS_CODE_FORMAT")) { + // User didn't want dartfmt and clang-format to run + return true; + } + + if (filename.endsWith(".dart")) { + if (!runDartFormatter(filename)) + return false; + } else if (filename.endsWith(".h") || filename.endsWith(".cpp")) { + if (!runFormatter(clangFormatExecutable(), { "-i", filename })) { + + qWarning() << "Make sure clang-format is in path. Tried" << clangFormatExecutable() + << ". Set the DARTAGNAN_CLANG_FORMAT env variable if needed"; + + return false; + } + } + + return true; +} + +QString DartagnanGeneratorBase::typeSystemFileName() const +{ + return api().typeSystem(); +} + +QString DartagnanGeneratorBase::dartPackageName() const +{ + return packageName(); +} + +QString DartagnanGeneratorBase::cmakeTargetName() const +{ + // Same as the package name is fine + return dartPackageName(); +} + +QString DartagnanGeneratorBase::moduleHeaderFileName() const +{ + return QString("%1.h").arg(packageName()); +} + +void DartagnanGeneratorBase::constructTemplateHash() +{ + QHash hash; + + auto processType = [this](AbstractMetaType type) { + if (!Dartagnan::hasType(type) || type.instantiations().isEmpty() + || type.hasTemplateChildren()) + return; + const AbstractMetaClass *templateClass = Dartagnan::classForType(type); + auto &list = m_templateHash[templateClass]; + if (list.contains(type)) + return; + + // Looks like there can be different AbstractMetaType instances for the same string + // representation So check for strings already inserted, before adding to list + const QString templateArgsStr = ToCConversions::templateArgs(type); + const bool found = + std::find_if(list.cbegin(), list.cend(), + [templateArgsStr](AbstractMetaType type) { + return templateArgsStr == ToCConversions::templateArgs(type); + }) + != list.cend(); + + if (!found) + list.append(type); + }; + + for (const AbstractMetaClass *metaClass : api().classes()) { + for (auto func : metaClass->functions()) + processType(func->type()); + } + + for (auto func : api().globalFunctions()) { + processType(func->type()); + } +} + +std::unique_ptr +Dartagnan::createDestructor(const AbstractMetaClass *metaClass) +{ + auto func = new AbstractMetaFunction(); + + func->setName(metaClass->name()); + func->setOwnerClass(metaClass); + func->setFunctionType(AbstractMetaFunction::DestructorFunction); + + return std::unique_ptr(func); +} + +std::unique_ptr Dartagnan::createGetterFor(AbstractMetaField field, + GeneratedCodeType codeType) +{ + Q_UNUSED(codeType); + if (!field.type().isPrimitive()) + return {}; // TODO + + if (field.isPrivate()) + return nullptr; + + if (field.isProtected()) { + // Not supported yet. C can't access protected C++ functions. We'll need to make more + // indirections + return nullptr; + } + + auto func = new AbstractMetaFunction(); + + func->setName(field.name()); + func->setOwnerClass(field.enclosingClass()); + func->setType(field.type()); + func->setFieldName(field.name()); + func->setFunctionType(AbstractMetaFunction::GetAttroFunction); + if (field.isStatic()) + func->setAttributes(func->attributes() | AbstractMetaFunction::Static); + + return std::unique_ptr(func); +} + +std::unique_ptr Dartagnan::createSetterFor(AbstractMetaField field, + GeneratedCodeType codeType) +{ + Q_UNUSED(codeType); + if (!field.type().isPrimitive()) + return nullptr; // TODO + + if (field.type().isConstant() || field.isPrivate()) { + // We don't give write access to private and constant members + return nullptr; + } + + if (field.isProtected()) { + // Not supported yet. C can't access protected C++ functions. We'll need to make more + // indirections + return nullptr; + } + + auto func = new AbstractMetaFunction(); + + func->setName(field.name()); + func->setOwnerClass(field.enclosingClass()); + func->setFunctionType(AbstractMetaFunction::SetAttroFunction); + if (field.isStatic()) + func->setAttributes(func->attributes() | AbstractMetaFunction::Static); + + AbstractMetaArgumentList args; + AbstractMetaArgument arg; + arg.setName(QString("%1_").arg(field.name())); + arg.setType(field.type()); + + func->setArguments({ arg }); + func->setFieldName(field.name()); + + return std::unique_ptr(func); +} + +std::vector> +Dartagnan::syntheticGetters(const AbstractMetaClass *metaClass, GeneratedCodeType codeType) +{ + if (metaClass->isNamespace()) { + // Not supported yet. Feel free to comment out and see if tests still pass. + return {}; + } + + std::vector> functions; + + const AbstractMetaFieldList fields = metaClass->fields(); + for (AbstractMetaField field : fields) { + if (auto getter = Dartagnan::createGetterFor(field, codeType)) + functions.push_back(std::move(getter)); + } + + return functions; +} + +std::vector> +Dartagnan::syntheticSetters(const AbstractMetaClass *metaClass, GeneratedCodeType codeType) +{ + if (metaClass->isNamespace()) { + // Not supported yet. Feel free to comment out and see if tests still pass. + return {}; + } + + std::vector> functions; + + const AbstractMetaFieldList fields = metaClass->fields(); + for (AbstractMetaField field : fields) { + if (auto setter = Dartagnan::createSetterFor(field, codeType)) + functions.push_back(std::move(setter)); + } + + return functions; +} + +QString DartagnanOptions::scopeForType(const QString &type) const +{ + for (const auto &scope : scopes) { + if (scope.types.contains(type)) + return scope.name; + } + + return QString(); +} + +QString DartagnanOptions::scopeForType(const AbstractMetaClass *metaClass) const +{ + if (metaClass) + return scopeForType(metaClass->qualifiedCppName()); + + return {}; +} + +std::unique_ptr +DartagnanOptions::namespacePrinterForType(TextStream &s, const AbstractMetaClass *metaClass) const +{ + const QString scope = scopeForType(metaClass); + if (scope.isEmpty()) + return {}; + + return std::make_unique(s, scope); +} diff --git a/src/generator_base.h b/src/generator_base.h new file mode 100644 index 0000000..67c5f68 --- /dev/null +++ b/src/generator_base.h @@ -0,0 +1,113 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#pragma once + +#include "abstractmetafield.h" +#include "abstractmetafunction.h" +#include "abstractmetalang.h" +#include "abstractmetatype.h" + +#include "dartagnan.h" +#include "typesystem.h" + +#include + +#include +#include + +#include + +class NamespacePrinter; + +namespace Dartagnan { +std::unique_ptr createDestructor(const AbstractMetaClass *metaClass); +std::unique_ptr createGetterFor(AbstractMetaField field, + GeneratedCodeType codeType); +std::unique_ptr createSetterFor(AbstractMetaField field, + GeneratedCodeType codeType); + +std::vector> +syntheticGetters(const AbstractMetaClass *metaClass, GeneratedCodeType codeType); +std::vector> +syntheticSetters(const AbstractMetaClass *metaClass, GeneratedCodeType codeType); +} + +/// @brief Struct for loading dartagnan.json +struct DartagnanOptions +{ + struct Scope + { + // The name of this scope, for creation of the Bindings_.dart file + QString name; + + // The types that should go into this scope + QStringList types; + }; + + QString targetLinkLibraries; + + QString exportsHeaderName; + QString exportsMacroName; + + QString qStringToDartCode; + + /// Controls whether we also generate the CMakeLists.txt for building the generated bindings + bool createCMakeLists = true; + + bool supportsQtSignals = true; + + /// The name of the dll, without "lib" prefix and without so/dll suffixes. + /// If empty then dartPackageName() is used + QString bindingsLibrary; + + /// AbstractMetaClass::isAbstract() can be false if the pure-virtual methods have unknown types + /// use this to override + QStringList pureVirtualClassOverrides; + + /// List of explicit scopes + QVector scopes; + + QString scopeForType(const QString &type) const; + QString scopeForType(const AbstractMetaClass *) const; + std::unique_ptr namespacePrinterForType(TextStream &, + const AbstractMetaClass *) const; +}; + +class DartagnanGeneratorBase : public Generator +{ +public: + ~DartagnanGeneratorBase(); + + QHash> templateHash() const; + static QHash functionIds(); + + static QString readSnippet(const QString &name); + static DartagnanOptions m_optionsFromJson; + +protected: + bool doSetup() override; + bool finishGeneration() override; + QString absoluteFileNameForContext(const GeneratorContext &context) const; + + bool createFile(const QString &filename, const QString &contents); + + QTextStream *streamForFileName(const QString &filename) const; + + QString typeSystemFileName() const; + QString dartPackageName() const; + QString cmakeTargetName() const; + QString moduleHeaderFileName() const; + +protected: + QHash> m_templateHash; + Dartagnan::SeenFunctions m_seenFunctions; + QStringList m_generatedFileNames; + +private: + void constructTemplateHash(); + bool formatFile(const QString &filename); + mutable QHash m_textStreams; +}; diff --git a/src/generator_cppwrapper_header.cpp b/src/generator_cppwrapper_header.cpp new file mode 100644 index 0000000..e6af592 --- /dev/null +++ b/src/generator_cppwrapper_header.cpp @@ -0,0 +1,247 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#include "generator_cppwrapper_header.h" +#include "abstractmetalang.h" +#include "apiextractor.h" +#include "fileout.h" +#include "generator_dart.h" +#include "printers/Cpp_HeaderPrinter.h" +#include "printers/ExternC_HeaderPrinter.h" +#include "type_conversions/to_CppWrapper.h" +#include "typedatabase.h" +#include "typesystem.h" + +#include +#include +#include +#include + +#include + +using namespace Dartagnan; + +static std::unique_ptr classPrinterFor(TextStream &s, + const AbstractMetaClass *metaClass) +{ + if (metaClass->isPolymorphic()) + return std::unique_ptr(new PolymorphicClassPrinter(s, metaClass)); + + return std::unique_ptr(new NonPolymorphicClassPrinter(s, metaClass)); +} + +static IncludeList includesFor(const TypeEntry *typeEntry) +{ + IncludeList includes; + + if (auto ce = typeEntry) + includes << ce->include() << ce->extraIncludes(); + + return includes; +} + +static IncludeList includesFor(const AbstractMetaClass *metaClass) +{ + IncludeList includes = includesFor(metaClass->typeEntry()); + + const AbstractMetaTypeList templateInstantiations = + DartGenerator::instance()->templateHash().value(metaClass); + for (AbstractMetaType templateInstantiation : templateInstantiations) { + const auto templateParams = templateInstantiation.instantiations(); + for (auto templateParam : templateParams) { + if (auto metaClass = classForType(templateParam)) { + includes += includesFor(metaClass->typeEntry()); + } + } + } + + return includes; +} + +static IncludeList includesFor(const AbstractMetaFunction *func) +{ + return includesFor(func->typeEntry()); +} + +static QString includeStatement(Include inc) +{ + if (inc.type() == Include::LocalPath) { + return QStringLiteral("#include \"%1\"").arg(inc.name()); + } else { + return QStringLiteral("#include <%1>").arg(inc.name()); + } +} + +template +static QStringList includesStrListFor(const T *meta) +{ + QStringList includeList; + const IncludeList includes = includesFor(meta); + for (const Include &include : includes) { + if (include.isValid() && !includeList.contains(includeStatement(include))) + includeList << includeStatement(include); + } + + return includeList; +} + +static QStringList includesStrListFor(const IncludeList &includes) +{ + QStringList includeList; + for (const Include &include : includes) { + if (include.isValid() && !includeList.contains(includeStatement(include))) + includeList << includeStatement(include); + } + + return includeList; +} + +template +static QString includesStrFor(const T *meta) +{ + return includesStrListFor(meta).join('\n'); +} + +static QString includesStrFor(const AbstractMetaFunctionCList &funcs) +{ + IncludeList includes; + for (auto func : funcs) { + includes << includesFor(func.get()); + } + + return includesStrListFor(includes).join("\n"); +} + +DartFFIHeaderGenerator::DartFFIHeaderGenerator() +{ +} + +DartFFIHeaderGenerator::~DartFFIHeaderGenerator() +{ +} + +QString DartFFIHeaderGenerator::fileNameSuffix() const +{ + return QStringLiteral("my-suffix"); +} + +QString DartFFIHeaderGenerator::fileNameForContext(const GeneratorContext &context) const +{ + const QString scope = m_optionsFromJson.scopeForType(context.metaClass()); + if (scope.isEmpty()) + return QStringLiteral("dart/ffi/%1_c.h").arg(context.metaClass()->name()); + + return QStringLiteral("dart/ffi/%1/%2_c.h").arg(scope, context.metaClass()->name()); +} + +QString DartFFIHeaderGenerator::globalCIncludeFileName() const +{ + return QStringLiteral("%1/%2/dart/ffi/c_%3.h") + .arg(outputDirectory(), dartPackageName(), TypeDatabase::instance()->defaultPackageName()); +} + +void DartFFIHeaderGenerator::generateClass(TextStream &s, const GeneratorContext &classContext) +{ + s << licenseComment(); + generateClass_(s, classContext); + generateClass_(*m_globalCIncludesStream, classContext, true); +} + +void DartFFIHeaderGenerator::generateClass_(TextStream &s, const GeneratorContext &classContext, + bool pureCOnly) +{ + m_generatedFileNames << absoluteFileNameForContext(classContext); + // s << "#pragma once\n\n"; + + const AbstractMetaClass *metaClass = classContext.metaClass(); + + if (!pureCOnly) { + ADD_READBILITY_TAG(1040) + s << QStringLiteral("#include \"%1\"\n").arg(Dartagnan::exportsHeaderFilename()); + s << includesStrFor(metaClass); + s << "\n\n"; + } + + if (metaClass->isNamespace()) { + // Write the C wrappers for the namespace-level functions + ExternCHeaderPrinter externPrinter(s, metaClass, {}, pureCOnly); + } else { + if (!pureCOnly) + generateClass(s, metaClass); + + if (metaClass->templateArguments().isEmpty()) { + ExternCHeaderPrinter externPrinter(s, metaClass, {}, pureCOnly); + } else { + const AbstractMetaTypeList instantiations = m_templateHash.value(metaClass); + for (AbstractMetaType instantiation : instantiations) { + ExternCHeaderPrinter externPrinter(s, metaClass, instantiation, pureCOnly); + } + } + } +} + +void DartFFIHeaderGenerator::generateClass(TextStream &s, const AbstractMetaClass *metaClass) +{ + // TODO: More namespaces + NamespacePrinter nsPrinter(s, ToCppWrapperConversions::wrappersNamespace()); + + // Add a namespace for the scope as well: + auto scopeNSPrinter = m_optionsFromJson.namespacePrinterForType(s, metaClass); + + auto classPrinter = classPrinterFor(s, metaClass); + classPrinter->printMethods(); + classPrinter->printMembers(); + classPrinter->printVirtualCallbacks(); + + s << "\n\n"; +} + +bool DartFFIHeaderGenerator::doSetup() +{ + auto file = new QFile(globalCIncludeFileName(), qApp); + file->open(QFile::WriteOnly); + m_globalCIncludesStream = new TextStream(file); + *m_globalCIncludesStream << licenseComment(); + *m_globalCIncludesStream << "#include \n" + << "\n"; + + return DartagnanGeneratorBase::doSetup(); +} + +bool DartFFIHeaderGenerator::finishGeneration() +{ + const auto funcs = api().globalFunctions(); + if (!funcs.isEmpty()) { + FileOut file(moduleFileNameAbsolutePath()); + QFileInfo info(moduleFileNameAbsolutePath()); + m_generatedFileNames << info.absoluteFilePath(); + + file.stream << QStringLiteral("#include \"%1\"\n").arg(Dartagnan::exportsHeaderFilename()); + file.stream << includesStrFor(funcs); + file.stream << "\n\n"; + + file.stream << "extern \"C\" {\n"; + + for (auto func : funcs) { + file.stream << ToCConversions::functionSignature(func.get(), + FunctionFormatOption::ExportMacro) + << ";\n"; + } + + file.stream << "}\n"; + file.done(); + } + + if (!DartagnanGeneratorBase::finishGeneration()) + return false; + + return true; +} + +QString DartFFIHeaderGenerator::moduleFileNameAbsolutePath() const +{ + return QStringLiteral("%1/%2/dart/ffi/%3") + .arg(outputDirectory(), dartPackageName(), moduleHeaderFileName()); +} diff --git a/src/generator_cppwrapper_header.h b/src/generator_cppwrapper_header.h new file mode 100644 index 0000000..a288b9a --- /dev/null +++ b/src/generator_cppwrapper_header.h @@ -0,0 +1,41 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#include "generator_base.h" +#include + +#include + +class DartFFIHeaderGenerator : public DartagnanGeneratorBase +{ +public: + DartFFIHeaderGenerator(); + ~DartFFIHeaderGenerator(); + OptionDescriptions options() const override + { + return OptionDescriptions(); + } + const char *name() const override + { + return "Dart FFI .h Generator"; + } + +protected: + QString fileNameSuffix() const override; + QString fileNameForContext(const GeneratorContext &context) const override; + void generateClass(TextStream &s, const GeneratorContext &classContext) override; + bool doSetup() override; + bool finishGeneration() override; + +private: + /// @brief Returns the file name of the include that declares the whole C API. + QString globalCIncludeFileName() const; + + void generateClass_(TextStream &s, const GeneratorContext &classContext, + bool pureCOnly = false); + void generateClass(TextStream &s, const AbstractMetaClass *); + QString moduleFileNameAbsolutePath() const; + TextStream *m_globalCIncludesStream = nullptr; +}; diff --git a/src/generator_cppwrapper_impl.cpp b/src/generator_cppwrapper_impl.cpp new file mode 100644 index 0000000..107235d --- /dev/null +++ b/src/generator_cppwrapper_impl.cpp @@ -0,0 +1,217 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#include "generator_cppwrapper_impl.h" +#include "abstractmetalang.h" +#include "fileout.h" +#include "printers.h" +#include "printers/ExternC_ImplPrinter.h" +#include "type_conversions/to_CppWrapper.h" +#include "typedatabase.h" +#include "typesystem.h" + +#include +#include +#include +#include + +using namespace Dartagnan; + +DartFFICPPGenerator::DartFFICPPGenerator() + : m_valueWrapperContents(readSnippet("ValueWrapper.h")) +{ +} + +QString DartFFICPPGenerator::fileNameSuffix() const +{ + return {}; +} + +QString DartFFICPPGenerator::fileNameForContext(const GeneratorContext &context) const +{ + const QString scope = m_optionsFromJson.scopeForType(context.metaClass()); + if (scope.isEmpty()) + return QStringLiteral("dart/ffi/%1_c.cpp").arg(context.metaClass()->name()); + + return QStringLiteral("dart/ffi/%1/%2_c.cpp").arg(scope, context.metaClass()->name()); +} + +void DartFFICPPGenerator::generateClass(TextStream &s, const GeneratorContext &classContext) +{ + s << licenseComment(); + + QString filename = absoluteFileNameForContext(classContext); + + m_generatedFileNames << filename; + auto metaClass = classContext.metaClass(); + s << QStringLiteral("#include \"%1_c.h\"\n\n").arg(metaClass->name()); + + s << QStringLiteral("\n#include \n"); + s << QStringLiteral("\n#include \n"); + s << "\n"; + + s << m_valueWrapperContents; + if (metaClass->isNamespace()) { + ExternCImplPrinter externCPrinter(s, metaClass); + } else { + generateClass(s, metaClass); + } +} + +void DartFFICPPGenerator::generateClass(TextStream &s, const AbstractMetaClass *metaClass) +{ + { + const auto methods = metaClass->functions(); + NamespacePrinter nsPrinter(s, QStringLiteral("%1_wrappersNS").arg(packageName())); + + // Add a namespace for the scope as well: + auto scopeNSPrinter = m_optionsFromJson.namespacePrinterForType(s, metaClass); + + bool seenDtor = false; + for (auto m : methods) { + auto method = m.get(); + if (m_seenFunctions.functionWasSeen(method)) + continue; + + m_seenFunctions.markAsSeen(method); + + if (Dartagnan::functionIsRemoved(method)) + continue; + + auto methodPrinter = createMethodPrinter(s, method); + if (method->isDestructor()) + seenDtor = true; + } + + if (!seenDtor) { + auto dtor = Dartagnan::createDestructor(metaClass); + DtorImplPrinter dtorPrinter(s, dtor.get()); + } + + s << "\n"; + } + + ADD_READBILITY_TAG(1013); + s << ToCppWrapperConversions::templateString(metaClass); + s << QString("static %1* fromPtr(void *ptr)\n") + .arg(ToCppWrapperConversions::qualifiedClassName(metaClass, + FunctionFormatOption::TemplateArgs)); + s << "{"; + s << QString("return reinterpret_cast<%1*>(ptr);") + .arg(ToCppWrapperConversions::qualifiedClassName(metaClass, + FunctionFormatOption::TemplateArgs)); + s << "}"; + const QString wrapperClassName = + ToCppWrapperConversions::wrapperClassName(metaClass, FunctionFormatOption::TemplateArgs); + ADD_READBILITY_TAG(1014); + s << ToCppWrapperConversions::templateString(metaClass); + s << QString("static %1* fromWrapperPtr(void *ptr)\n").arg(wrapperClassName); + s << "{"; + s << QString("return reinterpret_cast<%1*>(ptr);").arg(wrapperClassName); + s << "}"; + + if (metaClass->templateArguments().isEmpty()) { + ExternCImplPrinter externCPrinter(s, metaClass); + } else { + const AbstractMetaTypeList instantiations = m_templateHash.value(metaClass); + for (AbstractMetaType instantiation : instantiations) { + ExternCImplPrinter externCPrinter(s, metaClass, instantiation); + } + } +} + +QString DartFFICPPGenerator::moduleFileName() const +{ + return QString("%1.cpp").arg(packageName()); +} + +QString DartFFICPPGenerator::moduleFileNameAbsolutePath() const +{ + return QStringLiteral("%1/%2/dart/ffi/%3") + .arg(outputDirectory(), dartPackageName(), moduleFileName()); +} + +bool DartFFICPPGenerator::finishGeneration() +{ + const auto enums = api().globalEnums(); + const auto funcs = api().globalFunctions(); + if (!enums.isEmpty() || !funcs.isEmpty()) { + FileOut file(moduleFileNameAbsolutePath()); + QFileInfo info(moduleFileNameAbsolutePath()); + m_generatedFileNames << info.absoluteFilePath(); + file.stream << licenseComment(); + file.stream << QStringLiteral("#include \"%1\"\n\n").arg(moduleHeaderFileName()); + + for (auto func : funcs) { + ExternCMethodImplPrinter printer(file.stream, func.get(), {}); + } + + file.done(); + } + + if (!DartagnanGeneratorBase::finishGeneration()) + return false; + + if (m_optionsFromJson.createCMakeLists) + return createCMakeFile(); + + return true; +} + +bool DartFFICPPGenerator::doSetup() +{ + return DartagnanGeneratorBase::doSetup(); +} + +bool DartFFICPPGenerator::createCMakeFile() +{ + const QString filename = + QStringLiteral("%1/%2/CMakeLists.txt").arg(outputDirectory(), dartPackageName()); + QFile file(filename); + if (!file.open(QIODevice::WriteOnly)) { + qWarning() << Q_FUNC_INFO << "Failed to open" << filename << file.errorString(); + return false; + } + + TextStream s(&file); + s << "cmake_minimum_required(VERSION 3.10)\n\n"; + s << QStringLiteral("project(%1 LANGUAGES CXX)\n\n").arg(cmakeTargetName()); + + s << "set(SOURCES\n"; + + for (const QString &filename : m_generatedFileNames) { + QFileInfo info(filename); + + if (info.dir().dirName() == QLatin1String("ffi")) + s << QStringLiteral(" dart/ffi/%1\n").arg(info.fileName()); + else // it's scoped + s << QStringLiteral(" dart/ffi/%1/%2\n").arg(info.dir().dirName(), info.fileName()); + } + s << ")\n\n"; + + s << "set(CMAKE_CXX_VISIBILITY_PRESET hidden)\n\n"; + + s << "find_package(Qt6Widgets)\n\n"; + s << QStringLiteral("add_library(%1 SHARED ${SOURCES})\n\n").arg(cmakeTargetName()); + + s << "include(GenerateExportHeader)\n"; + s << QString("generate_export_header(%1 EXPORT_FILE_NAME " + "\"${CMAKE_CURRENT_BINARY_DIR}/%2\" EXPORT_MACRO_NAME %3)\n") + .arg(cmakeTargetName(), Dartagnan::exportsHeaderFilename(), + Dartagnan::exportMacroName()); + + s << QStringLiteral("set_property(TARGET %1 PROPERTY CXX_STANDARD 14)\n\n") + .arg(cmakeTargetName()); + + s << QStringLiteral("target_link_libraries(%1 %2 Qt6::Core Qt6::Widgets)\n") + .arg(cmakeTargetName(), m_optionsFromJson.targetLinkLibraries); + s << QStringLiteral("target_include_directories(%1 PUBLIC " + "$ " + "$\n" + "$)\n\n") + .arg(cmakeTargetName()); + + return true; +} diff --git a/src/generator_cppwrapper_impl.h b/src/generator_cppwrapper_impl.h new file mode 100644 index 0000000..2e289b9 --- /dev/null +++ b/src/generator_cppwrapper_impl.h @@ -0,0 +1,36 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#include "generator_base.h" + +class DartFFICPPGenerator : public DartagnanGeneratorBase +{ +public: + DartFFICPPGenerator(); + OptionDescriptions options() const override + { + return OptionDescriptions(); + } + const char *name() const override + { + return "Dart FFI .cpp Generator"; + } + +protected: + QString fileNameSuffix() const override; + QString fileNameForContext(const GeneratorContext &context) const override; + void generateClass(TextStream &s, const GeneratorContext &classContext) override; + + bool doSetup() override; + + bool finishGeneration() override; + +private: + void generateClass(TextStream &s, const AbstractMetaClass *metaClass); + bool createCMakeFile(); + QString moduleFileName() const; + QString moduleFileNameAbsolutePath() const; + const QString m_valueWrapperContents; +}; diff --git a/src/generator_dart.cpp b/src/generator_dart.cpp new file mode 100644 index 0000000..9f3c7b5 --- /dev/null +++ b/src/generator_dart.cpp @@ -0,0 +1,294 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#include "generator_dart.h" +#include "abstractmetalang.h" +#include "dart_ffi_typedefs.h" +#include "dartagnan.h" +#include "fileout.h" +#include "printers.h" +#include "printers/Dart_printer.h" +#include "to_dart.h" + +#include +#include +#include + +using namespace Dartagnan; + +static DartGenerator *s_dartGeneratorInstance = nullptr; + +DartGenerator::DartGenerator() +{ + s_dartGeneratorInstance = this; +} + +DartGenerator::~DartGenerator() +{ +} + +DartGenerator *DartGenerator::instance() +{ + return s_dartGeneratorInstance; +} + +QString DartGenerator::fileNameSuffix() const +{ + return QStringLiteral("my-suffix"); +} + +QString DartGenerator::fileNameForContext(const GeneratorContext &context) const +{ + const QString scope = m_optionsFromJson.scopeForType(context.metaClass()); + + if (scope.isEmpty()) + return QStringLiteral("dart/lib/src/%1.dart").arg(context.metaClass()->name()); + + return QStringLiteral("dart/lib/src/%1/%2.dart").arg(scope, context.metaClass()->name()); +} + +QString DartGenerator::dartExportsForGlobalScope() const +{ + QStringList result; + + const auto enums = api().globalEnums(); + for (auto metaEnum : enums) { + if (!metaEnum.isAnonymous()) + result << ToDartConversions::enumName(metaEnum); + } + + const auto funcs = api().globalFunctions(); + for (auto func : funcs) { + result << func->name(); + } + + return result.join(","); +} + +QString DartGenerator::dartExportsFor(const AbstractMetaClass *metaClass) +{ + if (!metaClass) + return dartExportsForGlobalScope(); + + QStringList result; + if (metaClass->isNamespace()) { + for (auto func : metaClass->functions()) { + if (Dartagnan::acceptsMethod(func.get())) + result << func->name(); + } + } else { + result << metaClass->name(); + } + + for (auto metaEnum : metaClass->enums()) { + if (!metaEnum.isAnonymous()) + result << ToDartConversions::enumName(metaEnum); + } + + return result.join(","); +} + +void DartGenerator::writeImports(TextStream &s, const AbstractMetaClass *metaClass) +{ + const QString scope = m_optionsFromJson.scopeForType(metaClass); + const QString relative = scope.isEmpty() ? QString() : "../"; + + ADD_READBILITY_TAG(1052) + s << "import 'dart:ffi' as ffi;"; + s << "import 'package:ffi/ffi.dart';"; + s << QStringLiteral("import '%1TypeHelpers.dart';").arg(relative); + + s << QStringLiteral("import '%1../Bindings.dart';").arg(relative); + for (const auto &scope : m_optionsFromJson.scopes) + s << QStringLiteral("import '%1../Bindings_%2.dart' as %3;") + .arg(relative, scope.name, scope.name); + + s << QStringLiteral("import '%1../LibraryLoader.dart';").arg(relative); + + ADD_READBILITY_TAG(1051) + s << "var _dylib = Library.instance().dylib;"; + + if (metaClass && !metaClass->isNamespace() && !metaClass->baseClass()) { + // Print the _finalizer variable + const QHash templateHash = + DartGenerator::instance()->templateHash(); + + s << QString("final _finalizerFunc = (String name) {return " + "_dylib.lookup>" + "(name);};\n\n"); + + s << "Map _finalizers = {};\n\n"; + } +} + +void DartGenerator::generateClass(TextStream &s, const GeneratorContext &classContext) +{ + s << licenseComment(); + + auto metaClass = classContext.metaClass(); + + writeImports(s, metaClass); + + m_generatedFileNames << absoluteFileNameForContext(classContext); + + if (metaClass->isNamespace()) { + // print namespace-level functions and enums + DartNamespacePrinter printer(s, metaClass); + } else { + DartClassPrinter printer(s, metaClass); + } + + QFileInfo info(fileNameForContext(classContext)); + const QString exports = dartExportsFor(metaClass); + if (!exports.isEmpty()) { + const QString scope = m_optionsFromJson.scopeForType(metaClass); + + QString contents = m_exportsFileContentsByNamespace.value(scope); + const QString filename = + scope.isEmpty() ? info.fileName() : QStringLiteral("%1/%2").arg(scope, info.fileName()); + contents = QStringLiteral("export 'src/%1' show %2;\n").arg(filename, exports) + contents; + m_exportsFileContentsByNamespace[scope] = contents; + } +} + +bool DartGenerator::finishGeneration() +{ + if (!createPubSpecFile()) + return false; + + const auto globalEnums = this->api().globalEnums(); + const auto globalFuncs = api().globalFunctions(); + if (!globalEnums.isEmpty() || !globalFuncs.isEmpty()) { + FileOut file(dartModuleFileName()); + QFileInfo info(dartModuleFileName()); + m_generatedFileNames << info.absoluteFilePath(); + + writeImports(file.stream); + + const QString enumExport = QStringLiteral("export 'src/%1' show %2;\n") + .arg(info.fileName(), dartExportsForGlobalScope()); + m_exportsFileContentsByNamespace[QString()] = + enumExport + m_exportsFileContentsByNamespace[QString()]; + + for (AbstractMetaEnum e : globalEnums) { + DartEnumPrinter printer(file.stream, e, /*context=*/nullptr); + } + + for (auto func : globalFuncs) { + DartMethodPrinter printer(file.stream, func.get()); + } + + file.done(); + } + + if (!createBindingsFiles()) + return false; + + if (!createLibraryLoaderFile()) + return false; + + if (!createTypeHelpersFile()) + return false; + + if (!DartagnanGeneratorBase::finishGeneration()) + return false; + + return true; +} + +QString DartGenerator::dartModuleFileName() const +{ + return QStringLiteral("%1/%2/dart/lib/src/%3.dart") + .arg(outputDirectory(), packageName(), dartPackageName()); +} + +QString DartGenerator::pubspecFileName() const +{ + return QStringLiteral("%1/%2/dart/pubspec.yaml").arg(outputDirectory(), packageName()); +} + +QString DartGenerator::exportsFileName(const QString &suffix) const +{ + const QString actualSuffix = suffix.isEmpty() ? QString() : QStringLiteral("_%1").arg(suffix); + + return QStringLiteral("%1/%2/dart/lib/Bindings%3.dart") + .arg(outputDirectory(), packageName(), actualSuffix); +} + +QString DartGenerator::libraryLoaderFileName() const +{ + return QStringLiteral("%1/%2/dart/lib/LibraryLoader.dart") + .arg(outputDirectory(), packageName()); +} + +QString DartGenerator::typeHelpersFileName() const +{ + return QStringLiteral("%1/%2/dart/lib/src/TypeHelpers.dart") + .arg(outputDirectory(), packageName()); +} + +bool DartGenerator::createPubSpecFile() +{ + QString pubSpecContents = readSnippet("pubspec.yaml"); + if (pubSpecContents.isEmpty()) + return false; + + pubSpecContents = pubSpecContents.arg(dartPackageName(), "Bindings"); + + return createFile(pubspecFileName(), pubSpecContents); +} + +bool DartGenerator::createBindingsFiles() +{ + if (!createBindingsFile()) + return false; + + for (const auto &ns : m_optionsFromJson.scopes) { + if (!createBindingsFile(ns.name)) + return false; + } + + return true; +} + +bool DartGenerator::createBindingsFile(const QString &ns) +{ + const QString contents = licenseComment() + m_exportsFileContentsByNamespace[ns]; + return createFile(exportsFileName(ns), contents); +} + +bool DartGenerator::createLibraryLoaderFile() +{ + const QString contents = + licenseComment() + readSnippet("LibraryLoader.dart").arg(m_optionsFromJson.bindingsLibrary); + + return createFile(libraryLoaderFileName(), contents); +} + +bool DartGenerator::createTypeHelpersFile() +{ + const QString typedefs = FFITypedefs::instance().typedefs().join("\n"); + + const QString contents = licenseComment() + "import 'dart:ffi' as ffi;\n" + + QString("import 'package:ffi/ffi.dart';\n") + typedefs; + return createFile(typeHelpersFileName(), contents); +} + +bool DartGenerator::doSetup() +{ + { + // Register all enums + auto &er = EnumRegistry::instance(); + for (const AbstractMetaClass *c : api().classes()) { + for (AbstractMetaEnum e : c->enums()) + er.registerEnum(e, c); + } + + for (AbstractMetaEnum globalEnum : api().globalEnums()) + er.registerEnum(globalEnum, /*context=*/nullptr); + } + + return DartagnanGeneratorBase::doSetup(); +} diff --git a/src/generator_dart.h b/src/generator_dart.h new file mode 100644 index 0000000..6f6d13e --- /dev/null +++ b/src/generator_dart.h @@ -0,0 +1,52 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#include "generator_base.h" + +class QTextStream; + +class DartGenerator : public DartagnanGeneratorBase +{ +public: + DartGenerator(); + ~DartGenerator(); + OptionDescriptions options() const override + { + return OptionDescriptions(); + } + const char *name() const override + { + return "Dart Generator"; + } + static DartGenerator *instance(); + +protected: + QString fileNameSuffix() const override; + QString fileNameForContext(const GeneratorContext &context) const override; + void generateClass(TextStream &s, const GeneratorContext &classContext) override; + + bool doSetup() override; + + bool finishGeneration() override; + +private: + void writeImports(TextStream &s, const AbstractMetaClass *metaClass = nullptr); + QString dartExportsForGlobalScope() const; + QString dartExportsFor(const AbstractMetaClass *metaClass); + QString dartModuleFileName() const; + QString pubspecFileName() const; + QString exportsFileName(const QString &suffix = {}) const; + QString libraryLoaderFileName() const; + QString typeHelpersFileName() const; + bool createPubSpecFile(); + bool createBindingsFile(const QString &ns = {}); + bool createBindingsFiles(); + bool createLibraryLoaderFile(); + bool createTypeHelpersFile(); + + QStringList m_generatedDartFiles; + QHash m_exportsFileContentsByNamespace; // The Bindings_foo.dart files, + // indexed by "foo" in this example +}; diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..f100fc0 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,33 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#include +#include +#include + +#include + +int main(int argc, char **argv) +{ + QCoreApplication app(argc, argv); + + QStringList arguments = app.arguments(); + arguments.removeAt(0); + + const bool hasGeneratorSet = + std::any_of(arguments.cbegin(), arguments.cend(), + [](const QString &arg) { return arg.startsWith("--generator-set="); }); + + if (hasGeneratorSet) { + qWarning() << "Don't pass --generator-set=, dart will be used by default"; + return 1; + } + + arguments << "--generator-set=dart" + << "--skip-deprecated" + << "--clang-option=-DDARTAGNAN_BINDINGS_RUN"; + + return QProcess::execute("shiboken6", arguments); +} diff --git a/src/printers/Cpp_HeaderPrinter.cpp b/src/printers/Cpp_HeaderPrinter.cpp new file mode 100644 index 0000000..34bb77f --- /dev/null +++ b/src/printers/Cpp_HeaderPrinter.cpp @@ -0,0 +1,134 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#include "Cpp_HeaderPrinter.h" +#include "type_conversions/to_CppWrapper.h" + +#include + +using namespace Dartagnan; + +ClassPrinter::ClassPrinter(TextStream &s, const AbstractMetaClass *metaClass) + : s(s) + , m_metaClass(metaClass) + , m_className(metaClass->name()) + , m_wrapperClassName(ToCppWrapperConversions::wrapperName(metaClass)) +{ +} + +ClassPrinter::~ClassPrinter() +{ + s << "};\n"; +} + +void ClassPrinter::printMembers() +{ +} + +void ClassPrinter::printMethods() +{ + const auto methods = m_metaClass->functions(); + for (auto m : methods) { + const AbstractMetaFunction *method = m.get(); + if (!Dartagnan::acceptsMethod(method)) + continue; + + if (m_seenFunctions.functionWasSeen(method)) + continue; + + m_seenFunctions.markAsSeen(method); + + const bool isFinal = m->attributes() & AbstractMetaFunction::FinalCppMethod; + if (isFinal) + continue; + + ADD_READBILITY_TAG(1041) if (method->isStatic()) s << "static "; + + const QString constStr = method->isConstant() ? "const" : QString(); + const QString argumentsStr = + ToCppWrapperConversions::arguments(method, FunctionFormatOption::DefaultArgumentExpr); + + if (method->isVirtual()) + s << "virtual "; + + s << QString("%1 %2(%3)%4;") + .arg(ToCppWrapperConversions::returnType(method), + ToCppWrapperConversions::wrapperMethodName(method), argumentsStr, constStr); + + + if (method->isVirtual()) { + ADD_READBILITY_TAG(1008) + s << QString("virtual %1 %2_nocallback(%3)%4;") + .arg(ToCppWrapperConversions::returnType(method), + ToCppWrapperConversions::wrapperMethodName(method), argumentsStr, + constStr); + } + } +} + +void ClassPrinter::printVirtualCallbacks() +{ + const auto methods = m_metaClass->functions(); + for (auto m : methods) { + const AbstractMetaFunction *method = m.get(); + if (!Dartagnan::acceptsMethod(method) || !method->isVirtual()) + continue; + + const QString functionTypedefName = + ToCppWrapperConversions::virtualCallbackTypedefName(method); + ADD_READBILITY_TAG(1042) + s << QString("typedef %1;") + .arg(ToCppWrapperConversions::virtualCallbackFunctionPointer(method, + functionTypedefName)); + s << QString("%1 %2 = nullptr;") + .arg(functionTypedefName, + ToCppWrapperConversions::virtualCallbackMemberName(method)); + } +} + +static void printProtectedEnumsWorkaround(TextStream &s, const AbstractMetaClass *metaClass) +{ + if (!metaClass) + return; + + for (auto baseClass : metaClass->baseClasses()) + printProtectedEnumsWorkaround(s, baseClass); + + const QString baseClassName = QString("::%1%2").arg( + metaClass->qualifiedCppName(), ToCppWrapperConversions::templateArgs(metaClass)); + for (auto metaEnum : metaClass->enums()) { + if (metaEnum.isProtected()) { + s << QString("using %1::%2;\n").arg(baseClassName, metaEnum.name()); + } + } +} + +PolymorphicClassPrinter::PolymorphicClassPrinter(TextStream &s, const AbstractMetaClass *metaClass) + : ClassPrinter(s, metaClass) +{ + ADD_READBILITY_TAG(1017) + s << ToCppWrapperConversions::templateString(metaClass); + const QString baseClassName = QString("::%1%2").arg( + metaClass->qualifiedCppName(), ToCppWrapperConversions::templateArgs(metaClass)); + s << QString("class %1 : public %2 {").arg(m_wrapperClassName, baseClassName); + s << "public:\n"; + s << QString("~%1();").arg(m_wrapperClassName); // Our polymorphic wrappers always have dtor + + // The C functions can static cast to protected enums, so print a workaround + printProtectedEnumsWorkaround(s, metaClass); +} + +NonPolymorphicClassPrinter::NonPolymorphicClassPrinter(TextStream &s, + const AbstractMetaClass *metaClass) + : ClassPrinter(s, metaClass) +{ + ADD_READBILITY_TAG(1043) + s << ToCppWrapperConversions::templateString(metaClass); + s << QString("class %1 : public ::%2%3 {") + .arg(m_wrapperClassName, metaClass->qualifiedCppName(), + ToCppWrapperConversions::templateArgs(metaClass)); + s << "public:\n"; + s << QString("~%1();").arg(m_wrapperClassName); // TODO +} diff --git a/src/printers/Cpp_HeaderPrinter.h b/src/printers/Cpp_HeaderPrinter.h new file mode 100644 index 0000000..7ad5765 --- /dev/null +++ b/src/printers/Cpp_HeaderPrinter.h @@ -0,0 +1,42 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#pragma once + +#include "printers.h" + +// RAII style printers +class ClassPrinter +{ +public: + explicit ClassPrinter(TextStream &s, const AbstractMetaClass *metaClass); + ~ClassPrinter(); + + void printMembers(); + void printMethods(); + void printVirtualCallbacks(); + +protected: + TextStream &s; + const AbstractMetaClass *const m_metaClass; + const QString m_className; + const QString m_wrapperClassName; + +private: + Dartagnan::SeenFunctions m_seenFunctions; + Q_DISABLE_COPY(ClassPrinter); +}; + +class PolymorphicClassPrinter : public ClassPrinter +{ +public: + explicit PolymorphicClassPrinter(TextStream &s, const AbstractMetaClass *metaClass); +}; + +class NonPolymorphicClassPrinter : public ClassPrinter +{ +public: + explicit NonPolymorphicClassPrinter(TextStream &s, const AbstractMetaClass *metaClass); +}; diff --git a/src/printers/Cpp_ImplPrinter.cpp b/src/printers/Cpp_ImplPrinter.cpp new file mode 100644 index 0000000..37f0c56 --- /dev/null +++ b/src/printers/Cpp_ImplPrinter.cpp @@ -0,0 +1,166 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#include "Cpp_ImplPrinter.h" +#include "type_conversions/to_CppWrapper.h" + +using namespace Dartagnan; + +MethodImplPrinterBase::MethodImplPrinterBase(TextStream &s, const AbstractMetaFunction *func, + AbstractMetaType instantiation) + : Printer(s) + , m_metaClass(func->ownerClass()) + , m_method(func) + , m_instantiation(instantiation) +{ +} + +MethodImplPrinterBase::~MethodImplPrinterBase() +{ + s << "}\n"; +} + +bool MethodImplPrinterBase::needsReturn() const +{ + return hasType(m_method->type()); +} + +MethodImplPrinter::MethodImplPrinter(TextStream &s, const AbstractMetaFunction *func) + : MethodImplPrinterBase(s, func) +{ + const QString className = m_metaClass->name(); + const QString qualifiedClassName = ToCppWrapperConversions::qualifiedClassName( + m_metaClass, FunctionFormatOption::TemplateArgs); + const QString arguments = ToCppWrapperConversions::arguments(func); + + s << ToCppWrapperConversions::templateString(m_metaClass); + s << QString("%1 %2::%3(%4)%5") + .arg(ToCppWrapperConversions::returnType(m_method), + ToCppWrapperConversions::wrapperName(m_metaClass, + FunctionFormatOption::TemplateArgs), + m_method->originalName(), arguments, + (m_method->isConstant() ? QString("const") : QString())); + s << "{"; + ADD_READBILITY_TAG(1000); + + const QString returnText = needsReturn() ? QString("return ") : QString(); + const QString callArguments = ToCppWrapperConversions::callArguments( + m_method, Dartagnan::GeneratedCodeType_Cppwrapper, {}); + const QString targetMethodCall = + QString("::%1::%2(%3);").arg(qualifiedClassName, m_method->originalName(), callArguments); + + if (func->isVirtual()) { + // If the method is virtual, C++ must ask Dart if it was overridden by the user. + const QString callbackName = ToCppWrapperConversions::virtualCallbackMemberName(func); + s << QString("if (%1) {").arg(callbackName); + ADD_READBILITY_TAG(1001); + + if (generatesQDebugStatements()) + s << QString("qDebug() << \"Debug:\" << Q_FUNC_INFO << this;\n"); + + s << "const void* thisPtr = this;\n"; + s << returnText; + const QString dereference = ToCppWrapperConversions::isValueClass(func->type()) ? "*" : ""; + const QString expression = + QString("%1%2(%3);") + .arg(dereference, callbackName, + ToCppWrapperConversions::callArguments( + m_method, Dartagnan::GeneratedCodeType_CppwrapperVirtualCallback, {})); + + s << expression; + + s << "} else {"; + if (func->isAbstract()) { // don't call base class if it's pure virtual + ADD_READBILITY_TAG(1015); + s << Dartagnan::emptyReturnStatementFor(func); + } else { + ADD_READBILITY_TAG(1002); + s << returnText << targetMethodCall; + } + + s << "}"; + s << "}"; + + // C can't call protected C++ methods, so we need an overload (here suffixed with + // _nocallback) to call the base method directly, bypassing protected. Also, since this is + // called by dart, we don't call into dart (hence nocallback) + ADD_READBILITY_TAG(1009) + s << QString("%1 %2::%3_nocallback(%4)%5") + .arg(ToCppWrapperConversions::returnType(m_method), + ToCppWrapperConversions::wrapperName(m_metaClass), m_method->originalName(), + arguments, (m_method->isConstant() ? QString("const") : QString())); + s << "{"; + ADD_READBILITY_TAG(1003); + + if (func->isAbstract()) { + ADD_READBILITY_TAG(1007); + s << Dartagnan::emptyReturnStatementFor(func); + } else { + s << returnText << targetMethodCall; + } + } else { + ADD_READBILITY_TAG(1004); + s << returnText << targetMethodCall; + } +} + +DtorImplPrinter::DtorImplPrinter(TextStream &s, const AbstractMetaFunction *func) + : MethodImplPrinterBase(s, func) +{ + const QString className = + ToCppWrapperConversions::wrapperName(m_metaClass, FunctionFormatOption::TemplateArgs); + const QString dtorName = ToCppWrapperConversions::wrapperName(m_metaClass); + ADD_READBILITY_TAG(1005); + s << ToCppWrapperConversions::templateString(m_metaClass); + s << QString("%1::~%2() {").arg(className, dtorName); +} + +CtorImplPrinter::CtorImplPrinter(TextStream &s, const AbstractMetaFunction *func) + : MethodImplPrinterBase(s, func) +{ + const QString className = + ToCppWrapperConversions::wrapperName(m_metaClass, FunctionFormatOption::TemplateArgs); + const QString ctorName = ToCppWrapperConversions::wrapperName(m_metaClass); + ADD_READBILITY_TAG(1006); + s << ToCppWrapperConversions::templateString(m_metaClass); + s << QString("%1::%2(%3) : ::%4(%5) {") + .arg(className) + .arg(ctorName) + .arg(ToCppWrapperConversions::arguments(func)) + .arg(ToCppWrapperConversions::qualifiedClassName(m_metaClass, + FunctionFormatOption::TemplateArgs)) + .arg(ToCppWrapperConversions::callArguments( + func, Dartagnan::GeneratedCodeType_Cppwrapper, {})); +} + +std::unique_ptr createMethodPrinter(TextStream &s, + const AbstractMetaFunction *func) +{ + if (!Dartagnan::acceptsMethod(func)) + return {}; + + if (func->hasInjectedCode()) { + const CodeSnipList snips = func->injectedCodeSnips(); + for (const CodeSnip &snip : snips) { + s << "\n" << snip.code() << "\n"; + return {}; + } + } + + const bool isFinal = func->attributes() & AbstractMetaFunction::FinalCppMethod; + if (isFinal) + return {}; + + MethodImplPrinterBase *printer = nullptr; + if (func->isConstructor()) + printer = new CtorImplPrinter(s, func); + else if (func->isDestructor()) + printer = new DtorImplPrinter(s, func); + else { + printer = new MethodImplPrinter(s, func); + } + + return std::unique_ptr(printer); +} diff --git a/src/printers/Cpp_ImplPrinter.h b/src/printers/Cpp_ImplPrinter.h new file mode 100644 index 0000000..1d9c25a --- /dev/null +++ b/src/printers/Cpp_ImplPrinter.h @@ -0,0 +1,46 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#pragma once + +#include "printers.h" + +class MethodImplPrinterBase; +std::unique_ptr createMethodPrinter(TextStream &s, + const AbstractMetaFunction *func); + +class MethodImplPrinterBase : public Printer +{ +public: + explicit MethodImplPrinterBase(TextStream &s, const AbstractMetaFunction *func, + AbstractMetaType instantiation = {}); + ~MethodImplPrinterBase(); + + ///@brief Returns whether we need a 'return' statement. False if it's a void method. + bool needsReturn() const; + +protected: + const AbstractMetaClass *m_metaClass; + const AbstractMetaFunction *m_method; + const AbstractMetaType m_instantiation; +}; + +class MethodImplPrinter : public MethodImplPrinterBase +{ +public: + explicit MethodImplPrinter(TextStream &s, const AbstractMetaFunction *); +}; + +class DtorImplPrinter : public MethodImplPrinterBase +{ +public: + explicit DtorImplPrinter(TextStream &s, const AbstractMetaFunction *func); +}; + +class CtorImplPrinter : public MethodImplPrinterBase +{ +public: + explicit CtorImplPrinter(TextStream &s, const AbstractMetaFunction *func = nullptr); +}; diff --git a/src/printers/Dart_printer.cpp b/src/printers/Dart_printer.cpp new file mode 100644 index 0000000..8b109a3 --- /dev/null +++ b/src/printers/Dart_printer.cpp @@ -0,0 +1,731 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#include "Dart_printer.h" +#include "../type_conversions/to_dart.h" +#include "dart_ffi_typedefs.h" +#include "generator_base.h" +#include "generator_dart.h" +#include "to_CppWrapper.h" + +#include + +using namespace Dartagnan; + +DartClassPrinter::DartClassPrinter(TextStream &s, const AbstractMetaClass *metaClass) + : Printer(s) +{ + const QString className = metaClass->name(); + const QString classNameWithTemplateArgs = + ToDartConversions::className(metaClass, {}, FunctionFormatOption::TemplateArgs); + + QString extendsStr; + AbstractMetaClass *baseClass = metaClass->baseClass(); + if (baseClass) + extendsStr = QString("extends %1").arg(ToDartConversions::scopedNameForType(baseClass)); + else + extendsStr = "implements ffi.Finalizable"; + + for (AbstractMetaEnum metaEnum : metaClass->enums()) { + if (!metaEnum.isAnonymous()) + DartEnumPrinter printer(s, metaEnum, metaClass); + } + + s << QString("class %1 %2").arg(classNameWithTemplateArgs, extendsStr); + s << "{"; + + // Anonymous enums are simply const variables instead of enum + for (AbstractMetaEnum metaEnum : metaClass->enums()) { + if (metaEnum.isAnonymous()) + DartEnumPrinter printer(s, metaEnum, metaClass); + } + + if (className == "QObject") { + s << "Map> signalHandlerersBySignal = {};\n"; + } + + if (baseClass) { + ADD_READBILITY_TAG(1064) + s << QString("%1.fromCppPointer(var cppPointer, [var needsAutoDelete = false]) : " + "super.fromCppPointer(cppPointer, needsAutoDelete) {}") + .arg(className); + s << QString("%1.init() : super.init() {}").arg(className); + + ADD_READBILITY_TAG(1062) + s << QString("factory %1.fromCache(var cppPointer, [needsAutoDelete = false]) {") + .arg(className); + s << QString("if (%1.isCached(cppPointer))\n").arg(Dartagnan::baseMostBaseClass(metaClass)); + s << "{"; + s << "var instance ="; + s << QString("%1.s_dartInstanceByCppPtr[cppPointer.address];") + .arg(Dartagnan::baseMostBaseClass(metaClass)); + s << QString("if (instance != null) return instance as %1;").arg(className); + s << "}"; + s << QString("return %1.fromCppPointer(cppPointer, needsAutoDelete);\n").arg(className); + s << "}"; + + } else { + // The first base class gets these members + ADD_READBILITY_TAG(1060) + s << QString("static var s_dartInstanceByCppPtr = Map();\n").arg(className); + s << "var _thisCpp = null;"; + s << QString("bool _needsAutoDelete = %1;") + .arg(Dartagnan::needsGarbageCollection(metaClass) ? "true" : "false"); + s << "get thisCpp => _thisCpp;"; + s << "set thisCpp (var ptr) {"; + s << "_thisCpp = ptr;"; + s << "ffi.Pointer ptrvoid = ptr.cast();\n"; + s << "if (_needsAutoDelete) {\n"; + + s << "final String finalizerName = getFinalizerName();"; + s << "if (!_finalizers.keys.contains(runtimeType)) {"; + s << QString("_finalizers[finalizerName] = " + "ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast());\n"); + s << "}"; + s << "_finalizers[finalizerName]!.attach(this, ptrvoid);\n"; + + s << "}}"; + s << QString("static bool isCached(var cppPointer) {"); + ADD_READBILITY_TAG(1024) + s << " return s_dartInstanceByCppPtr.containsKey(cppPointer.address);"; + s << "}"; + + ADD_READBILITY_TAG(1061) + s << QString("factory %1.fromCache(var cppPointer, [needsAutoDelete = false]) {") + .arg(className); + s << "return (s_dartInstanceByCppPtr[cppPointer.address] ??\n"; + s << QString("%1.fromCppPointer(cppPointer, needsAutoDelete)) as %2;") + .arg(className, classNameWithTemplateArgs); + s << "}"; + + s << QString("%1.fromCppPointer(var cppPointer, [this._needsAutoDelete = false]) {") + .arg(className); + ADD_READBILITY_TAG(1024) + s << "thisCpp = cppPointer;"; + s << "}"; + + ADD_READBILITY_TAG(1025) + s << QString("%1.init() {}").arg(className); + } + + const auto templateHash = DartGenerator::instance()->templateHash(); + const auto templateInstantiations = templateHash[metaClass]; + if (!metaClass->templateArguments().isEmpty()) { + ADD_READBILITY_TAG(1063) + s << "String getCFunctionName(int id) {"; + + for (const AbstractMetaType &templateInstantiation : templateInstantiations) { + s << QString("if (this is %1%2) {") + .arg(className, ToDartConversions::templateParams(templateInstantiation)); + s << "switch (id) {"; + + for (auto method : metaClass->functions()) { + if (!Dartagnan::acceptsMethod( + method.get(), + RejectedMethod::RejectedMethod_Default + | RejectedMethod::RejectedMethod_UnsupportedDartType)) + continue; + + s << QString("case %1:").arg(Dartagnan::idForFunction(method.get())); + s << QString("return \"%1\";") + .arg(ToCConversions::functionName(method.get(), templateInstantiation)); + s << "break;"; + } + + s << "}"; // switch + s << "}"; + } + + s << " return \"\" ;"; + s << "}"; // end getCFunctionName(); + } + + ADD_READBILITY_TAG(1090) + s << "String getFinalizerName() {"; + + if (metaClass->templateArguments().isEmpty()) { + const QString finalizerName = ToCConversions::finalizerName(metaClass, {}); + s << QString("return \"%1\";").arg(finalizerName); + } else { + for (const AbstractMetaType &templateInstantiation : templateInstantiations) { + + const QString finalizerVariableName = + ToDartConversions::finalizerMemberVariableName(templateInstantiation); + + s << QString("if (this is %1%2) {") + .arg(className, ToDartConversions::templateParams(templateInstantiation)); + + s << QString("return \"%1\";") + .arg(ToCConversions::finalizerName(metaClass, templateInstantiation)); + s << "}"; + } + s << "print(\"ERROR: Couldn't find finalizerName for\" + this.runtimeType.toString());"; + s << "return \"\";"; + } + + s << "}"; + + // Add the members + const AbstractMetaFieldList fields = metaClass->fields(); + for (AbstractMetaField field : fields) { + printGetterText(field); + printSetterText(field); + } + + // Add the methods + + const auto methods = metaClass->functions(); + bool seenDtor = false; + for (auto m : methods) { + auto method = m.get(); + if (Dartagnan::functionIsRemoved(method) || m_seenFunctions.functionWasSeen(method)) + continue; + + m_seenFunctions.markAsSeen(method); + + createDartFunctionPrinter(s, method); + static const bool supportsQtSignals = + DartGenerator::instance()->m_optionsFromJson.supportsQtSignals; + if (supportsQtSignals && method->isSignal() + && method->ownerClass() == method->implementingClass()) + DartSignalHandlerPrinter printer(s, method); + + if (method->isDestructor()) + seenDtor = true; + } + + if (!seenDtor) { + auto m = Dartagnan::createDestructor(metaClass); + auto printer = createDartFunctionPrinter(s, m.get()); + } + + if (metaClass->name() == "QString") { + // QString gets a toDartString() for convenience + + QString code = DartagnanGeneratorBase::m_optionsFromJson.qStringToDartCode; + if (code.isEmpty()) + code = "return toUtf8().constData();"; + + s << QString("String toDartString() { %1 }").arg(code); + } + + printOverriddenMethodHelpers(s, metaClass); +} + +DartClassPrinter::~DartClassPrinter() +{ + s << "}"; +} + +void DartClassPrinter::printOverriddenMethodHelpers(TextStream &s, + const AbstractMetaClass *metaclass) +{ + if (!metaclass->isPolymorphic()) + return; + + ADD_READBILITY_TAG(1019) + + s << "String cFunctionSymbolName(int methodId) {"; + const auto methods = metaclass->functions(); + s << " switch (methodId) {\n"; + for (auto method : methods) { + if (!method->isVirtual() + || !Dartagnan::acceptsMethod(method.get(), + Dartagnan::RejectedMethod_ReturningTemplate + | RejectedMethod::RejectedMethod_UnsupportedDartType)) + continue; + s << QString(" case %1:\n").arg(Dartagnan::idForFunction(method.get())); + s << QString(" return \"%1\";") + .arg(ToDartConversions::cFunctionNameText(method.get())); + } + s << "}\n"; + + if (Dartagnan::firstBaseClassIsPolymorphic(metaclass)) { + s << "return super.cFunctionSymbolName(methodId);"; + } else { + s << "return \"\";"; + } + s << "}"; + s << "static String methodNameFromId(int methodId) {\n"; + s << " switch (methodId) {\n"; + + for (auto method : methods) { + if (!method->isVirtual() + || !Dartagnan::acceptsMethod(method.get(), + Dartagnan::RejectedMethod_ReturningTemplate + | RejectedMethod::RejectedMethod_UnsupportedDartType)) + continue; + + s << QString(" case %1:\n").arg(Dartagnan::idForFunction(method.get())); + s << QString(" return \"%1\";") + .arg(DartOverloadRegistry::instance().nameForMethod(method.get())); + } + + s << " }"; + s << " throw Error();"; + s << "}\n"; + + ADD_READBILITY_TAG(1020) + s << "void registerCallbacks() {\n"; + s << "assert(thisCpp != null);\n"; + s << "final RegisterMethodIsReimplementedCallback registerCallback = _dylib\n"; + s << QString(".lookup>('%1')." + "asFunction();\n") + .arg(ToCConversions::registerCallbackFunctionsName(metaclass)); + + for (auto method : methods) { + if (!method->isVirtual() + || !Dartagnan::acceptsMethod(method.get(), + Dartagnan::RejectedMethod_ReturningTemplate + | RejectedMethod::RejectedMethod_UnsupportedDartType)) + continue; + + if (method->ownerClass() != method->declaringClass() + && !classIsFirstBaseInHierarchy(method->ownerClass(), method->declaringClass())) + continue; + + const auto returnType = method->type(); + const QString returnTypeName = ToDartConversions::type(returnType); + + const bool needsExceptionalValue = returnTypeName == "int" || returnTypeName == "bool" + || returnType.isEnum() || returnType.isFlags(); + + const int id = Dartagnan::idForFunction(method.get()); + const QString callbackExceptName = QString("callbackExcept%1").arg(id); + + const QString callbackExceptArg = + needsExceptionalValue ? QString(", %1").arg(callbackExceptName) : QString(); + + if (needsExceptionalValue) + s << QString("const %1 = %2;") + .arg(callbackExceptName, ToDartConversions::defaultValueForType(returnType)); + + ADD_READBILITY_TAG(1021) + const QString methodsBaseClass = + ToDartConversions::scopedNameForType(method->implementingClass()); + s << QString("final callback%1 = ffi.Pointer.fromFunction<%2>(%3.%4_calledFromC %5);\n") + .arg(id) + .arg(FFITypedefs::ffiTypedefName(method.get(), {}), methodsBaseClass, + DartOverloadRegistry::instance().nameForMethod(method.get()), + callbackExceptArg); + + s << QString("registerCallback(thisCpp, callback%1, %1);").arg(id); + } + + s << "}"; +} + +DartNamespacePrinter::DartNamespacePrinter(TextStream &s, const AbstractMetaClass *metaClass) + : Printer(s) +{ + for (AbstractMetaEnum metaEnum : metaClass->enums()) { + DartEnumPrinter printer(s, metaEnum, metaClass); + } + + const auto methods = metaClass->functions(); + for (auto method : methods) { + auto printer = createDartFunctionPrinter(s, method.get()); + } +} + +void DartClassPrinter::printGetterText(AbstractMetaField field) +{ + if (auto fakeMethod = Dartagnan::createGetterFor(field, Dartagnan::GeneratedCodeType_Dart)) { + DartMethodPrinter methodPrinter(s, fakeMethod.get()); + FFITypedefs::instance().addDartFunctionTypedef(fakeMethod.get()); + } +} + +void DartClassPrinter::printSetterText(AbstractMetaField field) +{ + if (auto fakeMethod = Dartagnan::createSetterFor(field, Dartagnan::GeneratedCodeType_Dart)) { + DartMethodPrinter methodPrinter(s, fakeMethod.get()); + FFITypedefs::instance().addDartFunctionTypedef(fakeMethod.get()); + } +} + +DartFunctionPrinterBase::DartFunctionPrinterBase(TextStream &s, const AbstractMetaFunction *func) + : Printer(s) + , m_func(func) +{ +} + +DartFunctionPrinterBase::~DartFunctionPrinterBase() +{ + s << "}"; +} + +DartDtorPrinter::DartDtorPrinter(TextStream &s, const AbstractMetaFunction *dtor) + : DartFunctionPrinterBase(s, dtor) +{ + // Skip, Dart has no dtors. But maybe we can add a release() function. + ADD_READBILITY_TAG(1022) + s << "void release() {"; + s << QString("final %1 func = _dylib.lookup>('%3').asFunction();") + .arg(FFITypedefs::typedefName(dtor, {})) + .arg(FFITypedefs::ffiTypedefName(dtor, {})) + .arg(ToDartConversions::cFunctionNameText(dtor)); + s << "func(thisCpp);"; +} + +DartCtorPrinter::DartCtorPrinter(TextStream &s, const AbstractMetaFunction *ctor) + : DartFunctionPrinterBase(s, ctor) +{ + QString callBaseClassInit; + const AbstractMetaClass *metaClass = ctor->ownerClass(); + const bool usesDummyInit = metaClass->baseClass() != nullptr; + if (usesDummyInit) + callBaseClassInit = ": super.init()"; + + const auto templateHash = DartGenerator::instance()->templateHash(); + const bool processInstantiations = Dartagnan::hasTemplateArguments(ctor); + AbstractMetaTypeList templateInstantiations; + if (processInstantiations) + templateInstantiations = templateHash.value(ctor->ownerClass()); + + if (templateInstantiations.isEmpty()) + templateInstantiations << AbstractMetaType(); + + ADD_READBILITY_TAG(1023) + s << QString("//%1\n").arg(ctor->signature()); + s << QString("%1(%2) %3 {") + .arg(DartOverloadRegistry::instance().nameForMethod(ctor)) + .arg(ToDartConversions::functionArguments( + ctor, true, ToDartConversions::Option::StringInsteadOfQString)) + .arg(callBaseClassInit); + + for (const AbstractMetaType &templateInstantiation : templateInstantiations) { + ADD_READBILITY_TAG(1075) + + if (hasType(templateInstantiation)) + s << QString("if (this is %1%2) {") + .arg(metaClass->name(), + ToDartConversions::templateParams(templateInstantiation)); + + s << QString("final %1 func = _dylib.lookup>('%3').asFunction();") + .arg(FFITypedefs::typedefName(ctor, templateInstantiation)) + .arg(FFITypedefs::ffiTypedefName(ctor, templateInstantiation)) + .arg(ToDartConversions::cFunctionNameText(ctor)); + s << QString("thisCpp = func(%1);") + .arg(ToDartConversions::callArguments(ctor, templateInstantiation)); + s << QString("%1.s_dartInstanceByCppPtr[thisCpp.address] = this;") + .arg(Dartagnan::baseMostBaseClass(metaClass)); + + if (hasType(templateInstantiation)) + s << QString("}\n"); // end if (this is T) + } + + if (metaClass->isPolymorphic()) { + s << "registerCallbacks();"; + } +} + +std::unique_ptr createDartFunctionPrinter(TextStream &s, + const AbstractMetaFunction *func) +{ + if (!Dartagnan::acceptsMethod(func, + RejectedMethod_MoveCtor | RejectedMethod_CopyCtor + | RejectedMethod_ReturningTemplate + | RejectedMethod::RejectedMethod_UnsupportedDartType)) { + return {}; + } + + DartFunctionPrinterBase *printer = nullptr; + if (func->isConstructor()) { + printer = new DartCtorPrinter(s, func); + } else if (func->isDestructor()) { + printer = new DartDtorPrinter(s, func); + } else if (func->isInGlobalScope()) { + printer = new DartGlobalFuncPrinter(s, func); + } else { + printer = new DartMethodPrinter(s, func); + } + + FFITypedefs::instance().addDartFunctionTypedef(func); + return std::unique_ptr(printer); +} + +DartGlobalFuncPrinter::DartGlobalFuncPrinter(TextStream &s, const AbstractMetaFunction *func) + : DartFunctionPrinterBase(s, func) +{ + Q_ASSERT(false); +} + +DartMethodPrinter::DartMethodPrinter(TextStream &s, const AbstractMetaFunction *method) + : DartFunctionPrinterBase(s, method) +{ + + auto ownerClass = method->ownerClass(); + auto declaringClass = method->declaringClass(); + const bool methodAlreadyInBaseClass = method->isVirtual() && !method->isAbstract() + && ownerClass != declaringClass + && ownerClass->baseClasses().size() == 1; // TODO: Support more base classes + + ADD_READBILITY_TAG(1024) + + const QString methodName = DartOverloadRegistry::instance().nameForMethod(method); + + bool needsClosing = false; + if (!methodAlreadyInBaseClass) { + needsClosing = true; + if (method->isStatic() && (ownerClass && !ownerClass->isNamespace())) + s << "static "; + + const QString returnType = ToDartConversions::type(method->type()); + + if (method->functionType() == AbstractMetaFunction::GetAttroFunction) { + // A getter + ADD_READBILITY_TAG(1025) + s << QString("%1 get %2 {").arg(returnType, methodName); + } else if (method->functionType() == AbstractMetaFunction::SetAttroFunction) { + // A setter + ADD_READBILITY_TAG(1026) + s << QString("%1 set %2(%3) {") + .arg(returnType, methodName, + ToDartConversions::functionArguments(method, true)); + } else { + ADD_READBILITY_TAG(1027) + s << QString("// %1 \n").arg(method->signature()); + s << QString("%1 %2(%3) {") + .arg(returnType, methodName, + ToDartConversions::functionArguments( + method, true, + ToDartConversions::Options( + ToDartConversions::Option::StringInsteadOfQString) + | ToDartConversions::Option::ReplaceReservedDartKeyword)); + } + + const auto templateHash = DartGenerator::instance()->templateHash(); + const bool processInstantiations = Dartagnan::hasTemplateArguments(method); + + AbstractMetaTypeList templateInstantiations; + if (processInstantiations) + templateInstantiations = templateHash.value(method->ownerClass()); + + const bool hasTemplateInstantiations = !templateInstantiations.isEmpty(); + if (!hasTemplateInstantiations) + templateInstantiations << AbstractMetaType(); + + Dartagnan::sortTemplatesByHierarchy(templateInstantiations); + auto printMethod = [&s, method, returnType, + &templateInstantiations](AbstractMetaType templateInstantiation) { + ADD_READBILITY_TAG(1028) + + const AbstractMetaClass *metaClass = method->ownerClass(); + const QString className = metaClass ? metaClass->name() : QString(); + + if (hasType(templateInstantiation)) { + s << QString("if (this is %1%2) {") + .arg(className, ToDartConversions::templateParams(templateInstantiation)); + } + + QString cFunctionSymbolName; + if (method->isVirtual()) { + cFunctionSymbolName = + QString("cFunctionSymbolName(%1)").arg(Dartagnan::idForFunction(method)); + } else { + cFunctionSymbolName = + QString("'%1'").arg(ToDartConversions::cFunctionNameText(method)); + } + + s << QString("final %1 func = _dylib.lookup>(%3).asFunction();") + .arg(FFITypedefs::typedefName(method, templateInstantiation)) + .arg(FFITypedefs::ffiTypedefName(method, templateInstantiation)) + .arg(cFunctionSymbolName); + + const QString arguments = + ToDartConversions::callArguments(method, templateInstantiation); + + const bool returnsTemplateArgument = hasType(method->type()) + && method->type().typeUsagePattern() == AbstractMetaType::TemplateArgument; + const AbstractMetaType type = returnsTemplateArgument + ? Dartagnan::instantiationForTemplateArgument(templateInstantiation, method->type()) + : method->type(); + + QString returnExpr; + const bool needsReturn = hasType(type) && !method->isVoid(); + + if (ToCConversions::methodReturnsBool(method, templateInstantiation)) { + ADD_READBILITY_TAG(1029) + returnExpr = QString("func(%1) != 0").arg(arguments); + } else if (!hasType(type) || method->isVoid()) { + ADD_READBILITY_TAG(1030) + returnExpr = QString("func(%1)").arg(arguments); + } else if (type.isPrimitive() && type.name() == "char") { + ADD_READBILITY_TAG(1031) + returnExpr = QString("String.fromCharCode(func(%1))").arg(arguments); + } else if (type.isPrimitive() || type.isEnum() || type.isFlags()) { + ADD_READBILITY_TAG(1031) + returnExpr = QString("func(%1)").arg(arguments); + } else if (Dartagnan::typeIsConstCharPtr(type)) { + ADD_READBILITY_TAG(1032) + s << QString("ffi.Pointer result = func(%1);").arg(arguments); + returnExpr = QString("result.toDartString()"); + } else if (type.isValuePointer() || type.isObject() || Dartagnan::typeIsRef(type) + || Dartagnan::typeIsValue(type)) { + ADD_READBILITY_TAG(1033) + s << QString("ffi.Pointer result = func(%1);").arg(arguments); + const QString needsAutoDelete = Dartagnan::typeIsValue(type) ? "true" : "false"; + + returnExpr = + QString("%1.fromCppPointer(result, %2)") + .arg(ToDartConversions::className( + type, + FunctionFormatOptions( + Dartagnan::FunctionFormatOption::TemplateParams) + | Dartagnan::FunctionFormatOption::QualifiedWithScope), + needsAutoDelete); + } else { + ADD_READBILITY_TAG(1034) + s << QString("ffi.Pointer result = func(%1);").arg(arguments); + returnExpr = QString("result"); + } + + const QString returnStatement = needsReturn ? QString("return") : QString(); + + if (needsReturn) { + if (returnsTemplateArgument) { + // Dart needs a cast to T. Even though this should be obvious to the compiler. + s << QString("%1 (%2 as %3);").arg(returnStatement, returnExpr, returnType); + } else { + s << QString("%1 %2;").arg(returnStatement, returnExpr); + } + + if (hasType(templateInstantiation)) { + s << "}"; // end if (this is Foo) + const bool isLastTemplateInstantiation = + templateInstantiation == templateInstantiations.last(); + if (isLastTemplateInstantiation) { + s << "print(\"Unreachable, but required, due to null safety we need to " + "return something\");"; + s << "throw Error();"; + } + } + } else { + s << QString("%1;").arg(returnExpr); + if (hasType(templateInstantiation)) + s << "}"; // end if (this is Foo) + } + }; + + for (const AbstractMetaType &templateInstantiation : templateInstantiations) { + printMethod(templateInstantiation); + } + + s << "\n"; + } + + if (method->isVirtual()) { + if (needsClosing) + s << "}"; + ADD_READBILITY_TAG(1035) + QString args = ToDartConversions::functionArguments(method, false, + ToDartConversions::Option::ForTypedef); + if (args.isEmpty()) + args = "ffi.Pointer thisCpp"; + else + args.prepend("ffi.Pointer thisCpp, "); + s << QString("static %1 %2_calledFromC(%3) {\n") + .arg( + ToDartConversions::type(method->type(), ToDartConversions::Option::ForTypedef), + methodName, args); + const QString downcast = method->ownerClass()->baseClass() + ? QString("as %1").arg(method->ownerClass()->name()) + : QString(); + s << QString("var dartInstance = %1.s_dartInstanceByCppPtr[thisCpp.address] %2;") + .arg(Dartagnan::baseMostBaseClass(method->declaringClass()), downcast); + + s << "if (dartInstance == null) {"; + const QString className = method->ownerClass() ? method->ownerClass()->name() : QString(); + s << QString("print(\"Dart instance not found for %1::%2! (${thisCpp.address})\");") + .arg(className, method->signature()); + s << "throw Error();\n"; + s << "}"; + + const QString call = QString("dartInstance.%1(%2);\n") + .arg(methodName, ToDartConversions::directCallArguments(method)); + + if (method->isVoid()) { + ADD_READBILITY_TAG(1036) + s << call; + } else { + ADD_READBILITY_TAG(1037) + s << "final result = " << call; + s << "return "; + + if (isBool(method->type())) { + s << "result ? 1 : 0;"; + } else if (method->type().isValuePointer() || method->type().isObject() + || method->type().isValue()) { + s << "result.thisCpp;"; + } else if (ToDartConversions::type(method->type()) == "String") { + s << " result.toNativeUtf8();"; + } else { + s << " result;"; + } + } + } +} + +DartSignalHandlerPrinter::DartSignalHandlerPrinter(TextStream &s, const AbstractMetaFunction *func) + : DartFunctionPrinterBase(s, func) +{ + ADD_READBILITY_TAG(1077); + const QString className = func->ownerClass()->name(); + QString signalName = func->name(); + signalName[0] = signalName[0].toUpper(); + const QString signalHandlerName = QString("on%1").arg(signalName); + + + s << QString("void %1(Function callback, {QObject? context}) {").arg(signalHandlerName); + s << "final SignalHandler func = "; + s << "_dylib.lookup>("; + s << QString("'%1').asFunction();") + .arg(ToCConversions::functionName(func, {}, FunctionFormatOption::ForSignalHandler)); + const QString callbackName = QString("%1_callback").arg(signalHandlerName); + s << "final dartCallback ="; + s << QString("ffi.Pointer.fromFunction)>(%1);") + .arg(callbackName); + + s << QString("final callbackMethod = %1;\n").arg(callbackName); + s << "var handlers = signalHandlerersBySignal[callbackMethod] ?? [];\n"; + s << "handlers.add(callback);\n"; + s << "signalHandlerersBySignal[callbackMethod] = handlers;\n"; + s << "ffi.Pointer contextPtr = context == null ? ffi.nullptr : context.thisCpp;\n"; + s << "func(thisCpp, contextPtr, dartCallback);"; + s << "}"; + + s << QString("static void %1_callback(ffi.Pointer thisCpp) {\n").arg(signalHandlerName); + s << QString("var dartInstance = QObject.s_dartInstanceByCppPtr[thisCpp.address] as %1;") + .arg(className); + + s << "final signalHandlers =\n"; + s << QString("dartInstance.signalHandlerersBySignal[%1] ?? [];\n").arg(callbackName); + s << "for (var signalHandler in signalHandlers) {\n"; + s << " signalHandler()\n;"; + s << "}\n"; +} + +DartEnumPrinter::DartEnumPrinter(TextStream &s, AbstractMetaEnum metaEnum, + const AbstractMetaClass *context) + : Printer(s) +{ + const auto values = metaEnum.values(); + const int numEnumerators = values.size(); + + if (metaEnum.isAnonymous()) { + ADD_READBILITY_TAG(1076) + s << "// Anonymous enum \n"; + for (AbstractMetaEnumValue value : values) + s << QString("static const %1 = %2;").arg(value.name(), value.value().toString()); + } else { + ADD_READBILITY_TAG(1038) + const QString dartName = ToDartConversions::enumName(metaEnum); + s << QStringLiteral("class %1 {").arg(dartName); + for (AbstractMetaEnumValue value : values) + s << QString("static const %1 = %2;").arg(value.name(), value.value().toString()); + s << "}"; + } +} diff --git a/src/printers/Dart_printer.h b/src/printers/Dart_printer.h new file mode 100644 index 0000000..5310e9a --- /dev/null +++ b/src/printers/Dart_printer.h @@ -0,0 +1,79 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#pragma once + +#include "printers.h" + +class DartFunctionPrinterBase; + +std::unique_ptr +createDartFunctionPrinter(TextStream &s, const AbstractMetaFunction *func); + +class DartClassPrinter : public Printer +{ +public: + explicit DartClassPrinter(TextStream &s, const AbstractMetaClass *metaClass); + ~DartClassPrinter(); + +private: + void printGetterText(AbstractMetaField field); + void printSetterText(AbstractMetaField field); + void printOverriddenMethodHelpers(TextStream &s, const AbstractMetaClass *metaclass); + + Dartagnan::SeenFunctions m_seenFunctions; +}; + +class DartNamespacePrinter : public Printer +{ +public: + explicit DartNamespacePrinter(TextStream &s, const AbstractMetaClass *metaClass); +}; + +class DartFunctionPrinterBase : public Printer +{ +public: + explicit DartFunctionPrinterBase(TextStream &s, const AbstractMetaFunction *func); + ~DartFunctionPrinterBase(); + +protected: + const AbstractMetaFunction *m_func; +}; + +class DartDtorPrinter : public DartFunctionPrinterBase +{ +public: + explicit DartDtorPrinter(TextStream &s, const AbstractMetaFunction *func); +}; + +class DartCtorPrinter : public DartFunctionPrinterBase +{ +public: + explicit DartCtorPrinter(TextStream &s, const AbstractMetaFunction *func); +}; + +class DartGlobalFuncPrinter : public DartFunctionPrinterBase +{ +public: + explicit DartGlobalFuncPrinter(TextStream &s, const AbstractMetaFunction *func); +}; + +class DartMethodPrinter : public DartFunctionPrinterBase +{ +public: + explicit DartMethodPrinter(TextStream &s, const AbstractMetaFunction *func); +}; + +class DartSignalHandlerPrinter : public DartFunctionPrinterBase +{ +public: + explicit DartSignalHandlerPrinter(TextStream &s, const AbstractMetaFunction *func); +}; + +class DartEnumPrinter : public Printer +{ +public: + explicit DartEnumPrinter(TextStream &s, AbstractMetaEnum, const AbstractMetaClass *context); +}; diff --git a/src/printers/ExternC_HeaderPrinter.cpp b/src/printers/ExternC_HeaderPrinter.cpp new file mode 100644 index 0000000..9786904 --- /dev/null +++ b/src/printers/ExternC_HeaderPrinter.cpp @@ -0,0 +1,74 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#include "ExternC_HeaderPrinter.h" +#include "generator_dart.h" +#include "typedatabase.h" + +#include + +using namespace Dartagnan; + +ExternCHeaderPrinter::ExternCHeaderPrinter(TextStream &s, const AbstractMetaClass *metaClass, + AbstractMetaType instantiation, bool pureCOnly) + : ExternCPrinterBase(s, metaClass, instantiation, pureCOnly) +{ + + const FunctionFormatOptions opt = + pureCOnly ? FunctionFormatOption::Default : FunctionFormatOption::ExportMacro; + const auto methods = metaClass->functions(); + bool seenDtor = false; + for (auto method : methods) { + if (!Dartagnan::acceptsMethod(method.get(), RejectedMethod::RejectedMethod_Default) + || m_seenFunctions.functionWasSeen(method.get())) + continue; + + m_seenFunctions.markAsSeen(method.get()); + + ADD_READBILITY_TAG(1067) + s << QString("// %1::%2\n").arg(metaClass->qualifiedCppName(), method->signature()); + s << ToCConversions::functionSignature(method.get(), opt, instantiation) << ";\n"; + if (method->isDestructor()) + seenDtor = true; + + if (method->isSignal() && DartGenerator::instance()->m_optionsFromJson.supportsQtSignals) { + ADD_READBILITY_TAG(1078) + s << ToCConversions::functionSignature( + method.get(), FunctionFormatOptions(opt | FunctionFormatOption::ForSignalHandler), + instantiation) + << ";"; + } + } + + if (!seenDtor && !metaClass->isNamespace()) { + ADD_READBILITY_TAG(1066) + auto dtor = Dartagnan::createDestructor(metaClass); + s << ToCConversions::functionSignature(dtor.get(), opt, instantiation) << ";\n"; + } + + // Also print the C getters/setters for members: + + auto getters = + Dartagnan::syntheticGetters(metaClass, Dartagnan::GeneratedCodeType_Cppwrapper_header); + auto setters = + Dartagnan::syntheticSetters(metaClass, Dartagnan::GeneratedCodeType_Cppwrapper_header); + + for (const auto &func : getters) { + ADD_READBILITY_TAG(1044) + s << ToCConversions::functionSignature(func.get(), opt, instantiation) << ";\n"; + } + + for (const auto &func : setters) { + ADD_READBILITY_TAG(1045) + s << ToCConversions::functionSignature(func.get(), opt, instantiation) << ";\n"; + } + + if (m_metaClass->isPolymorphic()) { + ADD_READBILITY_TAG(1046) + s << ToCConversions::registerCallbackFunctionSignature(metaClass, opt) << ";"; + } + ADD_READBILITY_TAG(1047) + s << ToCConversions::finalizerSignature(metaClass, opt, instantiation) << ";"; +} diff --git a/src/printers/ExternC_HeaderPrinter.h b/src/printers/ExternC_HeaderPrinter.h new file mode 100644 index 0000000..5c56ccc --- /dev/null +++ b/src/printers/ExternC_HeaderPrinter.h @@ -0,0 +1,25 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#pragma once + +#include "printers.h" + +/** + * @brief Prints the C functions that Dart ffi will call. + * These extern "C" functions will then call the normal C++ methods. + * + * This only prints the declarations (in the headers) see also ExternCImplPrinter which prints + * the implementation + */ +class ExternCHeaderPrinter : public ExternCPrinterBase +{ +public: + explicit ExternCHeaderPrinter(TextStream &s, const AbstractMetaClass *metaClass, + AbstractMetaType instantiation = {}, bool pureCOnly = false); + +private: + Dartagnan::SeenFunctions m_seenFunctions; +}; diff --git a/src/printers/ExternC_ImplPrinter.cpp b/src/printers/ExternC_ImplPrinter.cpp new file mode 100644 index 0000000..edb4c25 --- /dev/null +++ b/src/printers/ExternC_ImplPrinter.cpp @@ -0,0 +1,338 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#include "ExternC_ImplPrinter.h" +#include "generator_dart.h" +#include "to_CppWrapper.h" + +#include + +#include + +using namespace Dartagnan; + +ExternCImplPrinter::ExternCImplPrinter(TextStream &s, const AbstractMetaClass *metaClass, + AbstractMetaType instantiation) + : ExternCPrinterBase(s, metaClass, instantiation) +{ + const QString wrapperClassName = ToCppWrapperConversions::wrapperClassName(metaClass); + if (!metaClass->isNamespace()) { + ADD_READBILITY_TAG(1049) + s << ToCConversions::finalizerSignature(metaClass, {}, instantiation) << "{"; + s << QString("delete reinterpret_cast<%1 *>(cppObj);") + .arg(ToCppWrapperConversions::wrapperClassName( + metaClass, FunctionFormatOption::TemplateParams, instantiation)); + s << "}"; + } + + // Also print the C getters/setters impl for members: + + const auto methods = metaClass->functions(); + bool seenDtor = false; + for (auto m : methods) { + auto method = m.get(); + if (m_seenFunctions.functionWasSeen(method)) + continue; + if (method->isDestructor()) + seenDtor = true; + + m_seenFunctions.markAsSeen(method); + createExternCMethodPrinter(s, method, instantiation); + + static const bool supportsQtSignals = + DartGenerator::instance()->m_optionsFromJson.supportsQtSignals; + + if (supportsQtSignals && method->isSignal()) + ExternCSignalHandlerPrinter signalHandler(s, method); + } + + if (!seenDtor && !metaClass->isNamespace()) { + auto dtor = Dartagnan::createDestructor(metaClass); + ExternCDtorImplPrinter dtorPrinter(s, dtor.get(), instantiation); + } + + auto getters = + Dartagnan::syntheticGetters(metaClass, Dartagnan::GeneratedCodeType_Cppwrapper_impl); + auto setters = + Dartagnan::syntheticSetters(metaClass, Dartagnan::GeneratedCodeType_Cppwrapper_impl); + for (const auto &func : getters) + createExternCMethodPrinter(s, func.get(), instantiation); + for (const auto &func : setters) + createExternCMethodPrinter(s, func.get(), instantiation); + + if (m_metaClass->isPolymorphic()) { + s << ToCConversions::registerCallbackFunctionSignature(metaClass); + s << "{"; + ADD_READBILITY_TAG(1048) + s << "auto wrapper = fromWrapperPtr(ptr);\n"; + s << "switch (methodId) {\n"; + + for (auto m : methods) { + auto method = m.get(); + if (!method->isVirtual() || !Dartagnan::acceptsMethod(method)) + continue; + + s << QString("case %1:\n").arg(Dartagnan::idForFunction(method)); + s << QString("wrapper->%1 = %2;") + .arg(ToCppWrapperConversions::virtualCallbackMemberName(method), + QString("reinterpret_cast<%1::%2>(callback)") + .arg(wrapperClassName, + ToCppWrapperConversions::virtualCallbackTypedefName(method))); + s << "break;"; + } + s << "}\n"; // switch + s << "}"; + } +} + +std::unique_ptr createExternCMethodPrinter(TextStream &s, + const AbstractMetaFunction *func, + AbstractMetaType instantiation) +{ + if (!Dartagnan::acceptsMethod(func, RejectedMethod::RejectedMethod_Default)) + return {}; + + MethodImplPrinterBase *printer = nullptr; + if (func->isConstructor()) { + printer = new ExternCCtorImplPrinter(s, func, instantiation); + } else if (func->isDestructor()) { + printer = new ExternCDtorImplPrinter(s, func, instantiation); + } else if (func->functionType() + == AbstractMetaFunction::GetAttroFunction) { // TODO: Find out of this is the best + // way to mark our getters and setters + printer = new ExternCGetterImplPrinter(s, func, instantiation); + } else if (func->functionType() == AbstractMetaFunction::SetAttroFunction) { + printer = new ExternCSetterImplPrinter(s, func, instantiation); + } else { + printer = new ExternCMethodImplPrinter(s, func, instantiation); + } + + return std::unique_ptr(printer); +} + +ExternCMethodImplPrinter::ExternCMethodImplPrinter(TextStream &s, + const AbstractMetaFunction *method, + AbstractMetaType instantiation) + : MethodImplPrinterBase(s, method, instantiation) +{ + ADD_READBILITY_TAG(1050) + + const bool isFinal = method->attributes() & AbstractMetaFunction::FinalCppMethod; + + s << QString("//%1\n").arg(method->signature()); + + const FunctionFormatOptions options = FunctionFormatOption::StringInsteadOfQString; + s << ToCConversions::functionSignature(method, options, instantiation); + s << "{"; + + s << ToCConversions::argumentCasts(method, options, instantiation); + + if (needsReturn()) + s << "const auto &result = "; + + const QString argsCallText = ToCppWrapperConversions::callArguments( + method, Dartagnan::GeneratedCodeType_FFI_C, instantiation); + QString returnText; + + if (method->isStatic()) { + ADD_READBILITY_TAG(1068) + const QString wrapperName = ToCppWrapperConversions::qualifiedWrapperMethodName( + method, FunctionFormatOption::TemplateParams, instantiation); + returnText = QString("%1(%2)").arg(wrapperName, argsCallText); + } else if (!method->ownerClass()) { + // global func + ADD_READBILITY_TAG(1012) + returnText = QString("%1(%2)").arg(method->name(), argsCallText); + } else { + if (method->isPublic()) { + // Since method is public, call target class directly + + if (method->isVirtual() && !isFinal) { + ADD_READBILITY_TAG(1016) + + returnText = + QString("[&]{" + "auto targetPtr = fromPtr(thisObj);" + "auto wrapperPtr = dynamic_cast<%1*>(targetPtr);" + "if (wrapperPtr) {" + " return wrapperPtr->%2_nocallback(%3);" + "} else {" + " return targetPtr->%4(%5);" + "}" + "}()") + .arg(ToCppWrapperConversions::wrapperClassName(method->ownerClass()), + method->originalName(), argsCallText, method->originalName(), + argsCallText); + } else { + ADD_READBILITY_TAG(1010) + + returnText = QString("fromPtr%1(thisObj)->%2(%3)") + .arg(ToCppWrapperConversions::templateParams(instantiation), + method->originalName(), argsCallText); + + if (method->type().isEnum()) { + // Cast to int. Required if "enum class" + returnText = QString("int(%1)").arg(returnText); + } + } + } else if (method->isProtected()) { + ADD_READBILITY_TAG(1011) + // It's protected, so we go through an indirection. This will only work when the + // instance was created in dart. For something created in C++, it won't have a wrapper, + // this will fail. User shouldn't call these protected methods. We'll need to hide them + // in the dart class + if (method->isVirtual()) { + ADD_READBILITY_TAG(1074) + returnText = QString("fromWrapperPtr%1(thisObj)->%2_nocallback(%3)") + .arg(ToCppWrapperConversions::templateParams(instantiation), + method->name(), argsCallText); + } else { + ADD_READBILITY_TAG(1073) + returnText = QString("fromWrapperPtr%1(thisObj)->%2(%3)") + .arg(ToCppWrapperConversions::templateParams(instantiation), + method->originalName(), argsCallText); + } + } else { + // private methods don't reach here + Q_ASSERT(false); + } + } + + const AbstractMetaType actualType = Dartagnan::actualType(method->type(), instantiation); + + const bool isNonVoid = hasType(actualType); + const bool isConstant = isNonVoid && actualType.isConstant(); + const bool isObject = isNonVoid && actualType.isObject(); + const bool isValue = isNonVoid && actualType.isValue(); + const bool isValuePointer = isNonVoid && actualType.isValuePointer(); + const bool isReference = isNonVoid && Dartagnan::isReference(actualType); + const bool isPrimitive = isNonVoid && actualType.isPrimitive(); + + if (!isPrimitive) { + if (isValue && !isReference) { + ADD_READBILITY_TAG(1072) + returnText = + QString("new Dartagnan::ValueWrapper<%1>{%2}") + .arg(ToCppWrapperConversions::returnType(m_method, instantiation), returnText); + } else if (isReference) { + if (isConstant) { + ADD_READBILITY_TAG(1071) + returnText = + QString("const_cast(static_cast(&%1))").arg(returnText); + } else { + ADD_READBILITY_TAG(1070) + returnText = "&" + returnText; + } + } else if (isObject || isValuePointer || isValue) { + if (isConstant) { + ADD_READBILITY_TAG(1069) + returnText = + QString("const_cast(static_cast(%1))").arg(returnText); + } + } + } + + s << returnText + ";"; + + // Delete "const char *" arguments, if any. They were allocated in dart with "toNativeUtf8()" + for (AbstractMetaArgument arg : method->arguments()) { + const AbstractMetaType actualType = Dartagnan::actualType(arg.type(), instantiation); + const bool isString = actualType.name() == "char" && actualType.isPointer(); + const bool isQString = actualType.name() == "QString"; + + if (isString || isQString) { + const QString suffix = isQString ? "_" : ""; + s << QString("free((char*)%1%2);\n").arg(arg.name(), suffix); + } + } + + if (needsReturn()) + s << "return result;"; +} + +ExternCCtorImplPrinter::ExternCCtorImplPrinter(TextStream &s, const AbstractMetaFunction *ctor, + AbstractMetaType instantiation) + : MethodImplPrinterBase(s, ctor, instantiation) +{ + const FunctionFormatOptions options = FunctionFormatOption::StringInsteadOfQString; + s << ToCConversions::functionSignature(ctor, options, instantiation) << "\n"; + s << "{\n"; + s << ToCConversions::argumentCasts(ctor, options, instantiation); + ADD_READBILITY_TAG(1056); + s << QString("auto ptr = new %1(%2);") + .arg(ToCppWrapperConversions::wrapperClassName( + ctor->ownerClass(), FunctionFormatOption::TemplateParams, instantiation)) + .arg(ToCppWrapperConversions::callArguments(ctor, Dartagnan::GeneratedCodeType_FFI_C, + instantiation)); + s << "return reinterpret_cast(ptr);"; +} + +ExternCDtorImplPrinter::ExternCDtorImplPrinter(TextStream &s, const AbstractMetaFunction *method, + AbstractMetaType instantiation) + : MethodImplPrinterBase(s, method, instantiation) +{ + s << ToCConversions::functionSignature(method, {}, instantiation) << "\n"; + s << "{\n"; + ADD_READBILITY_TAG(1055); + s << QString("delete fromPtr%1(thisObj);") + .arg(ToCppWrapperConversions::templateParams(instantiation)); +} + +ExternCGetterImplPrinter::ExternCGetterImplPrinter(TextStream &s, const AbstractMetaFunction *func, + AbstractMetaType instantiation) + : MethodImplPrinterBase(s, func, instantiation) +{ + s << ToCConversions::functionSignature(func) << "\n"; + s << "{\n"; + + if (func->isStatic()) { + ADD_READBILITY_TAG(1054); + s << QString("return %1::%2;") + .arg(ToCppWrapperConversions::wrapperClassName(func->ownerClass()), + func->fieldName()); + } else { + ADD_READBILITY_TAG(1058); + s << QString("return fromPtr(thisObj)->%1;").arg(func->fieldName()); + } +} + +ExternCSetterImplPrinter::ExternCSetterImplPrinter(TextStream &s, const AbstractMetaFunction *func, + AbstractMetaType instantiation) + : MethodImplPrinterBase(s, func, instantiation) +{ + s << ToCConversions::functionSignature(func) << "\n"; + s << "{\n"; + + auto arg = func->arguments().constFirst(); + + if (func->isStatic()) { + ADD_READBILITY_TAG(1059); + s << QString("%1::%2 = %3;") + .arg(ToCppWrapperConversions::wrapperClassName(func->ownerClass()), + func->fieldName(), arg.name()); + } else { + ADD_READBILITY_TAG(1057); + s << QString("fromPtr(thisObj)->%1 = %2;").arg(func->fieldName(), arg.name()); + } +} + +ExternCSignalHandlerPrinter::ExternCSignalHandlerPrinter(TextStream &s, + const AbstractMetaFunction *func) + : MethodImplPrinterBase(s, func) +{ + ADD_READBILITY_TAG(1079) + s << ToCConversions::functionSignature(func, FunctionFormatOption::ForSignalHandler) << "\n"; + s << "{\n"; + + const QString className = func->ownerClass()->name(); + s << QString("auto instance = reinterpret_cast<%1 *>(thisObj);\n").arg(className); + s << "auto context = reinterpret_cast(contextQObject);\n"; + s << QString("QObject::connect(instance, &%1::%2, context ? context : instance, [thisObj, " + "callback] {\n") + .arg(className, func->name()); + s << "typedef void (*SignalHandler_callback)(void *);\n"; + s << "auto dartCallback = reinterpret_cast(callback);\n"; + s << "dartCallback(thisObj);});\n"; +} diff --git a/src/printers/ExternC_ImplPrinter.h b/src/printers/ExternC_ImplPrinter.h new file mode 100644 index 0000000..a21aaa1 --- /dev/null +++ b/src/printers/ExternC_ImplPrinter.h @@ -0,0 +1,73 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#pragma once + +#include "Cpp_ImplPrinter.h" +#include "printers.h" + +class MethodImplPrinterBase; + +std::unique_ptr createExternCMethodPrinter(TextStream &s, + const AbstractMetaFunction *func, + AbstractMetaType instantiation); + +/// @brief Iterates the class and creates impl for all methods and members +class ExternCImplPrinter : public ExternCPrinterBase +{ +public: + explicit ExternCImplPrinter(TextStream &s, const AbstractMetaClass *metaClass, + AbstractMetaType instantiation = {}); + +private: + Dartagnan::SeenFunctions m_seenFunctions; +}; + +/// @brief Prints an extern "C" method body +class ExternCMethodImplPrinter : public MethodImplPrinterBase +{ +public: + explicit ExternCMethodImplPrinter(TextStream &s, const AbstractMetaFunction *func, + AbstractMetaType instantiation); +}; + +/// @brief Prints an extern "C" CTOR body +class ExternCCtorImplPrinter : public MethodImplPrinterBase +{ +public: + explicit ExternCCtorImplPrinter(TextStream &s, const AbstractMetaFunction *func, + AbstractMetaType instantiation); +}; + +/// @brief Prints an extern "C" DTOR body +class ExternCDtorImplPrinter : public MethodImplPrinterBase +{ +public: + explicit ExternCDtorImplPrinter(TextStream &s, const AbstractMetaFunction *func, + AbstractMetaType instantiation); +}; + +/// @brief Prints an extern "C" member variable getter +class ExternCGetterImplPrinter : public MethodImplPrinterBase +{ +public: + explicit ExternCGetterImplPrinter(TextStream &s, const AbstractMetaFunction *func, + AbstractMetaType instantiation); +}; + +/// @brief Prints an extern "C" member variable setter +class ExternCSetterImplPrinter : public MethodImplPrinterBase +{ +public: + explicit ExternCSetterImplPrinter(TextStream &s, const AbstractMetaFunction *func, + AbstractMetaType instantiation); +}; + +/// @brief Prints the signal handler +class ExternCSignalHandlerPrinter : public MethodImplPrinterBase +{ +public: + explicit ExternCSignalHandlerPrinter(TextStream &s, const AbstractMetaFunction *); +}; diff --git a/src/printers/printers.cpp b/src/printers/printers.cpp new file mode 100644 index 0000000..e9f3cfb --- /dev/null +++ b/src/printers/printers.cpp @@ -0,0 +1,40 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#include "printers.h" + +#include + +Printer::~Printer() +{ +} + +NamespacePrinter::NamespacePrinter(TextStream &s, const QString nsName) + : Printer(s) +{ + s << QString("namespace %1 {").arg(nsName); +} + +NamespacePrinter::~NamespacePrinter() +{ + s << QString("}"); +} + +ExternCPrinterBase::ExternCPrinterBase(TextStream &s, const AbstractMetaClass *metaClass, + AbstractMetaType instantiation, bool pureCOnly) + : Printer(s) + , m_metaClass(metaClass) + , m_instantiation(instantiation) + , m_pureCOnly(pureCOnly) +{ + if (!pureCOnly) + s << "extern \"C\" {\n"; +} + +ExternCPrinterBase::~ExternCPrinterBase() +{ + if (!m_pureCOnly) + s << "}\n"; +} diff --git a/src/printers/printers.h b/src/printers/printers.h new file mode 100644 index 0000000..9815bba --- /dev/null +++ b/src/printers/printers.h @@ -0,0 +1,51 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#pragma once + +#include "dartagnan.h" +#include "generator_base.h" +#include "type_conversions/to_C.h" + +#include +#include + +/// RAII style printer +class Printer +{ +public: + explicit Printer(TextStream &s) + : s(s) + { + } + + virtual ~Printer(); + +protected: + TextStream &s; + +private: + Q_DISABLE_COPY(Printer); +}; + +class NamespacePrinter : public Printer +{ +public: + explicit NamespacePrinter(TextStream &s, const QString nsName); + ~NamespacePrinter(); +}; + +class ExternCPrinterBase : public Printer +{ +public: + explicit ExternCPrinterBase(TextStream &s, const AbstractMetaClass *metaClass, + AbstractMetaType instantiation = {}, bool pureCOnly = false); + ~ExternCPrinterBase(); + +protected: + const AbstractMetaClass *const m_metaClass; + const AbstractMetaType m_instantiation; + const bool m_pureCOnly; +}; diff --git a/src/type_conversions/to_C.cpp b/src/type_conversions/to_C.cpp new file mode 100644 index 0000000..904f77b --- /dev/null +++ b/src/type_conversions/to_C.cpp @@ -0,0 +1,367 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#include "to_C.h" +#include "to_CppWrapper.h" + +#include + +using namespace Dartagnan; + +namespace ToCConversions { + +QString type(const AbstractMetaType type) +{ + if (!hasType(type) || type.isVoid()) + return "void"; + + if (type.isObject() || type.isValuePointer() || type.isValue()) { + return "void*"; + } + + if (type.isEnum() || type.isFlags()) { + // TODO: Support enum class with different storage + return "int"; + } + + if (typeIsPrimitiveConst(type)) { + // "const int &" and "const int" are returned as int, etc. + return type.name(); + } + + return type.cppSignature(); +} + +QString functionReturnType(const AbstractMetaFunction *func, + const AbstractMetaType templateInstantiation) +{ + if (func->isConstructor()) + return "void *"; + + if (func->isDestructor()) + return "void"; + + const AbstractMetaType t = func->type(); + + if (hasType(t) && t.typeUsagePattern() == AbstractMetaType::TemplateArgument) { + // A method can return T, for example T QVector::at(int index). + // We now need to replace T with the instantiated type + + const AbstractMetaType actualType = + Dartagnan::instantiationForTemplateArgument(templateInstantiation, t); + + QString result = type(actualType); + + // Furthermore, a method can return "const T *", for example: const T + // *QVector::constData() So we need to add const and * + + if (t.isConstant()) + result = QString("const %1").arg(result); + + if (templateArgumentIsPointer(t)) { + // TODO: support ** + result = QString("%1 *").arg(result); + } + + return result; + } + + return type(t); +} + +QString functionSignature(const AbstractMetaFunction *func, FunctionFormatOptions opts, + AbstractMetaType instantiation) +{ + const QString exportMacro = (opts & FunctionFormatOption::ExportMacro) + ? QString("%1 ").arg(Dartagnan::exportMacroName()) + : QString(); + return QString("%1%2 %3(%4)") + .arg(exportMacro, functionReturnType(func, instantiation), + functionName(func, instantiation, opts), + membersText(func, + opts | FunctionFormatOption::ImplicitThisAs1stParams + | FunctionFormatOption::StringInsteadOfQString, + instantiation)); +} + +QString functionName(const AbstractMetaFunction *func, const AbstractMetaType instantiation, + FunctionFormatOptions opts) +{ + auto record = func->ownerClass(); + + const QString qualifiedClassCppName = ToCConversions::qualifiedClassName(record, instantiation); + QString cname; + + QString argumentsText = argumentTypesForSignature(func, instantiation); + if (!argumentsText.isEmpty()) + argumentsText = "_" + argumentsText; + + QString funcName = func->name(); + if (opts & FunctionFormatOption::ForSignalHandler) { + funcName[0] = funcName[0].toUpper(); + funcName = QString("on%1").arg(funcName); + } + + if (func->isConstructor()) { + cname = QStringLiteral("c_%1__constructor%2").arg(qualifiedClassCppName, argumentsText); + } else if (func->isDestructor()) { + cname = dtorFunctionName(record, instantiation); + } else { + // Normal, non-static method + // getter/setter prefix + const QString prefix = func->functionType() == AbstractMetaFunction::GetAttroFunction + ? QString("_get_") + : func->functionType() == AbstractMetaFunction::SetAttroFunction ? QString("_set_") + : QString(); + + if (func->isStatic()) { + cname = QStringLiteral("c_static_%1__%2%3%4") + .arg(qualifiedClassCppName, prefix, funcName, argumentsText); + } else { + cname = QStringLiteral("c_%1__%2%3%4") + .arg(qualifiedClassCppName, prefix, funcName, argumentsText); + } + } + + cname = cname.replace("::", "__"); + return cname; +} + +QString registerCallbackFunctionsName(const AbstractMetaClass *metaClass) +{ + const QString qualifiedClassCppName = metaClass ? metaClass->qualifiedCppName() : QString(); + QString name = QString("c_%1__registerVirtualMethodCallback").arg(qualifiedClassCppName); + return name.replace("::", "__"); +} + +QString registerCallbackFunctionSignature(const AbstractMetaClass *metaClass, + FunctionFormatOptions opts) +{ + const QString exportMacro = (opts & FunctionFormatOption::ExportMacro) + ? QString("%1 ").arg(Dartagnan::exportMacroName()) + : QString(); + const QString qualifiedClassCppName = metaClass ? metaClass->qualifiedCppName() : QString(); + return QString("%1void %2(void *ptr, void *callback, int methodId)") + .arg(exportMacro, registerCallbackFunctionsName(metaClass)); +} + +static const AbstractMetaType templateParamForArgument(const AbstractMetaFunction *func, + AbstractMetaArgument argument, + const AbstractMetaType instantiation) +{ + if (argument.type().typeUsagePattern() != AbstractMetaType::TemplateArgument) { + // Not a template argument, nothing to do + return argument.type(); + } + + if (!hasType(instantiation)) { + qWarning() << Q_FUNC_INFO << "Expected template instantiation when dealing with func" + << func->signature(); + return {}; + } + + const QString templateArg = argument.type().name(); + auto result = Dartagnan::instantiationForTemplateArgument(instantiation, argument.type()); + return hasType(result) ? result : argument.type(); +} + +QString membersText(const AbstractMetaFunction *func, FunctionFormatOptions formatOpts, + const AbstractMetaType instantiation) +{ + if (func->isDestructor()) + return "void *thisObj"; + + if (formatOpts & FunctionFormatOption::ForSignalHandler) { + return "void *thisObj, void *contextQObject, void *callback"; + } + + QStringList members; + if ((formatOpts & FunctionFormatOption::ImplicitThisAs1stParams) && !func->isStatic() + && !func->isConstructor() && func->ownerClass()) + members << "void *thisObj"; + + const auto arguments = func->arguments(); + for (AbstractMetaArgument argument : arguments) { + QString argName = argument.name(); + + const AbstractMetaType actualType = Dartagnan::actualType(argument.type(), instantiation); + if ((formatOpts & FunctionFormatOption::StringInsteadOfQString) + && actualType.name() == "QString") { + members << QString("const char *%1_").arg(argName); + continue; + } + + if (actualType.isObject() || actualType.isValue() || actualType.isValuePointer() + || actualType.isFlags()) { + // These are not supported by C, so will need to be cast before calling the C++ func. + argName += "_"; + } + + members << QStringLiteral("%1 %2").arg( + type(templateParamForArgument(func, argument, instantiation)), argName); + } + + return members.join(","); +} + +QString membersTextEscaped(const AbstractMetaFunction *func) +{ + QString text = membersText(func); + return text; +} + +QString argumentTypesForSignature(const AbstractMetaFunction *func, + const AbstractMetaType instantiation) +{ + if (func->isDestructor()) + return {}; + + QStringList result; + const auto args = func->arguments(); + for (AbstractMetaArgument arg : args) { + const AbstractMetaType actualType = Dartagnan::actualType(arg.type(), instantiation); + Q_ASSERT(hasType(actualType)); + result << actualType.name().replace(" ", "_"); + + // @param instantiation is about the class having a template, but arg.type() might be a + // template too, so append its arguments + if (actualType.hasInstantiations()) { + for (auto i : actualType.instantiations()) { + result << i.name(); + } + } + } + + return result.join('_'); +} + +QString dtorFunctionName(const AbstractMetaClass *record, const AbstractMetaType instantiation) +{ + QString cname = + QStringLiteral("c_%1__destructor").arg(qualifiedClassName(record, instantiation)); + cname = cname.replace("::", "__"); + return cname; +} + +QString argumentCasts(const AbstractMetaFunction *func, FunctionFormatOptions options, + AbstractMetaType instantiation) +{ + QString result; + const AbstractMetaArgumentList args = func->arguments(); + for (AbstractMetaArgument arg : args) { + const QString name = arg.name(); + const AbstractMetaType actualType = Dartagnan::actualType(arg.type(), instantiation); + QString typeName = actualType.typeEntry()->qualifiedCppName(); + + if ((options & FunctionFormatOption::StringInsteadOfQString) + && actualType.name() == "QString") { + result += QString("const auto %1 = QString::fromUtf8(%2_);").arg(name, name); + } else if (actualType.isObject() || actualType.isValue() || actualType.isValuePointer()) { + + if (arg.type().typeUsagePattern() != AbstractMetaType::TemplateArgument) { + QString params = ToCppWrapperConversions::templateParams(instantiation); + if (params.isEmpty()) + params += ToCppWrapperConversions::templateParams(arg.type()); + + typeName += params; + } + + const bool isPointer = + actualType.cppSignature().endsWith("*"); // TODO: Improve this. Quick hack for now. + const QString maybeDeref = isPointer ? QString() : "*"; + const QString ampersand = isPointer ? QString() : "&"; + + if (!isPointer) { + // Assert soon, as these bugs are difficult to debug + result += QString("assert(%1_);\n").arg(name); + } + + result += QString("auto %1%2 = %3reinterpret_cast<%4 *>(%5_);") + .arg(ampersand, name, maybeDeref, typeName, name); + } else if (actualType.isFlags()) { + // QFlags need to be cast to int, as C doesn't support QFlags + result += QString("auto %1 = static_cast<%2>(%3_);").arg(name, typeName, name); + } + } + + return result; +} + +bool typeIsPrimitiveConst(const AbstractMetaType type) +{ + return type.isPrimitive() && type.isConstant(); +} + +QString finalizerName(const AbstractMetaClass *metaClass, const AbstractMetaType instantiation) +{ + return QString("c_%1_Finalizer") + .arg(qualifiedClassName(metaClass, instantiation).replace(":", "_")); +} + +QString finalizerSignature(const AbstractMetaClass *metaClass, FunctionFormatOptions opts, + const AbstractMetaType instantiation) +{ + const QString exportMacro = (opts & FunctionFormatOption::ExportMacro) + ? QString("%1 ").arg(Dartagnan::exportMacroName()) + : QString(); + + return QString("%1 void %2(void *cppObj)") + .arg(exportMacro, finalizerName(metaClass, instantiation)); +} + +QString templateArgs(AbstractMetaType type) +{ + if (!hasType(type)) + return {}; + + QStringList args; + if (type.instantiations().isEmpty()) + return QString(); + + for (auto t : type.instantiations()) { + args << t.name().replace(" ", "_"); + } + + QString result = args.join("_"); + if (!result.isEmpty()) + result = QString("_T_%1_T_").arg(result); + + return result; +} + +QString qualifiedClassName(const AbstractMetaClass *metaClass, + const AbstractMetaType templateInstantiation) +{ + if (!metaClass) + return {}; + + QString name = metaClass->qualifiedCppName(); + if (hasType(templateInstantiation)) + name += templateArgs(templateInstantiation); + + return name; +} + +bool templateArgumentIsPointer(const AbstractMetaType type) +{ + return type.cppSignature().contains("*"); +} + +bool methodReturnsBool(const AbstractMetaFunction *method, AbstractMetaType templateInstantiation) +{ + if (!hasType(templateInstantiation)) + return method->returnsBool(); + + const AbstractMetaType type = method->type(); + if (hasType(type) && type.typeUsagePattern() == AbstractMetaType::TemplateArgument) { + const AbstractMetaType actualType = + Dartagnan::instantiationForTemplateArgument(templateInstantiation, type); + return hasType(actualType) && isBool(actualType); + } else { + return method->returnsBool(); + } +} + +} // namespace ToCConversions diff --git a/src/type_conversions/to_C.h b/src/type_conversions/to_C.h new file mode 100644 index 0000000..e92e310 --- /dev/null +++ b/src/type_conversions/to_C.h @@ -0,0 +1,86 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#pragma once + +#include "dartagnan.h" + +namespace ToCConversions { + +///@brief Returns a string representation of the specified type, in a manner suitable for C +/// Mostly means class pointers are void* +QString type(AbstractMetaType type); + +///@brief Returns the type that the C function should return +/// Mostly means the C function that represents the C++ ctor should return void* +/// and the dtor should return void +QString functionReturnType(const AbstractMetaFunction *func, + const AbstractMetaType templateInstantiation); + +/** + * @brief Return's the function's name in C. This also correspondos to its mangled name in dll/so + * This is the name of the wrapper function (with extern "C") which will call the real C++. + * + * For example, for a static function in a class named POD, in namespace TestTargetNS, it would be + * "c_TestTargetNS__POD__calculateStatic" + */ +QString functionName(const AbstractMetaFunction *func, const AbstractMetaType instantiation = {}, + Dartagnan::FunctionFormatOptions = {}); + +///@brief Returns the C function signature that dart will call +QString functionSignature(const AbstractMetaFunction *func, Dartagnan::FunctionFormatOptions = {}, + AbstractMetaType instantiation = {}); + +QString membersText(const AbstractMetaFunction *func, + Dartagnan::FunctionFormatOptions formatOpts = {}, + const AbstractMetaType instantiation = {}); + +QString membersTextEscaped(const AbstractMetaFunction *func); +QString argumentTypesForSignature(const AbstractMetaFunction *func, + const AbstractMetaType instantiation); +QString registerCallbackFunctionsName(const AbstractMetaClass *metaClass); +QString registerCallbackFunctionSignature(const AbstractMetaClass *metaClass, + Dartagnan::FunctionFormatOptions = {}); + +QString finalizerName(const AbstractMetaClass *metaClass, const AbstractMetaType instantiation); +QString finalizerSignature(const AbstractMetaClass *metaClass, + Dartagnan::FunctionFormatOptions = {}, + const AbstractMetaType instantiation = {}); + +/** + * @brief Returns the dtor's name in C. Example: + * "void c_TestTargetNS__MyBaseClass__destructor(void *);" + */ +QString dtorFunctionName(const AbstractMetaClass *record, const AbstractMetaType instantiation); + +QString argumentCasts(const AbstractMetaFunction *func, Dartagnan::FunctionFormatOptions, + AbstractMetaType instantiation); + +/** + * @brief Returns whether the type is primitive and const, examples: + * "const int" + * "const int &" + */ +bool typeIsPrimitiveConst(AbstractMetaType type); + +/** + * Returns the string representation of the template arguments, suitable for using in a + * ffi function name. + * + * Example Foo would return "int_double" + * + */ +QString templateArgs(AbstractMetaType type); + +QString qualifiedClassName(const AbstractMetaClass *, + const AbstractMetaType templateInstantiation = {}); + +/// @brief Returns whether the specified method returns a bool +bool methodReturnsBool(const AbstractMetaFunction *method, AbstractMetaType templateInstantiation); + +/// @brief "const T *" +bool templateArgumentIsPointer(AbstractMetaType type); + +} // namespace ToCConversions diff --git a/src/type_conversions/to_CppWrapper.cpp b/src/type_conversions/to_CppWrapper.cpp new file mode 100644 index 0000000..71132ae --- /dev/null +++ b/src/type_conversions/to_CppWrapper.cpp @@ -0,0 +1,276 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#include "to_CppWrapper.h" +#include "generator_base.h" +#include "typedatabase.h" + +#include + +using namespace Dartagnan; + +namespace ToCppWrapperConversions { + +QString type(const AbstractMetaFunction *func) +{ + if (hasType(func->type())) { + return type(func->type()); + } + + if (func->isConstructor() || func->isDestructor()) + return {}; + + return "void"; +} + +bool isValueClass(AbstractMetaType type) +{ + if (!hasType(type)) + return false; + + if (type.isValue()) { + return true; + } + + return false; +} + +QString type(AbstractMetaType t, AbstractMetaType templateInstantiation, + const AbstractMetaClass *protecedEnumWorkaroundFor, Options options) +{ + if (protecedEnumWorkaroundFor && hasType(t) && t.isEnum()) { + AbstractMetaEnum metaEnum = enumForType(t); + if (metaEnum.typeEntry() && metaEnum.isProtected()) { + // For the C function to access a protected enum, we need to qualify it with + // the wrapper's name, as there we redeclared it as public + return QString("%1::%2").arg( + ToCppWrapperConversions::wrapperClassName(protecedEnumWorkaroundFor), + metaEnum.name()); + } + } + + QString star; + if ((options & Option::ForVirtualCallbackReturnType) && isValueClass(t) + && !t.cppSignature().contains("&")) { + // Our virtual callbacks return ffi.Pointer for value types, so suffix our + // function typedef return type with * + star = "*"; + }; + + if (!hasType(templateInstantiation)) + return t.cppSignature() + star; + + if (t.typeUsagePattern() == AbstractMetaType::TemplateArgument) { + // Means the function returns for example T + + AbstractMetaType actualtype = instantiationForTemplateArgument(templateInstantiation, t); + + return type(actualtype); + + } else if (t.hasInstantiations() && t.hasTemplateChildren()) { + // This means it's return Foo, we need to replace T with the actual instantiated type + + // Get the class, for example MyTemplate + return instantiationsTextForTemplateArguments(templateInstantiation, t, + TemplateFormatOption::IncludeClassName); + } + + return t.cppSignature(); +} + +QString returnType(const AbstractMetaFunction *func, AbstractMetaType templateInstantiation, + ToCppWrapperConversions::Options options) +{ + if (func->isConstructor() || func->isDestructor()) + return {}; + + auto t = func->type(); + if (hasType(t)) + return type(t, templateInstantiation, nullptr, options); + + return "void"; +} + +QString arguments(const AbstractMetaFunction *func, FunctionFormatOptions formatOpts, + Options options) +{ + QStringList result; + + const auto arguments = func->arguments(); + for (AbstractMetaArgument argument : arguments) { + QString defaultArgumentExpression; + if ((formatOpts & FunctionFormatOption::DefaultArgumentExpr) + && argument.hasDefaultValueExpression()) + defaultArgumentExpression = QString(" = %1").arg(argument.defaultValueExpression()); + + result << QStringLiteral("%1 %2%3").arg(type(argument.type(), {}, {}, options), + argument.name(), defaultArgumentExpression); + } + + return result.join(','); +} + +QString callArguments(const AbstractMetaFunction *func, Dartagnan::GeneratedCodeType loc, + AbstractMetaType instantiation) +{ + QStringList result; + if (loc == Dartagnan::GeneratedCodeType_CppwrapperVirtualCallback) { + result << "const_cast(thisPtr)"; + } + + for (AbstractMetaArgument arg : func->arguments()) { + QString argText; + if (arg.type().isEnum() && (loc & Dartagnan::GeneratedCodeType_FFI_C)) { + argText = QStringLiteral("static_cast<%1>(%2)") + .arg(type(arg.type(), instantiation, func->ownerClass()), arg.name()); + } else if (loc == Dartagnan::GeneratedCodeType_CppwrapperVirtualCallback + && arg.type().isValue() && !arg.type().cppSignature().contains("&")) { + argText = QString("&%1").arg(arg.name()); + } else { + argText = arg.name(); + } + + result << argText; + } + + return result.join(','); +} + +QString qualifiedWrapperMethodName(const AbstractMetaFunction *func, + Dartagnan::FunctionFormatOptions formatOpts, + AbstractMetaType instantiation) +{ + Q_ASSERT(func); + return QString("%1::%2") + .arg(wrapperClassName(func->ownerClass(), formatOpts, instantiation)) + .arg(func->originalName()); +} + +QString wrappersNamespace() +{ + return TypeDatabase::instance()->defaultPackageName() + "_wrappersNS"; +} + +QString wrapperClassName(const AbstractMetaClass *metaClass, + Dartagnan::FunctionFormatOptions formatOpts, + AbstractMetaType instantiation) +{ + if (!metaClass) + return QString(); + + if (metaClass->isNamespace()) { + // For global functions, our C wrappers call the target functions directly, without + // wrapper C++ classes. + return metaClass->name(); + } else { + + const QString scope = DartagnanGeneratorBase::m_optionsFromJson.scopeForType(metaClass); + + QString name = scope.isEmpty() + ? QStringLiteral("%1::%2").arg(wrappersNamespace(), wrapperName(metaClass)) + : QStringLiteral("%1::%2::%3").arg(wrappersNamespace(), scope, wrapperName(metaClass)); + + if (formatOpts & FunctionFormatOption::TemplateArgs) { + name = name + templateArgs(metaClass); + } else if (hasType(instantiation) && (formatOpts & FunctionFormatOption::TemplateParams)) { + name = name + templateParams(instantiation); + } + + return name; + } +} + +QString wrapperName(const AbstractMetaClass *metaClass, Dartagnan::FunctionFormatOptions formatOpts) +{ + QString name = metaClass->name() + "_wrapper"; + + if (formatOpts & FunctionFormatOption::TemplateArgs) + name = name + templateArgs(metaClass); + + return name; +} + +QString wrapperMethodName(const AbstractMetaFunction *func) +{ + if (func->isConstructor() | func->isDestructor()) + return wrapperName(func->ownerClass()); + + return func->originalName(); +} + +QString virtualCallbackFunctionPointer(const AbstractMetaFunction *func, const QString &name) +{ + QString args = + ToCppWrapperConversions::arguments(func, {}, Option::ForVirtualCallbackReturnType); + if (args.isEmpty()) + args = "void *"; + else + args.prepend("void *,"); + + return QString("%1 (*%2)(%3)") + .arg(ToCppWrapperConversions::returnType(func, {}, Option::ForVirtualCallbackReturnType), + name, args); +} + +QString virtualCallbackMemberName(const AbstractMetaFunction *func) +{ + return QString("m_%1Callback").arg(DartOverloadRegistry::instance().nameForMethod(func)); +} + +QString virtualCallbackTypedefName(const AbstractMetaFunction *func) +{ + return QString("Callback_%1").arg(DartOverloadRegistry::instance().nameForMethod(func)); +} + +QString templateString(const AbstractMetaClass *metaClass) +{ + const int numTemplateArgs = metaClass->templateArguments().size(); + if (numTemplateArgs == 0) + return {}; + + QStringList args; + for (auto templateArg : metaClass->templateArguments()) + args << QString("typename %1").arg(templateArg->name()); + + return QString("template <%1>").arg(args.join(",")); +} + +QString templateArgs(const AbstractMetaClass *metaClass) +{ + const int numTemplateArgs = metaClass->templateArguments().size(); + if (numTemplateArgs == 0) + return {}; + + QStringList args; + for (auto templateArg : metaClass->templateArguments()) { + args << templateArg->name(); + } + + return QString("<%1>").arg(args.join(",")); +} + +QString templateParams(AbstractMetaType type) +{ + if (!hasType(type) || type.instantiations().isEmpty()) + return {}; + + QStringList args; + for (AbstractMetaType instantiation : type.instantiations()) { + args << instantiation.cppSignature(); + } + + return QString("<%1>").arg(args.join(",")); +} + +QString qualifiedClassName(const AbstractMetaClass *metaClass, FunctionFormatOptions formatOpts) +{ + QString name = metaClass->qualifiedCppName(); + if (formatOpts & FunctionFormatOption::TemplateArgs) + name = name + templateArgs(metaClass); + + return name; +} + +} // namespace ToCppWrapperConversions diff --git a/src/type_conversions/to_CppWrapper.h b/src/type_conversions/to_CppWrapper.h new file mode 100644 index 0000000..13b60d6 --- /dev/null +++ b/src/type_conversions/to_CppWrapper.h @@ -0,0 +1,78 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#pragma once + +#include "dartagnan.h" + +namespace ToCppWrapperConversions { + +enum class Option +{ + None = 0, + ForVirtualCallbackReturnType = 1 +}; +Q_DECLARE_FLAGS(Options, Option); + +/// @brief Returns the C++ return type for @p func +QString returnType(const AbstractMetaFunction *func, AbstractMetaType templateInstantiation = {}, + Options = {}); + +/// @brief Returns the C++ type for @p func +QString type(const AbstractMetaFunction *func); +QString type(AbstractMetaType type, AbstractMetaType templateInstantiation = {}, + const AbstractMetaClass *protecedEnumWorkaroundFor = nullptr, Options = {}); + +/// @brief Returns a string representation of the functions members +/// For example "int width, int height" +QString arguments(const AbstractMetaFunction *func, Dartagnan::FunctionFormatOptions = {}, + Options = {}); + +///@brief Returns the string representation of the arguments to be passed during a C++ call to @p +/// func For example, if func is resize(width, height), the result would be: "width, height" +///@sa cCallArguments() +QString callArguments(const AbstractMetaFunction *func, Dartagnan::GeneratedCodeType, + AbstractMetaType instantiation); + +QString wrapperClassName(const AbstractMetaClass *, Dartagnan::FunctionFormatOptions = {}, + AbstractMetaType instantiation = {}); + +QString qualifiedWrapperMethodName(const AbstractMetaFunction *, + Dartagnan::FunctionFormatOptions formatOpts, + AbstractMetaType instantiation); + +/** + * @brief Returns the name of the wrapper C++ class. + * For example, if the target is QWidget, the return is "QWidget_wrapper" + */ +QString wrapperName(const AbstractMetaClass *, Dartagnan::FunctionFormatOptions = {}); +QString wrapperMethodName(const AbstractMetaFunction *func); + +QString wrappersNamespace(); + +/// @brief Returns a C++ function pointer representation in string +QString virtualCallbackFunctionPointer(const AbstractMetaFunction *func, const QString &name); + +QString virtualCallbackMemberName(const AbstractMetaFunction *); +QString virtualCallbackTypedefName(const AbstractMetaFunction *); + +/// Returns, for example "template ", if the specied class is a template. +/// Empty if no template arguments +QString templateString(const AbstractMetaClass *); + +/// Returns, for example "", if the specied class is a template with one argument +/// Empty if no template arguments +QString templateArgs(const AbstractMetaClass *); + +/// Returns the template params, for example "" +QString templateParams(AbstractMetaType type); + +QString qualifiedClassName(const AbstractMetaClass *, Dartagnan::FunctionFormatOptions formatOpts); + +/// @brief Returns whether the type is a class/struct and is not a pointer +bool isValueClass(AbstractMetaType type); + + +} // namespace ToCppWrapperConversions diff --git a/src/type_conversions/to_dart.cpp b/src/type_conversions/to_dart.cpp new file mode 100644 index 0000000..166ffed --- /dev/null +++ b/src/type_conversions/to_dart.cpp @@ -0,0 +1,527 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#include "to_dart.h" +#include "dartagnan.h" +#include "generator_dart.h" +#include "to_C.h" +#include "to_CppWrapper.h" + +#include + +using namespace Dartagnan; + +QString ToDartConversions::type(AbstractMetaType t, Options options) +{ + const bool isForTypedef = options & Option::ForTypedef; + const bool isForTypedefName = options & Option::ForTypedefName; + + if (hasType(t) && t.isFlags()) + return "int"; + + if (isForTypedef) { + if (!hasType(t)) + return "void"; + + if (t.name() == "char" && t.isPrimitive()) + return isForTypedefName ? "char" : "int"; + + if (type(t) == "String") + return "ffi.Pointer"; + + if (t.isObject() || t.isValue() || t.isValuePointer()) { + // classes are passed as void* in the ffi interface + return "ffi.Pointer"; + } + + if (t.name() == "bool") + return isForTypedefName ? "bool" : "int"; + } + + if (!hasType(t)) + return QString(); + + if (t.isEnum()) { + // TODO: Support enum class with other types of storage + return "int"; + } + + QString scopePrefix; + if (const AbstractMetaClass *metaClass = Dartagnan::classForType(t)) { + const QString scope = DartagnanGeneratorBase::m_optionsFromJson.scopeForType(metaClass); + if (!scope.isEmpty()) + scopePrefix = scope + "."; + } + + + const QString name = scopePrefix + t.name(); + if (name == "int") + return name; + + if (name == "qreal" || name == "float") + return "double"; + + if (name == "qsizetype" || name == "unsigned int" || name == "signed int") + return "int"; + + if (name == "qsizetype" || name == "qint64") + return "int"; + + if ((options & Option::StringInsteadOfQString) && name == "QString") { + // It's nicer to use Dart's String in user code instead of QString + return "String"; + } + + if (name == "char") { + const QString sig = t.cppSignature().replace("const ", "").replace("volatile ", ""); + if (t.isPrimitive()) { + return "String"; + } else if (sig == "char *") { + return "String"; + } else if (sig == "char **") { + return "List"; + } else { + return QString("TODO-MAKE-GENERIC-%1").arg(t.minimalSignature()); + } + } + + // if (t->typeUsagePattern() == AbstractMetaType::TemplateArgument) + // return QString("%1?").arg(name); + + return name; +} + +QString ToDartConversions::typeForFFI(AbstractMetaType t, AbstractMetaType templateInstantiation) +{ + if (t.typeUsagePattern() == AbstractMetaType::TemplateArgument + && hasType(templateInstantiation)) { + // Use the instantiation instead + t = Dartagnan::instantiationForTemplateArgument(templateInstantiation, t); + if (!hasType(t)) { + qWarning() << Q_FUNC_INFO << "Failed to get instantiation type" + << "class instantiation=" << templateInstantiation.cppSignature(); + return {}; + } + } + + const QString dartType = type(t); + + if (t.name() == "char" && t.isPrimitive()) + return "ffi.Int8"; + + if (dartType == "String") + return "ffi.Pointer"; + + if (t.isObject() || t.isValue() || t.isValuePointer()) + return "ffi.Pointer"; + + const QString name = t.name(); + + if (name == "void" || name.isEmpty()) + return "ffi.Void"; + + if (name == "voidstar") + return "ffi.Pointer"; + + if (name == "bool") + return "ffi.Int8"; + + if (dartType == "double") + return "ffi.Double"; + + if (dartType == "int" || t.isEnum()) + return "ffi.Int32"; + + return dartType; +} + +QString ToDartConversions::typeForFFI(const AbstractMetaFunction *func, + AbstractMetaType templateInstantiation) +{ + if (func->isConstructor()) + return "ffi.Pointer"; + + if (hasType(func->type())) + return typeForFFI(func->type(), templateInstantiation); + + return "ffi.Void"; +} + +QString ToDartConversions::mangle(const QString &type) +{ + QString mangled = type; + return mangled.replace("ffi.Pointer", "voidstar") + .replace("ffi.Pointer", "string") + .replace('<', '_') + .replace('>', '_') + .replace('.', '_'); +} + +QString ToDartConversions::type(const AbstractMetaFunction *func, Options options, + AbstractMetaType templateInstantiation) +{ + if (func->isConstructor()) + return "ffi.Pointer"; + + AbstractMetaType t = func->type(); + if (hasType(t) && t.typeUsagePattern() == AbstractMetaType::TemplateArgument) { + AbstractMetaType actuaType = + Dartagnan::instantiationForTemplateArgument(templateInstantiation, t); + return type(actuaType, options); + } else { + return type(func->type(), options); + } +} + +QString ToDartConversions::value(AbstractMetaArgument arg, const QString &value) +{ + if (value == "nullptr") + return "null"; + + if (value == "{}") { + if (arg.type().isEnum() || arg.type().isFlags()) + return "0"; + return "null"; + } + + return value; +} + +QString ToDartConversions::defaultValueExpression(AbstractMetaArgument arg, + const AbstractMetaClass *context) +{ + if (!arg.hasDefaultValueExpression()) + return QString(); + + // For example: { "Qt::UserRole + 1" } + QStringList tokens = arg.defaultValueExpression().split(" "); + + for (QString &token : tokens) { + const QString dartEnumeratorName = + EnumRegistry::instance().dartNameForCppEnumerator(token, context); + if (!dartEnumeratorName.isEmpty()) + token = dartEnumeratorName; + } + + // For example: { "Qt_ItemDataRole.UserRole + 1" } + return tokens.join(" "); +} + +QString ToDartConversions::functionArguments(const AbstractMetaFunction *func, + bool includeDefaultArgumentExpr, Options options) +{ + QStringList arguments; + const AbstractMetaArgumentList args = func->arguments(); + int argsWithDefaultArgumentsCount = 0; + for (AbstractMetaArgument arg : args) { + QString defaultArgumentExpression; + QString required; + QString nullable; + if (includeDefaultArgumentExpr && arg.hasDefaultValueExpression()) { + argsWithDefaultArgumentsCount++; + + const QString defaultExpression = defaultValueExpression(arg, func->ownerClass()); + + if (arg.type().isPrimitive() || arg.type().isEnum() || arg.type().isFlags()) { + defaultArgumentExpression = + QString(" = %1").arg(ToDartConversions::value(arg, defaultExpression)); + } else if (arg.type().isValue() + || arg.type().typeUsagePattern() == AbstractMetaType::TemplateArgument + || arg.type().typeUsagePattern() == AbstractMetaType::ObjectPattern) { + // func(QSize sz = {}) + // Dart doesn't accept default constructible default arguments, so user needs to + // pass it, for now A workaround will be to make it nullable and optional {QSize? + // sz} and in our generated code, assign a default constructed value if null + required = "required "; + } + } + + if (typeIsNullable(arg)) + nullable = "?"; + + QString openBraces; + if (argsWithDefaultArgumentsCount == 1) + openBraces = '{'; + + const QString argName = (options & Option::ReplaceReservedDartKeyword) + ? cleanReservedKeywords(arg.name()) + : arg.name(); + + arguments << QStringLiteral("%1%2%3%4 %5%6") + .arg(openBraces, required, type(arg.type(), options), nullable, argName, + defaultArgumentExpression); + } + + if (argsWithDefaultArgumentsCount > 0) { + // Close brace of optional arguments list + arguments.last() += '}'; + } + + return arguments.join(','); +} + +QString ToDartConversions::scopedNameForType(const AbstractMetaClass *metaClass) +{ + const QString scope = DartagnanGeneratorBase::m_optionsFromJson.scopeForType(metaClass); + if (scope.isEmpty()) + return metaClass->name(); + return QStringLiteral("%1.%2").arg(scope, metaClass->name()); +} + +QString ToDartConversions::directCallArguments(const AbstractMetaFunction *func) +{ + QStringList arguments; + + const AbstractMetaArgumentList args = func->arguments(); + for (int i = 0; i < args.size(); ++i) { + AbstractMetaArgument arg = args[i]; + QString argumentStr; + if (type(arg.type(), Option::ForTypedef) == "ffi.Pointer") { + if (auto metaClass = Dartagnan::classForType(arg.type())) { + if (metaClass->name() == "QString") { + argumentStr = QString("%1.fromCppPointer(%2).toDartString()") + .arg(scopedNameForType(metaClass), arg.name()); + } else if (arg.type().isValue()) { + argumentStr = QString("%1.fromCppPointer(%2)") + .arg(scopedNameForType(metaClass), arg.name()); + } else { + argumentStr = + QString("(%1 == null || %1.address == 0) ? null : %2.fromCppPointer(%3)") + .arg(arg.name(), scopedNameForType(metaClass), arg.name()); + } + } else { + argumentStr = QString("ERROR, no class found for type %1").arg(arg.type().name()); + } + + } else if (isBool(arg.type())) { + argumentStr = QString("%1 != 0").arg(arg.name()); + } else if (arg.type().name() == "char") { + argumentStr = arg.name() + ".toString()"; + } else { + argumentStr = arg.name(); + } + + if (arg.hasDefaultValueExpression()) { + // Argument is optional, we used the named syntax, which is nicer for the user + + QString argName = arg.name(); + + + if (func->isVirtual()) { + + /// Take care of virtual functions in the base class having different argument names + /// than the derived In dart we need to use the argument names of the base method, + /// as we don't overload on the derived dart class + + auto func_ = Dartagnan::baseMethodForFunction(func); + auto arg_ = func_->arguments()[i]; + argName = arg_.name(); + } + + argumentStr = QString("%1 : %2").arg(argName, argumentStr); + } + + arguments << argumentStr; + } + + return arguments.join(','); +} + +QString ToDartConversions::callArguments(const AbstractMetaFunction *func, + AbstractMetaType templateInstantiation) +{ + QStringList arguments; + + if (!func->isStatic() && !func->isConstructor() && func->ownerClass()) + arguments << "thisCpp"; + + const AbstractMetaArgumentList args = func->arguments(); + for (AbstractMetaArgument arg : args) { + arguments << callArgument(arg, templateInstantiation); + } + + return arguments.join(','); +} + +QString ToDartConversions::callArgument(AbstractMetaArgument arg, + AbstractMetaType templateInstantiation) +{ + AbstractMetaType actualType = Dartagnan::actualType(arg.type(), templateInstantiation); + const QString dartType = ToDartConversions::type(actualType, Option::StringInsteadOfQString); + + QString argName = cleanReservedKeywords(arg.name()); + if (arg.type().typeUsagePattern() == AbstractMetaType::TemplateArgument) { + const QString typeName = + ToDartConversions::type(actualType, ToDartConversions::Option::StringInsteadOfQString); + argName = QString("(%1 as %2)").arg(argName, typeName); + } + + if (isBool(arg.type())) { + return QString("%1 ? 1 : 0").arg(argName); + } else if (dartType == "String") { + // If it's "const char*" in C++ but String in Dart. + // So can be nullptr. + return typeIsNullable(arg) ? QString("%1?.toNativeUtf8() ?? ffi.nullptr").arg(argName) + : QString("%1.toNativeUtf8()").arg(argName); + } else if (actualType.isObject() || actualType.isValuePointer()) { + return QString("%1 == null ? ffi.nullptr : %2.thisCpp").arg(argName, argName); + } else if (actualType.isValue()) { + return QString("%1 == null ? ffi.nullptr : %2.thisCpp").arg(argName, argName); + } + + return argName; +} + +QString ToDartConversions::enumeratorName(AbstractMetaEnum metaEnum, + const AbstractMetaEnumValue *enumerator) +{ + const AbstractMetaClass *metaClass = metaEnum.enclosingClass(); + if (metaEnum.isAnonymous()) { + if (metaClass) { + return QString("%1.%2").arg(metaClass->name().replace(":", "_"), enumerator->name()); + } else { + return enumerator->name(); + } + } else { + return QString("%1.%2").arg(enumName(metaEnum), enumerator->name()); + } +} + +QString ToDartConversions::enumName(AbstractMetaEnum metaEnum) +{ + if (metaEnum.isAnonymous()) + return QString(); + + const AbstractMetaClass *metaClass = metaEnum.enclosingClass(); + const QString classPrefix = + (metaClass ? (metaClass->name().replace(":", "_") + "_") : QString()); + + return QString("%1%2").arg(classPrefix, metaEnum.name()); +} + +QString ToDartConversions::defaultValueForType(AbstractMetaType t) +{ + const QString dartTypeName = ToDartConversions::type(t); + if (t.isEnum() || dartTypeName == "int" || isBool(t) + || t.typeUsagePattern() == AbstractMetaType::FlagsPattern) + return "0"; + + return "TODO"; +} + +QString ToDartConversions::templateArgs(const AbstractMetaClass *metaClass) +{ + // Impl is the same as the C++ one, so reuse + return ToCppWrapperConversions::templateArgs(metaClass); +} + +QString ToDartConversions::templateParams(AbstractMetaType type) +{ + if (!hasType(type) || type.instantiations().isEmpty()) + return {}; + + QStringList args; + for (AbstractMetaType instantiation : type.instantiations()) { + args << ToDartConversions::type(instantiation); + } + + return QString("<%1>").arg(args.join(",")); +} + +QString ToDartConversions::className(const AbstractMetaClass *metaClass, + AbstractMetaType templateInstantiation, + FunctionFormatOptions opts) +{ + if (!metaClass) + return {}; + + QString name = metaClass->name(); + if (opts & FunctionFormatOption::TemplateArgs) { + name = name += templateArgs(metaClass); + } else if (opts & FunctionFormatOption::TemplateParams) { + name = name += templateParams(templateInstantiation); + } + + if (opts & FunctionFormatOption::QualifiedWithScope) { + const QString scope = DartagnanGeneratorBase::m_optionsFromJson.scopeForType(metaClass); + if (!scope.isEmpty()) + name = QStringLiteral("%1.%2").arg(scope, name); + } + + return name; +} + +QString ToDartConversions::className(AbstractMetaType type, FunctionFormatOptions opts) +{ + const AbstractMetaClass *metaClass = Dartagnan::classForType(type); + if (!metaClass) { + qWarning() << "No class found for type" << type.name() << "Maybe not in bindings_global.h"; + qFatal("Aborting..."); + } + + return className(metaClass, type, opts); +} + +QString ToDartConversions::cFunctionNameText(const AbstractMetaFunction *method) +{ + auto metaClass = method->ownerClass(); + + const QHash> templateHash = + DartGenerator::instance()->templateHash(); + + + const auto list = templateHash.value(metaClass); + if (list.isEmpty() || !metaClass) + return ToCConversions::functionName(method); + + return QString("${getCFunctionName(%1)}").arg(Dartagnan::idForFunction(method)); +} + +QString ToDartConversions::finalizerMemberVariableName(AbstractMetaType templateInstantiation) +{ + return QString("_finalizer%1").arg(ToCConversions::templateArgs(templateInstantiation)); +} + +QString ToDartConversions::returnType(const AbstractMetaFunction *func, + FunctionFormatOptions formatOpts) +{ + AbstractMetaType type = func->type(); + if (type.typeUsagePattern() == AbstractMetaType::TemplateArgument) { + // It's an argument like T. We need to find it's actual instantiation + + return type.name(); + /*const AbstractMetaClass *metaClass = func->ownerClass(); + if (!metaClass || metaClass->isNamespace()) { + qWarning() << Q_FUNC_INFO << "Only class templates supported"; + return {}; + }*/ + + } else { + return className(type, formatOpts); + } +} + +QString ToDartConversions::cleanReservedKeywords(const QString &name) +{ + if (name == QLatin1String("var")) { + return QString("%1_dart").arg(name); + } + + return name; +} + +bool ToDartConversions::typeIsNullable(AbstractMetaArgument arg) +{ + if (arg.defaultValueExpression() == "nullptr") + return true; + + auto type = arg.type(); + if (type.isValuePointer() || type.isNativePointer() || type.isObject()) + return true; + + + + return false; +} diff --git a/src/type_conversions/to_dart.h b/src/type_conversions/to_dart.h new file mode 100644 index 0000000..1ffe8e1 --- /dev/null +++ b/src/type_conversions/to_dart.h @@ -0,0 +1,132 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#pragma once + +#include "dartagnan.h" + +namespace ToDartConversions { + +enum class Option { + None = 0, + ForTypedef = 1, + ForTypedefName = 2, + NoBool = 4, + NoClasses = 8, + StringInsteadOfQString = 16, + ReplaceReservedDartKeyword = 32 /// For example, we don't want arguments named 'var' +}; +Q_DECLARE_FLAGS(Options, Option); + +/** + * @brief Returns the type suitable for an FFI typedef which @p func returns + * + * For example: + * if fun returns "qreal", this returns "double" + * bool -> int + * pointer -> ffi.Pointer + * etc + */ +QString typeForFFI(const AbstractMetaFunction *func, AbstractMetaType templateInstantiation); + +///@overload +QString typeForFFI(AbstractMetaType type, AbstractMetaType templateInstantiation); + +/** + * @brief Returns a string representation of a dart type which corresponds to @p C++ type + * For example, if func returns "qreal" or "float", this function returns "double", which is the + * appropriate dart type. + * + * Another example: + * const char * -> String + */ +QString type(AbstractMetaType type, Options = {}); + +/// @overload +QString type(const AbstractMetaFunction *func, Options = {}, + AbstractMetaType templateInstantiation = {}); + + +/** + * @brief "mangles" a type, mostly replacing special characters like '<' and '>' so we can use it + * for the name of a typedef. + */ +QString mangle(const QString &type); + +/** + * @brief Receives a "C++ value" and returns a "Dart value". + * Example: + * nullptr -> null; + */ +QString value(AbstractMetaArgument, const QString &value); + +/// @brief Returns a string representation of the arguments of a function in dart +/// Example: "int width, int height" +QString functionArguments(const AbstractMetaFunction *func, bool includeDefaultArgumentExpr, + Options options = {}); + +/// @brief Returns a string representing the arguments to be passed to a dart function +/// For example "w, y" +QString callArguments(const AbstractMetaFunction *func, AbstractMetaType templateInstantiation); +QString callArgument(AbstractMetaArgument arg, AbstractMetaType templateInstantiation); + +/// @brief Returns the call arguments without any transformations. +/// example: If the dart function is foo(int a, int b), this returns "a, b" +QString directCallArguments(const AbstractMetaFunction *func); + +// If the class is scoped, returns ., otherwise just +QString scopedNameForType(const AbstractMetaClass *metaClass); + +/// @brief receives a C++ enum and returns what it would be called in Dart +/// example: The QWidget::RenderTarget enum would be QWidget_Enum_RenderTarget +/// Dart has a few limitations: +/// - Doesn't support enums nested inside classes +/// - Enumerators can't have arbitrary values associated, so we cheat and use a class instead +QString enumName(AbstractMetaEnum); + +QString enumeratorName(AbstractMetaEnum metaEnum, const AbstractMetaEnumValue *); + +/// @brief Returns the default type for type t. +/// This is used in Pointer.fromFunction(), which requires a fallback result. +/// TODO: Is this the best way ? Haven't spent more than 2m on this though. +QString defaultValueForType(AbstractMetaType t); + +/// Returns, for example "", if the specied class is a template with one argument +/// Empty if no template arguments +QString templateArgs(const AbstractMetaClass *); + +/// Returns the template params, for example "" +QString templateParams(AbstractMetaType type); + +/// Returns the class name for the specified class. Adds the template arguments if needed +QString className(const AbstractMetaClass *, AbstractMetaType templateInstantiation = {}, + Dartagnan::FunctionFormatOptions = {}); + +/// overload +QString className(AbstractMetaType type, Dartagnan::FunctionFormatOptions = {}); + +/// Returns the function's return type as a QString +QString returnType(const AbstractMetaFunction *func, Dartagnan::FunctionFormatOptions = {}); + +/// Returns the C function name to lookup in dart, example: "c_Foo__constructor" +QString cFunctionNameText(const AbstractMetaFunction *); + +/// Returns the name of the finalizer variable name for example: "_finalizer" +/// if templateInstantiation is not nullptr, then the template arguments are suffixed +QString finalizerMemberVariableName(AbstractMetaType templateInstantiation); + +/// Returns the default value expression for the specified argument +/// For example, if the function is "void func(int arg = 2)", then this +/// function would return "2" +QString defaultValueExpression(AbstractMetaArgument arg, const AbstractMetaClass *context); + +/// Renames reserved dart keywords to something else. We don't want arguments called "var" +QString cleanReservedKeywords(const QString &name); + +/// Returns whether the type is nullable +bool typeIsNullable(AbstractMetaArgument type); + + +} // namespace ToDartConversions diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..4def0dc --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,39 @@ +# This file is part of Dartagnan. +# +# SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +# SPDX-License-Identifier: MIT + +cmake_minimum_required(VERSION 3.10) + +project(TestTarget LANGUAGES CXX) + +# Uncomment once Qt bindings are exported too +# set(CMAKE_CXX_VISIBILITY_PRESET hidden) + +set(SOURCES + test.cpp +) + +set(CMAKE_AUTOMOC ON) + +find_package(Qt6Widgets) + + +# Enables sanitizers +set(ECM_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/ECM/modules/") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake" ${ECM_MODULE_DIR}) +include(ECMEnableSanitizers) + + +# The TestTarget is the client C++ library, which we'll generate bindings for +add_library(TestTarget SHARED ${SOURCES}) + +set_property(TARGET TestTarget PROPERTY CXX_STANDARD 14) + +target_compile_definitions(TestTarget PRIVATE BUILDING_TEST_LIBRARY) +target_include_directories(TestTarget + PUBLIC + $ +) + +target_link_libraries(TestTarget Qt::Widgets) diff --git a/tests/app/bin/main.dart b/tests/app/bin/main.dart new file mode 100644 index 0000000..62f5e72 --- /dev/null +++ b/tests/app/bin/main.dart @@ -0,0 +1,11 @@ +import 'package:DartBindingsTest/Tests.dart'; + +void main(List args) { + runTests(); + + if (args.contains("--symbolization-workaround")) { + Future.delayed(Duration(seconds: 5), () { + throw "Aborting so dart doesn't dlclose the library, otherwise lsan doesn't show readable symbols"; + }); + } +} diff --git a/tests/app/bin/test_leak.dart b/tests/app/bin/test_leak.dart new file mode 100644 index 0000000..0bb7498 --- /dev/null +++ b/tests/app/bin/test_leak.dart @@ -0,0 +1,12 @@ +import 'package:ffi/ffi.dart'; + +void main(List args) { + bool shouldLeak = args.contains("leak") || args.contains("--leak"); + + if (shouldLeak) { + print("Leak!"); + "foo".toNativeUtf8(); + } else { + print("No leak! Pass --leak to leak."); + } +} diff --git a/tests/app/lib/Tests.dart b/tests/app/lib/Tests.dart new file mode 100644 index 0000000..b8ffb63 --- /dev/null +++ b/tests/app/lib/Tests.dart @@ -0,0 +1,429 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +import 'dart:math'; + +import 'package:TestBindings/Bindings.dart' as TestTargetNS; +import 'package:TestBindings/Bindings.dart'; +import 'package:TestBindings/Bindings_ExplicitNamespace1.dart' + as ExplicitNamespace1; +import 'package:TestBindings/Bindings_ExplicitNamespace2.dart' + as ExplicitNamespace2; +import 'package:ffi/ffi.dart'; +import 'package:test/test.dart'; + +class Level3Derived extends TestTargetNS.MyDerivedClass { + int bar() { + return 50; + } + + int virtualInBaseDerivedAndDart() { + return 200; + } +} + +class DartDerived extends TestTargetNS.MyBaseClass { + int bar() { + // overrides MyBaseClass.bar() + return 100; + } + + SimpleStruct virtualReturningStruct() { + var s = SimpleStruct(); + s.value = 51; + return s; + } +} + +class DerivedFromPureAbstract extends PureAbstract { + DerivedFromPureAbstract() : super() {} + + int virtualReceivingPointer(SimpleStruct? s) { + if (s == null) return 0; + return 1; + } +} + +class Level3DerivedFromPureAbstract + extends TestTargetNS.DerivedFromPureAbstract { + Level3DerivedFromPureAbstract() : super() {} + Level3DerivedFromPureAbstract.ctor2(int v) : super.ctor2(v) {} + + int foo() { + return 200; + } + + @override + int receivesValueStruct(SimpleStruct s) { + // dereference, to check that it doesn't crash + print(s.value); + return 2; + } +} + +void runTests() { + var mybaseclass = TestTargetNS.MyBaseClass(); + + test('static-method-return-int', () { + expect(TestTargetNS.POD.calculateStatic(), 42); + }); + + test('method-return-int', () { + final result = mybaseclass.foo(); + expect(result, 42); + }); + + test('method-return-bool-false', () { + expect(mybaseclass.getBoolFalse(), false); + }); + + test('method-return-bool-true', () { + expect(mybaseclass.getBoolTrue(), true); + }); + + mybaseclass.hello(); + + /// [const-char] Pass to static + TestTargetNS.MyBaseClass.print("Hello-World"); + + test('POD-pointer-return-int', () { + POD podPtr = POD.returnsPointerToPOD(); + expect(podPtr.calculate(), 6); + podPtr.release(); + }); + + test('POD-ref-return-int', () { + POD podRef = POD.returnsReferenceToPOD(); + expect(podRef.calculate(), 6); + }); + + test('POD-value-return-int', () { + POD podValue = POD.returnsPOD(); + expect(podValue.calculate(), 6000); + }); + + test('POD-value-return-const-ref-int', () { + expect(POD().intByConstRef(), 1); + }); + + test('static-method-returning-const-char-ptr', () { + String actual = TestTargetNS.MyBaseClass.returnsConstChar(); + expect(actual, "Hello"); + }); + + test('method-returning-enum', () { + expect(mybaseclass.receivesEnum(MyBaseClass_MyEnum.MyEnumerator3), 30); + }); + + test('anonymous-enum', () { + expect(MyBaseClass.AnonymousEnumerator1, 1); + expect(MyBaseClass.AnonymousEnumerator2, 2); + expect(MyBaseClass.AnonymousEnumerator3, 3); + }); + + test('namespace-function-returning-namespace-enum', () { + expect(TestTargetNS.namespaceFunctionReturningNamespaceEnum(), + TestTargetNS.TestTargetNS_NameSpaceLevelEnum.NameSpaceLevelEnum_Value); + }); + + test('receives-two-ints', () { + expect(mybaseclass.sum(1, 2), 3); + }); + + test('receives-two-ints', () { + expect(mybaseclass.setBool(true), true); + }); + + test('receives-bool', () { + expect(mybaseclass.setBool(false), false); + }); + + test('returns-QString', () { + expect(TestTargetNS.MyBaseClass.returnsQString().toDartString(), "hello"); + }); + + test('receives-QString', () { + final c = MyBaseClass(); + final QString s = c.receivesAndReturnsQString("hello"); + expect(s.size(), 5); + expect(s.toDartString(), "hello"); + + c.release(); + }); + + test('returns-char', () { + expect(POD.returnsChar(), "c"); + }); + + test('receives-two-pods-by-value', () { + final a = POD(); + final b = POD(); + expect(TestTargetNS.POD.receivesPODs(a, b), 3); + }); + + test('receives-two-pods-by-const-ref', () { + final a = POD(); + final b = POD(); + expect(TestTargetNS.POD.receivesConstRefPODs(a, b), 3); + }); + + test('receives-two-pods-by-ptr', () { + final a = POD(); + final b = POD(); + expect(TestTargetNS.POD.receivesPointerToPODs(a, b), 3); + }); + + test('receives-two-pods-by-const-ptr', () { + final a = POD(); + final b = POD(); + expect(TestTargetNS.POD.receivesConstPointerToPODs(a, b), 3); + }); + + test('receives-two-pods-by-ref', () { + final a = POD(); + final b = POD(); + expect(TestTargetNS.POD.receivesRefPODs(a, b), 20); + expect(a.v1, 10); + }); + + test('read-int-members', () { + final a = POD(); + expect(a.v1, 1); + expect(a.v2, 2); + expect(a.v3, 3); + expect(a.v4_const, 4); + }); + + test('read-set-int-members', () { + final a = POD(); + expect(a.v1, 1); + final int newValue = 41; + a.v1 = newValue; + expect(a.v1, newValue); + }); + + test('namespace-level-function', () { + expect(TestTargetNS.namespaceLevelGlobalFunction(), 41); + }); + + test('global-enum', () { + expect(GlobalEnum.GlobalEnum_Value, 30); + }); + + test('globalFunction', () { + expect(globalFunction(), 42); + }); + + test('virtual-derived-in-dart', () { + var dartDerived = DartDerived(); + expect(dartDerived.callsVirtual(), 100); + SimpleStruct simpleStruct = dartDerived.nonVirtualReturningStruct(); + expect(simpleStruct.value, 51); + dartDerived.release(); + }); + test('virtual-returning-bool', () { + expect(mybaseclass.virtualReturningBool(true), true); + expect(mybaseclass.virtualReturningBool(false), false); + }); + + test('function-returns-pure-virtual', () { + TestTargetNS.PureAbstract abstract = TestTargetNS.returnsPureAbstract(); + expect(abstract.foo(), 42); + expect(receivingPureAbstract(abstract), 42); + abstract.release(); + }); + + test('virtuals-calling-themselves-in-infinit-loop', () { + var derived = MyDerivedClass(); + derived.show(); // Would crash before. + expect(true, true); + derived.release(); + }); + + test('virtual-with-optional-arg', () { + expect(mybaseclass.virtualReceivingOptionalArgument(optional: 10), 10); + }); + + test('instance-created-in-cpp', () { + // The C++ creates a new MyDerivedClass and passes it by argument. + // Dart's fromCache() will fail and it will create a dart wrapper instance + var derived = MyDerivedClass(); + expect(derived.alsoCallsVirtual(), 10); + derived.release(); + }); + + test('static-member', () { + // Tests that classes can have static members and they work + expect(MyBaseClass.s_staticMember, 1); + MyBaseClass.s_staticMember = 10; + expect(MyBaseClass.s_staticMember, 10); + }); + + test('destructors-are-called', () { + // 1. Allocate in C++ and release manually in dart + expect(DestructorCounter.s_instanceCount, 0); + var instance = DestructorCounter.newOnTheHeap(); + expect(DestructorCounter.s_instanceCount, 1); + instance.release(); + expect(DestructorCounter.s_instanceCount, 0); + DestructorCounter.newOnTheStack(); + expect(DestructorCounter.s_instanceCount, 1); + + final anotherInstance = DestructorCounter(); + expect(DestructorCounter.s_instanceCount, 2); + +// Gets to 0 when the isolate shutsdown + }); + + test("template", () { + var intTemplate = TestTargetNS.MyTemplate(); + expect(intTemplate.returnInt(), 1); + }); + + test("template-with-two-args", () { + var t = TestTargetNS.MyTemplateWithTwoArgs(); + expect(t.returnInt(), 1); + }); + + test("template-with-template-receiving-template", () { + var t = MyTemplate(); + expect(t.receivesTemplate(t), 30); + }); + + test("returns-QList", () { + final vector = mybaseclass.returnsVector(); + expect(vector.size(), 3); + // expect(vector.contains(2), true); TODO + vector.clear(); + expect(vector.size(), 0); + expect(vector.isEmpty(), true); + // expect(vector.contains(2), false); TODO + + for (int i = 0; i < vector.size(); ++i) { + expect(vector.at(i), i + 1); + } + }); + + test("returns-template-argument-as-ptr", () { + // Tests that QList::at works if T is a pointer. We had a crash regarding this. + final list = MyBaseClass.returnsListOfStructPtr(); + final SimpleStruct s = list.at(0); + expect(s.value, 1); + s.release(); + }); + + test("signal-handler", () { + var obj = MyObject(parent: null); + bool signalReceived = false; + obj.onValueChanged(() { + signalReceived = true; + }); + obj.valueChanged(5); + expect(signalReceived, true); + obj.release(); + }); + + test('StructAsDefaultArg', () { + var s = SimpleObjectStruct(); + s.receivesStructWithDefaultArg(arg__1: s); + }); + + test('ctor-pointer-arg-is-nullable', () { + var c = MyBaseClass.ctor2(null); + c.release(); + }); + + test('overridden-non-virtual', () { + var derived = MyDerivedClass(); + expect(mybaseclass.nonVirtualButOverridden(), 1); + expect(derived.nonVirtualButOverridden(), 2); + derived.release(); + }); + + test('derived-from-abstract-class', () { + var v = DerivedFromPureAbstract(); + expect(v.returnsInt(), 5); + + expect(v.callVirtualReceivingPointer(null), 0); + + v.release(); + }); + + test('protected-enum', () { + var derived = MyDerivedClass(); + expect(derived.receivesProtectedEnum(1), 1); + derived.release(); + }); + + test('injected-method', () { + // Tests that we can do an =3.0.0 <4.0.0" diff --git a/tests/app/pubspec.yaml b/tests/app/pubspec.yaml new file mode 100644 index 0000000..ecb2cad --- /dev/null +++ b/tests/app/pubspec.yaml @@ -0,0 +1,17 @@ +name: DartBindingsTest +description: A test app to test the dart bindings +# version: 1.0.0 +# homepage: https://www.example.com + +environment: + sdk: '>=2.17.0 <3.0.0' + +dependencies: + test: + TestBindings: + path: '../generated/TestBindings/dart/' + ffi: ^2.1.0 + +dev_dependencies: + pedantic: ^1.9.0 + diff --git a/tests/bindings_global.h b/tests/bindings_global.h new file mode 100644 index 0000000..df9fc2d --- /dev/null +++ b/tests/bindings_global.h @@ -0,0 +1,16 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#include "test.h" + +#include +#include +#include +#include + +#include +#include + +#include diff --git a/tests/dartagnan.json b/tests/dartagnan.json new file mode 100644 index 0000000..fb9f157 --- /dev/null +++ b/tests/dartagnan.json @@ -0,0 +1,20 @@ +{ + "target_link_libraries": "TestTarget", + "pureVirtualClassOverrides": [ + "PureAbstractWithUnknownType" + ], + "namespaces": [ + { + "name": "ExplicitNamespace1", + "types": [ + "NameClashingNS1::SimpleClash" + ] + }, + { + "name": "ExplicitNamespace2", + "types": [ + "NameClashingNS2::SimpleClash" + ] + } + ] +} \ No newline at end of file diff --git a/tests/generated/CMakeLists.txt b/tests/generated/CMakeLists.txt new file mode 100644 index 0000000..bec0a71 --- /dev/null +++ b/tests/generated/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.10) + +project(MyBindings LANGUAGES CXX) + + +set(ECM_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/ECM/modules/") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../../cmake" ${ECM_MODULE_DIR}) +include(ECMEnableSanitizers) + +include_directories(..) +link_directories(${CMAKE_BINARY_DIR}/..) + +add_subdirectory(TestBindings/) diff --git a/tests/generated/TestBindings/CMakeLists.txt b/tests/generated/TestBindings/CMakeLists.txt new file mode 100644 index 0000000..a0d2432 --- /dev/null +++ b/tests/generated/TestBindings/CMakeLists.txt @@ -0,0 +1,69 @@ +cmake_minimum_required(VERSION 3.10) + +project(TestBindings LANGUAGES CXX) + +set(SOURCES + dart/ffi/Virtual2_c.cpp + dart/ffi/Virtual1_c.cpp + dart/ffi/UnusedTemplate_c.cpp + dart/ffi/TestTargetNS_c.cpp + dart/ffi/PureAbstract_c.cpp + dart/ffi/POD_c.cpp + dart/ffi/StructWithStructAsMember_c.cpp + dart/ffi/MyBaseClass_c.cpp + dart/ffi/MyDerivedClass_c.cpp + dart/ffi/DestructorCounter_c.cpp + dart/ffi/DerivedFromPureAbstract_c.cpp + dart/ffi/Derived2FromPureAbstract_c.cpp + dart/ffi/SimpleStruct_c.cpp + dart/ffi/SimpleObjectStruct_c.cpp + dart/ffi/Qt_c.cpp + dart/ffi/QVariant_c.cpp + dart/ffi/QString_c.cpp + dart/ffi/QSet_c.cpp + dart/ffi/QObject_c.cpp + dart/ffi/QMap_c.cpp + dart/ffi/QList_c.cpp + dart/ffi/QHash_c.cpp + dart/ffi/QEvent_c.cpp + dart/ffi/QCoreApplication_c.cpp + dart/ffi/QGuiApplication_c.cpp + dart/ffi/QColor_c.cpp + dart/ffi/QByteArray_c.cpp + dart/ffi/QApplication_c.cpp + dart/ffi/PureAbstractWithUnknownType_c.cpp + dart/ffi/NonCopiable_c.cpp + dart/ffi/NameClashingNS2_c.cpp + dart/ffi/ExplicitNamespace2/SimpleClash_c.cpp + dart/ffi/NameClashingNS1_c.cpp + dart/ffi/ExplicitNamespace1/SimpleClash_c.cpp + dart/ffi/MyTemplateWithTwoArgs_c.cpp + dart/ffi/MyTemplate2_c.cpp + dart/ffi/MyTemplate_c.cpp + dart/ffi/MyObject_c.cpp + dart/ffi/EmptyStruct_c.cpp + dart/ffi/EmptyNameSpace_c.cpp + dart/ffi/DoubleInheritanceFromVirtuals_c.cpp + dart/ffi/DoubleInheritance_c.cpp + dart/ffi/Cyclic1_c.cpp + dart/ffi/Cyclic2_c.cpp + dart/ffi/BaseClassWithFinalMethod_c.cpp + dart/ffi/AnotherNamespace_c.cpp + dart/ffi/AnotherNamespaceStruct_c.cpp + dart/ffi/TestBindings.cpp +) + +set(CMAKE_CXX_VISIBILITY_PRESET hidden) + +find_package(Qt6Widgets) + +add_library(TestBindings SHARED ${SOURCES}) + +include(GenerateExportHeader) +generate_export_header(TestBindings EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/TestBindings_exports.h" EXPORT_MACRO_NAME TestBindings_EXPORT) +set_property(TARGET TestBindings PROPERTY CXX_STANDARD 14) + +target_link_libraries(TestBindings TestTarget Qt6::Core Qt6::Widgets) +target_include_directories(TestBindings PUBLIC $ $ +$) + diff --git a/tests/generated/TestBindings/dart/ffi/AnotherNamespaceStruct_c.cpp b/tests/generated/TestBindings/dart/ffi/AnotherNamespaceStruct_c.cpp new file mode 100644 index 0000000..78a0a99 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/AnotherNamespaceStruct_c.cpp @@ -0,0 +1,63 @@ +#include "AnotherNamespaceStruct_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +AnotherNamespaceStruct_wrapper::AnotherNamespaceStruct_wrapper() + : ::AnotherNamespace::AnotherNamespaceStruct() +{ +} +void AnotherNamespaceStruct_wrapper::receivesEnumerator(AnotherNamespace::NamespaceLevelEnum arg__1) +{ + ::AnotherNamespace::AnotherNamespaceStruct::receivesEnumerator(arg__1); +} +AnotherNamespaceStruct_wrapper::~AnotherNamespaceStruct_wrapper() +{ +} + +} +static AnotherNamespace::AnotherNamespaceStruct *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::AnotherNamespaceStruct_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_AnotherNamespace__AnotherNamespaceStruct_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} +void *c_AnotherNamespace__AnotherNamespaceStruct__constructor() +{ + auto ptr = new TestBindings_wrappersNS::AnotherNamespaceStruct_wrapper(); + return reinterpret_cast(ptr); +} +// receivesEnumerator(AnotherNamespace::NamespaceLevelEnum arg__1) +void c_AnotherNamespace__AnotherNamespaceStruct__receivesEnumerator_NamespaceLevelEnum( + void *thisObj, int arg__1) +{ + fromPtr(thisObj)->receivesEnumerator(static_cast(arg__1)); +} +void c_AnotherNamespace__AnotherNamespaceStruct__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} diff --git a/tests/generated/TestBindings/dart/ffi/AnotherNamespaceStruct_c.h b/tests/generated/TestBindings/dart/ffi/AnotherNamespaceStruct_c.h new file mode 100644 index 0000000..f8143d0 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/AnotherNamespaceStruct_c.h @@ -0,0 +1,24 @@ +#include "TestBindings_exports.h" +#include + +namespace TestBindings_wrappersNS { +class AnotherNamespaceStruct_wrapper : public ::AnotherNamespace::AnotherNamespaceStruct +{ +public: + ~AnotherNamespaceStruct_wrapper(); + AnotherNamespaceStruct_wrapper(); + void receivesEnumerator(AnotherNamespace::NamespaceLevelEnum arg__1 = + AnotherNamespace::NamespaceLevelEnum::NamespaceLevelEnum_value2); +}; +} +extern "C" { +// AnotherNamespace::AnotherNamespaceStruct::AnotherNamespaceStruct() +TestBindings_EXPORT void *c_AnotherNamespace__AnotherNamespaceStruct__constructor(); +// AnotherNamespace::AnotherNamespaceStruct::receivesEnumerator(AnotherNamespace::NamespaceLevelEnum +// arg__1) +TestBindings_EXPORT void +c_AnotherNamespace__AnotherNamespaceStruct__receivesEnumerator_NamespaceLevelEnum(void *thisObj, + int arg__1); +TestBindings_EXPORT void c_AnotherNamespace__AnotherNamespaceStruct__destructor(void *thisObj); +TestBindings_EXPORT void c_AnotherNamespace__AnotherNamespaceStruct_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/AnotherNamespace_c.cpp b/tests/generated/TestBindings/dart/ffi/AnotherNamespace_c.cpp new file mode 100644 index 0000000..5ee9d2c --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/AnotherNamespace_c.cpp @@ -0,0 +1,30 @@ +#include "AnotherNamespace_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +extern "C" { +// size(QString s) +void *c_static_AnotherNamespace__size_QString(const char *s_) +{ + const auto s = QString::fromUtf8(s_); + const auto &result = new Dartagnan::ValueWrapper { AnotherNamespace::size(s) }; + free(( char * )s_); + return result; +} +} diff --git a/tests/generated/TestBindings/dart/ffi/AnotherNamespace_c.h b/tests/generated/TestBindings/dart/ffi/AnotherNamespace_c.h new file mode 100644 index 0000000..18e4b9b --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/AnotherNamespace_c.h @@ -0,0 +1,9 @@ +#include "TestBindings_exports.h" +#include +#include + +extern "C" { +// AnotherNamespace::size(QString s) +TestBindings_EXPORT void *c_static_AnotherNamespace__size_QString(const char *s_); +TestBindings_EXPORT void c_AnotherNamespace_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/BaseClassWithFinalMethod_c.cpp b/tests/generated/TestBindings/dart/ffi/BaseClassWithFinalMethod_c.cpp new file mode 100644 index 0000000..7f08e3a --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/BaseClassWithFinalMethod_c.cpp @@ -0,0 +1,70 @@ +#include "BaseClassWithFinalMethod_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +BaseClassWithFinalMethod_wrapper::BaseClassWithFinalMethod_wrapper() + : ::BaseClassWithFinalMethod() +{ +} +BaseClassWithFinalMethod_wrapper::~BaseClassWithFinalMethod_wrapper() +{ +} + +} +static BaseClassWithFinalMethod *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::BaseClassWithFinalMethod_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_BaseClassWithFinalMethod_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} +void *c_BaseClassWithFinalMethod__constructor() +{ + auto ptr = new TestBindings_wrappersNS::BaseClassWithFinalMethod_wrapper(); + return reinterpret_cast(ptr); +} +// finalMethod() +void c_BaseClassWithFinalMethod__finalMethod(void *thisObj) +{ + fromPtr(thisObj)->finalMethod(); +} +void c_BaseClassWithFinalMethod__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +void c_BaseClassWithFinalMethod__registerVirtualMethodCallback(void *ptr, void *callback, + int methodId) +{ + auto wrapper = fromWrapperPtr(ptr); + switch (methodId) { + case 1200: + wrapper->m_finalMethodCallback = reinterpret_cast< + TestBindings_wrappersNS::BaseClassWithFinalMethod_wrapper::Callback_finalMethod>( + callback); + break; + } +} +} diff --git a/tests/generated/TestBindings/dart/ffi/BaseClassWithFinalMethod_c.h b/tests/generated/TestBindings/dart/ffi/BaseClassWithFinalMethod_c.h new file mode 100644 index 0000000..7e33e9d --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/BaseClassWithFinalMethod_c.h @@ -0,0 +1,23 @@ +#include "TestBindings_exports.h" +#include + +namespace TestBindings_wrappersNS { +class BaseClassWithFinalMethod_wrapper : public ::BaseClassWithFinalMethod +{ +public: + ~BaseClassWithFinalMethod_wrapper(); + BaseClassWithFinalMethod_wrapper(); + typedef void (*Callback_finalMethod)(void *); + Callback_finalMethod m_finalMethodCallback = nullptr; +}; +} +extern "C" { +// BaseClassWithFinalMethod::BaseClassWithFinalMethod() +TestBindings_EXPORT void *c_BaseClassWithFinalMethod__constructor(); +// BaseClassWithFinalMethod::finalMethod() +TestBindings_EXPORT void c_BaseClassWithFinalMethod__finalMethod(void *thisObj); +TestBindings_EXPORT void c_BaseClassWithFinalMethod__destructor(void *thisObj); +TestBindings_EXPORT void +c_BaseClassWithFinalMethod__registerVirtualMethodCallback(void *ptr, void *callback, int methodId); +TestBindings_EXPORT void c_BaseClassWithFinalMethod_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/Cyclic1_c.cpp b/tests/generated/TestBindings/dart/ffi/Cyclic1_c.cpp new file mode 100644 index 0000000..48c96d4 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/Cyclic1_c.cpp @@ -0,0 +1,64 @@ +#include "Cyclic1_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +Cyclic1_wrapper::Cyclic1_wrapper(Cyclic2 *arg__1) + : ::Cyclic1(arg__1) +{ +} +Cyclic2 *Cyclic1_wrapper::getCyclic2() const +{ + return ::Cyclic1::getCyclic2(); +} +Cyclic1_wrapper::~Cyclic1_wrapper() +{ +} + +} +static Cyclic1 *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::Cyclic1_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_Cyclic1_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} +void *c_Cyclic1__constructor_Cyclic2(void *arg__1_) +{ + auto arg__1 = reinterpret_cast(arg__1_); + auto ptr = new TestBindings_wrappersNS::Cyclic1_wrapper(arg__1); + return reinterpret_cast(ptr); +} +// getCyclic2() const +void *c_Cyclic1__getCyclic2(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->getCyclic2(); + return result; +} +void c_Cyclic1__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} diff --git a/tests/generated/TestBindings/dart/ffi/Cyclic1_c.h b/tests/generated/TestBindings/dart/ffi/Cyclic1_c.h new file mode 100644 index 0000000..5bdbfd5 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/Cyclic1_c.h @@ -0,0 +1,20 @@ +#include "TestBindings_exports.h" +#include + +namespace TestBindings_wrappersNS { +class Cyclic1_wrapper : public ::Cyclic1 +{ +public: + ~Cyclic1_wrapper(); + Cyclic1_wrapper(Cyclic2 *arg__1); + Cyclic2 *getCyclic2() const; +}; +} +extern "C" { +// Cyclic1::Cyclic1(Cyclic2 * arg__1) +TestBindings_EXPORT void *c_Cyclic1__constructor_Cyclic2(void *arg__1_); +// Cyclic1::getCyclic2() const +TestBindings_EXPORT void *c_Cyclic1__getCyclic2(void *thisObj); +TestBindings_EXPORT void c_Cyclic1__destructor(void *thisObj); +TestBindings_EXPORT void c_Cyclic1_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/Cyclic2_c.cpp b/tests/generated/TestBindings/dart/ffi/Cyclic2_c.cpp new file mode 100644 index 0000000..14c57ba --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/Cyclic2_c.cpp @@ -0,0 +1,53 @@ +#include "Cyclic2_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +Cyclic1 *Cyclic2_wrapper::getCyclic1() const +{ + return ::Cyclic2::getCyclic1(); +} +Cyclic2_wrapper::~Cyclic2_wrapper() +{ +} + +} +static Cyclic2 *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::Cyclic2_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_Cyclic2_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} // getCyclic1() const +void *c_Cyclic2__getCyclic1(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->getCyclic1(); + return result; +} +void c_Cyclic2__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} diff --git a/tests/generated/TestBindings/dart/ffi/Cyclic2_c.h b/tests/generated/TestBindings/dart/ffi/Cyclic2_c.h new file mode 100644 index 0000000..db86aaa --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/Cyclic2_c.h @@ -0,0 +1,17 @@ +#include "TestBindings_exports.h" +#include + +namespace TestBindings_wrappersNS { +class Cyclic2_wrapper : public ::Cyclic2 +{ +public: + ~Cyclic2_wrapper(); + Cyclic1 *getCyclic1() const; +}; +} +extern "C" { +// Cyclic2::getCyclic1() const +TestBindings_EXPORT void *c_Cyclic2__getCyclic1(void *thisObj); +TestBindings_EXPORT void c_Cyclic2__destructor(void *thisObj); +TestBindings_EXPORT void c_Cyclic2_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/Derived2FromPureAbstract_c.cpp b/tests/generated/TestBindings/dart/ffi/Derived2FromPureAbstract_c.cpp new file mode 100644 index 0000000..0d87080 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/Derived2FromPureAbstract_c.cpp @@ -0,0 +1,231 @@ +#include "Derived2FromPureAbstract_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +Derived2FromPureAbstract_wrapper::Derived2FromPureAbstract_wrapper() + : ::TestTargetNS::Derived2FromPureAbstract() +{ +} +int Derived2FromPureAbstract_wrapper::foo() +{ + if (m_fooCallback) { + const void *thisPtr = this; + return m_fooCallback(const_cast(thisPtr)); + } else { + std::cerr << "foo: Warning: Calling pure-virtual\n"; + return {}; + } +} +int Derived2FromPureAbstract_wrapper::foo_nocallback() +{ + std::cerr << "foo: Warning: Calling pure-virtual\n"; + return {}; +} +void Derived2FromPureAbstract_wrapper::renamedPureVirtual() +{ + if (m_renamedPureVirtual1Callback) { + const void *thisPtr = this; + m_renamedPureVirtual1Callback(const_cast(thisPtr)); + } else { + std::cerr << "renamedPureVirtual1: Warning: Calling pure-virtual\n"; + return; + } +} +void Derived2FromPureAbstract_wrapper::renamedPureVirtual_nocallback() +{ + std::cerr << "renamedPureVirtual1: Warning: Calling pure-virtual\n"; + return; +} +void Derived2FromPureAbstract_wrapper::unnamedOverriddenDefaultArgCase(int myarg) +{ + if (m_unnamedOverriddenDefaultArgCaseCallback) { + const void *thisPtr = this; + m_unnamedOverriddenDefaultArgCaseCallback(const_cast(thisPtr), myarg); + } else { + ::TestTargetNS::Derived2FromPureAbstract::unnamedOverriddenDefaultArgCase(myarg); + } +} +void Derived2FromPureAbstract_wrapper::unnamedOverriddenDefaultArgCase_nocallback(int myarg) +{ + ::TestTargetNS::Derived2FromPureAbstract::unnamedOverriddenDefaultArgCase(myarg); +} +int Derived2FromPureAbstract_wrapper::virtualReceivingPointer(SimpleStruct *s) +{ + if (m_virtualReceivingPointerCallback) { + const void *thisPtr = this; + return m_virtualReceivingPointerCallback(const_cast(thisPtr), s); + } else { + return ::TestTargetNS::Derived2FromPureAbstract::virtualReceivingPointer(s); + } +} +int Derived2FromPureAbstract_wrapper::virtualReceivingPointer_nocallback(SimpleStruct *s) +{ + return ::TestTargetNS::Derived2FromPureAbstract::virtualReceivingPointer(s); +} +void Derived2FromPureAbstract_wrapper::voidPureAbstract() +{ + if (m_voidPureAbstractCallback) { + const void *thisPtr = this; + m_voidPureAbstractCallback(const_cast(thisPtr)); + } else { + std::cerr << "voidPureAbstract: Warning: Calling pure-virtual\n"; + return; + } +} +void Derived2FromPureAbstract_wrapper::voidPureAbstract_nocallback() +{ + std::cerr << "voidPureAbstract: Warning: Calling pure-virtual\n"; + return; +} +Derived2FromPureAbstract_wrapper::~Derived2FromPureAbstract_wrapper() +{ +} + +} +static TestTargetNS::Derived2FromPureAbstract *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::Derived2FromPureAbstract_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_TestTargetNS__Derived2FromPureAbstract_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} +void *c_TestTargetNS__Derived2FromPureAbstract__constructor() +{ + auto ptr = new TestBindings_wrappersNS::Derived2FromPureAbstract_wrapper(); + return reinterpret_cast(ptr); +} +// foo() +int c_TestTargetNS__Derived2FromPureAbstract__foo(void *thisObj) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->foo_nocallback(); + } else { + return targetPtr->foo(); + } + }(); + return result; +} +// renamedPureVirtual() +void c_TestTargetNS__Derived2FromPureAbstract__renamedPureVirtual1(void *thisObj) +{ + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->renamedPureVirtual_nocallback(); + } else { + return targetPtr->renamedPureVirtual(); + } + }(); +} +// unnamedOverriddenDefaultArgCase(int myarg) +void c_TestTargetNS__Derived2FromPureAbstract__unnamedOverriddenDefaultArgCase_int(void *thisObj, + int myarg) +{ + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->unnamedOverriddenDefaultArgCase_nocallback(myarg); + } else { + return targetPtr->unnamedOverriddenDefaultArgCase(myarg); + } + }(); +} +// virtualReceivingPointer(SimpleStruct * s) +int c_TestTargetNS__Derived2FromPureAbstract__virtualReceivingPointer_SimpleStruct(void *thisObj, + void *s_) +{ + auto s = reinterpret_cast(s_); + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualReceivingPointer_nocallback(s); + } else { + return targetPtr->virtualReceivingPointer(s); + } + }(); + return result; +} +// voidPureAbstract() +void c_TestTargetNS__Derived2FromPureAbstract__voidPureAbstract(void *thisObj) +{ + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->voidPureAbstract_nocallback(); + } else { + return targetPtr->voidPureAbstract(); + } + }(); +} +void c_TestTargetNS__Derived2FromPureAbstract__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +void c_TestTargetNS__Derived2FromPureAbstract__registerVirtualMethodCallback(void *ptr, + void *callback, + int methodId) +{ + auto wrapper = fromWrapperPtr(ptr); + switch (methodId) { + case 13: + wrapper->m_fooCallback = reinterpret_cast< + TestBindings_wrappersNS::Derived2FromPureAbstract_wrapper::Callback_foo>(callback); + break; + case 14: + wrapper->m_renamedPureVirtual1Callback = + reinterpret_cast(callback); + break; + case 17: + wrapper->m_unnamedOverriddenDefaultArgCaseCallback = + reinterpret_cast(callback); + break; + case 18: + wrapper->m_virtualReceivingPointerCallback = + reinterpret_cast(callback); + break; + case 19: + wrapper->m_voidPureAbstractCallback = reinterpret_cast< + TestBindings_wrappersNS::Derived2FromPureAbstract_wrapper::Callback_voidPureAbstract>( + callback); + break; + } +} +} diff --git a/tests/generated/TestBindings/dart/ffi/Derived2FromPureAbstract_c.h b/tests/generated/TestBindings/dart/ffi/Derived2FromPureAbstract_c.h new file mode 100644 index 0000000..80a37fc --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/Derived2FromPureAbstract_c.h @@ -0,0 +1,55 @@ +#include "TestBindings_exports.h" +#include + +namespace TestBindings_wrappersNS { +class Derived2FromPureAbstract_wrapper : public ::TestTargetNS::Derived2FromPureAbstract +{ +public: + ~Derived2FromPureAbstract_wrapper(); + Derived2FromPureAbstract_wrapper(); + virtual int foo(); + virtual int foo_nocallback(); + virtual void renamedPureVirtual(); + virtual void renamedPureVirtual_nocallback(); + virtual void unnamedOverriddenDefaultArgCase(int myarg = 0); + virtual void unnamedOverriddenDefaultArgCase_nocallback(int myarg = 0); + virtual int virtualReceivingPointer(SimpleStruct *s); + virtual int virtualReceivingPointer_nocallback(SimpleStruct *s); + virtual void voidPureAbstract(); + virtual void voidPureAbstract_nocallback(); + typedef int (*Callback_foo)(void *); + Callback_foo m_fooCallback = nullptr; + typedef void (*Callback_renamedPureVirtual1)(void *); + Callback_renamedPureVirtual1 m_renamedPureVirtual1Callback = nullptr; + typedef void (*Callback_unnamedOverriddenDefaultArgCase)(void *, int myarg); + Callback_unnamedOverriddenDefaultArgCase m_unnamedOverriddenDefaultArgCaseCallback = nullptr; + typedef int (*Callback_virtualReceivingPointer)(void *, SimpleStruct *s); + Callback_virtualReceivingPointer m_virtualReceivingPointerCallback = nullptr; + typedef void (*Callback_voidPureAbstract)(void *); + Callback_voidPureAbstract m_voidPureAbstractCallback = nullptr; +}; +} +extern "C" { +// TestTargetNS::Derived2FromPureAbstract::Derived2FromPureAbstract() +TestBindings_EXPORT void *c_TestTargetNS__Derived2FromPureAbstract__constructor(); +// TestTargetNS::Derived2FromPureAbstract::foo() +TestBindings_EXPORT int c_TestTargetNS__Derived2FromPureAbstract__foo(void *thisObj); +// TestTargetNS::Derived2FromPureAbstract::renamedPureVirtual() +TestBindings_EXPORT void +c_TestTargetNS__Derived2FromPureAbstract__renamedPureVirtual1(void *thisObj); +// TestTargetNS::Derived2FromPureAbstract::unnamedOverriddenDefaultArgCase(int myarg) +TestBindings_EXPORT void +c_TestTargetNS__Derived2FromPureAbstract__unnamedOverriddenDefaultArgCase_int(void *thisObj, + int myarg); +// TestTargetNS::Derived2FromPureAbstract::virtualReceivingPointer(SimpleStruct * s) +TestBindings_EXPORT int +c_TestTargetNS__Derived2FromPureAbstract__virtualReceivingPointer_SimpleStruct(void *thisObj, + void *s_); +// TestTargetNS::Derived2FromPureAbstract::voidPureAbstract() +TestBindings_EXPORT void c_TestTargetNS__Derived2FromPureAbstract__voidPureAbstract(void *thisObj); +TestBindings_EXPORT void c_TestTargetNS__Derived2FromPureAbstract__destructor(void *thisObj); +TestBindings_EXPORT void +c_TestTargetNS__Derived2FromPureAbstract__registerVirtualMethodCallback(void *ptr, void *callback, + int methodId); +TestBindings_EXPORT void c_TestTargetNS__Derived2FromPureAbstract_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/DerivedFromPureAbstract_c.cpp b/tests/generated/TestBindings/dart/ffi/DerivedFromPureAbstract_c.cpp new file mode 100644 index 0000000..45b23c5 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/DerivedFromPureAbstract_c.cpp @@ -0,0 +1,293 @@ +#include "DerivedFromPureAbstract_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +DerivedFromPureAbstract_wrapper::DerivedFromPureAbstract_wrapper() + : ::TestTargetNS::DerivedFromPureAbstract() +{ +} +DerivedFromPureAbstract_wrapper::DerivedFromPureAbstract_wrapper(int arg__1) + : ::TestTargetNS::DerivedFromPureAbstract(arg__1) +{ +} +int DerivedFromPureAbstract_wrapper::foo() +{ + if (m_fooCallback) { + const void *thisPtr = this; + return m_fooCallback(const_cast(thisPtr)); + } else { + return ::TestTargetNS::DerivedFromPureAbstract::foo(); + } +} +int DerivedFromPureAbstract_wrapper::foo_nocallback() +{ + return ::TestTargetNS::DerivedFromPureAbstract::foo(); +} +int DerivedFromPureAbstract_wrapper::indirectionCallsVirtualReceivingStruct(SimpleStruct s) +{ + return ::TestTargetNS::DerivedFromPureAbstract::indirectionCallsVirtualReceivingStruct(s); +} +int DerivedFromPureAbstract_wrapper::nonVirtualCallsVirtual() +{ + return ::TestTargetNS::DerivedFromPureAbstract::nonVirtualCallsVirtual(); +} +int DerivedFromPureAbstract_wrapper::receivesValueStruct(SimpleStruct arg__1) +{ + if (m_receivesValueStructCallback) { + const void *thisPtr = this; + return m_receivesValueStructCallback(const_cast(thisPtr), &arg__1); + } else { + return ::TestTargetNS::DerivedFromPureAbstract::receivesValueStruct(arg__1); + } +} +int DerivedFromPureAbstract_wrapper::receivesValueStruct_nocallback(SimpleStruct arg__1) +{ + return ::TestTargetNS::DerivedFromPureAbstract::receivesValueStruct(arg__1); +} +void DerivedFromPureAbstract_wrapper::renamedPureVirtual() +{ + if (m_renamedPureVirtual1Callback) { + const void *thisPtr = this; + m_renamedPureVirtual1Callback(const_cast(thisPtr)); + } else { + ::TestTargetNS::DerivedFromPureAbstract::renamedPureVirtual(); + } +} +void DerivedFromPureAbstract_wrapper::renamedPureVirtual_nocallback() +{ + ::TestTargetNS::DerivedFromPureAbstract::renamedPureVirtual(); +} +void DerivedFromPureAbstract_wrapper::unnamedOverriddenDefaultArgCase(int arg__1) +{ + if (m_unnamedOverriddenDefaultArgCaseCallback) { + const void *thisPtr = this; + m_unnamedOverriddenDefaultArgCaseCallback(const_cast(thisPtr), arg__1); + } else { + ::TestTargetNS::DerivedFromPureAbstract::unnamedOverriddenDefaultArgCase(arg__1); + } +} +void DerivedFromPureAbstract_wrapper::unnamedOverriddenDefaultArgCase_nocallback(int arg__1) +{ + ::TestTargetNS::DerivedFromPureAbstract::unnamedOverriddenDefaultArgCase(arg__1); +} +int DerivedFromPureAbstract_wrapper::virtualReceivingPointer(SimpleStruct *s) +{ + if (m_virtualReceivingPointerCallback) { + const void *thisPtr = this; + return m_virtualReceivingPointerCallback(const_cast(thisPtr), s); + } else { + return ::TestTargetNS::DerivedFromPureAbstract::virtualReceivingPointer(s); + } +} +int DerivedFromPureAbstract_wrapper::virtualReceivingPointer_nocallback(SimpleStruct *s) +{ + return ::TestTargetNS::DerivedFromPureAbstract::virtualReceivingPointer(s); +} +void DerivedFromPureAbstract_wrapper::voidPureAbstract() +{ + if (m_voidPureAbstractCallback) { + const void *thisPtr = this; + m_voidPureAbstractCallback(const_cast(thisPtr)); + } else { + ::TestTargetNS::DerivedFromPureAbstract::voidPureAbstract(); + } +} +void DerivedFromPureAbstract_wrapper::voidPureAbstract_nocallback() +{ + ::TestTargetNS::DerivedFromPureAbstract::voidPureAbstract(); +} +DerivedFromPureAbstract_wrapper::~DerivedFromPureAbstract_wrapper() +{ +} + +} +static TestTargetNS::DerivedFromPureAbstract *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::DerivedFromPureAbstract_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_TestTargetNS__DerivedFromPureAbstract_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} +void *c_TestTargetNS__DerivedFromPureAbstract__constructor() +{ + auto ptr = new TestBindings_wrappersNS::DerivedFromPureAbstract_wrapper(); + return reinterpret_cast(ptr); +} +void *c_TestTargetNS__DerivedFromPureAbstract__constructor_int(int arg__1) +{ + auto ptr = new TestBindings_wrappersNS::DerivedFromPureAbstract_wrapper(arg__1); + return reinterpret_cast(ptr); +} +// foo() +int c_TestTargetNS__DerivedFromPureAbstract__foo(void *thisObj) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->foo_nocallback(); + } else { + return targetPtr->foo(); + } + }(); + return result; +} +// indirectionCallsVirtualReceivingStruct(SimpleStruct s) +int c_TestTargetNS__DerivedFromPureAbstract__indirectionCallsVirtualReceivingStruct_SimpleStruct( + void *thisObj, void *s_) +{ + assert(s_); + auto &s = *reinterpret_cast(s_); + const auto &result = fromPtr(thisObj)->indirectionCallsVirtualReceivingStruct(s); + return result; +} +// nonVirtualCallsVirtual() +int c_TestTargetNS__DerivedFromPureAbstract__nonVirtualCallsVirtual(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->nonVirtualCallsVirtual(); + return result; +} +// receivesValueStruct(SimpleStruct arg__1) +int c_TestTargetNS__DerivedFromPureAbstract__receivesValueStruct_SimpleStruct(void *thisObj, + void *arg__1_) +{ + assert(arg__1_); + auto &arg__1 = *reinterpret_cast(arg__1_); + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->receivesValueStruct_nocallback(arg__1); + } else { + return targetPtr->receivesValueStruct(arg__1); + } + }(); + return result; +} +// renamedPureVirtual() +void c_TestTargetNS__DerivedFromPureAbstract__renamedPureVirtual1(void *thisObj) +{ + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->renamedPureVirtual_nocallback(); + } else { + return targetPtr->renamedPureVirtual(); + } + }(); +} +// unnamedOverriddenDefaultArgCase(int arg__1) +void c_TestTargetNS__DerivedFromPureAbstract__unnamedOverriddenDefaultArgCase_int(void *thisObj, + int arg__1) +{ + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->unnamedOverriddenDefaultArgCase_nocallback(arg__1); + } else { + return targetPtr->unnamedOverriddenDefaultArgCase(arg__1); + } + }(); +} +// virtualReceivingPointer(SimpleStruct * s) +int c_TestTargetNS__DerivedFromPureAbstract__virtualReceivingPointer_SimpleStruct(void *thisObj, + void *s_) +{ + auto s = reinterpret_cast(s_); + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualReceivingPointer_nocallback(s); + } else { + return targetPtr->virtualReceivingPointer(s); + } + }(); + return result; +} +// voidPureAbstract() +void c_TestTargetNS__DerivedFromPureAbstract__voidPureAbstract(void *thisObj) +{ + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->voidPureAbstract_nocallback(); + } else { + return targetPtr->voidPureAbstract(); + } + }(); +} +void c_TestTargetNS__DerivedFromPureAbstract__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +void c_TestTargetNS__DerivedFromPureAbstract__registerVirtualMethodCallback(void *ptr, + void *callback, + int methodId) +{ + auto wrapper = fromWrapperPtr(ptr); + switch (methodId) { + case 13: + wrapper->m_fooCallback = reinterpret_cast< + TestBindings_wrappersNS::DerivedFromPureAbstract_wrapper::Callback_foo>(callback); + break; + case 193: + wrapper->m_receivesValueStructCallback = reinterpret_cast< + TestBindings_wrappersNS::DerivedFromPureAbstract_wrapper::Callback_receivesValueStruct>( + callback); + break; + case 14: + wrapper->m_renamedPureVirtual1Callback = reinterpret_cast< + TestBindings_wrappersNS::DerivedFromPureAbstract_wrapper::Callback_renamedPureVirtual1>( + callback); + break; + case 17: + wrapper->m_unnamedOverriddenDefaultArgCaseCallback = + reinterpret_cast(callback); + break; + case 18: + wrapper->m_virtualReceivingPointerCallback = + reinterpret_cast(callback); + break; + case 19: + wrapper->m_voidPureAbstractCallback = reinterpret_cast< + TestBindings_wrappersNS::DerivedFromPureAbstract_wrapper::Callback_voidPureAbstract>( + callback); + break; + } +} +} diff --git a/tests/generated/TestBindings/dart/ffi/DerivedFromPureAbstract_c.h b/tests/generated/TestBindings/dart/ffi/DerivedFromPureAbstract_c.h new file mode 100644 index 0000000..ff7c4dc --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/DerivedFromPureAbstract_c.h @@ -0,0 +1,75 @@ +#include "TestBindings_exports.h" +#include + +namespace TestBindings_wrappersNS { +class DerivedFromPureAbstract_wrapper : public ::TestTargetNS::DerivedFromPureAbstract +{ +public: + ~DerivedFromPureAbstract_wrapper(); + DerivedFromPureAbstract_wrapper(); + DerivedFromPureAbstract_wrapper(int arg__1); + virtual int foo(); + virtual int foo_nocallback(); + int indirectionCallsVirtualReceivingStruct(SimpleStruct s); + int nonVirtualCallsVirtual(); + virtual int receivesValueStruct(SimpleStruct arg__1); + virtual int receivesValueStruct_nocallback(SimpleStruct arg__1); + virtual void renamedPureVirtual(); + virtual void renamedPureVirtual_nocallback(); + virtual void unnamedOverriddenDefaultArgCase(int arg__1 = 0); + virtual void unnamedOverriddenDefaultArgCase_nocallback(int arg__1 = 0); + virtual int virtualReceivingPointer(SimpleStruct *s); + virtual int virtualReceivingPointer_nocallback(SimpleStruct *s); + virtual void voidPureAbstract(); + virtual void voidPureAbstract_nocallback(); + typedef int (*Callback_foo)(void *); + Callback_foo m_fooCallback = nullptr; + typedef int (*Callback_receivesValueStruct)(void *, SimpleStruct *arg__1); + Callback_receivesValueStruct m_receivesValueStructCallback = nullptr; + typedef void (*Callback_renamedPureVirtual1)(void *); + Callback_renamedPureVirtual1 m_renamedPureVirtual1Callback = nullptr; + typedef void (*Callback_unnamedOverriddenDefaultArgCase)(void *, int arg__1); + Callback_unnamedOverriddenDefaultArgCase m_unnamedOverriddenDefaultArgCaseCallback = nullptr; + typedef int (*Callback_virtualReceivingPointer)(void *, SimpleStruct *s); + Callback_virtualReceivingPointer m_virtualReceivingPointerCallback = nullptr; + typedef void (*Callback_voidPureAbstract)(void *); + Callback_voidPureAbstract m_voidPureAbstractCallback = nullptr; +}; +} +extern "C" { +// TestTargetNS::DerivedFromPureAbstract::DerivedFromPureAbstract() +TestBindings_EXPORT void *c_TestTargetNS__DerivedFromPureAbstract__constructor(); +// TestTargetNS::DerivedFromPureAbstract::DerivedFromPureAbstract(int arg__1) +TestBindings_EXPORT void *c_TestTargetNS__DerivedFromPureAbstract__constructor_int(int arg__1); +// TestTargetNS::DerivedFromPureAbstract::foo() +TestBindings_EXPORT int c_TestTargetNS__DerivedFromPureAbstract__foo(void *thisObj); +// TestTargetNS::DerivedFromPureAbstract::indirectionCallsVirtualReceivingStruct(SimpleStruct s) +TestBindings_EXPORT int +c_TestTargetNS__DerivedFromPureAbstract__indirectionCallsVirtualReceivingStruct_SimpleStruct( + void *thisObj, void *s_); +// TestTargetNS::DerivedFromPureAbstract::nonVirtualCallsVirtual() +TestBindings_EXPORT int +c_TestTargetNS__DerivedFromPureAbstract__nonVirtualCallsVirtual(void *thisObj); +// TestTargetNS::DerivedFromPureAbstract::receivesValueStruct(SimpleStruct arg__1) +TestBindings_EXPORT int +c_TestTargetNS__DerivedFromPureAbstract__receivesValueStruct_SimpleStruct(void *thisObj, + void *arg__1_); +// TestTargetNS::DerivedFromPureAbstract::renamedPureVirtual() +TestBindings_EXPORT void +c_TestTargetNS__DerivedFromPureAbstract__renamedPureVirtual1(void *thisObj); +// TestTargetNS::DerivedFromPureAbstract::unnamedOverriddenDefaultArgCase(int arg__1) +TestBindings_EXPORT void +c_TestTargetNS__DerivedFromPureAbstract__unnamedOverriddenDefaultArgCase_int(void *thisObj, + int arg__1); +// TestTargetNS::DerivedFromPureAbstract::virtualReceivingPointer(SimpleStruct * s) +TestBindings_EXPORT int +c_TestTargetNS__DerivedFromPureAbstract__virtualReceivingPointer_SimpleStruct(void *thisObj, + void *s_); +// TestTargetNS::DerivedFromPureAbstract::voidPureAbstract() +TestBindings_EXPORT void c_TestTargetNS__DerivedFromPureAbstract__voidPureAbstract(void *thisObj); +TestBindings_EXPORT void c_TestTargetNS__DerivedFromPureAbstract__destructor(void *thisObj); +TestBindings_EXPORT void +c_TestTargetNS__DerivedFromPureAbstract__registerVirtualMethodCallback(void *ptr, void *callback, + int methodId); +TestBindings_EXPORT void c_TestTargetNS__DerivedFromPureAbstract_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/DestructorCounter_c.cpp b/tests/generated/TestBindings/dart/ffi/DestructorCounter_c.cpp new file mode 100644 index 0000000..d68ca63 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/DestructorCounter_c.cpp @@ -0,0 +1,93 @@ +#include "DestructorCounter_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +DestructorCounter_wrapper::DestructorCounter_wrapper() + : ::TestTargetNS::DestructorCounter() +{ +} +int DestructorCounter_wrapper::instanceCount() +{ + return ::TestTargetNS::DestructorCounter::instanceCount(); +} +TestTargetNS::DestructorCounter *DestructorCounter_wrapper::newOnTheHeap() +{ + return ::TestTargetNS::DestructorCounter::newOnTheHeap(); +} +TestTargetNS::DestructorCounter DestructorCounter_wrapper::newOnTheStack() +{ + return ::TestTargetNS::DestructorCounter::newOnTheStack(); +} +DestructorCounter_wrapper::~DestructorCounter_wrapper() +{ +} + +} +static TestTargetNS::DestructorCounter *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::DestructorCounter_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_TestTargetNS__DestructorCounter_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} +void *c_TestTargetNS__DestructorCounter__constructor() +{ + auto ptr = new TestBindings_wrappersNS::DestructorCounter_wrapper(); + return reinterpret_cast(ptr); +} +// instanceCount() +int c_static_TestTargetNS__DestructorCounter__instanceCount() +{ + const auto &result = TestBindings_wrappersNS::DestructorCounter_wrapper::instanceCount(); + return result; +} +// newOnTheHeap() +void *c_static_TestTargetNS__DestructorCounter__newOnTheHeap() +{ + const auto &result = TestBindings_wrappersNS::DestructorCounter_wrapper::newOnTheHeap(); + return result; +} +// newOnTheStack() +void *c_static_TestTargetNS__DestructorCounter__newOnTheStack() +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::DestructorCounter_wrapper::newOnTheStack() + }; + return result; +} +void c_TestTargetNS__DestructorCounter__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +int c_static_TestTargetNS__DestructorCounter___get_s_instanceCount() +{ + return TestBindings_wrappersNS::DestructorCounter_wrapper::s_instanceCount; +} +void c_static_TestTargetNS__DestructorCounter___set_s_instanceCount_int(int s_instanceCount_) +{ + TestBindings_wrappersNS::DestructorCounter_wrapper::s_instanceCount = s_instanceCount_; +} +} diff --git a/tests/generated/TestBindings/dart/ffi/DestructorCounter_c.h b/tests/generated/TestBindings/dart/ffi/DestructorCounter_c.h new file mode 100644 index 0000000..a2c2c15 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/DestructorCounter_c.h @@ -0,0 +1,29 @@ +#include "TestBindings_exports.h" +#include + +namespace TestBindings_wrappersNS { +class DestructorCounter_wrapper : public ::TestTargetNS::DestructorCounter +{ +public: + ~DestructorCounter_wrapper(); + DestructorCounter_wrapper(); + static int instanceCount(); + static TestTargetNS::DestructorCounter *newOnTheHeap(); + static TestTargetNS::DestructorCounter newOnTheStack(); +}; +} +extern "C" { +// TestTargetNS::DestructorCounter::DestructorCounter() +TestBindings_EXPORT void *c_TestTargetNS__DestructorCounter__constructor(); +// TestTargetNS::DestructorCounter::instanceCount() +TestBindings_EXPORT int c_static_TestTargetNS__DestructorCounter__instanceCount(); +// TestTargetNS::DestructorCounter::newOnTheHeap() +TestBindings_EXPORT void *c_static_TestTargetNS__DestructorCounter__newOnTheHeap(); +// TestTargetNS::DestructorCounter::newOnTheStack() +TestBindings_EXPORT void *c_static_TestTargetNS__DestructorCounter__newOnTheStack(); +TestBindings_EXPORT void c_TestTargetNS__DestructorCounter__destructor(void *thisObj); +TestBindings_EXPORT int c_static_TestTargetNS__DestructorCounter___get_s_instanceCount(); +TestBindings_EXPORT void +c_static_TestTargetNS__DestructorCounter___set_s_instanceCount_int(int s_instanceCount_); +TestBindings_EXPORT void c_TestTargetNS__DestructorCounter_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/DoubleInheritanceFromVirtuals_c.cpp b/tests/generated/TestBindings/dart/ffi/DoubleInheritanceFromVirtuals_c.cpp new file mode 100644 index 0000000..c159023 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/DoubleInheritanceFromVirtuals_c.cpp @@ -0,0 +1,127 @@ +#include "DoubleInheritanceFromVirtuals_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +DoubleInheritanceFromVirtuals_wrapper::DoubleInheritanceFromVirtuals_wrapper() + : ::DoubleInheritanceFromVirtuals() +{ +} +void DoubleInheritanceFromVirtuals_wrapper::virtualMethod1() +{ + if (m_virtualMethod1Callback) { + const void *thisPtr = this; + m_virtualMethod1Callback(const_cast(thisPtr)); + } else { + ::DoubleInheritanceFromVirtuals::virtualMethod1(); + } +} +void DoubleInheritanceFromVirtuals_wrapper::virtualMethod1_nocallback() +{ + ::DoubleInheritanceFromVirtuals::virtualMethod1(); +} +void DoubleInheritanceFromVirtuals_wrapper::virtualMethod2() +{ + if (m_virtualMethod2Callback) { + const void *thisPtr = this; + m_virtualMethod2Callback(const_cast(thisPtr)); + } else { + ::DoubleInheritanceFromVirtuals::virtualMethod2(); + } +} +void DoubleInheritanceFromVirtuals_wrapper::virtualMethod2_nocallback() +{ + ::DoubleInheritanceFromVirtuals::virtualMethod2(); +} +DoubleInheritanceFromVirtuals_wrapper::~DoubleInheritanceFromVirtuals_wrapper() +{ +} + +} +static DoubleInheritanceFromVirtuals *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::DoubleInheritanceFromVirtuals_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_DoubleInheritanceFromVirtuals_Finalizer(void *cppObj) +{ + delete reinterpret_cast( + cppObj); +} +void *c_DoubleInheritanceFromVirtuals__constructor() +{ + auto ptr = new TestBindings_wrappersNS::DoubleInheritanceFromVirtuals_wrapper(); + return reinterpret_cast(ptr); +} +// virtualMethod1() +void c_DoubleInheritanceFromVirtuals__virtualMethod1(void *thisObj) +{ + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast( + targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualMethod1_nocallback(); + } else { + return targetPtr->virtualMethod1(); + } + }(); +} +// virtualMethod2() +void c_DoubleInheritanceFromVirtuals__virtualMethod2(void *thisObj) +{ + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast( + targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualMethod2_nocallback(); + } else { + return targetPtr->virtualMethod2(); + } + }(); +} +void c_DoubleInheritanceFromVirtuals__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +void c_DoubleInheritanceFromVirtuals__registerVirtualMethodCallback(void *ptr, void *callback, + int methodId) +{ + auto wrapper = fromWrapperPtr(ptr); + switch (methodId) { + case 3: + wrapper->m_virtualMethod1Callback = + reinterpret_cast(callback); + break; + case 1: + wrapper->m_virtualMethod2Callback = + reinterpret_cast(callback); + break; + } +} +} diff --git a/tests/generated/TestBindings/dart/ffi/DoubleInheritanceFromVirtuals_c.h b/tests/generated/TestBindings/dart/ffi/DoubleInheritanceFromVirtuals_c.h new file mode 100644 index 0000000..b4af1f0 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/DoubleInheritanceFromVirtuals_c.h @@ -0,0 +1,32 @@ +#include "TestBindings_exports.h" +#include + +namespace TestBindings_wrappersNS { +class DoubleInheritanceFromVirtuals_wrapper : public ::DoubleInheritanceFromVirtuals +{ +public: + ~DoubleInheritanceFromVirtuals_wrapper(); + DoubleInheritanceFromVirtuals_wrapper(); + virtual void virtualMethod1(); + virtual void virtualMethod1_nocallback(); + virtual void virtualMethod2(); + virtual void virtualMethod2_nocallback(); + typedef void (*Callback_virtualMethod1)(void *); + Callback_virtualMethod1 m_virtualMethod1Callback = nullptr; + typedef void (*Callback_virtualMethod2)(void *); + Callback_virtualMethod2 m_virtualMethod2Callback = nullptr; +}; +} +extern "C" { +// DoubleInheritanceFromVirtuals::DoubleInheritanceFromVirtuals() +TestBindings_EXPORT void *c_DoubleInheritanceFromVirtuals__constructor(); +// DoubleInheritanceFromVirtuals::virtualMethod1() +TestBindings_EXPORT void c_DoubleInheritanceFromVirtuals__virtualMethod1(void *thisObj); +// DoubleInheritanceFromVirtuals::virtualMethod2() +TestBindings_EXPORT void c_DoubleInheritanceFromVirtuals__virtualMethod2(void *thisObj); +TestBindings_EXPORT void c_DoubleInheritanceFromVirtuals__destructor(void *thisObj); +TestBindings_EXPORT void +c_DoubleInheritanceFromVirtuals__registerVirtualMethodCallback(void *ptr, void *callback, + int methodId); +TestBindings_EXPORT void c_DoubleInheritanceFromVirtuals_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/DoubleInheritance_c.cpp b/tests/generated/TestBindings/dart/ffi/DoubleInheritance_c.cpp new file mode 100644 index 0000000..c18a66e --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/DoubleInheritance_c.cpp @@ -0,0 +1,336 @@ +#include "DoubleInheritance_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +DoubleInheritance_wrapper::DoubleInheritance_wrapper() + : ::DoubleInheritance() +{ +} +void DoubleInheritance_wrapper::customEvent(QEvent *event) +{ + if (m_customEventCallback) { + const void *thisPtr = this; + m_customEventCallback(const_cast(thisPtr), event); + } else { + ::DoubleInheritance::customEvent(event); + } +} +void DoubleInheritance_wrapper::customEvent_nocallback(QEvent *event) +{ + ::DoubleInheritance::customEvent(event); +} +bool DoubleInheritance_wrapper::event(QEvent *event) +{ + if (m_eventCallback) { + const void *thisPtr = this; + return m_eventCallback(const_cast(thisPtr), event); + } else { + return ::DoubleInheritance::event(event); + } +} +bool DoubleInheritance_wrapper::event_nocallback(QEvent *event) +{ + return ::DoubleInheritance::event(event); +} +bool DoubleInheritance_wrapper::eventFilter(QObject *watched, QEvent *event) +{ + if (m_eventFilterCallback) { + const void *thisPtr = this; + return m_eventFilterCallback(const_cast(thisPtr), watched, event); + } else { + return ::DoubleInheritance::eventFilter(watched, event); + } +} +bool DoubleInheritance_wrapper::eventFilter_nocallback(QObject *watched, QEvent *event) +{ + return ::DoubleInheritance::eventFilter(watched, event); +} +int DoubleInheritance_wrapper::nonVirtualCallsVirtualFrom2ndBase() const +{ + return ::DoubleInheritance::nonVirtualCallsVirtualFrom2ndBase(); +} +void DoubleInheritance_wrapper::pureVirtual() +{ + if (m_pureVirtualCallback) { + const void *thisPtr = this; + m_pureVirtualCallback(const_cast(thisPtr)); + } else { + std::cerr << "pureVirtual: Warning: Calling pure-virtual\n"; + return; + } +} +void DoubleInheritance_wrapper::pureVirtual_nocallback() +{ + std::cerr << "pureVirtual: Warning: Calling pure-virtual\n"; + return; +} +int DoubleInheritance_wrapper::virtualFunc() +{ + if (m_virtualFuncCallback) { + const void *thisPtr = this; + return m_virtualFuncCallback(const_cast(thisPtr)); + } else { + return ::DoubleInheritance::virtualFunc(); + } +} +int DoubleInheritance_wrapper::virtualFunc_nocallback() +{ + return ::DoubleInheritance::virtualFunc(); +} +const char *DoubleInheritance_wrapper::virtualMethodReturningConstChar() const +{ + if (m_virtualMethodReturningConstCharCallback) { + const void *thisPtr = this; + return m_virtualMethodReturningConstCharCallback(const_cast(thisPtr)); + } else { + return ::DoubleInheritance::virtualMethodReturningConstChar(); + } +} +const char *DoubleInheritance_wrapper::virtualMethodReturningConstChar_nocallback() const +{ + return ::DoubleInheritance::virtualMethodReturningConstChar(); +} +void DoubleInheritance_wrapper::virtualReceivingQString(const QString &str) +{ + if (m_virtualReceivingQStringCallback) { + const void *thisPtr = this; + m_virtualReceivingQStringCallback(const_cast(thisPtr), str); + } else { + ::DoubleInheritance::virtualReceivingQString(str); + } +} +void DoubleInheritance_wrapper::virtualReceivingQString_nocallback(const QString &str) +{ + ::DoubleInheritance::virtualReceivingQString(str); +} +int DoubleInheritance_wrapper::virtualReturningInt() const +{ + if (m_virtualReturningIntCallback) { + const void *thisPtr = this; + return m_virtualReturningIntCallback(const_cast(thisPtr)); + } else { + return ::DoubleInheritance::virtualReturningInt(); + } +} +int DoubleInheritance_wrapper::virtualReturningInt_nocallback() const +{ + return ::DoubleInheritance::virtualReturningInt(); +} +DoubleInheritance_wrapper::~DoubleInheritance_wrapper() +{ +} + +} +static DoubleInheritance *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::DoubleInheritance_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_DoubleInheritance_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} +void *c_DoubleInheritance__constructor() +{ + auto ptr = new TestBindings_wrappersNS::DoubleInheritance_wrapper(); + return reinterpret_cast(ptr); +} +// customEvent(QEvent * event) +void c_DoubleInheritance__customEvent_QEvent(void *thisObj, void *event_) +{ + auto event = reinterpret_cast(event_); + fromWrapperPtr(thisObj)->customEvent_nocallback(event); +} +// event(QEvent * event) +bool c_DoubleInheritance__event_QEvent(void *thisObj, void *event_) +{ + auto event = reinterpret_cast(event_); + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->event_nocallback(event); + } else { + return targetPtr->event(event); + } + }(); + return result; +} +// eventFilter(QObject * watched, QEvent * event) +bool c_DoubleInheritance__eventFilter_QObject_QEvent(void *thisObj, void *watched_, void *event_) +{ + auto watched = reinterpret_cast(watched_); + auto event = reinterpret_cast(event_); + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->eventFilter_nocallback(watched, event); + } else { + return targetPtr->eventFilter(watched, event); + } + }(); + return result; +} +// nonVirtualCallsVirtualFrom2ndBase() const +int c_DoubleInheritance__nonVirtualCallsVirtualFrom2ndBase(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->nonVirtualCallsVirtualFrom2ndBase(); + return result; +} +// pureVirtual() +void c_DoubleInheritance__pureVirtual(void *thisObj) +{ + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->pureVirtual_nocallback(); + } else { + return targetPtr->pureVirtual(); + } + }(); +} +void c_DoubleInheritance__onValueChanged_int(void *thisObj, void *contextQObject, void *callback) +{ + auto instance = reinterpret_cast(thisObj); + auto context = reinterpret_cast(contextQObject); + QObject::connect(instance, &DoubleInheritance::valueChanged, context ? context : instance, + [thisObj, callback] { + typedef void (*SignalHandler_callback)(void *); + auto dartCallback = reinterpret_cast(callback); + dartCallback(thisObj); + }); +} +// virtualFunc() +int c_DoubleInheritance__virtualFunc(void *thisObj) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualFunc_nocallback(); + } else { + return targetPtr->virtualFunc(); + } + }(); + return result; +} +// virtualMethodReturningConstChar() const +const char *c_DoubleInheritance__virtualMethodReturningConstChar(void *thisObj) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualMethodReturningConstChar_nocallback(); + } else { + return targetPtr->virtualMethodReturningConstChar(); + } + }(); + return result; +} +// virtualReceivingQString(const QString & str) +void c_DoubleInheritance__virtualReceivingQString_QString(void *thisObj, const char *str_) +{ + const auto str = QString::fromUtf8(str_); + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualReceivingQString_nocallback(str); + } else { + return targetPtr->virtualReceivingQString(str); + } + }(); + free(( char * )str_); +} +// virtualReturningInt() const +int c_DoubleInheritance__virtualReturningInt(void *thisObj) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualReturningInt_nocallback(); + } else { + return targetPtr->virtualReturningInt(); + } + }(); + return result; +} +void c_DoubleInheritance__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +void c_DoubleInheritance__registerVirtualMethodCallback(void *ptr, void *callback, int methodId) +{ + auto wrapper = fromWrapperPtr(ptr); + switch (methodId) { + case 481: + wrapper->m_customEventCallback = reinterpret_cast< + TestBindings_wrappersNS::DoubleInheritance_wrapper::Callback_customEvent>(callback); + break; + case 490: + wrapper->m_eventCallback = + reinterpret_cast( + callback); + break; + case 491: + wrapper->m_eventFilterCallback = reinterpret_cast< + TestBindings_wrappersNS::DoubleInheritance_wrapper::Callback_eventFilter>(callback); + break; + case 1166: + wrapper->m_pureVirtualCallback = reinterpret_cast< + TestBindings_wrappersNS::DoubleInheritance_wrapper::Callback_pureVirtual>(callback); + break; + case 1181: + wrapper->m_virtualFuncCallback = reinterpret_cast< + TestBindings_wrappersNS::DoubleInheritance_wrapper::Callback_virtualFunc>(callback); + break; + case 1182: + wrapper->m_virtualMethodReturningConstCharCallback = + reinterpret_cast(callback); + break; + case 1183: + wrapper->m_virtualReceivingQStringCallback = reinterpret_cast< + TestBindings_wrappersNS::DoubleInheritance_wrapper::Callback_virtualReceivingQString>( + callback); + break; + case 1184: + wrapper->m_virtualReturningIntCallback = reinterpret_cast< + TestBindings_wrappersNS::DoubleInheritance_wrapper::Callback_virtualReturningInt>( + callback); + break; + } +} +} diff --git a/tests/generated/TestBindings/dart/ffi/DoubleInheritance_c.h b/tests/generated/TestBindings/dart/ffi/DoubleInheritance_c.h new file mode 100644 index 0000000..17da6b0 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/DoubleInheritance_c.h @@ -0,0 +1,75 @@ +#include "TestBindings_exports.h" +#include +#include +#include +#include + +namespace TestBindings_wrappersNS { +class DoubleInheritance_wrapper : public ::DoubleInheritance +{ +public: + ~DoubleInheritance_wrapper(); + DoubleInheritance_wrapper(); + virtual void customEvent(QEvent *event); + virtual void customEvent_nocallback(QEvent *event); + virtual bool event(QEvent *event); + virtual bool event_nocallback(QEvent *event); + virtual bool eventFilter(QObject *watched, QEvent *event); + virtual bool eventFilter_nocallback(QObject *watched, QEvent *event); + int nonVirtualCallsVirtualFrom2ndBase() const; + virtual void pureVirtual(); + virtual void pureVirtual_nocallback(); + virtual int virtualFunc(); + virtual int virtualFunc_nocallback(); + virtual const char *virtualMethodReturningConstChar() const; + virtual const char *virtualMethodReturningConstChar_nocallback() const; + virtual void virtualReceivingQString(const QString &str); + virtual void virtualReceivingQString_nocallback(const QString &str); + virtual int virtualReturningInt() const; + virtual int virtualReturningInt_nocallback() const; + typedef void (*Callback_customEvent)(void *, QEvent *event); + Callback_customEvent m_customEventCallback = nullptr; + typedef bool (*Callback_event)(void *, QEvent *event); + Callback_event m_eventCallback = nullptr; + typedef bool (*Callback_eventFilter)(void *, QObject *watched, QEvent *event); + Callback_eventFilter m_eventFilterCallback = nullptr; + typedef void (*Callback_pureVirtual)(void *); + Callback_pureVirtual m_pureVirtualCallback = nullptr; + typedef int (*Callback_virtualFunc)(void *); + Callback_virtualFunc m_virtualFuncCallback = nullptr; + typedef const char *(*Callback_virtualMethodReturningConstChar)(void *); + Callback_virtualMethodReturningConstChar m_virtualMethodReturningConstCharCallback = nullptr; + typedef void (*Callback_virtualReceivingQString)(void *, const QString &str); + Callback_virtualReceivingQString m_virtualReceivingQStringCallback = nullptr; + typedef int (*Callback_virtualReturningInt)(void *); + Callback_virtualReturningInt m_virtualReturningIntCallback = nullptr; +}; +} +extern "C" { +// DoubleInheritance::DoubleInheritance() +TestBindings_EXPORT void *c_DoubleInheritance__constructor(); +// DoubleInheritance::customEvent(QEvent * event) +TestBindings_EXPORT void c_DoubleInheritance__customEvent_QEvent(void *thisObj, void *event_); +// DoubleInheritance::event(QEvent * event) +TestBindings_EXPORT bool c_DoubleInheritance__event_QEvent(void *thisObj, void *event_); +// DoubleInheritance::eventFilter(QObject * watched, QEvent * event) +TestBindings_EXPORT bool +c_DoubleInheritance__eventFilter_QObject_QEvent(void *thisObj, void *watched_, void *event_); +// DoubleInheritance::nonVirtualCallsVirtualFrom2ndBase() const +TestBindings_EXPORT int c_DoubleInheritance__nonVirtualCallsVirtualFrom2ndBase(void *thisObj); +// DoubleInheritance::pureVirtual() +TestBindings_EXPORT void c_DoubleInheritance__pureVirtual(void *thisObj); +// DoubleInheritance::virtualFunc() +TestBindings_EXPORT int c_DoubleInheritance__virtualFunc(void *thisObj); +// DoubleInheritance::virtualMethodReturningConstChar() const +TestBindings_EXPORT const char *c_DoubleInheritance__virtualMethodReturningConstChar(void *thisObj); +// DoubleInheritance::virtualReceivingQString(const QString & str) +TestBindings_EXPORT void c_DoubleInheritance__virtualReceivingQString_QString(void *thisObj, + const char *str_); +// DoubleInheritance::virtualReturningInt() const +TestBindings_EXPORT int c_DoubleInheritance__virtualReturningInt(void *thisObj); +TestBindings_EXPORT void c_DoubleInheritance__destructor(void *thisObj); +TestBindings_EXPORT void +c_DoubleInheritance__registerVirtualMethodCallback(void *ptr, void *callback, int methodId); +TestBindings_EXPORT void c_DoubleInheritance_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/EmptyNameSpace_c.cpp b/tests/generated/TestBindings/dart/ffi/EmptyNameSpace_c.cpp new file mode 100644 index 0000000..04ff1a0 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/EmptyNameSpace_c.cpp @@ -0,0 +1,22 @@ +#include "EmptyNameSpace_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +extern "C" { +} diff --git a/tests/generated/TestBindings/dart/ffi/EmptyNameSpace_c.h b/tests/generated/TestBindings/dart/ffi/EmptyNameSpace_c.h new file mode 100644 index 0000000..410c967 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/EmptyNameSpace_c.h @@ -0,0 +1,6 @@ +#include "TestBindings_exports.h" +#include + +extern "C" { +TestBindings_EXPORT void c_EmptyNameSpace_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/EmptyStruct_c.cpp b/tests/generated/TestBindings/dart/ffi/EmptyStruct_c.cpp new file mode 100644 index 0000000..ffc36e2 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/EmptyStruct_c.cpp @@ -0,0 +1,53 @@ +#include "EmptyStruct_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +EmptyStruct_wrapper::EmptyStruct_wrapper() + : ::EmptyStruct() +{ +} +EmptyStruct_wrapper::~EmptyStruct_wrapper() +{ +} + +} +static EmptyStruct *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::EmptyStruct_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_EmptyStruct_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} +void *c_EmptyStruct__constructor() +{ + auto ptr = new TestBindings_wrappersNS::EmptyStruct_wrapper(); + return reinterpret_cast(ptr); +} +void c_EmptyStruct__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} diff --git a/tests/generated/TestBindings/dart/ffi/EmptyStruct_c.h b/tests/generated/TestBindings/dart/ffi/EmptyStruct_c.h new file mode 100644 index 0000000..a6d43c3 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/EmptyStruct_c.h @@ -0,0 +1,17 @@ +#include "TestBindings_exports.h" +#include + +namespace TestBindings_wrappersNS { +class EmptyStruct_wrapper : public ::EmptyStruct +{ +public: + ~EmptyStruct_wrapper(); + EmptyStruct_wrapper(); +}; +} +extern "C" { +// EmptyStruct::EmptyStruct() +TestBindings_EXPORT void *c_EmptyStruct__constructor(); +TestBindings_EXPORT void c_EmptyStruct__destructor(void *thisObj); +TestBindings_EXPORT void c_EmptyStruct_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/ExplicitNamespace1/SimpleClash_c.cpp b/tests/generated/TestBindings/dart/ffi/ExplicitNamespace1/SimpleClash_c.cpp new file mode 100644 index 0000000..c3653e9 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/ExplicitNamespace1/SimpleClash_c.cpp @@ -0,0 +1,39 @@ +#include "SimpleClash_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS {namespace ExplicitNamespace1 {SimpleClash_wrapper::SimpleClash_wrapper(int arg__1) : ::NameClashingNS1::SimpleClash(arg__1) {} +int SimpleClash_wrapper::getValue(){return ::NameClashingNS1::SimpleClash::getValue();} +int SimpleClash_wrapper::getValueStatic(){return ::NameClashingNS1::SimpleClash::getValueStatic();} +SimpleClash_wrapper::~SimpleClash_wrapper() {} + +}}static NameClashingNS1::SimpleClash* fromPtr(void *ptr) +{return reinterpret_cast(ptr);}static TestBindings_wrappersNS::ExplicitNamespace1::SimpleClash_wrapper* fromWrapperPtr(void *ptr) +{return reinterpret_cast(ptr);}extern "C" { + void c_NameClashingNS1__SimpleClash_Finalizer(void *cppObj){delete reinterpret_cast(cppObj);}void * c_NameClashingNS1__SimpleClash__constructor_int(int arg__1) +{ +auto ptr = new TestBindings_wrappersNS::ExplicitNamespace1::SimpleClash_wrapper(arg__1);return reinterpret_cast(ptr);} +//getValue() +int c_NameClashingNS1__SimpleClash__getValue(void *thisObj){const auto &result = fromPtr(thisObj)->getValue();return result;} +//getValueStatic() +int c_static_NameClashingNS1__SimpleClash__getValueStatic(){const auto &result = TestBindings_wrappersNS::ExplicitNamespace1::SimpleClash_wrapper::getValueStatic();return result;} +void c_NameClashingNS1__SimpleClash__destructor(void *thisObj) +{ +delete fromPtr(thisObj);} +} diff --git a/tests/generated/TestBindings/dart/ffi/ExplicitNamespace1/SimpleClash_c.h b/tests/generated/TestBindings/dart/ffi/ExplicitNamespace1/SimpleClash_c.h new file mode 100644 index 0000000..bfa5fb3 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/ExplicitNamespace1/SimpleClash_c.h @@ -0,0 +1,16 @@ +#include "TestBindings_exports.h" +#include + +namespace TestBindings_wrappersNS {namespace ExplicitNamespace1 {class SimpleClash_wrapper : public ::NameClashingNS1::SimpleClash {public: +~SimpleClash_wrapper(); SimpleClash_wrapper(int arg__1);int getValue();static int getValueStatic(); + +}; +}}extern "C" { +// NameClashingNS1::SimpleClash::SimpleClash(int arg__1) +TestBindings_EXPORT void * c_NameClashingNS1__SimpleClash__constructor_int(int arg__1); +// NameClashingNS1::SimpleClash::getValue() +TestBindings_EXPORT int c_NameClashingNS1__SimpleClash__getValue(void *thisObj); +// NameClashingNS1::SimpleClash::getValueStatic() +TestBindings_EXPORT int c_static_NameClashingNS1__SimpleClash__getValueStatic(); +TestBindings_EXPORT void c_NameClashingNS1__SimpleClash__destructor(void *thisObj); +TestBindings_EXPORT void c_NameClashingNS1__SimpleClash_Finalizer(void *cppObj);} diff --git a/tests/generated/TestBindings/dart/ffi/ExplicitNamespace2/SimpleClash_c.cpp b/tests/generated/TestBindings/dart/ffi/ExplicitNamespace2/SimpleClash_c.cpp new file mode 100644 index 0000000..0e521bb --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/ExplicitNamespace2/SimpleClash_c.cpp @@ -0,0 +1,46 @@ +#include "SimpleClash_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS {namespace ExplicitNamespace2 {SimpleClash_wrapper::SimpleClash_wrapper(int arg__1) : ::NameClashingNS2::SimpleClash(arg__1) {} +int SimpleClash_wrapper::getFoo(){return ::NameClashingNS2::SimpleClash::getFoo();} +int SimpleClash_wrapper::getValueStatic(){return ::NameClashingNS2::SimpleClash::getValueStatic();} +NameClashingNS1::SimpleClash SimpleClash_wrapper::returnsAndReceivesFromOtherScope(NameClashingNS1::SimpleClash s){return ::NameClashingNS2::SimpleClash::returnsAndReceivesFromOtherScope(s);} +NameClashingNS1::SimpleClash SimpleClash_wrapper::returnsFromOtherScope(){return ::NameClashingNS2::SimpleClash::returnsFromOtherScope();} +SimpleClash_wrapper::~SimpleClash_wrapper() {} + +}}static NameClashingNS2::SimpleClash* fromPtr(void *ptr) +{return reinterpret_cast(ptr);}static TestBindings_wrappersNS::ExplicitNamespace2::SimpleClash_wrapper* fromWrapperPtr(void *ptr) +{return reinterpret_cast(ptr);}extern "C" { + void c_NameClashingNS2__SimpleClash_Finalizer(void *cppObj){delete reinterpret_cast(cppObj);}void * c_NameClashingNS2__SimpleClash__constructor_int(int arg__1) +{ +auto ptr = new TestBindings_wrappersNS::ExplicitNamespace2::SimpleClash_wrapper(arg__1);return reinterpret_cast(ptr);} +//getFoo() +int c_NameClashingNS2__SimpleClash__getFoo(void *thisObj){const auto &result = fromPtr(thisObj)->getFoo();return result;} +//getValueStatic() +int c_static_NameClashingNS2__SimpleClash__getValueStatic(){const auto &result = TestBindings_wrappersNS::ExplicitNamespace2::SimpleClash_wrapper::getValueStatic();return result;} +//returnsAndReceivesFromOtherScope(NameClashingNS1::SimpleClash s) +void* c_static_NameClashingNS2__SimpleClash__returnsAndReceivesFromOtherScope_SimpleClash(void* s_){assert(s_); +auto &s = *reinterpret_cast(s_);const auto &result = new Dartagnan::ValueWrapper{TestBindings_wrappersNS::ExplicitNamespace2::SimpleClash_wrapper::returnsAndReceivesFromOtherScope(s)};return result;} +//returnsFromOtherScope() +void* c_static_NameClashingNS2__SimpleClash__returnsFromOtherScope(){const auto &result = new Dartagnan::ValueWrapper{TestBindings_wrappersNS::ExplicitNamespace2::SimpleClash_wrapper::returnsFromOtherScope()};return result;} +void c_NameClashingNS2__SimpleClash__destructor(void *thisObj) +{ +delete fromPtr(thisObj);} +} diff --git a/tests/generated/TestBindings/dart/ffi/ExplicitNamespace2/SimpleClash_c.h b/tests/generated/TestBindings/dart/ffi/ExplicitNamespace2/SimpleClash_c.h new file mode 100644 index 0000000..875213c --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/ExplicitNamespace2/SimpleClash_c.h @@ -0,0 +1,20 @@ +#include "TestBindings_exports.h" +#include + +namespace TestBindings_wrappersNS {namespace ExplicitNamespace2 {class SimpleClash_wrapper : public ::NameClashingNS2::SimpleClash {public: +~SimpleClash_wrapper(); SimpleClash_wrapper(int arg__1);int getFoo();static int getValueStatic();static NameClashingNS1::SimpleClash returnsAndReceivesFromOtherScope(NameClashingNS1::SimpleClash s);static NameClashingNS1::SimpleClash returnsFromOtherScope(); + +}; +}}extern "C" { +// NameClashingNS2::SimpleClash::SimpleClash(int arg__1) +TestBindings_EXPORT void * c_NameClashingNS2__SimpleClash__constructor_int(int arg__1); +// NameClashingNS2::SimpleClash::getFoo() +TestBindings_EXPORT int c_NameClashingNS2__SimpleClash__getFoo(void *thisObj); +// NameClashingNS2::SimpleClash::getValueStatic() +TestBindings_EXPORT int c_static_NameClashingNS2__SimpleClash__getValueStatic(); +// NameClashingNS2::SimpleClash::returnsAndReceivesFromOtherScope(NameClashingNS1::SimpleClash s) +TestBindings_EXPORT void* c_static_NameClashingNS2__SimpleClash__returnsAndReceivesFromOtherScope_SimpleClash(void* s_); +// NameClashingNS2::SimpleClash::returnsFromOtherScope() +TestBindings_EXPORT void* c_static_NameClashingNS2__SimpleClash__returnsFromOtherScope(); +TestBindings_EXPORT void c_NameClashingNS2__SimpleClash__destructor(void *thisObj); +TestBindings_EXPORT void c_NameClashingNS2__SimpleClash_Finalizer(void *cppObj);} diff --git a/tests/generated/TestBindings/dart/ffi/MyBaseClass_c.cpp b/tests/generated/TestBindings/dart/ffi/MyBaseClass_c.cpp new file mode 100644 index 0000000..5ea8fe8 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/MyBaseClass_c.cpp @@ -0,0 +1,996 @@ +#include "MyBaseClass_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +MyBaseClass_wrapper::MyBaseClass_wrapper() + : ::TestTargetNS::MyBaseClass() +{ +} +MyBaseClass_wrapper::MyBaseClass_wrapper(TestTargetNS::MyBaseClass *mybaseclassptr) + : ::TestTargetNS::MyBaseClass(mybaseclassptr) +{ +} +void MyBaseClass_wrapper::addInts(QList arg__1) +{ + ::TestTargetNS::MyBaseClass::addInts(arg__1); +} +void MyBaseClass_wrapper::addQObjects(const QList &arg__1) +{ + ::TestTargetNS::MyBaseClass::addQObjects(arg__1); +} +void MyBaseClass_wrapper::addReals(QList arg__1) +{ + ::TestTargetNS::MyBaseClass::addReals(arg__1); +} +int MyBaseClass_wrapper::anotherOverloadedStatic(int arg__1) +{ + return ::TestTargetNS::MyBaseClass::anotherOverloadedStatic(arg__1); +} +int MyBaseClass_wrapper::bar() const +{ + if (m_barCallback) { + const void *thisPtr = this; + return m_barCallback(const_cast(thisPtr)); + } else { + return ::TestTargetNS::MyBaseClass::bar(); + } +} +int MyBaseClass_wrapper::bar_nocallback() const +{ + return ::TestTargetNS::MyBaseClass::bar(); +} +int MyBaseClass_wrapper::bar2() const +{ + if (m_bar2Callback) { + const void *thisPtr = this; + return m_bar2Callback(const_cast(thisPtr)); + } else { + return ::TestTargetNS::MyBaseClass::bar2(); + } +} +int MyBaseClass_wrapper::bar2_nocallback() const +{ + return ::TestTargetNS::MyBaseClass::bar2(); +} +int MyBaseClass_wrapper::callsVirtual() const +{ + return ::TestTargetNS::MyBaseClass::callsVirtual(); +} +int MyBaseClass_wrapper::foo() const +{ + return ::TestTargetNS::MyBaseClass::foo(); +} +bool MyBaseClass_wrapper::getBool(int arg__1) const +{ + return ::TestTargetNS::MyBaseClass::getBool(arg__1); +} +bool MyBaseClass_wrapper::getBoolFalse() const +{ + return ::TestTargetNS::MyBaseClass::getBoolFalse(); +} +bool MyBaseClass_wrapper::getBoolTrue() const +{ + return ::TestTargetNS::MyBaseClass::getBoolTrue(); +} +void MyBaseClass_wrapper::hello() +{ + ::TestTargetNS::MyBaseClass::hello(); +} +MyTemplate MyBaseClass_wrapper::methodReturnsIntTemplate() +{ + return ::TestTargetNS::MyBaseClass::methodReturnsIntTemplate(); +} +int MyBaseClass_wrapper::nonVirtualButOverridden() const +{ + return ::TestTargetNS::MyBaseClass::nonVirtualButOverridden(); +} +int MyBaseClass_wrapper::nonVirtualInBaseButVirtualInDerived(int i) const +{ + return ::TestTargetNS::MyBaseClass::nonVirtualInBaseButVirtualInDerived(i); +} +int MyBaseClass_wrapper::nonVirtualInBaseButVirtualInDerived(int i, int j) const +{ + if (m_nonVirtualInBaseButVirtualInDerived_2Callback) { + const void *thisPtr = this; + return m_nonVirtualInBaseButVirtualInDerived_2Callback(const_cast(thisPtr), i, j); + } else { + return ::TestTargetNS::MyBaseClass::nonVirtualInBaseButVirtualInDerived(i, j); + } +} +int MyBaseClass_wrapper::nonVirtualInBaseButVirtualInDerived_nocallback(int i, int j) const +{ + return ::TestTargetNS::MyBaseClass::nonVirtualInBaseButVirtualInDerived(i, j); +} +SimpleStruct MyBaseClass_wrapper::nonVirtualReturningStruct() const +{ + return ::TestTargetNS::MyBaseClass::nonVirtualReturningStruct(); +} +void MyBaseClass_wrapper::overloadedStatic() +{ + ::TestTargetNS::MyBaseClass::overloadedStatic(); +} +void MyBaseClass_wrapper::overloadedStatic(int arg__1) +{ + ::TestTargetNS::MyBaseClass::overloadedStatic(arg__1); +} +void MyBaseClass_wrapper::overloadedStatic(int arg__1, int arg__2) +{ + ::TestTargetNS::MyBaseClass::overloadedStatic(arg__1, arg__2); +} +void MyBaseClass_wrapper::print(const char *msg) +{ + ::TestTargetNS::MyBaseClass::print(msg); +} +void MyBaseClass_wrapper::push(const char *arg__1) +{ + ::TestTargetNS::MyBaseClass::push(arg__1); +} +QString MyBaseClass_wrapper::receivesAndReturnsQString(const QString &s) +{ + return ::TestTargetNS::MyBaseClass::receivesAndReturnsQString(s); +} +int MyBaseClass_wrapper::receivesEnum(TestTargetNS::MyBaseClass::MyEnum e) +{ + return ::TestTargetNS::MyBaseClass::receivesEnum(e); +} +void MyBaseClass_wrapper::receivesEnumWithDefaultArg(TestTargetNS::MyBaseClass::MyEnum arg__1) +{ + ::TestTargetNS::MyBaseClass::receivesEnumWithDefaultArg(arg__1); +} +void MyBaseClass_wrapper::receivesEnumWithDefaultArgNull(TestTargetNS::MyBaseClass::MyEnum arg__1) +{ + ::TestTargetNS::MyBaseClass::receivesEnumWithDefaultArgNull(arg__1); +} +void MyBaseClass_wrapper::receivesFloat(float arg__1) +{ + ::TestTargetNS::MyBaseClass::receivesFloat(arg__1); +} +void MyBaseClass_wrapper::receivesQFlags(QFlags arg__1) +{ + ::TestTargetNS::MyBaseClass::receivesQFlags(arg__1); +} +void MyBaseClass_wrapper::receivesintWithDefaultEnumArg(int arg__1) +{ + ::TestTargetNS::MyBaseClass::receivesintWithDefaultEnumArg(arg__1); +} +void MyBaseClass_wrapper::receivesintWithDefaultEnumArg2(int arg__1) +{ + ::TestTargetNS::MyBaseClass::receivesintWithDefaultEnumArg2(arg__1); +} +void MyBaseClass_wrapper::receivesintWithDefaultEnumArg3(int arg__1) +{ + ::TestTargetNS::MyBaseClass::receivesintWithDefaultEnumArg3(arg__1); +} +void MyBaseClass_wrapper::renamedMethod1() +{ + ::TestTargetNS::MyBaseClass::renamedMethod1(); +} +void MyBaseClass_wrapper::renamedVirtual1() +{ + if (m_renamedVirtual2Callback) { + const void *thisPtr = this; + m_renamedVirtual2Callback(const_cast(thisPtr)); + } else { + ::TestTargetNS::MyBaseClass::renamedVirtual1(); + } +} +void MyBaseClass_wrapper::renamedVirtual1_nocallback() +{ + ::TestTargetNS::MyBaseClass::renamedVirtual1(); +} +const char *MyBaseClass_wrapper::returnsConstChar() +{ + return ::TestTargetNS::MyBaseClass::returnsConstChar(); +} +MyTemplate MyBaseClass_wrapper::returnsDoubleTemplate() +{ + return ::TestTargetNS::MyBaseClass::returnsDoubleTemplate(); +} +qint64 MyBaseClass_wrapper::returnsInt64() const +{ + return ::TestTargetNS::MyBaseClass::returnsInt64(); +} +MyTemplate MyBaseClass_wrapper::returnsIntTemplate() +{ + return ::TestTargetNS::MyBaseClass::returnsIntTemplate(); +} +QList MyBaseClass_wrapper::returnsListOfStructPtr() +{ + return ::TestTargetNS::MyBaseClass::returnsListOfStructPtr(); +} +QFlags MyBaseClass_wrapper::returnsQFlags() const +{ + return ::TestTargetNS::MyBaseClass::returnsQFlags(); +} +QString MyBaseClass_wrapper::returnsQString() +{ + return ::TestTargetNS::MyBaseClass::returnsQString(); +} +QList MyBaseClass_wrapper::returnsReals() const +{ + return ::TestTargetNS::MyBaseClass::returnsReals(); +} +SimpleStruct MyBaseClass_wrapper::returnsSimpleStruct(int value) +{ + return ::TestTargetNS::MyBaseClass::returnsSimpleStruct(value); +} +MyTemplateWithTwoArgs MyBaseClass_wrapper::returnsTemplateWithTwoArgs() +{ + return ::TestTargetNS::MyBaseClass::returnsTemplateWithTwoArgs(); +} +QList MyBaseClass_wrapper::returnsVector() +{ + return ::TestTargetNS::MyBaseClass::returnsVector(); +} +bool MyBaseClass_wrapper::setBool(bool b) +{ + return ::TestTargetNS::MyBaseClass::setBool(b); +} +int MyBaseClass_wrapper::sum(int a, int b) +{ + return ::TestTargetNS::MyBaseClass::sum(a, b); +} +int MyBaseClass_wrapper::virtualReceivingBool(bool b) +{ + if (m_virtualReceivingBoolCallback) { + const void *thisPtr = this; + return m_virtualReceivingBoolCallback(const_cast(thisPtr), b); + } else { + return ::TestTargetNS::MyBaseClass::virtualReceivingBool(b); + } +} +int MyBaseClass_wrapper::virtualReceivingBool_nocallback(bool b) +{ + return ::TestTargetNS::MyBaseClass::virtualReceivingBool(b); +} +void MyBaseClass_wrapper::virtualReceivingCharPtr(char *arg__1) +{ + if (m_virtualReceivingCharPtrCallback) { + const void *thisPtr = this; + m_virtualReceivingCharPtrCallback(const_cast(thisPtr), arg__1); + } else { + ::TestTargetNS::MyBaseClass::virtualReceivingCharPtr(arg__1); + } +} +void MyBaseClass_wrapper::virtualReceivingCharPtr_nocallback(char *arg__1) +{ + ::TestTargetNS::MyBaseClass::virtualReceivingCharPtr(arg__1); +} +int MyBaseClass_wrapper::virtualReceivingInt(int arg__1) +{ + if (m_virtualReceivingIntCallback) { + const void *thisPtr = this; + return m_virtualReceivingIntCallback(const_cast(thisPtr), arg__1); + } else { + return ::TestTargetNS::MyBaseClass::virtualReceivingInt(arg__1); + } +} +int MyBaseClass_wrapper::virtualReceivingInt_nocallback(int arg__1) +{ + return ::TestTargetNS::MyBaseClass::virtualReceivingInt(arg__1); +} +int MyBaseClass_wrapper::virtualReceivingOptionalArgument(int optional) +{ + if (m_virtualReceivingOptionalArgumentCallback) { + const void *thisPtr = this; + return m_virtualReceivingOptionalArgumentCallback(const_cast(thisPtr), optional); + } else { + return ::TestTargetNS::MyBaseClass::virtualReceivingOptionalArgument(optional); + } +} +int MyBaseClass_wrapper::virtualReceivingOptionalArgument_nocallback(int optional) +{ + return ::TestTargetNS::MyBaseClass::virtualReceivingOptionalArgument(optional); +} +bool MyBaseClass_wrapper::virtualReturningBool(bool b) +{ + if (m_virtualReturningBoolCallback) { + const void *thisPtr = this; + return m_virtualReturningBoolCallback(const_cast(thisPtr), b); + } else { + return ::TestTargetNS::MyBaseClass::virtualReturningBool(b); + } +} +bool MyBaseClass_wrapper::virtualReturningBool_nocallback(bool b) +{ + return ::TestTargetNS::MyBaseClass::virtualReturningBool(b); +} +qint64 MyBaseClass_wrapper::virtualReturningQint64() +{ + if (m_virtualReturningQint64Callback) { + const void *thisPtr = this; + return m_virtualReturningQint64Callback(const_cast(thisPtr)); + } else { + return ::TestTargetNS::MyBaseClass::virtualReturningQint64(); + } +} +qint64 MyBaseClass_wrapper::virtualReturningQint64_nocallback() +{ + return ::TestTargetNS::MyBaseClass::virtualReturningQint64(); +} +SimpleStruct MyBaseClass_wrapper::virtualReturningStruct() const +{ + if (m_virtualReturningStructCallback) { + const void *thisPtr = this; + return *m_virtualReturningStructCallback(const_cast(thisPtr)); + } else { + return ::TestTargetNS::MyBaseClass::virtualReturningStruct(); + } +} +SimpleStruct MyBaseClass_wrapper::virtualReturningStruct_nocallback() const +{ + return ::TestTargetNS::MyBaseClass::virtualReturningStruct(); +} +MyTemplate MyBaseClass_wrapper::virtualReturnsIntTemplate() +{ + if (m_virtualReturnsIntTemplateCallback) { + const void *thisPtr = this; + return *m_virtualReturnsIntTemplateCallback(const_cast(thisPtr)); + } else { + return ::TestTargetNS::MyBaseClass::virtualReturnsIntTemplate(); + } +} +MyTemplate MyBaseClass_wrapper::virtualReturnsIntTemplate_nocallback() +{ + return ::TestTargetNS::MyBaseClass::virtualReturnsIntTemplate(); +} +void MyBaseClass_wrapper::virtualWithNoDefaultArgumentInDerived(int optional) +{ + if (m_virtualWithNoDefaultArgumentInDerivedCallback) { + const void *thisPtr = this; + m_virtualWithNoDefaultArgumentInDerivedCallback(const_cast(thisPtr), optional); + } else { + ::TestTargetNS::MyBaseClass::virtualWithNoDefaultArgumentInDerived(optional); + } +} +void MyBaseClass_wrapper::virtualWithNoDefaultArgumentInDerived_nocallback(int optional) +{ + ::TestTargetNS::MyBaseClass::virtualWithNoDefaultArgumentInDerived(optional); +} +void MyBaseClass_wrapper::virtualWithOverload(int i) const +{ + if (m_virtualWithOverloadCallback) { + const void *thisPtr = this; + m_virtualWithOverloadCallback(const_cast(thisPtr), i); + } else { + ::TestTargetNS::MyBaseClass::virtualWithOverload(i); + } +} +void MyBaseClass_wrapper::virtualWithOverload_nocallback(int i) const +{ + ::TestTargetNS::MyBaseClass::virtualWithOverload(i); +} +void MyBaseClass_wrapper::virtualWithOverload(int i, int j) const +{ + if (m_virtualWithOverload_2Callback) { + const void *thisPtr = this; + m_virtualWithOverload_2Callback(const_cast(thisPtr), i, j); + } else { + ::TestTargetNS::MyBaseClass::virtualWithOverload(i, j); + } +} +void MyBaseClass_wrapper::virtualWithOverload_nocallback(int i, int j) const +{ + ::TestTargetNS::MyBaseClass::virtualWithOverload(i, j); +} +MyBaseClass_wrapper::~MyBaseClass_wrapper() +{ +} + +} +static TestTargetNS::MyBaseClass *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::MyBaseClass_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_TestTargetNS__MyBaseClass_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} +void *c_TestTargetNS__MyBaseClass__constructor() +{ + auto ptr = new TestBindings_wrappersNS::MyBaseClass_wrapper(); + return reinterpret_cast(ptr); +} +void *c_TestTargetNS__MyBaseClass__constructor_MyBaseClass(void *mybaseclassptr_) +{ + auto mybaseclassptr = reinterpret_cast(mybaseclassptr_); + auto ptr = new TestBindings_wrappersNS::MyBaseClass_wrapper(mybaseclassptr); + return reinterpret_cast(ptr); +} +// addInts(QList arg__1) +void c_TestTargetNS__MyBaseClass__addInts_QList_int(void *thisObj, void *arg__1_) +{ + assert(arg__1_); + auto &arg__1 = *reinterpret_cast *>(arg__1_); + fromPtr(thisObj)->addInts(arg__1); +} +// addQObjects(const QList & arg__1) +void c_TestTargetNS__MyBaseClass__addQObjects_QList_QObject(void *thisObj, void *arg__1_) +{ + assert(arg__1_); + auto &arg__1 = *reinterpret_cast *>(arg__1_); + fromPtr(thisObj)->addQObjects(arg__1); +} +// addReals(QList arg__1) +void c_TestTargetNS__MyBaseClass__addReals_QList_qreal(void *thisObj, void *arg__1_) +{ + assert(arg__1_); + auto &arg__1 = *reinterpret_cast *>(arg__1_); + fromPtr(thisObj)->addReals(arg__1); +} +// anotherOverloadedStatic(int arg__1) +int c_static_TestTargetNS__MyBaseClass__anotherOverloadedStatic_int(int arg__1) +{ + const auto &result = + TestBindings_wrappersNS::MyBaseClass_wrapper::anotherOverloadedStatic(arg__1); + return result; +} +// bar() const +int c_TestTargetNS__MyBaseClass__bar(void *thisObj) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->bar_nocallback(); + } else { + return targetPtr->bar(); + } + }(); + return result; +} +// bar2() const +int c_TestTargetNS__MyBaseClass__bar2(void *thisObj) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->bar2_nocallback(); + } else { + return targetPtr->bar2(); + } + }(); + return result; +} +// callsVirtual() const +int c_TestTargetNS__MyBaseClass__callsVirtual(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->callsVirtual(); + return result; +} +// foo() const +int c_TestTargetNS__MyBaseClass__foo(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->foo(); + return result; +} +// getBool(int arg__1) const +bool c_TestTargetNS__MyBaseClass__getBool_int(void *thisObj, int arg__1) +{ + const auto &result = fromPtr(thisObj)->getBool(arg__1); + return result; +} +// getBoolFalse() const +bool c_TestTargetNS__MyBaseClass__getBoolFalse(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->getBoolFalse(); + return result; +} +// getBoolTrue() const +bool c_TestTargetNS__MyBaseClass__getBoolTrue(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->getBoolTrue(); + return result; +} +// hello() +void c_TestTargetNS__MyBaseClass__hello(void *thisObj) +{ + fromPtr(thisObj)->hello(); +} +// methodReturnsIntTemplate() +void *c_TestTargetNS__MyBaseClass__methodReturnsIntTemplate(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->methodReturnsIntTemplate() + }; + return result; +} +// nonVirtualButOverridden() const +int c_TestTargetNS__MyBaseClass__nonVirtualButOverridden(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->nonVirtualButOverridden(); + return result; +} +// nonVirtualInBaseButVirtualInDerived(int i) const +int c_TestTargetNS__MyBaseClass__nonVirtualInBaseButVirtualInDerived_int(void *thisObj, int i) +{ + const auto &result = fromPtr(thisObj)->nonVirtualInBaseButVirtualInDerived(i); + return result; +} +// nonVirtualInBaseButVirtualInDerived(int i, int j) const +int c_TestTargetNS__MyBaseClass__nonVirtualInBaseButVirtualInDerived_int_int(void *thisObj, int i, + int j) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->nonVirtualInBaseButVirtualInDerived_nocallback(i, j); + } else { + return targetPtr->nonVirtualInBaseButVirtualInDerived(i, j); + } + }(); + return result; +} +// nonVirtualReturningStruct() const +void *c_TestTargetNS__MyBaseClass__nonVirtualReturningStruct(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->nonVirtualReturningStruct() }; + return result; +} +// overloadedStatic() +void c_static_TestTargetNS__MyBaseClass__overloadedStatic() +{ + TestBindings_wrappersNS::MyBaseClass_wrapper::overloadedStatic(); +} +// overloadedStatic(int arg__1) +void c_static_TestTargetNS__MyBaseClass__overloadedStatic_int(int arg__1) +{ + TestBindings_wrappersNS::MyBaseClass_wrapper::overloadedStatic(arg__1); +} +// overloadedStatic(int arg__1, int arg__2) +void c_static_TestTargetNS__MyBaseClass__overloadedStatic_int_int(int arg__1, int arg__2) +{ + TestBindings_wrappersNS::MyBaseClass_wrapper::overloadedStatic(arg__1, arg__2); +} +// print(const char * msg) +void c_static_TestTargetNS__MyBaseClass__print_char(const char *msg) +{ + TestBindings_wrappersNS::MyBaseClass_wrapper::print(msg); + free(( char * )msg); +} +// push(const char * arg__1) +void c_TestTargetNS__MyBaseClass__push_char(void *thisObj, const char *arg__1) +{ + fromPtr(thisObj)->push(arg__1); + free(( char * )arg__1); +} +// receivesAndReturnsQString(const QString & s) +void *c_TestTargetNS__MyBaseClass__receivesAndReturnsQString_QString(void *thisObj, const char *s_) +{ + const auto s = QString::fromUtf8(s_); + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->receivesAndReturnsQString(s) }; + free(( char * )s_); + return result; +} +// receivesEnum(TestTargetNS::MyBaseClass::MyEnum e) +int c_TestTargetNS__MyBaseClass__receivesEnum_MyEnum(void *thisObj, int e) +{ + const auto &result = + fromPtr(thisObj)->receivesEnum(static_cast(e)); + return result; +} +// receivesEnumWithDefaultArg(TestTargetNS::MyBaseClass::MyEnum arg__1) +void c_TestTargetNS__MyBaseClass__receivesEnumWithDefaultArg_MyEnum(void *thisObj, int arg__1) +{ + fromPtr(thisObj)->receivesEnumWithDefaultArg( + static_cast(arg__1)); +} +// receivesEnumWithDefaultArgNull(TestTargetNS::MyBaseClass::MyEnum arg__1) +void c_TestTargetNS__MyBaseClass__receivesEnumWithDefaultArgNull_MyEnum(void *thisObj, int arg__1) +{ + fromPtr(thisObj)->receivesEnumWithDefaultArgNull( + static_cast(arg__1)); +} +// receivesFloat(float arg__1) +void c_TestTargetNS__MyBaseClass__receivesFloat_float(void *thisObj, float arg__1) +{ + fromPtr(thisObj)->receivesFloat(arg__1); +} +// receivesQFlags(QFlags arg__1) +void c_TestTargetNS__MyBaseClass__receivesQFlags_NamespaceLevelEnums(void *thisObj, int arg__1_) +{ + auto arg__1 = static_cast>(arg__1_); + fromPtr(thisObj)->receivesQFlags(arg__1); +} +// receivesintWithDefaultEnumArg(int arg__1) +void c_TestTargetNS__MyBaseClass__receivesintWithDefaultEnumArg_int(void *thisObj, int arg__1) +{ + fromPtr(thisObj)->receivesintWithDefaultEnumArg(arg__1); +} +// receivesintWithDefaultEnumArg2(int arg__1) +void c_TestTargetNS__MyBaseClass__receivesintWithDefaultEnumArg2_int(void *thisObj, int arg__1) +{ + fromPtr(thisObj)->receivesintWithDefaultEnumArg2(arg__1); +} +// receivesintWithDefaultEnumArg3(int arg__1) +void c_TestTargetNS__MyBaseClass__receivesintWithDefaultEnumArg3_int(void *thisObj, int arg__1) +{ + fromPtr(thisObj)->receivesintWithDefaultEnumArg3(arg__1); +} +// renamedMethod1() +void c_TestTargetNS__MyBaseClass__renamedMethod2(void *thisObj) +{ + fromPtr(thisObj)->renamedMethod1(); +} +// renamedVirtual1() +void c_TestTargetNS__MyBaseClass__renamedVirtual2(void *thisObj) +{ + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->renamedVirtual1_nocallback(); + } else { + return targetPtr->renamedVirtual1(); + } + }(); +} +// returnsConstChar() +const char *c_static_TestTargetNS__MyBaseClass__returnsConstChar() +{ + const auto &result = TestBindings_wrappersNS::MyBaseClass_wrapper::returnsConstChar(); + return result; +} +// returnsDoubleTemplate() +void *c_static_TestTargetNS__MyBaseClass__returnsDoubleTemplate() +{ + const auto &result = new Dartagnan::ValueWrapper> { + TestBindings_wrappersNS::MyBaseClass_wrapper::returnsDoubleTemplate() + }; + return result; +} +// returnsInt64() const +qint64 c_TestTargetNS__MyBaseClass__returnsInt64(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->returnsInt64(); + return result; +} +// returnsIntTemplate() +void *c_static_TestTargetNS__MyBaseClass__returnsIntTemplate() +{ + const auto &result = new Dartagnan::ValueWrapper> { + TestBindings_wrappersNS::MyBaseClass_wrapper::returnsIntTemplate() + }; + return result; +} +// returnsListOfStructPtr() +void *c_static_TestTargetNS__MyBaseClass__returnsListOfStructPtr() +{ + const auto &result = new Dartagnan::ValueWrapper> { + TestBindings_wrappersNS::MyBaseClass_wrapper::returnsListOfStructPtr() + }; + return result; +} +// returnsQFlags() const +int c_TestTargetNS__MyBaseClass__returnsQFlags(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->returnsQFlags(); + return result; +} +// returnsQString() +void *c_static_TestTargetNS__MyBaseClass__returnsQString() +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::MyBaseClass_wrapper::returnsQString() + }; + return result; +} +// returnsReals() const +void *c_TestTargetNS__MyBaseClass__returnsReals(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->returnsReals() }; + return result; +} +// returnsSimpleStruct(int value) +void *c_static_TestTargetNS__MyBaseClass__returnsSimpleStruct_int(int value) +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::MyBaseClass_wrapper::returnsSimpleStruct(value) + }; + return result; +} +// returnsTemplateWithTwoArgs() +void *c_static_TestTargetNS__MyBaseClass__returnsTemplateWithTwoArgs() +{ + const auto &result = new Dartagnan::ValueWrapper> { + TestBindings_wrappersNS::MyBaseClass_wrapper::returnsTemplateWithTwoArgs() + }; + return result; +} +// returnsVector() +void *c_TestTargetNS__MyBaseClass__returnsVector(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->returnsVector() }; + return result; +} +// setBool(bool b) +bool c_TestTargetNS__MyBaseClass__setBool_bool(void *thisObj, bool b) +{ + const auto &result = fromPtr(thisObj)->setBool(b); + return result; +} +// sum(int a, int b) +int c_TestTargetNS__MyBaseClass__sum_int_int(void *thisObj, int a, int b) +{ + const auto &result = fromPtr(thisObj)->sum(a, b); + return result; +} +// virtualReceivingBool(bool b) +int c_TestTargetNS__MyBaseClass__virtualReceivingBool_bool(void *thisObj, bool b) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualReceivingBool_nocallback(b); + } else { + return targetPtr->virtualReceivingBool(b); + } + }(); + return result; +} +// virtualReceivingCharPtr(char * arg__1) +void c_TestTargetNS__MyBaseClass__virtualReceivingCharPtr_char(void *thisObj, char *arg__1) +{ + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualReceivingCharPtr_nocallback(arg__1); + } else { + return targetPtr->virtualReceivingCharPtr(arg__1); + } + }(); + free(( char * )arg__1); +} +// virtualReceivingInt(int arg__1) +int c_TestTargetNS__MyBaseClass__virtualReceivingInt_int(void *thisObj, int arg__1) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualReceivingInt_nocallback(arg__1); + } else { + return targetPtr->virtualReceivingInt(arg__1); + } + }(); + return result; +} +// virtualReceivingOptionalArgument(int optional) +int c_TestTargetNS__MyBaseClass__virtualReceivingOptionalArgument_int(void *thisObj, int optional) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualReceivingOptionalArgument_nocallback(optional); + } else { + return targetPtr->virtualReceivingOptionalArgument(optional); + } + }(); + return result; +} +// virtualReturningBool(bool b) +bool c_TestTargetNS__MyBaseClass__virtualReturningBool_bool(void *thisObj, bool b) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualReturningBool_nocallback(b); + } else { + return targetPtr->virtualReturningBool(b); + } + }(); + return result; +} +// virtualReturningQint64() +qint64 c_TestTargetNS__MyBaseClass__virtualReturningQint64(void *thisObj) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualReturningQint64_nocallback(); + } else { + return targetPtr->virtualReturningQint64(); + } + }(); + return result; +} +// virtualReturningStruct() const +void *c_TestTargetNS__MyBaseClass__virtualReturningStruct(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualReturningStruct_nocallback(); + } else { + return targetPtr->virtualReturningStruct(); + } + }() }; + return result; +} +// virtualReturnsIntTemplate() +void *c_TestTargetNS__MyBaseClass__virtualReturnsIntTemplate(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper> { [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualReturnsIntTemplate_nocallback(); + } else { + return targetPtr->virtualReturnsIntTemplate(); + } + }() }; + return result; +} +// virtualWithNoDefaultArgumentInDerived(int optional) +void c_TestTargetNS__MyBaseClass__virtualWithNoDefaultArgumentInDerived_int(void *thisObj, + int optional) +{ + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualWithNoDefaultArgumentInDerived_nocallback(optional); + } else { + return targetPtr->virtualWithNoDefaultArgumentInDerived(optional); + } + }(); +} +// virtualWithOverload(int i) const +void c_TestTargetNS__MyBaseClass__virtualWithOverload_int(void *thisObj, int i) +{ + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualWithOverload_nocallback(i); + } else { + return targetPtr->virtualWithOverload(i); + } + }(); +} +// virtualWithOverload(int i, int j) const +void c_TestTargetNS__MyBaseClass__virtualWithOverload_int_int(void *thisObj, int i, int j) +{ + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualWithOverload_nocallback(i, j); + } else { + return targetPtr->virtualWithOverload(i, j); + } + }(); +} +void c_TestTargetNS__MyBaseClass__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +int c_static_TestTargetNS__MyBaseClass___get_s_instanceCount() +{ + return TestBindings_wrappersNS::MyBaseClass_wrapper::s_instanceCount; +} +int c_static_TestTargetNS__MyBaseClass___get_s_staticMember() +{ + return TestBindings_wrappersNS::MyBaseClass_wrapper::s_staticMember; +} +int c_static_TestTargetNS__MyBaseClass___get_s_staticConstMember() +{ + return TestBindings_wrappersNS::MyBaseClass_wrapper::s_staticConstMember; +} +void c_static_TestTargetNS__MyBaseClass___set_s_instanceCount_int(int s_instanceCount_) +{ + TestBindings_wrappersNS::MyBaseClass_wrapper::s_instanceCount = s_instanceCount_; +} +void c_static_TestTargetNS__MyBaseClass___set_s_staticMember_int(int s_staticMember_) +{ + TestBindings_wrappersNS::MyBaseClass_wrapper::s_staticMember = s_staticMember_; +} +void c_TestTargetNS__MyBaseClass__registerVirtualMethodCallback(void *ptr, void *callback, + int methodId) +{ + auto wrapper = fromWrapperPtr(ptr); + switch (methodId) { + case 51: + wrapper->m_barCallback = + reinterpret_cast(callback); + break; + case 52: + wrapper->m_bar2Callback = + reinterpret_cast(callback); + break; + case 63: + wrapper->m_nonVirtualInBaseButVirtualInDerived_2Callback = + reinterpret_cast(callback); + break; + case 86: + wrapper->m_renamedVirtual2Callback = reinterpret_cast< + TestBindings_wrappersNS::MyBaseClass_wrapper::Callback_renamedVirtual2>(callback); + break; + case 103: + wrapper->m_virtualReceivingBoolCallback = reinterpret_cast< + TestBindings_wrappersNS::MyBaseClass_wrapper::Callback_virtualReceivingBool>(callback); + break; + case 104: + wrapper->m_virtualReceivingCharPtrCallback = reinterpret_cast< + TestBindings_wrappersNS::MyBaseClass_wrapper::Callback_virtualReceivingCharPtr>( + callback); + break; + case 105: + wrapper->m_virtualReceivingIntCallback = reinterpret_cast< + TestBindings_wrappersNS::MyBaseClass_wrapper::Callback_virtualReceivingInt>(callback); + break; + case 106: + wrapper->m_virtualReceivingOptionalArgumentCallback = + reinterpret_cast(callback); + break; + case 107: + wrapper->m_virtualReturningBoolCallback = reinterpret_cast< + TestBindings_wrappersNS::MyBaseClass_wrapper::Callback_virtualReturningBool>(callback); + break; + case 108: + wrapper->m_virtualReturningQint64Callback = reinterpret_cast< + TestBindings_wrappersNS::MyBaseClass_wrapper::Callback_virtualReturningQint64>( + callback); + break; + case 109: + wrapper->m_virtualReturningStructCallback = reinterpret_cast< + TestBindings_wrappersNS::MyBaseClass_wrapper::Callback_virtualReturningStruct>( + callback); + break; + case 110: + wrapper->m_virtualReturnsIntTemplateCallback = reinterpret_cast< + TestBindings_wrappersNS::MyBaseClass_wrapper::Callback_virtualReturnsIntTemplate>( + callback); + break; + case 111: + wrapper->m_virtualWithNoDefaultArgumentInDerivedCallback = + reinterpret_cast(callback); + break; + case 112: + wrapper->m_virtualWithOverloadCallback = reinterpret_cast< + TestBindings_wrappersNS::MyBaseClass_wrapper::Callback_virtualWithOverload>(callback); + break; + case 113: + wrapper->m_virtualWithOverload_2Callback = reinterpret_cast< + TestBindings_wrappersNS::MyBaseClass_wrapper::Callback_virtualWithOverload_2>(callback); + break; + } +} +} diff --git a/tests/generated/TestBindings/dart/ffi/MyBaseClass_c.h b/tests/generated/TestBindings/dart/ffi/MyBaseClass_c.h new file mode 100644 index 0000000..27ad26f --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/MyBaseClass_c.h @@ -0,0 +1,279 @@ +#include "TestBindings_exports.h" +#include +#include +#include +#include + +namespace TestBindings_wrappersNS { +class MyBaseClass_wrapper : public ::TestTargetNS::MyBaseClass +{ +public: + ~MyBaseClass_wrapper(); + using ::TestTargetNS::MyBaseClass::ProtectedEnum; + MyBaseClass_wrapper(); + MyBaseClass_wrapper(TestTargetNS::MyBaseClass *mybaseclassptr); + void addInts(QList arg__1); + void addQObjects(const QList &arg__1); + void addReals(QList arg__1); + static int anotherOverloadedStatic(int arg__1); + virtual int bar() const; + virtual int bar_nocallback() const; + virtual int bar2() const; + virtual int bar2_nocallback() const; + int callsVirtual() const; + int foo() const; + bool getBool(int arg__1) const; + bool getBoolFalse() const; + bool getBoolTrue() const; + void hello(); + MyTemplate methodReturnsIntTemplate(); + int nonVirtualButOverridden() const; + int nonVirtualInBaseButVirtualInDerived(int i) const; + virtual int nonVirtualInBaseButVirtualInDerived(int i, int j) const; + virtual int nonVirtualInBaseButVirtualInDerived_nocallback(int i, int j) const; + SimpleStruct nonVirtualReturningStruct() const; + static void overloadedStatic(); + static void overloadedStatic(int arg__1); + static void overloadedStatic(int arg__1, int arg__2); + static void print(const char *msg); + void push(const char *arg__1); + QString receivesAndReturnsQString(const QString &s); + int receivesEnum(TestTargetNS::MyBaseClass::MyEnum e); + void receivesEnumWithDefaultArg(TestTargetNS::MyBaseClass::MyEnum arg__1 = + TestTargetNS::MyBaseClass::MyEnum::MyEnumerator0); + void receivesEnumWithDefaultArgNull(TestTargetNS::MyBaseClass::MyEnum arg__1 = {}); + void receivesFloat(float arg__1); + void receivesQFlags(QFlags arg__1); + void + receivesintWithDefaultEnumArg(int arg__1 = TestTargetNS::MyBaseClass::MyEnum::MyEnumerator0); + void + receivesintWithDefaultEnumArg2(int arg__1 = TestTargetNS::MyBaseClass::AnonymousEnumerator1); + void + receivesintWithDefaultEnumArg3(int arg__1 = TestTargetNS::MyBaseClass::MyEnum::MyEnumerator0); + void renamedMethod1(); + virtual void renamedVirtual1(); + virtual void renamedVirtual1_nocallback(); + static const char *returnsConstChar(); + static MyTemplate returnsDoubleTemplate(); + qint64 returnsInt64() const; + static MyTemplate returnsIntTemplate(); + static QList returnsListOfStructPtr(); + QFlags returnsQFlags() const; + static QString returnsQString(); + QList returnsReals() const; + static SimpleStruct returnsSimpleStruct(int value); + static MyTemplateWithTwoArgs returnsTemplateWithTwoArgs(); + QList returnsVector(); + bool setBool(bool b); + int sum(int a, int b); + virtual int virtualReceivingBool(bool b); + virtual int virtualReceivingBool_nocallback(bool b); + virtual void virtualReceivingCharPtr(char *arg__1); + virtual void virtualReceivingCharPtr_nocallback(char *arg__1); + virtual int virtualReceivingInt(int arg__1); + virtual int virtualReceivingInt_nocallback(int arg__1); + virtual int virtualReceivingOptionalArgument(int optional = 1); + virtual int virtualReceivingOptionalArgument_nocallback(int optional = 1); + virtual bool virtualReturningBool(bool b); + virtual bool virtualReturningBool_nocallback(bool b); + virtual qint64 virtualReturningQint64(); + virtual qint64 virtualReturningQint64_nocallback(); + virtual SimpleStruct virtualReturningStruct() const; + virtual SimpleStruct virtualReturningStruct_nocallback() const; + virtual MyTemplate virtualReturnsIntTemplate(); + virtual MyTemplate virtualReturnsIntTemplate_nocallback(); + virtual void virtualWithNoDefaultArgumentInDerived(int optional = 1); + virtual void virtualWithNoDefaultArgumentInDerived_nocallback(int optional = 1); + virtual void virtualWithOverload(int i) const; + virtual void virtualWithOverload_nocallback(int i) const; + virtual void virtualWithOverload(int i, int j) const; + virtual void virtualWithOverload_nocallback(int i, int j) const; + typedef int (*Callback_bar)(void *); + Callback_bar m_barCallback = nullptr; + typedef int (*Callback_bar2)(void *); + Callback_bar2 m_bar2Callback = nullptr; + typedef int (*Callback_nonVirtualInBaseButVirtualInDerived_2)(void *, int i, int j); + Callback_nonVirtualInBaseButVirtualInDerived_2 m_nonVirtualInBaseButVirtualInDerived_2Callback = + nullptr; + typedef void (*Callback_renamedVirtual2)(void *); + Callback_renamedVirtual2 m_renamedVirtual2Callback = nullptr; + typedef int (*Callback_virtualReceivingBool)(void *, bool b); + Callback_virtualReceivingBool m_virtualReceivingBoolCallback = nullptr; + typedef void (*Callback_virtualReceivingCharPtr)(void *, char *arg__1); + Callback_virtualReceivingCharPtr m_virtualReceivingCharPtrCallback = nullptr; + typedef int (*Callback_virtualReceivingInt)(void *, int arg__1); + Callback_virtualReceivingInt m_virtualReceivingIntCallback = nullptr; + typedef int (*Callback_virtualReceivingOptionalArgument)(void *, int optional); + Callback_virtualReceivingOptionalArgument m_virtualReceivingOptionalArgumentCallback = nullptr; + typedef bool (*Callback_virtualReturningBool)(void *, bool b); + Callback_virtualReturningBool m_virtualReturningBoolCallback = nullptr; + typedef qint64 (*Callback_virtualReturningQint64)(void *); + Callback_virtualReturningQint64 m_virtualReturningQint64Callback = nullptr; + typedef SimpleStruct *(*Callback_virtualReturningStruct)(void *); + Callback_virtualReturningStruct m_virtualReturningStructCallback = nullptr; + typedef MyTemplate *(*Callback_virtualReturnsIntTemplate)(void *); + Callback_virtualReturnsIntTemplate m_virtualReturnsIntTemplateCallback = nullptr; + typedef void (*Callback_virtualWithNoDefaultArgumentInDerived)(void *, int optional); + Callback_virtualWithNoDefaultArgumentInDerived m_virtualWithNoDefaultArgumentInDerivedCallback = + nullptr; + typedef void (*Callback_virtualWithOverload)(void *, int i); + Callback_virtualWithOverload m_virtualWithOverloadCallback = nullptr; + typedef void (*Callback_virtualWithOverload_2)(void *, int i, int j); + Callback_virtualWithOverload_2 m_virtualWithOverload_2Callback = nullptr; +}; +} +extern "C" { +// TestTargetNS::MyBaseClass::MyBaseClass() +TestBindings_EXPORT void *c_TestTargetNS__MyBaseClass__constructor(); +// TestTargetNS::MyBaseClass::MyBaseClass(TestTargetNS::MyBaseClass * mybaseclassptr) +TestBindings_EXPORT void * +c_TestTargetNS__MyBaseClass__constructor_MyBaseClass(void *mybaseclassptr_); +// TestTargetNS::MyBaseClass::addInts(QList arg__1) +TestBindings_EXPORT void c_TestTargetNS__MyBaseClass__addInts_QList_int(void *thisObj, + void *arg__1_); +// TestTargetNS::MyBaseClass::addQObjects(const QList & arg__1) +TestBindings_EXPORT void c_TestTargetNS__MyBaseClass__addQObjects_QList_QObject(void *thisObj, + void *arg__1_); +// TestTargetNS::MyBaseClass::addReals(QList arg__1) +TestBindings_EXPORT void c_TestTargetNS__MyBaseClass__addReals_QList_qreal(void *thisObj, + void *arg__1_); +// TestTargetNS::MyBaseClass::anotherOverloadedStatic(int arg__1) +TestBindings_EXPORT int c_static_TestTargetNS__MyBaseClass__anotherOverloadedStatic_int(int arg__1); +// TestTargetNS::MyBaseClass::bar() const +TestBindings_EXPORT int c_TestTargetNS__MyBaseClass__bar(void *thisObj); +// TestTargetNS::MyBaseClass::bar2() const +TestBindings_EXPORT int c_TestTargetNS__MyBaseClass__bar2(void *thisObj); +// TestTargetNS::MyBaseClass::callsVirtual() const +TestBindings_EXPORT int c_TestTargetNS__MyBaseClass__callsVirtual(void *thisObj); +// TestTargetNS::MyBaseClass::foo() const +TestBindings_EXPORT int c_TestTargetNS__MyBaseClass__foo(void *thisObj); +// TestTargetNS::MyBaseClass::getBool(int arg__1) const +TestBindings_EXPORT bool c_TestTargetNS__MyBaseClass__getBool_int(void *thisObj, int arg__1); +// TestTargetNS::MyBaseClass::getBoolFalse() const +TestBindings_EXPORT bool c_TestTargetNS__MyBaseClass__getBoolFalse(void *thisObj); +// TestTargetNS::MyBaseClass::getBoolTrue() const +TestBindings_EXPORT bool c_TestTargetNS__MyBaseClass__getBoolTrue(void *thisObj); +// TestTargetNS::MyBaseClass::hello() +TestBindings_EXPORT void c_TestTargetNS__MyBaseClass__hello(void *thisObj); +// TestTargetNS::MyBaseClass::methodReturnsIntTemplate() +TestBindings_EXPORT void *c_TestTargetNS__MyBaseClass__methodReturnsIntTemplate(void *thisObj); +// TestTargetNS::MyBaseClass::nonVirtualButOverridden() const +TestBindings_EXPORT int c_TestTargetNS__MyBaseClass__nonVirtualButOverridden(void *thisObj); +// TestTargetNS::MyBaseClass::nonVirtualInBaseButVirtualInDerived(int i) const +TestBindings_EXPORT int +c_TestTargetNS__MyBaseClass__nonVirtualInBaseButVirtualInDerived_int(void *thisObj, int i); +// TestTargetNS::MyBaseClass::nonVirtualInBaseButVirtualInDerived(int i, int j) const +TestBindings_EXPORT int +c_TestTargetNS__MyBaseClass__nonVirtualInBaseButVirtualInDerived_int_int(void *thisObj, int i, + int j); +// TestTargetNS::MyBaseClass::nonVirtualReturningStruct() const +TestBindings_EXPORT void *c_TestTargetNS__MyBaseClass__nonVirtualReturningStruct(void *thisObj); +// TestTargetNS::MyBaseClass::overloadedStatic() +TestBindings_EXPORT void c_static_TestTargetNS__MyBaseClass__overloadedStatic(); +// TestTargetNS::MyBaseClass::overloadedStatic(int arg__1) +TestBindings_EXPORT void c_static_TestTargetNS__MyBaseClass__overloadedStatic_int(int arg__1); +// TestTargetNS::MyBaseClass::overloadedStatic(int arg__1, int arg__2) +TestBindings_EXPORT void c_static_TestTargetNS__MyBaseClass__overloadedStatic_int_int(int arg__1, + int arg__2); +// TestTargetNS::MyBaseClass::print(const char * msg) +TestBindings_EXPORT void c_static_TestTargetNS__MyBaseClass__print_char(const char *msg); +// TestTargetNS::MyBaseClass::push(const char * arg__1) +TestBindings_EXPORT void c_TestTargetNS__MyBaseClass__push_char(void *thisObj, const char *arg__1); +// TestTargetNS::MyBaseClass::receivesAndReturnsQString(const QString & s) +TestBindings_EXPORT void * +c_TestTargetNS__MyBaseClass__receivesAndReturnsQString_QString(void *thisObj, const char *s_); +// TestTargetNS::MyBaseClass::receivesEnum(TestTargetNS::MyBaseClass::MyEnum e) +TestBindings_EXPORT int c_TestTargetNS__MyBaseClass__receivesEnum_MyEnum(void *thisObj, int e); +// TestTargetNS::MyBaseClass::receivesEnumWithDefaultArg(TestTargetNS::MyBaseClass::MyEnum arg__1) +TestBindings_EXPORT void +c_TestTargetNS__MyBaseClass__receivesEnumWithDefaultArg_MyEnum(void *thisObj, int arg__1); +// TestTargetNS::MyBaseClass::receivesEnumWithDefaultArgNull(TestTargetNS::MyBaseClass::MyEnum +// arg__1) +TestBindings_EXPORT void +c_TestTargetNS__MyBaseClass__receivesEnumWithDefaultArgNull_MyEnum(void *thisObj, int arg__1); +// TestTargetNS::MyBaseClass::receivesFloat(float arg__1) +TestBindings_EXPORT void c_TestTargetNS__MyBaseClass__receivesFloat_float(void *thisObj, + float arg__1); +// TestTargetNS::MyBaseClass::receivesQFlags(QFlags arg__1) +TestBindings_EXPORT void +c_TestTargetNS__MyBaseClass__receivesQFlags_NamespaceLevelEnums(void *thisObj, int arg__1_); +// TestTargetNS::MyBaseClass::receivesintWithDefaultEnumArg(int arg__1) +TestBindings_EXPORT void +c_TestTargetNS__MyBaseClass__receivesintWithDefaultEnumArg_int(void *thisObj, int arg__1); +// TestTargetNS::MyBaseClass::receivesintWithDefaultEnumArg2(int arg__1) +TestBindings_EXPORT void +c_TestTargetNS__MyBaseClass__receivesintWithDefaultEnumArg2_int(void *thisObj, int arg__1); +// TestTargetNS::MyBaseClass::receivesintWithDefaultEnumArg3(int arg__1) +TestBindings_EXPORT void +c_TestTargetNS__MyBaseClass__receivesintWithDefaultEnumArg3_int(void *thisObj, int arg__1); +// TestTargetNS::MyBaseClass::renamedMethod1() +TestBindings_EXPORT void c_TestTargetNS__MyBaseClass__renamedMethod2(void *thisObj); +// TestTargetNS::MyBaseClass::renamedVirtual1() +TestBindings_EXPORT void c_TestTargetNS__MyBaseClass__renamedVirtual2(void *thisObj); +// TestTargetNS::MyBaseClass::returnsConstChar() +TestBindings_EXPORT const char *c_static_TestTargetNS__MyBaseClass__returnsConstChar(); +// TestTargetNS::MyBaseClass::returnsDoubleTemplate() +TestBindings_EXPORT void *c_static_TestTargetNS__MyBaseClass__returnsDoubleTemplate(); +// TestTargetNS::MyBaseClass::returnsInt64() const +TestBindings_EXPORT qint64 c_TestTargetNS__MyBaseClass__returnsInt64(void *thisObj); +// TestTargetNS::MyBaseClass::returnsIntTemplate() +TestBindings_EXPORT void *c_static_TestTargetNS__MyBaseClass__returnsIntTemplate(); +// TestTargetNS::MyBaseClass::returnsListOfStructPtr() +TestBindings_EXPORT void *c_static_TestTargetNS__MyBaseClass__returnsListOfStructPtr(); +// TestTargetNS::MyBaseClass::returnsQFlags() const +TestBindings_EXPORT int c_TestTargetNS__MyBaseClass__returnsQFlags(void *thisObj); +// TestTargetNS::MyBaseClass::returnsQString() +TestBindings_EXPORT void *c_static_TestTargetNS__MyBaseClass__returnsQString(); +// TestTargetNS::MyBaseClass::returnsReals() const +TestBindings_EXPORT void *c_TestTargetNS__MyBaseClass__returnsReals(void *thisObj); +// TestTargetNS::MyBaseClass::returnsSimpleStruct(int value) +TestBindings_EXPORT void *c_static_TestTargetNS__MyBaseClass__returnsSimpleStruct_int(int value); +// TestTargetNS::MyBaseClass::returnsTemplateWithTwoArgs() +TestBindings_EXPORT void *c_static_TestTargetNS__MyBaseClass__returnsTemplateWithTwoArgs(); +// TestTargetNS::MyBaseClass::returnsVector() +TestBindings_EXPORT void *c_TestTargetNS__MyBaseClass__returnsVector(void *thisObj); +// TestTargetNS::MyBaseClass::setBool(bool b) +TestBindings_EXPORT bool c_TestTargetNS__MyBaseClass__setBool_bool(void *thisObj, bool b); +// TestTargetNS::MyBaseClass::sum(int a, int b) +TestBindings_EXPORT int c_TestTargetNS__MyBaseClass__sum_int_int(void *thisObj, int a, int b); +// TestTargetNS::MyBaseClass::virtualReceivingBool(bool b) +TestBindings_EXPORT int c_TestTargetNS__MyBaseClass__virtualReceivingBool_bool(void *thisObj, + bool b); +// TestTargetNS::MyBaseClass::virtualReceivingCharPtr(char * arg__1) +TestBindings_EXPORT void c_TestTargetNS__MyBaseClass__virtualReceivingCharPtr_char(void *thisObj, + char *arg__1); +// TestTargetNS::MyBaseClass::virtualReceivingInt(int arg__1) +TestBindings_EXPORT int c_TestTargetNS__MyBaseClass__virtualReceivingInt_int(void *thisObj, + int arg__1); +// TestTargetNS::MyBaseClass::virtualReceivingOptionalArgument(int optional) +TestBindings_EXPORT int +c_TestTargetNS__MyBaseClass__virtualReceivingOptionalArgument_int(void *thisObj, int optional); +// TestTargetNS::MyBaseClass::virtualReturningBool(bool b) +TestBindings_EXPORT bool c_TestTargetNS__MyBaseClass__virtualReturningBool_bool(void *thisObj, + bool b); +// TestTargetNS::MyBaseClass::virtualReturningQint64() +TestBindings_EXPORT qint64 c_TestTargetNS__MyBaseClass__virtualReturningQint64(void *thisObj); +// TestTargetNS::MyBaseClass::virtualReturningStruct() const +TestBindings_EXPORT void *c_TestTargetNS__MyBaseClass__virtualReturningStruct(void *thisObj); +// TestTargetNS::MyBaseClass::virtualReturnsIntTemplate() +TestBindings_EXPORT void *c_TestTargetNS__MyBaseClass__virtualReturnsIntTemplate(void *thisObj); +// TestTargetNS::MyBaseClass::virtualWithNoDefaultArgumentInDerived(int optional) +TestBindings_EXPORT void +c_TestTargetNS__MyBaseClass__virtualWithNoDefaultArgumentInDerived_int(void *thisObj, int optional); +// TestTargetNS::MyBaseClass::virtualWithOverload(int i) const +TestBindings_EXPORT void c_TestTargetNS__MyBaseClass__virtualWithOverload_int(void *thisObj, int i); +// TestTargetNS::MyBaseClass::virtualWithOverload(int i, int j) const +TestBindings_EXPORT void c_TestTargetNS__MyBaseClass__virtualWithOverload_int_int(void *thisObj, + int i, int j); +TestBindings_EXPORT void c_TestTargetNS__MyBaseClass__destructor(void *thisObj); +TestBindings_EXPORT int c_static_TestTargetNS__MyBaseClass___get_s_instanceCount(); +TestBindings_EXPORT int c_static_TestTargetNS__MyBaseClass___get_s_staticMember(); +TestBindings_EXPORT int c_static_TestTargetNS__MyBaseClass___get_s_staticConstMember(); +TestBindings_EXPORT void +c_static_TestTargetNS__MyBaseClass___set_s_instanceCount_int(int s_instanceCount_); +TestBindings_EXPORT void +c_static_TestTargetNS__MyBaseClass___set_s_staticMember_int(int s_staticMember_); +TestBindings_EXPORT void +c_TestTargetNS__MyBaseClass__registerVirtualMethodCallback(void *ptr, void *callback, int methodId); +TestBindings_EXPORT void c_TestTargetNS__MyBaseClass_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/MyDerivedClass_c.cpp b/tests/generated/TestBindings/dart/ffi/MyDerivedClass_c.cpp new file mode 100644 index 0000000..dd24122 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/MyDerivedClass_c.cpp @@ -0,0 +1,780 @@ +#include "MyDerivedClass_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +MyDerivedClass_wrapper::MyDerivedClass_wrapper() + : ::TestTargetNS::MyDerivedClass() +{ +} +int MyDerivedClass_wrapper::alsoCallsVirtual() +{ + return ::TestTargetNS::MyDerivedClass::alsoCallsVirtual(); +} +const TestTargetNS::MyDerivedClass *MyDerivedClass_wrapper::anotherOverloadedStatic(int arg__1) +{ + return ::TestTargetNS::MyDerivedClass::anotherOverloadedStatic(arg__1); +} +const TestTargetNS::MyDerivedClass *MyDerivedClass_wrapper::anotherOverloadedStatic(int arg__1, + int arg__2) +{ + return ::TestTargetNS::MyDerivedClass::anotherOverloadedStatic(arg__1, arg__2); +} +int MyDerivedClass_wrapper::bar() const +{ + if (m_barCallback) { + const void *thisPtr = this; + return m_barCallback(const_cast(thisPtr)); + } else { + return ::TestTargetNS::MyDerivedClass::bar(); + } +} +int MyDerivedClass_wrapper::bar_nocallback() const +{ + return ::TestTargetNS::MyDerivedClass::bar(); +} +int MyDerivedClass_wrapper::bar2() const +{ + if (m_bar2Callback) { + const void *thisPtr = this; + return m_bar2Callback(const_cast(thisPtr)); + } else { + return ::TestTargetNS::MyDerivedClass::bar2(); + } +} +int MyDerivedClass_wrapper::bar2_nocallback() const +{ + return ::TestTargetNS::MyDerivedClass::bar2(); +} +int MyDerivedClass_wrapper::nonVirtualButOverridden() const +{ + return ::TestTargetNS::MyDerivedClass::nonVirtualButOverridden(); +} +int MyDerivedClass_wrapper::nonVirtualInBaseButVirtualInDerived(int i, int j) const +{ + if (m_nonVirtualInBaseButVirtualInDerived_2Callback) { + const void *thisPtr = this; + return m_nonVirtualInBaseButVirtualInDerived_2Callback(const_cast(thisPtr), i, j); + } else { + return ::TestTargetNS::MyDerivedClass::nonVirtualInBaseButVirtualInDerived(i, j); + } +} +int MyDerivedClass_wrapper::nonVirtualInBaseButVirtualInDerived_nocallback(int i, int j) const +{ + return ::TestTargetNS::MyDerivedClass::nonVirtualInBaseButVirtualInDerived(i, j); +} +void MyDerivedClass_wrapper::paintEvent() +{ + if (m_paintEventCallback) { + const void *thisPtr = this; + m_paintEventCallback(const_cast(thisPtr)); + } else { + ::TestTargetNS::MyDerivedClass::paintEvent(); + } +} +void MyDerivedClass_wrapper::paintEvent_nocallback() +{ + ::TestTargetNS::MyDerivedClass::paintEvent(); +} +int MyDerivedClass_wrapper::receivesDerivedPolymorphic(TestTargetNS::MyDerivedClass *der) +{ + if (m_receivesDerivedPolymorphicCallback) { + const void *thisPtr = this; + return m_receivesDerivedPolymorphicCallback(const_cast(thisPtr), der); + } else { + return ::TestTargetNS::MyDerivedClass::receivesDerivedPolymorphic(der); + } +} +int MyDerivedClass_wrapper::receivesDerivedPolymorphic_nocallback(TestTargetNS::MyDerivedClass *der) +{ + return ::TestTargetNS::MyDerivedClass::receivesDerivedPolymorphic(der); +} +void MyDerivedClass_wrapper::receivesEnumFromBaseClassWithDefaultValue(int a) +{ + ::TestTargetNS::MyDerivedClass::receivesEnumFromBaseClassWithDefaultValue(a); +} +int MyDerivedClass_wrapper::receivesProtectedEnum(TestTargetNS::MyBaseClass::ProtectedEnum p) +{ + return ::TestTargetNS::MyDerivedClass::receivesProtectedEnum(p); +} +void MyDerivedClass_wrapper::renamedVirtual1() +{ + if (m_renamedVirtual2Callback) { + const void *thisPtr = this; + m_renamedVirtual2Callback(const_cast(thisPtr)); + } else { + ::TestTargetNS::MyDerivedClass::renamedVirtual1(); + } +} +void MyDerivedClass_wrapper::renamedVirtual1_nocallback() +{ + ::TestTargetNS::MyDerivedClass::renamedVirtual1(); +} +MyTemplate2 MyDerivedClass_wrapper::returnTemplate1() +{ + return ::TestTargetNS::MyDerivedClass::returnTemplate1(); +} +const MyTemplate2 &MyDerivedClass_wrapper::returnTemplate2() +{ + return ::TestTargetNS::MyDerivedClass::returnTemplate2(); +} +AnotherNamespace::NamespaceLevelEnum MyDerivedClass_wrapper::returnsAnotherNamespaceEnum() +{ + return ::TestTargetNS::MyDerivedClass::returnsAnotherNamespaceEnum(); +} +AnotherNamespace::AnotherNamespaceStruct MyDerivedClass_wrapper::returnsAnotherNamespaceStruct() +{ + return ::TestTargetNS::MyDerivedClass::returnsAnotherNamespaceStruct(); +} +const TestTargetNS::MyDerivedClass *MyDerivedClass_wrapper::returnsConstPointer() +{ + return ::TestTargetNS::MyDerivedClass::returnsConstPointer(); +} +void MyDerivedClass_wrapper::setVisible(bool b) +{ + if (m_setVisibleCallback) { + const void *thisPtr = this; + m_setVisibleCallback(const_cast(thisPtr), b); + } else { + ::TestTargetNS::MyDerivedClass::setVisible(b); + } +} +void MyDerivedClass_wrapper::setVisible_nocallback(bool b) +{ + ::TestTargetNS::MyDerivedClass::setVisible(b); +} +void MyDerivedClass_wrapper::show() +{ + ::TestTargetNS::MyDerivedClass::show(); +} +int MyDerivedClass_wrapper::virtualNotInBase() const +{ + if (m_virtualNotInBaseCallback) { + const void *thisPtr = this; + return m_virtualNotInBaseCallback(const_cast(thisPtr)); + } else { + return ::TestTargetNS::MyDerivedClass::virtualNotInBase(); + } +} +int MyDerivedClass_wrapper::virtualNotInBase_nocallback() const +{ + return ::TestTargetNS::MyDerivedClass::virtualNotInBase(); +} +int MyDerivedClass_wrapper::virtualReceivingBool(bool b) +{ + if (m_virtualReceivingBoolCallback) { + const void *thisPtr = this; + return m_virtualReceivingBoolCallback(const_cast(thisPtr), b); + } else { + return ::TestTargetNS::MyDerivedClass::virtualReceivingBool(b); + } +} +int MyDerivedClass_wrapper::virtualReceivingBool_nocallback(bool b) +{ + return ::TestTargetNS::MyDerivedClass::virtualReceivingBool(b); +} +void MyDerivedClass_wrapper::virtualReceivingCharPtr(char *arg__1) +{ + if (m_virtualReceivingCharPtrCallback) { + const void *thisPtr = this; + m_virtualReceivingCharPtrCallback(const_cast(thisPtr), arg__1); + } else { + ::TestTargetNS::MyDerivedClass::virtualReceivingCharPtr(arg__1); + } +} +void MyDerivedClass_wrapper::virtualReceivingCharPtr_nocallback(char *arg__1) +{ + ::TestTargetNS::MyDerivedClass::virtualReceivingCharPtr(arg__1); +} +int MyDerivedClass_wrapper::virtualReceivingInt(int arg__1) +{ + if (m_virtualReceivingIntCallback) { + const void *thisPtr = this; + return m_virtualReceivingIntCallback(const_cast(thisPtr), arg__1); + } else { + return ::TestTargetNS::MyDerivedClass::virtualReceivingInt(arg__1); + } +} +int MyDerivedClass_wrapper::virtualReceivingInt_nocallback(int arg__1) +{ + return ::TestTargetNS::MyDerivedClass::virtualReceivingInt(arg__1); +} +int MyDerivedClass_wrapper::virtualReceivingOptionalArgument(int optional) +{ + if (m_virtualReceivingOptionalArgumentCallback) { + const void *thisPtr = this; + return m_virtualReceivingOptionalArgumentCallback(const_cast(thisPtr), optional); + } else { + return ::TestTargetNS::MyDerivedClass::virtualReceivingOptionalArgument(optional); + } +} +int MyDerivedClass_wrapper::virtualReceivingOptionalArgument_nocallback(int optional) +{ + return ::TestTargetNS::MyDerivedClass::virtualReceivingOptionalArgument(optional); +} +bool MyDerivedClass_wrapper::virtualReturningBool(bool b) +{ + if (m_virtualReturningBoolCallback) { + const void *thisPtr = this; + return m_virtualReturningBoolCallback(const_cast(thisPtr), b); + } else { + return ::TestTargetNS::MyDerivedClass::virtualReturningBool(b); + } +} +bool MyDerivedClass_wrapper::virtualReturningBool_nocallback(bool b) +{ + return ::TestTargetNS::MyDerivedClass::virtualReturningBool(b); +} +qint64 MyDerivedClass_wrapper::virtualReturningQint64() +{ + if (m_virtualReturningQint64Callback) { + const void *thisPtr = this; + return m_virtualReturningQint64Callback(const_cast(thisPtr)); + } else { + return ::TestTargetNS::MyDerivedClass::virtualReturningQint64(); + } +} +qint64 MyDerivedClass_wrapper::virtualReturningQint64_nocallback() +{ + return ::TestTargetNS::MyDerivedClass::virtualReturningQint64(); +} +SimpleStruct MyDerivedClass_wrapper::virtualReturningStruct() const +{ + if (m_virtualReturningStructCallback) { + const void *thisPtr = this; + return *m_virtualReturningStructCallback(const_cast(thisPtr)); + } else { + return ::TestTargetNS::MyDerivedClass::virtualReturningStruct(); + } +} +SimpleStruct MyDerivedClass_wrapper::virtualReturningStruct_nocallback() const +{ + return ::TestTargetNS::MyDerivedClass::virtualReturningStruct(); +} +MyTemplate MyDerivedClass_wrapper::virtualReturnsIntTemplate() +{ + if (m_virtualReturnsIntTemplateCallback) { + const void *thisPtr = this; + return *m_virtualReturnsIntTemplateCallback(const_cast(thisPtr)); + } else { + return ::TestTargetNS::MyDerivedClass::virtualReturnsIntTemplate(); + } +} +MyTemplate MyDerivedClass_wrapper::virtualReturnsIntTemplate_nocallback() +{ + return ::TestTargetNS::MyDerivedClass::virtualReturnsIntTemplate(); +} +void MyDerivedClass_wrapper::virtualWithOverload(int i) const +{ + if (m_virtualWithOverloadCallback) { + const void *thisPtr = this; + m_virtualWithOverloadCallback(const_cast(thisPtr), i); + } else { + ::TestTargetNS::MyDerivedClass::virtualWithOverload(i); + } +} +void MyDerivedClass_wrapper::virtualWithOverload_nocallback(int i) const +{ + ::TestTargetNS::MyDerivedClass::virtualWithOverload(i); +} +void MyDerivedClass_wrapper::virtualWithOverload(int i, int j) const +{ + if (m_virtualWithOverload_2Callback) { + const void *thisPtr = this; + m_virtualWithOverload_2Callback(const_cast(thisPtr), i, j); + } else { + ::TestTargetNS::MyDerivedClass::virtualWithOverload(i, j); + } +} +void MyDerivedClass_wrapper::virtualWithOverload_nocallback(int i, int j) const +{ + ::TestTargetNS::MyDerivedClass::virtualWithOverload(i, j); +} +MyDerivedClass_wrapper::~MyDerivedClass_wrapper() +{ +} + +} +static TestTargetNS::MyDerivedClass *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::MyDerivedClass_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_TestTargetNS__MyDerivedClass_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} +void *c_TestTargetNS__MyDerivedClass__constructor() +{ + auto ptr = new TestBindings_wrappersNS::MyDerivedClass_wrapper(); + return reinterpret_cast(ptr); +} +// alsoCallsVirtual() +int c_TestTargetNS__MyDerivedClass__alsoCallsVirtual(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->alsoCallsVirtual(); + return result; +} +// anotherOverloadedStatic(int arg__1) +void *c_static_TestTargetNS__MyDerivedClass__anotherOverloadedStatic_int(int arg__1) +{ + const auto &result = const_cast(static_cast( + TestBindings_wrappersNS::MyDerivedClass_wrapper::anotherOverloadedStatic(arg__1))); + return result; +} +// anotherOverloadedStatic(int arg__1, int arg__2) +void *c_static_TestTargetNS__MyDerivedClass__anotherOverloadedStatic_int_int(int arg__1, int arg__2) +{ + const auto &result = const_cast(static_cast( + TestBindings_wrappersNS::MyDerivedClass_wrapper::anotherOverloadedStatic(arg__1, arg__2))); + return result; +} +// bar() const +int c_TestTargetNS__MyDerivedClass__bar(void *thisObj) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->bar_nocallback(); + } else { + return targetPtr->bar(); + } + }(); + return result; +} +// bar2() const +int c_TestTargetNS__MyDerivedClass__bar2(void *thisObj) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->bar2_nocallback(); + } else { + return targetPtr->bar2(); + } + }(); + return result; +} +// nonVirtualButOverridden() const +int c_TestTargetNS__MyDerivedClass__nonVirtualButOverridden(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->nonVirtualButOverridden(); + return result; +} +// nonVirtualInBaseButVirtualInDerived(int i, int j) const +int c_TestTargetNS__MyDerivedClass__nonVirtualInBaseButVirtualInDerived_int_int(void *thisObj, + int i, int j) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->nonVirtualInBaseButVirtualInDerived_nocallback(i, j); + } else { + return targetPtr->nonVirtualInBaseButVirtualInDerived(i, j); + } + }(); + return result; +} +// paintEvent() +void c_TestTargetNS__MyDerivedClass__paintEvent(void *thisObj) +{ + fromWrapperPtr(thisObj)->paintEvent_nocallback(); +} +// receivesDerivedPolymorphic(TestTargetNS::MyDerivedClass * der) +int c_TestTargetNS__MyDerivedClass__receivesDerivedPolymorphic_MyDerivedClass(void *thisObj, + void *der_) +{ + auto der = reinterpret_cast(der_); + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->receivesDerivedPolymorphic_nocallback(der); + } else { + return targetPtr->receivesDerivedPolymorphic(der); + } + }(); + return result; +} +// receivesEnumFromBaseClassWithDefaultValue(int a) +void c_TestTargetNS__MyDerivedClass__receivesEnumFromBaseClassWithDefaultValue_int(void *thisObj, + int a) +{ + fromPtr(thisObj)->receivesEnumFromBaseClassWithDefaultValue(a); +} +// receivesProtectedEnum(TestTargetNS::MyBaseClass::ProtectedEnum p) +int c_TestTargetNS__MyDerivedClass__receivesProtectedEnum_ProtectedEnum(void *thisObj, int p) +{ + const auto &result = fromPtr(thisObj)->receivesProtectedEnum( + static_cast(p)); + return result; +} +// renamedVirtual1() +void c_TestTargetNS__MyDerivedClass__renamedVirtual2(void *thisObj) +{ + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->renamedVirtual1_nocallback(); + } else { + return targetPtr->renamedVirtual1(); + } + }(); +} +// returnTemplate1() +void *c_TestTargetNS__MyDerivedClass__returnTemplate1(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->returnTemplate1() + }; + return result; +} +// returnTemplate2() +void *c_TestTargetNS__MyDerivedClass__returnTemplate2(void *thisObj) +{ + const auto &result = + const_cast(static_cast(&fromPtr(thisObj)->returnTemplate2())); + return result; +} +// returnsAnotherNamespaceEnum() +int c_static_TestTargetNS__MyDerivedClass__returnsAnotherNamespaceEnum() +{ + const auto &result = + TestBindings_wrappersNS::MyDerivedClass_wrapper::returnsAnotherNamespaceEnum(); + return result; +} +// returnsAnotherNamespaceStruct() +void *c_static_TestTargetNS__MyDerivedClass__returnsAnotherNamespaceStruct() +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::MyDerivedClass_wrapper::returnsAnotherNamespaceStruct() + }; + return result; +} +// returnsConstPointer() +void *c_TestTargetNS__MyDerivedClass__returnsConstPointer(void *thisObj) +{ + const auto &result = + const_cast(static_cast(fromPtr(thisObj)->returnsConstPointer())); + return result; +} +// setVisible(bool b) +void c_TestTargetNS__MyDerivedClass__setVisible_bool(void *thisObj, bool b) +{ + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->setVisible_nocallback(b); + } else { + return targetPtr->setVisible(b); + } + }(); +} +// show() +void c_TestTargetNS__MyDerivedClass__show(void *thisObj) +{ + fromPtr(thisObj)->show(); +} +// virtualNotInBase() const +int c_TestTargetNS__MyDerivedClass__virtualNotInBase(void *thisObj) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualNotInBase_nocallback(); + } else { + return targetPtr->virtualNotInBase(); + } + }(); + return result; +} +// virtualReceivingBool(bool b) +int c_TestTargetNS__MyDerivedClass__virtualReceivingBool_bool(void *thisObj, bool b) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualReceivingBool_nocallback(b); + } else { + return targetPtr->virtualReceivingBool(b); + } + }(); + return result; +} +// virtualReceivingCharPtr(char * arg__1) +void c_TestTargetNS__MyDerivedClass__virtualReceivingCharPtr_char(void *thisObj, char *arg__1) +{ + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualReceivingCharPtr_nocallback(arg__1); + } else { + return targetPtr->virtualReceivingCharPtr(arg__1); + } + }(); + free(( char * )arg__1); +} +// virtualReceivingInt(int arg__1) +int c_TestTargetNS__MyDerivedClass__virtualReceivingInt_int(void *thisObj, int arg__1) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualReceivingInt_nocallback(arg__1); + } else { + return targetPtr->virtualReceivingInt(arg__1); + } + }(); + return result; +} +// virtualReceivingOptionalArgument(int optional) +int c_TestTargetNS__MyDerivedClass__virtualReceivingOptionalArgument_int(void *thisObj, + int optional) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualReceivingOptionalArgument_nocallback(optional); + } else { + return targetPtr->virtualReceivingOptionalArgument(optional); + } + }(); + return result; +} +// virtualReturningBool(bool b) +bool c_TestTargetNS__MyDerivedClass__virtualReturningBool_bool(void *thisObj, bool b) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualReturningBool_nocallback(b); + } else { + return targetPtr->virtualReturningBool(b); + } + }(); + return result; +} +// virtualReturningQint64() +qint64 c_TestTargetNS__MyDerivedClass__virtualReturningQint64(void *thisObj) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualReturningQint64_nocallback(); + } else { + return targetPtr->virtualReturningQint64(); + } + }(); + return result; +} +// virtualReturningStruct() const +void *c_TestTargetNS__MyDerivedClass__virtualReturningStruct(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualReturningStruct_nocallback(); + } else { + return targetPtr->virtualReturningStruct(); + } + }() }; + return result; +} +// virtualReturnsIntTemplate() +void *c_TestTargetNS__MyDerivedClass__virtualReturnsIntTemplate(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper> { [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualReturnsIntTemplate_nocallback(); + } else { + return targetPtr->virtualReturnsIntTemplate(); + } + }() }; + return result; +} +// virtualWithOverload(int i) const +void c_TestTargetNS__MyDerivedClass__virtualWithOverload_int(void *thisObj, int i) +{ + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualWithOverload_nocallback(i); + } else { + return targetPtr->virtualWithOverload(i); + } + }(); +} +// virtualWithOverload(int i, int j) const +void c_TestTargetNS__MyDerivedClass__virtualWithOverload_int_int(void *thisObj, int i, int j) +{ + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualWithOverload_nocallback(i, j); + } else { + return targetPtr->virtualWithOverload(i, j); + } + }(); +} +void c_TestTargetNS__MyDerivedClass__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +int c_static_TestTargetNS__MyDerivedClass___get_s_instanceCount() +{ + return TestBindings_wrappersNS::MyDerivedClass_wrapper::s_instanceCount; +} +void c_static_TestTargetNS__MyDerivedClass___set_s_instanceCount_int(int s_instanceCount_) +{ + TestBindings_wrappersNS::MyDerivedClass_wrapper::s_instanceCount = s_instanceCount_; +} +void c_TestTargetNS__MyDerivedClass__registerVirtualMethodCallback(void *ptr, void *callback, + int methodId) +{ + auto wrapper = fromWrapperPtr(ptr); + switch (methodId) { + case 51: + wrapper->m_barCallback = + reinterpret_cast( + callback); + break; + case 52: + wrapper->m_bar2Callback = + reinterpret_cast( + callback); + break; + case 63: + wrapper->m_nonVirtualInBaseButVirtualInDerived_2Callback = + reinterpret_cast(callback); + break; + case 135: + wrapper->m_paintEventCallback = + reinterpret_cast( + callback); + break; + case 143: + wrapper->m_receivesDerivedPolymorphicCallback = reinterpret_cast< + TestBindings_wrappersNS::MyDerivedClass_wrapper::Callback_receivesDerivedPolymorphic>( + callback); + break; + case 86: + wrapper->m_renamedVirtual2Callback = reinterpret_cast< + TestBindings_wrappersNS::MyDerivedClass_wrapper::Callback_renamedVirtual2>(callback); + break; + case 176: + wrapper->m_setVisibleCallback = + reinterpret_cast( + callback); + break; + case 181: + wrapper->m_virtualNotInBaseCallback = reinterpret_cast< + TestBindings_wrappersNS::MyDerivedClass_wrapper::Callback_virtualNotInBase>(callback); + break; + case 103: + wrapper->m_virtualReceivingBoolCallback = reinterpret_cast< + TestBindings_wrappersNS::MyDerivedClass_wrapper::Callback_virtualReceivingBool>( + callback); + break; + case 104: + wrapper->m_virtualReceivingCharPtrCallback = reinterpret_cast< + TestBindings_wrappersNS::MyDerivedClass_wrapper::Callback_virtualReceivingCharPtr>( + callback); + break; + case 105: + wrapper->m_virtualReceivingIntCallback = reinterpret_cast< + TestBindings_wrappersNS::MyDerivedClass_wrapper::Callback_virtualReceivingInt>( + callback); + break; + case 106: + wrapper->m_virtualReceivingOptionalArgumentCallback = + reinterpret_cast(callback); + break; + case 107: + wrapper->m_virtualReturningBoolCallback = reinterpret_cast< + TestBindings_wrappersNS::MyDerivedClass_wrapper::Callback_virtualReturningBool>( + callback); + break; + case 108: + wrapper->m_virtualReturningQint64Callback = reinterpret_cast< + TestBindings_wrappersNS::MyDerivedClass_wrapper::Callback_virtualReturningQint64>( + callback); + break; + case 109: + wrapper->m_virtualReturningStructCallback = reinterpret_cast< + TestBindings_wrappersNS::MyDerivedClass_wrapper::Callback_virtualReturningStruct>( + callback); + break; + case 110: + wrapper->m_virtualReturnsIntTemplateCallback = reinterpret_cast< + TestBindings_wrappersNS::MyDerivedClass_wrapper::Callback_virtualReturnsIntTemplate>( + callback); + break; + case 112: + wrapper->m_virtualWithOverloadCallback = reinterpret_cast< + TestBindings_wrappersNS::MyDerivedClass_wrapper::Callback_virtualWithOverload>( + callback); + break; + case 113: + wrapper->m_virtualWithOverload_2Callback = reinterpret_cast< + TestBindings_wrappersNS::MyDerivedClass_wrapper::Callback_virtualWithOverload_2>( + callback); + break; + } +} +} diff --git a/tests/generated/TestBindings/dart/ffi/MyDerivedClass_c.h b/tests/generated/TestBindings/dart/ffi/MyDerivedClass_c.h new file mode 100644 index 0000000..f0d3558 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/MyDerivedClass_c.h @@ -0,0 +1,189 @@ +#include "TestBindings_exports.h" +#include +#include +#include +#include +#include + +namespace TestBindings_wrappersNS { +class MyDerivedClass_wrapper : public ::TestTargetNS::MyDerivedClass +{ +public: + ~MyDerivedClass_wrapper(); + using ::TestTargetNS::MyBaseClass::ProtectedEnum; + MyDerivedClass_wrapper(); + int alsoCallsVirtual(); + static const TestTargetNS::MyDerivedClass *anotherOverloadedStatic(int arg__1); + static const TestTargetNS::MyDerivedClass *anotherOverloadedStatic(int arg__1, int arg__2); + virtual int bar() const; + virtual int bar_nocallback() const; + virtual int bar2() const; + virtual int bar2_nocallback() const; + int nonVirtualButOverridden() const; + virtual int nonVirtualInBaseButVirtualInDerived(int i, int j) const; + virtual int nonVirtualInBaseButVirtualInDerived_nocallback(int i, int j) const; + virtual void paintEvent(); + virtual void paintEvent_nocallback(); + virtual int receivesDerivedPolymorphic(TestTargetNS::MyDerivedClass *der); + virtual int receivesDerivedPolymorphic_nocallback(TestTargetNS::MyDerivedClass *der); + void receivesEnumFromBaseClassWithDefaultValue( + int a = TestTargetNS::MyBaseClass::MyEnum::MyEnumerator0); + int receivesProtectedEnum(TestTargetNS::MyBaseClass::ProtectedEnum p); + virtual void renamedVirtual1(); + virtual void renamedVirtual1_nocallback(); + MyTemplate2 returnTemplate1(); + const MyTemplate2 &returnTemplate2(); + static AnotherNamespace::NamespaceLevelEnum returnsAnotherNamespaceEnum(); + static AnotherNamespace::AnotherNamespaceStruct returnsAnotherNamespaceStruct(); + const TestTargetNS::MyDerivedClass *returnsConstPointer(); + virtual void setVisible(bool b); + virtual void setVisible_nocallback(bool b); + void show(); + virtual int virtualNotInBase() const; + virtual int virtualNotInBase_nocallback() const; + virtual int virtualReceivingBool(bool b); + virtual int virtualReceivingBool_nocallback(bool b); + virtual void virtualReceivingCharPtr(char *arg__1); + virtual void virtualReceivingCharPtr_nocallback(char *arg__1); + virtual int virtualReceivingInt(int arg__1); + virtual int virtualReceivingInt_nocallback(int arg__1); + virtual int virtualReceivingOptionalArgument(int optional = 1); + virtual int virtualReceivingOptionalArgument_nocallback(int optional = 1); + virtual bool virtualReturningBool(bool b); + virtual bool virtualReturningBool_nocallback(bool b); + virtual qint64 virtualReturningQint64(); + virtual qint64 virtualReturningQint64_nocallback(); + virtual SimpleStruct virtualReturningStruct() const; + virtual SimpleStruct virtualReturningStruct_nocallback() const; + virtual MyTemplate virtualReturnsIntTemplate(); + virtual MyTemplate virtualReturnsIntTemplate_nocallback(); + virtual void virtualWithOverload(int i) const; + virtual void virtualWithOverload_nocallback(int i) const; + virtual void virtualWithOverload(int i, int j) const; + virtual void virtualWithOverload_nocallback(int i, int j) const; + typedef int (*Callback_bar)(void *); + Callback_bar m_barCallback = nullptr; + typedef int (*Callback_bar2)(void *); + Callback_bar2 m_bar2Callback = nullptr; + typedef int (*Callback_nonVirtualInBaseButVirtualInDerived_2)(void *, int i, int j); + Callback_nonVirtualInBaseButVirtualInDerived_2 m_nonVirtualInBaseButVirtualInDerived_2Callback = + nullptr; + typedef void (*Callback_paintEvent)(void *); + Callback_paintEvent m_paintEventCallback = nullptr; + typedef int (*Callback_receivesDerivedPolymorphic)(void *, TestTargetNS::MyDerivedClass *der); + Callback_receivesDerivedPolymorphic m_receivesDerivedPolymorphicCallback = nullptr; + typedef void (*Callback_renamedVirtual2)(void *); + Callback_renamedVirtual2 m_renamedVirtual2Callback = nullptr; + typedef void (*Callback_setVisible)(void *, bool b); + Callback_setVisible m_setVisibleCallback = nullptr; + typedef int (*Callback_virtualNotInBase)(void *); + Callback_virtualNotInBase m_virtualNotInBaseCallback = nullptr; + typedef int (*Callback_virtualReceivingBool)(void *, bool b); + Callback_virtualReceivingBool m_virtualReceivingBoolCallback = nullptr; + typedef void (*Callback_virtualReceivingCharPtr)(void *, char *arg__1); + Callback_virtualReceivingCharPtr m_virtualReceivingCharPtrCallback = nullptr; + typedef int (*Callback_virtualReceivingInt)(void *, int arg__1); + Callback_virtualReceivingInt m_virtualReceivingIntCallback = nullptr; + typedef int (*Callback_virtualReceivingOptionalArgument)(void *, int optional); + Callback_virtualReceivingOptionalArgument m_virtualReceivingOptionalArgumentCallback = nullptr; + typedef bool (*Callback_virtualReturningBool)(void *, bool b); + Callback_virtualReturningBool m_virtualReturningBoolCallback = nullptr; + typedef qint64 (*Callback_virtualReturningQint64)(void *); + Callback_virtualReturningQint64 m_virtualReturningQint64Callback = nullptr; + typedef SimpleStruct *(*Callback_virtualReturningStruct)(void *); + Callback_virtualReturningStruct m_virtualReturningStructCallback = nullptr; + typedef MyTemplate *(*Callback_virtualReturnsIntTemplate)(void *); + Callback_virtualReturnsIntTemplate m_virtualReturnsIntTemplateCallback = nullptr; + typedef void (*Callback_virtualWithOverload)(void *, int i); + Callback_virtualWithOverload m_virtualWithOverloadCallback = nullptr; + typedef void (*Callback_virtualWithOverload_2)(void *, int i, int j); + Callback_virtualWithOverload_2 m_virtualWithOverload_2Callback = nullptr; +}; +} +extern "C" { +// TestTargetNS::MyDerivedClass::MyDerivedClass() +TestBindings_EXPORT void *c_TestTargetNS__MyDerivedClass__constructor(); +// TestTargetNS::MyDerivedClass::alsoCallsVirtual() +TestBindings_EXPORT int c_TestTargetNS__MyDerivedClass__alsoCallsVirtual(void *thisObj); +// TestTargetNS::MyDerivedClass::anotherOverloadedStatic(int arg__1) +TestBindings_EXPORT void * +c_static_TestTargetNS__MyDerivedClass__anotherOverloadedStatic_int(int arg__1); +// TestTargetNS::MyDerivedClass::anotherOverloadedStatic(int arg__1, int arg__2) +TestBindings_EXPORT void * +c_static_TestTargetNS__MyDerivedClass__anotherOverloadedStatic_int_int(int arg__1, int arg__2); +// TestTargetNS::MyDerivedClass::bar() const +TestBindings_EXPORT int c_TestTargetNS__MyDerivedClass__bar(void *thisObj); +// TestTargetNS::MyDerivedClass::bar2() const +TestBindings_EXPORT int c_TestTargetNS__MyDerivedClass__bar2(void *thisObj); +// TestTargetNS::MyDerivedClass::nonVirtualButOverridden() const +TestBindings_EXPORT int c_TestTargetNS__MyDerivedClass__nonVirtualButOverridden(void *thisObj); +// TestTargetNS::MyDerivedClass::nonVirtualInBaseButVirtualInDerived(int i, int j) const +TestBindings_EXPORT int +c_TestTargetNS__MyDerivedClass__nonVirtualInBaseButVirtualInDerived_int_int(void *thisObj, int i, + int j); +// TestTargetNS::MyDerivedClass::paintEvent() +TestBindings_EXPORT void c_TestTargetNS__MyDerivedClass__paintEvent(void *thisObj); +// TestTargetNS::MyDerivedClass::receivesDerivedPolymorphic(TestTargetNS::MyDerivedClass * der) +TestBindings_EXPORT int +c_TestTargetNS__MyDerivedClass__receivesDerivedPolymorphic_MyDerivedClass(void *thisObj, + void *der_); +// TestTargetNS::MyDerivedClass::receivesEnumFromBaseClassWithDefaultValue(int a) +TestBindings_EXPORT void +c_TestTargetNS__MyDerivedClass__receivesEnumFromBaseClassWithDefaultValue_int(void *thisObj, int a); +// TestTargetNS::MyDerivedClass::receivesProtectedEnum(TestTargetNS::MyBaseClass::ProtectedEnum p) +TestBindings_EXPORT int +c_TestTargetNS__MyDerivedClass__receivesProtectedEnum_ProtectedEnum(void *thisObj, int p); +// TestTargetNS::MyDerivedClass::renamedVirtual1() +TestBindings_EXPORT void c_TestTargetNS__MyDerivedClass__renamedVirtual2(void *thisObj); +// TestTargetNS::MyDerivedClass::returnTemplate1() +TestBindings_EXPORT void *c_TestTargetNS__MyDerivedClass__returnTemplate1(void *thisObj); +// TestTargetNS::MyDerivedClass::returnTemplate2() +TestBindings_EXPORT void *c_TestTargetNS__MyDerivedClass__returnTemplate2(void *thisObj); +// TestTargetNS::MyDerivedClass::returnsAnotherNamespaceEnum() +TestBindings_EXPORT int c_static_TestTargetNS__MyDerivedClass__returnsAnotherNamespaceEnum(); +// TestTargetNS::MyDerivedClass::returnsAnotherNamespaceStruct() +TestBindings_EXPORT void *c_static_TestTargetNS__MyDerivedClass__returnsAnotherNamespaceStruct(); +// TestTargetNS::MyDerivedClass::returnsConstPointer() +TestBindings_EXPORT void *c_TestTargetNS__MyDerivedClass__returnsConstPointer(void *thisObj); +// TestTargetNS::MyDerivedClass::setVisible(bool b) +TestBindings_EXPORT void c_TestTargetNS__MyDerivedClass__setVisible_bool(void *thisObj, bool b); +// TestTargetNS::MyDerivedClass::show() +TestBindings_EXPORT void c_TestTargetNS__MyDerivedClass__show(void *thisObj); +// TestTargetNS::MyDerivedClass::virtualNotInBase() const +TestBindings_EXPORT int c_TestTargetNS__MyDerivedClass__virtualNotInBase(void *thisObj); +// TestTargetNS::MyDerivedClass::virtualReceivingBool(bool b) +TestBindings_EXPORT int c_TestTargetNS__MyDerivedClass__virtualReceivingBool_bool(void *thisObj, + bool b); +// TestTargetNS::MyDerivedClass::virtualReceivingCharPtr(char * arg__1) +TestBindings_EXPORT void c_TestTargetNS__MyDerivedClass__virtualReceivingCharPtr_char(void *thisObj, + char *arg__1); +// TestTargetNS::MyDerivedClass::virtualReceivingInt(int arg__1) +TestBindings_EXPORT int c_TestTargetNS__MyDerivedClass__virtualReceivingInt_int(void *thisObj, + int arg__1); +// TestTargetNS::MyDerivedClass::virtualReceivingOptionalArgument(int optional) +TestBindings_EXPORT int +c_TestTargetNS__MyDerivedClass__virtualReceivingOptionalArgument_int(void *thisObj, int optional); +// TestTargetNS::MyDerivedClass::virtualReturningBool(bool b) +TestBindings_EXPORT bool c_TestTargetNS__MyDerivedClass__virtualReturningBool_bool(void *thisObj, + bool b); +// TestTargetNS::MyDerivedClass::virtualReturningQint64() +TestBindings_EXPORT qint64 c_TestTargetNS__MyDerivedClass__virtualReturningQint64(void *thisObj); +// TestTargetNS::MyDerivedClass::virtualReturningStruct() const +TestBindings_EXPORT void *c_TestTargetNS__MyDerivedClass__virtualReturningStruct(void *thisObj); +// TestTargetNS::MyDerivedClass::virtualReturnsIntTemplate() +TestBindings_EXPORT void *c_TestTargetNS__MyDerivedClass__virtualReturnsIntTemplate(void *thisObj); +// TestTargetNS::MyDerivedClass::virtualWithOverload(int i) const +TestBindings_EXPORT void c_TestTargetNS__MyDerivedClass__virtualWithOverload_int(void *thisObj, + int i); +// TestTargetNS::MyDerivedClass::virtualWithOverload(int i, int j) const +TestBindings_EXPORT void c_TestTargetNS__MyDerivedClass__virtualWithOverload_int_int(void *thisObj, + int i, int j); +TestBindings_EXPORT void c_TestTargetNS__MyDerivedClass__destructor(void *thisObj); +TestBindings_EXPORT int c_static_TestTargetNS__MyDerivedClass___get_s_instanceCount(); +TestBindings_EXPORT void +c_static_TestTargetNS__MyDerivedClass___set_s_instanceCount_int(int s_instanceCount_); +TestBindings_EXPORT void +c_TestTargetNS__MyDerivedClass__registerVirtualMethodCallback(void *ptr, void *callback, + int methodId); +TestBindings_EXPORT void c_TestTargetNS__MyDerivedClass_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/MyObject_c.cpp b/tests/generated/TestBindings/dart/ffi/MyObject_c.cpp new file mode 100644 index 0000000..be76a5a --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/MyObject_c.cpp @@ -0,0 +1,384 @@ +#include "MyObject_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +MyObject_wrapper::MyObject_wrapper(QObject *parent) + : ::MyObject(parent) +{ +} +void MyObject_wrapper::customEvent(QEvent *event) +{ + if (m_customEventCallback) { + const void *thisPtr = this; + m_customEventCallback(const_cast(thisPtr), event); + } else { + ::MyObject::customEvent(event); + } +} +void MyObject_wrapper::customEvent_nocallback(QEvent *event) +{ + ::MyObject::customEvent(event); +} +bool MyObject_wrapper::event(QEvent *event) +{ + if (m_eventCallback) { + const void *thisPtr = this; + return m_eventCallback(const_cast(thisPtr), event); + } else { + return ::MyObject::event(event); + } +} +bool MyObject_wrapper::event_nocallback(QEvent *event) +{ + return ::MyObject::event(event); +} +bool MyObject_wrapper::eventFilter(QObject *watched, QEvent *event) +{ + if (m_eventFilterCallback) { + const void *thisPtr = this; + return m_eventFilterCallback(const_cast(thisPtr), watched, event); + } else { + return ::MyObject::eventFilter(watched, event); + } +} +bool MyObject_wrapper::eventFilter_nocallback(QObject *watched, QEvent *event) +{ + return ::MyObject::eventFilter(watched, event); +} +void MyObject_wrapper::pureVirtual() +{ + if (m_pureVirtualCallback) { + const void *thisPtr = this; + m_pureVirtualCallback(const_cast(thisPtr)); + } else { + std::cerr << "pureVirtual: Warning: Calling pure-virtual\n"; + return; + } +} +void MyObject_wrapper::pureVirtual_nocallback() +{ + std::cerr << "pureVirtual: Warning: Calling pure-virtual\n"; + return; +} +void MyObject_wrapper::receivesEnumClassWithDefaultArg(AnotherNamespace::MyNamespacedEnumClass foo) +{ + ::MyObject::receivesEnumClassWithDefaultArg(foo); +} +void MyObject_wrapper::receivesEnumClassWithDefaultArg(MyEnumClass foo) +{ + ::MyObject::receivesEnumClassWithDefaultArg(foo); +} +MyEnumClass MyObject_wrapper::returnsEnumClass() +{ + return ::MyObject::returnsEnumClass(); +} +QString MyObject_wrapper::tr(const char *s, const char *c, int n) +{ + return ::MyObject::tr(s, c, n); +} +void MyObject_wrapper::valueChanged(int arg__1) +{ + ::MyObject::valueChanged(arg__1); +} +int MyObject_wrapper::virtualFunc() +{ + if (m_virtualFuncCallback) { + const void *thisPtr = this; + return m_virtualFuncCallback(const_cast(thisPtr)); + } else { + return ::MyObject::virtualFunc(); + } +} +int MyObject_wrapper::virtualFunc_nocallback() +{ + return ::MyObject::virtualFunc(); +} +const char *MyObject_wrapper::virtualMethodReturningConstChar() const +{ + if (m_virtualMethodReturningConstCharCallback) { + const void *thisPtr = this; + return m_virtualMethodReturningConstCharCallback(const_cast(thisPtr)); + } else { + return ::MyObject::virtualMethodReturningConstChar(); + } +} +const char *MyObject_wrapper::virtualMethodReturningConstChar_nocallback() const +{ + return ::MyObject::virtualMethodReturningConstChar(); +} +void MyObject_wrapper::virtualReceivingQString(const QString &str) +{ + if (m_virtualReceivingQStringCallback) { + const void *thisPtr = this; + m_virtualReceivingQStringCallback(const_cast(thisPtr), str); + } else { + ::MyObject::virtualReceivingQString(str); + } +} +void MyObject_wrapper::virtualReceivingQString_nocallback(const QString &str) +{ + ::MyObject::virtualReceivingQString(str); +} +int MyObject_wrapper::virtualReturningInt() const +{ + if (m_virtualReturningIntCallback) { + const void *thisPtr = this; + return m_virtualReturningIntCallback(const_cast(thisPtr)); + } else { + return ::MyObject::virtualReturningInt(); + } +} +int MyObject_wrapper::virtualReturningInt_nocallback() const +{ + return ::MyObject::virtualReturningInt(); +} +MyObject_wrapper::~MyObject_wrapper() +{ +} + +} +static MyObject *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::MyObject_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_MyObject_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} +void *c_MyObject__constructor_QObject(void *parent_) +{ + auto parent = reinterpret_cast(parent_); + auto ptr = new TestBindings_wrappersNS::MyObject_wrapper(parent); + return reinterpret_cast(ptr); +} +// customEvent(QEvent * event) +void c_MyObject__customEvent_QEvent(void *thisObj, void *event_) +{ + auto event = reinterpret_cast(event_); + fromWrapperPtr(thisObj)->customEvent_nocallback(event); +} +void c_MyObject__onDestroyed_QObject(void *thisObj, void *contextQObject, void *callback) +{ + auto instance = reinterpret_cast(thisObj); + auto context = reinterpret_cast(contextQObject); + QObject::connect(instance, &MyObject::destroyed, context ? context : instance, + [thisObj, callback] { + typedef void (*SignalHandler_callback)(void *); + auto dartCallback = reinterpret_cast(callback); + dartCallback(thisObj); + }); +} +// event(QEvent * event) +bool c_MyObject__event_QEvent(void *thisObj, void *event_) +{ + auto event = reinterpret_cast(event_); + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->event_nocallback(event); + } else { + return targetPtr->event(event); + } + }(); + return result; +} +// eventFilter(QObject * watched, QEvent * event) +bool c_MyObject__eventFilter_QObject_QEvent(void *thisObj, void *watched_, void *event_) +{ + auto watched = reinterpret_cast(watched_); + auto event = reinterpret_cast(event_); + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->eventFilter_nocallback(watched, event); + } else { + return targetPtr->eventFilter(watched, event); + } + }(); + return result; +} +// pureVirtual() +void c_MyObject__pureVirtual(void *thisObj) +{ + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->pureVirtual_nocallback(); + } else { + return targetPtr->pureVirtual(); + } + }(); +} +// receivesEnumClassWithDefaultArg(AnotherNamespace::MyNamespacedEnumClass foo) +void c_MyObject__receivesEnumClassWithDefaultArg_MyNamespacedEnumClass(void *thisObj, int foo) +{ + fromPtr(thisObj)->receivesEnumClassWithDefaultArg( + static_cast(foo)); +} +// receivesEnumClassWithDefaultArg(MyEnumClass foo) +void c_MyObject__receivesEnumClassWithDefaultArg_MyEnumClass(void *thisObj, int foo) +{ + fromPtr(thisObj)->receivesEnumClassWithDefaultArg(static_cast(foo)); +} +// returnsEnumClass() +int c_MyObject__returnsEnumClass(void *thisObj) +{ + const auto &result = int(fromPtr(thisObj)->returnsEnumClass()); + return result; +} +// tr(const char * s, const char * c, int n) +void *c_static_MyObject__tr_char_char_int(const char *s, const char *c, int n) +{ + const auto &result = + new Dartagnan::ValueWrapper { TestBindings_wrappersNS::MyObject_wrapper::tr(s, c, + n) }; + free(( char * )s); + free(( char * )c); + return result; +} +// valueChanged(int arg__1) +void c_MyObject__valueChanged_int(void *thisObj, int arg__1) +{ + fromPtr(thisObj)->valueChanged(arg__1); +} +void c_MyObject__onValueChanged_int(void *thisObj, void *contextQObject, void *callback) +{ + auto instance = reinterpret_cast(thisObj); + auto context = reinterpret_cast(contextQObject); + QObject::connect(instance, &MyObject::valueChanged, context ? context : instance, + [thisObj, callback] { + typedef void (*SignalHandler_callback)(void *); + auto dartCallback = reinterpret_cast(callback); + dartCallback(thisObj); + }); +} +// virtualFunc() +int c_MyObject__virtualFunc(void *thisObj) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualFunc_nocallback(); + } else { + return targetPtr->virtualFunc(); + } + }(); + return result; +} +// virtualMethodReturningConstChar() const +const char *c_MyObject__virtualMethodReturningConstChar(void *thisObj) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualMethodReturningConstChar_nocallback(); + } else { + return targetPtr->virtualMethodReturningConstChar(); + } + }(); + return result; +} +// virtualReceivingQString(const QString & str) +void c_MyObject__virtualReceivingQString_QString(void *thisObj, const char *str_) +{ + const auto str = QString::fromUtf8(str_); + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualReceivingQString_nocallback(str); + } else { + return targetPtr->virtualReceivingQString(str); + } + }(); + free(( char * )str_); +} +// virtualReturningInt() const +int c_MyObject__virtualReturningInt(void *thisObj) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualReturningInt_nocallback(); + } else { + return targetPtr->virtualReturningInt(); + } + }(); + return result; +} +void c_MyObject__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +void c_MyObject__registerVirtualMethodCallback(void *ptr, void *callback, int methodId) +{ + auto wrapper = fromWrapperPtr(ptr); + switch (methodId) { + case 481: + wrapper->m_customEventCallback = + reinterpret_cast( + callback); + break; + case 490: + wrapper->m_eventCallback = + reinterpret_cast(callback); + break; + case 491: + wrapper->m_eventFilterCallback = + reinterpret_cast( + callback); + break; + case 1166: + wrapper->m_pureVirtualCallback = + reinterpret_cast( + callback); + break; + case 1181: + wrapper->m_virtualFuncCallback = + reinterpret_cast( + callback); + break; + case 1182: + wrapper->m_virtualMethodReturningConstCharCallback = reinterpret_cast< + TestBindings_wrappersNS::MyObject_wrapper::Callback_virtualMethodReturningConstChar>( + callback); + break; + case 1183: + wrapper->m_virtualReceivingQStringCallback = reinterpret_cast< + TestBindings_wrappersNS::MyObject_wrapper::Callback_virtualReceivingQString>(callback); + break; + case 1184: + wrapper->m_virtualReturningIntCallback = reinterpret_cast< + TestBindings_wrappersNS::MyObject_wrapper::Callback_virtualReturningInt>(callback); + break; + } +} +} diff --git a/tests/generated/TestBindings/dart/ffi/MyObject_c.h b/tests/generated/TestBindings/dart/ffi/MyObject_c.h new file mode 100644 index 0000000..d816d50 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/MyObject_c.h @@ -0,0 +1,94 @@ +#include "TestBindings_exports.h" +#include +#include +#include +#include +#include +#include +#include + +namespace TestBindings_wrappersNS { +class MyObject_wrapper : public ::MyObject +{ +public: + ~MyObject_wrapper(); + MyObject_wrapper(QObject *parent = nullptr); + virtual void customEvent(QEvent *event); + virtual void customEvent_nocallback(QEvent *event); + virtual bool event(QEvent *event); + virtual bool event_nocallback(QEvent *event); + virtual bool eventFilter(QObject *watched, QEvent *event); + virtual bool eventFilter_nocallback(QObject *watched, QEvent *event); + virtual void pureVirtual(); + virtual void pureVirtual_nocallback(); + void receivesEnumClassWithDefaultArg(AnotherNamespace::MyNamespacedEnumClass foo = + AnotherNamespace::MyNamespacedEnumClass::ValueFoo1); + void receivesEnumClassWithDefaultArg(MyEnumClass foo = MyEnumClass::ValueFoo); + MyEnumClass returnsEnumClass(); + static QString tr(const char *s, const char *c, int n); + void valueChanged(int arg__1); + virtual int virtualFunc(); + virtual int virtualFunc_nocallback(); + virtual const char *virtualMethodReturningConstChar() const; + virtual const char *virtualMethodReturningConstChar_nocallback() const; + virtual void virtualReceivingQString(const QString &str); + virtual void virtualReceivingQString_nocallback(const QString &str); + virtual int virtualReturningInt() const; + virtual int virtualReturningInt_nocallback() const; + typedef void (*Callback_customEvent)(void *, QEvent *event); + Callback_customEvent m_customEventCallback = nullptr; + typedef bool (*Callback_event)(void *, QEvent *event); + Callback_event m_eventCallback = nullptr; + typedef bool (*Callback_eventFilter)(void *, QObject *watched, QEvent *event); + Callback_eventFilter m_eventFilterCallback = nullptr; + typedef void (*Callback_pureVirtual)(void *); + Callback_pureVirtual m_pureVirtualCallback = nullptr; + typedef int (*Callback_virtualFunc)(void *); + Callback_virtualFunc m_virtualFuncCallback = nullptr; + typedef const char *(*Callback_virtualMethodReturningConstChar)(void *); + Callback_virtualMethodReturningConstChar m_virtualMethodReturningConstCharCallback = nullptr; + typedef void (*Callback_virtualReceivingQString)(void *, const QString &str); + Callback_virtualReceivingQString m_virtualReceivingQStringCallback = nullptr; + typedef int (*Callback_virtualReturningInt)(void *); + Callback_virtualReturningInt m_virtualReturningIntCallback = nullptr; +}; +} +extern "C" { +// MyObject::MyObject(QObject * parent) +TestBindings_EXPORT void *c_MyObject__constructor_QObject(void *parent_); +// MyObject::customEvent(QEvent * event) +TestBindings_EXPORT void c_MyObject__customEvent_QEvent(void *thisObj, void *event_); +// MyObject::event(QEvent * event) +TestBindings_EXPORT bool c_MyObject__event_QEvent(void *thisObj, void *event_); +// MyObject::eventFilter(QObject * watched, QEvent * event) +TestBindings_EXPORT bool c_MyObject__eventFilter_QObject_QEvent(void *thisObj, void *watched_, + void *event_); +// MyObject::pureVirtual() +TestBindings_EXPORT void c_MyObject__pureVirtual(void *thisObj); +// MyObject::receivesEnumClassWithDefaultArg(AnotherNamespace::MyNamespacedEnumClass foo) +TestBindings_EXPORT void +c_MyObject__receivesEnumClassWithDefaultArg_MyNamespacedEnumClass(void *thisObj, int foo); +// MyObject::receivesEnumClassWithDefaultArg(MyEnumClass foo) +TestBindings_EXPORT void c_MyObject__receivesEnumClassWithDefaultArg_MyEnumClass(void *thisObj, + int foo); +// MyObject::returnsEnumClass() +TestBindings_EXPORT int c_MyObject__returnsEnumClass(void *thisObj); +// MyObject::tr(const char * s, const char * c, int n) +TestBindings_EXPORT void *c_static_MyObject__tr_char_char_int(const char *s, const char *c, int n); +// MyObject::valueChanged(int arg__1) +TestBindings_EXPORT void c_MyObject__valueChanged_int(void *thisObj, int arg__1); +TestBindings_EXPORT void c_MyObject__onValueChanged_int(void *thisObj, void *contextQObject, + void *callback); // MyObject::virtualFunc() +TestBindings_EXPORT int c_MyObject__virtualFunc(void *thisObj); +// MyObject::virtualMethodReturningConstChar() const +TestBindings_EXPORT const char *c_MyObject__virtualMethodReturningConstChar(void *thisObj); +// MyObject::virtualReceivingQString(const QString & str) +TestBindings_EXPORT void c_MyObject__virtualReceivingQString_QString(void *thisObj, + const char *str_); +// MyObject::virtualReturningInt() const +TestBindings_EXPORT int c_MyObject__virtualReturningInt(void *thisObj); +TestBindings_EXPORT void c_MyObject__destructor(void *thisObj); +TestBindings_EXPORT void c_MyObject__registerVirtualMethodCallback(void *ptr, void *callback, + int methodId); +TestBindings_EXPORT void c_MyObject_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/MyTemplate2_c.cpp b/tests/generated/TestBindings/dart/ffi/MyTemplate2_c.cpp new file mode 100644 index 0000000..39e664b --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/MyTemplate2_c.cpp @@ -0,0 +1,102 @@ +#include "MyTemplate2_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +template +MyTemplate2_wrapper::MyTemplate2_wrapper() + : ::MyTemplate2() +{ +} +template +void MyTemplate2_wrapper::assignsT() +{ + ::MyTemplate2::assignsT(); +} +template +int MyTemplate2_wrapper::count() const +{ + return ::MyTemplate2::count(); +} +template +void MyTemplate2_wrapper::receivesT(T arg__1) +{ + ::MyTemplate2::receivesT(arg__1); +} +template +MyTemplate2 MyTemplate2_wrapper::returnTemplate1() +{ + return ::MyTemplate2::returnTemplate1(); +} +template +MyTemplate2_wrapper::~MyTemplate2_wrapper() +{ +} + +} +template +static MyTemplate2 *fromPtr(void *ptr) +{ + return reinterpret_cast *>(ptr); +} +template +static TestBindings_wrappersNS::MyTemplate2_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast *>(ptr); +} +extern "C" { +void c_MyTemplate2_T_NonCopiable_T__Finalizer(void *cppObj) +{ + delete reinterpret_cast *>(cppObj); +} +void *c_MyTemplate2_T_NonCopiable_T___constructor() +{ + auto ptr = new TestBindings_wrappersNS::MyTemplate2_wrapper(); + return reinterpret_cast(ptr); +} +// assignsT() +void c_MyTemplate2_T_NonCopiable_T___assignsT(void *thisObj) +{ + fromPtr(thisObj)->assignsT(); +} +// count() const +int c_MyTemplate2_T_NonCopiable_T___count(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->count(); + return result; +} +// receivesT(T arg__1) +void c_MyTemplate2_T_NonCopiable_T___receivesT_NonCopiable(void *thisObj, void *arg__1_) +{ + auto arg__1 = reinterpret_cast(arg__1_); + fromPtr(thisObj)->receivesT(arg__1); +} +// returnTemplate1() +void *c_MyTemplate2_T_NonCopiable_T___returnTemplate1(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->returnTemplate1() + }; + return result; +} +void c_MyTemplate2_T_NonCopiable_T___destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} diff --git a/tests/generated/TestBindings/dart/ffi/MyTemplate2_c.h b/tests/generated/TestBindings/dart/ffi/MyTemplate2_c.h new file mode 100644 index 0000000..3297f9e --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/MyTemplate2_c.h @@ -0,0 +1,31 @@ +#include "TestBindings_exports.h" +#include + +namespace TestBindings_wrappersNS { +template +class MyTemplate2_wrapper : public ::MyTemplate2 +{ +public: + ~MyTemplate2_wrapper(); + MyTemplate2_wrapper(); + void assignsT(); + int count() const; + void receivesT(T arg__1); + MyTemplate2 returnTemplate1(); +}; +} +extern "C" { +// MyTemplate2::MyTemplate2() +TestBindings_EXPORT void *c_MyTemplate2_T_NonCopiable_T___constructor(); +// MyTemplate2::assignsT() +TestBindings_EXPORT void c_MyTemplate2_T_NonCopiable_T___assignsT(void *thisObj); +// MyTemplate2::count() const +TestBindings_EXPORT int c_MyTemplate2_T_NonCopiable_T___count(void *thisObj); +// MyTemplate2::receivesT(T arg__1) +TestBindings_EXPORT void c_MyTemplate2_T_NonCopiable_T___receivesT_NonCopiable(void *thisObj, + void *arg__1_); +// MyTemplate2::returnTemplate1() +TestBindings_EXPORT void *c_MyTemplate2_T_NonCopiable_T___returnTemplate1(void *thisObj); +TestBindings_EXPORT void c_MyTemplate2_T_NonCopiable_T___destructor(void *thisObj); +TestBindings_EXPORT void c_MyTemplate2_T_NonCopiable_T__Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/MyTemplateWithTwoArgs_c.cpp b/tests/generated/TestBindings/dart/ffi/MyTemplateWithTwoArgs_c.cpp new file mode 100644 index 0000000..1bebfd8 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/MyTemplateWithTwoArgs_c.cpp @@ -0,0 +1,69 @@ +#include "MyTemplateWithTwoArgs_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +template +MyTemplateWithTwoArgs_wrapper::MyTemplateWithTwoArgs_wrapper() + : ::MyTemplateWithTwoArgs() +{ +} +template +int MyTemplateWithTwoArgs_wrapper::returnInt() const +{ + return ::MyTemplateWithTwoArgs::returnInt(); +} +template +MyTemplateWithTwoArgs_wrapper::~MyTemplateWithTwoArgs_wrapper() +{ +} + +} +template +static MyTemplateWithTwoArgs *fromPtr(void *ptr) +{ + return reinterpret_cast *>(ptr); +} +template +static TestBindings_wrappersNS::MyTemplateWithTwoArgs_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast *>(ptr); +} +extern "C" { +void c_MyTemplateWithTwoArgs_T_int_double_T__Finalizer(void *cppObj) +{ + delete reinterpret_cast *>( + cppObj); +} +void *c_MyTemplateWithTwoArgs_T_int_double_T___constructor() +{ + auto ptr = new TestBindings_wrappersNS::MyTemplateWithTwoArgs_wrapper(); + return reinterpret_cast(ptr); +} +// returnInt() const +int c_MyTemplateWithTwoArgs_T_int_double_T___returnInt(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->returnInt(); + return result; +} +void c_MyTemplateWithTwoArgs_T_int_double_T___destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} diff --git a/tests/generated/TestBindings/dart/ffi/MyTemplateWithTwoArgs_c.h b/tests/generated/TestBindings/dart/ffi/MyTemplateWithTwoArgs_c.h new file mode 100644 index 0000000..d0e0ce2 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/MyTemplateWithTwoArgs_c.h @@ -0,0 +1,21 @@ +#include "TestBindings_exports.h" +#include + +namespace TestBindings_wrappersNS { +template +class MyTemplateWithTwoArgs_wrapper : public ::MyTemplateWithTwoArgs +{ +public: + ~MyTemplateWithTwoArgs_wrapper(); + MyTemplateWithTwoArgs_wrapper(); + int returnInt() const; +}; +} +extern "C" { +// MyTemplateWithTwoArgs::MyTemplateWithTwoArgs() +TestBindings_EXPORT void *c_MyTemplateWithTwoArgs_T_int_double_T___constructor(); +// MyTemplateWithTwoArgs::returnInt() const +TestBindings_EXPORT int c_MyTemplateWithTwoArgs_T_int_double_T___returnInt(void *thisObj); +TestBindings_EXPORT void c_MyTemplateWithTwoArgs_T_int_double_T___destructor(void *thisObj); +TestBindings_EXPORT void c_MyTemplateWithTwoArgs_T_int_double_T__Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/MyTemplate_c.cpp b/tests/generated/TestBindings/dart/ffi/MyTemplate_c.cpp new file mode 100644 index 0000000..13e0c21 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/MyTemplate_c.cpp @@ -0,0 +1,303 @@ +#include "MyTemplate_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +template +MyTemplate_wrapper::MyTemplate_wrapper() + : ::MyTemplate() +{ +} +template +int MyTemplate_wrapper::receivesT(T arg__1) +{ + return ::MyTemplate::receivesT(arg__1); +} +template +int MyTemplate_wrapper::receivesTemplate(MyTemplate arg__1) +{ + return ::MyTemplate::receivesTemplate(arg__1); +} +template +int MyTemplate_wrapper::returnInt() const +{ + return ::MyTemplate::returnInt(); +} +template +MyTemplate MyTemplate_wrapper::returnTemplate2() +{ + return ::MyTemplate::returnTemplate2(); +} +template +MyTemplate MyTemplate_wrapper::returnTemplate3() +{ + return ::MyTemplate::returnTemplate3(); +} +template +MyTemplate MyTemplate_wrapper::returnTemplate4() +{ + return ::MyTemplate::returnTemplate4(); +} +template +T MyTemplate_wrapper::returnsT() +{ + return ::MyTemplate::returnsT(); +} +template +MyTemplate MyTemplate_wrapper::returnsTemplate() +{ + return ::MyTemplate::returnsTemplate(); +} +template +MyTemplate_wrapper::~MyTemplate_wrapper() +{ +} + +} +template +static MyTemplate *fromPtr(void *ptr) +{ + return reinterpret_cast *>(ptr); +} +template +static TestBindings_wrappersNS::MyTemplate_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast *>(ptr); +} +extern "C" { +void c_MyTemplate_T_int_T__Finalizer(void *cppObj) +{ + delete reinterpret_cast *>(cppObj); +} +void *c_MyTemplate_T_int_T___constructor() +{ + auto ptr = new TestBindings_wrappersNS::MyTemplate_wrapper(); + return reinterpret_cast(ptr); +} +// receivesT(T arg__1) +int c_MyTemplate_T_int_T___receivesT_int(void *thisObj, int arg__1) +{ + const auto &result = fromPtr(thisObj)->receivesT(arg__1); + return result; +} +// receivesTemplate(MyTemplate arg__1) +int c_MyTemplate_T_int_T___receivesTemplate_MyTemplate_T(void *thisObj, void *arg__1_) +{ + assert(arg__1_); + auto &arg__1 = *reinterpret_cast *>(arg__1_); + const auto &result = fromPtr(thisObj)->receivesTemplate(arg__1); + return result; +} +// returnInt() const +int c_MyTemplate_T_int_T___returnInt(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->returnInt(); + return result; +} +// returnTemplate2() +void *c_MyTemplate_T_int_T___returnTemplate2(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->returnTemplate2() + }; + return result; +} +// returnTemplate3() +void *c_MyTemplate_T_int_T___returnTemplate3(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->returnTemplate3() + }; + return result; +} +// returnTemplate4() +void *c_MyTemplate_T_int_T___returnTemplate4(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->returnTemplate4() + }; + return result; +} +// returnsT() +int c_MyTemplate_T_int_T___returnsT(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->returnsT(); + return result; +} +// returnsTemplate() +void *c_MyTemplate_T_int_T___returnsTemplate(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->returnsTemplate() }; + return result; +} +void c_MyTemplate_T_int_T___destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} +extern "C" { +void c_MyTemplate_T_double_T__Finalizer(void *cppObj) +{ + delete reinterpret_cast *>(cppObj); +} +void *c_MyTemplate_T_double_T___constructor() +{ + auto ptr = new TestBindings_wrappersNS::MyTemplate_wrapper(); + return reinterpret_cast(ptr); +} +// receivesT(T arg__1) +int c_MyTemplate_T_double_T___receivesT_double(void *thisObj, double arg__1) +{ + const auto &result = fromPtr(thisObj)->receivesT(arg__1); + return result; +} +// receivesTemplate(MyTemplate arg__1) +int c_MyTemplate_T_double_T___receivesTemplate_MyTemplate_T(void *thisObj, void *arg__1_) +{ + assert(arg__1_); + auto &arg__1 = *reinterpret_cast *>(arg__1_); + const auto &result = fromPtr(thisObj)->receivesTemplate(arg__1); + return result; +} +// returnInt() const +int c_MyTemplate_T_double_T___returnInt(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->returnInt(); + return result; +} +// returnTemplate2() +void *c_MyTemplate_T_double_T___returnTemplate2(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->returnTemplate2() + }; + return result; +} +// returnTemplate3() +void *c_MyTemplate_T_double_T___returnTemplate3(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->returnTemplate3() + }; + return result; +} +// returnTemplate4() +void *c_MyTemplate_T_double_T___returnTemplate4(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->returnTemplate4() + }; + return result; +} +// returnsT() +double c_MyTemplate_T_double_T___returnsT(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->returnsT(); + return result; +} +// returnsTemplate() +void *c_MyTemplate_T_double_T___returnsTemplate(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->returnsTemplate() + }; + return result; +} +void c_MyTemplate_T_double_T___destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} +extern "C" { +void c_MyTemplate_T_EmptyStruct_T__Finalizer(void *cppObj) +{ + delete reinterpret_cast *>(cppObj); +} +void *c_MyTemplate_T_EmptyStruct_T___constructor() +{ + auto ptr = new TestBindings_wrappersNS::MyTemplate_wrapper(); + return reinterpret_cast(ptr); +} +// receivesT(T arg__1) +int c_MyTemplate_T_EmptyStruct_T___receivesT_EmptyStruct(void *thisObj, void *arg__1_) +{ + assert(arg__1_); + auto &arg__1 = *reinterpret_cast(arg__1_); + const auto &result = fromPtr(thisObj)->receivesT(arg__1); + return result; +} +// receivesTemplate(MyTemplate arg__1) +int c_MyTemplate_T_EmptyStruct_T___receivesTemplate_MyTemplate_T(void *thisObj, void *arg__1_) +{ + assert(arg__1_); + auto &arg__1 = *reinterpret_cast *>(arg__1_); + const auto &result = fromPtr(thisObj)->receivesTemplate(arg__1); + return result; +} +// returnInt() const +int c_MyTemplate_T_EmptyStruct_T___returnInt(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->returnInt(); + return result; +} +// returnTemplate2() +void *c_MyTemplate_T_EmptyStruct_T___returnTemplate2(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->returnTemplate2() + }; + return result; +} +// returnTemplate3() +void *c_MyTemplate_T_EmptyStruct_T___returnTemplate3(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->returnTemplate3() + }; + return result; +} +// returnTemplate4() +void *c_MyTemplate_T_EmptyStruct_T___returnTemplate4(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->returnTemplate4() + }; + return result; +} +// returnsT() +void *c_MyTemplate_T_EmptyStruct_T___returnsT(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->returnsT() }; + return result; +} +// returnsTemplate() +void *c_MyTemplate_T_EmptyStruct_T___returnsTemplate(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->returnsTemplate() + }; + return result; +} +void c_MyTemplate_T_EmptyStruct_T___destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} diff --git a/tests/generated/TestBindings/dart/ffi/MyTemplate_c.h b/tests/generated/TestBindings/dart/ffi/MyTemplate_c.h new file mode 100644 index 0000000..d7b02a5 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/MyTemplate_c.h @@ -0,0 +1,90 @@ +#include "TestBindings_exports.h" +#include + +namespace TestBindings_wrappersNS { +template +class MyTemplate_wrapper : public ::MyTemplate +{ +public: + ~MyTemplate_wrapper(); + MyTemplate_wrapper(); + int receivesT(T arg__1); + int receivesTemplate(MyTemplate arg__1); + int returnInt() const; + MyTemplate returnTemplate2(); + MyTemplate returnTemplate3(); + MyTemplate returnTemplate4(); + T returnsT(); + MyTemplate returnsTemplate(); +}; +} +extern "C" { +// MyTemplate::MyTemplate() +TestBindings_EXPORT void *c_MyTemplate_T_int_T___constructor(); +// MyTemplate::receivesT(T arg__1) +TestBindings_EXPORT int c_MyTemplate_T_int_T___receivesT_int(void *thisObj, int arg__1); +// MyTemplate::receivesTemplate(MyTemplate arg__1) +TestBindings_EXPORT int c_MyTemplate_T_int_T___receivesTemplate_MyTemplate_T(void *thisObj, + void *arg__1_); +// MyTemplate::returnInt() const +TestBindings_EXPORT int c_MyTemplate_T_int_T___returnInt(void *thisObj); +// MyTemplate::returnTemplate2() +TestBindings_EXPORT void *c_MyTemplate_T_int_T___returnTemplate2(void *thisObj); +// MyTemplate::returnTemplate3() +TestBindings_EXPORT void *c_MyTemplate_T_int_T___returnTemplate3(void *thisObj); +// MyTemplate::returnTemplate4() +TestBindings_EXPORT void *c_MyTemplate_T_int_T___returnTemplate4(void *thisObj); +// MyTemplate::returnsT() +TestBindings_EXPORT int c_MyTemplate_T_int_T___returnsT(void *thisObj); +// MyTemplate::returnsTemplate() +TestBindings_EXPORT void *c_MyTemplate_T_int_T___returnsTemplate(void *thisObj); +TestBindings_EXPORT void c_MyTemplate_T_int_T___destructor(void *thisObj); +TestBindings_EXPORT void c_MyTemplate_T_int_T__Finalizer(void *cppObj); +} +extern "C" { +// MyTemplate::MyTemplate() +TestBindings_EXPORT void *c_MyTemplate_T_double_T___constructor(); +// MyTemplate::receivesT(T arg__1) +TestBindings_EXPORT int c_MyTemplate_T_double_T___receivesT_double(void *thisObj, double arg__1); +// MyTemplate::receivesTemplate(MyTemplate arg__1) +TestBindings_EXPORT int c_MyTemplate_T_double_T___receivesTemplate_MyTemplate_T(void *thisObj, + void *arg__1_); +// MyTemplate::returnInt() const +TestBindings_EXPORT int c_MyTemplate_T_double_T___returnInt(void *thisObj); +// MyTemplate::returnTemplate2() +TestBindings_EXPORT void *c_MyTemplate_T_double_T___returnTemplate2(void *thisObj); +// MyTemplate::returnTemplate3() +TestBindings_EXPORT void *c_MyTemplate_T_double_T___returnTemplate3(void *thisObj); +// MyTemplate::returnTemplate4() +TestBindings_EXPORT void *c_MyTemplate_T_double_T___returnTemplate4(void *thisObj); +// MyTemplate::returnsT() +TestBindings_EXPORT double c_MyTemplate_T_double_T___returnsT(void *thisObj); +// MyTemplate::returnsTemplate() +TestBindings_EXPORT void *c_MyTemplate_T_double_T___returnsTemplate(void *thisObj); +TestBindings_EXPORT void c_MyTemplate_T_double_T___destructor(void *thisObj); +TestBindings_EXPORT void c_MyTemplate_T_double_T__Finalizer(void *cppObj); +} +extern "C" { +// MyTemplate::MyTemplate() +TestBindings_EXPORT void *c_MyTemplate_T_EmptyStruct_T___constructor(); +// MyTemplate::receivesT(T arg__1) +TestBindings_EXPORT int c_MyTemplate_T_EmptyStruct_T___receivesT_EmptyStruct(void *thisObj, + void *arg__1_); +// MyTemplate::receivesTemplate(MyTemplate arg__1) +TestBindings_EXPORT int c_MyTemplate_T_EmptyStruct_T___receivesTemplate_MyTemplate_T(void *thisObj, + void *arg__1_); +// MyTemplate::returnInt() const +TestBindings_EXPORT int c_MyTemplate_T_EmptyStruct_T___returnInt(void *thisObj); +// MyTemplate::returnTemplate2() +TestBindings_EXPORT void *c_MyTemplate_T_EmptyStruct_T___returnTemplate2(void *thisObj); +// MyTemplate::returnTemplate3() +TestBindings_EXPORT void *c_MyTemplate_T_EmptyStruct_T___returnTemplate3(void *thisObj); +// MyTemplate::returnTemplate4() +TestBindings_EXPORT void *c_MyTemplate_T_EmptyStruct_T___returnTemplate4(void *thisObj); +// MyTemplate::returnsT() +TestBindings_EXPORT void *c_MyTemplate_T_EmptyStruct_T___returnsT(void *thisObj); +// MyTemplate::returnsTemplate() +TestBindings_EXPORT void *c_MyTemplate_T_EmptyStruct_T___returnsTemplate(void *thisObj); +TestBindings_EXPORT void c_MyTemplate_T_EmptyStruct_T___destructor(void *thisObj); +TestBindings_EXPORT void c_MyTemplate_T_EmptyStruct_T__Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/NameClashingNS1_c.cpp b/tests/generated/TestBindings/dart/ffi/NameClashingNS1_c.cpp new file mode 100644 index 0000000..7547e05 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/NameClashingNS1_c.cpp @@ -0,0 +1,22 @@ +#include "NameClashingNS1_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +extern "C" { +} diff --git a/tests/generated/TestBindings/dart/ffi/NameClashingNS1_c.h b/tests/generated/TestBindings/dart/ffi/NameClashingNS1_c.h new file mode 100644 index 0000000..c5ffc01 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/NameClashingNS1_c.h @@ -0,0 +1,6 @@ +#include "TestBindings_exports.h" +#include + +extern "C" { +TestBindings_EXPORT void c_NameClashingNS1_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/NameClashingNS2_c.cpp b/tests/generated/TestBindings/dart/ffi/NameClashingNS2_c.cpp new file mode 100644 index 0000000..011ce57 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/NameClashingNS2_c.cpp @@ -0,0 +1,22 @@ +#include "NameClashingNS2_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +extern "C" { +} diff --git a/tests/generated/TestBindings/dart/ffi/NameClashingNS2_c.h b/tests/generated/TestBindings/dart/ffi/NameClashingNS2_c.h new file mode 100644 index 0000000..e1fb18f --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/NameClashingNS2_c.h @@ -0,0 +1,6 @@ +#include "TestBindings_exports.h" +#include + +extern "C" { +TestBindings_EXPORT void c_NameClashingNS2_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/NonCopiable_c.cpp b/tests/generated/TestBindings/dart/ffi/NonCopiable_c.cpp new file mode 100644 index 0000000..8912199 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/NonCopiable_c.cpp @@ -0,0 +1,63 @@ +#include "NonCopiable_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +NonCopiable_wrapper::NonCopiable_wrapper() + : ::NonCopiable() +{ +} +int NonCopiable_wrapper::count() const +{ + return ::NonCopiable::count(); +} +NonCopiable_wrapper::~NonCopiable_wrapper() +{ +} + +} +static NonCopiable *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::NonCopiable_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_NonCopiable_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} +void *c_NonCopiable__constructor() +{ + auto ptr = new TestBindings_wrappersNS::NonCopiable_wrapper(); + return reinterpret_cast(ptr); +} +// count() const +int c_NonCopiable__count(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->count(); + return result; +} +void c_NonCopiable__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} diff --git a/tests/generated/TestBindings/dart/ffi/NonCopiable_c.h b/tests/generated/TestBindings/dart/ffi/NonCopiable_c.h new file mode 100644 index 0000000..7c4531e --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/NonCopiable_c.h @@ -0,0 +1,20 @@ +#include "TestBindings_exports.h" +#include + +namespace TestBindings_wrappersNS { +class NonCopiable_wrapper : public ::NonCopiable +{ +public: + ~NonCopiable_wrapper(); + NonCopiable_wrapper(); + int count() const; +}; +} +extern "C" { +// NonCopiable::NonCopiable() +TestBindings_EXPORT void *c_NonCopiable__constructor(); +// NonCopiable::count() const +TestBindings_EXPORT int c_NonCopiable__count(void *thisObj); +TestBindings_EXPORT void c_NonCopiable__destructor(void *thisObj); +TestBindings_EXPORT void c_NonCopiable_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/POD_c.cpp b/tests/generated/TestBindings/dart/ffi/POD_c.cpp new file mode 100644 index 0000000..549d542 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/POD_c.cpp @@ -0,0 +1,310 @@ +#include "POD_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +POD_wrapper::POD_wrapper() + : ::TestTargetNS::POD() +{ +} +POD_wrapper::POD_wrapper(int a, int b, int c, int d) + : ::TestTargetNS::POD(a, b, c, d) +{ +} +int POD_wrapper::calculate() const +{ + return ::TestTargetNS::POD::calculate(); +} +int POD_wrapper::calculateStatic() +{ + return ::TestTargetNS::POD::calculateStatic(); +} +int POD_wrapper::doStuffOnMyClass(TestTargetNS::MyBaseClass *myarg) +{ + return ::TestTargetNS::POD::doStuffOnMyClass(myarg); +} +const int &POD_wrapper::intByConstRef() const +{ + return ::TestTargetNS::POD::intByConstRef(); +} +int POD_wrapper::receivesConstPointerToPODs(const TestTargetNS::POD *ptrPod1, + const TestTargetNS::POD *ptrPod2) +{ + return ::TestTargetNS::POD::receivesConstPointerToPODs(ptrPod1, ptrPod2); +} +int POD_wrapper::receivesConstRefPODs(const TestTargetNS::POD &pod1, const TestTargetNS::POD &pod2) +{ + return ::TestTargetNS::POD::receivesConstRefPODs(pod1, pod2); +} +void POD_wrapper::receivesNamespaceEnum(int v) +{ + ::TestTargetNS::POD::receivesNamespaceEnum(v); +} +void POD_wrapper::receivesNamespaceEnum1(AnotherNamespace::NamespaceLevelEnum arg__1) +{ + ::TestTargetNS::POD::receivesNamespaceEnum1(arg__1); +} +int POD_wrapper::receivesPODs(TestTargetNS::POD pod1, TestTargetNS::POD pod2) +{ + return ::TestTargetNS::POD::receivesPODs(pod1, pod2); +} +int POD_wrapper::receivesPointerToPODs(TestTargetNS::POD *ptrPod1, TestTargetNS::POD *ptrPod2) +{ + return ::TestTargetNS::POD::receivesPointerToPODs(ptrPod1, ptrPod2); +} +int POD_wrapper::receivesRefPODs(TestTargetNS::POD &pod1, TestTargetNS::POD &pod2) +{ + return ::TestTargetNS::POD::receivesRefPODs(pod1, pod2); +} +void POD_wrapper::receivesReservedDartKeyword(int var) +{ + ::TestTargetNS::POD::receivesReservedDartKeyword(var); +} +char POD_wrapper::returnsChar() +{ + return ::TestTargetNS::POD::returnsChar(); +} +const char POD_wrapper::returnsConstChar() +{ + return ::TestTargetNS::POD::returnsConstChar(); +} +const TestTargetNS::POD &POD_wrapper::returnsConstReferenceToPOD() +{ + return ::TestTargetNS::POD::returnsConstReferenceToPOD(); +} +TestTargetNS::POD POD_wrapper::returnsPOD() +{ + return ::TestTargetNS::POD::returnsPOD(); +} +TestTargetNS::POD *POD_wrapper::returnsPointerToPOD() +{ + return ::TestTargetNS::POD::returnsPointerToPOD(); +} +TestTargetNS::MyBaseClass *POD_wrapper::returnsPointerToPolymorphic() +{ + return ::TestTargetNS::POD::returnsPointerToPolymorphic(); +} +TestTargetNS::POD &POD_wrapper::returnsReferenceToPOD() +{ + return ::TestTargetNS::POD::returnsReferenceToPOD(); +} +void POD_wrapper::withDefaultAarg(int v) +{ + ::TestTargetNS::POD::withDefaultAarg(v); +} +POD_wrapper::~POD_wrapper() +{ +} + +} +static TestTargetNS::POD *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::POD_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_TestTargetNS__POD_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} +void *c_TestTargetNS__POD__constructor() +{ + auto ptr = new TestBindings_wrappersNS::POD_wrapper(); + return reinterpret_cast(ptr); +} +void *c_TestTargetNS__POD__constructor_int_int_int_int(int a, int b, int c, int d) +{ + auto ptr = new TestBindings_wrappersNS::POD_wrapper(a, b, c, d); + return reinterpret_cast(ptr); +} +// calculate() const +int c_TestTargetNS__POD__calculate(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->calculate(); + return result; +} +// calculateStatic() +int c_static_TestTargetNS__POD__calculateStatic() +{ + const auto &result = TestBindings_wrappersNS::POD_wrapper::calculateStatic(); + return result; +} +// doStuffOnMyClass(TestTargetNS::MyBaseClass * myarg) +int c_static_TestTargetNS__POD__doStuffOnMyClass_MyBaseClass(void *myarg_) +{ + auto myarg = reinterpret_cast(myarg_); + const auto &result = TestBindings_wrappersNS::POD_wrapper::doStuffOnMyClass(myarg); + return result; +} +// intByConstRef() const +int c_TestTargetNS__POD__intByConstRef(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->intByConstRef(); + return result; +} +// receivesConstPointerToPODs(const TestTargetNS::POD * ptrPod1, const TestTargetNS::POD * ptrPod2) +int c_static_TestTargetNS__POD__receivesConstPointerToPODs_POD_POD(void *ptrPod1_, void *ptrPod2_) +{ + auto ptrPod1 = reinterpret_cast(ptrPod1_); + auto ptrPod2 = reinterpret_cast(ptrPod2_); + const auto &result = + TestBindings_wrappersNS::POD_wrapper::receivesConstPointerToPODs(ptrPod1, ptrPod2); + return result; +} +// receivesConstRefPODs(const TestTargetNS::POD & pod1, const TestTargetNS::POD & pod2) +int c_static_TestTargetNS__POD__receivesConstRefPODs_POD_POD(void *pod1_, void *pod2_) +{ + assert(pod1_); + auto &pod1 = *reinterpret_cast(pod1_); + assert(pod2_); + auto &pod2 = *reinterpret_cast(pod2_); + const auto &result = TestBindings_wrappersNS::POD_wrapper::receivesConstRefPODs(pod1, pod2); + return result; +} +// receivesNamespaceEnum(int v) +void c_TestTargetNS__POD__receivesNamespaceEnum_int(void *thisObj, int v) +{ + fromPtr(thisObj)->receivesNamespaceEnum(v); +} +// receivesNamespaceEnum1(AnotherNamespace::NamespaceLevelEnum arg__1) +void c_TestTargetNS__POD__receivesNamespaceEnum1_NamespaceLevelEnum(void *thisObj, int arg__1) +{ + fromPtr(thisObj)->receivesNamespaceEnum1( + static_cast(arg__1)); +} +// receivesPODs(TestTargetNS::POD pod1, TestTargetNS::POD pod2) +int c_static_TestTargetNS__POD__receivesPODs_POD_POD(void *pod1_, void *pod2_) +{ + assert(pod1_); + auto &pod1 = *reinterpret_cast(pod1_); + assert(pod2_); + auto &pod2 = *reinterpret_cast(pod2_); + const auto &result = TestBindings_wrappersNS::POD_wrapper::receivesPODs(pod1, pod2); + return result; +} +// receivesPointerToPODs(TestTargetNS::POD * ptrPod1, TestTargetNS::POD * ptrPod2) +int c_static_TestTargetNS__POD__receivesPointerToPODs_POD_POD(void *ptrPod1_, void *ptrPod2_) +{ + auto ptrPod1 = reinterpret_cast(ptrPod1_); + auto ptrPod2 = reinterpret_cast(ptrPod2_); + const auto &result = + TestBindings_wrappersNS::POD_wrapper::receivesPointerToPODs(ptrPod1, ptrPod2); + return result; +} +// receivesRefPODs(TestTargetNS::POD & pod1, TestTargetNS::POD & pod2) +int c_static_TestTargetNS__POD__receivesRefPODs_POD_POD(void *pod1_, void *pod2_) +{ + assert(pod1_); + auto &pod1 = *reinterpret_cast(pod1_); + assert(pod2_); + auto &pod2 = *reinterpret_cast(pod2_); + const auto &result = TestBindings_wrappersNS::POD_wrapper::receivesRefPODs(pod1, pod2); + return result; +} +// receivesReservedDartKeyword(int var) +void c_TestTargetNS__POD__receivesReservedDartKeyword_int(void *thisObj, int var) +{ + fromPtr(thisObj)->receivesReservedDartKeyword(var); +} +// returnsChar() +char c_static_TestTargetNS__POD__returnsChar() +{ + const auto &result = TestBindings_wrappersNS::POD_wrapper::returnsChar(); + return result; +} +// returnsConstChar() +char c_static_TestTargetNS__POD__returnsConstChar() +{ + const auto &result = TestBindings_wrappersNS::POD_wrapper::returnsConstChar(); + return result; +} +// returnsConstReferenceToPOD() +void *c_static_TestTargetNS__POD__returnsConstReferenceToPOD() +{ + const auto &result = const_cast(static_cast( + &TestBindings_wrappersNS::POD_wrapper::returnsConstReferenceToPOD())); + return result; +} +// returnsPOD() +void *c_static_TestTargetNS__POD__returnsPOD() +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::POD_wrapper::returnsPOD() + }; + return result; +} +// returnsPointerToPOD() +void *c_static_TestTargetNS__POD__returnsPointerToPOD() +{ + const auto &result = TestBindings_wrappersNS::POD_wrapper::returnsPointerToPOD(); + return result; +} +// returnsPointerToPolymorphic() +void *c_static_TestTargetNS__POD__returnsPointerToPolymorphic() +{ + const auto &result = TestBindings_wrappersNS::POD_wrapper::returnsPointerToPolymorphic(); + return result; +} +// returnsReferenceToPOD() +void *c_static_TestTargetNS__POD__returnsReferenceToPOD() +{ + const auto &result = &TestBindings_wrappersNS::POD_wrapper::returnsReferenceToPOD(); + return result; +} +// withDefaultAarg(int v) +void c_TestTargetNS__POD__withDefaultAarg_int(void *thisObj, int v) +{ + fromPtr(thisObj)->withDefaultAarg(v); +} +void c_TestTargetNS__POD__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +int c_TestTargetNS__POD___get_v1(void *thisObj) +{ + return fromPtr(thisObj)->v1; +} +int c_TestTargetNS__POD___get_v2(void *thisObj) +{ + return fromPtr(thisObj)->v2; +} +int c_TestTargetNS__POD___get_v3(void *thisObj) +{ + return fromPtr(thisObj)->v3; +} +int c_TestTargetNS__POD___get_v4_const(void *thisObj) +{ + return fromPtr(thisObj)->v4_const; +} +void c_TestTargetNS__POD___set_v1_int(void *thisObj, int v1_) +{ + fromPtr(thisObj)->v1 = v1_; +} +void c_TestTargetNS__POD___set_v2_int(void *thisObj, int v2_) +{ + fromPtr(thisObj)->v2 = v2_; +} +void c_TestTargetNS__POD___set_v3_int(void *thisObj, int v3_) +{ + fromPtr(thisObj)->v3 = v3_; +} +} diff --git a/tests/generated/TestBindings/dart/ffi/POD_c.h b/tests/generated/TestBindings/dart/ffi/POD_c.h new file mode 100644 index 0000000..2b6456d --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/POD_c.h @@ -0,0 +1,99 @@ +#include "TestBindings_exports.h" +#include + +namespace TestBindings_wrappersNS { +class POD_wrapper : public ::TestTargetNS::POD +{ +public: + ~POD_wrapper(); + POD_wrapper(); + POD_wrapper(int a, int b, int c, int d); + int calculate() const; + static int calculateStatic(); + static int doStuffOnMyClass(TestTargetNS::MyBaseClass *myarg); + const int &intByConstRef() const; + static int receivesConstPointerToPODs(const TestTargetNS::POD *ptrPod1, + const TestTargetNS::POD *ptrPod2); + static int receivesConstRefPODs(const TestTargetNS::POD &pod1, const TestTargetNS::POD &pod2); + void receivesNamespaceEnum(int v = AnotherNamespace::NamespaceLevelEnum_value1 + 1); + void receivesNamespaceEnum1( + AnotherNamespace::NamespaceLevelEnum arg__1 = AnotherNamespace::NamespaceLevelEnum_value1); + static int receivesPODs(TestTargetNS::POD pod1, TestTargetNS::POD pod2); + static int receivesPointerToPODs(TestTargetNS::POD *ptrPod1, TestTargetNS::POD *ptrPod2); + static int receivesRefPODs(TestTargetNS::POD &pod1, TestTargetNS::POD &pod2); + void receivesReservedDartKeyword(int var); + static char returnsChar(); + static const char returnsConstChar(); + static const TestTargetNS::POD &returnsConstReferenceToPOD(); + static TestTargetNS::POD returnsPOD(); + static TestTargetNS::POD *returnsPointerToPOD(); + static TestTargetNS::MyBaseClass *returnsPointerToPolymorphic(); + static TestTargetNS::POD &returnsReferenceToPOD(); + void withDefaultAarg(int v = 2); +}; +} +extern "C" { +// TestTargetNS::POD::POD() +TestBindings_EXPORT void *c_TestTargetNS__POD__constructor(); +// TestTargetNS::POD::POD(int a, int b, int c, int d) +TestBindings_EXPORT void *c_TestTargetNS__POD__constructor_int_int_int_int(int a, int b, int c, + int d); +// TestTargetNS::POD::calculate() const +TestBindings_EXPORT int c_TestTargetNS__POD__calculate(void *thisObj); +// TestTargetNS::POD::calculateStatic() +TestBindings_EXPORT int c_static_TestTargetNS__POD__calculateStatic(); +// TestTargetNS::POD::doStuffOnMyClass(TestTargetNS::MyBaseClass * myarg) +TestBindings_EXPORT int c_static_TestTargetNS__POD__doStuffOnMyClass_MyBaseClass(void *myarg_); +// TestTargetNS::POD::intByConstRef() const +TestBindings_EXPORT int c_TestTargetNS__POD__intByConstRef(void *thisObj); +// TestTargetNS::POD::receivesConstPointerToPODs(const TestTargetNS::POD * ptrPod1, const +// TestTargetNS::POD * ptrPod2) +TestBindings_EXPORT int +c_static_TestTargetNS__POD__receivesConstPointerToPODs_POD_POD(void *ptrPod1_, void *ptrPod2_); +// TestTargetNS::POD::receivesConstRefPODs(const TestTargetNS::POD & pod1, const TestTargetNS::POD & +// pod2) +TestBindings_EXPORT int c_static_TestTargetNS__POD__receivesConstRefPODs_POD_POD(void *pod1_, + void *pod2_); +// TestTargetNS::POD::receivesNamespaceEnum(int v) +TestBindings_EXPORT void c_TestTargetNS__POD__receivesNamespaceEnum_int(void *thisObj, int v); +// TestTargetNS::POD::receivesNamespaceEnum1(AnotherNamespace::NamespaceLevelEnum arg__1) +TestBindings_EXPORT void +c_TestTargetNS__POD__receivesNamespaceEnum1_NamespaceLevelEnum(void *thisObj, int arg__1); +// TestTargetNS::POD::receivesPODs(TestTargetNS::POD pod1, TestTargetNS::POD pod2) +TestBindings_EXPORT int c_static_TestTargetNS__POD__receivesPODs_POD_POD(void *pod1_, void *pod2_); +// TestTargetNS::POD::receivesPointerToPODs(TestTargetNS::POD * ptrPod1, TestTargetNS::POD * +// ptrPod2) +TestBindings_EXPORT int c_static_TestTargetNS__POD__receivesPointerToPODs_POD_POD(void *ptrPod1_, + void *ptrPod2_); +// TestTargetNS::POD::receivesRefPODs(TestTargetNS::POD & pod1, TestTargetNS::POD & pod2) +TestBindings_EXPORT int c_static_TestTargetNS__POD__receivesRefPODs_POD_POD(void *pod1_, + void *pod2_); +// TestTargetNS::POD::receivesReservedDartKeyword(int var) +TestBindings_EXPORT void c_TestTargetNS__POD__receivesReservedDartKeyword_int(void *thisObj, + int var); +// TestTargetNS::POD::returnsChar() +TestBindings_EXPORT char c_static_TestTargetNS__POD__returnsChar(); +// TestTargetNS::POD::returnsConstChar() +TestBindings_EXPORT char c_static_TestTargetNS__POD__returnsConstChar(); +// TestTargetNS::POD::returnsConstReferenceToPOD() +TestBindings_EXPORT void *c_static_TestTargetNS__POD__returnsConstReferenceToPOD(); +// TestTargetNS::POD::returnsPOD() +TestBindings_EXPORT void *c_static_TestTargetNS__POD__returnsPOD(); +// TestTargetNS::POD::returnsPointerToPOD() +TestBindings_EXPORT void *c_static_TestTargetNS__POD__returnsPointerToPOD(); +// TestTargetNS::POD::returnsPointerToPolymorphic() +TestBindings_EXPORT void *c_static_TestTargetNS__POD__returnsPointerToPolymorphic(); +// TestTargetNS::POD::returnsReferenceToPOD() +TestBindings_EXPORT void *c_static_TestTargetNS__POD__returnsReferenceToPOD(); +// TestTargetNS::POD::withDefaultAarg(int v) +TestBindings_EXPORT void c_TestTargetNS__POD__withDefaultAarg_int(void *thisObj, int v); +TestBindings_EXPORT void c_TestTargetNS__POD__destructor(void *thisObj); +TestBindings_EXPORT int c_TestTargetNS__POD___get_v1(void *thisObj); +TestBindings_EXPORT int c_TestTargetNS__POD___get_v2(void *thisObj); +TestBindings_EXPORT int c_TestTargetNS__POD___get_v3(void *thisObj); +TestBindings_EXPORT int c_TestTargetNS__POD___get_v4_const(void *thisObj); +TestBindings_EXPORT void c_TestTargetNS__POD___set_v1_int(void *thisObj, int v1_); +TestBindings_EXPORT void c_TestTargetNS__POD___set_v2_int(void *thisObj, int v2_); +TestBindings_EXPORT void c_TestTargetNS__POD___set_v3_int(void *thisObj, int v3_); +TestBindings_EXPORT void c_TestTargetNS__POD_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/PureAbstractWithUnknownType_c.cpp b/tests/generated/TestBindings/dart/ffi/PureAbstractWithUnknownType_c.cpp new file mode 100644 index 0000000..3be9855 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/PureAbstractWithUnknownType_c.cpp @@ -0,0 +1,53 @@ +#include "PureAbstractWithUnknownType_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +int PureAbstractWithUnknownType_wrapper::getValue() const +{ + return ::PureAbstractWithUnknownType::getValue(); +} +PureAbstractWithUnknownType_wrapper::~PureAbstractWithUnknownType_wrapper() +{ +} + +} +static PureAbstractWithUnknownType *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::PureAbstractWithUnknownType_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_PureAbstractWithUnknownType_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} // getValue() const +int c_PureAbstractWithUnknownType__getValue(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->getValue(); + return result; +} +void c_PureAbstractWithUnknownType__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} diff --git a/tests/generated/TestBindings/dart/ffi/PureAbstractWithUnknownType_c.h b/tests/generated/TestBindings/dart/ffi/PureAbstractWithUnknownType_c.h new file mode 100644 index 0000000..5e746a0 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/PureAbstractWithUnknownType_c.h @@ -0,0 +1,17 @@ +#include "TestBindings_exports.h" +#include + +namespace TestBindings_wrappersNS { +class PureAbstractWithUnknownType_wrapper : public ::PureAbstractWithUnknownType +{ +public: + ~PureAbstractWithUnknownType_wrapper(); + int getValue() const; +}; +} +extern "C" { +// PureAbstractWithUnknownType::getValue() const +TestBindings_EXPORT int c_PureAbstractWithUnknownType__getValue(void *thisObj); +TestBindings_EXPORT void c_PureAbstractWithUnknownType__destructor(void *thisObj); +TestBindings_EXPORT void c_PureAbstractWithUnknownType_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/PureAbstract_c.cpp b/tests/generated/TestBindings/dart/ffi/PureAbstract_c.cpp new file mode 100644 index 0000000..13e2c7e --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/PureAbstract_c.cpp @@ -0,0 +1,271 @@ +#include "PureAbstract_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +PureAbstract_wrapper::PureAbstract_wrapper() + : ::TestTargetNS::PureAbstract() +{ +} +int PureAbstract_wrapper::callVirtualReceivingPointer(SimpleStruct *s) +{ + return ::TestTargetNS::PureAbstract::callVirtualReceivingPointer(s); +} +void PureAbstract_wrapper::flagsWithDefaultArgs( + QFlags options) +{ + ::TestTargetNS::PureAbstract::flagsWithDefaultArgs(options); +} +int PureAbstract_wrapper::foo() +{ + if (m_fooCallback) { + const void *thisPtr = this; + return m_fooCallback(const_cast(thisPtr)); + } else { + std::cerr << "foo: Warning: Calling pure-virtual\n"; + return {}; + } +} +int PureAbstract_wrapper::foo_nocallback() +{ + std::cerr << "foo: Warning: Calling pure-virtual\n"; + return {}; +} +void PureAbstract_wrapper::renamedPureVirtual() +{ + if (m_renamedPureVirtual1Callback) { + const void *thisPtr = this; + m_renamedPureVirtual1Callback(const_cast(thisPtr)); + } else { + std::cerr << "renamedPureVirtual1: Warning: Calling pure-virtual\n"; + return; + } +} +void PureAbstract_wrapper::renamedPureVirtual_nocallback() +{ + std::cerr << "renamedPureVirtual1: Warning: Calling pure-virtual\n"; + return; +} +void PureAbstract_wrapper::renamedStatic() +{ + ::TestTargetNS::PureAbstract::renamedStatic(); +} +int PureAbstract_wrapper::returnsInt() const +{ + return ::TestTargetNS::PureAbstract::returnsInt(); +} +void PureAbstract_wrapper::unnamedOverriddenDefaultArgCase(int myarg) +{ + if (m_unnamedOverriddenDefaultArgCaseCallback) { + const void *thisPtr = this; + m_unnamedOverriddenDefaultArgCaseCallback(const_cast(thisPtr), myarg); + } else { + ::TestTargetNS::PureAbstract::unnamedOverriddenDefaultArgCase(myarg); + } +} +void PureAbstract_wrapper::unnamedOverriddenDefaultArgCase_nocallback(int myarg) +{ + ::TestTargetNS::PureAbstract::unnamedOverriddenDefaultArgCase(myarg); +} +int PureAbstract_wrapper::virtualReceivingPointer(SimpleStruct *s) +{ + if (m_virtualReceivingPointerCallback) { + const void *thisPtr = this; + return m_virtualReceivingPointerCallback(const_cast(thisPtr), s); + } else { + return ::TestTargetNS::PureAbstract::virtualReceivingPointer(s); + } +} +int PureAbstract_wrapper::virtualReceivingPointer_nocallback(SimpleStruct *s) +{ + return ::TestTargetNS::PureAbstract::virtualReceivingPointer(s); +} +void PureAbstract_wrapper::voidPureAbstract() +{ + if (m_voidPureAbstractCallback) { + const void *thisPtr = this; + m_voidPureAbstractCallback(const_cast(thisPtr)); + } else { + std::cerr << "voidPureAbstract: Warning: Calling pure-virtual\n"; + return; + } +} +void PureAbstract_wrapper::voidPureAbstract_nocallback() +{ + std::cerr << "voidPureAbstract: Warning: Calling pure-virtual\n"; + return; +} +PureAbstract_wrapper::~PureAbstract_wrapper() +{ +} + +} +static TestTargetNS::PureAbstract *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::PureAbstract_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_TestTargetNS__PureAbstract_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} +void *c_TestTargetNS__PureAbstract__constructor() +{ + auto ptr = new TestBindings_wrappersNS::PureAbstract_wrapper(); + return reinterpret_cast(ptr); +} +// callVirtualReceivingPointer(SimpleStruct * s) +int c_TestTargetNS__PureAbstract__callVirtualReceivingPointer_SimpleStruct(void *thisObj, void *s_) +{ + auto s = reinterpret_cast(s_); + const auto &result = fromPtr(thisObj)->callVirtualReceivingPointer(s); + return result; +} +// flagsWithDefaultArgs(QFlags options) +void c_TestTargetNS__PureAbstract__flagsWithDefaultArgs_NamespaceLevelEnums(void *thisObj, + int options_) +{ + auto options = static_cast>(options_); + fromPtr(thisObj)->flagsWithDefaultArgs(options); +} +// foo() +int c_TestTargetNS__PureAbstract__foo(void *thisObj) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->foo_nocallback(); + } else { + return targetPtr->foo(); + } + }(); + return result; +} +// renamedPureVirtual() +void c_TestTargetNS__PureAbstract__renamedPureVirtual1(void *thisObj) +{ + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->renamedPureVirtual_nocallback(); + } else { + return targetPtr->renamedPureVirtual(); + } + }(); +} +// renamedStatic() +void c_static_TestTargetNS__PureAbstract__renamedStatic1() +{ + TestBindings_wrappersNS::PureAbstract_wrapper::renamedStatic(); +} +// returnsInt() const +int c_TestTargetNS__PureAbstract__returnsInt(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->returnsInt(); + return result; +} +// unnamedOverriddenDefaultArgCase(int myarg) +void c_TestTargetNS__PureAbstract__unnamedOverriddenDefaultArgCase_int(void *thisObj, int myarg) +{ + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->unnamedOverriddenDefaultArgCase_nocallback(myarg); + } else { + return targetPtr->unnamedOverriddenDefaultArgCase(myarg); + } + }(); +} +// virtualReceivingPointer(SimpleStruct * s) +int c_TestTargetNS__PureAbstract__virtualReceivingPointer_SimpleStruct(void *thisObj, void *s_) +{ + auto s = reinterpret_cast(s_); + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualReceivingPointer_nocallback(s); + } else { + return targetPtr->virtualReceivingPointer(s); + } + }(); + return result; +} +// voidPureAbstract() +void c_TestTargetNS__PureAbstract__voidPureAbstract(void *thisObj) +{ + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->voidPureAbstract_nocallback(); + } else { + return targetPtr->voidPureAbstract(); + } + }(); +} +void c_TestTargetNS__PureAbstract__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +int c_static_TestTargetNS__PureAbstract___get_s_instanceCount() +{ + return TestBindings_wrappersNS::PureAbstract_wrapper::s_instanceCount; +} +void c_static_TestTargetNS__PureAbstract___set_s_instanceCount_int(int s_instanceCount_) +{ + TestBindings_wrappersNS::PureAbstract_wrapper::s_instanceCount = s_instanceCount_; +} +void c_TestTargetNS__PureAbstract__registerVirtualMethodCallback(void *ptr, void *callback, + int methodId) +{ + auto wrapper = fromWrapperPtr(ptr); + switch (methodId) { + case 13: + wrapper->m_fooCallback = + reinterpret_cast(callback); + break; + case 14: + wrapper->m_renamedPureVirtual1Callback = reinterpret_cast< + TestBindings_wrappersNS::PureAbstract_wrapper::Callback_renamedPureVirtual1>(callback); + break; + case 17: + wrapper->m_unnamedOverriddenDefaultArgCaseCallback = + reinterpret_cast(callback); + break; + case 18: + wrapper->m_virtualReceivingPointerCallback = reinterpret_cast< + TestBindings_wrappersNS::PureAbstract_wrapper::Callback_virtualReceivingPointer>( + callback); + break; + case 19: + wrapper->m_voidPureAbstractCallback = reinterpret_cast< + TestBindings_wrappersNS::PureAbstract_wrapper::Callback_voidPureAbstract>(callback); + break; + } +} +} diff --git a/tests/generated/TestBindings/dart/ffi/PureAbstract_c.h b/tests/generated/TestBindings/dart/ffi/PureAbstract_c.h new file mode 100644 index 0000000..51e3558 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/PureAbstract_c.h @@ -0,0 +1,70 @@ +#include "TestBindings_exports.h" +#include + +namespace TestBindings_wrappersNS { +class PureAbstract_wrapper : public ::TestTargetNS::PureAbstract +{ +public: + ~PureAbstract_wrapper(); + PureAbstract_wrapper(); + int callVirtualReceivingPointer(SimpleStruct *s); + void flagsWithDefaultArgs(QFlags options = {}); + virtual int foo(); + virtual int foo_nocallback(); + virtual void renamedPureVirtual(); + virtual void renamedPureVirtual_nocallback(); + static void renamedStatic(); + int returnsInt() const; + virtual void unnamedOverriddenDefaultArgCase(int myarg = 0); + virtual void unnamedOverriddenDefaultArgCase_nocallback(int myarg = 0); + virtual int virtualReceivingPointer(SimpleStruct *s); + virtual int virtualReceivingPointer_nocallback(SimpleStruct *s); + virtual void voidPureAbstract(); + virtual void voidPureAbstract_nocallback(); + typedef int (*Callback_foo)(void *); + Callback_foo m_fooCallback = nullptr; + typedef void (*Callback_renamedPureVirtual1)(void *); + Callback_renamedPureVirtual1 m_renamedPureVirtual1Callback = nullptr; + typedef void (*Callback_unnamedOverriddenDefaultArgCase)(void *, int myarg); + Callback_unnamedOverriddenDefaultArgCase m_unnamedOverriddenDefaultArgCaseCallback = nullptr; + typedef int (*Callback_virtualReceivingPointer)(void *, SimpleStruct *s); + Callback_virtualReceivingPointer m_virtualReceivingPointerCallback = nullptr; + typedef void (*Callback_voidPureAbstract)(void *); + Callback_voidPureAbstract m_voidPureAbstractCallback = nullptr; +}; +} +extern "C" { +// TestTargetNS::PureAbstract::PureAbstract() +TestBindings_EXPORT void *c_TestTargetNS__PureAbstract__constructor(); +// TestTargetNS::PureAbstract::callVirtualReceivingPointer(SimpleStruct * s) +TestBindings_EXPORT int +c_TestTargetNS__PureAbstract__callVirtualReceivingPointer_SimpleStruct(void *thisObj, void *s_); +// TestTargetNS::PureAbstract::flagsWithDefaultArgs(QFlags +// options) +TestBindings_EXPORT void +c_TestTargetNS__PureAbstract__flagsWithDefaultArgs_NamespaceLevelEnums(void *thisObj, int options_); +// TestTargetNS::PureAbstract::foo() +TestBindings_EXPORT int c_TestTargetNS__PureAbstract__foo(void *thisObj); +// TestTargetNS::PureAbstract::renamedPureVirtual() +TestBindings_EXPORT void c_TestTargetNS__PureAbstract__renamedPureVirtual1(void *thisObj); +// TestTargetNS::PureAbstract::renamedStatic() +TestBindings_EXPORT void c_static_TestTargetNS__PureAbstract__renamedStatic1(); +// TestTargetNS::PureAbstract::returnsInt() const +TestBindings_EXPORT int c_TestTargetNS__PureAbstract__returnsInt(void *thisObj); +// TestTargetNS::PureAbstract::unnamedOverriddenDefaultArgCase(int myarg) +TestBindings_EXPORT void +c_TestTargetNS__PureAbstract__unnamedOverriddenDefaultArgCase_int(void *thisObj, int myarg); +// TestTargetNS::PureAbstract::virtualReceivingPointer(SimpleStruct * s) +TestBindings_EXPORT int +c_TestTargetNS__PureAbstract__virtualReceivingPointer_SimpleStruct(void *thisObj, void *s_); +// TestTargetNS::PureAbstract::voidPureAbstract() +TestBindings_EXPORT void c_TestTargetNS__PureAbstract__voidPureAbstract(void *thisObj); +TestBindings_EXPORT void c_TestTargetNS__PureAbstract__destructor(void *thisObj); +TestBindings_EXPORT int c_static_TestTargetNS__PureAbstract___get_s_instanceCount(); +TestBindings_EXPORT void +c_static_TestTargetNS__PureAbstract___set_s_instanceCount_int(int s_instanceCount_); +TestBindings_EXPORT void c_TestTargetNS__PureAbstract__registerVirtualMethodCallback(void *ptr, + void *callback, + int methodId); +TestBindings_EXPORT void c_TestTargetNS__PureAbstract_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/QApplication_c.cpp b/tests/generated/TestBindings/dart/ffi/QApplication_c.cpp new file mode 100644 index 0000000..996c7f5 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/QApplication_c.cpp @@ -0,0 +1,417 @@ +#include "QApplication_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +void QApplication_wrapper::aboutQt() +{ + ::QApplication::aboutQt(); +} +bool QApplication_wrapper::autoSipEnabled() const +{ + return ::QApplication::autoSipEnabled(); +} +void QApplication_wrapper::beep() +{ + ::QApplication::beep(); +} +void QApplication_wrapper::closeAllWindows() +{ + ::QApplication::closeAllWindows(); +} +int QApplication_wrapper::cursorFlashTime() +{ + return ::QApplication::cursorFlashTime(); +} +void QApplication_wrapper::customEvent(QEvent *event) +{ + if (m_customEventCallback) { + const void *thisPtr = this; + m_customEventCallback(const_cast(thisPtr), event); + } else { + ::QApplication::customEvent(event); + } +} +void QApplication_wrapper::customEvent_nocallback(QEvent *event) +{ + ::QApplication::customEvent(event); +} +int QApplication_wrapper::doubleClickInterval() +{ + return ::QApplication::doubleClickInterval(); +} +bool QApplication_wrapper::event(QEvent *arg__1) +{ + if (m_eventCallback) { + const void *thisPtr = this; + return m_eventCallback(const_cast(thisPtr), arg__1); + } else { + return ::QApplication::event(arg__1); + } +} +bool QApplication_wrapper::event_nocallback(QEvent *arg__1) +{ + return ::QApplication::event(arg__1); +} +bool QApplication_wrapper::eventFilter(QObject *watched, QEvent *event) +{ + if (m_eventFilterCallback) { + const void *thisPtr = this; + return m_eventFilterCallback(const_cast(thisPtr), watched, event); + } else { + return ::QApplication::eventFilter(watched, event); + } +} +bool QApplication_wrapper::eventFilter_nocallback(QObject *watched, QEvent *event) +{ + return ::QApplication::eventFilter(watched, event); +} +int QApplication_wrapper::exec() +{ + return ::QApplication::exec(); +} +int QApplication_wrapper::keyboardInputInterval() +{ + return ::QApplication::keyboardInputInterval(); +} +bool QApplication_wrapper::notify(QObject *arg__1, QEvent *arg__2) +{ + if (m_notifyCallback) { + const void *thisPtr = this; + return m_notifyCallback(const_cast(thisPtr), arg__1, arg__2); + } else { + return ::QApplication::notify(arg__1, arg__2); + } +} +bool QApplication_wrapper::notify_nocallback(QObject *arg__1, QEvent *arg__2) +{ + return ::QApplication::notify(arg__1, arg__2); +} +void QApplication_wrapper::setAutoSipEnabled(const bool enabled) +{ + ::QApplication::setAutoSipEnabled(enabled); +} +void QApplication_wrapper::setCursorFlashTime(int arg__1) +{ + ::QApplication::setCursorFlashTime(arg__1); +} +void QApplication_wrapper::setDoubleClickInterval(int arg__1) +{ + ::QApplication::setDoubleClickInterval(arg__1); +} +void QApplication_wrapper::setKeyboardInputInterval(int arg__1) +{ + ::QApplication::setKeyboardInputInterval(arg__1); +} +void QApplication_wrapper::setStartDragDistance(int l) +{ + ::QApplication::setStartDragDistance(l); +} +void QApplication_wrapper::setStartDragTime(int ms) +{ + ::QApplication::setStartDragTime(ms); +} +void QApplication_wrapper::setStyleSheet(const QString &sheet) +{ + ::QApplication::setStyleSheet(sheet); +} +void QApplication_wrapper::setWheelScrollLines(int arg__1) +{ + ::QApplication::setWheelScrollLines(arg__1); +} +int QApplication_wrapper::startDragDistance() +{ + return ::QApplication::startDragDistance(); +} +int QApplication_wrapper::startDragTime() +{ + return ::QApplication::startDragTime(); +} +QString QApplication_wrapper::styleSheet() const +{ + return ::QApplication::styleSheet(); +} +QString QApplication_wrapper::tr(const char *s, const char *c, int n) +{ + return ::QApplication::tr(s, c, n); +} +int QApplication_wrapper::wheelScrollLines() +{ + return ::QApplication::wheelScrollLines(); +} +QApplication_wrapper::~QApplication_wrapper() +{ +} + +} +static QApplication *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::QApplication_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_QApplication_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} // aboutQt() +void c_static_QApplication__aboutQt() +{ + TestBindings_wrappersNS::QApplication_wrapper::aboutQt(); +} +void c_QApplication__onApplicationDisplayNameChanged(void *thisObj, void *contextQObject, + void *callback) +{ + auto instance = reinterpret_cast(thisObj); + auto context = reinterpret_cast(contextQObject); + QObject::connect(instance, &QApplication::applicationDisplayNameChanged, + context ? context : instance, [thisObj, callback] { + typedef void (*SignalHandler_callback)(void *); + auto dartCallback = reinterpret_cast(callback); + dartCallback(thisObj); + }); +} +// autoSipEnabled() const +bool c_QApplication__autoSipEnabled(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->autoSipEnabled(); + return result; +} +// beep() +void c_static_QApplication__beep() +{ + TestBindings_wrappersNS::QApplication_wrapper::beep(); +} +// closeAllWindows() +void c_static_QApplication__closeAllWindows() +{ + TestBindings_wrappersNS::QApplication_wrapper::closeAllWindows(); +} +// cursorFlashTime() +int c_static_QApplication__cursorFlashTime() +{ + const auto &result = TestBindings_wrappersNS::QApplication_wrapper::cursorFlashTime(); + return result; +} +// customEvent(QEvent * event) +void c_QApplication__customEvent_QEvent(void *thisObj, void *event_) +{ + auto event = reinterpret_cast(event_); + fromWrapperPtr(thisObj)->customEvent_nocallback(event); +} +// doubleClickInterval() +int c_static_QApplication__doubleClickInterval() +{ + const auto &result = TestBindings_wrappersNS::QApplication_wrapper::doubleClickInterval(); + return result; +} +// event(QEvent * arg__1) +bool c_QApplication__event_QEvent(void *thisObj, void *arg__1_) +{ + auto arg__1 = reinterpret_cast(arg__1_); + const auto &result = fromWrapperPtr(thisObj)->event_nocallback(arg__1); + return result; +} +// eventFilter(QObject * watched, QEvent * event) +bool c_QApplication__eventFilter_QObject_QEvent(void *thisObj, void *watched_, void *event_) +{ + auto watched = reinterpret_cast(watched_); + auto event = reinterpret_cast(event_); + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->eventFilter_nocallback(watched, event); + } else { + return targetPtr->eventFilter(watched, event); + } + }(); + return result; +} +// exec() +int c_static_QApplication__exec() +{ + const auto &result = TestBindings_wrappersNS::QApplication_wrapper::exec(); + return result; +} +void c_QApplication__onFocusObjectChanged_QObject(void *thisObj, void *contextQObject, + void *callback) +{ + auto instance = reinterpret_cast(thisObj); + auto context = reinterpret_cast(contextQObject); + QObject::connect(instance, &QApplication::focusObjectChanged, context ? context : instance, + [thisObj, callback] { + typedef void (*SignalHandler_callback)(void *); + auto dartCallback = reinterpret_cast(callback); + dartCallback(thisObj); + }); +} +void c_QApplication__onFontDatabaseChanged(void *thisObj, void *contextQObject, void *callback) +{ + auto instance = reinterpret_cast(thisObj); + auto context = reinterpret_cast(contextQObject); + QObject::connect(instance, &QApplication::fontDatabaseChanged, context ? context : instance, + [thisObj, callback] { + typedef void (*SignalHandler_callback)(void *); + auto dartCallback = reinterpret_cast(callback); + dartCallback(thisObj); + }); +} +// keyboardInputInterval() +int c_static_QApplication__keyboardInputInterval() +{ + const auto &result = TestBindings_wrappersNS::QApplication_wrapper::keyboardInputInterval(); + return result; +} +void c_QApplication__onLastWindowClosed(void *thisObj, void *contextQObject, void *callback) +{ + auto instance = reinterpret_cast(thisObj); + auto context = reinterpret_cast(contextQObject); + QObject::connect(instance, &QApplication::lastWindowClosed, context ? context : instance, + [thisObj, callback] { + typedef void (*SignalHandler_callback)(void *); + auto dartCallback = reinterpret_cast(callback); + dartCallback(thisObj); + }); +} +// notify(QObject * arg__1, QEvent * arg__2) +bool c_QApplication__notify_QObject_QEvent(void *thisObj, void *arg__1_, void *arg__2_) +{ + auto arg__1 = reinterpret_cast(arg__1_); + auto arg__2 = reinterpret_cast(arg__2_); + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->notify_nocallback(arg__1, arg__2); + } else { + return targetPtr->notify(arg__1, arg__2); + } + }(); + return result; +} +// setAutoSipEnabled(const bool enabled) +void c_QApplication__setAutoSipEnabled_bool(void *thisObj, bool enabled) +{ + fromPtr(thisObj)->setAutoSipEnabled(enabled); +} +// setCursorFlashTime(int arg__1) +void c_static_QApplication__setCursorFlashTime_int(int arg__1) +{ + TestBindings_wrappersNS::QApplication_wrapper::setCursorFlashTime(arg__1); +} +// setDoubleClickInterval(int arg__1) +void c_static_QApplication__setDoubleClickInterval_int(int arg__1) +{ + TestBindings_wrappersNS::QApplication_wrapper::setDoubleClickInterval(arg__1); +} +// setKeyboardInputInterval(int arg__1) +void c_static_QApplication__setKeyboardInputInterval_int(int arg__1) +{ + TestBindings_wrappersNS::QApplication_wrapper::setKeyboardInputInterval(arg__1); +} +// setStartDragDistance(int l) +void c_static_QApplication__setStartDragDistance_int(int l) +{ + TestBindings_wrappersNS::QApplication_wrapper::setStartDragDistance(l); +} +// setStartDragTime(int ms) +void c_static_QApplication__setStartDragTime_int(int ms) +{ + TestBindings_wrappersNS::QApplication_wrapper::setStartDragTime(ms); +} +// setStyleSheet(const QString & sheet) +void c_QApplication__setStyleSheet_QString(void *thisObj, const char *sheet_) +{ + const auto sheet = QString::fromUtf8(sheet_); + fromPtr(thisObj)->setStyleSheet(sheet); + free(( char * )sheet_); +} +// setWheelScrollLines(int arg__1) +void c_static_QApplication__setWheelScrollLines_int(int arg__1) +{ + TestBindings_wrappersNS::QApplication_wrapper::setWheelScrollLines(arg__1); +} +// startDragDistance() +int c_static_QApplication__startDragDistance() +{ + const auto &result = TestBindings_wrappersNS::QApplication_wrapper::startDragDistance(); + return result; +} +// startDragTime() +int c_static_QApplication__startDragTime() +{ + const auto &result = TestBindings_wrappersNS::QApplication_wrapper::startDragTime(); + return result; +} +// styleSheet() const +void *c_QApplication__styleSheet(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->styleSheet() }; + return result; +} +// tr(const char * s, const char * c, int n) +void *c_static_QApplication__tr_char_char_int(const char *s, const char *c, int n) +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QApplication_wrapper::tr(s, c, n) + }; + free(( char * )s); + free(( char * )c); + return result; +} +// wheelScrollLines() +int c_static_QApplication__wheelScrollLines() +{ + const auto &result = TestBindings_wrappersNS::QApplication_wrapper::wheelScrollLines(); + return result; +} +void c_QApplication__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +void c_QApplication__registerVirtualMethodCallback(void *ptr, void *callback, int methodId) +{ + auto wrapper = fromWrapperPtr(ptr); + switch (methodId) { + case 481: + wrapper->m_customEventCallback = + reinterpret_cast( + callback); + break; + case 490: + wrapper->m_eventCallback = + reinterpret_cast( + callback); + break; + case 491: + wrapper->m_eventFilterCallback = + reinterpret_cast( + callback); + break; + case 688: + wrapper->m_notifyCallback = + reinterpret_cast( + callback); + break; + } +} +} diff --git a/tests/generated/TestBindings/dart/ffi/QApplication_c.h b/tests/generated/TestBindings/dart/ffi/QApplication_c.h new file mode 100644 index 0000000..7101109 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/QApplication_c.h @@ -0,0 +1,109 @@ +#include "TestBindings_exports.h" +#include +#include +#include +#include + +namespace TestBindings_wrappersNS { +class QApplication_wrapper : public ::QApplication +{ +public: + ~QApplication_wrapper(); + static void aboutQt(); + bool autoSipEnabled() const; + static void beep(); + static void closeAllWindows(); + static int cursorFlashTime(); + virtual void customEvent(QEvent *event); + virtual void customEvent_nocallback(QEvent *event); + static int doubleClickInterval(); + virtual bool event(QEvent *arg__1); + virtual bool event_nocallback(QEvent *arg__1); + virtual bool eventFilter(QObject *watched, QEvent *event); + virtual bool eventFilter_nocallback(QObject *watched, QEvent *event); + static int exec(); + static int keyboardInputInterval(); + virtual bool notify(QObject *arg__1, QEvent *arg__2); + virtual bool notify_nocallback(QObject *arg__1, QEvent *arg__2); + void setAutoSipEnabled(const bool enabled); + static void setCursorFlashTime(int arg__1); + static void setDoubleClickInterval(int arg__1); + static void setKeyboardInputInterval(int arg__1); + static void setStartDragDistance(int l); + static void setStartDragTime(int ms); + void setStyleSheet(const QString &sheet); + static void setWheelScrollLines(int arg__1); + static int startDragDistance(); + static int startDragTime(); + QString styleSheet() const; + static QString tr(const char *s, const char *c, int n); + static int wheelScrollLines(); + typedef void (*Callback_customEvent)(void *, QEvent *event); + Callback_customEvent m_customEventCallback = nullptr; + typedef bool (*Callback_event)(void *, QEvent *arg__1); + Callback_event m_eventCallback = nullptr; + typedef bool (*Callback_eventFilter)(void *, QObject *watched, QEvent *event); + Callback_eventFilter m_eventFilterCallback = nullptr; + typedef bool (*Callback_notify)(void *, QObject *arg__1, QEvent *arg__2); + Callback_notify m_notifyCallback = nullptr; +}; +} +extern "C" { +// QApplication::aboutQt() +TestBindings_EXPORT void c_static_QApplication__aboutQt(); +// QApplication::autoSipEnabled() const +TestBindings_EXPORT bool c_QApplication__autoSipEnabled(void *thisObj); +// QApplication::beep() +TestBindings_EXPORT void c_static_QApplication__beep(); +// QApplication::closeAllWindows() +TestBindings_EXPORT void c_static_QApplication__closeAllWindows(); +// QApplication::cursorFlashTime() +TestBindings_EXPORT int c_static_QApplication__cursorFlashTime(); +// QApplication::customEvent(QEvent * event) +TestBindings_EXPORT void c_QApplication__customEvent_QEvent(void *thisObj, void *event_); +// QApplication::doubleClickInterval() +TestBindings_EXPORT int c_static_QApplication__doubleClickInterval(); +// QApplication::event(QEvent * arg__1) +TestBindings_EXPORT bool c_QApplication__event_QEvent(void *thisObj, void *arg__1_); +// QApplication::eventFilter(QObject * watched, QEvent * event) +TestBindings_EXPORT bool c_QApplication__eventFilter_QObject_QEvent(void *thisObj, void *watched_, + void *event_); +// QApplication::exec() +TestBindings_EXPORT int c_static_QApplication__exec(); +// QApplication::keyboardInputInterval() +TestBindings_EXPORT int c_static_QApplication__keyboardInputInterval(); +// QApplication::notify(QObject * arg__1, QEvent * arg__2) +TestBindings_EXPORT bool c_QApplication__notify_QObject_QEvent(void *thisObj, void *arg__1_, + void *arg__2_); +// QApplication::setAutoSipEnabled(const bool enabled) +TestBindings_EXPORT void c_QApplication__setAutoSipEnabled_bool(void *thisObj, bool enabled); +// QApplication::setCursorFlashTime(int arg__1) +TestBindings_EXPORT void c_static_QApplication__setCursorFlashTime_int(int arg__1); +// QApplication::setDoubleClickInterval(int arg__1) +TestBindings_EXPORT void c_static_QApplication__setDoubleClickInterval_int(int arg__1); +// QApplication::setKeyboardInputInterval(int arg__1) +TestBindings_EXPORT void c_static_QApplication__setKeyboardInputInterval_int(int arg__1); +// QApplication::setStartDragDistance(int l) +TestBindings_EXPORT void c_static_QApplication__setStartDragDistance_int(int l); +// QApplication::setStartDragTime(int ms) +TestBindings_EXPORT void c_static_QApplication__setStartDragTime_int(int ms); +// QApplication::setStyleSheet(const QString & sheet) +TestBindings_EXPORT void c_QApplication__setStyleSheet_QString(void *thisObj, const char *sheet_); +// QApplication::setWheelScrollLines(int arg__1) +TestBindings_EXPORT void c_static_QApplication__setWheelScrollLines_int(int arg__1); +// QApplication::startDragDistance() +TestBindings_EXPORT int c_static_QApplication__startDragDistance(); +// QApplication::startDragTime() +TestBindings_EXPORT int c_static_QApplication__startDragTime(); +// QApplication::styleSheet() const +TestBindings_EXPORT void *c_QApplication__styleSheet(void *thisObj); +// QApplication::tr(const char * s, const char * c, int n) +TestBindings_EXPORT void *c_static_QApplication__tr_char_char_int(const char *s, const char *c, + int n); +// QApplication::wheelScrollLines() +TestBindings_EXPORT int c_static_QApplication__wheelScrollLines(); +TestBindings_EXPORT void c_QApplication__destructor(void *thisObj); +TestBindings_EXPORT void c_QApplication__registerVirtualMethodCallback(void *ptr, void *callback, + int methodId); +TestBindings_EXPORT void c_QApplication_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/QByteArray_c.cpp b/tests/generated/TestBindings/dart/ffi/QByteArray_c.cpp new file mode 100644 index 0000000..c893149 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/QByteArray_c.cpp @@ -0,0 +1,761 @@ +#include "QByteArray_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +QByteArray_wrapper::QByteArray_wrapper() + : ::QByteArray() +{ +} +QByteArray_wrapper::QByteArray_wrapper(const char *arg__1, qsizetype size) + : ::QByteArray(arg__1, size) +{ +} +QByteArray &QByteArray_wrapper::append(const QByteArray &a) +{ + return ::QByteArray::append(a); +} +QByteArray &QByteArray_wrapper::append(const char *s) +{ + return ::QByteArray::append(s); +} +QByteArray &QByteArray_wrapper::append(const char *s, qsizetype len) +{ + return ::QByteArray::append(s, len); +} +char QByteArray_wrapper::at(qsizetype i) const +{ + return ::QByteArray::at(i); +} +qsizetype QByteArray_wrapper::capacity() const +{ + return ::QByteArray::capacity(); +} +const char *QByteArray_wrapper::cbegin() const +{ + return ::QByteArray::cbegin(); +} +const char *QByteArray_wrapper::cend() const +{ + return ::QByteArray::cend(); +} +void QByteArray_wrapper::chop(qsizetype n) +{ + ::QByteArray::chop(n); +} +QByteArray QByteArray_wrapper::chopped(qsizetype len) const +{ + return ::QByteArray::chopped(len); +} +void QByteArray_wrapper::clear() +{ + ::QByteArray::clear(); +} +const char *QByteArray_wrapper::constBegin() const +{ + return ::QByteArray::constBegin(); +} +const char *QByteArray_wrapper::constData() const +{ + return ::QByteArray::constData(); +} +const char *QByteArray_wrapper::constEnd() const +{ + return ::QByteArray::constEnd(); +} +qsizetype QByteArray_wrapper::count() const +{ + return ::QByteArray::count(); +} +void QByteArray_wrapper::detach() +{ + ::QByteArray::detach(); +} +QByteArray QByteArray_wrapper::first(qsizetype n) const +{ + return ::QByteArray::first(n); +} +QByteArray QByteArray_wrapper::fromBase64(const QByteArray &base64) +{ + return ::QByteArray::fromBase64(base64); +} +QByteArray QByteArray_wrapper::fromHex(const QByteArray &hexEncoded) +{ + return ::QByteArray::fromHex(hexEncoded); +} +QByteArray QByteArray_wrapper::fromRawData(const char *data, qsizetype size) +{ + return ::QByteArray::fromRawData(data, size); +} +QByteArray &QByteArray_wrapper::insert(qsizetype i, const QByteArray &data) +{ + return ::QByteArray::insert(i, data); +} +QByteArray &QByteArray_wrapper::insert(qsizetype i, const char *s) +{ + return ::QByteArray::insert(i, s); +} +QByteArray &QByteArray_wrapper::insert(qsizetype i, const char *s, qsizetype len) +{ + return ::QByteArray::insert(i, s, len); +} +bool QByteArray_wrapper::isDetached() const +{ + return ::QByteArray::isDetached(); +} +bool QByteArray_wrapper::isEmpty() const +{ + return ::QByteArray::isEmpty(); +} +bool QByteArray_wrapper::isLower() const +{ + return ::QByteArray::isLower(); +} +bool QByteArray_wrapper::isNull() const +{ + return ::QByteArray::isNull(); +} +bool QByteArray_wrapper::isSharedWith(const QByteArray &other) const +{ + return ::QByteArray::isSharedWith(other); +} +bool QByteArray_wrapper::isUpper() const +{ + return ::QByteArray::isUpper(); +} +bool QByteArray_wrapper::isValidUtf8() const +{ + return ::QByteArray::isValidUtf8(); +} +QByteArray QByteArray_wrapper::last(qsizetype n) const +{ + return ::QByteArray::last(n); +} +QByteArray QByteArray_wrapper::left(qsizetype len) const +{ + return ::QByteArray::left(len); +} +qsizetype QByteArray_wrapper::length() const +{ + return ::QByteArray::length(); +} +QByteArray QByteArray_wrapper::mid(qsizetype index, qsizetype len) const +{ + return ::QByteArray::mid(index, len); +} +QByteArray QByteArray_wrapper::number(int arg__1, int base) +{ + return ::QByteArray::number(arg__1, base); +} +QByteArray QByteArray_wrapper::number(long arg__1, int base) +{ + return ::QByteArray::number(arg__1, base); +} +QByteArray QByteArray_wrapper::number(qint64 arg__1, int base) +{ + return ::QByteArray::number(arg__1, base); +} +QByteArray &QByteArray_wrapper::prepend(const QByteArray &a) +{ + return ::QByteArray::prepend(a); +} +QByteArray &QByteArray_wrapper::prepend(const char *s) +{ + return ::QByteArray::prepend(s); +} +QByteArray &QByteArray_wrapper::prepend(const char *s, qsizetype len) +{ + return ::QByteArray::prepend(s, len); +} +void QByteArray_wrapper::push_back(const QByteArray &a) +{ + ::QByteArray::push_back(a); +} +void QByteArray_wrapper::push_back(const char *s) +{ + ::QByteArray::push_back(s); +} +void QByteArray_wrapper::push_front(const QByteArray &a) +{ + ::QByteArray::push_front(a); +} +void QByteArray_wrapper::push_front(const char *c) +{ + ::QByteArray::push_front(c); +} +QByteArray &QByteArray_wrapper::remove(qsizetype index, qsizetype len) +{ + return ::QByteArray::remove(index, len); +} +QByteArray QByteArray_wrapper::repeated(qsizetype times) const +{ + return ::QByteArray::repeated(times); +} +QByteArray &QByteArray_wrapper::replace(const char *before, qsizetype bsize, const char *after, + qsizetype asize) +{ + return ::QByteArray::replace(before, bsize, after, asize); +} +QByteArray &QByteArray_wrapper::replace(qsizetype index, qsizetype len, const char *s, + qsizetype alen) +{ + return ::QByteArray::replace(index, len, s, alen); +} +void QByteArray_wrapper::reserve(qsizetype size) +{ + ::QByteArray::reserve(size); +} +void QByteArray_wrapper::resize(qsizetype size) +{ + ::QByteArray::resize(size); +} +QByteArray QByteArray_wrapper::right(qsizetype len) const +{ + return ::QByteArray::right(len); +} +QByteArray &QByteArray_wrapper::setNum(int arg__1, int base) +{ + return ::QByteArray::setNum(arg__1, base); +} +QByteArray &QByteArray_wrapper::setNum(long arg__1, int base) +{ + return ::QByteArray::setNum(arg__1, base); +} +QByteArray &QByteArray_wrapper::setNum(qint64 arg__1, int base) +{ + return ::QByteArray::setNum(arg__1, base); +} +QByteArray &QByteArray_wrapper::setNum(short arg__1, int base) +{ + return ::QByteArray::setNum(arg__1, base); +} +QByteArray &QByteArray_wrapper::setRawData(const char *a, qsizetype n) +{ + return ::QByteArray::setRawData(a, n); +} +void QByteArray_wrapper::shrink_to_fit() +{ + ::QByteArray::shrink_to_fit(); +} +QByteArray QByteArray_wrapper::simplified() +{ + return ::QByteArray::simplified(); +} +qsizetype QByteArray_wrapper::size() const +{ + return ::QByteArray::size(); +} +QByteArray QByteArray_wrapper::sliced(qsizetype pos) const +{ + return ::QByteArray::sliced(pos); +} +QByteArray QByteArray_wrapper::sliced(qsizetype pos, qsizetype n) const +{ + return ::QByteArray::sliced(pos, n); +} +void QByteArray_wrapper::squeeze() +{ + ::QByteArray::squeeze(); +} +QByteArray QByteArray_wrapper::toBase64() const +{ + return ::QByteArray::toBase64(); +} +QByteArray QByteArray_wrapper::toLower() +{ + return ::QByteArray::toLower(); +} +QByteArray QByteArray_wrapper::toUpper() +{ + return ::QByteArray::toUpper(); +} +QByteArray QByteArray_wrapper::trimmed() +{ + return ::QByteArray::trimmed(); +} +void QByteArray_wrapper::truncate(qsizetype pos) +{ + ::QByteArray::truncate(pos); +} +QByteArray_wrapper::~QByteArray_wrapper() +{ +} + +} +static QByteArray *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::QByteArray_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_QByteArray_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} +void *c_QByteArray__constructor() +{ + auto ptr = new TestBindings_wrappersNS::QByteArray_wrapper(); + return reinterpret_cast(ptr); +} +void *c_QByteArray__constructor_char_qsizetype(const char *arg__1, qsizetype size) +{ + auto ptr = new TestBindings_wrappersNS::QByteArray_wrapper(arg__1, size); + return reinterpret_cast(ptr); +} +// append(const QByteArray & a) +void *c_QByteArray__append_QByteArray(void *thisObj, void *a_) +{ + assert(a_); + auto &a = *reinterpret_cast(a_); + const auto &result = &fromPtr(thisObj)->append(a); + return result; +} +// append(const char * s) +void *c_QByteArray__append_char(void *thisObj, const char *s) +{ + const auto &result = &fromPtr(thisObj)->append(s); + free(( char * )s); + return result; +} +// append(const char * s, qsizetype len) +void *c_QByteArray__append_char_qsizetype(void *thisObj, const char *s, qsizetype len) +{ + const auto &result = &fromPtr(thisObj)->append(s, len); + free(( char * )s); + return result; +} +// at(qsizetype i) const +char c_QByteArray__at_qsizetype(void *thisObj, qsizetype i) +{ + const auto &result = fromPtr(thisObj)->at(i); + return result; +} +// capacity() const +qsizetype c_QByteArray__capacity(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->capacity(); + return result; +} +// cbegin() const +const char *c_QByteArray__cbegin(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->cbegin(); + return result; +} +// cend() const +const char *c_QByteArray__cend(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->cend(); + return result; +} +// chop(qsizetype n) +void c_QByteArray__chop_qsizetype(void *thisObj, qsizetype n) +{ + fromPtr(thisObj)->chop(n); +} +// chopped(qsizetype len) const +void *c_QByteArray__chopped_qsizetype(void *thisObj, qsizetype len) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->chopped(len) }; + return result; +} +// clear() +void c_QByteArray__clear(void *thisObj) +{ + fromPtr(thisObj)->clear(); +} +// constBegin() const +const char *c_QByteArray__constBegin(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->constBegin(); + return result; +} +// constData() const +const char *c_QByteArray__constData(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->constData(); + return result; +} +// constEnd() const +const char *c_QByteArray__constEnd(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->constEnd(); + return result; +} +// count() const +qsizetype c_QByteArray__count(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->count(); + return result; +} +// detach() +void c_QByteArray__detach(void *thisObj) +{ + fromPtr(thisObj)->detach(); +} +// first(qsizetype n) const +void *c_QByteArray__first_qsizetype(void *thisObj, qsizetype n) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->first(n) }; + return result; +} +// fromBase64(const QByteArray & base64) +void *c_static_QByteArray__fromBase64_QByteArray(void *base64_) +{ + assert(base64_); + auto &base64 = *reinterpret_cast(base64_); + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QByteArray_wrapper::fromBase64(base64) + }; + return result; +} +// fromHex(const QByteArray & hexEncoded) +void *c_static_QByteArray__fromHex_QByteArray(void *hexEncoded_) +{ + assert(hexEncoded_); + auto &hexEncoded = *reinterpret_cast(hexEncoded_); + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QByteArray_wrapper::fromHex(hexEncoded) + }; + return result; +} +// fromRawData(const char * data, qsizetype size) +void *c_static_QByteArray__fromRawData_char_qsizetype(const char *data, qsizetype size) +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QByteArray_wrapper::fromRawData(data, size) + }; + free(( char * )data); + return result; +} +// insert(qsizetype i, const QByteArray & data) +void *c_QByteArray__insert_qsizetype_QByteArray(void *thisObj, qsizetype i, void *data_) +{ + assert(data_); + auto &data = *reinterpret_cast(data_); + const auto &result = &fromPtr(thisObj)->insert(i, data); + return result; +} +// insert(qsizetype i, const char * s) +void *c_QByteArray__insert_qsizetype_char(void *thisObj, qsizetype i, const char *s) +{ + const auto &result = &fromPtr(thisObj)->insert(i, s); + free(( char * )s); + return result; +} +// insert(qsizetype i, const char * s, qsizetype len) +void *c_QByteArray__insert_qsizetype_char_qsizetype(void *thisObj, qsizetype i, const char *s, + qsizetype len) +{ + const auto &result = &fromPtr(thisObj)->insert(i, s, len); + free(( char * )s); + return result; +} +// isDetached() const +bool c_QByteArray__isDetached(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isDetached(); + return result; +} +// isEmpty() const +bool c_QByteArray__isEmpty(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isEmpty(); + return result; +} +// isLower() const +bool c_QByteArray__isLower(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isLower(); + return result; +} +// isNull() const +bool c_QByteArray__isNull(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isNull(); + return result; +} +// isSharedWith(const QByteArray & other) const +bool c_QByteArray__isSharedWith_QByteArray(void *thisObj, void *other_) +{ + assert(other_); + auto &other = *reinterpret_cast(other_); + const auto &result = fromPtr(thisObj)->isSharedWith(other); + return result; +} +// isUpper() const +bool c_QByteArray__isUpper(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isUpper(); + return result; +} +// isValidUtf8() const +bool c_QByteArray__isValidUtf8(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isValidUtf8(); + return result; +} +// last(qsizetype n) const +void *c_QByteArray__last_qsizetype(void *thisObj, qsizetype n) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->last(n) }; + return result; +} +// left(qsizetype len) const +void *c_QByteArray__left_qsizetype(void *thisObj, qsizetype len) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->left(len) }; + return result; +} +// length() const +qsizetype c_QByteArray__length(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->length(); + return result; +} +// mid(qsizetype index, qsizetype len) const +void *c_QByteArray__mid_qsizetype_qsizetype(void *thisObj, qsizetype index, qsizetype len) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->mid(index, len) }; + return result; +} +// number(int arg__1, int base) +void *c_static_QByteArray__number_int_int(int arg__1, int base) +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QByteArray_wrapper::number(arg__1, base) + }; + return result; +} +// number(long arg__1, int base) +void *c_static_QByteArray__number_long_int(long arg__1, int base) +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QByteArray_wrapper::number(arg__1, base) + }; + return result; +} +// number(qint64 arg__1, int base) +void *c_static_QByteArray__number_qint64_int(qint64 arg__1, int base) +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QByteArray_wrapper::number(arg__1, base) + }; + return result; +} +// prepend(const QByteArray & a) +void *c_QByteArray__prepend_QByteArray(void *thisObj, void *a_) +{ + assert(a_); + auto &a = *reinterpret_cast(a_); + const auto &result = &fromPtr(thisObj)->prepend(a); + return result; +} +// prepend(const char * s) +void *c_QByteArray__prepend_char(void *thisObj, const char *s) +{ + const auto &result = &fromPtr(thisObj)->prepend(s); + free(( char * )s); + return result; +} +// prepend(const char * s, qsizetype len) +void *c_QByteArray__prepend_char_qsizetype(void *thisObj, const char *s, qsizetype len) +{ + const auto &result = &fromPtr(thisObj)->prepend(s, len); + free(( char * )s); + return result; +} +// push_back(const QByteArray & a) +void c_QByteArray__push_back_QByteArray(void *thisObj, void *a_) +{ + assert(a_); + auto &a = *reinterpret_cast(a_); + fromPtr(thisObj)->push_back(a); +} +// push_back(const char * s) +void c_QByteArray__push_back_char(void *thisObj, const char *s) +{ + fromPtr(thisObj)->push_back(s); + free(( char * )s); +} +// push_front(const QByteArray & a) +void c_QByteArray__push_front_QByteArray(void *thisObj, void *a_) +{ + assert(a_); + auto &a = *reinterpret_cast(a_); + fromPtr(thisObj)->push_front(a); +} +// push_front(const char * c) +void c_QByteArray__push_front_char(void *thisObj, const char *c) +{ + fromPtr(thisObj)->push_front(c); + free(( char * )c); +} +// remove(qsizetype index, qsizetype len) +void *c_QByteArray__remove_qsizetype_qsizetype(void *thisObj, qsizetype index, qsizetype len) +{ + const auto &result = &fromPtr(thisObj)->remove(index, len); + return result; +} +// repeated(qsizetype times) const +void *c_QByteArray__repeated_qsizetype(void *thisObj, qsizetype times) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->repeated(times) }; + return result; +} +// replace(const char * before, qsizetype bsize, const char * after, qsizetype asize) +void *c_QByteArray__replace_char_qsizetype_char_qsizetype(void *thisObj, const char *before, + qsizetype bsize, const char *after, + qsizetype asize) +{ + const auto &result = &fromPtr(thisObj)->replace(before, bsize, after, asize); + free(( char * )before); + free(( char * )after); + return result; +} +// replace(qsizetype index, qsizetype len, const char * s, qsizetype alen) +void *c_QByteArray__replace_qsizetype_qsizetype_char_qsizetype(void *thisObj, qsizetype index, + qsizetype len, const char *s, + qsizetype alen) +{ + const auto &result = &fromPtr(thisObj)->replace(index, len, s, alen); + free(( char * )s); + return result; +} +// reserve(qsizetype size) +void c_QByteArray__reserve_qsizetype(void *thisObj, qsizetype size) +{ + fromPtr(thisObj)->reserve(size); +} +// resize(qsizetype size) +void c_QByteArray__resize_qsizetype(void *thisObj, qsizetype size) +{ + fromPtr(thisObj)->resize(size); +} +// right(qsizetype len) const +void *c_QByteArray__right_qsizetype(void *thisObj, qsizetype len) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->right(len) }; + return result; +} +// setNum(int arg__1, int base) +void *c_QByteArray__setNum_int_int(void *thisObj, int arg__1, int base) +{ + const auto &result = &fromPtr(thisObj)->setNum(arg__1, base); + return result; +} +// setNum(long arg__1, int base) +void *c_QByteArray__setNum_long_int(void *thisObj, long arg__1, int base) +{ + const auto &result = &fromPtr(thisObj)->setNum(arg__1, base); + return result; +} +// setNum(qint64 arg__1, int base) +void *c_QByteArray__setNum_qint64_int(void *thisObj, qint64 arg__1, int base) +{ + const auto &result = &fromPtr(thisObj)->setNum(arg__1, base); + return result; +} +// setNum(short arg__1, int base) +void *c_QByteArray__setNum_short_int(void *thisObj, short arg__1, int base) +{ + const auto &result = &fromPtr(thisObj)->setNum(arg__1, base); + return result; +} +// setRawData(const char * a, qsizetype n) +void *c_QByteArray__setRawData_char_qsizetype(void *thisObj, const char *a, qsizetype n) +{ + const auto &result = &fromPtr(thisObj)->setRawData(a, n); + free(( char * )a); + return result; +} +// shrink_to_fit() +void c_QByteArray__shrink_to_fit(void *thisObj) +{ + fromPtr(thisObj)->shrink_to_fit(); +} +// simplified() +void *c_QByteArray__simplified(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->simplified() }; + return result; +} +// size() const +qsizetype c_QByteArray__size(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->size(); + return result; +} +// sliced(qsizetype pos) const +void *c_QByteArray__sliced_qsizetype(void *thisObj, qsizetype pos) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->sliced(pos) }; + return result; +} +// sliced(qsizetype pos, qsizetype n) const +void *c_QByteArray__sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype n) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->sliced(pos, n) }; + return result; +} +// squeeze() +void c_QByteArray__squeeze(void *thisObj) +{ + fromPtr(thisObj)->squeeze(); +} +// toBase64() const +void *c_QByteArray__toBase64(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->toBase64() }; + return result; +} +// toLower() +void *c_QByteArray__toLower(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->toLower() }; + return result; +} +// toUpper() +void *c_QByteArray__toUpper(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->toUpper() }; + return result; +} +// trimmed() +void *c_QByteArray__trimmed(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->trimmed() }; + return result; +} +// truncate(qsizetype pos) +void c_QByteArray__truncate_qsizetype(void *thisObj, qsizetype pos) +{ + fromPtr(thisObj)->truncate(pos); +} +void c_QByteArray__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} diff --git a/tests/generated/TestBindings/dart/ffi/QByteArray_c.h b/tests/generated/TestBindings/dart/ffi/QByteArray_c.h new file mode 100644 index 0000000..3c93249 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/QByteArray_c.h @@ -0,0 +1,249 @@ +#include "TestBindings_exports.h" +#include +#include +#include + +namespace TestBindings_wrappersNS { +class QByteArray_wrapper : public ::QByteArray +{ +public: + ~QByteArray_wrapper(); + QByteArray_wrapper(); + QByteArray_wrapper(const char *arg__1, qsizetype size = -1); + QByteArray &append(const QByteArray &a); + QByteArray &append(const char *s); + QByteArray &append(const char *s, qsizetype len); + char at(qsizetype i) const; + char back() const; + const char *begin() const; + qsizetype capacity() const; + const char *cbegin() const; + const char *cend() const; + void chop(qsizetype n); + QByteArray chopped(qsizetype len) const; + void clear(); + const char *constBegin() const; + const char *constData() const; + const char *constEnd() const; + qsizetype count() const; + const char *data() const; + void detach(); + const char *end() const; + QByteArray first(qsizetype n) const; + static QByteArray fromBase64(const QByteArray &base64); + static QByteArray fromHex(const QByteArray &hexEncoded); + static QByteArray fromRawData(const char *data, qsizetype size); + char front() const; + QByteArray &insert(qsizetype i, const QByteArray &data); + QByteArray &insert(qsizetype i, const char *s); + QByteArray &insert(qsizetype i, const char *s, qsizetype len); + bool isDetached() const; + bool isEmpty() const; + bool isLower() const; + bool isNull() const; + bool isSharedWith(const QByteArray &other) const; + bool isUpper() const; + bool isValidUtf8() const; + QByteArray last(qsizetype n) const; + QByteArray left(qsizetype len) const; + qsizetype length() const; + QByteArray mid(qsizetype index, qsizetype len = -1) const; + static QByteArray number(int arg__1, int base = 10); + static QByteArray number(long arg__1, int base = 10); + static QByteArray number(qint64 arg__1, int base = 10); + QByteArray &prepend(const QByteArray &a); + QByteArray &prepend(const char *s); + QByteArray &prepend(const char *s, qsizetype len); + void push_back(const QByteArray &a); + void push_back(const char *s); + void push_front(const QByteArray &a); + void push_front(const char *c); + QByteArray &remove(qsizetype index, qsizetype len); + QByteArray repeated(qsizetype times) const; + QByteArray &replace(const char *before, qsizetype bsize, const char *after, qsizetype asize); + QByteArray &replace(qsizetype index, qsizetype len, const char *s, qsizetype alen); + void reserve(qsizetype size); + void resize(qsizetype size); + QByteArray right(qsizetype len) const; + QByteArray &setNum(int arg__1, int base = 10); + QByteArray &setNum(long arg__1, int base = 10); + QByteArray &setNum(qint64 arg__1, int base = 10); + QByteArray &setNum(short arg__1, int base = 10); + QByteArray &setRawData(const char *a, qsizetype n); + void shrink_to_fit(); + QByteArray simplified(); + qsizetype size() const; + QByteArray sliced(qsizetype pos) const; + QByteArray sliced(qsizetype pos, qsizetype n) const; + void squeeze(); + QByteArray toBase64() const; + QByteArray toLower(); + QByteArray toUpper(); + QByteArray trimmed(); + void truncate(qsizetype pos); +}; +} +extern "C" { +// QByteArray::QByteArray() +TestBindings_EXPORT void *c_QByteArray__constructor(); +// QByteArray::QByteArray(const char * arg__1, qsizetype size) +TestBindings_EXPORT void *c_QByteArray__constructor_char_qsizetype(const char *arg__1, + qsizetype size); +// QByteArray::append(const QByteArray & a) +TestBindings_EXPORT void *c_QByteArray__append_QByteArray(void *thisObj, void *a_); +// QByteArray::append(const char * s) +TestBindings_EXPORT void *c_QByteArray__append_char(void *thisObj, const char *s); +// QByteArray::append(const char * s, qsizetype len) +TestBindings_EXPORT void *c_QByteArray__append_char_qsizetype(void *thisObj, const char *s, + qsizetype len); +// QByteArray::at(qsizetype i) const +TestBindings_EXPORT char c_QByteArray__at_qsizetype(void *thisObj, qsizetype i); +// QByteArray::back() const +TestBindings_EXPORT char c_QByteArray__back(void *thisObj); +// QByteArray::begin() const +TestBindings_EXPORT const char *c_QByteArray__begin(void *thisObj); +// QByteArray::capacity() const +TestBindings_EXPORT qsizetype c_QByteArray__capacity(void *thisObj); +// QByteArray::cbegin() const +TestBindings_EXPORT const char *c_QByteArray__cbegin(void *thisObj); +// QByteArray::cend() const +TestBindings_EXPORT const char *c_QByteArray__cend(void *thisObj); +// QByteArray::chop(qsizetype n) +TestBindings_EXPORT void c_QByteArray__chop_qsizetype(void *thisObj, qsizetype n); +// QByteArray::chopped(qsizetype len) const +TestBindings_EXPORT void *c_QByteArray__chopped_qsizetype(void *thisObj, qsizetype len); +// QByteArray::clear() +TestBindings_EXPORT void c_QByteArray__clear(void *thisObj); +// QByteArray::constBegin() const +TestBindings_EXPORT const char *c_QByteArray__constBegin(void *thisObj); +// QByteArray::constData() const +TestBindings_EXPORT const char *c_QByteArray__constData(void *thisObj); +// QByteArray::constEnd() const +TestBindings_EXPORT const char *c_QByteArray__constEnd(void *thisObj); +// QByteArray::count() const +TestBindings_EXPORT qsizetype c_QByteArray__count(void *thisObj); +// QByteArray::data() const +TestBindings_EXPORT const char *c_QByteArray__data(void *thisObj); +// QByteArray::detach() +TestBindings_EXPORT void c_QByteArray__detach(void *thisObj); +// QByteArray::end() const +TestBindings_EXPORT const char *c_QByteArray__end(void *thisObj); +// QByteArray::first(qsizetype n) const +TestBindings_EXPORT void *c_QByteArray__first_qsizetype(void *thisObj, qsizetype n); +// QByteArray::fromBase64(const QByteArray & base64) +TestBindings_EXPORT void *c_static_QByteArray__fromBase64_QByteArray(void *base64_); +// QByteArray::fromHex(const QByteArray & hexEncoded) +TestBindings_EXPORT void *c_static_QByteArray__fromHex_QByteArray(void *hexEncoded_); +// QByteArray::fromRawData(const char * data, qsizetype size) +TestBindings_EXPORT void *c_static_QByteArray__fromRawData_char_qsizetype(const char *data, + qsizetype size); +// QByteArray::front() const +TestBindings_EXPORT char c_QByteArray__front(void *thisObj); +// QByteArray::insert(qsizetype i, const QByteArray & data) +TestBindings_EXPORT void *c_QByteArray__insert_qsizetype_QByteArray(void *thisObj, qsizetype i, + void *data_); +// QByteArray::insert(qsizetype i, const char * s) +TestBindings_EXPORT void *c_QByteArray__insert_qsizetype_char(void *thisObj, qsizetype i, + const char *s); +// QByteArray::insert(qsizetype i, const char * s, qsizetype len) +TestBindings_EXPORT void *c_QByteArray__insert_qsizetype_char_qsizetype(void *thisObj, qsizetype i, + const char *s, + qsizetype len); +// QByteArray::isDetached() const +TestBindings_EXPORT bool c_QByteArray__isDetached(void *thisObj); +// QByteArray::isEmpty() const +TestBindings_EXPORT bool c_QByteArray__isEmpty(void *thisObj); +// QByteArray::isLower() const +TestBindings_EXPORT bool c_QByteArray__isLower(void *thisObj); +// QByteArray::isNull() const +TestBindings_EXPORT bool c_QByteArray__isNull(void *thisObj); +// QByteArray::isSharedWith(const QByteArray & other) const +TestBindings_EXPORT bool c_QByteArray__isSharedWith_QByteArray(void *thisObj, void *other_); +// QByteArray::isUpper() const +TestBindings_EXPORT bool c_QByteArray__isUpper(void *thisObj); +// QByteArray::isValidUtf8() const +TestBindings_EXPORT bool c_QByteArray__isValidUtf8(void *thisObj); +// QByteArray::last(qsizetype n) const +TestBindings_EXPORT void *c_QByteArray__last_qsizetype(void *thisObj, qsizetype n); +// QByteArray::left(qsizetype len) const +TestBindings_EXPORT void *c_QByteArray__left_qsizetype(void *thisObj, qsizetype len); +// QByteArray::length() const +TestBindings_EXPORT qsizetype c_QByteArray__length(void *thisObj); +// QByteArray::mid(qsizetype index, qsizetype len) const +TestBindings_EXPORT void *c_QByteArray__mid_qsizetype_qsizetype(void *thisObj, qsizetype index, + qsizetype len); +// QByteArray::number(int arg__1, int base) +TestBindings_EXPORT void *c_static_QByteArray__number_int_int(int arg__1, int base); +// QByteArray::number(long arg__1, int base) +TestBindings_EXPORT void *c_static_QByteArray__number_long_int(long arg__1, int base); +// QByteArray::number(qint64 arg__1, int base) +TestBindings_EXPORT void *c_static_QByteArray__number_qint64_int(qint64 arg__1, int base); +// QByteArray::prepend(const QByteArray & a) +TestBindings_EXPORT void *c_QByteArray__prepend_QByteArray(void *thisObj, void *a_); +// QByteArray::prepend(const char * s) +TestBindings_EXPORT void *c_QByteArray__prepend_char(void *thisObj, const char *s); +// QByteArray::prepend(const char * s, qsizetype len) +TestBindings_EXPORT void *c_QByteArray__prepend_char_qsizetype(void *thisObj, const char *s, + qsizetype len); +// QByteArray::push_back(const QByteArray & a) +TestBindings_EXPORT void c_QByteArray__push_back_QByteArray(void *thisObj, void *a_); +// QByteArray::push_back(const char * s) +TestBindings_EXPORT void c_QByteArray__push_back_char(void *thisObj, const char *s); +// QByteArray::push_front(const QByteArray & a) +TestBindings_EXPORT void c_QByteArray__push_front_QByteArray(void *thisObj, void *a_); +// QByteArray::push_front(const char * c) +TestBindings_EXPORT void c_QByteArray__push_front_char(void *thisObj, const char *c); +// QByteArray::remove(qsizetype index, qsizetype len) +TestBindings_EXPORT void *c_QByteArray__remove_qsizetype_qsizetype(void *thisObj, qsizetype index, + qsizetype len); +// QByteArray::repeated(qsizetype times) const +TestBindings_EXPORT void *c_QByteArray__repeated_qsizetype(void *thisObj, qsizetype times); +// QByteArray::replace(const char * before, qsizetype bsize, const char * after, qsizetype asize) +TestBindings_EXPORT void *c_QByteArray__replace_char_qsizetype_char_qsizetype( + void *thisObj, const char *before, qsizetype bsize, const char *after, qsizetype asize); +// QByteArray::replace(qsizetype index, qsizetype len, const char * s, qsizetype alen) +TestBindings_EXPORT void *c_QByteArray__replace_qsizetype_qsizetype_char_qsizetype( + void *thisObj, qsizetype index, qsizetype len, const char *s, qsizetype alen); +// QByteArray::reserve(qsizetype size) +TestBindings_EXPORT void c_QByteArray__reserve_qsizetype(void *thisObj, qsizetype size); +// QByteArray::resize(qsizetype size) +TestBindings_EXPORT void c_QByteArray__resize_qsizetype(void *thisObj, qsizetype size); +// QByteArray::right(qsizetype len) const +TestBindings_EXPORT void *c_QByteArray__right_qsizetype(void *thisObj, qsizetype len); +// QByteArray::setNum(int arg__1, int base) +TestBindings_EXPORT void *c_QByteArray__setNum_int_int(void *thisObj, int arg__1, int base); +// QByteArray::setNum(long arg__1, int base) +TestBindings_EXPORT void *c_QByteArray__setNum_long_int(void *thisObj, long arg__1, int base); +// QByteArray::setNum(qint64 arg__1, int base) +TestBindings_EXPORT void *c_QByteArray__setNum_qint64_int(void *thisObj, qint64 arg__1, int base); +// QByteArray::setNum(short arg__1, int base) +TestBindings_EXPORT void *c_QByteArray__setNum_short_int(void *thisObj, short arg__1, int base); +// QByteArray::setRawData(const char * a, qsizetype n) +TestBindings_EXPORT void *c_QByteArray__setRawData_char_qsizetype(void *thisObj, const char *a, + qsizetype n); +// QByteArray::shrink_to_fit() +TestBindings_EXPORT void c_QByteArray__shrink_to_fit(void *thisObj); +// QByteArray::simplified() +TestBindings_EXPORT void *c_QByteArray__simplified(void *thisObj); +// QByteArray::size() const +TestBindings_EXPORT qsizetype c_QByteArray__size(void *thisObj); +// QByteArray::sliced(qsizetype pos) const +TestBindings_EXPORT void *c_QByteArray__sliced_qsizetype(void *thisObj, qsizetype pos); +// QByteArray::sliced(qsizetype pos, qsizetype n) const +TestBindings_EXPORT void *c_QByteArray__sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, + qsizetype n); +// QByteArray::squeeze() +TestBindings_EXPORT void c_QByteArray__squeeze(void *thisObj); +// QByteArray::toBase64() const +TestBindings_EXPORT void *c_QByteArray__toBase64(void *thisObj); +// QByteArray::toLower() +TestBindings_EXPORT void *c_QByteArray__toLower(void *thisObj); +// QByteArray::toUpper() +TestBindings_EXPORT void *c_QByteArray__toUpper(void *thisObj); +// QByteArray::trimmed() +TestBindings_EXPORT void *c_QByteArray__trimmed(void *thisObj); +// QByteArray::truncate(qsizetype pos) +TestBindings_EXPORT void c_QByteArray__truncate_qsizetype(void *thisObj, qsizetype pos); +TestBindings_EXPORT void c_QByteArray__destructor(void *thisObj); +TestBindings_EXPORT void c_QByteArray_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/QColor_c.cpp b/tests/generated/TestBindings/dart/ffi/QColor_c.cpp new file mode 100644 index 0000000..cf4ecb7 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/QColor_c.cpp @@ -0,0 +1,768 @@ +#include "QColor_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +QColor_wrapper::QColor_wrapper() + : ::QColor() +{ +} +QColor_wrapper::QColor_wrapper(const QString &name) + : ::QColor(name) +{ +} +QColor_wrapper::QColor_wrapper(const char *aname) + : ::QColor(aname) +{ +} +QColor_wrapper::QColor_wrapper(int r, int g, int b, int a) + : ::QColor(r, g, b, a) +{ +} +int QColor_wrapper::alpha() const +{ + return ::QColor::alpha(); +} +float QColor_wrapper::alphaF() const +{ + return ::QColor::alphaF(); +} +int QColor_wrapper::black() const +{ + return ::QColor::black(); +} +float QColor_wrapper::blackF() const +{ + return ::QColor::blackF(); +} +int QColor_wrapper::blue() const +{ + return ::QColor::blue(); +} +float QColor_wrapper::blueF() const +{ + return ::QColor::blueF(); +} +QList QColor_wrapper::colorNames() +{ + return ::QColor::colorNames(); +} +int QColor_wrapper::cyan() const +{ + return ::QColor::cyan(); +} +float QColor_wrapper::cyanF() const +{ + return ::QColor::cyanF(); +} +QColor QColor_wrapper::darker(int f) const +{ + return ::QColor::darker(f); +} +QColor QColor_wrapper::fromCmyk(int c, int m, int y, int k, int a) +{ + return ::QColor::fromCmyk(c, m, y, k, a); +} +QColor QColor_wrapper::fromCmykF(float c, float m, float y, float k, float a) +{ + return ::QColor::fromCmykF(c, m, y, k, a); +} +QColor QColor_wrapper::fromHsl(int h, int s, int l, int a) +{ + return ::QColor::fromHsl(h, s, l, a); +} +QColor QColor_wrapper::fromHslF(float h, float s, float l, float a) +{ + return ::QColor::fromHslF(h, s, l, a); +} +QColor QColor_wrapper::fromHsv(int h, int s, int v, int a) +{ + return ::QColor::fromHsv(h, s, v, a); +} +QColor QColor_wrapper::fromHsvF(float h, float s, float v, float a) +{ + return ::QColor::fromHsvF(h, s, v, a); +} +QColor QColor_wrapper::fromRgb(int r, int g, int b, int a) +{ + return ::QColor::fromRgb(r, g, b, a); +} +QColor QColor_wrapper::fromRgbF(float r, float g, float b, float a) +{ + return ::QColor::fromRgbF(r, g, b, a); +} +int QColor_wrapper::green() const +{ + return ::QColor::green(); +} +float QColor_wrapper::greenF() const +{ + return ::QColor::greenF(); +} +int QColor_wrapper::hslHue() const +{ + return ::QColor::hslHue(); +} +float QColor_wrapper::hslHueF() const +{ + return ::QColor::hslHueF(); +} +int QColor_wrapper::hslSaturation() const +{ + return ::QColor::hslSaturation(); +} +float QColor_wrapper::hslSaturationF() const +{ + return ::QColor::hslSaturationF(); +} +int QColor_wrapper::hsvHue() const +{ + return ::QColor::hsvHue(); +} +float QColor_wrapper::hsvHueF() const +{ + return ::QColor::hsvHueF(); +} +int QColor_wrapper::hsvSaturation() const +{ + return ::QColor::hsvSaturation(); +} +float QColor_wrapper::hsvSaturationF() const +{ + return ::QColor::hsvSaturationF(); +} +int QColor_wrapper::hue() const +{ + return ::QColor::hue(); +} +float QColor_wrapper::hueF() const +{ + return ::QColor::hueF(); +} +bool QColor_wrapper::isValid() const +{ + return ::QColor::isValid(); +} +bool QColor_wrapper::isValidColor(const QString &name) +{ + return ::QColor::isValidColor(name); +} +QColor QColor_wrapper::lighter(int f) const +{ + return ::QColor::lighter(f); +} +int QColor_wrapper::lightness() const +{ + return ::QColor::lightness(); +} +float QColor_wrapper::lightnessF() const +{ + return ::QColor::lightnessF(); +} +int QColor_wrapper::magenta() const +{ + return ::QColor::magenta(); +} +float QColor_wrapper::magentaF() const +{ + return ::QColor::magentaF(); +} +QString QColor_wrapper::name() const +{ + return ::QColor::name(); +} +int QColor_wrapper::red() const +{ + return ::QColor::red(); +} +float QColor_wrapper::redF() const +{ + return ::QColor::redF(); +} +int QColor_wrapper::saturation() const +{ + return ::QColor::saturation(); +} +float QColor_wrapper::saturationF() const +{ + return ::QColor::saturationF(); +} +void QColor_wrapper::setAlpha(int alpha) +{ + ::QColor::setAlpha(alpha); +} +void QColor_wrapper::setAlphaF(float alpha) +{ + ::QColor::setAlphaF(alpha); +} +void QColor_wrapper::setBlue(int blue) +{ + ::QColor::setBlue(blue); +} +void QColor_wrapper::setBlueF(float blue) +{ + ::QColor::setBlueF(blue); +} +void QColor_wrapper::setCmyk(int c, int m, int y, int k, int a) +{ + ::QColor::setCmyk(c, m, y, k, a); +} +void QColor_wrapper::setCmykF(float c, float m, float y, float k, float a) +{ + ::QColor::setCmykF(c, m, y, k, a); +} +void QColor_wrapper::setGreen(int green) +{ + ::QColor::setGreen(green); +} +void QColor_wrapper::setGreenF(float green) +{ + ::QColor::setGreenF(green); +} +void QColor_wrapper::setHsl(int h, int s, int l, int a) +{ + ::QColor::setHsl(h, s, l, a); +} +void QColor_wrapper::setHslF(float h, float s, float l, float a) +{ + ::QColor::setHslF(h, s, l, a); +} +void QColor_wrapper::setHsv(int h, int s, int v, int a) +{ + ::QColor::setHsv(h, s, v, a); +} +void QColor_wrapper::setHsvF(float h, float s, float v, float a) +{ + ::QColor::setHsvF(h, s, v, a); +} +void QColor_wrapper::setNamedColor(const QString &name) +{ + ::QColor::setNamedColor(name); +} +void QColor_wrapper::setRed(int red) +{ + ::QColor::setRed(red); +} +void QColor_wrapper::setRedF(float red) +{ + ::QColor::setRedF(red); +} +void QColor_wrapper::setRgb(int r, int g, int b, int a) +{ + ::QColor::setRgb(r, g, b, a); +} +void QColor_wrapper::setRgbF(float r, float g, float b, float a) +{ + ::QColor::setRgbF(r, g, b, a); +} +QColor QColor_wrapper::toCmyk() const +{ + return ::QColor::toCmyk(); +} +QColor QColor_wrapper::toExtendedRgb() const +{ + return ::QColor::toExtendedRgb(); +} +QColor QColor_wrapper::toHsl() const +{ + return ::QColor::toHsl(); +} +QColor QColor_wrapper::toHsv() const +{ + return ::QColor::toHsv(); +} +QColor QColor_wrapper::toRgb() const +{ + return ::QColor::toRgb(); +} +int QColor_wrapper::value() const +{ + return ::QColor::value(); +} +float QColor_wrapper::valueF() const +{ + return ::QColor::valueF(); +} +int QColor_wrapper::yellow() const +{ + return ::QColor::yellow(); +} +float QColor_wrapper::yellowF() const +{ + return ::QColor::yellowF(); +} +QColor_wrapper::~QColor_wrapper() +{ +} + +} +static QColor *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::QColor_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_QColor_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} +void *c_QColor__constructor() +{ + auto ptr = new TestBindings_wrappersNS::QColor_wrapper(); + return reinterpret_cast(ptr); +} +void *c_QColor__constructor_QString(const char *name_) +{ + const auto name = QString::fromUtf8(name_); + auto ptr = new TestBindings_wrappersNS::QColor_wrapper(name); + return reinterpret_cast(ptr); +} +void *c_QColor__constructor_char(const char *aname) +{ + auto ptr = new TestBindings_wrappersNS::QColor_wrapper(aname); + return reinterpret_cast(ptr); +} +void *c_QColor__constructor_int_int_int_int(int r, int g, int b, int a) +{ + auto ptr = new TestBindings_wrappersNS::QColor_wrapper(r, g, b, a); + return reinterpret_cast(ptr); +} +// alpha() const +int c_QColor__alpha(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->alpha(); + return result; +} +// alphaF() const +float c_QColor__alphaF(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->alphaF(); + return result; +} +// black() const +int c_QColor__black(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->black(); + return result; +} +// blackF() const +float c_QColor__blackF(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->blackF(); + return result; +} +// blue() const +int c_QColor__blue(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->blue(); + return result; +} +// blueF() const +float c_QColor__blueF(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->blueF(); + return result; +} +// colorNames() +void *c_static_QColor__colorNames() +{ + const auto &result = new Dartagnan::ValueWrapper> { + TestBindings_wrappersNS::QColor_wrapper::colorNames() + }; + return result; +} +// cyan() const +int c_QColor__cyan(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->cyan(); + return result; +} +// cyanF() const +float c_QColor__cyanF(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->cyanF(); + return result; +} +// darker(int f) const +void *c_QColor__darker_int(void *thisObj, int f) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->darker(f) }; + return result; +} +// fromCmyk(int c, int m, int y, int k, int a) +void *c_static_QColor__fromCmyk_int_int_int_int_int(int c, int m, int y, int k, int a) +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QColor_wrapper::fromCmyk(c, m, y, k, a) + }; + return result; +} +// fromCmykF(float c, float m, float y, float k, float a) +void *c_static_QColor__fromCmykF_float_float_float_float_float(float c, float m, float y, float k, + float a) +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QColor_wrapper::fromCmykF(c, m, y, k, a) + }; + return result; +} +// fromHsl(int h, int s, int l, int a) +void *c_static_QColor__fromHsl_int_int_int_int(int h, int s, int l, int a) +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QColor_wrapper::fromHsl(h, s, l, a) + }; + return result; +} +// fromHslF(float h, float s, float l, float a) +void *c_static_QColor__fromHslF_float_float_float_float(float h, float s, float l, float a) +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QColor_wrapper::fromHslF(h, s, l, a) + }; + return result; +} +// fromHsv(int h, int s, int v, int a) +void *c_static_QColor__fromHsv_int_int_int_int(int h, int s, int v, int a) +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QColor_wrapper::fromHsv(h, s, v, a) + }; + return result; +} +// fromHsvF(float h, float s, float v, float a) +void *c_static_QColor__fromHsvF_float_float_float_float(float h, float s, float v, float a) +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QColor_wrapper::fromHsvF(h, s, v, a) + }; + return result; +} +// fromRgb(int r, int g, int b, int a) +void *c_static_QColor__fromRgb_int_int_int_int(int r, int g, int b, int a) +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QColor_wrapper::fromRgb(r, g, b, a) + }; + return result; +} +// fromRgbF(float r, float g, float b, float a) +void *c_static_QColor__fromRgbF_float_float_float_float(float r, float g, float b, float a) +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QColor_wrapper::fromRgbF(r, g, b, a) + }; + return result; +} +// green() const +int c_QColor__green(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->green(); + return result; +} +// greenF() const +float c_QColor__greenF(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->greenF(); + return result; +} +// hslHue() const +int c_QColor__hslHue(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->hslHue(); + return result; +} +// hslHueF() const +float c_QColor__hslHueF(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->hslHueF(); + return result; +} +// hslSaturation() const +int c_QColor__hslSaturation(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->hslSaturation(); + return result; +} +// hslSaturationF() const +float c_QColor__hslSaturationF(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->hslSaturationF(); + return result; +} +// hsvHue() const +int c_QColor__hsvHue(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->hsvHue(); + return result; +} +// hsvHueF() const +float c_QColor__hsvHueF(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->hsvHueF(); + return result; +} +// hsvSaturation() const +int c_QColor__hsvSaturation(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->hsvSaturation(); + return result; +} +// hsvSaturationF() const +float c_QColor__hsvSaturationF(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->hsvSaturationF(); + return result; +} +// hue() const +int c_QColor__hue(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->hue(); + return result; +} +// hueF() const +float c_QColor__hueF(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->hueF(); + return result; +} +// isValid() const +bool c_QColor__isValid(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isValid(); + return result; +} +// isValidColor(const QString & name) +bool c_static_QColor__isValidColor_QString(const char *name_) +{ + const auto name = QString::fromUtf8(name_); + const auto &result = TestBindings_wrappersNS::QColor_wrapper::isValidColor(name); + free(( char * )name_); + return result; +} +// lighter(int f) const +void *c_QColor__lighter_int(void *thisObj, int f) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->lighter(f) }; + return result; +} +// lightness() const +int c_QColor__lightness(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->lightness(); + return result; +} +// lightnessF() const +float c_QColor__lightnessF(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->lightnessF(); + return result; +} +// magenta() const +int c_QColor__magenta(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->magenta(); + return result; +} +// magentaF() const +float c_QColor__magentaF(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->magentaF(); + return result; +} +// name() const +void *c_QColor__name(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->name() }; + return result; +} +// red() const +int c_QColor__red(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->red(); + return result; +} +// redF() const +float c_QColor__redF(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->redF(); + return result; +} +// saturation() const +int c_QColor__saturation(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->saturation(); + return result; +} +// saturationF() const +float c_QColor__saturationF(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->saturationF(); + return result; +} +// setAlpha(int alpha) +void c_QColor__setAlpha_int(void *thisObj, int alpha) +{ + fromPtr(thisObj)->setAlpha(alpha); +} +// setAlphaF(float alpha) +void c_QColor__setAlphaF_float(void *thisObj, float alpha) +{ + fromPtr(thisObj)->setAlphaF(alpha); +} +// setBlue(int blue) +void c_QColor__setBlue_int(void *thisObj, int blue) +{ + fromPtr(thisObj)->setBlue(blue); +} +// setBlueF(float blue) +void c_QColor__setBlueF_float(void *thisObj, float blue) +{ + fromPtr(thisObj)->setBlueF(blue); +} +// setCmyk(int c, int m, int y, int k, int a) +void c_QColor__setCmyk_int_int_int_int_int(void *thisObj, int c, int m, int y, int k, int a) +{ + fromPtr(thisObj)->setCmyk(c, m, y, k, a); +} +// setCmykF(float c, float m, float y, float k, float a) +void c_QColor__setCmykF_float_float_float_float_float(void *thisObj, float c, float m, float y, + float k, float a) +{ + fromPtr(thisObj)->setCmykF(c, m, y, k, a); +} +// setGreen(int green) +void c_QColor__setGreen_int(void *thisObj, int green) +{ + fromPtr(thisObj)->setGreen(green); +} +// setGreenF(float green) +void c_QColor__setGreenF_float(void *thisObj, float green) +{ + fromPtr(thisObj)->setGreenF(green); +} +// setHsl(int h, int s, int l, int a) +void c_QColor__setHsl_int_int_int_int(void *thisObj, int h, int s, int l, int a) +{ + fromPtr(thisObj)->setHsl(h, s, l, a); +} +// setHslF(float h, float s, float l, float a) +void c_QColor__setHslF_float_float_float_float(void *thisObj, float h, float s, float l, float a) +{ + fromPtr(thisObj)->setHslF(h, s, l, a); +} +// setHsv(int h, int s, int v, int a) +void c_QColor__setHsv_int_int_int_int(void *thisObj, int h, int s, int v, int a) +{ + fromPtr(thisObj)->setHsv(h, s, v, a); +} +// setHsvF(float h, float s, float v, float a) +void c_QColor__setHsvF_float_float_float_float(void *thisObj, float h, float s, float v, float a) +{ + fromPtr(thisObj)->setHsvF(h, s, v, a); +} +// setNamedColor(const QString & name) +void c_QColor__setNamedColor_QString(void *thisObj, const char *name_) +{ + const auto name = QString::fromUtf8(name_); + fromPtr(thisObj)->setNamedColor(name); + free(( char * )name_); +} +// setRed(int red) +void c_QColor__setRed_int(void *thisObj, int red) +{ + fromPtr(thisObj)->setRed(red); +} +// setRedF(float red) +void c_QColor__setRedF_float(void *thisObj, float red) +{ + fromPtr(thisObj)->setRedF(red); +} +// setRgb(int r, int g, int b, int a) +void c_QColor__setRgb_int_int_int_int(void *thisObj, int r, int g, int b, int a) +{ + fromPtr(thisObj)->setRgb(r, g, b, a); +} +// setRgbF(float r, float g, float b, float a) +void c_QColor__setRgbF_float_float_float_float(void *thisObj, float r, float g, float b, float a) +{ + fromPtr(thisObj)->setRgbF(r, g, b, a); +} +// toCmyk() const +void *c_QColor__toCmyk(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->toCmyk() }; + return result; +} +// toExtendedRgb() const +void *c_QColor__toExtendedRgb(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->toExtendedRgb() }; + return result; +} +// toHsl() const +void *c_QColor__toHsl(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->toHsl() }; + return result; +} +// toHsv() const +void *c_QColor__toHsv(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->toHsv() }; + return result; +} +// toRgb() const +void *c_QColor__toRgb(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->toRgb() }; + return result; +} +// value() const +int c_QColor__value(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->value(); + return result; +} +// valueF() const +float c_QColor__valueF(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->valueF(); + return result; +} +// yellow() const +int c_QColor__yellow(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->yellow(); + return result; +} +// yellowF() const +float c_QColor__yellowF(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->yellowF(); + return result; +} +void c_QColor__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} diff --git a/tests/generated/TestBindings/dart/ffi/QColor_c.h b/tests/generated/TestBindings/dart/ffi/QColor_c.h new file mode 100644 index 0000000..6be7442 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/QColor_c.h @@ -0,0 +1,248 @@ +#include "TestBindings_exports.h" +#include +#include +#include +#include + +namespace TestBindings_wrappersNS { +class QColor_wrapper : public ::QColor +{ +public: + ~QColor_wrapper(); + QColor_wrapper(); + QColor_wrapper(const QString &name); + QColor_wrapper(const char *aname); + QColor_wrapper(int r, int g, int b, int a = 255); + int alpha() const; + float alphaF() const; + int black() const; + float blackF() const; + int blue() const; + float blueF() const; + static QList colorNames(); + int cyan() const; + float cyanF() const; + QColor darker(int f = 200) const; + static QColor fromCmyk(int c, int m, int y, int k, int a = 255); + static QColor fromCmykF(float c, float m, float y, float k, float a = 1.0); + static QColor fromHsl(int h, int s, int l, int a = 255); + static QColor fromHslF(float h, float s, float l, float a = 1.0); + static QColor fromHsv(int h, int s, int v, int a = 255); + static QColor fromHsvF(float h, float s, float v, float a = 1.0); + static QColor fromRgb(int r, int g, int b, int a = 255); + static QColor fromRgbF(float r, float g, float b, float a = 1.0); + int green() const; + float greenF() const; + int hslHue() const; + float hslHueF() const; + int hslSaturation() const; + float hslSaturationF() const; + int hsvHue() const; + float hsvHueF() const; + int hsvSaturation() const; + float hsvSaturationF() const; + int hue() const; + float hueF() const; + bool isValid() const; + static bool isValidColor(const QString &name); + QColor lighter(int f = 150) const; + int lightness() const; + float lightnessF() const; + int magenta() const; + float magentaF() const; + QString name() const; + int red() const; + float redF() const; + int saturation() const; + float saturationF() const; + void setAlpha(int alpha); + void setAlphaF(float alpha); + void setBlue(int blue); + void setBlueF(float blue); + void setCmyk(int c, int m, int y, int k, int a = 255); + void setCmykF(float c, float m, float y, float k, float a = 1.0); + void setGreen(int green); + void setGreenF(float green); + void setHsl(int h, int s, int l, int a = 255); + void setHslF(float h, float s, float l, float a = 1.0); + void setHsv(int h, int s, int v, int a = 255); + void setHsvF(float h, float s, float v, float a = 1.0); + void setNamedColor(const QString &name); + void setRed(int red); + void setRedF(float red); + void setRgb(int r, int g, int b, int a = 255); + void setRgbF(float r, float g, float b, float a = 1.0); + QColor toCmyk() const; + QColor toExtendedRgb() const; + QColor toHsl() const; + QColor toHsv() const; + QColor toRgb() const; + int value() const; + float valueF() const; + int yellow() const; + float yellowF() const; +}; +} +extern "C" { +// QColor::QColor() +TestBindings_EXPORT void *c_QColor__constructor(); +// QColor::QColor(const QString & name) +TestBindings_EXPORT void *c_QColor__constructor_QString(const char *name_); +// QColor::QColor(const char * aname) +TestBindings_EXPORT void *c_QColor__constructor_char(const char *aname); +// QColor::QColor(int r, int g, int b, int a) +TestBindings_EXPORT void *c_QColor__constructor_int_int_int_int(int r, int g, int b, int a); +// QColor::alpha() const +TestBindings_EXPORT int c_QColor__alpha(void *thisObj); +// QColor::alphaF() const +TestBindings_EXPORT float c_QColor__alphaF(void *thisObj); +// QColor::black() const +TestBindings_EXPORT int c_QColor__black(void *thisObj); +// QColor::blackF() const +TestBindings_EXPORT float c_QColor__blackF(void *thisObj); +// QColor::blue() const +TestBindings_EXPORT int c_QColor__blue(void *thisObj); +// QColor::blueF() const +TestBindings_EXPORT float c_QColor__blueF(void *thisObj); +// QColor::colorNames() +TestBindings_EXPORT void *c_static_QColor__colorNames(); +// QColor::cyan() const +TestBindings_EXPORT int c_QColor__cyan(void *thisObj); +// QColor::cyanF() const +TestBindings_EXPORT float c_QColor__cyanF(void *thisObj); +// QColor::darker(int f) const +TestBindings_EXPORT void *c_QColor__darker_int(void *thisObj, int f); +// QColor::fromCmyk(int c, int m, int y, int k, int a) +TestBindings_EXPORT void *c_static_QColor__fromCmyk_int_int_int_int_int(int c, int m, int y, int k, + int a); +// QColor::fromCmykF(float c, float m, float y, float k, float a) +TestBindings_EXPORT void *c_static_QColor__fromCmykF_float_float_float_float_float(float c, float m, + float y, float k, + float a); +// QColor::fromHsl(int h, int s, int l, int a) +TestBindings_EXPORT void *c_static_QColor__fromHsl_int_int_int_int(int h, int s, int l, int a); +// QColor::fromHslF(float h, float s, float l, float a) +TestBindings_EXPORT void *c_static_QColor__fromHslF_float_float_float_float(float h, float s, + float l, float a); +// QColor::fromHsv(int h, int s, int v, int a) +TestBindings_EXPORT void *c_static_QColor__fromHsv_int_int_int_int(int h, int s, int v, int a); +// QColor::fromHsvF(float h, float s, float v, float a) +TestBindings_EXPORT void *c_static_QColor__fromHsvF_float_float_float_float(float h, float s, + float v, float a); +// QColor::fromRgb(int r, int g, int b, int a) +TestBindings_EXPORT void *c_static_QColor__fromRgb_int_int_int_int(int r, int g, int b, int a); +// QColor::fromRgbF(float r, float g, float b, float a) +TestBindings_EXPORT void *c_static_QColor__fromRgbF_float_float_float_float(float r, float g, + float b, float a); +// QColor::green() const +TestBindings_EXPORT int c_QColor__green(void *thisObj); +// QColor::greenF() const +TestBindings_EXPORT float c_QColor__greenF(void *thisObj); +// QColor::hslHue() const +TestBindings_EXPORT int c_QColor__hslHue(void *thisObj); +// QColor::hslHueF() const +TestBindings_EXPORT float c_QColor__hslHueF(void *thisObj); +// QColor::hslSaturation() const +TestBindings_EXPORT int c_QColor__hslSaturation(void *thisObj); +// QColor::hslSaturationF() const +TestBindings_EXPORT float c_QColor__hslSaturationF(void *thisObj); +// QColor::hsvHue() const +TestBindings_EXPORT int c_QColor__hsvHue(void *thisObj); +// QColor::hsvHueF() const +TestBindings_EXPORT float c_QColor__hsvHueF(void *thisObj); +// QColor::hsvSaturation() const +TestBindings_EXPORT int c_QColor__hsvSaturation(void *thisObj); +// QColor::hsvSaturationF() const +TestBindings_EXPORT float c_QColor__hsvSaturationF(void *thisObj); +// QColor::hue() const +TestBindings_EXPORT int c_QColor__hue(void *thisObj); +// QColor::hueF() const +TestBindings_EXPORT float c_QColor__hueF(void *thisObj); +// QColor::isValid() const +TestBindings_EXPORT bool c_QColor__isValid(void *thisObj); +// QColor::isValidColor(const QString & name) +TestBindings_EXPORT bool c_static_QColor__isValidColor_QString(const char *name_); +// QColor::lighter(int f) const +TestBindings_EXPORT void *c_QColor__lighter_int(void *thisObj, int f); +// QColor::lightness() const +TestBindings_EXPORT int c_QColor__lightness(void *thisObj); +// QColor::lightnessF() const +TestBindings_EXPORT float c_QColor__lightnessF(void *thisObj); +// QColor::magenta() const +TestBindings_EXPORT int c_QColor__magenta(void *thisObj); +// QColor::magentaF() const +TestBindings_EXPORT float c_QColor__magentaF(void *thisObj); +// QColor::name() const +TestBindings_EXPORT void *c_QColor__name(void *thisObj); +// QColor::red() const +TestBindings_EXPORT int c_QColor__red(void *thisObj); +// QColor::redF() const +TestBindings_EXPORT float c_QColor__redF(void *thisObj); +// QColor::saturation() const +TestBindings_EXPORT int c_QColor__saturation(void *thisObj); +// QColor::saturationF() const +TestBindings_EXPORT float c_QColor__saturationF(void *thisObj); +// QColor::setAlpha(int alpha) +TestBindings_EXPORT void c_QColor__setAlpha_int(void *thisObj, int alpha); +// QColor::setAlphaF(float alpha) +TestBindings_EXPORT void c_QColor__setAlphaF_float(void *thisObj, float alpha); +// QColor::setBlue(int blue) +TestBindings_EXPORT void c_QColor__setBlue_int(void *thisObj, int blue); +// QColor::setBlueF(float blue) +TestBindings_EXPORT void c_QColor__setBlueF_float(void *thisObj, float blue); +// QColor::setCmyk(int c, int m, int y, int k, int a) +TestBindings_EXPORT void c_QColor__setCmyk_int_int_int_int_int(void *thisObj, int c, int m, int y, + int k, int a); +// QColor::setCmykF(float c, float m, float y, float k, float a) +TestBindings_EXPORT void c_QColor__setCmykF_float_float_float_float_float(void *thisObj, float c, + float m, float y, float k, + float a); +// QColor::setGreen(int green) +TestBindings_EXPORT void c_QColor__setGreen_int(void *thisObj, int green); +// QColor::setGreenF(float green) +TestBindings_EXPORT void c_QColor__setGreenF_float(void *thisObj, float green); +// QColor::setHsl(int h, int s, int l, int a) +TestBindings_EXPORT void c_QColor__setHsl_int_int_int_int(void *thisObj, int h, int s, int l, + int a); +// QColor::setHslF(float h, float s, float l, float a) +TestBindings_EXPORT void c_QColor__setHslF_float_float_float_float(void *thisObj, float h, float s, + float l, float a); +// QColor::setHsv(int h, int s, int v, int a) +TestBindings_EXPORT void c_QColor__setHsv_int_int_int_int(void *thisObj, int h, int s, int v, + int a); +// QColor::setHsvF(float h, float s, float v, float a) +TestBindings_EXPORT void c_QColor__setHsvF_float_float_float_float(void *thisObj, float h, float s, + float v, float a); +// QColor::setNamedColor(const QString & name) +TestBindings_EXPORT void c_QColor__setNamedColor_QString(void *thisObj, const char *name_); +// QColor::setRed(int red) +TestBindings_EXPORT void c_QColor__setRed_int(void *thisObj, int red); +// QColor::setRedF(float red) +TestBindings_EXPORT void c_QColor__setRedF_float(void *thisObj, float red); +// QColor::setRgb(int r, int g, int b, int a) +TestBindings_EXPORT void c_QColor__setRgb_int_int_int_int(void *thisObj, int r, int g, int b, + int a); +// QColor::setRgbF(float r, float g, float b, float a) +TestBindings_EXPORT void c_QColor__setRgbF_float_float_float_float(void *thisObj, float r, float g, + float b, float a); +// QColor::toCmyk() const +TestBindings_EXPORT void *c_QColor__toCmyk(void *thisObj); +// QColor::toExtendedRgb() const +TestBindings_EXPORT void *c_QColor__toExtendedRgb(void *thisObj); +// QColor::toHsl() const +TestBindings_EXPORT void *c_QColor__toHsl(void *thisObj); +// QColor::toHsv() const +TestBindings_EXPORT void *c_QColor__toHsv(void *thisObj); +// QColor::toRgb() const +TestBindings_EXPORT void *c_QColor__toRgb(void *thisObj); +// QColor::value() const +TestBindings_EXPORT int c_QColor__value(void *thisObj); +// QColor::valueF() const +TestBindings_EXPORT float c_QColor__valueF(void *thisObj); +// QColor::yellow() const +TestBindings_EXPORT int c_QColor__yellow(void *thisObj); +// QColor::yellowF() const +TestBindings_EXPORT float c_QColor__yellowF(void *thisObj); +TestBindings_EXPORT void c_QColor__destructor(void *thisObj); +TestBindings_EXPORT void c_QColor_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/QCoreApplication_c.cpp b/tests/generated/TestBindings/dart/ffi/QCoreApplication_c.cpp new file mode 100644 index 0000000..bd09ed7 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/QCoreApplication_c.cpp @@ -0,0 +1,626 @@ +#include "QCoreApplication_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +void QCoreApplication_wrapper::addLibraryPath(const QString &arg__1) +{ + ::QCoreApplication::addLibraryPath(arg__1); +} +QString QCoreApplication_wrapper::applicationDirPath() +{ + return ::QCoreApplication::applicationDirPath(); +} +QString QCoreApplication_wrapper::applicationFilePath() +{ + return ::QCoreApplication::applicationFilePath(); +} +QString QCoreApplication_wrapper::applicationName() +{ + return ::QCoreApplication::applicationName(); +} +void QCoreApplication_wrapper::applicationNameChanged() +{ + ::QCoreApplication::applicationNameChanged(); +} +qint64 QCoreApplication_wrapper::applicationPid() +{ + return ::QCoreApplication::applicationPid(); +} +QString QCoreApplication_wrapper::applicationVersion() +{ + return ::QCoreApplication::applicationVersion(); +} +void QCoreApplication_wrapper::applicationVersionChanged() +{ + ::QCoreApplication::applicationVersionChanged(); +} +QList QCoreApplication_wrapper::arguments() +{ + return ::QCoreApplication::arguments(); +} +bool QCoreApplication_wrapper::closingDown() +{ + return ::QCoreApplication::closingDown(); +} +void QCoreApplication_wrapper::customEvent(QEvent *event) +{ + if (m_customEventCallback) { + const void *thisPtr = this; + m_customEventCallback(const_cast(thisPtr), event); + } else { + ::QCoreApplication::customEvent(event); + } +} +void QCoreApplication_wrapper::customEvent_nocallback(QEvent *event) +{ + ::QCoreApplication::customEvent(event); +} +bool QCoreApplication_wrapper::event(QEvent *arg__1) +{ + if (m_eventCallback) { + const void *thisPtr = this; + return m_eventCallback(const_cast(thisPtr), arg__1); + } else { + return ::QCoreApplication::event(arg__1); + } +} +bool QCoreApplication_wrapper::event_nocallback(QEvent *arg__1) +{ + return ::QCoreApplication::event(arg__1); +} +bool QCoreApplication_wrapper::eventFilter(QObject *watched, QEvent *event) +{ + if (m_eventFilterCallback) { + const void *thisPtr = this; + return m_eventFilterCallback(const_cast(thisPtr), watched, event); + } else { + return ::QCoreApplication::eventFilter(watched, event); + } +} +bool QCoreApplication_wrapper::eventFilter_nocallback(QObject *watched, QEvent *event) +{ + return ::QCoreApplication::eventFilter(watched, event); +} +int QCoreApplication_wrapper::exec() +{ + return ::QCoreApplication::exec(); +} +void QCoreApplication_wrapper::exit(int retcode) +{ + ::QCoreApplication::exit(retcode); +} +QCoreApplication *QCoreApplication_wrapper::instance() +{ + return ::QCoreApplication::instance(); +} +bool QCoreApplication_wrapper::isQuitLockEnabled() +{ + return ::QCoreApplication::isQuitLockEnabled(); +} +bool QCoreApplication_wrapper::isSetuidAllowed() +{ + return ::QCoreApplication::isSetuidAllowed(); +} +QList QCoreApplication_wrapper::libraryPaths() +{ + return ::QCoreApplication::libraryPaths(); +} +bool QCoreApplication_wrapper::notify(QObject *arg__1, QEvent *arg__2) +{ + if (m_notifyCallback) { + const void *thisPtr = this; + return m_notifyCallback(const_cast(thisPtr), arg__1, arg__2); + } else { + return ::QCoreApplication::notify(arg__1, arg__2); + } +} +bool QCoreApplication_wrapper::notify_nocallback(QObject *arg__1, QEvent *arg__2) +{ + return ::QCoreApplication::notify(arg__1, arg__2); +} +QString QCoreApplication_wrapper::organizationDomain() +{ + return ::QCoreApplication::organizationDomain(); +} +void QCoreApplication_wrapper::organizationDomainChanged() +{ + ::QCoreApplication::organizationDomainChanged(); +} +QString QCoreApplication_wrapper::organizationName() +{ + return ::QCoreApplication::organizationName(); +} +void QCoreApplication_wrapper::organizationNameChanged() +{ + ::QCoreApplication::organizationNameChanged(); +} +void QCoreApplication_wrapper::postEvent(QObject *receiver, QEvent *event, int priority) +{ + ::QCoreApplication::postEvent(receiver, event, priority); +} +void QCoreApplication_wrapper::processEvents() +{ + ::QCoreApplication::processEvents(); +} +void QCoreApplication_wrapper::quit() +{ + ::QCoreApplication::quit(); +} +void QCoreApplication_wrapper::removeLibraryPath(const QString &arg__1) +{ + ::QCoreApplication::removeLibraryPath(arg__1); +} +void QCoreApplication_wrapper::removePostedEvents(QObject *receiver, int eventType) +{ + ::QCoreApplication::removePostedEvents(receiver, eventType); +} +bool QCoreApplication_wrapper::sendEvent(QObject *receiver, QEvent *event) +{ + return ::QCoreApplication::sendEvent(receiver, event); +} +void QCoreApplication_wrapper::sendPostedEvents(QObject *receiver, int event_type) +{ + ::QCoreApplication::sendPostedEvents(receiver, event_type); +} +void QCoreApplication_wrapper::setApplicationName(const QString &application) +{ + ::QCoreApplication::setApplicationName(application); +} +void QCoreApplication_wrapper::setApplicationVersion(const QString &version) +{ + ::QCoreApplication::setApplicationVersion(version); +} +void QCoreApplication_wrapper::setLibraryPaths(const QList &arg__1) +{ + ::QCoreApplication::setLibraryPaths(arg__1); +} +void QCoreApplication_wrapper::setOrganizationDomain(const QString &orgDomain) +{ + ::QCoreApplication::setOrganizationDomain(orgDomain); +} +void QCoreApplication_wrapper::setOrganizationName(const QString &orgName) +{ + ::QCoreApplication::setOrganizationName(orgName); +} +void QCoreApplication_wrapper::setQuitLockEnabled(bool enabled) +{ + ::QCoreApplication::setQuitLockEnabled(enabled); +} +void QCoreApplication_wrapper::setSetuidAllowed(bool allow) +{ + ::QCoreApplication::setSetuidAllowed(allow); +} +bool QCoreApplication_wrapper::startingUp() +{ + return ::QCoreApplication::startingUp(); +} +QString QCoreApplication_wrapper::tr(const char *s, const char *c, int n) +{ + return ::QCoreApplication::tr(s, c, n); +} +QString QCoreApplication_wrapper::translate(const char *context, const char *key, + const char *disambiguation, int n) +{ + return ::QCoreApplication::translate(context, key, disambiguation, n); +} +QCoreApplication_wrapper::~QCoreApplication_wrapper() +{ +} + +} +static QCoreApplication *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::QCoreApplication_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_QCoreApplication_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} // addLibraryPath(const QString & arg__1) +void c_static_QCoreApplication__addLibraryPath_QString(const char *arg__1_) +{ + const auto arg__1 = QString::fromUtf8(arg__1_); + TestBindings_wrappersNS::QCoreApplication_wrapper::addLibraryPath(arg__1); + free(( char * )arg__1_); +} +// applicationDirPath() +void *c_static_QCoreApplication__applicationDirPath() +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QCoreApplication_wrapper::applicationDirPath() + }; + return result; +} +// applicationFilePath() +void *c_static_QCoreApplication__applicationFilePath() +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QCoreApplication_wrapper::applicationFilePath() + }; + return result; +} +// applicationName() +void *c_static_QCoreApplication__applicationName() +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QCoreApplication_wrapper::applicationName() + }; + return result; +} +// applicationNameChanged() +void c_QCoreApplication__applicationNameChanged(void *thisObj) +{ + fromPtr(thisObj)->applicationNameChanged(); +} +void c_QCoreApplication__onApplicationNameChanged(void *thisObj, void *contextQObject, + void *callback) +{ + auto instance = reinterpret_cast(thisObj); + auto context = reinterpret_cast(contextQObject); + QObject::connect(instance, &QCoreApplication::applicationNameChanged, + context ? context : instance, [thisObj, callback] { + typedef void (*SignalHandler_callback)(void *); + auto dartCallback = reinterpret_cast(callback); + dartCallback(thisObj); + }); +} +// applicationPid() +qint64 c_static_QCoreApplication__applicationPid() +{ + const auto &result = TestBindings_wrappersNS::QCoreApplication_wrapper::applicationPid(); + return result; +} +// applicationVersion() +void *c_static_QCoreApplication__applicationVersion() +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QCoreApplication_wrapper::applicationVersion() + }; + return result; +} +// applicationVersionChanged() +void c_QCoreApplication__applicationVersionChanged(void *thisObj) +{ + fromPtr(thisObj)->applicationVersionChanged(); +} +void c_QCoreApplication__onApplicationVersionChanged(void *thisObj, void *contextQObject, + void *callback) +{ + auto instance = reinterpret_cast(thisObj); + auto context = reinterpret_cast(contextQObject); + QObject::connect(instance, &QCoreApplication::applicationVersionChanged, + context ? context : instance, [thisObj, callback] { + typedef void (*SignalHandler_callback)(void *); + auto dartCallback = reinterpret_cast(callback); + dartCallback(thisObj); + }); +} +// arguments() +void *c_static_QCoreApplication__arguments() +{ + const auto &result = new Dartagnan::ValueWrapper> { + TestBindings_wrappersNS::QCoreApplication_wrapper::arguments() + }; + return result; +} +// closingDown() +bool c_static_QCoreApplication__closingDown() +{ + const auto &result = TestBindings_wrappersNS::QCoreApplication_wrapper::closingDown(); + return result; +} +// customEvent(QEvent * event) +void c_QCoreApplication__customEvent_QEvent(void *thisObj, void *event_) +{ + auto event = reinterpret_cast(event_); + fromWrapperPtr(thisObj)->customEvent_nocallback(event); +} +void c_QCoreApplication__onDestroyed_QObject(void *thisObj, void *contextQObject, void *callback) +{ + auto instance = reinterpret_cast(thisObj); + auto context = reinterpret_cast(contextQObject); + QObject::connect(instance, &QCoreApplication::destroyed, context ? context : instance, + [thisObj, callback] { + typedef void (*SignalHandler_callback)(void *); + auto dartCallback = reinterpret_cast(callback); + dartCallback(thisObj); + }); +} +// event(QEvent * arg__1) +bool c_QCoreApplication__event_QEvent(void *thisObj, void *arg__1_) +{ + auto arg__1 = reinterpret_cast(arg__1_); + const auto &result = fromWrapperPtr(thisObj)->event_nocallback(arg__1); + return result; +} +// eventFilter(QObject * watched, QEvent * event) +bool c_QCoreApplication__eventFilter_QObject_QEvent(void *thisObj, void *watched_, void *event_) +{ + auto watched = reinterpret_cast(watched_); + auto event = reinterpret_cast(event_); + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->eventFilter_nocallback(watched, event); + } else { + return targetPtr->eventFilter(watched, event); + } + }(); + return result; +} +// exec() +int c_static_QCoreApplication__exec() +{ + const auto &result = TestBindings_wrappersNS::QCoreApplication_wrapper::exec(); + return result; +} +// exit(int retcode) +void c_static_QCoreApplication__exit_int(int retcode) +{ + TestBindings_wrappersNS::QCoreApplication_wrapper::exit(retcode); +} +// instance() +void *c_static_QCoreApplication__instance() +{ + const auto &result = TestBindings_wrappersNS::QCoreApplication_wrapper::instance(); + return result; +} +// isQuitLockEnabled() +bool c_static_QCoreApplication__isQuitLockEnabled() +{ + const auto &result = TestBindings_wrappersNS::QCoreApplication_wrapper::isQuitLockEnabled(); + return result; +} +// isSetuidAllowed() +bool c_static_QCoreApplication__isSetuidAllowed() +{ + const auto &result = TestBindings_wrappersNS::QCoreApplication_wrapper::isSetuidAllowed(); + return result; +} +// libraryPaths() +void *c_static_QCoreApplication__libraryPaths() +{ + const auto &result = new Dartagnan::ValueWrapper> { + TestBindings_wrappersNS::QCoreApplication_wrapper::libraryPaths() + }; + return result; +} +// notify(QObject * arg__1, QEvent * arg__2) +bool c_QCoreApplication__notify_QObject_QEvent(void *thisObj, void *arg__1_, void *arg__2_) +{ + auto arg__1 = reinterpret_cast(arg__1_); + auto arg__2 = reinterpret_cast(arg__2_); + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->notify_nocallback(arg__1, arg__2); + } else { + return targetPtr->notify(arg__1, arg__2); + } + }(); + return result; +} +// organizationDomain() +void *c_static_QCoreApplication__organizationDomain() +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QCoreApplication_wrapper::organizationDomain() + }; + return result; +} +// organizationDomainChanged() +void c_QCoreApplication__organizationDomainChanged(void *thisObj) +{ + fromPtr(thisObj)->organizationDomainChanged(); +} +void c_QCoreApplication__onOrganizationDomainChanged(void *thisObj, void *contextQObject, + void *callback) +{ + auto instance = reinterpret_cast(thisObj); + auto context = reinterpret_cast(contextQObject); + QObject::connect(instance, &QCoreApplication::organizationDomainChanged, + context ? context : instance, [thisObj, callback] { + typedef void (*SignalHandler_callback)(void *); + auto dartCallback = reinterpret_cast(callback); + dartCallback(thisObj); + }); +} +// organizationName() +void *c_static_QCoreApplication__organizationName() +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QCoreApplication_wrapper::organizationName() + }; + return result; +} +// organizationNameChanged() +void c_QCoreApplication__organizationNameChanged(void *thisObj) +{ + fromPtr(thisObj)->organizationNameChanged(); +} +void c_QCoreApplication__onOrganizationNameChanged(void *thisObj, void *contextQObject, + void *callback) +{ + auto instance = reinterpret_cast(thisObj); + auto context = reinterpret_cast(contextQObject); + QObject::connect(instance, &QCoreApplication::organizationNameChanged, + context ? context : instance, [thisObj, callback] { + typedef void (*SignalHandler_callback)(void *); + auto dartCallback = reinterpret_cast(callback); + dartCallback(thisObj); + }); +} +// postEvent(QObject * receiver, QEvent * event, int priority) +void c_static_QCoreApplication__postEvent_QObject_QEvent_int(void *receiver_, void *event_, + int priority) +{ + auto receiver = reinterpret_cast(receiver_); + auto event = reinterpret_cast(event_); + TestBindings_wrappersNS::QCoreApplication_wrapper::postEvent(receiver, event, priority); +} +// processEvents() +void c_static_QCoreApplication__processEvents() +{ + TestBindings_wrappersNS::QCoreApplication_wrapper::processEvents(); +} +// quit() +void c_static_QCoreApplication__quit() +{ + TestBindings_wrappersNS::QCoreApplication_wrapper::quit(); +} +// removeLibraryPath(const QString & arg__1) +void c_static_QCoreApplication__removeLibraryPath_QString(const char *arg__1_) +{ + const auto arg__1 = QString::fromUtf8(arg__1_); + TestBindings_wrappersNS::QCoreApplication_wrapper::removeLibraryPath(arg__1); + free(( char * )arg__1_); +} +// removePostedEvents(QObject * receiver, int eventType) +void c_static_QCoreApplication__removePostedEvents_QObject_int(void *receiver_, int eventType) +{ + auto receiver = reinterpret_cast(receiver_); + TestBindings_wrappersNS::QCoreApplication_wrapper::removePostedEvents(receiver, eventType); +} +// sendEvent(QObject * receiver, QEvent * event) +bool c_static_QCoreApplication__sendEvent_QObject_QEvent(void *receiver_, void *event_) +{ + auto receiver = reinterpret_cast(receiver_); + auto event = reinterpret_cast(event_); + const auto &result = + TestBindings_wrappersNS::QCoreApplication_wrapper::sendEvent(receiver, event); + return result; +} +// sendPostedEvents(QObject * receiver, int event_type) +void c_static_QCoreApplication__sendPostedEvents_QObject_int(void *receiver_, int event_type) +{ + auto receiver = reinterpret_cast(receiver_); + TestBindings_wrappersNS::QCoreApplication_wrapper::sendPostedEvents(receiver, event_type); +} +// setApplicationName(const QString & application) +void c_static_QCoreApplication__setApplicationName_QString(const char *application_) +{ + const auto application = QString::fromUtf8(application_); + TestBindings_wrappersNS::QCoreApplication_wrapper::setApplicationName(application); + free(( char * )application_); +} +// setApplicationVersion(const QString & version) +void c_static_QCoreApplication__setApplicationVersion_QString(const char *version_) +{ + const auto version = QString::fromUtf8(version_); + TestBindings_wrappersNS::QCoreApplication_wrapper::setApplicationVersion(version); + free(( char * )version_); +} +// setLibraryPaths(const QList & arg__1) +void c_static_QCoreApplication__setLibraryPaths_QList_QString(void *arg__1_) +{ + assert(arg__1_); + auto &arg__1 = *reinterpret_cast *>(arg__1_); + TestBindings_wrappersNS::QCoreApplication_wrapper::setLibraryPaths(arg__1); +} +// setOrganizationDomain(const QString & orgDomain) +void c_static_QCoreApplication__setOrganizationDomain_QString(const char *orgDomain_) +{ + const auto orgDomain = QString::fromUtf8(orgDomain_); + TestBindings_wrappersNS::QCoreApplication_wrapper::setOrganizationDomain(orgDomain); + free(( char * )orgDomain_); +} +// setOrganizationName(const QString & orgName) +void c_static_QCoreApplication__setOrganizationName_QString(const char *orgName_) +{ + const auto orgName = QString::fromUtf8(orgName_); + TestBindings_wrappersNS::QCoreApplication_wrapper::setOrganizationName(orgName); + free(( char * )orgName_); +} +// setQuitLockEnabled(bool enabled) +void c_static_QCoreApplication__setQuitLockEnabled_bool(bool enabled) +{ + TestBindings_wrappersNS::QCoreApplication_wrapper::setQuitLockEnabled(enabled); +} +// setSetuidAllowed(bool allow) +void c_static_QCoreApplication__setSetuidAllowed_bool(bool allow) +{ + TestBindings_wrappersNS::QCoreApplication_wrapper::setSetuidAllowed(allow); +} +// startingUp() +bool c_static_QCoreApplication__startingUp() +{ + const auto &result = TestBindings_wrappersNS::QCoreApplication_wrapper::startingUp(); + return result; +} +// tr(const char * s, const char * c, int n) +void *c_static_QCoreApplication__tr_char_char_int(const char *s, const char *c, int n) +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QCoreApplication_wrapper::tr(s, c, n) + }; + free(( char * )s); + free(( char * )c); + return result; +} +// translate(const char * context, const char * key, const char * disambiguation, int n) +void *c_static_QCoreApplication__translate_char_char_char_int(const char *context, const char *key, + const char *disambiguation, int n) +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QCoreApplication_wrapper::translate(context, key, disambiguation, + n) + }; + free(( char * )context); + free(( char * )key); + free(( char * )disambiguation); + return result; +} +void c_QCoreApplication__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +void c_QCoreApplication__registerVirtualMethodCallback(void *ptr, void *callback, int methodId) +{ + auto wrapper = fromWrapperPtr(ptr); + switch (methodId) { + case 481: + wrapper->m_customEventCallback = reinterpret_cast< + TestBindings_wrappersNS::QCoreApplication_wrapper::Callback_customEvent>(callback); + break; + case 490: + wrapper->m_eventCallback = + reinterpret_cast( + callback); + break; + case 491: + wrapper->m_eventFilterCallback = reinterpret_cast< + TestBindings_wrappersNS::QCoreApplication_wrapper::Callback_eventFilter>(callback); + break; + case 688: + wrapper->m_notifyCallback = + reinterpret_cast( + callback); + break; + } +} +} diff --git a/tests/generated/TestBindings/dart/ffi/QCoreApplication_c.h b/tests/generated/TestBindings/dart/ffi/QCoreApplication_c.h new file mode 100644 index 0000000..b0e9ff4 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/QCoreApplication_c.h @@ -0,0 +1,180 @@ +#include "TestBindings_exports.h" +#include +#include +#include +#include +#include +#include +#include + +namespace TestBindings_wrappersNS { +class QCoreApplication_wrapper : public ::QCoreApplication +{ +public: + ~QCoreApplication_wrapper(); + static void addLibraryPath(const QString &arg__1); + static QString applicationDirPath(); + static QString applicationFilePath(); + static QString applicationName(); + void applicationNameChanged(); + static qint64 applicationPid(); + static QString applicationVersion(); + void applicationVersionChanged(); + static QList arguments(); + static bool closingDown(); + virtual void customEvent(QEvent *event); + virtual void customEvent_nocallback(QEvent *event); + virtual bool event(QEvent *arg__1); + virtual bool event_nocallback(QEvent *arg__1); + virtual bool eventFilter(QObject *watched, QEvent *event); + virtual bool eventFilter_nocallback(QObject *watched, QEvent *event); + static int exec(); + static void exit(int retcode = 0); + static QCoreApplication *instance(); + static bool isQuitLockEnabled(); + static bool isSetuidAllowed(); + static QList libraryPaths(); + virtual bool notify(QObject *arg__1, QEvent *arg__2); + virtual bool notify_nocallback(QObject *arg__1, QEvent *arg__2); + static QString organizationDomain(); + void organizationDomainChanged(); + static QString organizationName(); + void organizationNameChanged(); + static void postEvent(QObject *receiver, QEvent *event, int priority = Qt::NormalEventPriority); + static void processEvents(); + static void quit(); + static void removeLibraryPath(const QString &arg__1); + static void removePostedEvents(QObject *receiver, int eventType = 0); + static bool sendEvent(QObject *receiver, QEvent *event); + static void sendPostedEvents(QObject *receiver = nullptr, int event_type = 0); + static void setApplicationName(const QString &application); + static void setApplicationVersion(const QString &version); + static void setLibraryPaths(const QList &arg__1); + static void setOrganizationDomain(const QString &orgDomain); + static void setOrganizationName(const QString &orgName); + static void setQuitLockEnabled(bool enabled); + static void setSetuidAllowed(bool allow); + static bool startingUp(); + static QString tr(const char *s, const char *c, int n); + static QString translate(const char *context, const char *key, + const char *disambiguation = nullptr, int n = -1); + typedef void (*Callback_customEvent)(void *, QEvent *event); + Callback_customEvent m_customEventCallback = nullptr; + typedef bool (*Callback_event)(void *, QEvent *arg__1); + Callback_event m_eventCallback = nullptr; + typedef bool (*Callback_eventFilter)(void *, QObject *watched, QEvent *event); + Callback_eventFilter m_eventFilterCallback = nullptr; + typedef bool (*Callback_notify)(void *, QObject *arg__1, QEvent *arg__2); + Callback_notify m_notifyCallback = nullptr; +}; +} +extern "C" { +// QCoreApplication::addLibraryPath(const QString & arg__1) +TestBindings_EXPORT void c_static_QCoreApplication__addLibraryPath_QString(const char *arg__1_); +// QCoreApplication::applicationDirPath() +TestBindings_EXPORT void *c_static_QCoreApplication__applicationDirPath(); +// QCoreApplication::applicationFilePath() +TestBindings_EXPORT void *c_static_QCoreApplication__applicationFilePath(); +// QCoreApplication::applicationName() +TestBindings_EXPORT void *c_static_QCoreApplication__applicationName(); +// QCoreApplication::applicationNameChanged() +TestBindings_EXPORT void c_QCoreApplication__applicationNameChanged(void *thisObj); +TestBindings_EXPORT void +c_QCoreApplication__onApplicationNameChanged(void *thisObj, void *contextQObject, + void *callback); // QCoreApplication::applicationPid() +TestBindings_EXPORT qint64 c_static_QCoreApplication__applicationPid(); +// QCoreApplication::applicationVersion() +TestBindings_EXPORT void *c_static_QCoreApplication__applicationVersion(); +// QCoreApplication::applicationVersionChanged() +TestBindings_EXPORT void c_QCoreApplication__applicationVersionChanged(void *thisObj); +TestBindings_EXPORT void +c_QCoreApplication__onApplicationVersionChanged(void *thisObj, void *contextQObject, + void *callback); // QCoreApplication::arguments() +TestBindings_EXPORT void *c_static_QCoreApplication__arguments(); +// QCoreApplication::closingDown() +TestBindings_EXPORT bool c_static_QCoreApplication__closingDown(); +// QCoreApplication::customEvent(QEvent * event) +TestBindings_EXPORT void c_QCoreApplication__customEvent_QEvent(void *thisObj, void *event_); +// QCoreApplication::event(QEvent * arg__1) +TestBindings_EXPORT bool c_QCoreApplication__event_QEvent(void *thisObj, void *arg__1_); +// QCoreApplication::eventFilter(QObject * watched, QEvent * event) +TestBindings_EXPORT bool +c_QCoreApplication__eventFilter_QObject_QEvent(void *thisObj, void *watched_, void *event_); +// QCoreApplication::exec() +TestBindings_EXPORT int c_static_QCoreApplication__exec(); +// QCoreApplication::exit(int retcode) +TestBindings_EXPORT void c_static_QCoreApplication__exit_int(int retcode); +// QCoreApplication::instance() +TestBindings_EXPORT void *c_static_QCoreApplication__instance(); +// QCoreApplication::isQuitLockEnabled() +TestBindings_EXPORT bool c_static_QCoreApplication__isQuitLockEnabled(); +// QCoreApplication::isSetuidAllowed() +TestBindings_EXPORT bool c_static_QCoreApplication__isSetuidAllowed(); +// QCoreApplication::libraryPaths() +TestBindings_EXPORT void *c_static_QCoreApplication__libraryPaths(); +// QCoreApplication::notify(QObject * arg__1, QEvent * arg__2) +TestBindings_EXPORT bool c_QCoreApplication__notify_QObject_QEvent(void *thisObj, void *arg__1_, + void *arg__2_); +// QCoreApplication::organizationDomain() +TestBindings_EXPORT void *c_static_QCoreApplication__organizationDomain(); +// QCoreApplication::organizationDomainChanged() +TestBindings_EXPORT void c_QCoreApplication__organizationDomainChanged(void *thisObj); +TestBindings_EXPORT void c_QCoreApplication__onOrganizationDomainChanged( + void *thisObj, void *contextQObject, void *callback); // QCoreApplication::organizationName() +TestBindings_EXPORT void *c_static_QCoreApplication__organizationName(); +// QCoreApplication::organizationNameChanged() +TestBindings_EXPORT void c_QCoreApplication__organizationNameChanged(void *thisObj); +TestBindings_EXPORT void c_QCoreApplication__onOrganizationNameChanged( + void *thisObj, void *contextQObject, void *callback); // QCoreApplication::postEvent(QObject * + // receiver, QEvent * event, int priority) +TestBindings_EXPORT void c_static_QCoreApplication__postEvent_QObject_QEvent_int(void *receiver_, + void *event_, + int priority); +// QCoreApplication::processEvents() +TestBindings_EXPORT void c_static_QCoreApplication__processEvents(); +// QCoreApplication::quit() +TestBindings_EXPORT void c_static_QCoreApplication__quit(); +// QCoreApplication::removeLibraryPath(const QString & arg__1) +TestBindings_EXPORT void c_static_QCoreApplication__removeLibraryPath_QString(const char *arg__1_); +// QCoreApplication::removePostedEvents(QObject * receiver, int eventType) +TestBindings_EXPORT void c_static_QCoreApplication__removePostedEvents_QObject_int(void *receiver_, + int eventType); +// QCoreApplication::sendEvent(QObject * receiver, QEvent * event) +TestBindings_EXPORT bool c_static_QCoreApplication__sendEvent_QObject_QEvent(void *receiver_, + void *event_); +// QCoreApplication::sendPostedEvents(QObject * receiver, int event_type) +TestBindings_EXPORT void c_static_QCoreApplication__sendPostedEvents_QObject_int(void *receiver_, + int event_type); +// QCoreApplication::setApplicationName(const QString & application) +TestBindings_EXPORT void +c_static_QCoreApplication__setApplicationName_QString(const char *application_); +// QCoreApplication::setApplicationVersion(const QString & version) +TestBindings_EXPORT void +c_static_QCoreApplication__setApplicationVersion_QString(const char *version_); +// QCoreApplication::setLibraryPaths(const QList & arg__1) +TestBindings_EXPORT void c_static_QCoreApplication__setLibraryPaths_QList_QString(void *arg__1_); +// QCoreApplication::setOrganizationDomain(const QString & orgDomain) +TestBindings_EXPORT void +c_static_QCoreApplication__setOrganizationDomain_QString(const char *orgDomain_); +// QCoreApplication::setOrganizationName(const QString & orgName) +TestBindings_EXPORT void +c_static_QCoreApplication__setOrganizationName_QString(const char *orgName_); +// QCoreApplication::setQuitLockEnabled(bool enabled) +TestBindings_EXPORT void c_static_QCoreApplication__setQuitLockEnabled_bool(bool enabled); +// QCoreApplication::setSetuidAllowed(bool allow) +TestBindings_EXPORT void c_static_QCoreApplication__setSetuidAllowed_bool(bool allow); +// QCoreApplication::startingUp() +TestBindings_EXPORT bool c_static_QCoreApplication__startingUp(); +// QCoreApplication::tr(const char * s, const char * c, int n) +TestBindings_EXPORT void *c_static_QCoreApplication__tr_char_char_int(const char *s, const char *c, + int n); +// QCoreApplication::translate(const char * context, const char * key, const char * disambiguation, +// int n) +TestBindings_EXPORT void * +c_static_QCoreApplication__translate_char_char_char_int(const char *context, const char *key, + const char *disambiguation, int n); +TestBindings_EXPORT void c_QCoreApplication__destructor(void *thisObj); +TestBindings_EXPORT void +c_QCoreApplication__registerVirtualMethodCallback(void *ptr, void *callback, int methodId); +TestBindings_EXPORT void c_QCoreApplication_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/QEvent_c.cpp b/tests/generated/TestBindings/dart/ffi/QEvent_c.cpp new file mode 100644 index 0000000..cce7a3a --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/QEvent_c.cpp @@ -0,0 +1,189 @@ +#include "QEvent_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +void QEvent_wrapper::accept() +{ + ::QEvent::accept(); +} +QEvent *QEvent_wrapper::clone() const +{ + if (m_cloneCallback) { + const void *thisPtr = this; + return m_cloneCallback(const_cast(thisPtr)); + } else { + return ::QEvent::clone(); + } +} +QEvent *QEvent_wrapper::clone_nocallback() const +{ + return ::QEvent::clone(); +} +void QEvent_wrapper::ignore() +{ + ::QEvent::ignore(); +} +bool QEvent_wrapper::isAccepted() const +{ + return ::QEvent::isAccepted(); +} +bool QEvent_wrapper::isInputEvent() const +{ + return ::QEvent::isInputEvent(); +} +bool QEvent_wrapper::isPointerEvent() const +{ + return ::QEvent::isPointerEvent(); +} +bool QEvent_wrapper::isSinglePointEvent() const +{ + return ::QEvent::isSinglePointEvent(); +} +int QEvent_wrapper::registerEventType(int hint) +{ + return ::QEvent::registerEventType(hint); +} +void QEvent_wrapper::setAccepted(bool accepted) +{ + if (m_setAcceptedCallback) { + const void *thisPtr = this; + m_setAcceptedCallback(const_cast(thisPtr), accepted); + } else { + ::QEvent::setAccepted(accepted); + } +} +void QEvent_wrapper::setAccepted_nocallback(bool accepted) +{ + ::QEvent::setAccepted(accepted); +} +bool QEvent_wrapper::spontaneous() const +{ + return ::QEvent::spontaneous(); +} +QEvent_wrapper::~QEvent_wrapper() +{ +} + +} +static QEvent *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::QEvent_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_QEvent_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} // accept() +void c_QEvent__accept(void *thisObj) +{ + fromPtr(thisObj)->accept(); +} +// clone() const +void *c_QEvent__clone(void *thisObj) +{ + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->clone_nocallback(); + } else { + return targetPtr->clone(); + } + }(); + return result; +} +// ignore() +void c_QEvent__ignore(void *thisObj) +{ + fromPtr(thisObj)->ignore(); +} +// isAccepted() const +bool c_QEvent__isAccepted(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isAccepted(); + return result; +} +// isInputEvent() const +bool c_QEvent__isInputEvent(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isInputEvent(); + return result; +} +// isPointerEvent() const +bool c_QEvent__isPointerEvent(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isPointerEvent(); + return result; +} +// isSinglePointEvent() const +bool c_QEvent__isSinglePointEvent(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isSinglePointEvent(); + return result; +} +// registerEventType(int hint) +int c_static_QEvent__registerEventType_int(int hint) +{ + const auto &result = TestBindings_wrappersNS::QEvent_wrapper::registerEventType(hint); + return result; +} +// setAccepted(bool accepted) +void c_QEvent__setAccepted_bool(void *thisObj, bool accepted) +{ + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->setAccepted_nocallback(accepted); + } else { + return targetPtr->setAccepted(accepted); + } + }(); +} +// spontaneous() const +bool c_QEvent__spontaneous(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->spontaneous(); + return result; +} +void c_QEvent__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +void c_QEvent__registerVirtualMethodCallback(void *ptr, void *callback, int methodId) +{ + auto wrapper = fromWrapperPtr(ptr); + switch (methodId) { + case 643: + wrapper->m_cloneCallback = + reinterpret_cast(callback); + break; + case 651: + wrapper->m_setAcceptedCallback = + reinterpret_cast( + callback); + break; + } +} +} diff --git a/tests/generated/TestBindings/dart/ffi/QEvent_c.h b/tests/generated/TestBindings/dart/ffi/QEvent_c.h new file mode 100644 index 0000000..1ecaa24 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/QEvent_c.h @@ -0,0 +1,52 @@ +#include "TestBindings_exports.h" +#include + +namespace TestBindings_wrappersNS { +class QEvent_wrapper : public ::QEvent +{ +public: + ~QEvent_wrapper(); + void accept(); + virtual QEvent *clone() const; + virtual QEvent *clone_nocallback() const; + void ignore(); + bool isAccepted() const; + bool isInputEvent() const; + bool isPointerEvent() const; + bool isSinglePointEvent() const; + static int registerEventType(int hint = -1); + virtual void setAccepted(bool accepted); + virtual void setAccepted_nocallback(bool accepted); + bool spontaneous() const; + typedef QEvent *(*Callback_clone)(void *); + Callback_clone m_cloneCallback = nullptr; + typedef void (*Callback_setAccepted)(void *, bool accepted); + Callback_setAccepted m_setAcceptedCallback = nullptr; +}; +} +extern "C" { +// QEvent::accept() +TestBindings_EXPORT void c_QEvent__accept(void *thisObj); +// QEvent::clone() const +TestBindings_EXPORT void *c_QEvent__clone(void *thisObj); +// QEvent::ignore() +TestBindings_EXPORT void c_QEvent__ignore(void *thisObj); +// QEvent::isAccepted() const +TestBindings_EXPORT bool c_QEvent__isAccepted(void *thisObj); +// QEvent::isInputEvent() const +TestBindings_EXPORT bool c_QEvent__isInputEvent(void *thisObj); +// QEvent::isPointerEvent() const +TestBindings_EXPORT bool c_QEvent__isPointerEvent(void *thisObj); +// QEvent::isSinglePointEvent() const +TestBindings_EXPORT bool c_QEvent__isSinglePointEvent(void *thisObj); +// QEvent::registerEventType(int hint) +TestBindings_EXPORT int c_static_QEvent__registerEventType_int(int hint); +// QEvent::setAccepted(bool accepted) +TestBindings_EXPORT void c_QEvent__setAccepted_bool(void *thisObj, bool accepted); +// QEvent::spontaneous() const +TestBindings_EXPORT bool c_QEvent__spontaneous(void *thisObj); +TestBindings_EXPORT void c_QEvent__destructor(void *thisObj); +TestBindings_EXPORT void c_QEvent__registerVirtualMethodCallback(void *ptr, void *callback, + int methodId); +TestBindings_EXPORT void c_QEvent_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/QGuiApplication_c.cpp b/tests/generated/TestBindings/dart/ffi/QGuiApplication_c.cpp new file mode 100644 index 0000000..2d83bb5 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/QGuiApplication_c.cpp @@ -0,0 +1,515 @@ +#include "QGuiApplication_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +QString QGuiApplication_wrapper::applicationDisplayName() +{ + return ::QGuiApplication::applicationDisplayName(); +} +void QGuiApplication_wrapper::applicationDisplayNameChanged() +{ + ::QGuiApplication::applicationDisplayNameChanged(); +} +void QGuiApplication_wrapper::customEvent(QEvent *event) +{ + if (m_customEventCallback) { + const void *thisPtr = this; + m_customEventCallback(const_cast(thisPtr), event); + } else { + ::QGuiApplication::customEvent(event); + } +} +void QGuiApplication_wrapper::customEvent_nocallback(QEvent *event) +{ + ::QGuiApplication::customEvent(event); +} +QString QGuiApplication_wrapper::desktopFileName() +{ + return ::QGuiApplication::desktopFileName(); +} +bool QGuiApplication_wrapper::desktopSettingsAware() +{ + return ::QGuiApplication::desktopSettingsAware(); +} +qreal QGuiApplication_wrapper::devicePixelRatio() const +{ + return ::QGuiApplication::devicePixelRatio(); +} +bool QGuiApplication_wrapper::event(QEvent *arg__1) +{ + if (m_eventCallback) { + const void *thisPtr = this; + return m_eventCallback(const_cast(thisPtr), arg__1); + } else { + return ::QGuiApplication::event(arg__1); + } +} +bool QGuiApplication_wrapper::event_nocallback(QEvent *arg__1) +{ + return ::QGuiApplication::event(arg__1); +} +bool QGuiApplication_wrapper::eventFilter(QObject *watched, QEvent *event) +{ + if (m_eventFilterCallback) { + const void *thisPtr = this; + return m_eventFilterCallback(const_cast(thisPtr), watched, event); + } else { + return ::QGuiApplication::eventFilter(watched, event); + } +} +bool QGuiApplication_wrapper::eventFilter_nocallback(QObject *watched, QEvent *event) +{ + return ::QGuiApplication::eventFilter(watched, event); +} +int QGuiApplication_wrapper::exec() +{ + return ::QGuiApplication::exec(); +} +QObject *QGuiApplication_wrapper::focusObject() +{ + return ::QGuiApplication::focusObject(); +} +void QGuiApplication_wrapper::focusObjectChanged(QObject *focusObject) +{ + ::QGuiApplication::focusObjectChanged(focusObject); +} +void QGuiApplication_wrapper::fontDatabaseChanged() +{ + ::QGuiApplication::fontDatabaseChanged(); +} +bool QGuiApplication_wrapper::isLeftToRight() +{ + return ::QGuiApplication::isLeftToRight(); +} +bool QGuiApplication_wrapper::isRightToLeft() +{ + return ::QGuiApplication::isRightToLeft(); +} +bool QGuiApplication_wrapper::isSavingSession() const +{ + return ::QGuiApplication::isSavingSession(); +} +bool QGuiApplication_wrapper::isSessionRestored() const +{ + return ::QGuiApplication::isSessionRestored(); +} +void QGuiApplication_wrapper::lastWindowClosed() +{ + ::QGuiApplication::lastWindowClosed(); +} +bool QGuiApplication_wrapper::notify(QObject *arg__1, QEvent *arg__2) +{ + if (m_notifyCallback) { + const void *thisPtr = this; + return m_notifyCallback(const_cast(thisPtr), arg__1, arg__2); + } else { + return ::QGuiApplication::notify(arg__1, arg__2); + } +} +bool QGuiApplication_wrapper::notify_nocallback(QObject *arg__1, QEvent *arg__2) +{ + return ::QGuiApplication::notify(arg__1, arg__2); +} +QString QGuiApplication_wrapper::platformName() +{ + return ::QGuiApplication::platformName(); +} +bool QGuiApplication_wrapper::quitOnLastWindowClosed() +{ + return ::QGuiApplication::quitOnLastWindowClosed(); +} +void QGuiApplication_wrapper::restoreOverrideCursor() +{ + ::QGuiApplication::restoreOverrideCursor(); +} +QString QGuiApplication_wrapper::sessionId() const +{ + return ::QGuiApplication::sessionId(); +} +QString QGuiApplication_wrapper::sessionKey() const +{ + return ::QGuiApplication::sessionKey(); +} +void QGuiApplication_wrapper::setApplicationDisplayName(const QString &name) +{ + ::QGuiApplication::setApplicationDisplayName(name); +} +void QGuiApplication_wrapper::setDesktopFileName(const QString &name) +{ + ::QGuiApplication::setDesktopFileName(name); +} +void QGuiApplication_wrapper::setDesktopSettingsAware(bool on) +{ + ::QGuiApplication::setDesktopSettingsAware(on); +} +void QGuiApplication_wrapper::setQuitOnLastWindowClosed(bool quit) +{ + ::QGuiApplication::setQuitOnLastWindowClosed(quit); +} +void QGuiApplication_wrapper::sync() +{ + ::QGuiApplication::sync(); +} +QString QGuiApplication_wrapper::tr(const char *s, const char *c, int n) +{ + return ::QGuiApplication::tr(s, c, n); +} +QGuiApplication_wrapper::~QGuiApplication_wrapper() +{ +} + +} +static QGuiApplication *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::QGuiApplication_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_QGuiApplication_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} // applicationDisplayName() +void *c_static_QGuiApplication__applicationDisplayName() +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QGuiApplication_wrapper::applicationDisplayName() + }; + return result; +} +// applicationDisplayNameChanged() +void c_QGuiApplication__applicationDisplayNameChanged(void *thisObj) +{ + fromPtr(thisObj)->applicationDisplayNameChanged(); +} +void c_QGuiApplication__onApplicationDisplayNameChanged(void *thisObj, void *contextQObject, + void *callback) +{ + auto instance = reinterpret_cast(thisObj); + auto context = reinterpret_cast(contextQObject); + QObject::connect(instance, &QGuiApplication::applicationDisplayNameChanged, + context ? context : instance, [thisObj, callback] { + typedef void (*SignalHandler_callback)(void *); + auto dartCallback = reinterpret_cast(callback); + dartCallback(thisObj); + }); +} +void c_QGuiApplication__onApplicationNameChanged(void *thisObj, void *contextQObject, + void *callback) +{ + auto instance = reinterpret_cast(thisObj); + auto context = reinterpret_cast(contextQObject); + QObject::connect(instance, &QGuiApplication::applicationNameChanged, + context ? context : instance, [thisObj, callback] { + typedef void (*SignalHandler_callback)(void *); + auto dartCallback = reinterpret_cast(callback); + dartCallback(thisObj); + }); +} +void c_QGuiApplication__onApplicationVersionChanged(void *thisObj, void *contextQObject, + void *callback) +{ + auto instance = reinterpret_cast(thisObj); + auto context = reinterpret_cast(contextQObject); + QObject::connect(instance, &QGuiApplication::applicationVersionChanged, + context ? context : instance, [thisObj, callback] { + typedef void (*SignalHandler_callback)(void *); + auto dartCallback = reinterpret_cast(callback); + dartCallback(thisObj); + }); +} +// customEvent(QEvent * event) +void c_QGuiApplication__customEvent_QEvent(void *thisObj, void *event_) +{ + auto event = reinterpret_cast(event_); + fromWrapperPtr(thisObj)->customEvent_nocallback(event); +} +// desktopFileName() +void *c_static_QGuiApplication__desktopFileName() +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QGuiApplication_wrapper::desktopFileName() + }; + return result; +} +// desktopSettingsAware() +bool c_static_QGuiApplication__desktopSettingsAware() +{ + const auto &result = TestBindings_wrappersNS::QGuiApplication_wrapper::desktopSettingsAware(); + return result; +} +// devicePixelRatio() const +qreal c_QGuiApplication__devicePixelRatio(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->devicePixelRatio(); + return result; +} +// event(QEvent * arg__1) +bool c_QGuiApplication__event_QEvent(void *thisObj, void *arg__1_) +{ + auto arg__1 = reinterpret_cast(arg__1_); + const auto &result = fromWrapperPtr(thisObj)->event_nocallback(arg__1); + return result; +} +// eventFilter(QObject * watched, QEvent * event) +bool c_QGuiApplication__eventFilter_QObject_QEvent(void *thisObj, void *watched_, void *event_) +{ + auto watched = reinterpret_cast(watched_); + auto event = reinterpret_cast(event_); + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->eventFilter_nocallback(watched, event); + } else { + return targetPtr->eventFilter(watched, event); + } + }(); + return result; +} +// exec() +int c_static_QGuiApplication__exec() +{ + const auto &result = TestBindings_wrappersNS::QGuiApplication_wrapper::exec(); + return result; +} +// focusObject() +void *c_static_QGuiApplication__focusObject() +{ + const auto &result = TestBindings_wrappersNS::QGuiApplication_wrapper::focusObject(); + return result; +} +// focusObjectChanged(QObject * focusObject) +void c_QGuiApplication__focusObjectChanged_QObject(void *thisObj, void *focusObject_) +{ + auto focusObject = reinterpret_cast(focusObject_); + fromPtr(thisObj)->focusObjectChanged(focusObject); +} +void c_QGuiApplication__onFocusObjectChanged_QObject(void *thisObj, void *contextQObject, + void *callback) +{ + auto instance = reinterpret_cast(thisObj); + auto context = reinterpret_cast(contextQObject); + QObject::connect(instance, &QGuiApplication::focusObjectChanged, context ? context : instance, + [thisObj, callback] { + typedef void (*SignalHandler_callback)(void *); + auto dartCallback = reinterpret_cast(callback); + dartCallback(thisObj); + }); +} +// fontDatabaseChanged() +void c_QGuiApplication__fontDatabaseChanged(void *thisObj) +{ + fromPtr(thisObj)->fontDatabaseChanged(); +} +void c_QGuiApplication__onFontDatabaseChanged(void *thisObj, void *contextQObject, void *callback) +{ + auto instance = reinterpret_cast(thisObj); + auto context = reinterpret_cast(contextQObject); + QObject::connect(instance, &QGuiApplication::fontDatabaseChanged, context ? context : instance, + [thisObj, callback] { + typedef void (*SignalHandler_callback)(void *); + auto dartCallback = reinterpret_cast(callback); + dartCallback(thisObj); + }); +} +// isLeftToRight() +bool c_static_QGuiApplication__isLeftToRight() +{ + const auto &result = TestBindings_wrappersNS::QGuiApplication_wrapper::isLeftToRight(); + return result; +} +// isRightToLeft() +bool c_static_QGuiApplication__isRightToLeft() +{ + const auto &result = TestBindings_wrappersNS::QGuiApplication_wrapper::isRightToLeft(); + return result; +} +// isSavingSession() const +bool c_QGuiApplication__isSavingSession(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isSavingSession(); + return result; +} +// isSessionRestored() const +bool c_QGuiApplication__isSessionRestored(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isSessionRestored(); + return result; +} +// lastWindowClosed() +void c_QGuiApplication__lastWindowClosed(void *thisObj) +{ + fromPtr(thisObj)->lastWindowClosed(); +} +void c_QGuiApplication__onLastWindowClosed(void *thisObj, void *contextQObject, void *callback) +{ + auto instance = reinterpret_cast(thisObj); + auto context = reinterpret_cast(contextQObject); + QObject::connect(instance, &QGuiApplication::lastWindowClosed, context ? context : instance, + [thisObj, callback] { + typedef void (*SignalHandler_callback)(void *); + auto dartCallback = reinterpret_cast(callback); + dartCallback(thisObj); + }); +} +// notify(QObject * arg__1, QEvent * arg__2) +bool c_QGuiApplication__notify_QObject_QEvent(void *thisObj, void *arg__1_, void *arg__2_) +{ + auto arg__1 = reinterpret_cast(arg__1_); + auto arg__2 = reinterpret_cast(arg__2_); + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = + dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->notify_nocallback(arg__1, arg__2); + } else { + return targetPtr->notify(arg__1, arg__2); + } + }(); + return result; +} +void c_QGuiApplication__onOrganizationDomainChanged(void *thisObj, void *contextQObject, + void *callback) +{ + auto instance = reinterpret_cast(thisObj); + auto context = reinterpret_cast(contextQObject); + QObject::connect(instance, &QGuiApplication::organizationDomainChanged, + context ? context : instance, [thisObj, callback] { + typedef void (*SignalHandler_callback)(void *); + auto dartCallback = reinterpret_cast(callback); + dartCallback(thisObj); + }); +} +void c_QGuiApplication__onOrganizationNameChanged(void *thisObj, void *contextQObject, + void *callback) +{ + auto instance = reinterpret_cast(thisObj); + auto context = reinterpret_cast(contextQObject); + QObject::connect(instance, &QGuiApplication::organizationNameChanged, + context ? context : instance, [thisObj, callback] { + typedef void (*SignalHandler_callback)(void *); + auto dartCallback = reinterpret_cast(callback); + dartCallback(thisObj); + }); +} +// platformName() +void *c_static_QGuiApplication__platformName() +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QGuiApplication_wrapper::platformName() + }; + return result; +} +// quitOnLastWindowClosed() +bool c_static_QGuiApplication__quitOnLastWindowClosed() +{ + const auto &result = TestBindings_wrappersNS::QGuiApplication_wrapper::quitOnLastWindowClosed(); + return result; +} +// restoreOverrideCursor() +void c_static_QGuiApplication__restoreOverrideCursor() +{ + TestBindings_wrappersNS::QGuiApplication_wrapper::restoreOverrideCursor(); +} +// sessionId() const +void *c_QGuiApplication__sessionId(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->sessionId() }; + return result; +} +// sessionKey() const +void *c_QGuiApplication__sessionKey(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->sessionKey() }; + return result; +} +// setApplicationDisplayName(const QString & name) +void c_static_QGuiApplication__setApplicationDisplayName_QString(const char *name_) +{ + const auto name = QString::fromUtf8(name_); + TestBindings_wrappersNS::QGuiApplication_wrapper::setApplicationDisplayName(name); + free(( char * )name_); +} +// setDesktopFileName(const QString & name) +void c_static_QGuiApplication__setDesktopFileName_QString(const char *name_) +{ + const auto name = QString::fromUtf8(name_); + TestBindings_wrappersNS::QGuiApplication_wrapper::setDesktopFileName(name); + free(( char * )name_); +} +// setDesktopSettingsAware(bool on) +void c_static_QGuiApplication__setDesktopSettingsAware_bool(bool on) +{ + TestBindings_wrappersNS::QGuiApplication_wrapper::setDesktopSettingsAware(on); +} +// setQuitOnLastWindowClosed(bool quit) +void c_static_QGuiApplication__setQuitOnLastWindowClosed_bool(bool quit) +{ + TestBindings_wrappersNS::QGuiApplication_wrapper::setQuitOnLastWindowClosed(quit); +} +// sync() +void c_static_QGuiApplication__sync() +{ + TestBindings_wrappersNS::QGuiApplication_wrapper::sync(); +} +// tr(const char * s, const char * c, int n) +void *c_static_QGuiApplication__tr_char_char_int(const char *s, const char *c, int n) +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QGuiApplication_wrapper::tr(s, c, n) + }; + free(( char * )s); + free(( char * )c); + return result; +} +void c_QGuiApplication__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +void c_QGuiApplication__registerVirtualMethodCallback(void *ptr, void *callback, int methodId) +{ + auto wrapper = fromWrapperPtr(ptr); + switch (methodId) { + case 481: + wrapper->m_customEventCallback = reinterpret_cast< + TestBindings_wrappersNS::QGuiApplication_wrapper::Callback_customEvent>(callback); + break; + case 490: + wrapper->m_eventCallback = + reinterpret_cast( + callback); + break; + case 491: + wrapper->m_eventFilterCallback = reinterpret_cast< + TestBindings_wrappersNS::QGuiApplication_wrapper::Callback_eventFilter>(callback); + break; + case 688: + wrapper->m_notifyCallback = + reinterpret_cast( + callback); + break; + } +} +} diff --git a/tests/generated/TestBindings/dart/ffi/QGuiApplication_c.h b/tests/generated/TestBindings/dart/ffi/QGuiApplication_c.h new file mode 100644 index 0000000..792d670 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/QGuiApplication_c.h @@ -0,0 +1,134 @@ +#include "TestBindings_exports.h" +#include +#include +#include +#include +#include +#include + +namespace TestBindings_wrappersNS { +class QGuiApplication_wrapper : public ::QGuiApplication +{ +public: + ~QGuiApplication_wrapper(); + static QString applicationDisplayName(); + void applicationDisplayNameChanged(); + virtual void customEvent(QEvent *event); + virtual void customEvent_nocallback(QEvent *event); + static QString desktopFileName(); + static bool desktopSettingsAware(); + qreal devicePixelRatio() const; + virtual bool event(QEvent *arg__1); + virtual bool event_nocallback(QEvent *arg__1); + virtual bool eventFilter(QObject *watched, QEvent *event); + virtual bool eventFilter_nocallback(QObject *watched, QEvent *event); + static int exec(); + static QObject *focusObject(); + void focusObjectChanged(QObject *focusObject); + void fontDatabaseChanged(); + static bool isLeftToRight(); + static bool isRightToLeft(); + bool isSavingSession() const; + bool isSessionRestored() const; + void lastWindowClosed(); + virtual bool notify(QObject *arg__1, QEvent *arg__2); + virtual bool notify_nocallback(QObject *arg__1, QEvent *arg__2); + static QString platformName(); + static bool quitOnLastWindowClosed(); + static void restoreOverrideCursor(); + QString sessionId() const; + QString sessionKey() const; + static void setApplicationDisplayName(const QString &name); + static void setDesktopFileName(const QString &name); + static void setDesktopSettingsAware(bool on); + static void setQuitOnLastWindowClosed(bool quit); + static void sync(); + static QString tr(const char *s, const char *c, int n); + typedef void (*Callback_customEvent)(void *, QEvent *event); + Callback_customEvent m_customEventCallback = nullptr; + typedef bool (*Callback_event)(void *, QEvent *arg__1); + Callback_event m_eventCallback = nullptr; + typedef bool (*Callback_eventFilter)(void *, QObject *watched, QEvent *event); + Callback_eventFilter m_eventFilterCallback = nullptr; + typedef bool (*Callback_notify)(void *, QObject *arg__1, QEvent *arg__2); + Callback_notify m_notifyCallback = nullptr; +}; +} +extern "C" { +// QGuiApplication::applicationDisplayName() +TestBindings_EXPORT void *c_static_QGuiApplication__applicationDisplayName(); +// QGuiApplication::applicationDisplayNameChanged() +TestBindings_EXPORT void c_QGuiApplication__applicationDisplayNameChanged(void *thisObj); +TestBindings_EXPORT void +c_QGuiApplication__onApplicationDisplayNameChanged(void *thisObj, void *contextQObject, + void *callback); // QGuiApplication::customEvent(QEvent + // * event) +TestBindings_EXPORT void c_QGuiApplication__customEvent_QEvent(void *thisObj, void *event_); +// QGuiApplication::desktopFileName() +TestBindings_EXPORT void *c_static_QGuiApplication__desktopFileName(); +// QGuiApplication::desktopSettingsAware() +TestBindings_EXPORT bool c_static_QGuiApplication__desktopSettingsAware(); +// QGuiApplication::devicePixelRatio() const +TestBindings_EXPORT qreal c_QGuiApplication__devicePixelRatio(void *thisObj); +// QGuiApplication::event(QEvent * arg__1) +TestBindings_EXPORT bool c_QGuiApplication__event_QEvent(void *thisObj, void *arg__1_); +// QGuiApplication::eventFilter(QObject * watched, QEvent * event) +TestBindings_EXPORT bool +c_QGuiApplication__eventFilter_QObject_QEvent(void *thisObj, void *watched_, void *event_); +// QGuiApplication::exec() +TestBindings_EXPORT int c_static_QGuiApplication__exec(); +// QGuiApplication::focusObject() +TestBindings_EXPORT void *c_static_QGuiApplication__focusObject(); +// QGuiApplication::focusObjectChanged(QObject * focusObject) +TestBindings_EXPORT void c_QGuiApplication__focusObjectChanged_QObject(void *thisObj, + void *focusObject_); +TestBindings_EXPORT void c_QGuiApplication__onFocusObjectChanged_QObject( + void *thisObj, void *contextQObject, void *callback); // QGuiApplication::fontDatabaseChanged() +TestBindings_EXPORT void c_QGuiApplication__fontDatabaseChanged(void *thisObj); +TestBindings_EXPORT void +c_QGuiApplication__onFontDatabaseChanged(void *thisObj, void *contextQObject, + void *callback); // QGuiApplication::isLeftToRight() +TestBindings_EXPORT bool c_static_QGuiApplication__isLeftToRight(); +// QGuiApplication::isRightToLeft() +TestBindings_EXPORT bool c_static_QGuiApplication__isRightToLeft(); +// QGuiApplication::isSavingSession() const +TestBindings_EXPORT bool c_QGuiApplication__isSavingSession(void *thisObj); +// QGuiApplication::isSessionRestored() const +TestBindings_EXPORT bool c_QGuiApplication__isSessionRestored(void *thisObj); +// QGuiApplication::lastWindowClosed() +TestBindings_EXPORT void c_QGuiApplication__lastWindowClosed(void *thisObj); +TestBindings_EXPORT void c_QGuiApplication__onLastWindowClosed(void *thisObj, void *contextQObject, + void *callback); // QGuiApplication::notify(QObject + // * arg__1, QEvent + // * arg__2) +TestBindings_EXPORT bool c_QGuiApplication__notify_QObject_QEvent(void *thisObj, void *arg__1_, + void *arg__2_); +// QGuiApplication::platformName() +TestBindings_EXPORT void *c_static_QGuiApplication__platformName(); +// QGuiApplication::quitOnLastWindowClosed() +TestBindings_EXPORT bool c_static_QGuiApplication__quitOnLastWindowClosed(); +// QGuiApplication::restoreOverrideCursor() +TestBindings_EXPORT void c_static_QGuiApplication__restoreOverrideCursor(); +// QGuiApplication::sessionId() const +TestBindings_EXPORT void *c_QGuiApplication__sessionId(void *thisObj); +// QGuiApplication::sessionKey() const +TestBindings_EXPORT void *c_QGuiApplication__sessionKey(void *thisObj); +// QGuiApplication::setApplicationDisplayName(const QString & name) +TestBindings_EXPORT void +c_static_QGuiApplication__setApplicationDisplayName_QString(const char *name_); +// QGuiApplication::setDesktopFileName(const QString & name) +TestBindings_EXPORT void c_static_QGuiApplication__setDesktopFileName_QString(const char *name_); +// QGuiApplication::setDesktopSettingsAware(bool on) +TestBindings_EXPORT void c_static_QGuiApplication__setDesktopSettingsAware_bool(bool on); +// QGuiApplication::setQuitOnLastWindowClosed(bool quit) +TestBindings_EXPORT void c_static_QGuiApplication__setQuitOnLastWindowClosed_bool(bool quit); +// QGuiApplication::sync() +TestBindings_EXPORT void c_static_QGuiApplication__sync(); +// QGuiApplication::tr(const char * s, const char * c, int n) +TestBindings_EXPORT void *c_static_QGuiApplication__tr_char_char_int(const char *s, const char *c, + int n); +TestBindings_EXPORT void c_QGuiApplication__destructor(void *thisObj); +TestBindings_EXPORT void c_QGuiApplication__registerVirtualMethodCallback(void *ptr, void *callback, + int methodId); +TestBindings_EXPORT void c_QGuiApplication_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/QHash_c.cpp b/tests/generated/TestBindings/dart/ffi/QHash_c.cpp new file mode 100644 index 0000000..0f5dc31 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/QHash_c.cpp @@ -0,0 +1,356 @@ +#include "QHash_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +template +QHash_wrapper::QHash_wrapper() + : ::QHash() +{ +} +template +qsizetype QHash_wrapper::capacity() const +{ + return ::QHash::capacity(); +} +template +void QHash_wrapper::clear() +{ + ::QHash::clear(); +} +template +bool QHash_wrapper::contains(const Key &key) const +{ + return ::QHash::contains(key); +} +template +qsizetype QHash_wrapper::count() const +{ + return ::QHash::count(); +} +template +qsizetype QHash_wrapper::count(const Key &key) const +{ + return ::QHash::count(key); +} +template +void QHash_wrapper::detach() +{ + ::QHash::detach(); +} +template +bool QHash_wrapper::empty() const +{ + return ::QHash::empty(); +} +template +void QHash_wrapper::insert(const QHash &hash) +{ + ::QHash::insert(hash); +} +template +bool QHash_wrapper::isDetached() const +{ + return ::QHash::isDetached(); +} +template +bool QHash_wrapper::isEmpty() const +{ + return ::QHash::isEmpty(); +} +template +bool QHash_wrapper::isSharedWith(const QHash &other) const +{ + return ::QHash::isSharedWith(other); +} +template +Key QHash_wrapper::key(const T &value) const +{ + return ::QHash::key(value); +} +template +Key QHash_wrapper::key(const T &value, const Key &defaultKey) const +{ + return ::QHash::key(value, defaultKey); +} +template +QList QHash_wrapper::keys() const +{ + return ::QHash::keys(); +} +template +QList QHash_wrapper::keys(const T &value) const +{ + return ::QHash::keys(value); +} +template +float QHash_wrapper::load_factor() const +{ + return ::QHash::load_factor(); +} +template +bool QHash_wrapper::remove(const Key &key) +{ + return ::QHash::remove(key); +} +template +void QHash_wrapper::reserve(qsizetype size) +{ + ::QHash::reserve(size); +} +template +qsizetype QHash_wrapper::size() const +{ + return ::QHash::size(); +} +template +void QHash_wrapper::squeeze() +{ + ::QHash::squeeze(); +} +template +T QHash_wrapper::take(const Key &key) +{ + return ::QHash::take(key); +} +template +T QHash_wrapper::value(const Key &key) const +{ + return ::QHash::value(key); +} +template +T QHash_wrapper::value(const Key &key, const T &defaultValue) const +{ + return ::QHash::value(key, defaultValue); +} +template +QList QHash_wrapper::values() const +{ + return ::QHash::values(); +} +template +QHash_wrapper::~QHash_wrapper() +{ +} + +} +template +static QHash *fromPtr(void *ptr) +{ + return reinterpret_cast *>(ptr); +} +template +static TestBindings_wrappersNS::QHash_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast *>(ptr); +} +extern "C" { +void c_QHash_T_QString_QVariant_T__Finalizer(void *cppObj) +{ + delete reinterpret_cast *>(cppObj); +} +void *c_QHash_T_QString_QVariant_T___constructor() +{ + auto ptr = new TestBindings_wrappersNS::QHash_wrapper(); + return reinterpret_cast(ptr); +} +// capacity() const +qsizetype c_QHash_T_QString_QVariant_T___capacity(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->capacity(); + return result; +} +// clear() +void c_QHash_T_QString_QVariant_T___clear(void *thisObj) +{ + fromPtr(thisObj)->clear(); +} +// contains(const Key & key) const +bool c_QHash_T_QString_QVariant_T___contains_QString(void *thisObj, const char *key_) +{ + const auto key = QString::fromUtf8(key_); + const auto &result = fromPtr(thisObj)->contains(key); + free(( char * )key_); + return result; +} +// count() const +qsizetype c_QHash_T_QString_QVariant_T___count(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->count(); + return result; +} +// count(const Key & key) const +qsizetype c_QHash_T_QString_QVariant_T___count_QString(void *thisObj, const char *key_) +{ + const auto key = QString::fromUtf8(key_); + const auto &result = fromPtr(thisObj)->count(key); + free(( char * )key_); + return result; +} +// detach() +void c_QHash_T_QString_QVariant_T___detach(void *thisObj) +{ + fromPtr(thisObj)->detach(); +} +// empty() const +bool c_QHash_T_QString_QVariant_T___empty(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->empty(); + return result; +} +// insert(const QHash & hash) +void c_QHash_T_QString_QVariant_T___insert_QHash_Key_T(void *thisObj, void *hash_) +{ + assert(hash_); + auto &hash = *reinterpret_cast *>(hash_); + fromPtr(thisObj)->insert(hash); +} +// isDetached() const +bool c_QHash_T_QString_QVariant_T___isDetached(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isDetached(); + return result; +} +// isEmpty() const +bool c_QHash_T_QString_QVariant_T___isEmpty(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isEmpty(); + return result; +} +// isSharedWith(const QHash & other) const +bool c_QHash_T_QString_QVariant_T___isSharedWith_QHash_Key_T(void *thisObj, void *other_) +{ + assert(other_); + auto &other = *reinterpret_cast *>(other_); + const auto &result = fromPtr(thisObj)->isSharedWith(other); + return result; +} +// key(const T & value) const +void *c_QHash_T_QString_QVariant_T___key_QVariant(void *thisObj, void *value_) +{ + assert(value_); + auto &value = *reinterpret_cast(value_); + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->key(value) }; + return result; +} +// key(const T & value, const Key & defaultKey) const +void *c_QHash_T_QString_QVariant_T___key_QVariant_QString(void *thisObj, void *value_, + const char *defaultKey_) +{ + assert(value_); + auto &value = *reinterpret_cast(value_); + const auto defaultKey = QString::fromUtf8(defaultKey_); + const auto &result = new Dartagnan::ValueWrapper { + fromPtr(thisObj)->key(value, defaultKey) + }; + free(( char * )defaultKey_); + return result; +} +// keys() const +void *c_QHash_T_QString_QVariant_T___keys(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->keys() }; + return result; +} +// keys(const T & value) const +void *c_QHash_T_QString_QVariant_T___keys_QVariant(void *thisObj, void *value_) +{ + assert(value_); + auto &value = *reinterpret_cast(value_); + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->keys(value) + }; + return result; +} +// load_factor() const +float c_QHash_T_QString_QVariant_T___load_factor(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->load_factor(); + return result; +} +// remove(const Key & key) +bool c_QHash_T_QString_QVariant_T___remove_QString(void *thisObj, const char *key_) +{ + const auto key = QString::fromUtf8(key_); + const auto &result = fromPtr(thisObj)->remove(key); + free(( char * )key_); + return result; +} +// reserve(qsizetype size) +void c_QHash_T_QString_QVariant_T___reserve_qsizetype(void *thisObj, qsizetype size) +{ + fromPtr(thisObj)->reserve(size); +} +// size() const +qsizetype c_QHash_T_QString_QVariant_T___size(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->size(); + return result; +} +// squeeze() +void c_QHash_T_QString_QVariant_T___squeeze(void *thisObj) +{ + fromPtr(thisObj)->squeeze(); +} +// take(const Key & key) +void *c_QHash_T_QString_QVariant_T___take_QString(void *thisObj, const char *key_) +{ + const auto key = QString::fromUtf8(key_); + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->take(key) }; + free(( char * )key_); + return result; +} +// value(const Key & key) const +void *c_QHash_T_QString_QVariant_T___value_QString(void *thisObj, const char *key_) +{ + const auto key = QString::fromUtf8(key_); + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->value(key) }; + free(( char * )key_); + return result; +} +// value(const Key & key, const T & defaultValue) const +void *c_QHash_T_QString_QVariant_T___value_QString_QVariant(void *thisObj, const char *key_, + void *defaultValue_) +{ + const auto key = QString::fromUtf8(key_); + assert(defaultValue_); + auto &defaultValue = *reinterpret_cast(defaultValue_); + const auto &result = new Dartagnan::ValueWrapper { + fromPtr(thisObj)->value(key, defaultValue) + }; + free(( char * )key_); + return result; +} +// values() const +void *c_QHash_T_QString_QVariant_T___values(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->values() + }; + return result; +} +void c_QHash_T_QString_QVariant_T___destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} diff --git a/tests/generated/TestBindings/dart/ffi/QHash_c.h b/tests/generated/TestBindings/dart/ffi/QHash_c.h new file mode 100644 index 0000000..ba8dbee --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/QHash_c.h @@ -0,0 +1,108 @@ +#include "TestBindings_exports.h" +#include +#include +#include +#include +#include +#include +#include + +namespace TestBindings_wrappersNS { +template +class QHash_wrapper : public ::QHash +{ +public: + ~QHash_wrapper(); + QHash_wrapper(); + qsizetype capacity() const; + void clear(); + bool contains(const Key &key) const; + qsizetype count() const; + qsizetype count(const Key &key) const; + void detach(); + bool empty() const; + void insert(const QHash &hash); + bool isDetached() const; + bool isEmpty() const; + bool isSharedWith(const QHash &other) const; + Key key(const T &value) const; + Key key(const T &value, const Key &defaultKey) const; + QList keys() const; + QList keys(const T &value) const; + float load_factor() const; + bool remove(const Key &key); + void reserve(qsizetype size); + qsizetype size() const; + void squeeze(); + T take(const Key &key); + T value(const Key &key) const; + T value(const Key &key, const T &defaultValue) const; + QList values() const; +}; +} +extern "C" { +// QHash::QHash() +TestBindings_EXPORT void *c_QHash_T_QString_QVariant_T___constructor(); +// QHash::capacity() const +TestBindings_EXPORT qsizetype c_QHash_T_QString_QVariant_T___capacity(void *thisObj); +// QHash::clear() +TestBindings_EXPORT void c_QHash_T_QString_QVariant_T___clear(void *thisObj); +// QHash::contains(const Key & key) const +TestBindings_EXPORT bool c_QHash_T_QString_QVariant_T___contains_QString(void *thisObj, + const char *key_); +// QHash::count() const +TestBindings_EXPORT qsizetype c_QHash_T_QString_QVariant_T___count(void *thisObj); +// QHash::count(const Key & key) const +TestBindings_EXPORT qsizetype c_QHash_T_QString_QVariant_T___count_QString(void *thisObj, + const char *key_); +// QHash::detach() +TestBindings_EXPORT void c_QHash_T_QString_QVariant_T___detach(void *thisObj); +// QHash::empty() const +TestBindings_EXPORT bool c_QHash_T_QString_QVariant_T___empty(void *thisObj); +// QHash::insert(const QHash & hash) +TestBindings_EXPORT void c_QHash_T_QString_QVariant_T___insert_QHash_Key_T(void *thisObj, + void *hash_); +// QHash::isDetached() const +TestBindings_EXPORT bool c_QHash_T_QString_QVariant_T___isDetached(void *thisObj); +// QHash::isEmpty() const +TestBindings_EXPORT bool c_QHash_T_QString_QVariant_T___isEmpty(void *thisObj); +// QHash::isSharedWith(const QHash & other) const +TestBindings_EXPORT bool c_QHash_T_QString_QVariant_T___isSharedWith_QHash_Key_T(void *thisObj, + void *other_); +// QHash::key(const T & value) const +TestBindings_EXPORT void *c_QHash_T_QString_QVariant_T___key_QVariant(void *thisObj, void *value_); +// QHash::key(const T & value, const Key & defaultKey) const +TestBindings_EXPORT void * +c_QHash_T_QString_QVariant_T___key_QVariant_QString(void *thisObj, void *value_, + const char *defaultKey_); +// QHash::keys() const +TestBindings_EXPORT void *c_QHash_T_QString_QVariant_T___keys(void *thisObj); +// QHash::keys(const T & value) const +TestBindings_EXPORT void *c_QHash_T_QString_QVariant_T___keys_QVariant(void *thisObj, void *value_); +// QHash::load_factor() const +TestBindings_EXPORT float c_QHash_T_QString_QVariant_T___load_factor(void *thisObj); +// QHash::remove(const Key & key) +TestBindings_EXPORT bool c_QHash_T_QString_QVariant_T___remove_QString(void *thisObj, + const char *key_); +// QHash::reserve(qsizetype size) +TestBindings_EXPORT void c_QHash_T_QString_QVariant_T___reserve_qsizetype(void *thisObj, + qsizetype size); +// QHash::size() const +TestBindings_EXPORT qsizetype c_QHash_T_QString_QVariant_T___size(void *thisObj); +// QHash::squeeze() +TestBindings_EXPORT void c_QHash_T_QString_QVariant_T___squeeze(void *thisObj); +// QHash::take(const Key & key) +TestBindings_EXPORT void *c_QHash_T_QString_QVariant_T___take_QString(void *thisObj, + const char *key_); +// QHash::value(const Key & key) const +TestBindings_EXPORT void *c_QHash_T_QString_QVariant_T___value_QString(void *thisObj, + const char *key_); +// QHash::value(const Key & key, const T & defaultValue) const +TestBindings_EXPORT void * +c_QHash_T_QString_QVariant_T___value_QString_QVariant(void *thisObj, const char *key_, + void *defaultValue_); +// QHash::values() const +TestBindings_EXPORT void *c_QHash_T_QString_QVariant_T___values(void *thisObj); +TestBindings_EXPORT void c_QHash_T_QString_QVariant_T___destructor(void *thisObj); +TestBindings_EXPORT void c_QHash_T_QString_QVariant_T__Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/QList_c.cpp b/tests/generated/TestBindings/dart/ffi/QList_c.cpp new file mode 100644 index 0000000..c30d526 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/QList_c.cpp @@ -0,0 +1,2293 @@ +#include "QList_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +template +QList_wrapper::QList_wrapper() + : ::QList() +{ +} +template +QList_wrapper::QList_wrapper(qsizetype size) + : ::QList(size) +{ +} +template +void QList_wrapper::append(const QList &l) +{ + ::QList::append(l); +} +template +const T &QList_wrapper::at(qsizetype i) const +{ + return ::QList::at(i); +} +template +T &QList_wrapper::back() +{ + return ::QList::back(); +} +template +qsizetype QList_wrapper::capacity() const +{ + return ::QList::capacity(); +} +template +void QList_wrapper::clear() +{ + ::QList::clear(); +} +template +const T &QList_wrapper::constFirst() const +{ + return ::QList::constFirst(); +} +template +const T &QList_wrapper::constLast() const +{ + return ::QList::constLast(); +} +template +qsizetype QList_wrapper::count() const +{ + return ::QList::count(); +} +template +void QList_wrapper::detach() +{ + ::QList::detach(); +} +template +bool QList_wrapper::empty() const +{ + return ::QList::empty(); +} +template +T &QList_wrapper::first() +{ + return ::QList::first(); +} +template +QList QList_wrapper::first(qsizetype n) const +{ + return ::QList::first(n); +} +template +T &QList_wrapper::front() +{ + return ::QList::front(); +} +template +bool QList_wrapper::isDetached() const +{ + return ::QList::isDetached(); +} +template +bool QList_wrapper::isEmpty() const +{ + return ::QList::isEmpty(); +} +template +bool QList_wrapper::isSharedWith(const QList &other) const +{ + return ::QList::isSharedWith(other); +} +template +T &QList_wrapper::last() +{ + return ::QList::last(); +} +template +QList QList_wrapper::last(qsizetype n) const +{ + return ::QList::last(n); +} +template +qsizetype QList_wrapper::length() const +{ + return ::QList::length(); +} +template +QList QList_wrapper::mid(qsizetype pos, qsizetype len) const +{ + return ::QList::mid(pos, len); +} +template +void QList_wrapper::move(qsizetype from, qsizetype to) +{ + ::QList::move(from, to); +} +template +void QList_wrapper::pop_back() +{ + ::QList::pop_back(); +} +template +void QList_wrapper::pop_front() +{ + ::QList::pop_front(); +} +template +void QList_wrapper::remove(qsizetype i, qsizetype n) +{ + ::QList::remove(i, n); +} +template +void QList_wrapper::removeAt(qsizetype i) +{ + ::QList::removeAt(i); +} +template +void QList_wrapper::removeFirst() +{ + ::QList::removeFirst(); +} +template +void QList_wrapper::removeLast() +{ + ::QList::removeLast(); +} +template +void QList_wrapper::reserve(qsizetype size) +{ + ::QList::reserve(size); +} +template +void QList_wrapper::resize(qsizetype size) +{ + ::QList::resize(size); +} +template +void QList_wrapper::shrink_to_fit() +{ + ::QList::shrink_to_fit(); +} +template +qsizetype QList_wrapper::size() const +{ + return ::QList::size(); +} +template +QList QList_wrapper::sliced(qsizetype pos) const +{ + return ::QList::sliced(pos); +} +template +QList QList_wrapper::sliced(qsizetype pos, qsizetype n) const +{ + return ::QList::sliced(pos, n); +} +template +void QList_wrapper::squeeze() +{ + ::QList::squeeze(); +} +template +void QList_wrapper::swapItemsAt(qsizetype i, qsizetype j) +{ + ::QList::swapItemsAt(i, j); +} +template +T QList_wrapper::takeAt(qsizetype i) +{ + return ::QList::takeAt(i); +} +template +QList QList_wrapper::toList() const +{ + return ::QList::toList(); +} +template +QList QList_wrapper::toVector() const +{ + return ::QList::toVector(); +} +template +T QList_wrapper::value(qsizetype i) const +{ + return ::QList::value(i); +} +template +QList_wrapper::~QList_wrapper() +{ +} + +} +template +static QList *fromPtr(void *ptr) +{ + return reinterpret_cast *>(ptr); +} +template +static TestBindings_wrappersNS::QList_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast *>(ptr); +} +extern "C" { +void c_QList_T_SimpleStruct_T__Finalizer(void *cppObj) +{ + delete reinterpret_cast *>(cppObj); +} +void *c_QList_T_SimpleStruct_T___constructor() +{ + auto ptr = new TestBindings_wrappersNS::QList_wrapper(); + return reinterpret_cast(ptr); +} +void *c_QList_T_SimpleStruct_T___constructor_qsizetype(qsizetype size) +{ + auto ptr = new TestBindings_wrappersNS::QList_wrapper(size); + return reinterpret_cast(ptr); +} +// append(const QList & l) +void c_QList_T_SimpleStruct_T___append_QList_T(void *thisObj, void *l_) +{ + assert(l_); + auto &l = *reinterpret_cast *>(l_); + fromPtr(thisObj)->append(l); +} +// at(qsizetype i) const +const void *c_QList_T_SimpleStruct_T___at_qsizetype(void *thisObj, qsizetype i) +{ + const auto &result = fromPtr(thisObj)->at(i); + return result; +} +// back() +void *c_QList_T_SimpleStruct_T___back(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->back(); + return result; +} +// capacity() const +qsizetype c_QList_T_SimpleStruct_T___capacity(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->capacity(); + return result; +} +// clear() +void c_QList_T_SimpleStruct_T___clear(void *thisObj) +{ + fromPtr(thisObj)->clear(); +} +// constFirst() const +const void *c_QList_T_SimpleStruct_T___constFirst(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->constFirst(); + return result; +} +// constLast() const +const void *c_QList_T_SimpleStruct_T___constLast(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->constLast(); + return result; +} +// count() const +qsizetype c_QList_T_SimpleStruct_T___count(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->count(); + return result; +} +// detach() +void c_QList_T_SimpleStruct_T___detach(void *thisObj) +{ + fromPtr(thisObj)->detach(); +} +// empty() const +bool c_QList_T_SimpleStruct_T___empty(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->empty(); + return result; +} +// first() +void *c_QList_T_SimpleStruct_T___first(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->first(); + return result; +} +// first(qsizetype n) const +void *c_QList_T_SimpleStruct_T___first_qsizetype(void *thisObj, qsizetype n) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->first(n) + }; + return result; +} +// front() +void *c_QList_T_SimpleStruct_T___front(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->front(); + return result; +} +// isDetached() const +bool c_QList_T_SimpleStruct_T___isDetached(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isDetached(); + return result; +} +// isEmpty() const +bool c_QList_T_SimpleStruct_T___isEmpty(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isEmpty(); + return result; +} +// isSharedWith(const QList & other) const +bool c_QList_T_SimpleStruct_T___isSharedWith_QList_T(void *thisObj, void *other_) +{ + assert(other_); + auto &other = *reinterpret_cast *>(other_); + const auto &result = fromPtr(thisObj)->isSharedWith(other); + return result; +} +// last() +void *c_QList_T_SimpleStruct_T___last(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->last(); + return result; +} +// last(qsizetype n) const +void *c_QList_T_SimpleStruct_T___last_qsizetype(void *thisObj, qsizetype n) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->last(n) + }; + return result; +} +// length() const +qsizetype c_QList_T_SimpleStruct_T___length(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->length(); + return result; +} +// mid(qsizetype pos, qsizetype len) const +void *c_QList_T_SimpleStruct_T___mid_qsizetype_qsizetype(void *thisObj, qsizetype pos, + qsizetype len) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->mid(pos, len) + }; + return result; +} +// move(qsizetype from, qsizetype to) +void c_QList_T_SimpleStruct_T___move_qsizetype_qsizetype(void *thisObj, qsizetype from, + qsizetype to) +{ + fromPtr(thisObj)->move(from, to); +} +// pop_back() +void c_QList_T_SimpleStruct_T___pop_back(void *thisObj) +{ + fromPtr(thisObj)->pop_back(); +} +// pop_front() +void c_QList_T_SimpleStruct_T___pop_front(void *thisObj) +{ + fromPtr(thisObj)->pop_front(); +} +// remove(qsizetype i, qsizetype n) +void c_QList_T_SimpleStruct_T___remove_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype n) +{ + fromPtr(thisObj)->remove(i, n); +} +// removeAt(qsizetype i) +void c_QList_T_SimpleStruct_T___removeAt_qsizetype(void *thisObj, qsizetype i) +{ + fromPtr(thisObj)->removeAt(i); +} +// removeFirst() +void c_QList_T_SimpleStruct_T___removeFirst(void *thisObj) +{ + fromPtr(thisObj)->removeFirst(); +} +// removeLast() +void c_QList_T_SimpleStruct_T___removeLast(void *thisObj) +{ + fromPtr(thisObj)->removeLast(); +} +// reserve(qsizetype size) +void c_QList_T_SimpleStruct_T___reserve_qsizetype(void *thisObj, qsizetype size) +{ + fromPtr(thisObj)->reserve(size); +} +// resize(qsizetype size) +void c_QList_T_SimpleStruct_T___resize_qsizetype(void *thisObj, qsizetype size) +{ + fromPtr(thisObj)->resize(size); +} +// shrink_to_fit() +void c_QList_T_SimpleStruct_T___shrink_to_fit(void *thisObj) +{ + fromPtr(thisObj)->shrink_to_fit(); +} +// size() const +qsizetype c_QList_T_SimpleStruct_T___size(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->size(); + return result; +} +// sliced(qsizetype pos) const +void *c_QList_T_SimpleStruct_T___sliced_qsizetype(void *thisObj, qsizetype pos) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->sliced(pos) + }; + return result; +} +// sliced(qsizetype pos, qsizetype n) const +void *c_QList_T_SimpleStruct_T___sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, + qsizetype n) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->sliced(pos, n) + }; + return result; +} +// squeeze() +void c_QList_T_SimpleStruct_T___squeeze(void *thisObj) +{ + fromPtr(thisObj)->squeeze(); +} +// swapItemsAt(qsizetype i, qsizetype j) +void c_QList_T_SimpleStruct_T___swapItemsAt_qsizetype_qsizetype(void *thisObj, qsizetype i, + qsizetype j) +{ + fromPtr(thisObj)->swapItemsAt(i, j); +} +// takeAt(qsizetype i) +void *c_QList_T_SimpleStruct_T___takeAt_qsizetype(void *thisObj, qsizetype i) +{ + const auto &result = fromPtr(thisObj)->takeAt(i); + return result; +} +// toList() const +void *c_QList_T_SimpleStruct_T___toList(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->toList() + }; + return result; +} +// toVector() const +void *c_QList_T_SimpleStruct_T___toVector(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->toVector() + }; + return result; +} +// value(qsizetype i) const +void *c_QList_T_SimpleStruct_T___value_qsizetype(void *thisObj, qsizetype i) +{ + const auto &result = fromPtr(thisObj)->value(i); + return result; +} +void c_QList_T_SimpleStruct_T___destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} +extern "C" { +void c_QList_T_qreal_T__Finalizer(void *cppObj) +{ + delete reinterpret_cast *>(cppObj); +} +void *c_QList_T_qreal_T___constructor() +{ + auto ptr = new TestBindings_wrappersNS::QList_wrapper(); + return reinterpret_cast(ptr); +} +void *c_QList_T_qreal_T___constructor_qsizetype(qsizetype size) +{ + auto ptr = new TestBindings_wrappersNS::QList_wrapper(size); + return reinterpret_cast(ptr); +} +// append(const QList & l) +void c_QList_T_qreal_T___append_QList_T(void *thisObj, void *l_) +{ + assert(l_); + auto &l = *reinterpret_cast *>(l_); + fromPtr(thisObj)->append(l); +} +// at(qsizetype i) const +const qreal c_QList_T_qreal_T___at_qsizetype(void *thisObj, qsizetype i) +{ + const auto &result = fromPtr(thisObj)->at(i); + return result; +} +// back() +qreal c_QList_T_qreal_T___back(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->back(); + return result; +} +// capacity() const +qsizetype c_QList_T_qreal_T___capacity(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->capacity(); + return result; +} +// clear() +void c_QList_T_qreal_T___clear(void *thisObj) +{ + fromPtr(thisObj)->clear(); +} +// constFirst() const +const qreal c_QList_T_qreal_T___constFirst(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->constFirst(); + return result; +} +// constLast() const +const qreal c_QList_T_qreal_T___constLast(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->constLast(); + return result; +} +// count() const +qsizetype c_QList_T_qreal_T___count(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->count(); + return result; +} +// detach() +void c_QList_T_qreal_T___detach(void *thisObj) +{ + fromPtr(thisObj)->detach(); +} +// empty() const +bool c_QList_T_qreal_T___empty(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->empty(); + return result; +} +// first() +qreal c_QList_T_qreal_T___first(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->first(); + return result; +} +// first(qsizetype n) const +void *c_QList_T_qreal_T___first_qsizetype(void *thisObj, qsizetype n) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->first(n) }; + return result; +} +// front() +qreal c_QList_T_qreal_T___front(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->front(); + return result; +} +// isDetached() const +bool c_QList_T_qreal_T___isDetached(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isDetached(); + return result; +} +// isEmpty() const +bool c_QList_T_qreal_T___isEmpty(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isEmpty(); + return result; +} +// isSharedWith(const QList & other) const +bool c_QList_T_qreal_T___isSharedWith_QList_T(void *thisObj, void *other_) +{ + assert(other_); + auto &other = *reinterpret_cast *>(other_); + const auto &result = fromPtr(thisObj)->isSharedWith(other); + return result; +} +// last() +qreal c_QList_T_qreal_T___last(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->last(); + return result; +} +// last(qsizetype n) const +void *c_QList_T_qreal_T___last_qsizetype(void *thisObj, qsizetype n) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->last(n) }; + return result; +} +// length() const +qsizetype c_QList_T_qreal_T___length(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->length(); + return result; +} +// mid(qsizetype pos, qsizetype len) const +void *c_QList_T_qreal_T___mid_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype len) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->mid(pos, len) }; + return result; +} +// move(qsizetype from, qsizetype to) +void c_QList_T_qreal_T___move_qsizetype_qsizetype(void *thisObj, qsizetype from, qsizetype to) +{ + fromPtr(thisObj)->move(from, to); +} +// pop_back() +void c_QList_T_qreal_T___pop_back(void *thisObj) +{ + fromPtr(thisObj)->pop_back(); +} +// pop_front() +void c_QList_T_qreal_T___pop_front(void *thisObj) +{ + fromPtr(thisObj)->pop_front(); +} +// remove(qsizetype i, qsizetype n) +void c_QList_T_qreal_T___remove_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype n) +{ + fromPtr(thisObj)->remove(i, n); +} +// removeAt(qsizetype i) +void c_QList_T_qreal_T___removeAt_qsizetype(void *thisObj, qsizetype i) +{ + fromPtr(thisObj)->removeAt(i); +} +// removeFirst() +void c_QList_T_qreal_T___removeFirst(void *thisObj) +{ + fromPtr(thisObj)->removeFirst(); +} +// removeLast() +void c_QList_T_qreal_T___removeLast(void *thisObj) +{ + fromPtr(thisObj)->removeLast(); +} +// reserve(qsizetype size) +void c_QList_T_qreal_T___reserve_qsizetype(void *thisObj, qsizetype size) +{ + fromPtr(thisObj)->reserve(size); +} +// resize(qsizetype size) +void c_QList_T_qreal_T___resize_qsizetype(void *thisObj, qsizetype size) +{ + fromPtr(thisObj)->resize(size); +} +// shrink_to_fit() +void c_QList_T_qreal_T___shrink_to_fit(void *thisObj) +{ + fromPtr(thisObj)->shrink_to_fit(); +} +// size() const +qsizetype c_QList_T_qreal_T___size(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->size(); + return result; +} +// sliced(qsizetype pos) const +void *c_QList_T_qreal_T___sliced_qsizetype(void *thisObj, qsizetype pos) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->sliced(pos) }; + return result; +} +// sliced(qsizetype pos, qsizetype n) const +void *c_QList_T_qreal_T___sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype n) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->sliced(pos, n) }; + return result; +} +// squeeze() +void c_QList_T_qreal_T___squeeze(void *thisObj) +{ + fromPtr(thisObj)->squeeze(); +} +// swapItemsAt(qsizetype i, qsizetype j) +void c_QList_T_qreal_T___swapItemsAt_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype j) +{ + fromPtr(thisObj)->swapItemsAt(i, j); +} +// takeAt(qsizetype i) +qreal c_QList_T_qreal_T___takeAt_qsizetype(void *thisObj, qsizetype i) +{ + const auto &result = fromPtr(thisObj)->takeAt(i); + return result; +} +// toList() const +void *c_QList_T_qreal_T___toList(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->toList() }; + return result; +} +// toVector() const +void *c_QList_T_qreal_T___toVector(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->toVector() }; + return result; +} +// value(qsizetype i) const +qreal c_QList_T_qreal_T___value_qsizetype(void *thisObj, qsizetype i) +{ + const auto &result = fromPtr(thisObj)->value(i); + return result; +} +void c_QList_T_qreal_T___destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} +extern "C" { +void c_QList_T_int_T__Finalizer(void *cppObj) +{ + delete reinterpret_cast *>(cppObj); +} +void *c_QList_T_int_T___constructor() +{ + auto ptr = new TestBindings_wrappersNS::QList_wrapper(); + return reinterpret_cast(ptr); +} +void *c_QList_T_int_T___constructor_qsizetype(qsizetype size) +{ + auto ptr = new TestBindings_wrappersNS::QList_wrapper(size); + return reinterpret_cast(ptr); +} +// append(const QList & l) +void c_QList_T_int_T___append_QList_T(void *thisObj, void *l_) +{ + assert(l_); + auto &l = *reinterpret_cast *>(l_); + fromPtr(thisObj)->append(l); +} +// at(qsizetype i) const +const int c_QList_T_int_T___at_qsizetype(void *thisObj, qsizetype i) +{ + const auto &result = fromPtr(thisObj)->at(i); + return result; +} +// back() +int c_QList_T_int_T___back(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->back(); + return result; +} +// capacity() const +qsizetype c_QList_T_int_T___capacity(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->capacity(); + return result; +} +// clear() +void c_QList_T_int_T___clear(void *thisObj) +{ + fromPtr(thisObj)->clear(); +} +// constFirst() const +const int c_QList_T_int_T___constFirst(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->constFirst(); + return result; +} +// constLast() const +const int c_QList_T_int_T___constLast(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->constLast(); + return result; +} +// count() const +qsizetype c_QList_T_int_T___count(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->count(); + return result; +} +// detach() +void c_QList_T_int_T___detach(void *thisObj) +{ + fromPtr(thisObj)->detach(); +} +// empty() const +bool c_QList_T_int_T___empty(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->empty(); + return result; +} +// first() +int c_QList_T_int_T___first(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->first(); + return result; +} +// first(qsizetype n) const +void *c_QList_T_int_T___first_qsizetype(void *thisObj, qsizetype n) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->first(n) }; + return result; +} +// front() +int c_QList_T_int_T___front(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->front(); + return result; +} +// isDetached() const +bool c_QList_T_int_T___isDetached(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isDetached(); + return result; +} +// isEmpty() const +bool c_QList_T_int_T___isEmpty(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isEmpty(); + return result; +} +// isSharedWith(const QList & other) const +bool c_QList_T_int_T___isSharedWith_QList_T(void *thisObj, void *other_) +{ + assert(other_); + auto &other = *reinterpret_cast *>(other_); + const auto &result = fromPtr(thisObj)->isSharedWith(other); + return result; +} +// last() +int c_QList_T_int_T___last(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->last(); + return result; +} +// last(qsizetype n) const +void *c_QList_T_int_T___last_qsizetype(void *thisObj, qsizetype n) +{ + const auto &result = new Dartagnan::ValueWrapper> { fromPtr(thisObj)->last(n) }; + return result; +} +// length() const +qsizetype c_QList_T_int_T___length(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->length(); + return result; +} +// mid(qsizetype pos, qsizetype len) const +void *c_QList_T_int_T___mid_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype len) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->mid(pos, len) }; + return result; +} +// move(qsizetype from, qsizetype to) +void c_QList_T_int_T___move_qsizetype_qsizetype(void *thisObj, qsizetype from, qsizetype to) +{ + fromPtr(thisObj)->move(from, to); +} +// pop_back() +void c_QList_T_int_T___pop_back(void *thisObj) +{ + fromPtr(thisObj)->pop_back(); +} +// pop_front() +void c_QList_T_int_T___pop_front(void *thisObj) +{ + fromPtr(thisObj)->pop_front(); +} +// remove(qsizetype i, qsizetype n) +void c_QList_T_int_T___remove_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype n) +{ + fromPtr(thisObj)->remove(i, n); +} +// removeAt(qsizetype i) +void c_QList_T_int_T___removeAt_qsizetype(void *thisObj, qsizetype i) +{ + fromPtr(thisObj)->removeAt(i); +} +// removeFirst() +void c_QList_T_int_T___removeFirst(void *thisObj) +{ + fromPtr(thisObj)->removeFirst(); +} +// removeLast() +void c_QList_T_int_T___removeLast(void *thisObj) +{ + fromPtr(thisObj)->removeLast(); +} +// reserve(qsizetype size) +void c_QList_T_int_T___reserve_qsizetype(void *thisObj, qsizetype size) +{ + fromPtr(thisObj)->reserve(size); +} +// resize(qsizetype size) +void c_QList_T_int_T___resize_qsizetype(void *thisObj, qsizetype size) +{ + fromPtr(thisObj)->resize(size); +} +// shrink_to_fit() +void c_QList_T_int_T___shrink_to_fit(void *thisObj) +{ + fromPtr(thisObj)->shrink_to_fit(); +} +// size() const +qsizetype c_QList_T_int_T___size(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->size(); + return result; +} +// sliced(qsizetype pos) const +void *c_QList_T_int_T___sliced_qsizetype(void *thisObj, qsizetype pos) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->sliced(pos) }; + return result; +} +// sliced(qsizetype pos, qsizetype n) const +void *c_QList_T_int_T___sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype n) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->sliced(pos, n) }; + return result; +} +// squeeze() +void c_QList_T_int_T___squeeze(void *thisObj) +{ + fromPtr(thisObj)->squeeze(); +} +// swapItemsAt(qsizetype i, qsizetype j) +void c_QList_T_int_T___swapItemsAt_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype j) +{ + fromPtr(thisObj)->swapItemsAt(i, j); +} +// takeAt(qsizetype i) +int c_QList_T_int_T___takeAt_qsizetype(void *thisObj, qsizetype i) +{ + const auto &result = fromPtr(thisObj)->takeAt(i); + return result; +} +// toList() const +void *c_QList_T_int_T___toList(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->toList() }; + return result; +} +// toVector() const +void *c_QList_T_int_T___toVector(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->toVector() }; + return result; +} +// value(qsizetype i) const +int c_QList_T_int_T___value_qsizetype(void *thisObj, qsizetype i) +{ + const auto &result = fromPtr(thisObj)->value(i); + return result; +} +void c_QList_T_int_T___destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} +extern "C" { +void c_QList_T_QVariant_T__Finalizer(void *cppObj) +{ + delete reinterpret_cast *>(cppObj); +} +void *c_QList_T_QVariant_T___constructor() +{ + auto ptr = new TestBindings_wrappersNS::QList_wrapper(); + return reinterpret_cast(ptr); +} +void *c_QList_T_QVariant_T___constructor_qsizetype(qsizetype size) +{ + auto ptr = new TestBindings_wrappersNS::QList_wrapper(size); + return reinterpret_cast(ptr); +} +// append(const QList & l) +void c_QList_T_QVariant_T___append_QList_T(void *thisObj, void *l_) +{ + assert(l_); + auto &l = *reinterpret_cast *>(l_); + fromPtr(thisObj)->append(l); +} +// at(qsizetype i) const +const void *c_QList_T_QVariant_T___at_qsizetype(void *thisObj, qsizetype i) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->at(i) }; + return result; +} +// back() +void *c_QList_T_QVariant_T___back(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->back() }; + return result; +} +// capacity() const +qsizetype c_QList_T_QVariant_T___capacity(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->capacity(); + return result; +} +// clear() +void c_QList_T_QVariant_T___clear(void *thisObj) +{ + fromPtr(thisObj)->clear(); +} +// constFirst() const +const void *c_QList_T_QVariant_T___constFirst(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->constFirst() }; + return result; +} +// constLast() const +const void *c_QList_T_QVariant_T___constLast(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->constLast() }; + return result; +} +// count() const +qsizetype c_QList_T_QVariant_T___count(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->count(); + return result; +} +// detach() +void c_QList_T_QVariant_T___detach(void *thisObj) +{ + fromPtr(thisObj)->detach(); +} +// empty() const +bool c_QList_T_QVariant_T___empty(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->empty(); + return result; +} +// first() +void *c_QList_T_QVariant_T___first(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->first() }; + return result; +} +// first(qsizetype n) const +void *c_QList_T_QVariant_T___first_qsizetype(void *thisObj, qsizetype n) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->first(n) }; + return result; +} +// front() +void *c_QList_T_QVariant_T___front(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->front() }; + return result; +} +// isDetached() const +bool c_QList_T_QVariant_T___isDetached(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isDetached(); + return result; +} +// isEmpty() const +bool c_QList_T_QVariant_T___isEmpty(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isEmpty(); + return result; +} +// isSharedWith(const QList & other) const +bool c_QList_T_QVariant_T___isSharedWith_QList_T(void *thisObj, void *other_) +{ + assert(other_); + auto &other = *reinterpret_cast *>(other_); + const auto &result = fromPtr(thisObj)->isSharedWith(other); + return result; +} +// last() +void *c_QList_T_QVariant_T___last(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->last() }; + return result; +} +// last(qsizetype n) const +void *c_QList_T_QVariant_T___last_qsizetype(void *thisObj, qsizetype n) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->last(n) }; + return result; +} +// length() const +qsizetype c_QList_T_QVariant_T___length(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->length(); + return result; +} +// mid(qsizetype pos, qsizetype len) const +void *c_QList_T_QVariant_T___mid_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype len) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->mid(pos, len) }; + return result; +} +// move(qsizetype from, qsizetype to) +void c_QList_T_QVariant_T___move_qsizetype_qsizetype(void *thisObj, qsizetype from, qsizetype to) +{ + fromPtr(thisObj)->move(from, to); +} +// pop_back() +void c_QList_T_QVariant_T___pop_back(void *thisObj) +{ + fromPtr(thisObj)->pop_back(); +} +// pop_front() +void c_QList_T_QVariant_T___pop_front(void *thisObj) +{ + fromPtr(thisObj)->pop_front(); +} +// remove(qsizetype i, qsizetype n) +void c_QList_T_QVariant_T___remove_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype n) +{ + fromPtr(thisObj)->remove(i, n); +} +// removeAt(qsizetype i) +void c_QList_T_QVariant_T___removeAt_qsizetype(void *thisObj, qsizetype i) +{ + fromPtr(thisObj)->removeAt(i); +} +// removeFirst() +void c_QList_T_QVariant_T___removeFirst(void *thisObj) +{ + fromPtr(thisObj)->removeFirst(); +} +// removeLast() +void c_QList_T_QVariant_T___removeLast(void *thisObj) +{ + fromPtr(thisObj)->removeLast(); +} +// reserve(qsizetype size) +void c_QList_T_QVariant_T___reserve_qsizetype(void *thisObj, qsizetype size) +{ + fromPtr(thisObj)->reserve(size); +} +// resize(qsizetype size) +void c_QList_T_QVariant_T___resize_qsizetype(void *thisObj, qsizetype size) +{ + fromPtr(thisObj)->resize(size); +} +// shrink_to_fit() +void c_QList_T_QVariant_T___shrink_to_fit(void *thisObj) +{ + fromPtr(thisObj)->shrink_to_fit(); +} +// size() const +qsizetype c_QList_T_QVariant_T___size(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->size(); + return result; +} +// sliced(qsizetype pos) const +void *c_QList_T_QVariant_T___sliced_qsizetype(void *thisObj, qsizetype pos) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->sliced(pos) }; + return result; +} +// sliced(qsizetype pos, qsizetype n) const +void *c_QList_T_QVariant_T___sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype n) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->sliced(pos, n) }; + return result; +} +// squeeze() +void c_QList_T_QVariant_T___squeeze(void *thisObj) +{ + fromPtr(thisObj)->squeeze(); +} +// swapItemsAt(qsizetype i, qsizetype j) +void c_QList_T_QVariant_T___swapItemsAt_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype j) +{ + fromPtr(thisObj)->swapItemsAt(i, j); +} +// takeAt(qsizetype i) +void *c_QList_T_QVariant_T___takeAt_qsizetype(void *thisObj, qsizetype i) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->takeAt(i) }; + return result; +} +// toList() const +void *c_QList_T_QVariant_T___toList(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->toList() }; + return result; +} +// toVector() const +void *c_QList_T_QVariant_T___toVector(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->toVector() }; + return result; +} +// value(qsizetype i) const +void *c_QList_T_QVariant_T___value_qsizetype(void *thisObj, qsizetype i) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->value(i) }; + return result; +} +void c_QList_T_QVariant_T___destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} +extern "C" { +void c_QList_T_QString_T__Finalizer(void *cppObj) +{ + delete reinterpret_cast *>(cppObj); +} +void *c_QList_T_QString_T___constructor() +{ + auto ptr = new TestBindings_wrappersNS::QList_wrapper(); + return reinterpret_cast(ptr); +} +void *c_QList_T_QString_T___constructor_qsizetype(qsizetype size) +{ + auto ptr = new TestBindings_wrappersNS::QList_wrapper(size); + return reinterpret_cast(ptr); +} +// append(const QList & l) +void c_QList_T_QString_T___append_QList_T(void *thisObj, void *l_) +{ + assert(l_); + auto &l = *reinterpret_cast *>(l_); + fromPtr(thisObj)->append(l); +} +// at(qsizetype i) const +const void *c_QList_T_QString_T___at_qsizetype(void *thisObj, qsizetype i) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->at(i) }; + return result; +} +// back() +void *c_QList_T_QString_T___back(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->back() }; + return result; +} +// capacity() const +qsizetype c_QList_T_QString_T___capacity(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->capacity(); + return result; +} +// clear() +void c_QList_T_QString_T___clear(void *thisObj) +{ + fromPtr(thisObj)->clear(); +} +// constFirst() const +const void *c_QList_T_QString_T___constFirst(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->constFirst() }; + return result; +} +// constLast() const +const void *c_QList_T_QString_T___constLast(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->constLast() }; + return result; +} +// count() const +qsizetype c_QList_T_QString_T___count(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->count(); + return result; +} +// detach() +void c_QList_T_QString_T___detach(void *thisObj) +{ + fromPtr(thisObj)->detach(); +} +// empty() const +bool c_QList_T_QString_T___empty(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->empty(); + return result; +} +// first() +void *c_QList_T_QString_T___first(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->first() }; + return result; +} +// first(qsizetype n) const +void *c_QList_T_QString_T___first_qsizetype(void *thisObj, qsizetype n) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->first(n) }; + return result; +} +// front() +void *c_QList_T_QString_T___front(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->front() }; + return result; +} +// isDetached() const +bool c_QList_T_QString_T___isDetached(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isDetached(); + return result; +} +// isEmpty() const +bool c_QList_T_QString_T___isEmpty(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isEmpty(); + return result; +} +// isSharedWith(const QList & other) const +bool c_QList_T_QString_T___isSharedWith_QList_T(void *thisObj, void *other_) +{ + assert(other_); + auto &other = *reinterpret_cast *>(other_); + const auto &result = fromPtr(thisObj)->isSharedWith(other); + return result; +} +// last() +void *c_QList_T_QString_T___last(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->last() }; + return result; +} +// last(qsizetype n) const +void *c_QList_T_QString_T___last_qsizetype(void *thisObj, qsizetype n) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->last(n) }; + return result; +} +// length() const +qsizetype c_QList_T_QString_T___length(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->length(); + return result; +} +// mid(qsizetype pos, qsizetype len) const +void *c_QList_T_QString_T___mid_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype len) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->mid(pos, len) }; + return result; +} +// move(qsizetype from, qsizetype to) +void c_QList_T_QString_T___move_qsizetype_qsizetype(void *thisObj, qsizetype from, qsizetype to) +{ + fromPtr(thisObj)->move(from, to); +} +// pop_back() +void c_QList_T_QString_T___pop_back(void *thisObj) +{ + fromPtr(thisObj)->pop_back(); +} +// pop_front() +void c_QList_T_QString_T___pop_front(void *thisObj) +{ + fromPtr(thisObj)->pop_front(); +} +// remove(qsizetype i, qsizetype n) +void c_QList_T_QString_T___remove_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype n) +{ + fromPtr(thisObj)->remove(i, n); +} +// removeAt(qsizetype i) +void c_QList_T_QString_T___removeAt_qsizetype(void *thisObj, qsizetype i) +{ + fromPtr(thisObj)->removeAt(i); +} +// removeFirst() +void c_QList_T_QString_T___removeFirst(void *thisObj) +{ + fromPtr(thisObj)->removeFirst(); +} +// removeLast() +void c_QList_T_QString_T___removeLast(void *thisObj) +{ + fromPtr(thisObj)->removeLast(); +} +// reserve(qsizetype size) +void c_QList_T_QString_T___reserve_qsizetype(void *thisObj, qsizetype size) +{ + fromPtr(thisObj)->reserve(size); +} +// resize(qsizetype size) +void c_QList_T_QString_T___resize_qsizetype(void *thisObj, qsizetype size) +{ + fromPtr(thisObj)->resize(size); +} +// shrink_to_fit() +void c_QList_T_QString_T___shrink_to_fit(void *thisObj) +{ + fromPtr(thisObj)->shrink_to_fit(); +} +// size() const +qsizetype c_QList_T_QString_T___size(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->size(); + return result; +} +// sliced(qsizetype pos) const +void *c_QList_T_QString_T___sliced_qsizetype(void *thisObj, qsizetype pos) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->sliced(pos) }; + return result; +} +// sliced(qsizetype pos, qsizetype n) const +void *c_QList_T_QString_T___sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype n) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->sliced(pos, n) }; + return result; +} +// squeeze() +void c_QList_T_QString_T___squeeze(void *thisObj) +{ + fromPtr(thisObj)->squeeze(); +} +// swapItemsAt(qsizetype i, qsizetype j) +void c_QList_T_QString_T___swapItemsAt_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype j) +{ + fromPtr(thisObj)->swapItemsAt(i, j); +} +// takeAt(qsizetype i) +void *c_QList_T_QString_T___takeAt_qsizetype(void *thisObj, qsizetype i) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->takeAt(i) }; + return result; +} +// toList() const +void *c_QList_T_QString_T___toList(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->toList() }; + return result; +} +// toVector() const +void *c_QList_T_QString_T___toVector(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->toVector() }; + return result; +} +// value(qsizetype i) const +void *c_QList_T_QString_T___value_qsizetype(void *thisObj, qsizetype i) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->value(i) }; + return result; +} +void c_QList_T_QString_T___destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} +extern "C" { +void c_QList_T_unsigned_int_T__Finalizer(void *cppObj) +{ + delete reinterpret_cast *>(cppObj); +} +void *c_QList_T_unsigned_int_T___constructor() +{ + auto ptr = new TestBindings_wrappersNS::QList_wrapper(); + return reinterpret_cast(ptr); +} +void *c_QList_T_unsigned_int_T___constructor_qsizetype(qsizetype size) +{ + auto ptr = new TestBindings_wrappersNS::QList_wrapper(size); + return reinterpret_cast(ptr); +} +// append(const QList & l) +void c_QList_T_unsigned_int_T___append_QList_T(void *thisObj, void *l_) +{ + assert(l_); + auto &l = *reinterpret_cast *>(l_); + fromPtr(thisObj)->append(l); +} +// at(qsizetype i) const +const unsigned int c_QList_T_unsigned_int_T___at_qsizetype(void *thisObj, qsizetype i) +{ + const auto &result = fromPtr(thisObj)->at(i); + return result; +} +// back() +unsigned int c_QList_T_unsigned_int_T___back(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->back(); + return result; +} +// capacity() const +qsizetype c_QList_T_unsigned_int_T___capacity(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->capacity(); + return result; +} +// clear() +void c_QList_T_unsigned_int_T___clear(void *thisObj) +{ + fromPtr(thisObj)->clear(); +} +// constFirst() const +const unsigned int c_QList_T_unsigned_int_T___constFirst(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->constFirst(); + return result; +} +// constLast() const +const unsigned int c_QList_T_unsigned_int_T___constLast(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->constLast(); + return result; +} +// count() const +qsizetype c_QList_T_unsigned_int_T___count(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->count(); + return result; +} +// detach() +void c_QList_T_unsigned_int_T___detach(void *thisObj) +{ + fromPtr(thisObj)->detach(); +} +// empty() const +bool c_QList_T_unsigned_int_T___empty(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->empty(); + return result; +} +// first() +unsigned int c_QList_T_unsigned_int_T___first(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->first(); + return result; +} +// first(qsizetype n) const +void *c_QList_T_unsigned_int_T___first_qsizetype(void *thisObj, qsizetype n) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->first(n) + }; + return result; +} +// front() +unsigned int c_QList_T_unsigned_int_T___front(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->front(); + return result; +} +// isDetached() const +bool c_QList_T_unsigned_int_T___isDetached(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isDetached(); + return result; +} +// isEmpty() const +bool c_QList_T_unsigned_int_T___isEmpty(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isEmpty(); + return result; +} +// isSharedWith(const QList & other) const +bool c_QList_T_unsigned_int_T___isSharedWith_QList_T(void *thisObj, void *other_) +{ + assert(other_); + auto &other = *reinterpret_cast *>(other_); + const auto &result = fromPtr(thisObj)->isSharedWith(other); + return result; +} +// last() +unsigned int c_QList_T_unsigned_int_T___last(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->last(); + return result; +} +// last(qsizetype n) const +void *c_QList_T_unsigned_int_T___last_qsizetype(void *thisObj, qsizetype n) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->last(n) + }; + return result; +} +// length() const +qsizetype c_QList_T_unsigned_int_T___length(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->length(); + return result; +} +// mid(qsizetype pos, qsizetype len) const +void *c_QList_T_unsigned_int_T___mid_qsizetype_qsizetype(void *thisObj, qsizetype pos, + qsizetype len) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->mid(pos, len) + }; + return result; +} +// move(qsizetype from, qsizetype to) +void c_QList_T_unsigned_int_T___move_qsizetype_qsizetype(void *thisObj, qsizetype from, + qsizetype to) +{ + fromPtr(thisObj)->move(from, to); +} +// pop_back() +void c_QList_T_unsigned_int_T___pop_back(void *thisObj) +{ + fromPtr(thisObj)->pop_back(); +} +// pop_front() +void c_QList_T_unsigned_int_T___pop_front(void *thisObj) +{ + fromPtr(thisObj)->pop_front(); +} +// remove(qsizetype i, qsizetype n) +void c_QList_T_unsigned_int_T___remove_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype n) +{ + fromPtr(thisObj)->remove(i, n); +} +// removeAt(qsizetype i) +void c_QList_T_unsigned_int_T___removeAt_qsizetype(void *thisObj, qsizetype i) +{ + fromPtr(thisObj)->removeAt(i); +} +// removeFirst() +void c_QList_T_unsigned_int_T___removeFirst(void *thisObj) +{ + fromPtr(thisObj)->removeFirst(); +} +// removeLast() +void c_QList_T_unsigned_int_T___removeLast(void *thisObj) +{ + fromPtr(thisObj)->removeLast(); +} +// reserve(qsizetype size) +void c_QList_T_unsigned_int_T___reserve_qsizetype(void *thisObj, qsizetype size) +{ + fromPtr(thisObj)->reserve(size); +} +// resize(qsizetype size) +void c_QList_T_unsigned_int_T___resize_qsizetype(void *thisObj, qsizetype size) +{ + fromPtr(thisObj)->resize(size); +} +// shrink_to_fit() +void c_QList_T_unsigned_int_T___shrink_to_fit(void *thisObj) +{ + fromPtr(thisObj)->shrink_to_fit(); +} +// size() const +qsizetype c_QList_T_unsigned_int_T___size(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->size(); + return result; +} +// sliced(qsizetype pos) const +void *c_QList_T_unsigned_int_T___sliced_qsizetype(void *thisObj, qsizetype pos) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->sliced(pos) + }; + return result; +} +// sliced(qsizetype pos, qsizetype n) const +void *c_QList_T_unsigned_int_T___sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, + qsizetype n) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->sliced(pos, n) + }; + return result; +} +// squeeze() +void c_QList_T_unsigned_int_T___squeeze(void *thisObj) +{ + fromPtr(thisObj)->squeeze(); +} +// swapItemsAt(qsizetype i, qsizetype j) +void c_QList_T_unsigned_int_T___swapItemsAt_qsizetype_qsizetype(void *thisObj, qsizetype i, + qsizetype j) +{ + fromPtr(thisObj)->swapItemsAt(i, j); +} +// takeAt(qsizetype i) +unsigned int c_QList_T_unsigned_int_T___takeAt_qsizetype(void *thisObj, qsizetype i) +{ + const auto &result = fromPtr(thisObj)->takeAt(i); + return result; +} +// toList() const +void *c_QList_T_unsigned_int_T___toList(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->toList() + }; + return result; +} +// toVector() const +void *c_QList_T_unsigned_int_T___toVector(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->toVector() + }; + return result; +} +// value(qsizetype i) const +unsigned int c_QList_T_unsigned_int_T___value_qsizetype(void *thisObj, qsizetype i) +{ + const auto &result = fromPtr(thisObj)->value(i); + return result; +} +void c_QList_T_unsigned_int_T___destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} +extern "C" { +void c_QList_T_QObject_T__Finalizer(void *cppObj) +{ + delete reinterpret_cast *>(cppObj); +} +void *c_QList_T_QObject_T___constructor() +{ + auto ptr = new TestBindings_wrappersNS::QList_wrapper(); + return reinterpret_cast(ptr); +} +void *c_QList_T_QObject_T___constructor_qsizetype(qsizetype size) +{ + auto ptr = new TestBindings_wrappersNS::QList_wrapper(size); + return reinterpret_cast(ptr); +} +// append(const QList & l) +void c_QList_T_QObject_T___append_QList_T(void *thisObj, void *l_) +{ + assert(l_); + auto &l = *reinterpret_cast *>(l_); + fromPtr(thisObj)->append(l); +} +// at(qsizetype i) const +const void *c_QList_T_QObject_T___at_qsizetype(void *thisObj, qsizetype i) +{ + const auto &result = fromPtr(thisObj)->at(i); + return result; +} +// back() +void *c_QList_T_QObject_T___back(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->back(); + return result; +} +// capacity() const +qsizetype c_QList_T_QObject_T___capacity(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->capacity(); + return result; +} +// clear() +void c_QList_T_QObject_T___clear(void *thisObj) +{ + fromPtr(thisObj)->clear(); +} +// constFirst() const +const void *c_QList_T_QObject_T___constFirst(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->constFirst(); + return result; +} +// constLast() const +const void *c_QList_T_QObject_T___constLast(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->constLast(); + return result; +} +// count() const +qsizetype c_QList_T_QObject_T___count(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->count(); + return result; +} +// detach() +void c_QList_T_QObject_T___detach(void *thisObj) +{ + fromPtr(thisObj)->detach(); +} +// empty() const +bool c_QList_T_QObject_T___empty(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->empty(); + return result; +} +// first() +void *c_QList_T_QObject_T___first(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->first(); + return result; +} +// first(qsizetype n) const +void *c_QList_T_QObject_T___first_qsizetype(void *thisObj, qsizetype n) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->first(n) }; + return result; +} +// front() +void *c_QList_T_QObject_T___front(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->front(); + return result; +} +// isDetached() const +bool c_QList_T_QObject_T___isDetached(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isDetached(); + return result; +} +// isEmpty() const +bool c_QList_T_QObject_T___isEmpty(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isEmpty(); + return result; +} +// isSharedWith(const QList & other) const +bool c_QList_T_QObject_T___isSharedWith_QList_T(void *thisObj, void *other_) +{ + assert(other_); + auto &other = *reinterpret_cast *>(other_); + const auto &result = fromPtr(thisObj)->isSharedWith(other); + return result; +} +// last() +void *c_QList_T_QObject_T___last(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->last(); + return result; +} +// last(qsizetype n) const +void *c_QList_T_QObject_T___last_qsizetype(void *thisObj, qsizetype n) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->last(n) }; + return result; +} +// length() const +qsizetype c_QList_T_QObject_T___length(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->length(); + return result; +} +// mid(qsizetype pos, qsizetype len) const +void *c_QList_T_QObject_T___mid_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype len) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->mid(pos, + len) }; + return result; +} +// move(qsizetype from, qsizetype to) +void c_QList_T_QObject_T___move_qsizetype_qsizetype(void *thisObj, qsizetype from, qsizetype to) +{ + fromPtr(thisObj)->move(from, to); +} +// pop_back() +void c_QList_T_QObject_T___pop_back(void *thisObj) +{ + fromPtr(thisObj)->pop_back(); +} +// pop_front() +void c_QList_T_QObject_T___pop_front(void *thisObj) +{ + fromPtr(thisObj)->pop_front(); +} +// remove(qsizetype i, qsizetype n) +void c_QList_T_QObject_T___remove_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype n) +{ + fromPtr(thisObj)->remove(i, n); +} +// removeAt(qsizetype i) +void c_QList_T_QObject_T___removeAt_qsizetype(void *thisObj, qsizetype i) +{ + fromPtr(thisObj)->removeAt(i); +} +// removeFirst() +void c_QList_T_QObject_T___removeFirst(void *thisObj) +{ + fromPtr(thisObj)->removeFirst(); +} +// removeLast() +void c_QList_T_QObject_T___removeLast(void *thisObj) +{ + fromPtr(thisObj)->removeLast(); +} +// reserve(qsizetype size) +void c_QList_T_QObject_T___reserve_qsizetype(void *thisObj, qsizetype size) +{ + fromPtr(thisObj)->reserve(size); +} +// resize(qsizetype size) +void c_QList_T_QObject_T___resize_qsizetype(void *thisObj, qsizetype size) +{ + fromPtr(thisObj)->resize(size); +} +// shrink_to_fit() +void c_QList_T_QObject_T___shrink_to_fit(void *thisObj) +{ + fromPtr(thisObj)->shrink_to_fit(); +} +// size() const +qsizetype c_QList_T_QObject_T___size(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->size(); + return result; +} +// sliced(qsizetype pos) const +void *c_QList_T_QObject_T___sliced_qsizetype(void *thisObj, qsizetype pos) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->sliced(pos) }; + return result; +} +// sliced(qsizetype pos, qsizetype n) const +void *c_QList_T_QObject_T___sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype n) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->sliced(pos, + n) }; + return result; +} +// squeeze() +void c_QList_T_QObject_T___squeeze(void *thisObj) +{ + fromPtr(thisObj)->squeeze(); +} +// swapItemsAt(qsizetype i, qsizetype j) +void c_QList_T_QObject_T___swapItemsAt_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype j) +{ + fromPtr(thisObj)->swapItemsAt(i, j); +} +// takeAt(qsizetype i) +void *c_QList_T_QObject_T___takeAt_qsizetype(void *thisObj, qsizetype i) +{ + const auto &result = fromPtr(thisObj)->takeAt(i); + return result; +} +// toList() const +void *c_QList_T_QObject_T___toList(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->toList() }; + return result; +} +// toVector() const +void *c_QList_T_QObject_T___toVector(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->toVector() }; + return result; +} +// value(qsizetype i) const +void *c_QList_T_QObject_T___value_qsizetype(void *thisObj, qsizetype i) +{ + const auto &result = fromPtr(thisObj)->value(i); + return result; +} +void c_QList_T_QObject_T___destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} +extern "C" { +void c_QList_T_QByteArray_T__Finalizer(void *cppObj) +{ + delete reinterpret_cast *>(cppObj); +} +void *c_QList_T_QByteArray_T___constructor() +{ + auto ptr = new TestBindings_wrappersNS::QList_wrapper(); + return reinterpret_cast(ptr); +} +void *c_QList_T_QByteArray_T___constructor_qsizetype(qsizetype size) +{ + auto ptr = new TestBindings_wrappersNS::QList_wrapper(size); + return reinterpret_cast(ptr); +} +// append(const QList & l) +void c_QList_T_QByteArray_T___append_QList_T(void *thisObj, void *l_) +{ + assert(l_); + auto &l = *reinterpret_cast *>(l_); + fromPtr(thisObj)->append(l); +} +// at(qsizetype i) const +const void *c_QList_T_QByteArray_T___at_qsizetype(void *thisObj, qsizetype i) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->at(i) }; + return result; +} +// back() +void *c_QList_T_QByteArray_T___back(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->back() }; + return result; +} +// capacity() const +qsizetype c_QList_T_QByteArray_T___capacity(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->capacity(); + return result; +} +// clear() +void c_QList_T_QByteArray_T___clear(void *thisObj) +{ + fromPtr(thisObj)->clear(); +} +// constFirst() const +const void *c_QList_T_QByteArray_T___constFirst(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->constFirst() }; + return result; +} +// constLast() const +const void *c_QList_T_QByteArray_T___constLast(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->constLast() }; + return result; +} +// count() const +qsizetype c_QList_T_QByteArray_T___count(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->count(); + return result; +} +// detach() +void c_QList_T_QByteArray_T___detach(void *thisObj) +{ + fromPtr(thisObj)->detach(); +} +// empty() const +bool c_QList_T_QByteArray_T___empty(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->empty(); + return result; +} +// first() +void *c_QList_T_QByteArray_T___first(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->first() }; + return result; +} +// first(qsizetype n) const +void *c_QList_T_QByteArray_T___first_qsizetype(void *thisObj, qsizetype n) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->first(n) }; + return result; +} +// front() +void *c_QList_T_QByteArray_T___front(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->front() }; + return result; +} +// isDetached() const +bool c_QList_T_QByteArray_T___isDetached(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isDetached(); + return result; +} +// isEmpty() const +bool c_QList_T_QByteArray_T___isEmpty(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isEmpty(); + return result; +} +// isSharedWith(const QList & other) const +bool c_QList_T_QByteArray_T___isSharedWith_QList_T(void *thisObj, void *other_) +{ + assert(other_); + auto &other = *reinterpret_cast *>(other_); + const auto &result = fromPtr(thisObj)->isSharedWith(other); + return result; +} +// last() +void *c_QList_T_QByteArray_T___last(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->last() }; + return result; +} +// last(qsizetype n) const +void *c_QList_T_QByteArray_T___last_qsizetype(void *thisObj, qsizetype n) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->last(n) }; + return result; +} +// length() const +qsizetype c_QList_T_QByteArray_T___length(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->length(); + return result; +} +// mid(qsizetype pos, qsizetype len) const +void *c_QList_T_QByteArray_T___mid_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype len) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->mid(pos, + len) }; + return result; +} +// move(qsizetype from, qsizetype to) +void c_QList_T_QByteArray_T___move_qsizetype_qsizetype(void *thisObj, qsizetype from, qsizetype to) +{ + fromPtr(thisObj)->move(from, to); +} +// pop_back() +void c_QList_T_QByteArray_T___pop_back(void *thisObj) +{ + fromPtr(thisObj)->pop_back(); +} +// pop_front() +void c_QList_T_QByteArray_T___pop_front(void *thisObj) +{ + fromPtr(thisObj)->pop_front(); +} +// remove(qsizetype i, qsizetype n) +void c_QList_T_QByteArray_T___remove_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype n) +{ + fromPtr(thisObj)->remove(i, n); +} +// removeAt(qsizetype i) +void c_QList_T_QByteArray_T___removeAt_qsizetype(void *thisObj, qsizetype i) +{ + fromPtr(thisObj)->removeAt(i); +} +// removeFirst() +void c_QList_T_QByteArray_T___removeFirst(void *thisObj) +{ + fromPtr(thisObj)->removeFirst(); +} +// removeLast() +void c_QList_T_QByteArray_T___removeLast(void *thisObj) +{ + fromPtr(thisObj)->removeLast(); +} +// reserve(qsizetype size) +void c_QList_T_QByteArray_T___reserve_qsizetype(void *thisObj, qsizetype size) +{ + fromPtr(thisObj)->reserve(size); +} +// resize(qsizetype size) +void c_QList_T_QByteArray_T___resize_qsizetype(void *thisObj, qsizetype size) +{ + fromPtr(thisObj)->resize(size); +} +// shrink_to_fit() +void c_QList_T_QByteArray_T___shrink_to_fit(void *thisObj) +{ + fromPtr(thisObj)->shrink_to_fit(); +} +// size() const +qsizetype c_QList_T_QByteArray_T___size(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->size(); + return result; +} +// sliced(qsizetype pos) const +void *c_QList_T_QByteArray_T___sliced_qsizetype(void *thisObj, qsizetype pos) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->sliced(pos) + }; + return result; +} +// sliced(qsizetype pos, qsizetype n) const +void *c_QList_T_QByteArray_T___sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype n) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->sliced(pos, + n) }; + return result; +} +// squeeze() +void c_QList_T_QByteArray_T___squeeze(void *thisObj) +{ + fromPtr(thisObj)->squeeze(); +} +// swapItemsAt(qsizetype i, qsizetype j) +void c_QList_T_QByteArray_T___swapItemsAt_qsizetype_qsizetype(void *thisObj, qsizetype i, + qsizetype j) +{ + fromPtr(thisObj)->swapItemsAt(i, j); +} +// takeAt(qsizetype i) +void *c_QList_T_QByteArray_T___takeAt_qsizetype(void *thisObj, qsizetype i) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->takeAt(i) }; + return result; +} +// toList() const +void *c_QList_T_QByteArray_T___toList(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->toList() }; + return result; +} +// toVector() const +void *c_QList_T_QByteArray_T___toVector(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->toVector() }; + return result; +} +// value(qsizetype i) const +void *c_QList_T_QByteArray_T___value_qsizetype(void *thisObj, qsizetype i) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->value(i) }; + return result; +} +void c_QList_T_QByteArray_T___destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} diff --git a/tests/generated/TestBindings/dart/ffi/QList_c.h b/tests/generated/TestBindings/dart/ffi/QList_c.h new file mode 100644 index 0000000..2a4a30b --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/QList_c.h @@ -0,0 +1,795 @@ +#include "TestBindings_exports.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace TestBindings_wrappersNS { +template +class QList_wrapper : public ::QList +{ +public: + ~QList_wrapper(); + QList_wrapper(); + QList_wrapper(qsizetype size); + void append(const QList &l); + const T &at(qsizetype i) const; + T &back(); + qsizetype capacity() const; + void clear(); + const T &constFirst() const; + const T &constLast() const; + qsizetype count() const; + void detach(); + bool empty() const; + T &first(); + QList first(qsizetype n) const; + T &front(); + bool isDetached() const; + bool isEmpty() const; + bool isSharedWith(const QList &other) const; + T &last(); + QList last(qsizetype n) const; + qsizetype length() const; + QList mid(qsizetype pos, qsizetype len = -1) const; + void move(qsizetype from, qsizetype to); + void pop_back(); + void pop_front(); + void remove(qsizetype i, qsizetype n = 1); + void removeAt(qsizetype i); + void removeFirst(); + void removeLast(); + void reserve(qsizetype size); + void resize(qsizetype size); + void shrink_to_fit(); + qsizetype size() const; + QList sliced(qsizetype pos) const; + QList sliced(qsizetype pos, qsizetype n) const; + void squeeze(); + void swapItemsAt(qsizetype i, qsizetype j); + T takeAt(qsizetype i); + QList toList() const; + QList toVector() const; + T value(qsizetype i) const; +}; +} +extern "C" { +// QList::QList() +TestBindings_EXPORT void *c_QList_T_SimpleStruct_T___constructor(); +// QList::QList(qsizetype size) +TestBindings_EXPORT void *c_QList_T_SimpleStruct_T___constructor_qsizetype(qsizetype size); +// QList::append(const QList & l) +TestBindings_EXPORT void c_QList_T_SimpleStruct_T___append_QList_T(void *thisObj, void *l_); +// QList::at(qsizetype i) const +TestBindings_EXPORT const void *c_QList_T_SimpleStruct_T___at_qsizetype(void *thisObj, qsizetype i); +// QList::back() +TestBindings_EXPORT void *c_QList_T_SimpleStruct_T___back(void *thisObj); +// QList::capacity() const +TestBindings_EXPORT qsizetype c_QList_T_SimpleStruct_T___capacity(void *thisObj); +// QList::clear() +TestBindings_EXPORT void c_QList_T_SimpleStruct_T___clear(void *thisObj); +// QList::constFirst() const +TestBindings_EXPORT const void *c_QList_T_SimpleStruct_T___constFirst(void *thisObj); +// QList::constLast() const +TestBindings_EXPORT const void *c_QList_T_SimpleStruct_T___constLast(void *thisObj); +// QList::count() const +TestBindings_EXPORT qsizetype c_QList_T_SimpleStruct_T___count(void *thisObj); +// QList::detach() +TestBindings_EXPORT void c_QList_T_SimpleStruct_T___detach(void *thisObj); +// QList::empty() const +TestBindings_EXPORT bool c_QList_T_SimpleStruct_T___empty(void *thisObj); +// QList::first() +TestBindings_EXPORT void *c_QList_T_SimpleStruct_T___first(void *thisObj); +// QList::first(qsizetype n) const +TestBindings_EXPORT void *c_QList_T_SimpleStruct_T___first_qsizetype(void *thisObj, qsizetype n); +// QList::front() +TestBindings_EXPORT void *c_QList_T_SimpleStruct_T___front(void *thisObj); +// QList::isDetached() const +TestBindings_EXPORT bool c_QList_T_SimpleStruct_T___isDetached(void *thisObj); +// QList::isEmpty() const +TestBindings_EXPORT bool c_QList_T_SimpleStruct_T___isEmpty(void *thisObj); +// QList::isSharedWith(const QList & other) const +TestBindings_EXPORT bool c_QList_T_SimpleStruct_T___isSharedWith_QList_T(void *thisObj, + void *other_); +// QList::last() +TestBindings_EXPORT void *c_QList_T_SimpleStruct_T___last(void *thisObj); +// QList::last(qsizetype n) const +TestBindings_EXPORT void *c_QList_T_SimpleStruct_T___last_qsizetype(void *thisObj, qsizetype n); +// QList::length() const +TestBindings_EXPORT qsizetype c_QList_T_SimpleStruct_T___length(void *thisObj); +// QList::mid(qsizetype pos, qsizetype len) const +TestBindings_EXPORT void * +c_QList_T_SimpleStruct_T___mid_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype len); +// QList::move(qsizetype from, qsizetype to) +TestBindings_EXPORT void +c_QList_T_SimpleStruct_T___move_qsizetype_qsizetype(void *thisObj, qsizetype from, qsizetype to); +// QList::pop_back() +TestBindings_EXPORT void c_QList_T_SimpleStruct_T___pop_back(void *thisObj); +// QList::pop_front() +TestBindings_EXPORT void c_QList_T_SimpleStruct_T___pop_front(void *thisObj); +// QList::remove(qsizetype i, qsizetype n) +TestBindings_EXPORT void +c_QList_T_SimpleStruct_T___remove_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype n); +// QList::removeAt(qsizetype i) +TestBindings_EXPORT void c_QList_T_SimpleStruct_T___removeAt_qsizetype(void *thisObj, qsizetype i); +// QList::removeFirst() +TestBindings_EXPORT void c_QList_T_SimpleStruct_T___removeFirst(void *thisObj); +// QList::removeLast() +TestBindings_EXPORT void c_QList_T_SimpleStruct_T___removeLast(void *thisObj); +// QList::reserve(qsizetype size) +TestBindings_EXPORT void c_QList_T_SimpleStruct_T___reserve_qsizetype(void *thisObj, + qsizetype size); +// QList::resize(qsizetype size) +TestBindings_EXPORT void c_QList_T_SimpleStruct_T___resize_qsizetype(void *thisObj, qsizetype size); +// QList::shrink_to_fit() +TestBindings_EXPORT void c_QList_T_SimpleStruct_T___shrink_to_fit(void *thisObj); +// QList::size() const +TestBindings_EXPORT qsizetype c_QList_T_SimpleStruct_T___size(void *thisObj); +// QList::sliced(qsizetype pos) const +TestBindings_EXPORT void *c_QList_T_SimpleStruct_T___sliced_qsizetype(void *thisObj, qsizetype pos); +// QList::sliced(qsizetype pos, qsizetype n) const +TestBindings_EXPORT void * +c_QList_T_SimpleStruct_T___sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype n); +// QList::squeeze() +TestBindings_EXPORT void c_QList_T_SimpleStruct_T___squeeze(void *thisObj); +// QList::swapItemsAt(qsizetype i, qsizetype j) +TestBindings_EXPORT void +c_QList_T_SimpleStruct_T___swapItemsAt_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype j); +// QList::takeAt(qsizetype i) +TestBindings_EXPORT void *c_QList_T_SimpleStruct_T___takeAt_qsizetype(void *thisObj, qsizetype i); +// QList::toList() const +TestBindings_EXPORT void *c_QList_T_SimpleStruct_T___toList(void *thisObj); +// QList::toVector() const +TestBindings_EXPORT void *c_QList_T_SimpleStruct_T___toVector(void *thisObj); +// QList::value(qsizetype i) const +TestBindings_EXPORT void *c_QList_T_SimpleStruct_T___value_qsizetype(void *thisObj, qsizetype i); +TestBindings_EXPORT void c_QList_T_SimpleStruct_T___destructor(void *thisObj); +TestBindings_EXPORT void c_QList_T_SimpleStruct_T__Finalizer(void *cppObj); +} +extern "C" { +// QList::QList() +TestBindings_EXPORT void *c_QList_T_qreal_T___constructor(); +// QList::QList(qsizetype size) +TestBindings_EXPORT void *c_QList_T_qreal_T___constructor_qsizetype(qsizetype size); +// QList::append(const QList & l) +TestBindings_EXPORT void c_QList_T_qreal_T___append_QList_T(void *thisObj, void *l_); +// QList::at(qsizetype i) const +TestBindings_EXPORT const qreal c_QList_T_qreal_T___at_qsizetype(void *thisObj, qsizetype i); +// QList::back() +TestBindings_EXPORT qreal c_QList_T_qreal_T___back(void *thisObj); +// QList::capacity() const +TestBindings_EXPORT qsizetype c_QList_T_qreal_T___capacity(void *thisObj); +// QList::clear() +TestBindings_EXPORT void c_QList_T_qreal_T___clear(void *thisObj); +// QList::constFirst() const +TestBindings_EXPORT const qreal c_QList_T_qreal_T___constFirst(void *thisObj); +// QList::constLast() const +TestBindings_EXPORT const qreal c_QList_T_qreal_T___constLast(void *thisObj); +// QList::count() const +TestBindings_EXPORT qsizetype c_QList_T_qreal_T___count(void *thisObj); +// QList::detach() +TestBindings_EXPORT void c_QList_T_qreal_T___detach(void *thisObj); +// QList::empty() const +TestBindings_EXPORT bool c_QList_T_qreal_T___empty(void *thisObj); +// QList::first() +TestBindings_EXPORT qreal c_QList_T_qreal_T___first(void *thisObj); +// QList::first(qsizetype n) const +TestBindings_EXPORT void *c_QList_T_qreal_T___first_qsizetype(void *thisObj, qsizetype n); +// QList::front() +TestBindings_EXPORT qreal c_QList_T_qreal_T___front(void *thisObj); +// QList::isDetached() const +TestBindings_EXPORT bool c_QList_T_qreal_T___isDetached(void *thisObj); +// QList::isEmpty() const +TestBindings_EXPORT bool c_QList_T_qreal_T___isEmpty(void *thisObj); +// QList::isSharedWith(const QList & other) const +TestBindings_EXPORT bool c_QList_T_qreal_T___isSharedWith_QList_T(void *thisObj, void *other_); +// QList::last() +TestBindings_EXPORT qreal c_QList_T_qreal_T___last(void *thisObj); +// QList::last(qsizetype n) const +TestBindings_EXPORT void *c_QList_T_qreal_T___last_qsizetype(void *thisObj, qsizetype n); +// QList::length() const +TestBindings_EXPORT qsizetype c_QList_T_qreal_T___length(void *thisObj); +// QList::mid(qsizetype pos, qsizetype len) const +TestBindings_EXPORT void *c_QList_T_qreal_T___mid_qsizetype_qsizetype(void *thisObj, qsizetype pos, + qsizetype len); +// QList::move(qsizetype from, qsizetype to) +TestBindings_EXPORT void c_QList_T_qreal_T___move_qsizetype_qsizetype(void *thisObj, qsizetype from, + qsizetype to); +// QList::pop_back() +TestBindings_EXPORT void c_QList_T_qreal_T___pop_back(void *thisObj); +// QList::pop_front() +TestBindings_EXPORT void c_QList_T_qreal_T___pop_front(void *thisObj); +// QList::remove(qsizetype i, qsizetype n) +TestBindings_EXPORT void c_QList_T_qreal_T___remove_qsizetype_qsizetype(void *thisObj, qsizetype i, + qsizetype n); +// QList::removeAt(qsizetype i) +TestBindings_EXPORT void c_QList_T_qreal_T___removeAt_qsizetype(void *thisObj, qsizetype i); +// QList::removeFirst() +TestBindings_EXPORT void c_QList_T_qreal_T___removeFirst(void *thisObj); +// QList::removeLast() +TestBindings_EXPORT void c_QList_T_qreal_T___removeLast(void *thisObj); +// QList::reserve(qsizetype size) +TestBindings_EXPORT void c_QList_T_qreal_T___reserve_qsizetype(void *thisObj, qsizetype size); +// QList::resize(qsizetype size) +TestBindings_EXPORT void c_QList_T_qreal_T___resize_qsizetype(void *thisObj, qsizetype size); +// QList::shrink_to_fit() +TestBindings_EXPORT void c_QList_T_qreal_T___shrink_to_fit(void *thisObj); +// QList::size() const +TestBindings_EXPORT qsizetype c_QList_T_qreal_T___size(void *thisObj); +// QList::sliced(qsizetype pos) const +TestBindings_EXPORT void *c_QList_T_qreal_T___sliced_qsizetype(void *thisObj, qsizetype pos); +// QList::sliced(qsizetype pos, qsizetype n) const +TestBindings_EXPORT void * +c_QList_T_qreal_T___sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype n); +// QList::squeeze() +TestBindings_EXPORT void c_QList_T_qreal_T___squeeze(void *thisObj); +// QList::swapItemsAt(qsizetype i, qsizetype j) +TestBindings_EXPORT void +c_QList_T_qreal_T___swapItemsAt_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype j); +// QList::takeAt(qsizetype i) +TestBindings_EXPORT qreal c_QList_T_qreal_T___takeAt_qsizetype(void *thisObj, qsizetype i); +// QList::toList() const +TestBindings_EXPORT void *c_QList_T_qreal_T___toList(void *thisObj); +// QList::toVector() const +TestBindings_EXPORT void *c_QList_T_qreal_T___toVector(void *thisObj); +// QList::value(qsizetype i) const +TestBindings_EXPORT qreal c_QList_T_qreal_T___value_qsizetype(void *thisObj, qsizetype i); +TestBindings_EXPORT void c_QList_T_qreal_T___destructor(void *thisObj); +TestBindings_EXPORT void c_QList_T_qreal_T__Finalizer(void *cppObj); +} +extern "C" { +// QList::QList() +TestBindings_EXPORT void *c_QList_T_int_T___constructor(); +// QList::QList(qsizetype size) +TestBindings_EXPORT void *c_QList_T_int_T___constructor_qsizetype(qsizetype size); +// QList::append(const QList & l) +TestBindings_EXPORT void c_QList_T_int_T___append_QList_T(void *thisObj, void *l_); +// QList::at(qsizetype i) const +TestBindings_EXPORT const int c_QList_T_int_T___at_qsizetype(void *thisObj, qsizetype i); +// QList::back() +TestBindings_EXPORT int c_QList_T_int_T___back(void *thisObj); +// QList::capacity() const +TestBindings_EXPORT qsizetype c_QList_T_int_T___capacity(void *thisObj); +// QList::clear() +TestBindings_EXPORT void c_QList_T_int_T___clear(void *thisObj); +// QList::constFirst() const +TestBindings_EXPORT const int c_QList_T_int_T___constFirst(void *thisObj); +// QList::constLast() const +TestBindings_EXPORT const int c_QList_T_int_T___constLast(void *thisObj); +// QList::count() const +TestBindings_EXPORT qsizetype c_QList_T_int_T___count(void *thisObj); +// QList::detach() +TestBindings_EXPORT void c_QList_T_int_T___detach(void *thisObj); +// QList::empty() const +TestBindings_EXPORT bool c_QList_T_int_T___empty(void *thisObj); +// QList::first() +TestBindings_EXPORT int c_QList_T_int_T___first(void *thisObj); +// QList::first(qsizetype n) const +TestBindings_EXPORT void *c_QList_T_int_T___first_qsizetype(void *thisObj, qsizetype n); +// QList::front() +TestBindings_EXPORT int c_QList_T_int_T___front(void *thisObj); +// QList::isDetached() const +TestBindings_EXPORT bool c_QList_T_int_T___isDetached(void *thisObj); +// QList::isEmpty() const +TestBindings_EXPORT bool c_QList_T_int_T___isEmpty(void *thisObj); +// QList::isSharedWith(const QList & other) const +TestBindings_EXPORT bool c_QList_T_int_T___isSharedWith_QList_T(void *thisObj, void *other_); +// QList::last() +TestBindings_EXPORT int c_QList_T_int_T___last(void *thisObj); +// QList::last(qsizetype n) const +TestBindings_EXPORT void *c_QList_T_int_T___last_qsizetype(void *thisObj, qsizetype n); +// QList::length() const +TestBindings_EXPORT qsizetype c_QList_T_int_T___length(void *thisObj); +// QList::mid(qsizetype pos, qsizetype len) const +TestBindings_EXPORT void *c_QList_T_int_T___mid_qsizetype_qsizetype(void *thisObj, qsizetype pos, + qsizetype len); +// QList::move(qsizetype from, qsizetype to) +TestBindings_EXPORT void c_QList_T_int_T___move_qsizetype_qsizetype(void *thisObj, qsizetype from, + qsizetype to); +// QList::pop_back() +TestBindings_EXPORT void c_QList_T_int_T___pop_back(void *thisObj); +// QList::pop_front() +TestBindings_EXPORT void c_QList_T_int_T___pop_front(void *thisObj); +// QList::remove(qsizetype i, qsizetype n) +TestBindings_EXPORT void c_QList_T_int_T___remove_qsizetype_qsizetype(void *thisObj, qsizetype i, + qsizetype n); +// QList::removeAt(qsizetype i) +TestBindings_EXPORT void c_QList_T_int_T___removeAt_qsizetype(void *thisObj, qsizetype i); +// QList::removeFirst() +TestBindings_EXPORT void c_QList_T_int_T___removeFirst(void *thisObj); +// QList::removeLast() +TestBindings_EXPORT void c_QList_T_int_T___removeLast(void *thisObj); +// QList::reserve(qsizetype size) +TestBindings_EXPORT void c_QList_T_int_T___reserve_qsizetype(void *thisObj, qsizetype size); +// QList::resize(qsizetype size) +TestBindings_EXPORT void c_QList_T_int_T___resize_qsizetype(void *thisObj, qsizetype size); +// QList::shrink_to_fit() +TestBindings_EXPORT void c_QList_T_int_T___shrink_to_fit(void *thisObj); +// QList::size() const +TestBindings_EXPORT qsizetype c_QList_T_int_T___size(void *thisObj); +// QList::sliced(qsizetype pos) const +TestBindings_EXPORT void *c_QList_T_int_T___sliced_qsizetype(void *thisObj, qsizetype pos); +// QList::sliced(qsizetype pos, qsizetype n) const +TestBindings_EXPORT void *c_QList_T_int_T___sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, + qsizetype n); +// QList::squeeze() +TestBindings_EXPORT void c_QList_T_int_T___squeeze(void *thisObj); +// QList::swapItemsAt(qsizetype i, qsizetype j) +TestBindings_EXPORT void +c_QList_T_int_T___swapItemsAt_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype j); +// QList::takeAt(qsizetype i) +TestBindings_EXPORT int c_QList_T_int_T___takeAt_qsizetype(void *thisObj, qsizetype i); +// QList::toList() const +TestBindings_EXPORT void *c_QList_T_int_T___toList(void *thisObj); +// QList::toVector() const +TestBindings_EXPORT void *c_QList_T_int_T___toVector(void *thisObj); +// QList::value(qsizetype i) const +TestBindings_EXPORT int c_QList_T_int_T___value_qsizetype(void *thisObj, qsizetype i); +TestBindings_EXPORT void c_QList_T_int_T___destructor(void *thisObj); +TestBindings_EXPORT void c_QList_T_int_T__Finalizer(void *cppObj); +} +extern "C" { +// QList::QList() +TestBindings_EXPORT void *c_QList_T_QVariant_T___constructor(); +// QList::QList(qsizetype size) +TestBindings_EXPORT void *c_QList_T_QVariant_T___constructor_qsizetype(qsizetype size); +// QList::append(const QList & l) +TestBindings_EXPORT void c_QList_T_QVariant_T___append_QList_T(void *thisObj, void *l_); +// QList::at(qsizetype i) const +TestBindings_EXPORT const void *c_QList_T_QVariant_T___at_qsizetype(void *thisObj, qsizetype i); +// QList::back() +TestBindings_EXPORT void *c_QList_T_QVariant_T___back(void *thisObj); +// QList::capacity() const +TestBindings_EXPORT qsizetype c_QList_T_QVariant_T___capacity(void *thisObj); +// QList::clear() +TestBindings_EXPORT void c_QList_T_QVariant_T___clear(void *thisObj); +// QList::constFirst() const +TestBindings_EXPORT const void *c_QList_T_QVariant_T___constFirst(void *thisObj); +// QList::constLast() const +TestBindings_EXPORT const void *c_QList_T_QVariant_T___constLast(void *thisObj); +// QList::count() const +TestBindings_EXPORT qsizetype c_QList_T_QVariant_T___count(void *thisObj); +// QList::detach() +TestBindings_EXPORT void c_QList_T_QVariant_T___detach(void *thisObj); +// QList::empty() const +TestBindings_EXPORT bool c_QList_T_QVariant_T___empty(void *thisObj); +// QList::first() +TestBindings_EXPORT void *c_QList_T_QVariant_T___first(void *thisObj); +// QList::first(qsizetype n) const +TestBindings_EXPORT void *c_QList_T_QVariant_T___first_qsizetype(void *thisObj, qsizetype n); +// QList::front() +TestBindings_EXPORT void *c_QList_T_QVariant_T___front(void *thisObj); +// QList::isDetached() const +TestBindings_EXPORT bool c_QList_T_QVariant_T___isDetached(void *thisObj); +// QList::isEmpty() const +TestBindings_EXPORT bool c_QList_T_QVariant_T___isEmpty(void *thisObj); +// QList::isSharedWith(const QList & other) const +TestBindings_EXPORT bool c_QList_T_QVariant_T___isSharedWith_QList_T(void *thisObj, void *other_); +// QList::last() +TestBindings_EXPORT void *c_QList_T_QVariant_T___last(void *thisObj); +// QList::last(qsizetype n) const +TestBindings_EXPORT void *c_QList_T_QVariant_T___last_qsizetype(void *thisObj, qsizetype n); +// QList::length() const +TestBindings_EXPORT qsizetype c_QList_T_QVariant_T___length(void *thisObj); +// QList::mid(qsizetype pos, qsizetype len) const +TestBindings_EXPORT void * +c_QList_T_QVariant_T___mid_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype len); +// QList::move(qsizetype from, qsizetype to) +TestBindings_EXPORT void +c_QList_T_QVariant_T___move_qsizetype_qsizetype(void *thisObj, qsizetype from, qsizetype to); +// QList::pop_back() +TestBindings_EXPORT void c_QList_T_QVariant_T___pop_back(void *thisObj); +// QList::pop_front() +TestBindings_EXPORT void c_QList_T_QVariant_T___pop_front(void *thisObj); +// QList::remove(qsizetype i, qsizetype n) +TestBindings_EXPORT void +c_QList_T_QVariant_T___remove_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype n); +// QList::removeAt(qsizetype i) +TestBindings_EXPORT void c_QList_T_QVariant_T___removeAt_qsizetype(void *thisObj, qsizetype i); +// QList::removeFirst() +TestBindings_EXPORT void c_QList_T_QVariant_T___removeFirst(void *thisObj); +// QList::removeLast() +TestBindings_EXPORT void c_QList_T_QVariant_T___removeLast(void *thisObj); +// QList::reserve(qsizetype size) +TestBindings_EXPORT void c_QList_T_QVariant_T___reserve_qsizetype(void *thisObj, qsizetype size); +// QList::resize(qsizetype size) +TestBindings_EXPORT void c_QList_T_QVariant_T___resize_qsizetype(void *thisObj, qsizetype size); +// QList::shrink_to_fit() +TestBindings_EXPORT void c_QList_T_QVariant_T___shrink_to_fit(void *thisObj); +// QList::size() const +TestBindings_EXPORT qsizetype c_QList_T_QVariant_T___size(void *thisObj); +// QList::sliced(qsizetype pos) const +TestBindings_EXPORT void *c_QList_T_QVariant_T___sliced_qsizetype(void *thisObj, qsizetype pos); +// QList::sliced(qsizetype pos, qsizetype n) const +TestBindings_EXPORT void * +c_QList_T_QVariant_T___sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype n); +// QList::squeeze() +TestBindings_EXPORT void c_QList_T_QVariant_T___squeeze(void *thisObj); +// QList::swapItemsAt(qsizetype i, qsizetype j) +TestBindings_EXPORT void +c_QList_T_QVariant_T___swapItemsAt_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype j); +// QList::takeAt(qsizetype i) +TestBindings_EXPORT void *c_QList_T_QVariant_T___takeAt_qsizetype(void *thisObj, qsizetype i); +// QList::toList() const +TestBindings_EXPORT void *c_QList_T_QVariant_T___toList(void *thisObj); +// QList::toVector() const +TestBindings_EXPORT void *c_QList_T_QVariant_T___toVector(void *thisObj); +// QList::value(qsizetype i) const +TestBindings_EXPORT void *c_QList_T_QVariant_T___value_qsizetype(void *thisObj, qsizetype i); +TestBindings_EXPORT void c_QList_T_QVariant_T___destructor(void *thisObj); +TestBindings_EXPORT void c_QList_T_QVariant_T__Finalizer(void *cppObj); +} +extern "C" { +// QList::QList() +TestBindings_EXPORT void *c_QList_T_QString_T___constructor(); +// QList::QList(qsizetype size) +TestBindings_EXPORT void *c_QList_T_QString_T___constructor_qsizetype(qsizetype size); +// QList::append(const QList & l) +TestBindings_EXPORT void c_QList_T_QString_T___append_QList_T(void *thisObj, void *l_); +// QList::at(qsizetype i) const +TestBindings_EXPORT const void *c_QList_T_QString_T___at_qsizetype(void *thisObj, qsizetype i); +// QList::back() +TestBindings_EXPORT void *c_QList_T_QString_T___back(void *thisObj); +// QList::capacity() const +TestBindings_EXPORT qsizetype c_QList_T_QString_T___capacity(void *thisObj); +// QList::clear() +TestBindings_EXPORT void c_QList_T_QString_T___clear(void *thisObj); +// QList::constFirst() const +TestBindings_EXPORT const void *c_QList_T_QString_T___constFirst(void *thisObj); +// QList::constLast() const +TestBindings_EXPORT const void *c_QList_T_QString_T___constLast(void *thisObj); +// QList::count() const +TestBindings_EXPORT qsizetype c_QList_T_QString_T___count(void *thisObj); +// QList::detach() +TestBindings_EXPORT void c_QList_T_QString_T___detach(void *thisObj); +// QList::empty() const +TestBindings_EXPORT bool c_QList_T_QString_T___empty(void *thisObj); +// QList::first() +TestBindings_EXPORT void *c_QList_T_QString_T___first(void *thisObj); +// QList::first(qsizetype n) const +TestBindings_EXPORT void *c_QList_T_QString_T___first_qsizetype(void *thisObj, qsizetype n); +// QList::front() +TestBindings_EXPORT void *c_QList_T_QString_T___front(void *thisObj); +// QList::isDetached() const +TestBindings_EXPORT bool c_QList_T_QString_T___isDetached(void *thisObj); +// QList::isEmpty() const +TestBindings_EXPORT bool c_QList_T_QString_T___isEmpty(void *thisObj); +// QList::isSharedWith(const QList & other) const +TestBindings_EXPORT bool c_QList_T_QString_T___isSharedWith_QList_T(void *thisObj, void *other_); +// QList::last() +TestBindings_EXPORT void *c_QList_T_QString_T___last(void *thisObj); +// QList::last(qsizetype n) const +TestBindings_EXPORT void *c_QList_T_QString_T___last_qsizetype(void *thisObj, qsizetype n); +// QList::length() const +TestBindings_EXPORT qsizetype c_QList_T_QString_T___length(void *thisObj); +// QList::mid(qsizetype pos, qsizetype len) const +TestBindings_EXPORT void * +c_QList_T_QString_T___mid_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype len); +// QList::move(qsizetype from, qsizetype to) +TestBindings_EXPORT void +c_QList_T_QString_T___move_qsizetype_qsizetype(void *thisObj, qsizetype from, qsizetype to); +// QList::pop_back() +TestBindings_EXPORT void c_QList_T_QString_T___pop_back(void *thisObj); +// QList::pop_front() +TestBindings_EXPORT void c_QList_T_QString_T___pop_front(void *thisObj); +// QList::remove(qsizetype i, qsizetype n) +TestBindings_EXPORT void c_QList_T_QString_T___remove_qsizetype_qsizetype(void *thisObj, + qsizetype i, qsizetype n); +// QList::removeAt(qsizetype i) +TestBindings_EXPORT void c_QList_T_QString_T___removeAt_qsizetype(void *thisObj, qsizetype i); +// QList::removeFirst() +TestBindings_EXPORT void c_QList_T_QString_T___removeFirst(void *thisObj); +// QList::removeLast() +TestBindings_EXPORT void c_QList_T_QString_T___removeLast(void *thisObj); +// QList::reserve(qsizetype size) +TestBindings_EXPORT void c_QList_T_QString_T___reserve_qsizetype(void *thisObj, qsizetype size); +// QList::resize(qsizetype size) +TestBindings_EXPORT void c_QList_T_QString_T___resize_qsizetype(void *thisObj, qsizetype size); +// QList::shrink_to_fit() +TestBindings_EXPORT void c_QList_T_QString_T___shrink_to_fit(void *thisObj); +// QList::size() const +TestBindings_EXPORT qsizetype c_QList_T_QString_T___size(void *thisObj); +// QList::sliced(qsizetype pos) const +TestBindings_EXPORT void *c_QList_T_QString_T___sliced_qsizetype(void *thisObj, qsizetype pos); +// QList::sliced(qsizetype pos, qsizetype n) const +TestBindings_EXPORT void * +c_QList_T_QString_T___sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype n); +// QList::squeeze() +TestBindings_EXPORT void c_QList_T_QString_T___squeeze(void *thisObj); +// QList::swapItemsAt(qsizetype i, qsizetype j) +TestBindings_EXPORT void +c_QList_T_QString_T___swapItemsAt_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype j); +// QList::takeAt(qsizetype i) +TestBindings_EXPORT void *c_QList_T_QString_T___takeAt_qsizetype(void *thisObj, qsizetype i); +// QList::toList() const +TestBindings_EXPORT void *c_QList_T_QString_T___toList(void *thisObj); +// QList::toVector() const +TestBindings_EXPORT void *c_QList_T_QString_T___toVector(void *thisObj); +// QList::value(qsizetype i) const +TestBindings_EXPORT void *c_QList_T_QString_T___value_qsizetype(void *thisObj, qsizetype i); +TestBindings_EXPORT void c_QList_T_QString_T___destructor(void *thisObj); +TestBindings_EXPORT void c_QList_T_QString_T__Finalizer(void *cppObj); +} +extern "C" { +// QList::QList() +TestBindings_EXPORT void *c_QList_T_unsigned_int_T___constructor(); +// QList::QList(qsizetype size) +TestBindings_EXPORT void *c_QList_T_unsigned_int_T___constructor_qsizetype(qsizetype size); +// QList::append(const QList & l) +TestBindings_EXPORT void c_QList_T_unsigned_int_T___append_QList_T(void *thisObj, void *l_); +// QList::at(qsizetype i) const +TestBindings_EXPORT const unsigned int c_QList_T_unsigned_int_T___at_qsizetype(void *thisObj, + qsizetype i); +// QList::back() +TestBindings_EXPORT unsigned int c_QList_T_unsigned_int_T___back(void *thisObj); +// QList::capacity() const +TestBindings_EXPORT qsizetype c_QList_T_unsigned_int_T___capacity(void *thisObj); +// QList::clear() +TestBindings_EXPORT void c_QList_T_unsigned_int_T___clear(void *thisObj); +// QList::constFirst() const +TestBindings_EXPORT const unsigned int c_QList_T_unsigned_int_T___constFirst(void *thisObj); +// QList::constLast() const +TestBindings_EXPORT const unsigned int c_QList_T_unsigned_int_T___constLast(void *thisObj); +// QList::count() const +TestBindings_EXPORT qsizetype c_QList_T_unsigned_int_T___count(void *thisObj); +// QList::detach() +TestBindings_EXPORT void c_QList_T_unsigned_int_T___detach(void *thisObj); +// QList::empty() const +TestBindings_EXPORT bool c_QList_T_unsigned_int_T___empty(void *thisObj); +// QList::first() +TestBindings_EXPORT unsigned int c_QList_T_unsigned_int_T___first(void *thisObj); +// QList::first(qsizetype n) const +TestBindings_EXPORT void *c_QList_T_unsigned_int_T___first_qsizetype(void *thisObj, qsizetype n); +// QList::front() +TestBindings_EXPORT unsigned int c_QList_T_unsigned_int_T___front(void *thisObj); +// QList::isDetached() const +TestBindings_EXPORT bool c_QList_T_unsigned_int_T___isDetached(void *thisObj); +// QList::isEmpty() const +TestBindings_EXPORT bool c_QList_T_unsigned_int_T___isEmpty(void *thisObj); +// QList::isSharedWith(const QList & other) const +TestBindings_EXPORT bool c_QList_T_unsigned_int_T___isSharedWith_QList_T(void *thisObj, + void *other_); +// QList::last() +TestBindings_EXPORT unsigned int c_QList_T_unsigned_int_T___last(void *thisObj); +// QList::last(qsizetype n) const +TestBindings_EXPORT void *c_QList_T_unsigned_int_T___last_qsizetype(void *thisObj, qsizetype n); +// QList::length() const +TestBindings_EXPORT qsizetype c_QList_T_unsigned_int_T___length(void *thisObj); +// QList::mid(qsizetype pos, qsizetype len) const +TestBindings_EXPORT void * +c_QList_T_unsigned_int_T___mid_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype len); +// QList::move(qsizetype from, qsizetype to) +TestBindings_EXPORT void +c_QList_T_unsigned_int_T___move_qsizetype_qsizetype(void *thisObj, qsizetype from, qsizetype to); +// QList::pop_back() +TestBindings_EXPORT void c_QList_T_unsigned_int_T___pop_back(void *thisObj); +// QList::pop_front() +TestBindings_EXPORT void c_QList_T_unsigned_int_T___pop_front(void *thisObj); +// QList::remove(qsizetype i, qsizetype n) +TestBindings_EXPORT void +c_QList_T_unsigned_int_T___remove_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype n); +// QList::removeAt(qsizetype i) +TestBindings_EXPORT void c_QList_T_unsigned_int_T___removeAt_qsizetype(void *thisObj, qsizetype i); +// QList::removeFirst() +TestBindings_EXPORT void c_QList_T_unsigned_int_T___removeFirst(void *thisObj); +// QList::removeLast() +TestBindings_EXPORT void c_QList_T_unsigned_int_T___removeLast(void *thisObj); +// QList::reserve(qsizetype size) +TestBindings_EXPORT void c_QList_T_unsigned_int_T___reserve_qsizetype(void *thisObj, + qsizetype size); +// QList::resize(qsizetype size) +TestBindings_EXPORT void c_QList_T_unsigned_int_T___resize_qsizetype(void *thisObj, qsizetype size); +// QList::shrink_to_fit() +TestBindings_EXPORT void c_QList_T_unsigned_int_T___shrink_to_fit(void *thisObj); +// QList::size() const +TestBindings_EXPORT qsizetype c_QList_T_unsigned_int_T___size(void *thisObj); +// QList::sliced(qsizetype pos) const +TestBindings_EXPORT void *c_QList_T_unsigned_int_T___sliced_qsizetype(void *thisObj, qsizetype pos); +// QList::sliced(qsizetype pos, qsizetype n) const +TestBindings_EXPORT void * +c_QList_T_unsigned_int_T___sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype n); +// QList::squeeze() +TestBindings_EXPORT void c_QList_T_unsigned_int_T___squeeze(void *thisObj); +// QList::swapItemsAt(qsizetype i, qsizetype j) +TestBindings_EXPORT void +c_QList_T_unsigned_int_T___swapItemsAt_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype j); +// QList::takeAt(qsizetype i) +TestBindings_EXPORT unsigned int c_QList_T_unsigned_int_T___takeAt_qsizetype(void *thisObj, + qsizetype i); +// QList::toList() const +TestBindings_EXPORT void *c_QList_T_unsigned_int_T___toList(void *thisObj); +// QList::toVector() const +TestBindings_EXPORT void *c_QList_T_unsigned_int_T___toVector(void *thisObj); +// QList::value(qsizetype i) const +TestBindings_EXPORT unsigned int c_QList_T_unsigned_int_T___value_qsizetype(void *thisObj, + qsizetype i); +TestBindings_EXPORT void c_QList_T_unsigned_int_T___destructor(void *thisObj); +TestBindings_EXPORT void c_QList_T_unsigned_int_T__Finalizer(void *cppObj); +} +extern "C" { +// QList::QList() +TestBindings_EXPORT void *c_QList_T_QObject_T___constructor(); +// QList::QList(qsizetype size) +TestBindings_EXPORT void *c_QList_T_QObject_T___constructor_qsizetype(qsizetype size); +// QList::append(const QList & l) +TestBindings_EXPORT void c_QList_T_QObject_T___append_QList_T(void *thisObj, void *l_); +// QList::at(qsizetype i) const +TestBindings_EXPORT const void *c_QList_T_QObject_T___at_qsizetype(void *thisObj, qsizetype i); +// QList::back() +TestBindings_EXPORT void *c_QList_T_QObject_T___back(void *thisObj); +// QList::capacity() const +TestBindings_EXPORT qsizetype c_QList_T_QObject_T___capacity(void *thisObj); +// QList::clear() +TestBindings_EXPORT void c_QList_T_QObject_T___clear(void *thisObj); +// QList::constFirst() const +TestBindings_EXPORT const void *c_QList_T_QObject_T___constFirst(void *thisObj); +// QList::constLast() const +TestBindings_EXPORT const void *c_QList_T_QObject_T___constLast(void *thisObj); +// QList::count() const +TestBindings_EXPORT qsizetype c_QList_T_QObject_T___count(void *thisObj); +// QList::detach() +TestBindings_EXPORT void c_QList_T_QObject_T___detach(void *thisObj); +// QList::empty() const +TestBindings_EXPORT bool c_QList_T_QObject_T___empty(void *thisObj); +// QList::first() +TestBindings_EXPORT void *c_QList_T_QObject_T___first(void *thisObj); +// QList::first(qsizetype n) const +TestBindings_EXPORT void *c_QList_T_QObject_T___first_qsizetype(void *thisObj, qsizetype n); +// QList::front() +TestBindings_EXPORT void *c_QList_T_QObject_T___front(void *thisObj); +// QList::isDetached() const +TestBindings_EXPORT bool c_QList_T_QObject_T___isDetached(void *thisObj); +// QList::isEmpty() const +TestBindings_EXPORT bool c_QList_T_QObject_T___isEmpty(void *thisObj); +// QList::isSharedWith(const QList & other) const +TestBindings_EXPORT bool c_QList_T_QObject_T___isSharedWith_QList_T(void *thisObj, void *other_); +// QList::last() +TestBindings_EXPORT void *c_QList_T_QObject_T___last(void *thisObj); +// QList::last(qsizetype n) const +TestBindings_EXPORT void *c_QList_T_QObject_T___last_qsizetype(void *thisObj, qsizetype n); +// QList::length() const +TestBindings_EXPORT qsizetype c_QList_T_QObject_T___length(void *thisObj); +// QList::mid(qsizetype pos, qsizetype len) const +TestBindings_EXPORT void * +c_QList_T_QObject_T___mid_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype len); +// QList::move(qsizetype from, qsizetype to) +TestBindings_EXPORT void +c_QList_T_QObject_T___move_qsizetype_qsizetype(void *thisObj, qsizetype from, qsizetype to); +// QList::pop_back() +TestBindings_EXPORT void c_QList_T_QObject_T___pop_back(void *thisObj); +// QList::pop_front() +TestBindings_EXPORT void c_QList_T_QObject_T___pop_front(void *thisObj); +// QList::remove(qsizetype i, qsizetype n) +TestBindings_EXPORT void c_QList_T_QObject_T___remove_qsizetype_qsizetype(void *thisObj, + qsizetype i, qsizetype n); +// QList::removeAt(qsizetype i) +TestBindings_EXPORT void c_QList_T_QObject_T___removeAt_qsizetype(void *thisObj, qsizetype i); +// QList::removeFirst() +TestBindings_EXPORT void c_QList_T_QObject_T___removeFirst(void *thisObj); +// QList::removeLast() +TestBindings_EXPORT void c_QList_T_QObject_T___removeLast(void *thisObj); +// QList::reserve(qsizetype size) +TestBindings_EXPORT void c_QList_T_QObject_T___reserve_qsizetype(void *thisObj, qsizetype size); +// QList::resize(qsizetype size) +TestBindings_EXPORT void c_QList_T_QObject_T___resize_qsizetype(void *thisObj, qsizetype size); +// QList::shrink_to_fit() +TestBindings_EXPORT void c_QList_T_QObject_T___shrink_to_fit(void *thisObj); +// QList::size() const +TestBindings_EXPORT qsizetype c_QList_T_QObject_T___size(void *thisObj); +// QList::sliced(qsizetype pos) const +TestBindings_EXPORT void *c_QList_T_QObject_T___sliced_qsizetype(void *thisObj, qsizetype pos); +// QList::sliced(qsizetype pos, qsizetype n) const +TestBindings_EXPORT void * +c_QList_T_QObject_T___sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype n); +// QList::squeeze() +TestBindings_EXPORT void c_QList_T_QObject_T___squeeze(void *thisObj); +// QList::swapItemsAt(qsizetype i, qsizetype j) +TestBindings_EXPORT void +c_QList_T_QObject_T___swapItemsAt_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype j); +// QList::takeAt(qsizetype i) +TestBindings_EXPORT void *c_QList_T_QObject_T___takeAt_qsizetype(void *thisObj, qsizetype i); +// QList::toList() const +TestBindings_EXPORT void *c_QList_T_QObject_T___toList(void *thisObj); +// QList::toVector() const +TestBindings_EXPORT void *c_QList_T_QObject_T___toVector(void *thisObj); +// QList::value(qsizetype i) const +TestBindings_EXPORT void *c_QList_T_QObject_T___value_qsizetype(void *thisObj, qsizetype i); +TestBindings_EXPORT void c_QList_T_QObject_T___destructor(void *thisObj); +TestBindings_EXPORT void c_QList_T_QObject_T__Finalizer(void *cppObj); +} +extern "C" { +// QList::QList() +TestBindings_EXPORT void *c_QList_T_QByteArray_T___constructor(); +// QList::QList(qsizetype size) +TestBindings_EXPORT void *c_QList_T_QByteArray_T___constructor_qsizetype(qsizetype size); +// QList::append(const QList & l) +TestBindings_EXPORT void c_QList_T_QByteArray_T___append_QList_T(void *thisObj, void *l_); +// QList::at(qsizetype i) const +TestBindings_EXPORT const void *c_QList_T_QByteArray_T___at_qsizetype(void *thisObj, qsizetype i); +// QList::back() +TestBindings_EXPORT void *c_QList_T_QByteArray_T___back(void *thisObj); +// QList::capacity() const +TestBindings_EXPORT qsizetype c_QList_T_QByteArray_T___capacity(void *thisObj); +// QList::clear() +TestBindings_EXPORT void c_QList_T_QByteArray_T___clear(void *thisObj); +// QList::constFirst() const +TestBindings_EXPORT const void *c_QList_T_QByteArray_T___constFirst(void *thisObj); +// QList::constLast() const +TestBindings_EXPORT const void *c_QList_T_QByteArray_T___constLast(void *thisObj); +// QList::count() const +TestBindings_EXPORT qsizetype c_QList_T_QByteArray_T___count(void *thisObj); +// QList::detach() +TestBindings_EXPORT void c_QList_T_QByteArray_T___detach(void *thisObj); +// QList::empty() const +TestBindings_EXPORT bool c_QList_T_QByteArray_T___empty(void *thisObj); +// QList::first() +TestBindings_EXPORT void *c_QList_T_QByteArray_T___first(void *thisObj); +// QList::first(qsizetype n) const +TestBindings_EXPORT void *c_QList_T_QByteArray_T___first_qsizetype(void *thisObj, qsizetype n); +// QList::front() +TestBindings_EXPORT void *c_QList_T_QByteArray_T___front(void *thisObj); +// QList::isDetached() const +TestBindings_EXPORT bool c_QList_T_QByteArray_T___isDetached(void *thisObj); +// QList::isEmpty() const +TestBindings_EXPORT bool c_QList_T_QByteArray_T___isEmpty(void *thisObj); +// QList::isSharedWith(const QList & other) const +TestBindings_EXPORT bool c_QList_T_QByteArray_T___isSharedWith_QList_T(void *thisObj, void *other_); +// QList::last() +TestBindings_EXPORT void *c_QList_T_QByteArray_T___last(void *thisObj); +// QList::last(qsizetype n) const +TestBindings_EXPORT void *c_QList_T_QByteArray_T___last_qsizetype(void *thisObj, qsizetype n); +// QList::length() const +TestBindings_EXPORT qsizetype c_QList_T_QByteArray_T___length(void *thisObj); +// QList::mid(qsizetype pos, qsizetype len) const +TestBindings_EXPORT void * +c_QList_T_QByteArray_T___mid_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype len); +// QList::move(qsizetype from, qsizetype to) +TestBindings_EXPORT void +c_QList_T_QByteArray_T___move_qsizetype_qsizetype(void *thisObj, qsizetype from, qsizetype to); +// QList::pop_back() +TestBindings_EXPORT void c_QList_T_QByteArray_T___pop_back(void *thisObj); +// QList::pop_front() +TestBindings_EXPORT void c_QList_T_QByteArray_T___pop_front(void *thisObj); +// QList::remove(qsizetype i, qsizetype n) +TestBindings_EXPORT void +c_QList_T_QByteArray_T___remove_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype n); +// QList::removeAt(qsizetype i) +TestBindings_EXPORT void c_QList_T_QByteArray_T___removeAt_qsizetype(void *thisObj, qsizetype i); +// QList::removeFirst() +TestBindings_EXPORT void c_QList_T_QByteArray_T___removeFirst(void *thisObj); +// QList::removeLast() +TestBindings_EXPORT void c_QList_T_QByteArray_T___removeLast(void *thisObj); +// QList::reserve(qsizetype size) +TestBindings_EXPORT void c_QList_T_QByteArray_T___reserve_qsizetype(void *thisObj, qsizetype size); +// QList::resize(qsizetype size) +TestBindings_EXPORT void c_QList_T_QByteArray_T___resize_qsizetype(void *thisObj, qsizetype size); +// QList::shrink_to_fit() +TestBindings_EXPORT void c_QList_T_QByteArray_T___shrink_to_fit(void *thisObj); +// QList::size() const +TestBindings_EXPORT qsizetype c_QList_T_QByteArray_T___size(void *thisObj); +// QList::sliced(qsizetype pos) const +TestBindings_EXPORT void *c_QList_T_QByteArray_T___sliced_qsizetype(void *thisObj, qsizetype pos); +// QList::sliced(qsizetype pos, qsizetype n) const +TestBindings_EXPORT void * +c_QList_T_QByteArray_T___sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype n); +// QList::squeeze() +TestBindings_EXPORT void c_QList_T_QByteArray_T___squeeze(void *thisObj); +// QList::swapItemsAt(qsizetype i, qsizetype j) +TestBindings_EXPORT void +c_QList_T_QByteArray_T___swapItemsAt_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype j); +// QList::takeAt(qsizetype i) +TestBindings_EXPORT void *c_QList_T_QByteArray_T___takeAt_qsizetype(void *thisObj, qsizetype i); +// QList::toList() const +TestBindings_EXPORT void *c_QList_T_QByteArray_T___toList(void *thisObj); +// QList::toVector() const +TestBindings_EXPORT void *c_QList_T_QByteArray_T___toVector(void *thisObj); +// QList::value(qsizetype i) const +TestBindings_EXPORT void *c_QList_T_QByteArray_T___value_qsizetype(void *thisObj, qsizetype i); +TestBindings_EXPORT void c_QList_T_QByteArray_T___destructor(void *thisObj); +TestBindings_EXPORT void c_QList_T_QByteArray_T__Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/QMap_c.cpp b/tests/generated/TestBindings/dart/ffi/QMap_c.cpp new file mode 100644 index 0000000..86cbf81 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/QMap_c.cpp @@ -0,0 +1,286 @@ +#include "QMap_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +template +QMap_wrapper::QMap_wrapper() + : ::QMap() +{ +} +template +void QMap_wrapper::clear() +{ + ::QMap::clear(); +} +template +bool QMap_wrapper::contains(const Key &key) const +{ + return ::QMap::contains(key); +} +template +void QMap_wrapper::detach() +{ + ::QMap::detach(); +} +template +bool QMap_wrapper::empty() const +{ + return ::QMap::empty(); +} +template +T &QMap_wrapper::first() +{ + return ::QMap::first(); +} +template +const Key &QMap_wrapper::firstKey() const +{ + return ::QMap::firstKey(); +} +template +void QMap_wrapper::insert(const QMap &map) +{ + ::QMap::insert(map); +} +template +bool QMap_wrapper::isDetached() const +{ + return ::QMap::isDetached(); +} +template +bool QMap_wrapper::isEmpty() const +{ + return ::QMap::isEmpty(); +} +template +bool QMap_wrapper::isSharedWith(const QMap &other) const +{ + return ::QMap::isSharedWith(other); +} +template +Key QMap_wrapper::key(const T &value, const Key &defaultKey) const +{ + return ::QMap::key(value, defaultKey); +} +template +QList QMap_wrapper::keys() const +{ + return ::QMap::keys(); +} +template +QList QMap_wrapper::keys(const T &value) const +{ + return ::QMap::keys(value); +} +template +T &QMap_wrapper::last() +{ + return ::QMap::last(); +} +template +const Key &QMap_wrapper::lastKey() const +{ + return ::QMap::lastKey(); +} +template +T QMap_wrapper::take(const Key &key) +{ + return ::QMap::take(key); +} +template +T QMap_wrapper::value(const Key &key, const T &defaultValue) const +{ + return ::QMap::value(key, defaultValue); +} +template +QList QMap_wrapper::values() const +{ + return ::QMap::values(); +} +template +QMap_wrapper::~QMap_wrapper() +{ +} + +} +template +static QMap *fromPtr(void *ptr) +{ + return reinterpret_cast *>(ptr); +} +template +static TestBindings_wrappersNS::QMap_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast *>(ptr); +} +extern "C" { +void c_QMap_T_QString_QVariant_T__Finalizer(void *cppObj) +{ + delete reinterpret_cast *>(cppObj); +} +void *c_QMap_T_QString_QVariant_T___constructor() +{ + auto ptr = new TestBindings_wrappersNS::QMap_wrapper(); + return reinterpret_cast(ptr); +} +// clear() +void c_QMap_T_QString_QVariant_T___clear(void *thisObj) +{ + fromPtr(thisObj)->clear(); +} +// contains(const Key & key) const +bool c_QMap_T_QString_QVariant_T___contains_QString(void *thisObj, const char *key_) +{ + const auto key = QString::fromUtf8(key_); + const auto &result = fromPtr(thisObj)->contains(key); + free(( char * )key_); + return result; +} +// detach() +void c_QMap_T_QString_QVariant_T___detach(void *thisObj) +{ + fromPtr(thisObj)->detach(); +} +// empty() const +bool c_QMap_T_QString_QVariant_T___empty(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->empty(); + return result; +} +// first() +void *c_QMap_T_QString_QVariant_T___first(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->first() }; + return result; +} +// firstKey() const +const void *c_QMap_T_QString_QVariant_T___firstKey(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->firstKey() }; + return result; +} +// insert(const QMap & map) +void c_QMap_T_QString_QVariant_T___insert_QMap_Key_T(void *thisObj, void *map_) +{ + assert(map_); + auto &map = *reinterpret_cast *>(map_); + fromPtr(thisObj)->insert(map); +} +// isDetached() const +bool c_QMap_T_QString_QVariant_T___isDetached(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isDetached(); + return result; +} +// isEmpty() const +bool c_QMap_T_QString_QVariant_T___isEmpty(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isEmpty(); + return result; +} +// isSharedWith(const QMap & other) const +bool c_QMap_T_QString_QVariant_T___isSharedWith_QMap_Key_T(void *thisObj, void *other_) +{ + assert(other_); + auto &other = *reinterpret_cast *>(other_); + const auto &result = fromPtr(thisObj)->isSharedWith(other); + return result; +} +// key(const T & value, const Key & defaultKey) const +void *c_QMap_T_QString_QVariant_T___key_QVariant_QString(void *thisObj, void *value_, + const char *defaultKey_) +{ + assert(value_); + auto &value = *reinterpret_cast(value_); + const auto defaultKey = QString::fromUtf8(defaultKey_); + const auto &result = new Dartagnan::ValueWrapper { + fromPtr(thisObj)->key(value, defaultKey) + }; + free(( char * )defaultKey_); + return result; +} +// keys() const +void *c_QMap_T_QString_QVariant_T___keys(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->keys() }; + return result; +} +// keys(const T & value) const +void *c_QMap_T_QString_QVariant_T___keys_QVariant(void *thisObj, void *value_) +{ + assert(value_); + auto &value = *reinterpret_cast(value_); + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->keys(value) + }; + return result; +} +// last() +void *c_QMap_T_QString_QVariant_T___last(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->last() }; + return result; +} +// lastKey() const +const void *c_QMap_T_QString_QVariant_T___lastKey(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->lastKey() }; + return result; +} +// take(const Key & key) +void *c_QMap_T_QString_QVariant_T___take_QString(void *thisObj, const char *key_) +{ + const auto key = QString::fromUtf8(key_); + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->take(key) }; + free(( char * )key_); + return result; +} +// value(const Key & key, const T & defaultValue) const +void *c_QMap_T_QString_QVariant_T___value_QString_QVariant(void *thisObj, const char *key_, + void *defaultValue_) +{ + const auto key = QString::fromUtf8(key_); + assert(defaultValue_); + auto &defaultValue = *reinterpret_cast(defaultValue_); + const auto &result = new Dartagnan::ValueWrapper { + fromPtr(thisObj)->value(key, defaultValue) + }; + free(( char * )key_); + return result; +} +// values() const +void *c_QMap_T_QString_QVariant_T___values(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper> { + fromPtr(thisObj)->values() + }; + return result; +} +void c_QMap_T_QString_QVariant_T___destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} diff --git a/tests/generated/TestBindings/dart/ffi/QMap_c.h b/tests/generated/TestBindings/dart/ffi/QMap_c.h new file mode 100644 index 0000000..87ea969 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/QMap_c.h @@ -0,0 +1,86 @@ +#include "TestBindings_exports.h" +#include +#include +#include +#include +#include +#include +#include +#include + +namespace TestBindings_wrappersNS { +template +class QMap_wrapper : public ::QMap +{ +public: + ~QMap_wrapper(); + QMap_wrapper(); + void clear(); + bool contains(const Key &key) const; + void detach(); + bool empty() const; + T &first(); + const Key &firstKey() const; + void insert(const QMap &map); + bool isDetached() const; + bool isEmpty() const; + bool isSharedWith(const QMap &other) const; + Key key(const T &value, const Key &defaultKey = Key()) const; + QList keys() const; + QList keys(const T &value) const; + T &last(); + const Key &lastKey() const; + T take(const Key &key); + T value(const Key &key, const T &defaultValue = T()) const; + QList values() const; +}; +} +extern "C" { +// QMap::QMap() +TestBindings_EXPORT void *c_QMap_T_QString_QVariant_T___constructor(); +// QMap::clear() +TestBindings_EXPORT void c_QMap_T_QString_QVariant_T___clear(void *thisObj); +// QMap::contains(const Key & key) const +TestBindings_EXPORT bool c_QMap_T_QString_QVariant_T___contains_QString(void *thisObj, + const char *key_); +// QMap::detach() +TestBindings_EXPORT void c_QMap_T_QString_QVariant_T___detach(void *thisObj); +// QMap::empty() const +TestBindings_EXPORT bool c_QMap_T_QString_QVariant_T___empty(void *thisObj); +// QMap::first() +TestBindings_EXPORT void *c_QMap_T_QString_QVariant_T___first(void *thisObj); +// QMap::firstKey() const +TestBindings_EXPORT const void *c_QMap_T_QString_QVariant_T___firstKey(void *thisObj); +// QMap::insert(const QMap & map) +TestBindings_EXPORT void c_QMap_T_QString_QVariant_T___insert_QMap_Key_T(void *thisObj, void *map_); +// QMap::isDetached() const +TestBindings_EXPORT bool c_QMap_T_QString_QVariant_T___isDetached(void *thisObj); +// QMap::isEmpty() const +TestBindings_EXPORT bool c_QMap_T_QString_QVariant_T___isEmpty(void *thisObj); +// QMap::isSharedWith(const QMap & other) const +TestBindings_EXPORT bool c_QMap_T_QString_QVariant_T___isSharedWith_QMap_Key_T(void *thisObj, + void *other_); +// QMap::key(const T & value, const Key & defaultKey) const +TestBindings_EXPORT void * +c_QMap_T_QString_QVariant_T___key_QVariant_QString(void *thisObj, void *value_, + const char *defaultKey_); +// QMap::keys() const +TestBindings_EXPORT void *c_QMap_T_QString_QVariant_T___keys(void *thisObj); +// QMap::keys(const T & value) const +TestBindings_EXPORT void *c_QMap_T_QString_QVariant_T___keys_QVariant(void *thisObj, void *value_); +// QMap::last() +TestBindings_EXPORT void *c_QMap_T_QString_QVariant_T___last(void *thisObj); +// QMap::lastKey() const +TestBindings_EXPORT const void *c_QMap_T_QString_QVariant_T___lastKey(void *thisObj); +// QMap::take(const Key & key) +TestBindings_EXPORT void *c_QMap_T_QString_QVariant_T___take_QString(void *thisObj, + const char *key_); +// QMap::value(const Key & key, const T & defaultValue) const +TestBindings_EXPORT void *c_QMap_T_QString_QVariant_T___value_QString_QVariant(void *thisObj, + const char *key_, + void *defaultValue_); +// QMap::values() const +TestBindings_EXPORT void *c_QMap_T_QString_QVariant_T___values(void *thisObj); +TestBindings_EXPORT void c_QMap_T_QString_QVariant_T___destructor(void *thisObj); +TestBindings_EXPORT void c_QMap_T_QString_QVariant_T__Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/QObject_c.cpp b/tests/generated/TestBindings/dart/ffi/QObject_c.cpp new file mode 100644 index 0000000..5c58f2c --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/QObject_c.cpp @@ -0,0 +1,465 @@ +#include "QObject_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +QObject_wrapper::QObject_wrapper(QObject *parent) + : ::QObject(parent) +{ +} +bool QObject_wrapper::blockSignals(bool b) +{ + return ::QObject::blockSignals(b); +} +const QList &QObject_wrapper::children() const +{ + return ::QObject::children(); +} +void QObject_wrapper::customEvent(QEvent *event) +{ + if (m_customEventCallback) { + const void *thisPtr = this; + m_customEventCallback(const_cast(thisPtr), event); + } else { + ::QObject::customEvent(event); + } +} +void QObject_wrapper::customEvent_nocallback(QEvent *event) +{ + ::QObject::customEvent(event); +} +void QObject_wrapper::deleteLater() +{ + ::QObject::deleteLater(); +} +void QObject_wrapper::destroyed(QObject *arg__1) +{ + ::QObject::destroyed(arg__1); +} +bool QObject_wrapper::disconnect(const QObject *receiver, const char *member) const +{ + return ::QObject::disconnect(receiver, member); +} +bool QObject_wrapper::disconnect(const QObject *sender, const char *signal, const QObject *receiver, + const char *member) +{ + return ::QObject::disconnect(sender, signal, receiver, member); +} +bool QObject_wrapper::disconnect(const char *signal, const QObject *receiver, + const char *member) const +{ + return ::QObject::disconnect(signal, receiver, member); +} +void QObject_wrapper::dumpObjectInfo() const +{ + ::QObject::dumpObjectInfo(); +} +void QObject_wrapper::dumpObjectTree() const +{ + ::QObject::dumpObjectTree(); +} +QList QObject_wrapper::dynamicPropertyNames() const +{ + return ::QObject::dynamicPropertyNames(); +} +bool QObject_wrapper::event(QEvent *event) +{ + if (m_eventCallback) { + const void *thisPtr = this; + return m_eventCallback(const_cast(thisPtr), event); + } else { + return ::QObject::event(event); + } +} +bool QObject_wrapper::event_nocallback(QEvent *event) +{ + return ::QObject::event(event); +} +bool QObject_wrapper::eventFilter(QObject *watched, QEvent *event) +{ + if (m_eventFilterCallback) { + const void *thisPtr = this; + return m_eventFilterCallback(const_cast(thisPtr), watched, event); + } else { + return ::QObject::eventFilter(watched, event); + } +} +bool QObject_wrapper::eventFilter_nocallback(QObject *watched, QEvent *event) +{ + return ::QObject::eventFilter(watched, event); +} +bool QObject_wrapper::inherits(const char *classname) const +{ + return ::QObject::inherits(classname); +} +void QObject_wrapper::installEventFilter(QObject *filterObj) +{ + ::QObject::installEventFilter(filterObj); +} +bool QObject_wrapper::isWidgetType() const +{ + return ::QObject::isWidgetType(); +} +bool QObject_wrapper::isWindowType() const +{ + return ::QObject::isWindowType(); +} +void QObject_wrapper::killTimer(int id) +{ + ::QObject::killTimer(id); +} +QString QObject_wrapper::objectName() const +{ + return ::QObject::objectName(); +} +QObject *QObject_wrapper::parent() const +{ + return ::QObject::parent(); +} +QVariant QObject_wrapper::property(const char *name) const +{ + return ::QObject::property(name); +} +int QObject_wrapper::receivers(const char *signal) const +{ + return ::QObject::receivers(signal); +} +void QObject_wrapper::removeEventFilter(QObject *obj) +{ + ::QObject::removeEventFilter(obj); +} +QObject *QObject_wrapper::sender() const +{ + return ::QObject::sender(); +} +int QObject_wrapper::senderSignalIndex() const +{ + return ::QObject::senderSignalIndex(); +} +void QObject_wrapper::setObjectName(const QString &name) +{ + ::QObject::setObjectName(name); +} +void QObject_wrapper::setParent(QObject *parent) +{ + ::QObject::setParent(parent); +} +bool QObject_wrapper::setProperty(const char *name, const QVariant &value) +{ + return ::QObject::setProperty(name, value); +} +bool QObject_wrapper::signalsBlocked() const +{ + return ::QObject::signalsBlocked(); +} +int QObject_wrapper::startTimer(int interval) +{ + return ::QObject::startTimer(interval); +} +QString QObject_wrapper::tr(const char *s, const char *c, int n) +{ + return ::QObject::tr(s, c, n); +} +QObject_wrapper::~QObject_wrapper() +{ +} + +} +static QObject *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::QObject_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_QObject_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} +void *c_QObject__constructor_QObject(void *parent_) +{ + auto parent = reinterpret_cast(parent_); + auto ptr = new TestBindings_wrappersNS::QObject_wrapper(parent); + return reinterpret_cast(ptr); +} +// blockSignals(bool b) +bool c_QObject__blockSignals_bool(void *thisObj, bool b) +{ + const auto &result = fromPtr(thisObj)->blockSignals(b); + return result; +} +// children() const +void *c_QObject__children(void *thisObj) +{ + const auto &result = + const_cast(static_cast(&fromPtr(thisObj)->children())); + return result; +} +// customEvent(QEvent * event) +void c_QObject__customEvent_QEvent(void *thisObj, void *event_) +{ + auto event = reinterpret_cast(event_); + fromWrapperPtr(thisObj)->customEvent_nocallback(event); +} +// deleteLater() +void c_QObject__deleteLater(void *thisObj) +{ + fromPtr(thisObj)->deleteLater(); +} +// destroyed(QObject * arg__1) +void c_QObject__destroyed_QObject(void *thisObj, void *arg__1_) +{ + auto arg__1 = reinterpret_cast(arg__1_); + fromPtr(thisObj)->destroyed(arg__1); +} +void c_QObject__onDestroyed_QObject(void *thisObj, void *contextQObject, void *callback) +{ + auto instance = reinterpret_cast(thisObj); + auto context = reinterpret_cast(contextQObject); + QObject::connect(instance, &QObject::destroyed, context ? context : instance, + [thisObj, callback] { + typedef void (*SignalHandler_callback)(void *); + auto dartCallback = reinterpret_cast(callback); + dartCallback(thisObj); + }); +} +// disconnect(const QObject * receiver, const char * member) const +bool c_QObject__disconnect_QObject_char(void *thisObj, void *receiver_, const char *member) +{ + auto receiver = reinterpret_cast(receiver_); + const auto &result = fromPtr(thisObj)->disconnect(receiver, member); + free(( char * )member); + return result; +} +// disconnect(const QObject * sender, const char * signal, const QObject * receiver, const char * +// member) +bool c_static_QObject__disconnect_QObject_char_QObject_char(void *sender_, const char *signal, + void *receiver_, const char *member) +{ + auto sender = reinterpret_cast(sender_); + auto receiver = reinterpret_cast(receiver_); + const auto &result = + TestBindings_wrappersNS::QObject_wrapper::disconnect(sender, signal, receiver, member); + free(( char * )signal); + free(( char * )member); + return result; +} +// disconnect(const char * signal, const QObject * receiver, const char * member) const +bool c_QObject__disconnect_char_QObject_char(void *thisObj, const char *signal, void *receiver_, + const char *member) +{ + auto receiver = reinterpret_cast(receiver_); + const auto &result = fromPtr(thisObj)->disconnect(signal, receiver, member); + free(( char * )signal); + free(( char * )member); + return result; +} +// dumpObjectInfo() const +void c_QObject__dumpObjectInfo(void *thisObj) +{ + fromPtr(thisObj)->dumpObjectInfo(); +} +// dumpObjectTree() const +void c_QObject__dumpObjectTree(void *thisObj) +{ + fromPtr(thisObj)->dumpObjectTree(); +} +// dynamicPropertyNames() const +void *c_QObject__dynamicPropertyNames(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->dynamicPropertyNames() }; + return result; +} +// event(QEvent * event) +bool c_QObject__event_QEvent(void *thisObj, void *event_) +{ + auto event = reinterpret_cast(event_); + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->event_nocallback(event); + } else { + return targetPtr->event(event); + } + }(); + return result; +} +// eventFilter(QObject * watched, QEvent * event) +bool c_QObject__eventFilter_QObject_QEvent(void *thisObj, void *watched_, void *event_) +{ + auto watched = reinterpret_cast(watched_); + auto event = reinterpret_cast(event_); + const auto &result = [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->eventFilter_nocallback(watched, event); + } else { + return targetPtr->eventFilter(watched, event); + } + }(); + return result; +} +// inherits(const char * classname) const +bool c_QObject__inherits_char(void *thisObj, const char *classname) +{ + const auto &result = fromPtr(thisObj)->inherits(classname); + free(( char * )classname); + return result; +} +// installEventFilter(QObject * filterObj) +void c_QObject__installEventFilter_QObject(void *thisObj, void *filterObj_) +{ + auto filterObj = reinterpret_cast(filterObj_); + fromPtr(thisObj)->installEventFilter(filterObj); +} +// isWidgetType() const +bool c_QObject__isWidgetType(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isWidgetType(); + return result; +} +// isWindowType() const +bool c_QObject__isWindowType(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isWindowType(); + return result; +} +// killTimer(int id) +void c_QObject__killTimer_int(void *thisObj, int id) +{ + fromPtr(thisObj)->killTimer(id); +} +// objectName() const +void *c_QObject__objectName(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->objectName() }; + return result; +} +// parent() const +void *c_QObject__parent(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->parent(); + return result; +} +// property(const char * name) const +void *c_QObject__property_char(void *thisObj, const char *name) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->property(name) }; + free(( char * )name); + return result; +} +// receivers(const char * signal) const +int c_QObject__receivers_char(void *thisObj, const char *signal) +{ + const auto &result = fromWrapperPtr(thisObj)->receivers(signal); + free(( char * )signal); + return result; +} +// removeEventFilter(QObject * obj) +void c_QObject__removeEventFilter_QObject(void *thisObj, void *obj_) +{ + auto obj = reinterpret_cast(obj_); + fromPtr(thisObj)->removeEventFilter(obj); +} +// sender() const +void *c_QObject__sender(void *thisObj) +{ + const auto &result = fromWrapperPtr(thisObj)->sender(); + return result; +} +// senderSignalIndex() const +int c_QObject__senderSignalIndex(void *thisObj) +{ + const auto &result = fromWrapperPtr(thisObj)->senderSignalIndex(); + return result; +} +// setObjectName(const QString & name) +void c_QObject__setObjectName_QString(void *thisObj, const char *name_) +{ + const auto name = QString::fromUtf8(name_); + fromPtr(thisObj)->setObjectName(name); + free(( char * )name_); +} +// setParent(QObject * parent) +void c_QObject__setParent_QObject(void *thisObj, void *parent_) +{ + auto parent = reinterpret_cast(parent_); + fromPtr(thisObj)->setParent(parent); +} +// setProperty(const char * name, const QVariant & value) +bool c_QObject__setProperty_char_QVariant(void *thisObj, const char *name, void *value_) +{ + assert(value_); + auto &value = *reinterpret_cast(value_); + const auto &result = fromPtr(thisObj)->setProperty(name, value); + free(( char * )name); + return result; +} +// signalsBlocked() const +bool c_QObject__signalsBlocked(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->signalsBlocked(); + return result; +} +// startTimer(int interval) +int c_QObject__startTimer_int(void *thisObj, int interval) +{ + const auto &result = fromPtr(thisObj)->startTimer(interval); + return result; +} +// tr(const char * s, const char * c, int n) +void *c_static_QObject__tr_char_char_int(const char *s, const char *c, int n) +{ + const auto &result = + new Dartagnan::ValueWrapper { TestBindings_wrappersNS::QObject_wrapper::tr(s, c, + n) }; + free(( char * )s); + free(( char * )c); + return result; +} +void c_QObject__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +void c_QObject__registerVirtualMethodCallback(void *ptr, void *callback, int methodId) +{ + auto wrapper = fromWrapperPtr(ptr); + switch (methodId) { + case 481: + wrapper->m_customEventCallback = + reinterpret_cast( + callback); + break; + case 490: + wrapper->m_eventCallback = + reinterpret_cast(callback); + break; + case 491: + wrapper->m_eventFilterCallback = + reinterpret_cast( + callback); + break; + } +} +} diff --git a/tests/generated/TestBindings/dart/ffi/QObject_c.h b/tests/generated/TestBindings/dart/ffi/QObject_c.h new file mode 100644 index 0000000..752ff28 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/QObject_c.h @@ -0,0 +1,140 @@ +#include "TestBindings_exports.h" +#include +#include +#include +#include +#include +#include + +namespace TestBindings_wrappersNS { +class QObject_wrapper : public ::QObject +{ +public: + ~QObject_wrapper(); + QObject_wrapper(QObject *parent = nullptr); + bool blockSignals(bool b); + const QList &children() const; + virtual void customEvent(QEvent *event); + virtual void customEvent_nocallback(QEvent *event); + void deleteLater(); + void destroyed(QObject *arg__1 = nullptr); + bool disconnect(const QObject *receiver, const char *member = nullptr) const; + static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, + const char *member); + bool disconnect(const char *signal = nullptr, const QObject *receiver = nullptr, + const char *member = nullptr) const; + void dumpObjectInfo() const; + void dumpObjectTree() const; + QList dynamicPropertyNames() const; + virtual bool event(QEvent *event); + virtual bool event_nocallback(QEvent *event); + virtual bool eventFilter(QObject *watched, QEvent *event); + virtual bool eventFilter_nocallback(QObject *watched, QEvent *event); + bool inherits(const char *classname) const; + void installEventFilter(QObject *filterObj); + bool isWidgetType() const; + bool isWindowType() const; + void killTimer(int id); + QString objectName() const; + QObject *parent() const; + QVariant property(const char *name) const; + int receivers(const char *signal) const; + void removeEventFilter(QObject *obj); + QObject *sender() const; + int senderSignalIndex() const; + void setObjectName(const QString &name); + void setParent(QObject *parent); + bool setProperty(const char *name, const QVariant &value); + bool signalsBlocked() const; + int startTimer(int interval); + static QString tr(const char *s, const char *c, int n); + typedef void (*Callback_customEvent)(void *, QEvent *event); + Callback_customEvent m_customEventCallback = nullptr; + typedef bool (*Callback_event)(void *, QEvent *event); + Callback_event m_eventCallback = nullptr; + typedef bool (*Callback_eventFilter)(void *, QObject *watched, QEvent *event); + Callback_eventFilter m_eventFilterCallback = nullptr; +}; +} +extern "C" { +// QObject::QObject(QObject * parent) +TestBindings_EXPORT void *c_QObject__constructor_QObject(void *parent_); +// QObject::blockSignals(bool b) +TestBindings_EXPORT bool c_QObject__blockSignals_bool(void *thisObj, bool b); +// QObject::children() const +TestBindings_EXPORT void *c_QObject__children(void *thisObj); +// QObject::customEvent(QEvent * event) +TestBindings_EXPORT void c_QObject__customEvent_QEvent(void *thisObj, void *event_); +// QObject::deleteLater() +TestBindings_EXPORT void c_QObject__deleteLater(void *thisObj); +// QObject::destroyed(QObject * arg__1) +TestBindings_EXPORT void c_QObject__destroyed_QObject(void *thisObj, void *arg__1_); +TestBindings_EXPORT void +c_QObject__onDestroyed_QObject(void *thisObj, void *contextQObject, + void *callback); // QObject::disconnect(const QObject * receiver, + // const char * member) const +TestBindings_EXPORT bool c_QObject__disconnect_QObject_char(void *thisObj, void *receiver_, + const char *member); +// QObject::disconnect(const QObject * sender, const char * signal, const QObject * receiver, const +// char * member) +TestBindings_EXPORT bool c_static_QObject__disconnect_QObject_char_QObject_char(void *sender_, + const char *signal, + void *receiver_, + const char *member); +// QObject::disconnect(const char * signal, const QObject * receiver, const char * member) const +TestBindings_EXPORT bool c_QObject__disconnect_char_QObject_char(void *thisObj, const char *signal, + void *receiver_, + const char *member); +// QObject::dumpObjectInfo() const +TestBindings_EXPORT void c_QObject__dumpObjectInfo(void *thisObj); +// QObject::dumpObjectTree() const +TestBindings_EXPORT void c_QObject__dumpObjectTree(void *thisObj); +// QObject::dynamicPropertyNames() const +TestBindings_EXPORT void *c_QObject__dynamicPropertyNames(void *thisObj); +// QObject::event(QEvent * event) +TestBindings_EXPORT bool c_QObject__event_QEvent(void *thisObj, void *event_); +// QObject::eventFilter(QObject * watched, QEvent * event) +TestBindings_EXPORT bool c_QObject__eventFilter_QObject_QEvent(void *thisObj, void *watched_, + void *event_); +// QObject::inherits(const char * classname) const +TestBindings_EXPORT bool c_QObject__inherits_char(void *thisObj, const char *classname); +// QObject::installEventFilter(QObject * filterObj) +TestBindings_EXPORT void c_QObject__installEventFilter_QObject(void *thisObj, void *filterObj_); +// QObject::isWidgetType() const +TestBindings_EXPORT bool c_QObject__isWidgetType(void *thisObj); +// QObject::isWindowType() const +TestBindings_EXPORT bool c_QObject__isWindowType(void *thisObj); +// QObject::killTimer(int id) +TestBindings_EXPORT void c_QObject__killTimer_int(void *thisObj, int id); +// QObject::objectName() const +TestBindings_EXPORT void *c_QObject__objectName(void *thisObj); +// QObject::parent() const +TestBindings_EXPORT void *c_QObject__parent(void *thisObj); +// QObject::property(const char * name) const +TestBindings_EXPORT void *c_QObject__property_char(void *thisObj, const char *name); +// QObject::receivers(const char * signal) const +TestBindings_EXPORT int c_QObject__receivers_char(void *thisObj, const char *signal); +// QObject::removeEventFilter(QObject * obj) +TestBindings_EXPORT void c_QObject__removeEventFilter_QObject(void *thisObj, void *obj_); +// QObject::sender() const +TestBindings_EXPORT void *c_QObject__sender(void *thisObj); +// QObject::senderSignalIndex() const +TestBindings_EXPORT int c_QObject__senderSignalIndex(void *thisObj); +// QObject::setObjectName(const QString & name) +TestBindings_EXPORT void c_QObject__setObjectName_QString(void *thisObj, const char *name_); +// QObject::setParent(QObject * parent) +TestBindings_EXPORT void c_QObject__setParent_QObject(void *thisObj, void *parent_); +// QObject::setProperty(const char * name, const QVariant & value) +TestBindings_EXPORT bool c_QObject__setProperty_char_QVariant(void *thisObj, const char *name, + void *value_); +// QObject::signalsBlocked() const +TestBindings_EXPORT bool c_QObject__signalsBlocked(void *thisObj); +// QObject::startTimer(int interval) +TestBindings_EXPORT int c_QObject__startTimer_int(void *thisObj, int interval); +// QObject::tr(const char * s, const char * c, int n) +TestBindings_EXPORT void *c_static_QObject__tr_char_char_int(const char *s, const char *c, int n); +TestBindings_EXPORT void c_QObject__destructor(void *thisObj); +TestBindings_EXPORT void c_QObject__registerVirtualMethodCallback(void *ptr, void *callback, + int methodId); +TestBindings_EXPORT void c_QObject_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/QSet_c.cpp b/tests/generated/TestBindings/dart/ffi/QSet_c.cpp new file mode 100644 index 0000000..ba69197 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/QSet_c.cpp @@ -0,0 +1,122 @@ +#include "QSet_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +template +QSet_wrapper::QSet_wrapper() + : ::QSet() +{ +} +template +qsizetype QSet_wrapper::capacity() const +{ + return ::QSet::capacity(); +} +template +void QSet_wrapper::clear() +{ + ::QSet::clear(); +} +template +bool QSet_wrapper::contains(const QSet &set) const +{ + return ::QSet::contains(set); +} +template +qsizetype QSet_wrapper::count() const +{ + return ::QSet::count(); +} +template +void QSet_wrapper::detach() +{ + ::QSet::detach(); +} +template +bool QSet_wrapper::empty() const +{ + return ::QSet::empty(); +} +template +QSet &QSet_wrapper::intersect(const QSet &other) +{ + return ::QSet::intersect(other); +} +template +bool QSet_wrapper::intersects(const QSet &other) const +{ + return ::QSet::intersects(other); +} +template +bool QSet_wrapper::isDetached() const +{ + return ::QSet::isDetached(); +} +template +bool QSet_wrapper::isEmpty() const +{ + return ::QSet::isEmpty(); +} +template +void QSet_wrapper::reserve(qsizetype size) +{ + ::QSet::reserve(size); +} +template +qsizetype QSet_wrapper::size() const +{ + return ::QSet::size(); +} +template +void QSet_wrapper::squeeze() +{ + ::QSet::squeeze(); +} +template +QSet &QSet_wrapper::subtract(const QSet &other) +{ + return ::QSet::subtract(other); +} +template +QSet &QSet_wrapper::unite(const QSet &other) +{ + return ::QSet::unite(other); +} +template +QList QSet_wrapper::values() const +{ + return ::QSet::values(); +} +template +QSet_wrapper::~QSet_wrapper() +{ +} + +} +template +static QSet *fromPtr(void *ptr) +{ + return reinterpret_cast *>(ptr); +} +template +static TestBindings_wrappersNS::QSet_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast *>(ptr); +} \ No newline at end of file diff --git a/tests/generated/TestBindings/dart/ffi/QSet_c.h b/tests/generated/TestBindings/dart/ffi/QSet_c.h new file mode 100644 index 0000000..04ee019 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/QSet_c.h @@ -0,0 +1,29 @@ +#include "TestBindings_exports.h" +#include +#include + +namespace TestBindings_wrappersNS { +template +class QSet_wrapper : public ::QSet +{ +public: + ~QSet_wrapper(); + QSet_wrapper(); + qsizetype capacity() const; + void clear(); + bool contains(const QSet &set) const; + qsizetype count() const; + void detach(); + bool empty() const; + QSet &intersect(const QSet &other); + bool intersects(const QSet &other) const; + bool isDetached() const; + bool isEmpty() const; + void reserve(qsizetype size); + qsizetype size() const; + void squeeze(); + QSet &subtract(const QSet &other); + QSet &unite(const QSet &other); + QList values() const; +}; +} \ No newline at end of file diff --git a/tests/generated/TestBindings/dart/ffi/QString_c.cpp b/tests/generated/TestBindings/dart/ffi/QString_c.cpp new file mode 100644 index 0000000..b884ec9 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/QString_c.cpp @@ -0,0 +1,1016 @@ +#include "QString_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +QString_wrapper::QString_wrapper() + : ::QString() +{ +} +QString_wrapper::QString_wrapper(const QByteArray &a) + : ::QString(a) +{ +} +QString_wrapper::QString_wrapper(const char *ch) + : ::QString(ch) +{ +} +QString &QString_wrapper::append(const QByteArray &s) +{ + return ::QString::append(s); +} +QString &QString_wrapper::append(const QString &s) +{ + return ::QString::append(s); +} +QString &QString_wrapper::append(const char *s) +{ + return ::QString::append(s); +} +QString QString_wrapper::arg(const QString &a, int fieldWidth) const +{ + return ::QString::arg(a, fieldWidth); +} +QString QString_wrapper::arg(int a, int fieldWidth, int base) const +{ + return ::QString::arg(a, fieldWidth, base); +} +QString QString_wrapper::arg(long a, int fieldwidth, int base) const +{ + return ::QString::arg(a, fieldwidth, base); +} +QString QString_wrapper::arg(qint64 a, int fieldwidth, int base) const +{ + return ::QString::arg(a, fieldwidth, base); +} +QString QString_wrapper::arg(short a, int fieldWidth, int base) const +{ + return ::QString::arg(a, fieldWidth, base); +} +QString QString_wrapper::asprintf(const char *format) +{ + return ::QString::asprintf(format); +} +qsizetype QString_wrapper::capacity() const +{ + return ::QString::capacity(); +} +void QString_wrapper::chop(qsizetype n) +{ + ::QString::chop(n); +} +QString QString_wrapper::chopped(qsizetype n) const +{ + return ::QString::chopped(n); +} +void QString_wrapper::clear() +{ + ::QString::clear(); +} +int QString_wrapper::compare(const QString &s) const +{ + return ::QString::compare(s); +} +int QString_wrapper::compare(const QString &s1, const QString &s2) +{ + return ::QString::compare(s1, s2); +} +bool QString_wrapper::contains(const QString &s) const +{ + return ::QString::contains(s); +} +qsizetype QString_wrapper::count() const +{ + return ::QString::count(); +} +qsizetype QString_wrapper::count(const QString &s) const +{ + return ::QString::count(s); +} +void QString_wrapper::detach() +{ + ::QString::detach(); +} +bool QString_wrapper::endsWith(const QString &s) const +{ + return ::QString::endsWith(s); +} +QString QString_wrapper::first(qsizetype n) const +{ + return ::QString::first(n); +} +QString QString_wrapper::fromLatin1(const char *str, qsizetype size) +{ + return ::QString::fromLatin1(str, size); +} +QString QString_wrapper::fromLocal8Bit(const char *str, qsizetype size) +{ + return ::QString::fromLocal8Bit(str, size); +} +QString QString_wrapper::fromUtf8(const char *utf8, qsizetype size) +{ + return ::QString::fromUtf8(utf8, size); +} +qsizetype QString_wrapper::indexOf(const QString &s, qsizetype from) const +{ + return ::QString::indexOf(s, from); +} +QString &QString_wrapper::insert(qsizetype i, const QByteArray &s) +{ + return ::QString::insert(i, s); +} +QString &QString_wrapper::insert(qsizetype i, const QString &s) +{ + return ::QString::insert(i, s); +} +QString &QString_wrapper::insert(qsizetype i, const char *s) +{ + return ::QString::insert(i, s); +} +bool QString_wrapper::isDetached() const +{ + return ::QString::isDetached(); +} +bool QString_wrapper::isEmpty() const +{ + return ::QString::isEmpty(); +} +bool QString_wrapper::isLower() const +{ + return ::QString::isLower(); +} +bool QString_wrapper::isNull() const +{ + return ::QString::isNull(); +} +bool QString_wrapper::isRightToLeft() const +{ + return ::QString::isRightToLeft(); +} +bool QString_wrapper::isSharedWith(const QString &other) const +{ + return ::QString::isSharedWith(other); +} +bool QString_wrapper::isSimpleText() const +{ + return ::QString::isSimpleText(); +} +bool QString_wrapper::isUpper() const +{ + return ::QString::isUpper(); +} +bool QString_wrapper::isValidUtf16() const +{ + return ::QString::isValidUtf16(); +} +QString QString_wrapper::last(qsizetype n) const +{ + return ::QString::last(n); +} +qsizetype QString_wrapper::lastIndexOf(const QString &s) const +{ + return ::QString::lastIndexOf(s); +} +qsizetype QString_wrapper::lastIndexOf(const QString &s, qsizetype from) const +{ + return ::QString::lastIndexOf(s, from); +} +QString QString_wrapper::left(qsizetype n) const +{ + return ::QString::left(n); +} +QString QString_wrapper::leftJustified(qsizetype width) const +{ + return ::QString::leftJustified(width); +} +qsizetype QString_wrapper::length() const +{ + return ::QString::length(); +} +int QString_wrapper::localeAwareCompare(const QString &s) const +{ + return ::QString::localeAwareCompare(s); +} +int QString_wrapper::localeAwareCompare(const QString &s1, const QString &s2) +{ + return ::QString::localeAwareCompare(s1, s2); +} +QString QString_wrapper::mid(qsizetype position, qsizetype n) const +{ + return ::QString::mid(position, n); +} +QString QString_wrapper::number(int arg__1, int base) +{ + return ::QString::number(arg__1, base); +} +QString QString_wrapper::number(long arg__1, int base) +{ + return ::QString::number(arg__1, base); +} +QString QString_wrapper::number(qint64 arg__1, int base) +{ + return ::QString::number(arg__1, base); +} +QString &QString_wrapper::prepend(const QByteArray &s) +{ + return ::QString::prepend(s); +} +QString &QString_wrapper::prepend(const QString &s) +{ + return ::QString::prepend(s); +} +QString &QString_wrapper::prepend(const char *s) +{ + return ::QString::prepend(s); +} +void QString_wrapper::push_back(const QString &s) +{ + ::QString::push_back(s); +} +void QString_wrapper::push_front(const QString &s) +{ + ::QString::push_front(s); +} +QString &QString_wrapper::remove(const QString &s) +{ + return ::QString::remove(s); +} +QString &QString_wrapper::remove(qsizetype i, qsizetype len) +{ + return ::QString::remove(i, len); +} +QString QString_wrapper::repeated(qsizetype times) const +{ + return ::QString::repeated(times); +} +QString &QString_wrapper::replace(const QString &before, const QString &after) +{ + return ::QString::replace(before, after); +} +QString &QString_wrapper::replace(qsizetype i, qsizetype len, const QString &after) +{ + return ::QString::replace(i, len, after); +} +void QString_wrapper::reserve(qsizetype size) +{ + ::QString::reserve(size); +} +void QString_wrapper::resize(qsizetype size) +{ + ::QString::resize(size); +} +QString QString_wrapper::right(qsizetype n) const +{ + return ::QString::right(n); +} +QString QString_wrapper::rightJustified(qsizetype width) const +{ + return ::QString::rightJustified(width); +} +QString QString_wrapper::section(const QString &in_sep, qsizetype start, qsizetype end) const +{ + return ::QString::section(in_sep, start, end); +} +QString &QString_wrapper::setNum(int arg__1, int base) +{ + return ::QString::setNum(arg__1, base); +} +QString &QString_wrapper::setNum(long arg__1, int base) +{ + return ::QString::setNum(arg__1, base); +} +QString &QString_wrapper::setNum(qint64 arg__1, int base) +{ + return ::QString::setNum(arg__1, base); +} +QString &QString_wrapper::setNum(short arg__1, int base) +{ + return ::QString::setNum(arg__1, base); +} +void QString_wrapper::shrink_to_fit() +{ + ::QString::shrink_to_fit(); +} +QString QString_wrapper::simplified() +{ + return ::QString::simplified(); +} +qsizetype QString_wrapper::size() const +{ + return ::QString::size(); +} +QString QString_wrapper::sliced(qsizetype pos) const +{ + return ::QString::sliced(pos); +} +QString QString_wrapper::sliced(qsizetype pos, qsizetype n) const +{ + return ::QString::sliced(pos, n); +} +QList QString_wrapper::split(const QString &sep) const +{ + return ::QString::split(sep); +} +void QString_wrapper::squeeze() +{ + ::QString::squeeze(); +} +bool QString_wrapper::startsWith(const QString &s) const +{ + return ::QString::startsWith(s); +} +QString QString_wrapper::toCaseFolded() +{ + return ::QString::toCaseFolded(); +} +QString QString_wrapper::toHtmlEscaped() const +{ + return ::QString::toHtmlEscaped(); +} +QByteArray QString_wrapper::toLatin1() +{ + return ::QString::toLatin1(); +} +QByteArray QString_wrapper::toLocal8Bit() +{ + return ::QString::toLocal8Bit(); +} +QString QString_wrapper::toLower() +{ + return ::QString::toLower(); +} +QList QString_wrapper::toUcs4() const +{ + return ::QString::toUcs4(); +} +QString QString_wrapper::toUpper() +{ + return ::QString::toUpper(); +} +QByteArray QString_wrapper::toUtf8() +{ + return ::QString::toUtf8(); +} +QString QString_wrapper::trimmed() +{ + return ::QString::trimmed(); +} +void QString_wrapper::truncate(qsizetype pos) +{ + ::QString::truncate(pos); +} +QString_wrapper::~QString_wrapper() +{ +} + +} +static QString *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::QString_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_QString_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} +void *c_QString__constructor() +{ + auto ptr = new TestBindings_wrappersNS::QString_wrapper(); + return reinterpret_cast(ptr); +} +void *c_QString__constructor_QByteArray(void *a_) +{ + assert(a_); + auto &a = *reinterpret_cast(a_); + auto ptr = new TestBindings_wrappersNS::QString_wrapper(a); + return reinterpret_cast(ptr); +} +void *c_QString__constructor_char(const char *ch) +{ + auto ptr = new TestBindings_wrappersNS::QString_wrapper(ch); + return reinterpret_cast(ptr); +} +// append(const QByteArray & s) +void *c_QString__append_QByteArray(void *thisObj, void *s_) +{ + assert(s_); + auto &s = *reinterpret_cast(s_); + const auto &result = &fromPtr(thisObj)->append(s); + return result; +} +// append(const QString & s) +void *c_QString__append_QString(void *thisObj, const char *s_) +{ + const auto s = QString::fromUtf8(s_); + const auto &result = &fromPtr(thisObj)->append(s); + free(( char * )s_); + return result; +} +// append(const char * s) +void *c_QString__append_char(void *thisObj, const char *s) +{ + const auto &result = &fromPtr(thisObj)->append(s); + free(( char * )s); + return result; +} +// arg(const QString & a, int fieldWidth) const +void *c_QString__arg_QString_int(void *thisObj, const char *a_, int fieldWidth) +{ + const auto a = QString::fromUtf8(a_); + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->arg(a, fieldWidth) }; + free(( char * )a_); + return result; +} +// arg(int a, int fieldWidth, int base) const +void *c_QString__arg_int_int_int(void *thisObj, int a, int fieldWidth, int base) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->arg(a, fieldWidth, base) }; + return result; +} +// arg(long a, int fieldwidth, int base) const +void *c_QString__arg_long_int_int(void *thisObj, long a, int fieldwidth, int base) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->arg(a, fieldwidth, base) }; + return result; +} +// arg(qint64 a, int fieldwidth, int base) const +void *c_QString__arg_qint64_int_int(void *thisObj, qint64 a, int fieldwidth, int base) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->arg(a, fieldwidth, base) }; + return result; +} +// arg(short a, int fieldWidth, int base) const +void *c_QString__arg_short_int_int(void *thisObj, short a, int fieldWidth, int base) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->arg(a, fieldWidth, base) }; + return result; +} +// asprintf(const char * format) +void *c_static_QString__asprintf_char(const char *format) +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QString_wrapper::asprintf(format) + }; + free(( char * )format); + return result; +} +// capacity() const +qsizetype c_QString__capacity(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->capacity(); + return result; +} +// chop(qsizetype n) +void c_QString__chop_qsizetype(void *thisObj, qsizetype n) +{ + fromPtr(thisObj)->chop(n); +} +// chopped(qsizetype n) const +void *c_QString__chopped_qsizetype(void *thisObj, qsizetype n) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->chopped(n) }; + return result; +} +// clear() +void c_QString__clear(void *thisObj) +{ + fromPtr(thisObj)->clear(); +} +// compare(const QString & s) const +int c_QString__compare_QString(void *thisObj, const char *s_) +{ + const auto s = QString::fromUtf8(s_); + const auto &result = fromPtr(thisObj)->compare(s); + free(( char * )s_); + return result; +} +// compare(const QString & s1, const QString & s2) +int c_static_QString__compare_QString_QString(const char *s1_, const char *s2_) +{ + const auto s1 = QString::fromUtf8(s1_); + const auto s2 = QString::fromUtf8(s2_); + const auto &result = TestBindings_wrappersNS::QString_wrapper::compare(s1, s2); + free(( char * )s1_); + free(( char * )s2_); + return result; +} +// contains(const QString & s) const +bool c_QString__contains_QString(void *thisObj, const char *s_) +{ + const auto s = QString::fromUtf8(s_); + const auto &result = fromPtr(thisObj)->contains(s); + free(( char * )s_); + return result; +} +// count() const +qsizetype c_QString__count(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->count(); + return result; +} +// count(const QString & s) const +qsizetype c_QString__count_QString(void *thisObj, const char *s_) +{ + const auto s = QString::fromUtf8(s_); + const auto &result = fromPtr(thisObj)->count(s); + free(( char * )s_); + return result; +} +// detach() +void c_QString__detach(void *thisObj) +{ + fromPtr(thisObj)->detach(); +} +// endsWith(const QString & s) const +bool c_QString__endsWith_QString(void *thisObj, const char *s_) +{ + const auto s = QString::fromUtf8(s_); + const auto &result = fromPtr(thisObj)->endsWith(s); + free(( char * )s_); + return result; +} +// first(qsizetype n) const +void *c_QString__first_qsizetype(void *thisObj, qsizetype n) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->first(n) }; + return result; +} +// fromLatin1(const char * str, qsizetype size) +void *c_static_QString__fromLatin1_char_qsizetype(const char *str, qsizetype size) +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QString_wrapper::fromLatin1(str, size) + }; + free(( char * )str); + return result; +} +// fromLocal8Bit(const char * str, qsizetype size) +void *c_static_QString__fromLocal8Bit_char_qsizetype(const char *str, qsizetype size) +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QString_wrapper::fromLocal8Bit(str, size) + }; + free(( char * )str); + return result; +} +// fromUtf8(const char * utf8, qsizetype size) +void *c_static_QString__fromUtf8_char_qsizetype(const char *utf8, qsizetype size) +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QString_wrapper::fromUtf8(utf8, size) + }; + free(( char * )utf8); + return result; +} +// indexOf(const QString & s, qsizetype from) const +qsizetype c_QString__indexOf_QString_qsizetype(void *thisObj, const char *s_, qsizetype from) +{ + const auto s = QString::fromUtf8(s_); + const auto &result = fromPtr(thisObj)->indexOf(s, from); + free(( char * )s_); + return result; +} +// insert(qsizetype i, const QByteArray & s) +void *c_QString__insert_qsizetype_QByteArray(void *thisObj, qsizetype i, void *s_) +{ + assert(s_); + auto &s = *reinterpret_cast(s_); + const auto &result = &fromPtr(thisObj)->insert(i, s); + return result; +} +// insert(qsizetype i, const QString & s) +void *c_QString__insert_qsizetype_QString(void *thisObj, qsizetype i, const char *s_) +{ + const auto s = QString::fromUtf8(s_); + const auto &result = &fromPtr(thisObj)->insert(i, s); + free(( char * )s_); + return result; +} +// insert(qsizetype i, const char * s) +void *c_QString__insert_qsizetype_char(void *thisObj, qsizetype i, const char *s) +{ + const auto &result = &fromPtr(thisObj)->insert(i, s); + free(( char * )s); + return result; +} +// isDetached() const +bool c_QString__isDetached(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isDetached(); + return result; +} +// isEmpty() const +bool c_QString__isEmpty(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isEmpty(); + return result; +} +// isLower() const +bool c_QString__isLower(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isLower(); + return result; +} +// isNull() const +bool c_QString__isNull(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isNull(); + return result; +} +// isRightToLeft() const +bool c_QString__isRightToLeft(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isRightToLeft(); + return result; +} +// isSharedWith(const QString & other) const +bool c_QString__isSharedWith_QString(void *thisObj, const char *other_) +{ + const auto other = QString::fromUtf8(other_); + const auto &result = fromPtr(thisObj)->isSharedWith(other); + free(( char * )other_); + return result; +} +// isSimpleText() const +bool c_QString__isSimpleText(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isSimpleText(); + return result; +} +// isUpper() const +bool c_QString__isUpper(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isUpper(); + return result; +} +// isValidUtf16() const +bool c_QString__isValidUtf16(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isValidUtf16(); + return result; +} +// last(qsizetype n) const +void *c_QString__last_qsizetype(void *thisObj, qsizetype n) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->last(n) }; + return result; +} +// lastIndexOf(const QString & s) const +qsizetype c_QString__lastIndexOf_QString(void *thisObj, const char *s_) +{ + const auto s = QString::fromUtf8(s_); + const auto &result = fromPtr(thisObj)->lastIndexOf(s); + free(( char * )s_); + return result; +} +// lastIndexOf(const QString & s, qsizetype from) const +qsizetype c_QString__lastIndexOf_QString_qsizetype(void *thisObj, const char *s_, qsizetype from) +{ + const auto s = QString::fromUtf8(s_); + const auto &result = fromPtr(thisObj)->lastIndexOf(s, from); + free(( char * )s_); + return result; +} +// left(qsizetype n) const +void *c_QString__left_qsizetype(void *thisObj, qsizetype n) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->left(n) }; + return result; +} +// leftJustified(qsizetype width) const +void *c_QString__leftJustified_qsizetype(void *thisObj, qsizetype width) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->leftJustified(width) }; + return result; +} +// length() const +qsizetype c_QString__length(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->length(); + return result; +} +// localeAwareCompare(const QString & s) const +int c_QString__localeAwareCompare_QString(void *thisObj, const char *s_) +{ + const auto s = QString::fromUtf8(s_); + const auto &result = fromPtr(thisObj)->localeAwareCompare(s); + free(( char * )s_); + return result; +} +// localeAwareCompare(const QString & s1, const QString & s2) +int c_static_QString__localeAwareCompare_QString_QString(const char *s1_, const char *s2_) +{ + const auto s1 = QString::fromUtf8(s1_); + const auto s2 = QString::fromUtf8(s2_); + const auto &result = TestBindings_wrappersNS::QString_wrapper::localeAwareCompare(s1, s2); + free(( char * )s1_); + free(( char * )s2_); + return result; +} +// mid(qsizetype position, qsizetype n) const +void *c_QString__mid_qsizetype_qsizetype(void *thisObj, qsizetype position, qsizetype n) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->mid(position, n) }; + return result; +} +// number(int arg__1, int base) +void *c_static_QString__number_int_int(int arg__1, int base) +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QString_wrapper::number(arg__1, base) + }; + return result; +} +// number(long arg__1, int base) +void *c_static_QString__number_long_int(long arg__1, int base) +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QString_wrapper::number(arg__1, base) + }; + return result; +} +// number(qint64 arg__1, int base) +void *c_static_QString__number_qint64_int(qint64 arg__1, int base) +{ + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QString_wrapper::number(arg__1, base) + }; + return result; +} +// prepend(const QByteArray & s) +void *c_QString__prepend_QByteArray(void *thisObj, void *s_) +{ + assert(s_); + auto &s = *reinterpret_cast(s_); + const auto &result = &fromPtr(thisObj)->prepend(s); + return result; +} +// prepend(const QString & s) +void *c_QString__prepend_QString(void *thisObj, const char *s_) +{ + const auto s = QString::fromUtf8(s_); + const auto &result = &fromPtr(thisObj)->prepend(s); + free(( char * )s_); + return result; +} +// prepend(const char * s) +void *c_QString__prepend_char(void *thisObj, const char *s) +{ + const auto &result = &fromPtr(thisObj)->prepend(s); + free(( char * )s); + return result; +} +// push_back(const QString & s) +void c_QString__push_back_QString(void *thisObj, const char *s_) +{ + const auto s = QString::fromUtf8(s_); + fromPtr(thisObj)->push_back(s); + free(( char * )s_); +} +// push_front(const QString & s) +void c_QString__push_front_QString(void *thisObj, const char *s_) +{ + const auto s = QString::fromUtf8(s_); + fromPtr(thisObj)->push_front(s); + free(( char * )s_); +} +// remove(const QString & s) +void *c_QString__remove_QString(void *thisObj, const char *s_) +{ + const auto s = QString::fromUtf8(s_); + const auto &result = &fromPtr(thisObj)->remove(s); + free(( char * )s_); + return result; +} +// remove(qsizetype i, qsizetype len) +void *c_QString__remove_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype len) +{ + const auto &result = &fromPtr(thisObj)->remove(i, len); + return result; +} +// repeated(qsizetype times) const +void *c_QString__repeated_qsizetype(void *thisObj, qsizetype times) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->repeated(times) }; + return result; +} +// replace(const QString & before, const QString & after) +void *c_QString__replace_QString_QString(void *thisObj, const char *before_, const char *after_) +{ + const auto before = QString::fromUtf8(before_); + const auto after = QString::fromUtf8(after_); + const auto &result = &fromPtr(thisObj)->replace(before, after); + free(( char * )before_); + free(( char * )after_); + return result; +} +// replace(qsizetype i, qsizetype len, const QString & after) +void *c_QString__replace_qsizetype_qsizetype_QString(void *thisObj, qsizetype i, qsizetype len, + const char *after_) +{ + const auto after = QString::fromUtf8(after_); + const auto &result = &fromPtr(thisObj)->replace(i, len, after); + free(( char * )after_); + return result; +} +// reserve(qsizetype size) +void c_QString__reserve_qsizetype(void *thisObj, qsizetype size) +{ + fromPtr(thisObj)->reserve(size); +} +// resize(qsizetype size) +void c_QString__resize_qsizetype(void *thisObj, qsizetype size) +{ + fromPtr(thisObj)->resize(size); +} +// right(qsizetype n) const +void *c_QString__right_qsizetype(void *thisObj, qsizetype n) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->right(n) }; + return result; +} +// rightJustified(qsizetype width) const +void *c_QString__rightJustified_qsizetype(void *thisObj, qsizetype width) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->rightJustified(width) }; + return result; +} +// section(const QString & in_sep, qsizetype start, qsizetype end) const +void *c_QString__section_QString_qsizetype_qsizetype(void *thisObj, const char *in_sep_, + qsizetype start, qsizetype end) +{ + const auto in_sep = QString::fromUtf8(in_sep_); + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->section(in_sep, start, end) }; + free(( char * )in_sep_); + return result; +} +// setNum(int arg__1, int base) +void *c_QString__setNum_int_int(void *thisObj, int arg__1, int base) +{ + const auto &result = &fromPtr(thisObj)->setNum(arg__1, base); + return result; +} +// setNum(long arg__1, int base) +void *c_QString__setNum_long_int(void *thisObj, long arg__1, int base) +{ + const auto &result = &fromPtr(thisObj)->setNum(arg__1, base); + return result; +} +// setNum(qint64 arg__1, int base) +void *c_QString__setNum_qint64_int(void *thisObj, qint64 arg__1, int base) +{ + const auto &result = &fromPtr(thisObj)->setNum(arg__1, base); + return result; +} +// setNum(short arg__1, int base) +void *c_QString__setNum_short_int(void *thisObj, short arg__1, int base) +{ + const auto &result = &fromPtr(thisObj)->setNum(arg__1, base); + return result; +} +// shrink_to_fit() +void c_QString__shrink_to_fit(void *thisObj) +{ + fromPtr(thisObj)->shrink_to_fit(); +} +// simplified() +void *c_QString__simplified(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->simplified() }; + return result; +} +// size() const +qsizetype c_QString__size(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->size(); + return result; +} +// sliced(qsizetype pos) const +void *c_QString__sliced_qsizetype(void *thisObj, qsizetype pos) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->sliced(pos) }; + return result; +} +// sliced(qsizetype pos, qsizetype n) const +void *c_QString__sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype n) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->sliced(pos, n) }; + return result; +} +// split(const QString & sep) const +void *c_QString__split_QString(void *thisObj, const char *sep_) +{ + const auto sep = QString::fromUtf8(sep_); + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->split(sep) }; + free(( char * )sep_); + return result; +} +// squeeze() +void c_QString__squeeze(void *thisObj) +{ + fromPtr(thisObj)->squeeze(); +} +// startsWith(const QString & s) const +bool c_QString__startsWith_QString(void *thisObj, const char *s_) +{ + const auto s = QString::fromUtf8(s_); + const auto &result = fromPtr(thisObj)->startsWith(s); + free(( char * )s_); + return result; +} +// toCaseFolded() +void *c_QString__toCaseFolded(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->toCaseFolded() }; + return result; +} +// toHtmlEscaped() const +void *c_QString__toHtmlEscaped(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->toHtmlEscaped() }; + return result; +} +// toLatin1() +void *c_QString__toLatin1(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->toLatin1() }; + return result; +} +// toLocal8Bit() +void *c_QString__toLocal8Bit(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->toLocal8Bit() }; + return result; +} +// toLower() +void *c_QString__toLower(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->toLower() }; + return result; +} +// toUcs4() const +void *c_QString__toUcs4(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->toUcs4() }; + return result; +} +// toUpper() +void *c_QString__toUpper(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->toUpper() }; + return result; +} +// toUtf8() +void *c_QString__toUtf8(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->toUtf8() }; + return result; +} +// trimmed() +void *c_QString__trimmed(void *thisObj) +{ + const auto &result = new Dartagnan::ValueWrapper { fromPtr(thisObj)->trimmed() }; + return result; +} +// truncate(qsizetype pos) +void c_QString__truncate_qsizetype(void *thisObj, qsizetype pos) +{ + fromPtr(thisObj)->truncate(pos); +} +void c_QString__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} diff --git a/tests/generated/TestBindings/dart/ffi/QString_c.h b/tests/generated/TestBindings/dart/ffi/QString_c.h new file mode 100644 index 0000000..8801569 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/QString_c.h @@ -0,0 +1,306 @@ +#include "TestBindings_exports.h" +#include +#include +#include + +namespace TestBindings_wrappersNS { +class QString_wrapper : public ::QString +{ +public: + ~QString_wrapper(); + QString_wrapper(); + QString_wrapper(const QByteArray &a); + QString_wrapper(const char *ch); + QString &append(const QByteArray &s); + QString &append(const QString &s); + QString &append(const char *s); + QString arg(const QString &a, int fieldWidth = 0) const; + QString arg(int a, int fieldWidth = 0, int base = 10) const; + QString arg(long a, int fieldwidth = 0, int base = 10) const; + QString arg(qint64 a, int fieldwidth = 0, int base = 10) const; + QString arg(short a, int fieldWidth = 0, int base = 10) const; + static QString asprintf(const char *format); + qsizetype capacity() const; + void chop(qsizetype n); + QString chopped(qsizetype n) const; + void clear(); + int compare(const QString &s) const; + static int compare(const QString &s1, const QString &s2); + bool contains(const QString &s) const; + qsizetype count() const; + qsizetype count(const QString &s) const; + void detach(); + bool endsWith(const QString &s) const; + QString first(qsizetype n) const; + static QString fromLatin1(const char *str, qsizetype size); + static QString fromLocal8Bit(const char *str, qsizetype size); + static QString fromUtf8(const char *utf8, qsizetype size); + qsizetype indexOf(const QString &s, qsizetype from = 0) const; + QString &insert(qsizetype i, const QByteArray &s); + QString &insert(qsizetype i, const QString &s); + QString &insert(qsizetype i, const char *s); + bool isDetached() const; + bool isEmpty() const; + bool isLower() const; + bool isNull() const; + bool isRightToLeft() const; + bool isSharedWith(const QString &other) const; + bool isSimpleText() const; + bool isUpper() const; + bool isValidUtf16() const; + QString last(qsizetype n) const; + qsizetype lastIndexOf(const QString &s) const; + qsizetype lastIndexOf(const QString &s, qsizetype from) const; + QString left(qsizetype n) const; + QString leftJustified(qsizetype width) const; + qsizetype length() const; + int localeAwareCompare(const QString &s) const; + static int localeAwareCompare(const QString &s1, const QString &s2); + QString mid(qsizetype position, qsizetype n = -1) const; + static QString number(int arg__1, int base = 10); + static QString number(long arg__1, int base = 10); + static QString number(qint64 arg__1, int base = 10); + QString &prepend(const QByteArray &s); + QString &prepend(const QString &s); + QString &prepend(const char *s); + void push_back(const QString &s); + void push_front(const QString &s); + QString &remove(const QString &s); + QString &remove(qsizetype i, qsizetype len); + QString repeated(qsizetype times) const; + QString &replace(const QString &before, const QString &after); + QString &replace(qsizetype i, qsizetype len, const QString &after); + void reserve(qsizetype size); + void resize(qsizetype size); + QString right(qsizetype n) const; + QString rightJustified(qsizetype width) const; + QString section(const QString &in_sep, qsizetype start, qsizetype end = -1) const; + QString &setNum(int arg__1, int base = 10); + QString &setNum(long arg__1, int base = 10); + QString &setNum(qint64 arg__1, int base = 10); + QString &setNum(short arg__1, int base = 10); + void shrink_to_fit(); + QString simplified(); + qsizetype size() const; + QString sliced(qsizetype pos) const; + QString sliced(qsizetype pos, qsizetype n) const; + QList split(const QString &sep) const; + void squeeze(); + bool startsWith(const QString &s) const; + QString toCaseFolded(); + QString toHtmlEscaped() const; + QByteArray toLatin1(); + QByteArray toLocal8Bit(); + QString toLower(); + QList toUcs4() const; + QString toUpper(); + QByteArray toUtf8(); + QString trimmed(); + void truncate(qsizetype pos); +}; +} +extern "C" { +// QString::QString() +TestBindings_EXPORT void *c_QString__constructor(); +// QString::QString(const QByteArray & a) +TestBindings_EXPORT void *c_QString__constructor_QByteArray(void *a_); +// QString::QString(const char * ch) +TestBindings_EXPORT void *c_QString__constructor_char(const char *ch); +// QString::append(const QByteArray & s) +TestBindings_EXPORT void *c_QString__append_QByteArray(void *thisObj, void *s_); +// QString::append(const QString & s) +TestBindings_EXPORT void *c_QString__append_QString(void *thisObj, const char *s_); +// QString::append(const char * s) +TestBindings_EXPORT void *c_QString__append_char(void *thisObj, const char *s); +// QString::arg(const QString & a, int fieldWidth) const +TestBindings_EXPORT void *c_QString__arg_QString_int(void *thisObj, const char *a_, int fieldWidth); +// QString::arg(int a, int fieldWidth, int base) const +TestBindings_EXPORT void *c_QString__arg_int_int_int(void *thisObj, int a, int fieldWidth, + int base); +// QString::arg(long a, int fieldwidth, int base) const +TestBindings_EXPORT void *c_QString__arg_long_int_int(void *thisObj, long a, int fieldwidth, + int base); +// QString::arg(qint64 a, int fieldwidth, int base) const +TestBindings_EXPORT void *c_QString__arg_qint64_int_int(void *thisObj, qint64 a, int fieldwidth, + int base); +// QString::arg(short a, int fieldWidth, int base) const +TestBindings_EXPORT void *c_QString__arg_short_int_int(void *thisObj, short a, int fieldWidth, + int base); +// QString::asprintf(const char * format) +TestBindings_EXPORT void *c_static_QString__asprintf_char(const char *format); +// QString::capacity() const +TestBindings_EXPORT qsizetype c_QString__capacity(void *thisObj); +// QString::chop(qsizetype n) +TestBindings_EXPORT void c_QString__chop_qsizetype(void *thisObj, qsizetype n); +// QString::chopped(qsizetype n) const +TestBindings_EXPORT void *c_QString__chopped_qsizetype(void *thisObj, qsizetype n); +// QString::clear() +TestBindings_EXPORT void c_QString__clear(void *thisObj); +// QString::compare(const QString & s) const +TestBindings_EXPORT int c_QString__compare_QString(void *thisObj, const char *s_); +// QString::compare(const QString & s1, const QString & s2) +TestBindings_EXPORT int c_static_QString__compare_QString_QString(const char *s1_, const char *s2_); +// QString::contains(const QString & s) const +TestBindings_EXPORT bool c_QString__contains_QString(void *thisObj, const char *s_); +// QString::count() const +TestBindings_EXPORT qsizetype c_QString__count(void *thisObj); +// QString::count(const QString & s) const +TestBindings_EXPORT qsizetype c_QString__count_QString(void *thisObj, const char *s_); +// QString::detach() +TestBindings_EXPORT void c_QString__detach(void *thisObj); +// QString::endsWith(const QString & s) const +TestBindings_EXPORT bool c_QString__endsWith_QString(void *thisObj, const char *s_); +// QString::first(qsizetype n) const +TestBindings_EXPORT void *c_QString__first_qsizetype(void *thisObj, qsizetype n); +// QString::fromLatin1(const char * str, qsizetype size) +TestBindings_EXPORT void *c_static_QString__fromLatin1_char_qsizetype(const char *str, + qsizetype size); +// QString::fromLocal8Bit(const char * str, qsizetype size) +TestBindings_EXPORT void *c_static_QString__fromLocal8Bit_char_qsizetype(const char *str, + qsizetype size); +// QString::fromUtf8(const char * utf8, qsizetype size) +TestBindings_EXPORT void *c_static_QString__fromUtf8_char_qsizetype(const char *utf8, + qsizetype size); +// QString::indexOf(const QString & s, qsizetype from) const +TestBindings_EXPORT qsizetype c_QString__indexOf_QString_qsizetype(void *thisObj, const char *s_, + qsizetype from); +// QString::insert(qsizetype i, const QByteArray & s) +TestBindings_EXPORT void *c_QString__insert_qsizetype_QByteArray(void *thisObj, qsizetype i, + void *s_); +// QString::insert(qsizetype i, const QString & s) +TestBindings_EXPORT void *c_QString__insert_qsizetype_QString(void *thisObj, qsizetype i, + const char *s_); +// QString::insert(qsizetype i, const char * s) +TestBindings_EXPORT void *c_QString__insert_qsizetype_char(void *thisObj, qsizetype i, + const char *s); +// QString::isDetached() const +TestBindings_EXPORT bool c_QString__isDetached(void *thisObj); +// QString::isEmpty() const +TestBindings_EXPORT bool c_QString__isEmpty(void *thisObj); +// QString::isLower() const +TestBindings_EXPORT bool c_QString__isLower(void *thisObj); +// QString::isNull() const +TestBindings_EXPORT bool c_QString__isNull(void *thisObj); +// QString::isRightToLeft() const +TestBindings_EXPORT bool c_QString__isRightToLeft(void *thisObj); +// QString::isSharedWith(const QString & other) const +TestBindings_EXPORT bool c_QString__isSharedWith_QString(void *thisObj, const char *other_); +// QString::isSimpleText() const +TestBindings_EXPORT bool c_QString__isSimpleText(void *thisObj); +// QString::isUpper() const +TestBindings_EXPORT bool c_QString__isUpper(void *thisObj); +// QString::isValidUtf16() const +TestBindings_EXPORT bool c_QString__isValidUtf16(void *thisObj); +// QString::last(qsizetype n) const +TestBindings_EXPORT void *c_QString__last_qsizetype(void *thisObj, qsizetype n); +// QString::lastIndexOf(const QString & s) const +TestBindings_EXPORT qsizetype c_QString__lastIndexOf_QString(void *thisObj, const char *s_); +// QString::lastIndexOf(const QString & s, qsizetype from) const +TestBindings_EXPORT qsizetype c_QString__lastIndexOf_QString_qsizetype(void *thisObj, + const char *s_, + qsizetype from); +// QString::left(qsizetype n) const +TestBindings_EXPORT void *c_QString__left_qsizetype(void *thisObj, qsizetype n); +// QString::leftJustified(qsizetype width) const +TestBindings_EXPORT void *c_QString__leftJustified_qsizetype(void *thisObj, qsizetype width); +// QString::length() const +TestBindings_EXPORT qsizetype c_QString__length(void *thisObj); +// QString::localeAwareCompare(const QString & s) const +TestBindings_EXPORT int c_QString__localeAwareCompare_QString(void *thisObj, const char *s_); +// QString::localeAwareCompare(const QString & s1, const QString & s2) +TestBindings_EXPORT int c_static_QString__localeAwareCompare_QString_QString(const char *s1_, + const char *s2_); +// QString::mid(qsizetype position, qsizetype n) const +TestBindings_EXPORT void *c_QString__mid_qsizetype_qsizetype(void *thisObj, qsizetype position, + qsizetype n); +// QString::number(int arg__1, int base) +TestBindings_EXPORT void *c_static_QString__number_int_int(int arg__1, int base); +// QString::number(long arg__1, int base) +TestBindings_EXPORT void *c_static_QString__number_long_int(long arg__1, int base); +// QString::number(qint64 arg__1, int base) +TestBindings_EXPORT void *c_static_QString__number_qint64_int(qint64 arg__1, int base); +// QString::prepend(const QByteArray & s) +TestBindings_EXPORT void *c_QString__prepend_QByteArray(void *thisObj, void *s_); +// QString::prepend(const QString & s) +TestBindings_EXPORT void *c_QString__prepend_QString(void *thisObj, const char *s_); +// QString::prepend(const char * s) +TestBindings_EXPORT void *c_QString__prepend_char(void *thisObj, const char *s); +// QString::push_back(const QString & s) +TestBindings_EXPORT void c_QString__push_back_QString(void *thisObj, const char *s_); +// QString::push_front(const QString & s) +TestBindings_EXPORT void c_QString__push_front_QString(void *thisObj, const char *s_); +// QString::remove(const QString & s) +TestBindings_EXPORT void *c_QString__remove_QString(void *thisObj, const char *s_); +// QString::remove(qsizetype i, qsizetype len) +TestBindings_EXPORT void *c_QString__remove_qsizetype_qsizetype(void *thisObj, qsizetype i, + qsizetype len); +// QString::repeated(qsizetype times) const +TestBindings_EXPORT void *c_QString__repeated_qsizetype(void *thisObj, qsizetype times); +// QString::replace(const QString & before, const QString & after) +TestBindings_EXPORT void *c_QString__replace_QString_QString(void *thisObj, const char *before_, + const char *after_); +// QString::replace(qsizetype i, qsizetype len, const QString & after) +TestBindings_EXPORT void *c_QString__replace_qsizetype_qsizetype_QString(void *thisObj, qsizetype i, + qsizetype len, + const char *after_); +// QString::reserve(qsizetype size) +TestBindings_EXPORT void c_QString__reserve_qsizetype(void *thisObj, qsizetype size); +// QString::resize(qsizetype size) +TestBindings_EXPORT void c_QString__resize_qsizetype(void *thisObj, qsizetype size); +// QString::right(qsizetype n) const +TestBindings_EXPORT void *c_QString__right_qsizetype(void *thisObj, qsizetype n); +// QString::rightJustified(qsizetype width) const +TestBindings_EXPORT void *c_QString__rightJustified_qsizetype(void *thisObj, qsizetype width); +// QString::section(const QString & in_sep, qsizetype start, qsizetype end) const +TestBindings_EXPORT void *c_QString__section_QString_qsizetype_qsizetype(void *thisObj, + const char *in_sep_, + qsizetype start, + qsizetype end); +// QString::setNum(int arg__1, int base) +TestBindings_EXPORT void *c_QString__setNum_int_int(void *thisObj, int arg__1, int base); +// QString::setNum(long arg__1, int base) +TestBindings_EXPORT void *c_QString__setNum_long_int(void *thisObj, long arg__1, int base); +// QString::setNum(qint64 arg__1, int base) +TestBindings_EXPORT void *c_QString__setNum_qint64_int(void *thisObj, qint64 arg__1, int base); +// QString::setNum(short arg__1, int base) +TestBindings_EXPORT void *c_QString__setNum_short_int(void *thisObj, short arg__1, int base); +// QString::shrink_to_fit() +TestBindings_EXPORT void c_QString__shrink_to_fit(void *thisObj); +// QString::simplified() +TestBindings_EXPORT void *c_QString__simplified(void *thisObj); +// QString::size() const +TestBindings_EXPORT qsizetype c_QString__size(void *thisObj); +// QString::sliced(qsizetype pos) const +TestBindings_EXPORT void *c_QString__sliced_qsizetype(void *thisObj, qsizetype pos); +// QString::sliced(qsizetype pos, qsizetype n) const +TestBindings_EXPORT void *c_QString__sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, + qsizetype n); +// QString::split(const QString & sep) const +TestBindings_EXPORT void *c_QString__split_QString(void *thisObj, const char *sep_); +// QString::squeeze() +TestBindings_EXPORT void c_QString__squeeze(void *thisObj); +// QString::startsWith(const QString & s) const +TestBindings_EXPORT bool c_QString__startsWith_QString(void *thisObj, const char *s_); +// QString::toCaseFolded() +TestBindings_EXPORT void *c_QString__toCaseFolded(void *thisObj); +// QString::toHtmlEscaped() const +TestBindings_EXPORT void *c_QString__toHtmlEscaped(void *thisObj); +// QString::toLatin1() +TestBindings_EXPORT void *c_QString__toLatin1(void *thisObj); +// QString::toLocal8Bit() +TestBindings_EXPORT void *c_QString__toLocal8Bit(void *thisObj); +// QString::toLower() +TestBindings_EXPORT void *c_QString__toLower(void *thisObj); +// QString::toUcs4() const +TestBindings_EXPORT void *c_QString__toUcs4(void *thisObj); +// QString::toUpper() +TestBindings_EXPORT void *c_QString__toUpper(void *thisObj); +// QString::toUtf8() +TestBindings_EXPORT void *c_QString__toUtf8(void *thisObj); +// QString::trimmed() +TestBindings_EXPORT void *c_QString__trimmed(void *thisObj); +// QString::truncate(qsizetype pos) +TestBindings_EXPORT void c_QString__truncate_qsizetype(void *thisObj, qsizetype pos); +TestBindings_EXPORT void c_QString__destructor(void *thisObj); +TestBindings_EXPORT void c_QString_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/QVariant_c.cpp b/tests/generated/TestBindings/dart/ffi/QVariant_c.cpp new file mode 100644 index 0000000..2a190e6 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/QVariant_c.cpp @@ -0,0 +1,359 @@ +#include "QVariant_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +QVariant_wrapper::QVariant_wrapper() + : ::QVariant() +{ +} +QVariant_wrapper::QVariant_wrapper(bool b) + : ::QVariant(b) +{ +} +QVariant_wrapper::QVariant_wrapper(const QByteArray &bytearray) + : ::QVariant(bytearray) +{ +} +QVariant_wrapper::QVariant_wrapper(const QHash &hash) + : ::QVariant(hash) +{ +} +QVariant_wrapper::QVariant_wrapper(const QList &stringlist) + : ::QVariant(stringlist) +{ +} +QVariant_wrapper::QVariant_wrapper(const QList &list) + : ::QVariant(list) +{ +} +QVariant_wrapper::QVariant_wrapper(const QMap &map) + : ::QVariant(map) +{ +} +QVariant_wrapper::QVariant_wrapper(const QString &string) + : ::QVariant(string) +{ +} +QVariant_wrapper::QVariant_wrapper(const char *str) + : ::QVariant(str) +{ +} +QVariant_wrapper::QVariant_wrapper(double d) + : ::QVariant(d) +{ +} +QVariant_wrapper::QVariant_wrapper(float f) + : ::QVariant(f) +{ +} +QVariant_wrapper::QVariant_wrapper(int i) + : ::QVariant(i) +{ +} +QVariant_wrapper::QVariant_wrapper(qint64 ll) + : ::QVariant(ll) +{ +} +void QVariant_wrapper::clear() +{ + ::QVariant::clear(); +} +void QVariant_wrapper::detach() +{ + ::QVariant::detach(); +} +bool QVariant_wrapper::equals(const QVariant &other) const +{ + return ::QVariant::equals(other); +} + +// ======================================================================== +// START of custom code block [file: glue/qvariant.cpp (qvariant-fromObject)] + +/** static*/ +QVariant QVariant_wrapper::fromObject(QObject *obj) +{ + return QVariant::fromValue(obj); +} +// END of custom code block [file: glue/qvariant.cpp (qvariant-fromObject)] +// ======================================================================== + +bool QVariant_wrapper::isDetached() const +{ + return ::QVariant::isDetached(); +} +bool QVariant_wrapper::isNull() const +{ + return ::QVariant::isNull(); +} +bool QVariant_wrapper::isValid() const +{ + return ::QVariant::isValid(); +} +void QVariant_wrapper::setValue(const QVariant &avalue) +{ + ::QVariant::setValue(avalue); +} +bool QVariant_wrapper::toBool() const +{ + return ::QVariant::toBool(); +} +QByteArray QVariant_wrapper::toByteArray() const +{ + return ::QVariant::toByteArray(); +} +QHash QVariant_wrapper::toHash() const +{ + return ::QVariant::toHash(); +} +QList QVariant_wrapper::toList() const +{ + return ::QVariant::toList(); +} +QMap QVariant_wrapper::toMap() const +{ + return ::QVariant::toMap(); +} +QList QVariant_wrapper::toStringList() const +{ + return ::QVariant::toStringList(); +} +int QVariant_wrapper::typeId() const +{ + return ::QVariant::typeId(); +} +const char *QVariant_wrapper::typeName() const +{ + return ::QVariant::typeName(); +} +int QVariant_wrapper::userType() const +{ + return ::QVariant::userType(); +} +QVariant_wrapper::~QVariant_wrapper() +{ +} + +} +static QVariant *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::QVariant_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_QVariant_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} +void *c_QVariant__constructor() +{ + auto ptr = new TestBindings_wrappersNS::QVariant_wrapper(); + return reinterpret_cast(ptr); +} +void *c_QVariant__constructor_bool(bool b) +{ + auto ptr = new TestBindings_wrappersNS::QVariant_wrapper(b); + return reinterpret_cast(ptr); +} +void *c_QVariant__constructor_QByteArray(void *bytearray_) +{ + assert(bytearray_); + auto &bytearray = *reinterpret_cast(bytearray_); + auto ptr = new TestBindings_wrappersNS::QVariant_wrapper(bytearray); + return reinterpret_cast(ptr); +} +void *c_QVariant__constructor_QHash_QString_QVariant(void *hash_) +{ + assert(hash_); + auto &hash = *reinterpret_cast *>(hash_); + auto ptr = new TestBindings_wrappersNS::QVariant_wrapper(hash); + return reinterpret_cast(ptr); +} +void *c_QVariant__constructor_QList_QString(void *stringlist_) +{ + assert(stringlist_); + auto &stringlist = *reinterpret_cast *>(stringlist_); + auto ptr = new TestBindings_wrappersNS::QVariant_wrapper(stringlist); + return reinterpret_cast(ptr); +} +void *c_QVariant__constructor_QList_QVariant(void *list_) +{ + assert(list_); + auto &list = *reinterpret_cast *>(list_); + auto ptr = new TestBindings_wrappersNS::QVariant_wrapper(list); + return reinterpret_cast(ptr); +} +void *c_QVariant__constructor_QMap_QString_QVariant(void *map_) +{ + assert(map_); + auto &map = *reinterpret_cast *>(map_); + auto ptr = new TestBindings_wrappersNS::QVariant_wrapper(map); + return reinterpret_cast(ptr); +} +void *c_QVariant__constructor_QString(const char *string_) +{ + const auto string = QString::fromUtf8(string_); + auto ptr = new TestBindings_wrappersNS::QVariant_wrapper(string); + return reinterpret_cast(ptr); +} +void *c_QVariant__constructor_char(const char *str) +{ + auto ptr = new TestBindings_wrappersNS::QVariant_wrapper(str); + return reinterpret_cast(ptr); +} +void *c_QVariant__constructor_double(double d) +{ + auto ptr = new TestBindings_wrappersNS::QVariant_wrapper(d); + return reinterpret_cast(ptr); +} +void *c_QVariant__constructor_float(float f) +{ + auto ptr = new TestBindings_wrappersNS::QVariant_wrapper(f); + return reinterpret_cast(ptr); +} +void *c_QVariant__constructor_int(int i) +{ + auto ptr = new TestBindings_wrappersNS::QVariant_wrapper(i); + return reinterpret_cast(ptr); +} +void *c_QVariant__constructor_qint64(qint64 ll) +{ + auto ptr = new TestBindings_wrappersNS::QVariant_wrapper(ll); + return reinterpret_cast(ptr); +} +// clear() +void c_QVariant__clear(void *thisObj) +{ + fromPtr(thisObj)->clear(); +} +// detach() +void c_QVariant__detach(void *thisObj) +{ + fromPtr(thisObj)->detach(); +} +// equals(const QVariant & other) const +bool c_QVariant__equals_QVariant(void *thisObj, void *other_) +{ + assert(other_); + auto &other = *reinterpret_cast(other_); + const auto &result = fromWrapperPtr(thisObj)->equals(other); + return result; +} +// fromObject(QObject * arg__1) +void *c_static_QVariant__fromObject_QObject(void *arg__1_) +{ + auto arg__1 = reinterpret_cast(arg__1_); + const auto &result = new Dartagnan::ValueWrapper { + TestBindings_wrappersNS::QVariant_wrapper::fromObject(arg__1) + }; + return result; +} +// isDetached() const +bool c_QVariant__isDetached(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isDetached(); + return result; +} +// isNull() const +bool c_QVariant__isNull(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isNull(); + return result; +} +// isValid() const +bool c_QVariant__isValid(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->isValid(); + return result; +} +// setValue(const QVariant & avalue) +void c_QVariant__setValue_QVariant(void *thisObj, void *avalue_) +{ + assert(avalue_); + auto &avalue = *reinterpret_cast(avalue_); + fromPtr(thisObj)->setValue(avalue); +} +// toBool() const +bool c_QVariant__toBool(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->toBool(); + return result; +} +// toByteArray() const +void *c_QVariant__toByteArray(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper { fromPtr(thisObj)->toByteArray() }; + return result; +} +// toHash() const +void *c_QVariant__toHash(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->toHash() }; + return result; +} +// toList() const +void *c_QVariant__toList(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->toList() }; + return result; +} +// toMap() const +void *c_QVariant__toMap(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->toMap() }; + return result; +} +// toStringList() const +void *c_QVariant__toStringList(void *thisObj) +{ + const auto &result = + new Dartagnan::ValueWrapper> { fromPtr(thisObj)->toStringList() }; + return result; +} +// typeId() const +int c_QVariant__typeId(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->typeId(); + return result; +} +// typeName() const +const char *c_QVariant__typeName(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->typeName(); + return result; +} +// userType() const +int c_QVariant__userType(void *thisObj) +{ + const auto &result = fromPtr(thisObj)->userType(); + return result; +} +void c_QVariant__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} diff --git a/tests/generated/TestBindings/dart/ffi/QVariant_c.h b/tests/generated/TestBindings/dart/ffi/QVariant_c.h new file mode 100644 index 0000000..0e22540 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/QVariant_c.h @@ -0,0 +1,110 @@ +#include "TestBindings_exports.h" +#include +#include +#include +#include +#include +#include +#include + +namespace TestBindings_wrappersNS { +class QVariant_wrapper : public ::QVariant +{ +public: + ~QVariant_wrapper(); + QVariant_wrapper(); + QVariant_wrapper(bool b); + QVariant_wrapper(const QByteArray &bytearray); + QVariant_wrapper(const QHash &hash); + QVariant_wrapper(const QList &stringlist); + QVariant_wrapper(const QList &list); + QVariant_wrapper(const QMap &map); + QVariant_wrapper(const QString &string); + QVariant_wrapper(const char *str); + QVariant_wrapper(double d); + QVariant_wrapper(float f); + QVariant_wrapper(int i); + QVariant_wrapper(qint64 ll); + void clear(); + void detach(); + bool equals(const QVariant &other) const; + static QVariant fromObject(QObject *arg__1); + bool isDetached() const; + bool isNull() const; + bool isValid() const; + void setValue(const QVariant &avalue); + bool toBool() const; + QByteArray toByteArray() const; + QHash toHash() const; + QList toList() const; + QMap toMap() const; + QList toStringList() const; + int typeId() const; + const char *typeName() const; + int userType() const; +}; +} +extern "C" { +// QVariant::QVariant() +TestBindings_EXPORT void *c_QVariant__constructor(); +// QVariant::QVariant(bool b) +TestBindings_EXPORT void *c_QVariant__constructor_bool(bool b); +// QVariant::QVariant(const QByteArray & bytearray) +TestBindings_EXPORT void *c_QVariant__constructor_QByteArray(void *bytearray_); +// QVariant::QVariant(const QHash & hash) +TestBindings_EXPORT void *c_QVariant__constructor_QHash_QString_QVariant(void *hash_); +// QVariant::QVariant(const QList & stringlist) +TestBindings_EXPORT void *c_QVariant__constructor_QList_QString(void *stringlist_); +// QVariant::QVariant(const QList & list) +TestBindings_EXPORT void *c_QVariant__constructor_QList_QVariant(void *list_); +// QVariant::QVariant(const QMap & map) +TestBindings_EXPORT void *c_QVariant__constructor_QMap_QString_QVariant(void *map_); +// QVariant::QVariant(const QString & string) +TestBindings_EXPORT void *c_QVariant__constructor_QString(const char *string_); +// QVariant::QVariant(const char * str) +TestBindings_EXPORT void *c_QVariant__constructor_char(const char *str); +// QVariant::QVariant(double d) +TestBindings_EXPORT void *c_QVariant__constructor_double(double d); +// QVariant::QVariant(float f) +TestBindings_EXPORT void *c_QVariant__constructor_float(float f); +// QVariant::QVariant(int i) +TestBindings_EXPORT void *c_QVariant__constructor_int(int i); +// QVariant::QVariant(qint64 ll) +TestBindings_EXPORT void *c_QVariant__constructor_qint64(qint64 ll); +// QVariant::clear() +TestBindings_EXPORT void c_QVariant__clear(void *thisObj); +// QVariant::detach() +TestBindings_EXPORT void c_QVariant__detach(void *thisObj); +// QVariant::equals(const QVariant & other) const +TestBindings_EXPORT bool c_QVariant__equals_QVariant(void *thisObj, void *other_); +// QVariant::fromObject(QObject * arg__1) +TestBindings_EXPORT void *c_static_QVariant__fromObject_QObject(void *arg__1_); +// QVariant::isDetached() const +TestBindings_EXPORT bool c_QVariant__isDetached(void *thisObj); +// QVariant::isNull() const +TestBindings_EXPORT bool c_QVariant__isNull(void *thisObj); +// QVariant::isValid() const +TestBindings_EXPORT bool c_QVariant__isValid(void *thisObj); +// QVariant::setValue(const QVariant & avalue) +TestBindings_EXPORT void c_QVariant__setValue_QVariant(void *thisObj, void *avalue_); +// QVariant::toBool() const +TestBindings_EXPORT bool c_QVariant__toBool(void *thisObj); +// QVariant::toByteArray() const +TestBindings_EXPORT void *c_QVariant__toByteArray(void *thisObj); +// QVariant::toHash() const +TestBindings_EXPORT void *c_QVariant__toHash(void *thisObj); +// QVariant::toList() const +TestBindings_EXPORT void *c_QVariant__toList(void *thisObj); +// QVariant::toMap() const +TestBindings_EXPORT void *c_QVariant__toMap(void *thisObj); +// QVariant::toStringList() const +TestBindings_EXPORT void *c_QVariant__toStringList(void *thisObj); +// QVariant::typeId() const +TestBindings_EXPORT int c_QVariant__typeId(void *thisObj); +// QVariant::typeName() const +TestBindings_EXPORT const char *c_QVariant__typeName(void *thisObj); +// QVariant::userType() const +TestBindings_EXPORT int c_QVariant__userType(void *thisObj); +TestBindings_EXPORT void c_QVariant__destructor(void *thisObj); +TestBindings_EXPORT void c_QVariant_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/Qt_c.cpp b/tests/generated/TestBindings/dart/ffi/Qt_c.cpp new file mode 100644 index 0000000..9140bb9 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/Qt_c.cpp @@ -0,0 +1,22 @@ +#include "Qt_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +extern "C" { +} diff --git a/tests/generated/TestBindings/dart/ffi/Qt_c.h b/tests/generated/TestBindings/dart/ffi/Qt_c.h new file mode 100644 index 0000000..83cb6e7 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/Qt_c.h @@ -0,0 +1,6 @@ +#include "TestBindings_exports.h" +#include + +extern "C" { +TestBindings_EXPORT void c_Qt_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/SimpleObjectStruct_c.cpp b/tests/generated/TestBindings/dart/ffi/SimpleObjectStruct_c.cpp new file mode 100644 index 0000000..c00e944 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/SimpleObjectStruct_c.cpp @@ -0,0 +1,65 @@ +#include "SimpleObjectStruct_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +SimpleObjectStruct_wrapper::SimpleObjectStruct_wrapper() + : ::SimpleObjectStruct() +{ +} +void SimpleObjectStruct_wrapper::receivesStructWithDefaultArg(SimpleObjectStruct arg__1) +{ + ::SimpleObjectStruct::receivesStructWithDefaultArg(arg__1); +} +SimpleObjectStruct_wrapper::~SimpleObjectStruct_wrapper() +{ +} + +} +static SimpleObjectStruct *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::SimpleObjectStruct_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_SimpleObjectStruct_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} +void *c_SimpleObjectStruct__constructor() +{ + auto ptr = new TestBindings_wrappersNS::SimpleObjectStruct_wrapper(); + return reinterpret_cast(ptr); +} +// receivesStructWithDefaultArg(SimpleObjectStruct arg__1) +void c_SimpleObjectStruct__receivesStructWithDefaultArg_SimpleObjectStruct(void *thisObj, + void *arg__1_) +{ + assert(arg__1_); + auto &arg__1 = *reinterpret_cast(arg__1_); + fromPtr(thisObj)->receivesStructWithDefaultArg(arg__1); +} +void c_SimpleObjectStruct__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} diff --git a/tests/generated/TestBindings/dart/ffi/SimpleObjectStruct_c.h b/tests/generated/TestBindings/dart/ffi/SimpleObjectStruct_c.h new file mode 100644 index 0000000..d8817f2 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/SimpleObjectStruct_c.h @@ -0,0 +1,21 @@ +#include "TestBindings_exports.h" +#include + +namespace TestBindings_wrappersNS { +class SimpleObjectStruct_wrapper : public ::SimpleObjectStruct +{ +public: + ~SimpleObjectStruct_wrapper(); + SimpleObjectStruct_wrapper(); + void receivesStructWithDefaultArg(SimpleObjectStruct arg__1 = {}); +}; +} +extern "C" { +// SimpleObjectStruct::SimpleObjectStruct() +TestBindings_EXPORT void *c_SimpleObjectStruct__constructor(); +// SimpleObjectStruct::receivesStructWithDefaultArg(SimpleObjectStruct arg__1) +TestBindings_EXPORT void +c_SimpleObjectStruct__receivesStructWithDefaultArg_SimpleObjectStruct(void *thisObj, void *arg__1_); +TestBindings_EXPORT void c_SimpleObjectStruct__destructor(void *thisObj); +TestBindings_EXPORT void c_SimpleObjectStruct_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/SimpleStruct_c.cpp b/tests/generated/TestBindings/dart/ffi/SimpleStruct_c.cpp new file mode 100644 index 0000000..352e29c --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/SimpleStruct_c.cpp @@ -0,0 +1,61 @@ +#include "SimpleStruct_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +SimpleStruct_wrapper::SimpleStruct_wrapper() + : ::SimpleStruct() +{ +} +SimpleStruct_wrapper::~SimpleStruct_wrapper() +{ +} + +} +static SimpleStruct *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::SimpleStruct_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_SimpleStruct_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} +void *c_SimpleStruct__constructor() +{ + auto ptr = new TestBindings_wrappersNS::SimpleStruct_wrapper(); + return reinterpret_cast(ptr); +} +void c_SimpleStruct__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +int c_SimpleStruct___get_value(void *thisObj) +{ + return fromPtr(thisObj)->value; +} +void c_SimpleStruct___set_value_int(void *thisObj, int value_) +{ + fromPtr(thisObj)->value = value_; +} +} diff --git a/tests/generated/TestBindings/dart/ffi/SimpleStruct_c.h b/tests/generated/TestBindings/dart/ffi/SimpleStruct_c.h new file mode 100644 index 0000000..ee8bbc2 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/SimpleStruct_c.h @@ -0,0 +1,19 @@ +#include "TestBindings_exports.h" +#include + +namespace TestBindings_wrappersNS { +class SimpleStruct_wrapper : public ::SimpleStruct +{ +public: + ~SimpleStruct_wrapper(); + SimpleStruct_wrapper(); +}; +} +extern "C" { +// SimpleStruct::SimpleStruct() +TestBindings_EXPORT void *c_SimpleStruct__constructor(); +TestBindings_EXPORT void c_SimpleStruct__destructor(void *thisObj); +TestBindings_EXPORT int c_SimpleStruct___get_value(void *thisObj); +TestBindings_EXPORT void c_SimpleStruct___set_value_int(void *thisObj, int value_); +TestBindings_EXPORT void c_SimpleStruct_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/StructWithStructAsMember_c.cpp b/tests/generated/TestBindings/dart/ffi/StructWithStructAsMember_c.cpp new file mode 100644 index 0000000..69e3146 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/StructWithStructAsMember_c.cpp @@ -0,0 +1,53 @@ +#include "StructWithStructAsMember_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +StructWithStructAsMember_wrapper::StructWithStructAsMember_wrapper() + : ::TestTargetNS::StructWithStructAsMember() +{ +} +StructWithStructAsMember_wrapper::~StructWithStructAsMember_wrapper() +{ +} + +} +static TestTargetNS::StructWithStructAsMember *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::StructWithStructAsMember_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_TestTargetNS__StructWithStructAsMember_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} +void *c_TestTargetNS__StructWithStructAsMember__constructor() +{ + auto ptr = new TestBindings_wrappersNS::StructWithStructAsMember_wrapper(); + return reinterpret_cast(ptr); +} +void c_TestTargetNS__StructWithStructAsMember__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +} diff --git a/tests/generated/TestBindings/dart/ffi/StructWithStructAsMember_c.h b/tests/generated/TestBindings/dart/ffi/StructWithStructAsMember_c.h new file mode 100644 index 0000000..4ef5ecc --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/StructWithStructAsMember_c.h @@ -0,0 +1,17 @@ +#include "TestBindings_exports.h" +#include + +namespace TestBindings_wrappersNS { +class StructWithStructAsMember_wrapper : public ::TestTargetNS::StructWithStructAsMember +{ +public: + ~StructWithStructAsMember_wrapper(); + StructWithStructAsMember_wrapper(); +}; +} +extern "C" { +// TestTargetNS::StructWithStructAsMember::StructWithStructAsMember() +TestBindings_EXPORT void *c_TestTargetNS__StructWithStructAsMember__constructor(); +TestBindings_EXPORT void c_TestTargetNS__StructWithStructAsMember__destructor(void *thisObj); +TestBindings_EXPORT void c_TestTargetNS__StructWithStructAsMember_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/TestBindings.cpp b/tests/generated/TestBindings/dart/ffi/TestBindings.cpp new file mode 100644 index 0000000..b3a9b17 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/TestBindings.cpp @@ -0,0 +1,37 @@ +#include "TestBindings.h" + +// globalFunction() +int c___globalFunction() +{ + const auto &result = globalFunction(); + return result; +} +// receivesStructAsOptionalArgument(EmptyStruct arg1) +int c___receivesStructAsOptionalArgument_EmptyStruct(void *arg1_) +{ + assert(arg1_); + auto &arg1 = *reinterpret_cast(arg1_); + const auto &result = receivesStructAsOptionalArgument(arg1); + return result; +} +// receivesStructAsOptionalArgument2(EmptyStruct arg__1) +int c___receivesStructAsOptionalArgument2_EmptyStruct(void *arg__1_) +{ + assert(arg__1_); + auto &arg__1 = *reinterpret_cast(arg__1_); + const auto &result = receivesStructAsOptionalArgument2(arg__1); + return result; +} +// receivingPureAbstract(TestTargetNS::PureAbstract * a) +int c_static___receivingPureAbstract_PureAbstract(void *a_) +{ + auto a = reinterpret_cast(a_); + const auto &result = ::receivingPureAbstract(a); + return result; +} +// returnsPureAbstract() +void *c_static___returnsPureAbstract() +{ + const auto &result = ::returnsPureAbstract(); + return result; +} diff --git a/tests/generated/TestBindings/dart/ffi/TestBindings.h b/tests/generated/TestBindings/dart/ffi/TestBindings.h new file mode 100644 index 0000000..97c0eb7 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/TestBindings.h @@ -0,0 +1,10 @@ +#include "TestBindings_exports.h" +#include + +extern "C" { +TestBindings_EXPORT int c___globalFunction(); +TestBindings_EXPORT int c___receivesStructAsOptionalArgument_EmptyStruct(void *arg1_); +TestBindings_EXPORT int c___receivesStructAsOptionalArgument2_EmptyStruct(void *arg__1_); +TestBindings_EXPORT int c_static___receivingPureAbstract_PureAbstract(void *a_); +TestBindings_EXPORT void *c_static___returnsPureAbstract(); +} diff --git a/tests/generated/TestBindings/dart/ffi/TestTargetNS_c.cpp b/tests/generated/TestBindings/dart/ffi/TestTargetNS_c.cpp new file mode 100644 index 0000000..e1d9f8b --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/TestTargetNS_c.cpp @@ -0,0 +1,34 @@ +#include "TestTargetNS_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +extern "C" { +// namespaceFunctionReturningNamespaceEnum() +int c_static_TestTargetNS__namespaceFunctionReturningNamespaceEnum() +{ + const auto &result = TestTargetNS::namespaceFunctionReturningNamespaceEnum(); + return result; +} +// namespaceLevelGlobalFunction() +int c_static_TestTargetNS__namespaceLevelGlobalFunction() +{ + const auto &result = TestTargetNS::namespaceLevelGlobalFunction(); + return result; +} +} diff --git a/tests/generated/TestBindings/dart/ffi/TestTargetNS_c.h b/tests/generated/TestBindings/dart/ffi/TestTargetNS_c.h new file mode 100644 index 0000000..8e39a7c --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/TestTargetNS_c.h @@ -0,0 +1,10 @@ +#include "TestBindings_exports.h" +#include + +extern "C" { +// TestTargetNS::namespaceFunctionReturningNamespaceEnum() +TestBindings_EXPORT int c_static_TestTargetNS__namespaceFunctionReturningNamespaceEnum(); +// TestTargetNS::namespaceLevelGlobalFunction() +TestBindings_EXPORT int c_static_TestTargetNS__namespaceLevelGlobalFunction(); +TestBindings_EXPORT void c_TestTargetNS_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/UnusedTemplate_c.cpp b/tests/generated/TestBindings/dart/ffi/UnusedTemplate_c.cpp new file mode 100644 index 0000000..e2d6b4c --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/UnusedTemplate_c.cpp @@ -0,0 +1,42 @@ +#include "UnusedTemplate_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +template +UnusedTemplate_wrapper::UnusedTemplate_wrapper() + : ::UnusedTemplate() +{ +} +template +UnusedTemplate_wrapper::~UnusedTemplate_wrapper() +{ +} + +} +template +static UnusedTemplate *fromPtr(void *ptr) +{ + return reinterpret_cast *>(ptr); +} +template +static TestBindings_wrappersNS::UnusedTemplate_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast *>(ptr); +} \ No newline at end of file diff --git a/tests/generated/TestBindings/dart/ffi/UnusedTemplate_c.h b/tests/generated/TestBindings/dart/ffi/UnusedTemplate_c.h new file mode 100644 index 0000000..b8309e0 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/UnusedTemplate_c.h @@ -0,0 +1,12 @@ +#include "TestBindings_exports.h" +#include + +namespace TestBindings_wrappersNS { +template +class UnusedTemplate_wrapper : public ::UnusedTemplate +{ +public: + ~UnusedTemplate_wrapper(); + UnusedTemplate_wrapper(); +}; +} \ No newline at end of file diff --git a/tests/generated/TestBindings/dart/ffi/Virtual1_c.cpp b/tests/generated/TestBindings/dart/ffi/Virtual1_c.cpp new file mode 100644 index 0000000..012fd0d --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/Virtual1_c.cpp @@ -0,0 +1,90 @@ +#include "Virtual1_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +Virtual1_wrapper::Virtual1_wrapper() + : ::Virtual1() +{ +} +void Virtual1_wrapper::virtualMethod1() +{ + if (m_virtualMethod1Callback) { + const void *thisPtr = this; + m_virtualMethod1Callback(const_cast(thisPtr)); + } else { + ::Virtual1::virtualMethod1(); + } +} +void Virtual1_wrapper::virtualMethod1_nocallback() +{ + ::Virtual1::virtualMethod1(); +} +Virtual1_wrapper::~Virtual1_wrapper() +{ +} + +} +static Virtual1 *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::Virtual1_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_Virtual1_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} +void *c_Virtual1__constructor() +{ + auto ptr = new TestBindings_wrappersNS::Virtual1_wrapper(); + return reinterpret_cast(ptr); +} +// virtualMethod1() +void c_Virtual1__virtualMethod1(void *thisObj) +{ + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualMethod1_nocallback(); + } else { + return targetPtr->virtualMethod1(); + } + }(); +} +void c_Virtual1__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +void c_Virtual1__registerVirtualMethodCallback(void *ptr, void *callback, int methodId) +{ + auto wrapper = fromWrapperPtr(ptr); + switch (methodId) { + case 3: + wrapper->m_virtualMethod1Callback = + reinterpret_cast( + callback); + break; + } +} +} diff --git a/tests/generated/TestBindings/dart/ffi/Virtual1_c.h b/tests/generated/TestBindings/dart/ffi/Virtual1_c.h new file mode 100644 index 0000000..9df83f2 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/Virtual1_c.h @@ -0,0 +1,25 @@ +#include "TestBindings_exports.h" +#include + +namespace TestBindings_wrappersNS { +class Virtual1_wrapper : public ::Virtual1 +{ +public: + ~Virtual1_wrapper(); + Virtual1_wrapper(); + virtual void virtualMethod1(); + virtual void virtualMethod1_nocallback(); + typedef void (*Callback_virtualMethod1)(void *); + Callback_virtualMethod1 m_virtualMethod1Callback = nullptr; +}; +} +extern "C" { +// Virtual1::Virtual1() +TestBindings_EXPORT void *c_Virtual1__constructor(); +// Virtual1::virtualMethod1() +TestBindings_EXPORT void c_Virtual1__virtualMethod1(void *thisObj); +TestBindings_EXPORT void c_Virtual1__destructor(void *thisObj); +TestBindings_EXPORT void c_Virtual1__registerVirtualMethodCallback(void *ptr, void *callback, + int methodId); +TestBindings_EXPORT void c_Virtual1_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/Virtual2_c.cpp b/tests/generated/TestBindings/dart/ffi/Virtual2_c.cpp new file mode 100644 index 0000000..3f99e2c --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/Virtual2_c.cpp @@ -0,0 +1,90 @@ +#include "Virtual2_c.h" + + +#include + +#include + + +namespace Dartagnan { + +typedef int (*CleanupCallback)(void *thisPtr); +static CleanupCallback s_cleanupCallback = nullptr; + +template +struct ValueWrapper +{ + T value; +}; + +} +namespace TestBindings_wrappersNS { +Virtual2_wrapper::Virtual2_wrapper() + : ::Virtual2() +{ +} +void Virtual2_wrapper::virtualMethod2() +{ + if (m_virtualMethod2Callback) { + const void *thisPtr = this; + m_virtualMethod2Callback(const_cast(thisPtr)); + } else { + ::Virtual2::virtualMethod2(); + } +} +void Virtual2_wrapper::virtualMethod2_nocallback() +{ + ::Virtual2::virtualMethod2(); +} +Virtual2_wrapper::~Virtual2_wrapper() +{ +} + +} +static Virtual2 *fromPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +static TestBindings_wrappersNS::Virtual2_wrapper *fromWrapperPtr(void *ptr) +{ + return reinterpret_cast(ptr); +} +extern "C" { +void c_Virtual2_Finalizer(void *cppObj) +{ + delete reinterpret_cast(cppObj); +} +void *c_Virtual2__constructor() +{ + auto ptr = new TestBindings_wrappersNS::Virtual2_wrapper(); + return reinterpret_cast(ptr); +} +// virtualMethod2() +void c_Virtual2__virtualMethod2(void *thisObj) +{ + [&] { + auto targetPtr = fromPtr(thisObj); + auto wrapperPtr = dynamic_cast(targetPtr); + if (wrapperPtr) { + return wrapperPtr->virtualMethod2_nocallback(); + } else { + return targetPtr->virtualMethod2(); + } + }(); +} +void c_Virtual2__destructor(void *thisObj) +{ + delete fromPtr(thisObj); +} +void c_Virtual2__registerVirtualMethodCallback(void *ptr, void *callback, int methodId) +{ + auto wrapper = fromWrapperPtr(ptr); + switch (methodId) { + case 1: + wrapper->m_virtualMethod2Callback = + reinterpret_cast( + callback); + break; + } +} +} diff --git a/tests/generated/TestBindings/dart/ffi/Virtual2_c.h b/tests/generated/TestBindings/dart/ffi/Virtual2_c.h new file mode 100644 index 0000000..9271aa4 --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/Virtual2_c.h @@ -0,0 +1,25 @@ +#include "TestBindings_exports.h" +#include + +namespace TestBindings_wrappersNS { +class Virtual2_wrapper : public ::Virtual2 +{ +public: + ~Virtual2_wrapper(); + Virtual2_wrapper(); + virtual void virtualMethod2(); + virtual void virtualMethod2_nocallback(); + typedef void (*Callback_virtualMethod2)(void *); + Callback_virtualMethod2 m_virtualMethod2Callback = nullptr; +}; +} +extern "C" { +// Virtual2::Virtual2() +TestBindings_EXPORT void *c_Virtual2__constructor(); +// Virtual2::virtualMethod2() +TestBindings_EXPORT void c_Virtual2__virtualMethod2(void *thisObj); +TestBindings_EXPORT void c_Virtual2__destructor(void *thisObj); +TestBindings_EXPORT void c_Virtual2__registerVirtualMethodCallback(void *ptr, void *callback, + int methodId); +TestBindings_EXPORT void c_Virtual2_Finalizer(void *cppObj); +} diff --git a/tests/generated/TestBindings/dart/ffi/c_TestBindings.h b/tests/generated/TestBindings/dart/ffi/c_TestBindings.h new file mode 100644 index 0000000..5b6f10d --- /dev/null +++ b/tests/generated/TestBindings/dart/ffi/c_TestBindings.h @@ -0,0 +1,2192 @@ +#include + +// Virtual2::Virtual2() +void *c_Virtual2__constructor(); +// Virtual2::virtualMethod2() +void c_Virtual2__virtualMethod2(void *thisObj); +void c_Virtual2__destructor(void *thisObj); +void c_Virtual2__registerVirtualMethodCallback(void *ptr, void *callback, int methodId); +void c_Virtual2_Finalizer(void *cppObj); // Virtual1::Virtual1() +void *c_Virtual1__constructor(); +// Virtual1::virtualMethod1() +void c_Virtual1__virtualMethod1(void *thisObj); +void c_Virtual1__destructor(void *thisObj); +void c_Virtual1__registerVirtualMethodCallback(void *ptr, void *callback, int methodId); +void c_Virtual1_Finalizer(void *cppObj); // TestTargetNS::namespaceFunctionReturningNamespaceEnum() +int c_static_TestTargetNS__namespaceFunctionReturningNamespaceEnum(); +// TestTargetNS::namespaceLevelGlobalFunction() +int c_static_TestTargetNS__namespaceLevelGlobalFunction(); +void c_TestTargetNS_Finalizer(void *cppObj); // TestTargetNS::PureAbstract::PureAbstract() +void *c_TestTargetNS__PureAbstract__constructor(); +// TestTargetNS::PureAbstract::callVirtualReceivingPointer(SimpleStruct * s) +int c_TestTargetNS__PureAbstract__callVirtualReceivingPointer_SimpleStruct(void *thisObj, void *s_); +// TestTargetNS::PureAbstract::flagsWithDefaultArgs(QFlags +// options) +void c_TestTargetNS__PureAbstract__flagsWithDefaultArgs_NamespaceLevelEnums(void *thisObj, + int options_); +// TestTargetNS::PureAbstract::foo() +int c_TestTargetNS__PureAbstract__foo(void *thisObj); +// TestTargetNS::PureAbstract::renamedPureVirtual() +void c_TestTargetNS__PureAbstract__renamedPureVirtual1(void *thisObj); +// TestTargetNS::PureAbstract::renamedStatic() +void c_static_TestTargetNS__PureAbstract__renamedStatic1(); +// TestTargetNS::PureAbstract::returnsInt() const +int c_TestTargetNS__PureAbstract__returnsInt(void *thisObj); +// TestTargetNS::PureAbstract::unnamedOverriddenDefaultArgCase(int myarg) +void c_TestTargetNS__PureAbstract__unnamedOverriddenDefaultArgCase_int(void *thisObj, int myarg); +// TestTargetNS::PureAbstract::virtualReceivingPointer(SimpleStruct * s) +int c_TestTargetNS__PureAbstract__virtualReceivingPointer_SimpleStruct(void *thisObj, void *s_); +// TestTargetNS::PureAbstract::voidPureAbstract() +void c_TestTargetNS__PureAbstract__voidPureAbstract(void *thisObj); +void c_TestTargetNS__PureAbstract__destructor(void *thisObj); +int c_static_TestTargetNS__PureAbstract___get_s_instanceCount(); +void c_static_TestTargetNS__PureAbstract___set_s_instanceCount_int(int s_instanceCount_); +void c_TestTargetNS__PureAbstract__registerVirtualMethodCallback(void *ptr, void *callback, + int methodId); +void c_TestTargetNS__PureAbstract_Finalizer(void *cppObj); // TestTargetNS::POD::POD() +void *c_TestTargetNS__POD__constructor(); +// TestTargetNS::POD::POD(int a, int b, int c, int d) +void *c_TestTargetNS__POD__constructor_int_int_int_int(int a, int b, int c, int d); +// TestTargetNS::POD::calculate() const +int c_TestTargetNS__POD__calculate(void *thisObj); +// TestTargetNS::POD::calculateStatic() +int c_static_TestTargetNS__POD__calculateStatic(); +// TestTargetNS::POD::doStuffOnMyClass(TestTargetNS::MyBaseClass * myarg) +int c_static_TestTargetNS__POD__doStuffOnMyClass_MyBaseClass(void *myarg_); +// TestTargetNS::POD::intByConstRef() const +int c_TestTargetNS__POD__intByConstRef(void *thisObj); +// TestTargetNS::POD::receivesConstPointerToPODs(const TestTargetNS::POD * ptrPod1, const +// TestTargetNS::POD * ptrPod2) +int c_static_TestTargetNS__POD__receivesConstPointerToPODs_POD_POD(void *ptrPod1_, void *ptrPod2_); +// TestTargetNS::POD::receivesConstRefPODs(const TestTargetNS::POD & pod1, const TestTargetNS::POD & +// pod2) +int c_static_TestTargetNS__POD__receivesConstRefPODs_POD_POD(void *pod1_, void *pod2_); +// TestTargetNS::POD::receivesNamespaceEnum(int v) +void c_TestTargetNS__POD__receivesNamespaceEnum_int(void *thisObj, int v); +// TestTargetNS::POD::receivesNamespaceEnum1(AnotherNamespace::NamespaceLevelEnum arg__1) +void c_TestTargetNS__POD__receivesNamespaceEnum1_NamespaceLevelEnum(void *thisObj, int arg__1); +// TestTargetNS::POD::receivesPODs(TestTargetNS::POD pod1, TestTargetNS::POD pod2) +int c_static_TestTargetNS__POD__receivesPODs_POD_POD(void *pod1_, void *pod2_); +// TestTargetNS::POD::receivesPointerToPODs(TestTargetNS::POD * ptrPod1, TestTargetNS::POD * +// ptrPod2) +int c_static_TestTargetNS__POD__receivesPointerToPODs_POD_POD(void *ptrPod1_, void *ptrPod2_); +// TestTargetNS::POD::receivesRefPODs(TestTargetNS::POD & pod1, TestTargetNS::POD & pod2) +int c_static_TestTargetNS__POD__receivesRefPODs_POD_POD(void *pod1_, void *pod2_); +// TestTargetNS::POD::receivesReservedDartKeyword(int var) +void c_TestTargetNS__POD__receivesReservedDartKeyword_int(void *thisObj, int var); +// TestTargetNS::POD::returnsChar() +char c_static_TestTargetNS__POD__returnsChar(); +// TestTargetNS::POD::returnsConstChar() +char c_static_TestTargetNS__POD__returnsConstChar(); +// TestTargetNS::POD::returnsConstReferenceToPOD() +void *c_static_TestTargetNS__POD__returnsConstReferenceToPOD(); +// TestTargetNS::POD::returnsPOD() +void *c_static_TestTargetNS__POD__returnsPOD(); +// TestTargetNS::POD::returnsPointerToPOD() +void *c_static_TestTargetNS__POD__returnsPointerToPOD(); +// TestTargetNS::POD::returnsPointerToPolymorphic() +void *c_static_TestTargetNS__POD__returnsPointerToPolymorphic(); +// TestTargetNS::POD::returnsReferenceToPOD() +void *c_static_TestTargetNS__POD__returnsReferenceToPOD(); +// TestTargetNS::POD::withDefaultAarg(int v) +void c_TestTargetNS__POD__withDefaultAarg_int(void *thisObj, int v); +void c_TestTargetNS__POD__destructor(void *thisObj); +int c_TestTargetNS__POD___get_v1(void *thisObj); +int c_TestTargetNS__POD___get_v2(void *thisObj); +int c_TestTargetNS__POD___get_v3(void *thisObj); +int c_TestTargetNS__POD___get_v4_const(void *thisObj); +void c_TestTargetNS__POD___set_v1_int(void *thisObj, int v1_); +void c_TestTargetNS__POD___set_v2_int(void *thisObj, int v2_); +void c_TestTargetNS__POD___set_v3_int(void *thisObj, int v3_); +void c_TestTargetNS__POD_Finalizer( + void *cppObj); // TestTargetNS::StructWithStructAsMember::StructWithStructAsMember() +void *c_TestTargetNS__StructWithStructAsMember__constructor(); +void c_TestTargetNS__StructWithStructAsMember__destructor(void *thisObj); +void c_TestTargetNS__StructWithStructAsMember_Finalizer( + void *cppObj); // TestTargetNS::MyBaseClass::MyBaseClass() +void *c_TestTargetNS__MyBaseClass__constructor(); +// TestTargetNS::MyBaseClass::MyBaseClass(TestTargetNS::MyBaseClass * mybaseclassptr) +void *c_TestTargetNS__MyBaseClass__constructor_MyBaseClass(void *mybaseclassptr_); +// TestTargetNS::MyBaseClass::addInts(QList arg__1) +void c_TestTargetNS__MyBaseClass__addInts_QList_int(void *thisObj, void *arg__1_); +// TestTargetNS::MyBaseClass::addQObjects(const QList & arg__1) +void c_TestTargetNS__MyBaseClass__addQObjects_QList_QObject(void *thisObj, void *arg__1_); +// TestTargetNS::MyBaseClass::addReals(QList arg__1) +void c_TestTargetNS__MyBaseClass__addReals_QList_qreal(void *thisObj, void *arg__1_); +// TestTargetNS::MyBaseClass::anotherOverloadedStatic(int arg__1) +int c_static_TestTargetNS__MyBaseClass__anotherOverloadedStatic_int(int arg__1); +// TestTargetNS::MyBaseClass::bar() const +int c_TestTargetNS__MyBaseClass__bar(void *thisObj); +// TestTargetNS::MyBaseClass::bar2() const +int c_TestTargetNS__MyBaseClass__bar2(void *thisObj); +// TestTargetNS::MyBaseClass::callsVirtual() const +int c_TestTargetNS__MyBaseClass__callsVirtual(void *thisObj); +// TestTargetNS::MyBaseClass::foo() const +int c_TestTargetNS__MyBaseClass__foo(void *thisObj); +// TestTargetNS::MyBaseClass::getBool(int arg__1) const +bool c_TestTargetNS__MyBaseClass__getBool_int(void *thisObj, int arg__1); +// TestTargetNS::MyBaseClass::getBoolFalse() const +bool c_TestTargetNS__MyBaseClass__getBoolFalse(void *thisObj); +// TestTargetNS::MyBaseClass::getBoolTrue() const +bool c_TestTargetNS__MyBaseClass__getBoolTrue(void *thisObj); +// TestTargetNS::MyBaseClass::hello() +void c_TestTargetNS__MyBaseClass__hello(void *thisObj); +// TestTargetNS::MyBaseClass::methodReturnsIntTemplate() +void *c_TestTargetNS__MyBaseClass__methodReturnsIntTemplate(void *thisObj); +// TestTargetNS::MyBaseClass::nonVirtualButOverridden() const +int c_TestTargetNS__MyBaseClass__nonVirtualButOverridden(void *thisObj); +// TestTargetNS::MyBaseClass::nonVirtualInBaseButVirtualInDerived(int i) const +int c_TestTargetNS__MyBaseClass__nonVirtualInBaseButVirtualInDerived_int(void *thisObj, int i); +// TestTargetNS::MyBaseClass::nonVirtualInBaseButVirtualInDerived(int i, int j) const +int c_TestTargetNS__MyBaseClass__nonVirtualInBaseButVirtualInDerived_int_int(void *thisObj, int i, + int j); +// TestTargetNS::MyBaseClass::nonVirtualReturningStruct() const +void *c_TestTargetNS__MyBaseClass__nonVirtualReturningStruct(void *thisObj); +// TestTargetNS::MyBaseClass::overloadedStatic() +void c_static_TestTargetNS__MyBaseClass__overloadedStatic(); +// TestTargetNS::MyBaseClass::overloadedStatic(int arg__1) +void c_static_TestTargetNS__MyBaseClass__overloadedStatic_int(int arg__1); +// TestTargetNS::MyBaseClass::overloadedStatic(int arg__1, int arg__2) +void c_static_TestTargetNS__MyBaseClass__overloadedStatic_int_int(int arg__1, int arg__2); +// TestTargetNS::MyBaseClass::print(const char * msg) +void c_static_TestTargetNS__MyBaseClass__print_char(const char *msg); +// TestTargetNS::MyBaseClass::push(const char * arg__1) +void c_TestTargetNS__MyBaseClass__push_char(void *thisObj, const char *arg__1); +// TestTargetNS::MyBaseClass::receivesAndReturnsQString(const QString & s) +void *c_TestTargetNS__MyBaseClass__receivesAndReturnsQString_QString(void *thisObj, const char *s_); +// TestTargetNS::MyBaseClass::receivesEnum(TestTargetNS::MyBaseClass::MyEnum e) +int c_TestTargetNS__MyBaseClass__receivesEnum_MyEnum(void *thisObj, int e); +// TestTargetNS::MyBaseClass::receivesEnumWithDefaultArg(TestTargetNS::MyBaseClass::MyEnum arg__1) +void c_TestTargetNS__MyBaseClass__receivesEnumWithDefaultArg_MyEnum(void *thisObj, int arg__1); +// TestTargetNS::MyBaseClass::receivesEnumWithDefaultArgNull(TestTargetNS::MyBaseClass::MyEnum +// arg__1) +void c_TestTargetNS__MyBaseClass__receivesEnumWithDefaultArgNull_MyEnum(void *thisObj, int arg__1); +// TestTargetNS::MyBaseClass::receivesFloat(float arg__1) +void c_TestTargetNS__MyBaseClass__receivesFloat_float(void *thisObj, float arg__1); +// TestTargetNS::MyBaseClass::receivesQFlags(QFlags arg__1) +void c_TestTargetNS__MyBaseClass__receivesQFlags_NamespaceLevelEnums(void *thisObj, int arg__1_); +// TestTargetNS::MyBaseClass::receivesintWithDefaultEnumArg(int arg__1) +void c_TestTargetNS__MyBaseClass__receivesintWithDefaultEnumArg_int(void *thisObj, int arg__1); +// TestTargetNS::MyBaseClass::receivesintWithDefaultEnumArg2(int arg__1) +void c_TestTargetNS__MyBaseClass__receivesintWithDefaultEnumArg2_int(void *thisObj, int arg__1); +// TestTargetNS::MyBaseClass::receivesintWithDefaultEnumArg3(int arg__1) +void c_TestTargetNS__MyBaseClass__receivesintWithDefaultEnumArg3_int(void *thisObj, int arg__1); +// TestTargetNS::MyBaseClass::renamedMethod1() +void c_TestTargetNS__MyBaseClass__renamedMethod2(void *thisObj); +// TestTargetNS::MyBaseClass::renamedVirtual1() +void c_TestTargetNS__MyBaseClass__renamedVirtual2(void *thisObj); +// TestTargetNS::MyBaseClass::returnsConstChar() +const char *c_static_TestTargetNS__MyBaseClass__returnsConstChar(); +// TestTargetNS::MyBaseClass::returnsDoubleTemplate() +void *c_static_TestTargetNS__MyBaseClass__returnsDoubleTemplate(); +// TestTargetNS::MyBaseClass::returnsInt64() const +qint64 c_TestTargetNS__MyBaseClass__returnsInt64(void *thisObj); +// TestTargetNS::MyBaseClass::returnsIntTemplate() +void *c_static_TestTargetNS__MyBaseClass__returnsIntTemplate(); +// TestTargetNS::MyBaseClass::returnsListOfStructPtr() +void *c_static_TestTargetNS__MyBaseClass__returnsListOfStructPtr(); +// TestTargetNS::MyBaseClass::returnsQFlags() const +int c_TestTargetNS__MyBaseClass__returnsQFlags(void *thisObj); +// TestTargetNS::MyBaseClass::returnsQString() +void *c_static_TestTargetNS__MyBaseClass__returnsQString(); +// TestTargetNS::MyBaseClass::returnsReals() const +void *c_TestTargetNS__MyBaseClass__returnsReals(void *thisObj); +// TestTargetNS::MyBaseClass::returnsSimpleStruct(int value) +void *c_static_TestTargetNS__MyBaseClass__returnsSimpleStruct_int(int value); +// TestTargetNS::MyBaseClass::returnsTemplateWithTwoArgs() +void *c_static_TestTargetNS__MyBaseClass__returnsTemplateWithTwoArgs(); +// TestTargetNS::MyBaseClass::returnsVector() +void *c_TestTargetNS__MyBaseClass__returnsVector(void *thisObj); +// TestTargetNS::MyBaseClass::setBool(bool b) +bool c_TestTargetNS__MyBaseClass__setBool_bool(void *thisObj, bool b); +// TestTargetNS::MyBaseClass::sum(int a, int b) +int c_TestTargetNS__MyBaseClass__sum_int_int(void *thisObj, int a, int b); +// TestTargetNS::MyBaseClass::virtualReceivingBool(bool b) +int c_TestTargetNS__MyBaseClass__virtualReceivingBool_bool(void *thisObj, bool b); +// TestTargetNS::MyBaseClass::virtualReceivingCharPtr(char * arg__1) +void c_TestTargetNS__MyBaseClass__virtualReceivingCharPtr_char(void *thisObj, char *arg__1); +// TestTargetNS::MyBaseClass::virtualReceivingInt(int arg__1) +int c_TestTargetNS__MyBaseClass__virtualReceivingInt_int(void *thisObj, int arg__1); +// TestTargetNS::MyBaseClass::virtualReceivingOptionalArgument(int optional) +int c_TestTargetNS__MyBaseClass__virtualReceivingOptionalArgument_int(void *thisObj, int optional); +// TestTargetNS::MyBaseClass::virtualReturningBool(bool b) +bool c_TestTargetNS__MyBaseClass__virtualReturningBool_bool(void *thisObj, bool b); +// TestTargetNS::MyBaseClass::virtualReturningQint64() +qint64 c_TestTargetNS__MyBaseClass__virtualReturningQint64(void *thisObj); +// TestTargetNS::MyBaseClass::virtualReturningStruct() const +void *c_TestTargetNS__MyBaseClass__virtualReturningStruct(void *thisObj); +// TestTargetNS::MyBaseClass::virtualReturnsIntTemplate() +void *c_TestTargetNS__MyBaseClass__virtualReturnsIntTemplate(void *thisObj); +// TestTargetNS::MyBaseClass::virtualWithNoDefaultArgumentInDerived(int optional) +void c_TestTargetNS__MyBaseClass__virtualWithNoDefaultArgumentInDerived_int(void *thisObj, + int optional); +// TestTargetNS::MyBaseClass::virtualWithOverload(int i) const +void c_TestTargetNS__MyBaseClass__virtualWithOverload_int(void *thisObj, int i); +// TestTargetNS::MyBaseClass::virtualWithOverload(int i, int j) const +void c_TestTargetNS__MyBaseClass__virtualWithOverload_int_int(void *thisObj, int i, int j); +void c_TestTargetNS__MyBaseClass__destructor(void *thisObj); +int c_static_TestTargetNS__MyBaseClass___get_s_instanceCount(); +int c_static_TestTargetNS__MyBaseClass___get_s_staticMember(); +int c_static_TestTargetNS__MyBaseClass___get_s_staticConstMember(); +void c_static_TestTargetNS__MyBaseClass___set_s_instanceCount_int(int s_instanceCount_); +void c_static_TestTargetNS__MyBaseClass___set_s_staticMember_int(int s_staticMember_); +void c_TestTargetNS__MyBaseClass__registerVirtualMethodCallback(void *ptr, void *callback, + int methodId); +void c_TestTargetNS__MyBaseClass_Finalizer( + void *cppObj); // TestTargetNS::MyDerivedClass::MyDerivedClass() +void *c_TestTargetNS__MyDerivedClass__constructor(); +// TestTargetNS::MyDerivedClass::alsoCallsVirtual() +int c_TestTargetNS__MyDerivedClass__alsoCallsVirtual(void *thisObj); +// TestTargetNS::MyDerivedClass::anotherOverloadedStatic(int arg__1) +void *c_static_TestTargetNS__MyDerivedClass__anotherOverloadedStatic_int(int arg__1); +// TestTargetNS::MyDerivedClass::anotherOverloadedStatic(int arg__1, int arg__2) +void *c_static_TestTargetNS__MyDerivedClass__anotherOverloadedStatic_int_int(int arg__1, + int arg__2); +// TestTargetNS::MyDerivedClass::bar() const +int c_TestTargetNS__MyDerivedClass__bar(void *thisObj); +// TestTargetNS::MyDerivedClass::bar2() const +int c_TestTargetNS__MyDerivedClass__bar2(void *thisObj); +// TestTargetNS::MyDerivedClass::nonVirtualButOverridden() const +int c_TestTargetNS__MyDerivedClass__nonVirtualButOverridden(void *thisObj); +// TestTargetNS::MyDerivedClass::nonVirtualInBaseButVirtualInDerived(int i, int j) const +int c_TestTargetNS__MyDerivedClass__nonVirtualInBaseButVirtualInDerived_int_int(void *thisObj, + int i, int j); +// TestTargetNS::MyDerivedClass::paintEvent() +void c_TestTargetNS__MyDerivedClass__paintEvent(void *thisObj); +// TestTargetNS::MyDerivedClass::receivesDerivedPolymorphic(TestTargetNS::MyDerivedClass * der) +int c_TestTargetNS__MyDerivedClass__receivesDerivedPolymorphic_MyDerivedClass(void *thisObj, + void *der_); +// TestTargetNS::MyDerivedClass::receivesEnumFromBaseClassWithDefaultValue(int a) +void c_TestTargetNS__MyDerivedClass__receivesEnumFromBaseClassWithDefaultValue_int(void *thisObj, + int a); +// TestTargetNS::MyDerivedClass::receivesProtectedEnum(TestTargetNS::MyBaseClass::ProtectedEnum p) +int c_TestTargetNS__MyDerivedClass__receivesProtectedEnum_ProtectedEnum(void *thisObj, int p); +// TestTargetNS::MyDerivedClass::renamedVirtual1() +void c_TestTargetNS__MyDerivedClass__renamedVirtual2(void *thisObj); +// TestTargetNS::MyDerivedClass::returnTemplate1() +void *c_TestTargetNS__MyDerivedClass__returnTemplate1(void *thisObj); +// TestTargetNS::MyDerivedClass::returnTemplate2() +void *c_TestTargetNS__MyDerivedClass__returnTemplate2(void *thisObj); +// TestTargetNS::MyDerivedClass::returnsAnotherNamespaceEnum() +int c_static_TestTargetNS__MyDerivedClass__returnsAnotherNamespaceEnum(); +// TestTargetNS::MyDerivedClass::returnsAnotherNamespaceStruct() +void *c_static_TestTargetNS__MyDerivedClass__returnsAnotherNamespaceStruct(); +// TestTargetNS::MyDerivedClass::returnsConstPointer() +void *c_TestTargetNS__MyDerivedClass__returnsConstPointer(void *thisObj); +// TestTargetNS::MyDerivedClass::setVisible(bool b) +void c_TestTargetNS__MyDerivedClass__setVisible_bool(void *thisObj, bool b); +// TestTargetNS::MyDerivedClass::show() +void c_TestTargetNS__MyDerivedClass__show(void *thisObj); +// TestTargetNS::MyDerivedClass::virtualNotInBase() const +int c_TestTargetNS__MyDerivedClass__virtualNotInBase(void *thisObj); +// TestTargetNS::MyDerivedClass::virtualReceivingBool(bool b) +int c_TestTargetNS__MyDerivedClass__virtualReceivingBool_bool(void *thisObj, bool b); +// TestTargetNS::MyDerivedClass::virtualReceivingCharPtr(char * arg__1) +void c_TestTargetNS__MyDerivedClass__virtualReceivingCharPtr_char(void *thisObj, char *arg__1); +// TestTargetNS::MyDerivedClass::virtualReceivingInt(int arg__1) +int c_TestTargetNS__MyDerivedClass__virtualReceivingInt_int(void *thisObj, int arg__1); +// TestTargetNS::MyDerivedClass::virtualReceivingOptionalArgument(int optional) +int c_TestTargetNS__MyDerivedClass__virtualReceivingOptionalArgument_int(void *thisObj, + int optional); +// TestTargetNS::MyDerivedClass::virtualReturningBool(bool b) +bool c_TestTargetNS__MyDerivedClass__virtualReturningBool_bool(void *thisObj, bool b); +// TestTargetNS::MyDerivedClass::virtualReturningQint64() +qint64 c_TestTargetNS__MyDerivedClass__virtualReturningQint64(void *thisObj); +// TestTargetNS::MyDerivedClass::virtualReturningStruct() const +void *c_TestTargetNS__MyDerivedClass__virtualReturningStruct(void *thisObj); +// TestTargetNS::MyDerivedClass::virtualReturnsIntTemplate() +void *c_TestTargetNS__MyDerivedClass__virtualReturnsIntTemplate(void *thisObj); +// TestTargetNS::MyDerivedClass::virtualWithOverload(int i) const +void c_TestTargetNS__MyDerivedClass__virtualWithOverload_int(void *thisObj, int i); +// TestTargetNS::MyDerivedClass::virtualWithOverload(int i, int j) const +void c_TestTargetNS__MyDerivedClass__virtualWithOverload_int_int(void *thisObj, int i, int j); +void c_TestTargetNS__MyDerivedClass__destructor(void *thisObj); +int c_static_TestTargetNS__MyDerivedClass___get_s_instanceCount(); +void c_static_TestTargetNS__MyDerivedClass___set_s_instanceCount_int(int s_instanceCount_); +void c_TestTargetNS__MyDerivedClass__registerVirtualMethodCallback(void *ptr, void *callback, + int methodId); +void c_TestTargetNS__MyDerivedClass_Finalizer( + void *cppObj); // TestTargetNS::DestructorCounter::DestructorCounter() +void *c_TestTargetNS__DestructorCounter__constructor(); +// TestTargetNS::DestructorCounter::instanceCount() +int c_static_TestTargetNS__DestructorCounter__instanceCount(); +// TestTargetNS::DestructorCounter::newOnTheHeap() +void *c_static_TestTargetNS__DestructorCounter__newOnTheHeap(); +// TestTargetNS::DestructorCounter::newOnTheStack() +void *c_static_TestTargetNS__DestructorCounter__newOnTheStack(); +void c_TestTargetNS__DestructorCounter__destructor(void *thisObj); +int c_static_TestTargetNS__DestructorCounter___get_s_instanceCount(); +void c_static_TestTargetNS__DestructorCounter___set_s_instanceCount_int(int s_instanceCount_); +void c_TestTargetNS__DestructorCounter_Finalizer( + void *cppObj); // TestTargetNS::DerivedFromPureAbstract::DerivedFromPureAbstract() +void *c_TestTargetNS__DerivedFromPureAbstract__constructor(); +// TestTargetNS::DerivedFromPureAbstract::DerivedFromPureAbstract(int arg__1) +void *c_TestTargetNS__DerivedFromPureAbstract__constructor_int(int arg__1); +// TestTargetNS::DerivedFromPureAbstract::foo() +int c_TestTargetNS__DerivedFromPureAbstract__foo(void *thisObj); +// TestTargetNS::DerivedFromPureAbstract::indirectionCallsVirtualReceivingStruct(SimpleStruct s) +int c_TestTargetNS__DerivedFromPureAbstract__indirectionCallsVirtualReceivingStruct_SimpleStruct( + void *thisObj, void *s_); +// TestTargetNS::DerivedFromPureAbstract::nonVirtualCallsVirtual() +int c_TestTargetNS__DerivedFromPureAbstract__nonVirtualCallsVirtual(void *thisObj); +// TestTargetNS::DerivedFromPureAbstract::receivesValueStruct(SimpleStruct arg__1) +int c_TestTargetNS__DerivedFromPureAbstract__receivesValueStruct_SimpleStruct(void *thisObj, + void *arg__1_); +// TestTargetNS::DerivedFromPureAbstract::renamedPureVirtual() +void c_TestTargetNS__DerivedFromPureAbstract__renamedPureVirtual1(void *thisObj); +// TestTargetNS::DerivedFromPureAbstract::unnamedOverriddenDefaultArgCase(int arg__1) +void c_TestTargetNS__DerivedFromPureAbstract__unnamedOverriddenDefaultArgCase_int(void *thisObj, + int arg__1); +// TestTargetNS::DerivedFromPureAbstract::virtualReceivingPointer(SimpleStruct * s) +int c_TestTargetNS__DerivedFromPureAbstract__virtualReceivingPointer_SimpleStruct(void *thisObj, + void *s_); +// TestTargetNS::DerivedFromPureAbstract::voidPureAbstract() +void c_TestTargetNS__DerivedFromPureAbstract__voidPureAbstract(void *thisObj); +void c_TestTargetNS__DerivedFromPureAbstract__destructor(void *thisObj); +void c_TestTargetNS__DerivedFromPureAbstract__registerVirtualMethodCallback(void *ptr, + void *callback, + int methodId); +void c_TestTargetNS__DerivedFromPureAbstract_Finalizer( + void *cppObj); // TestTargetNS::Derived2FromPureAbstract::Derived2FromPureAbstract() +void *c_TestTargetNS__Derived2FromPureAbstract__constructor(); +// TestTargetNS::Derived2FromPureAbstract::foo() +int c_TestTargetNS__Derived2FromPureAbstract__foo(void *thisObj); +// TestTargetNS::Derived2FromPureAbstract::renamedPureVirtual() +void c_TestTargetNS__Derived2FromPureAbstract__renamedPureVirtual1(void *thisObj); +// TestTargetNS::Derived2FromPureAbstract::unnamedOverriddenDefaultArgCase(int myarg) +void c_TestTargetNS__Derived2FromPureAbstract__unnamedOverriddenDefaultArgCase_int(void *thisObj, + int myarg); +// TestTargetNS::Derived2FromPureAbstract::virtualReceivingPointer(SimpleStruct * s) +int c_TestTargetNS__Derived2FromPureAbstract__virtualReceivingPointer_SimpleStruct(void *thisObj, + void *s_); +// TestTargetNS::Derived2FromPureAbstract::voidPureAbstract() +void c_TestTargetNS__Derived2FromPureAbstract__voidPureAbstract(void *thisObj); +void c_TestTargetNS__Derived2FromPureAbstract__destructor(void *thisObj); +void c_TestTargetNS__Derived2FromPureAbstract__registerVirtualMethodCallback(void *ptr, + void *callback, + int methodId); +void c_TestTargetNS__Derived2FromPureAbstract_Finalizer( + void *cppObj); // SimpleStruct::SimpleStruct() +void *c_SimpleStruct__constructor(); +void c_SimpleStruct__destructor(void *thisObj); +int c_SimpleStruct___get_value(void *thisObj); +void c_SimpleStruct___set_value_int(void *thisObj, int value_); +void c_SimpleStruct_Finalizer(void *cppObj); // SimpleObjectStruct::SimpleObjectStruct() +void *c_SimpleObjectStruct__constructor(); +// SimpleObjectStruct::receivesStructWithDefaultArg(SimpleObjectStruct arg__1) +void c_SimpleObjectStruct__receivesStructWithDefaultArg_SimpleObjectStruct(void *thisObj, + void *arg__1_); +void c_SimpleObjectStruct__destructor(void *thisObj); +void c_SimpleObjectStruct_Finalizer(void *cppObj); +void c_Qt_Finalizer(void *cppObj); // QVariant::QVariant() +void *c_QVariant__constructor(); +// QVariant::QVariant(bool b) +void *c_QVariant__constructor_bool(bool b); +// QVariant::QVariant(const QByteArray & bytearray) +void *c_QVariant__constructor_QByteArray(void *bytearray_); +// QVariant::QVariant(const QHash & hash) +void *c_QVariant__constructor_QHash_QString_QVariant(void *hash_); +// QVariant::QVariant(const QList & stringlist) +void *c_QVariant__constructor_QList_QString(void *stringlist_); +// QVariant::QVariant(const QList & list) +void *c_QVariant__constructor_QList_QVariant(void *list_); +// QVariant::QVariant(const QMap & map) +void *c_QVariant__constructor_QMap_QString_QVariant(void *map_); +// QVariant::QVariant(const QString & string) +void *c_QVariant__constructor_QString(const char *string_); +// QVariant::QVariant(const char * str) +void *c_QVariant__constructor_char(const char *str); +// QVariant::QVariant(double d) +void *c_QVariant__constructor_double(double d); +// QVariant::QVariant(float f) +void *c_QVariant__constructor_float(float f); +// QVariant::QVariant(int i) +void *c_QVariant__constructor_int(int i); +// QVariant::QVariant(qint64 ll) +void *c_QVariant__constructor_qint64(qint64 ll); +// QVariant::clear() +void c_QVariant__clear(void *thisObj); +// QVariant::detach() +void c_QVariant__detach(void *thisObj); +// QVariant::equals(const QVariant & other) const +bool c_QVariant__equals_QVariant(void *thisObj, void *other_); +// QVariant::fromObject(QObject * arg__1) +void *c_static_QVariant__fromObject_QObject(void *arg__1_); +// QVariant::isDetached() const +bool c_QVariant__isDetached(void *thisObj); +// QVariant::isNull() const +bool c_QVariant__isNull(void *thisObj); +// QVariant::isValid() const +bool c_QVariant__isValid(void *thisObj); +// QVariant::setValue(const QVariant & avalue) +void c_QVariant__setValue_QVariant(void *thisObj, void *avalue_); +// QVariant::toBool() const +bool c_QVariant__toBool(void *thisObj); +// QVariant::toByteArray() const +void *c_QVariant__toByteArray(void *thisObj); +// QVariant::toHash() const +void *c_QVariant__toHash(void *thisObj); +// QVariant::toList() const +void *c_QVariant__toList(void *thisObj); +// QVariant::toMap() const +void *c_QVariant__toMap(void *thisObj); +// QVariant::toStringList() const +void *c_QVariant__toStringList(void *thisObj); +// QVariant::typeId() const +int c_QVariant__typeId(void *thisObj); +// QVariant::typeName() const +const char *c_QVariant__typeName(void *thisObj); +// QVariant::userType() const +int c_QVariant__userType(void *thisObj); +void c_QVariant__destructor(void *thisObj); +void c_QVariant_Finalizer(void *cppObj); // QString::QString() +void *c_QString__constructor(); +// QString::QString(const QByteArray & a) +void *c_QString__constructor_QByteArray(void *a_); +// QString::QString(const char * ch) +void *c_QString__constructor_char(const char *ch); +// QString::append(const QByteArray & s) +void *c_QString__append_QByteArray(void *thisObj, void *s_); +// QString::append(const QString & s) +void *c_QString__append_QString(void *thisObj, const char *s_); +// QString::append(const char * s) +void *c_QString__append_char(void *thisObj, const char *s); +// QString::arg(const QString & a, int fieldWidth) const +void *c_QString__arg_QString_int(void *thisObj, const char *a_, int fieldWidth); +// QString::arg(int a, int fieldWidth, int base) const +void *c_QString__arg_int_int_int(void *thisObj, int a, int fieldWidth, int base); +// QString::arg(long a, int fieldwidth, int base) const +void *c_QString__arg_long_int_int(void *thisObj, long a, int fieldwidth, int base); +// QString::arg(qint64 a, int fieldwidth, int base) const +void *c_QString__arg_qint64_int_int(void *thisObj, qint64 a, int fieldwidth, int base); +// QString::arg(short a, int fieldWidth, int base) const +void *c_QString__arg_short_int_int(void *thisObj, short a, int fieldWidth, int base); +// QString::asprintf(const char * format) +void *c_static_QString__asprintf_char(const char *format); +// QString::capacity() const +qsizetype c_QString__capacity(void *thisObj); +// QString::chop(qsizetype n) +void c_QString__chop_qsizetype(void *thisObj, qsizetype n); +// QString::chopped(qsizetype n) const +void *c_QString__chopped_qsizetype(void *thisObj, qsizetype n); +// QString::clear() +void c_QString__clear(void *thisObj); +// QString::compare(const QString & s) const +int c_QString__compare_QString(void *thisObj, const char *s_); +// QString::compare(const QString & s1, const QString & s2) +int c_static_QString__compare_QString_QString(const char *s1_, const char *s2_); +// QString::contains(const QString & s) const +bool c_QString__contains_QString(void *thisObj, const char *s_); +// QString::count() const +qsizetype c_QString__count(void *thisObj); +// QString::count(const QString & s) const +qsizetype c_QString__count_QString(void *thisObj, const char *s_); +// QString::detach() +void c_QString__detach(void *thisObj); +// QString::endsWith(const QString & s) const +bool c_QString__endsWith_QString(void *thisObj, const char *s_); +// QString::first(qsizetype n) const +void *c_QString__first_qsizetype(void *thisObj, qsizetype n); +// QString::fromLatin1(const char * str, qsizetype size) +void *c_static_QString__fromLatin1_char_qsizetype(const char *str, qsizetype size); +// QString::fromLocal8Bit(const char * str, qsizetype size) +void *c_static_QString__fromLocal8Bit_char_qsizetype(const char *str, qsizetype size); +// QString::fromUtf8(const char * utf8, qsizetype size) +void *c_static_QString__fromUtf8_char_qsizetype(const char *utf8, qsizetype size); +// QString::indexOf(const QString & s, qsizetype from) const +qsizetype c_QString__indexOf_QString_qsizetype(void *thisObj, const char *s_, qsizetype from); +// QString::insert(qsizetype i, const QByteArray & s) +void *c_QString__insert_qsizetype_QByteArray(void *thisObj, qsizetype i, void *s_); +// QString::insert(qsizetype i, const QString & s) +void *c_QString__insert_qsizetype_QString(void *thisObj, qsizetype i, const char *s_); +// QString::insert(qsizetype i, const char * s) +void *c_QString__insert_qsizetype_char(void *thisObj, qsizetype i, const char *s); +// QString::isDetached() const +bool c_QString__isDetached(void *thisObj); +// QString::isEmpty() const +bool c_QString__isEmpty(void *thisObj); +// QString::isLower() const +bool c_QString__isLower(void *thisObj); +// QString::isNull() const +bool c_QString__isNull(void *thisObj); +// QString::isRightToLeft() const +bool c_QString__isRightToLeft(void *thisObj); +// QString::isSharedWith(const QString & other) const +bool c_QString__isSharedWith_QString(void *thisObj, const char *other_); +// QString::isSimpleText() const +bool c_QString__isSimpleText(void *thisObj); +// QString::isUpper() const +bool c_QString__isUpper(void *thisObj); +// QString::isValidUtf16() const +bool c_QString__isValidUtf16(void *thisObj); +// QString::last(qsizetype n) const +void *c_QString__last_qsizetype(void *thisObj, qsizetype n); +// QString::lastIndexOf(const QString & s) const +qsizetype c_QString__lastIndexOf_QString(void *thisObj, const char *s_); +// QString::lastIndexOf(const QString & s, qsizetype from) const +qsizetype c_QString__lastIndexOf_QString_qsizetype(void *thisObj, const char *s_, qsizetype from); +// QString::left(qsizetype n) const +void *c_QString__left_qsizetype(void *thisObj, qsizetype n); +// QString::leftJustified(qsizetype width) const +void *c_QString__leftJustified_qsizetype(void *thisObj, qsizetype width); +// QString::length() const +qsizetype c_QString__length(void *thisObj); +// QString::localeAwareCompare(const QString & s) const +int c_QString__localeAwareCompare_QString(void *thisObj, const char *s_); +// QString::localeAwareCompare(const QString & s1, const QString & s2) +int c_static_QString__localeAwareCompare_QString_QString(const char *s1_, const char *s2_); +// QString::mid(qsizetype position, qsizetype n) const +void *c_QString__mid_qsizetype_qsizetype(void *thisObj, qsizetype position, qsizetype n); +// QString::number(int arg__1, int base) +void *c_static_QString__number_int_int(int arg__1, int base); +// QString::number(long arg__1, int base) +void *c_static_QString__number_long_int(long arg__1, int base); +// QString::number(qint64 arg__1, int base) +void *c_static_QString__number_qint64_int(qint64 arg__1, int base); +// QString::prepend(const QByteArray & s) +void *c_QString__prepend_QByteArray(void *thisObj, void *s_); +// QString::prepend(const QString & s) +void *c_QString__prepend_QString(void *thisObj, const char *s_); +// QString::prepend(const char * s) +void *c_QString__prepend_char(void *thisObj, const char *s); +// QString::push_back(const QString & s) +void c_QString__push_back_QString(void *thisObj, const char *s_); +// QString::push_front(const QString & s) +void c_QString__push_front_QString(void *thisObj, const char *s_); +// QString::remove(const QString & s) +void *c_QString__remove_QString(void *thisObj, const char *s_); +// QString::remove(qsizetype i, qsizetype len) +void *c_QString__remove_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype len); +// QString::repeated(qsizetype times) const +void *c_QString__repeated_qsizetype(void *thisObj, qsizetype times); +// QString::replace(const QString & before, const QString & after) +void *c_QString__replace_QString_QString(void *thisObj, const char *before_, const char *after_); +// QString::replace(qsizetype i, qsizetype len, const QString & after) +void *c_QString__replace_qsizetype_qsizetype_QString(void *thisObj, qsizetype i, qsizetype len, + const char *after_); +// QString::reserve(qsizetype size) +void c_QString__reserve_qsizetype(void *thisObj, qsizetype size); +// QString::resize(qsizetype size) +void c_QString__resize_qsizetype(void *thisObj, qsizetype size); +// QString::right(qsizetype n) const +void *c_QString__right_qsizetype(void *thisObj, qsizetype n); +// QString::rightJustified(qsizetype width) const +void *c_QString__rightJustified_qsizetype(void *thisObj, qsizetype width); +// QString::section(const QString & in_sep, qsizetype start, qsizetype end) const +void *c_QString__section_QString_qsizetype_qsizetype(void *thisObj, const char *in_sep_, + qsizetype start, qsizetype end); +// QString::setNum(int arg__1, int base) +void *c_QString__setNum_int_int(void *thisObj, int arg__1, int base); +// QString::setNum(long arg__1, int base) +void *c_QString__setNum_long_int(void *thisObj, long arg__1, int base); +// QString::setNum(qint64 arg__1, int base) +void *c_QString__setNum_qint64_int(void *thisObj, qint64 arg__1, int base); +// QString::setNum(short arg__1, int base) +void *c_QString__setNum_short_int(void *thisObj, short arg__1, int base); +// QString::shrink_to_fit() +void c_QString__shrink_to_fit(void *thisObj); +// QString::simplified() +void *c_QString__simplified(void *thisObj); +// QString::size() const +qsizetype c_QString__size(void *thisObj); +// QString::sliced(qsizetype pos) const +void *c_QString__sliced_qsizetype(void *thisObj, qsizetype pos); +// QString::sliced(qsizetype pos, qsizetype n) const +void *c_QString__sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype n); +// QString::split(const QString & sep) const +void *c_QString__split_QString(void *thisObj, const char *sep_); +// QString::squeeze() +void c_QString__squeeze(void *thisObj); +// QString::startsWith(const QString & s) const +bool c_QString__startsWith_QString(void *thisObj, const char *s_); +// QString::toCaseFolded() +void *c_QString__toCaseFolded(void *thisObj); +// QString::toHtmlEscaped() const +void *c_QString__toHtmlEscaped(void *thisObj); +// QString::toLatin1() +void *c_QString__toLatin1(void *thisObj); +// QString::toLocal8Bit() +void *c_QString__toLocal8Bit(void *thisObj); +// QString::toLower() +void *c_QString__toLower(void *thisObj); +// QString::toUcs4() const +void *c_QString__toUcs4(void *thisObj); +// QString::toUpper() +void *c_QString__toUpper(void *thisObj); +// QString::toUtf8() +void *c_QString__toUtf8(void *thisObj); +// QString::trimmed() +void *c_QString__trimmed(void *thisObj); +// QString::truncate(qsizetype pos) +void c_QString__truncate_qsizetype(void *thisObj, qsizetype pos); +void c_QString__destructor(void *thisObj); +void c_QString_Finalizer(void *cppObj); // QObject::QObject(QObject * parent) +void *c_QObject__constructor_QObject(void *parent_); +// QObject::blockSignals(bool b) +bool c_QObject__blockSignals_bool(void *thisObj, bool b); +// QObject::children() const +void *c_QObject__children(void *thisObj); +// QObject::customEvent(QEvent * event) +void c_QObject__customEvent_QEvent(void *thisObj, void *event_); +// QObject::deleteLater() +void c_QObject__deleteLater(void *thisObj); +// QObject::destroyed(QObject * arg__1) +void c_QObject__destroyed_QObject(void *thisObj, void *arg__1_); +void c_QObject__onDestroyed_QObject(void *thisObj, void *contextQObject, + void *callback); // QObject::disconnect(const QObject * + // receiver, const char * member) const +bool c_QObject__disconnect_QObject_char(void *thisObj, void *receiver_, const char *member); +// QObject::disconnect(const QObject * sender, const char * signal, const QObject * receiver, const +// char * member) +bool c_static_QObject__disconnect_QObject_char_QObject_char(void *sender_, const char *signal, + void *receiver_, const char *member); +// QObject::disconnect(const char * signal, const QObject * receiver, const char * member) const +bool c_QObject__disconnect_char_QObject_char(void *thisObj, const char *signal, void *receiver_, + const char *member); +// QObject::dumpObjectInfo() const +void c_QObject__dumpObjectInfo(void *thisObj); +// QObject::dumpObjectTree() const +void c_QObject__dumpObjectTree(void *thisObj); +// QObject::dynamicPropertyNames() const +void *c_QObject__dynamicPropertyNames(void *thisObj); +// QObject::event(QEvent * event) +bool c_QObject__event_QEvent(void *thisObj, void *event_); +// QObject::eventFilter(QObject * watched, QEvent * event) +bool c_QObject__eventFilter_QObject_QEvent(void *thisObj, void *watched_, void *event_); +// QObject::inherits(const char * classname) const +bool c_QObject__inherits_char(void *thisObj, const char *classname); +// QObject::installEventFilter(QObject * filterObj) +void c_QObject__installEventFilter_QObject(void *thisObj, void *filterObj_); +// QObject::isWidgetType() const +bool c_QObject__isWidgetType(void *thisObj); +// QObject::isWindowType() const +bool c_QObject__isWindowType(void *thisObj); +// QObject::killTimer(int id) +void c_QObject__killTimer_int(void *thisObj, int id); +// QObject::objectName() const +void *c_QObject__objectName(void *thisObj); +// QObject::parent() const +void *c_QObject__parent(void *thisObj); +// QObject::property(const char * name) const +void *c_QObject__property_char(void *thisObj, const char *name); +// QObject::receivers(const char * signal) const +int c_QObject__receivers_char(void *thisObj, const char *signal); +// QObject::removeEventFilter(QObject * obj) +void c_QObject__removeEventFilter_QObject(void *thisObj, void *obj_); +// QObject::sender() const +void *c_QObject__sender(void *thisObj); +// QObject::senderSignalIndex() const +int c_QObject__senderSignalIndex(void *thisObj); +// QObject::setObjectName(const QString & name) +void c_QObject__setObjectName_QString(void *thisObj, const char *name_); +// QObject::setParent(QObject * parent) +void c_QObject__setParent_QObject(void *thisObj, void *parent_); +// QObject::setProperty(const char * name, const QVariant & value) +bool c_QObject__setProperty_char_QVariant(void *thisObj, const char *name, void *value_); +// QObject::signalsBlocked() const +bool c_QObject__signalsBlocked(void *thisObj); +// QObject::startTimer(int interval) +int c_QObject__startTimer_int(void *thisObj, int interval); +// QObject::tr(const char * s, const char * c, int n) +void *c_static_QObject__tr_char_char_int(const char *s, const char *c, int n); +void c_QObject__destructor(void *thisObj); +void c_QObject__registerVirtualMethodCallback(void *ptr, void *callback, int methodId); +void c_QObject_Finalizer(void *cppObj); // QMap::QMap() +void *c_QMap_T_QString_QVariant_T___constructor(); +// QMap::clear() +void c_QMap_T_QString_QVariant_T___clear(void *thisObj); +// QMap::contains(const Key & key) const +bool c_QMap_T_QString_QVariant_T___contains_QString(void *thisObj, const char *key_); +// QMap::detach() +void c_QMap_T_QString_QVariant_T___detach(void *thisObj); +// QMap::empty() const +bool c_QMap_T_QString_QVariant_T___empty(void *thisObj); +// QMap::first() +void *c_QMap_T_QString_QVariant_T___first(void *thisObj); +// QMap::firstKey() const +const void *c_QMap_T_QString_QVariant_T___firstKey(void *thisObj); +// QMap::insert(const QMap & map) +void c_QMap_T_QString_QVariant_T___insert_QMap_Key_T(void *thisObj, void *map_); +// QMap::isDetached() const +bool c_QMap_T_QString_QVariant_T___isDetached(void *thisObj); +// QMap::isEmpty() const +bool c_QMap_T_QString_QVariant_T___isEmpty(void *thisObj); +// QMap::isSharedWith(const QMap & other) const +bool c_QMap_T_QString_QVariant_T___isSharedWith_QMap_Key_T(void *thisObj, void *other_); +// QMap::key(const T & value, const Key & defaultKey) const +void *c_QMap_T_QString_QVariant_T___key_QVariant_QString(void *thisObj, void *value_, + const char *defaultKey_); +// QMap::keys() const +void *c_QMap_T_QString_QVariant_T___keys(void *thisObj); +// QMap::keys(const T & value) const +void *c_QMap_T_QString_QVariant_T___keys_QVariant(void *thisObj, void *value_); +// QMap::last() +void *c_QMap_T_QString_QVariant_T___last(void *thisObj); +// QMap::lastKey() const +const void *c_QMap_T_QString_QVariant_T___lastKey(void *thisObj); +// QMap::take(const Key & key) +void *c_QMap_T_QString_QVariant_T___take_QString(void *thisObj, const char *key_); +// QMap::value(const Key & key, const T & defaultValue) const +void *c_QMap_T_QString_QVariant_T___value_QString_QVariant(void *thisObj, const char *key_, + void *defaultValue_); +// QMap::values() const +void *c_QMap_T_QString_QVariant_T___values(void *thisObj); +void c_QMap_T_QString_QVariant_T___destructor(void *thisObj); +void c_QMap_T_QString_QVariant_T__Finalizer(void *cppObj); // QList::QList() +void *c_QList_T_SimpleStruct_T___constructor(); +// QList::QList(qsizetype size) +void *c_QList_T_SimpleStruct_T___constructor_qsizetype(qsizetype size); +// QList::append(const QList & l) +void c_QList_T_SimpleStruct_T___append_QList_T(void *thisObj, void *l_); +// QList::at(qsizetype i) const +const void *c_QList_T_SimpleStruct_T___at_qsizetype(void *thisObj, qsizetype i); +// QList::back() +void *c_QList_T_SimpleStruct_T___back(void *thisObj); +// QList::capacity() const +qsizetype c_QList_T_SimpleStruct_T___capacity(void *thisObj); +// QList::clear() +void c_QList_T_SimpleStruct_T___clear(void *thisObj); +// QList::constFirst() const +const void *c_QList_T_SimpleStruct_T___constFirst(void *thisObj); +// QList::constLast() const +const void *c_QList_T_SimpleStruct_T___constLast(void *thisObj); +// QList::count() const +qsizetype c_QList_T_SimpleStruct_T___count(void *thisObj); +// QList::detach() +void c_QList_T_SimpleStruct_T___detach(void *thisObj); +// QList::empty() const +bool c_QList_T_SimpleStruct_T___empty(void *thisObj); +// QList::first() +void *c_QList_T_SimpleStruct_T___first(void *thisObj); +// QList::first(qsizetype n) const +void *c_QList_T_SimpleStruct_T___first_qsizetype(void *thisObj, qsizetype n); +// QList::front() +void *c_QList_T_SimpleStruct_T___front(void *thisObj); +// QList::isDetached() const +bool c_QList_T_SimpleStruct_T___isDetached(void *thisObj); +// QList::isEmpty() const +bool c_QList_T_SimpleStruct_T___isEmpty(void *thisObj); +// QList::isSharedWith(const QList & other) const +bool c_QList_T_SimpleStruct_T___isSharedWith_QList_T(void *thisObj, void *other_); +// QList::last() +void *c_QList_T_SimpleStruct_T___last(void *thisObj); +// QList::last(qsizetype n) const +void *c_QList_T_SimpleStruct_T___last_qsizetype(void *thisObj, qsizetype n); +// QList::length() const +qsizetype c_QList_T_SimpleStruct_T___length(void *thisObj); +// QList::mid(qsizetype pos, qsizetype len) const +void *c_QList_T_SimpleStruct_T___mid_qsizetype_qsizetype(void *thisObj, qsizetype pos, + qsizetype len); +// QList::move(qsizetype from, qsizetype to) +void c_QList_T_SimpleStruct_T___move_qsizetype_qsizetype(void *thisObj, qsizetype from, + qsizetype to); +// QList::pop_back() +void c_QList_T_SimpleStruct_T___pop_back(void *thisObj); +// QList::pop_front() +void c_QList_T_SimpleStruct_T___pop_front(void *thisObj); +// QList::remove(qsizetype i, qsizetype n) +void c_QList_T_SimpleStruct_T___remove_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype n); +// QList::removeAt(qsizetype i) +void c_QList_T_SimpleStruct_T___removeAt_qsizetype(void *thisObj, qsizetype i); +// QList::removeFirst() +void c_QList_T_SimpleStruct_T___removeFirst(void *thisObj); +// QList::removeLast() +void c_QList_T_SimpleStruct_T___removeLast(void *thisObj); +// QList::reserve(qsizetype size) +void c_QList_T_SimpleStruct_T___reserve_qsizetype(void *thisObj, qsizetype size); +// QList::resize(qsizetype size) +void c_QList_T_SimpleStruct_T___resize_qsizetype(void *thisObj, qsizetype size); +// QList::shrink_to_fit() +void c_QList_T_SimpleStruct_T___shrink_to_fit(void *thisObj); +// QList::size() const +qsizetype c_QList_T_SimpleStruct_T___size(void *thisObj); +// QList::sliced(qsizetype pos) const +void *c_QList_T_SimpleStruct_T___sliced_qsizetype(void *thisObj, qsizetype pos); +// QList::sliced(qsizetype pos, qsizetype n) const +void *c_QList_T_SimpleStruct_T___sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, + qsizetype n); +// QList::squeeze() +void c_QList_T_SimpleStruct_T___squeeze(void *thisObj); +// QList::swapItemsAt(qsizetype i, qsizetype j) +void c_QList_T_SimpleStruct_T___swapItemsAt_qsizetype_qsizetype(void *thisObj, qsizetype i, + qsizetype j); +// QList::takeAt(qsizetype i) +void *c_QList_T_SimpleStruct_T___takeAt_qsizetype(void *thisObj, qsizetype i); +// QList::toList() const +void *c_QList_T_SimpleStruct_T___toList(void *thisObj); +// QList::toVector() const +void *c_QList_T_SimpleStruct_T___toVector(void *thisObj); +// QList::value(qsizetype i) const +void *c_QList_T_SimpleStruct_T___value_qsizetype(void *thisObj, qsizetype i); +void c_QList_T_SimpleStruct_T___destructor(void *thisObj); +void c_QList_T_SimpleStruct_T__Finalizer(void *cppObj); // QList::QList() +void *c_QList_T_qreal_T___constructor(); +// QList::QList(qsizetype size) +void *c_QList_T_qreal_T___constructor_qsizetype(qsizetype size); +// QList::append(const QList & l) +void c_QList_T_qreal_T___append_QList_T(void *thisObj, void *l_); +// QList::at(qsizetype i) const +const qreal c_QList_T_qreal_T___at_qsizetype(void *thisObj, qsizetype i); +// QList::back() +qreal c_QList_T_qreal_T___back(void *thisObj); +// QList::capacity() const +qsizetype c_QList_T_qreal_T___capacity(void *thisObj); +// QList::clear() +void c_QList_T_qreal_T___clear(void *thisObj); +// QList::constFirst() const +const qreal c_QList_T_qreal_T___constFirst(void *thisObj); +// QList::constLast() const +const qreal c_QList_T_qreal_T___constLast(void *thisObj); +// QList::count() const +qsizetype c_QList_T_qreal_T___count(void *thisObj); +// QList::detach() +void c_QList_T_qreal_T___detach(void *thisObj); +// QList::empty() const +bool c_QList_T_qreal_T___empty(void *thisObj); +// QList::first() +qreal c_QList_T_qreal_T___first(void *thisObj); +// QList::first(qsizetype n) const +void *c_QList_T_qreal_T___first_qsizetype(void *thisObj, qsizetype n); +// QList::front() +qreal c_QList_T_qreal_T___front(void *thisObj); +// QList::isDetached() const +bool c_QList_T_qreal_T___isDetached(void *thisObj); +// QList::isEmpty() const +bool c_QList_T_qreal_T___isEmpty(void *thisObj); +// QList::isSharedWith(const QList & other) const +bool c_QList_T_qreal_T___isSharedWith_QList_T(void *thisObj, void *other_); +// QList::last() +qreal c_QList_T_qreal_T___last(void *thisObj); +// QList::last(qsizetype n) const +void *c_QList_T_qreal_T___last_qsizetype(void *thisObj, qsizetype n); +// QList::length() const +qsizetype c_QList_T_qreal_T___length(void *thisObj); +// QList::mid(qsizetype pos, qsizetype len) const +void *c_QList_T_qreal_T___mid_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype len); +// QList::move(qsizetype from, qsizetype to) +void c_QList_T_qreal_T___move_qsizetype_qsizetype(void *thisObj, qsizetype from, qsizetype to); +// QList::pop_back() +void c_QList_T_qreal_T___pop_back(void *thisObj); +// QList::pop_front() +void c_QList_T_qreal_T___pop_front(void *thisObj); +// QList::remove(qsizetype i, qsizetype n) +void c_QList_T_qreal_T___remove_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype n); +// QList::removeAt(qsizetype i) +void c_QList_T_qreal_T___removeAt_qsizetype(void *thisObj, qsizetype i); +// QList::removeFirst() +void c_QList_T_qreal_T___removeFirst(void *thisObj); +// QList::removeLast() +void c_QList_T_qreal_T___removeLast(void *thisObj); +// QList::reserve(qsizetype size) +void c_QList_T_qreal_T___reserve_qsizetype(void *thisObj, qsizetype size); +// QList::resize(qsizetype size) +void c_QList_T_qreal_T___resize_qsizetype(void *thisObj, qsizetype size); +// QList::shrink_to_fit() +void c_QList_T_qreal_T___shrink_to_fit(void *thisObj); +// QList::size() const +qsizetype c_QList_T_qreal_T___size(void *thisObj); +// QList::sliced(qsizetype pos) const +void *c_QList_T_qreal_T___sliced_qsizetype(void *thisObj, qsizetype pos); +// QList::sliced(qsizetype pos, qsizetype n) const +void *c_QList_T_qreal_T___sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype n); +// QList::squeeze() +void c_QList_T_qreal_T___squeeze(void *thisObj); +// QList::swapItemsAt(qsizetype i, qsizetype j) +void c_QList_T_qreal_T___swapItemsAt_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype j); +// QList::takeAt(qsizetype i) +qreal c_QList_T_qreal_T___takeAt_qsizetype(void *thisObj, qsizetype i); +// QList::toList() const +void *c_QList_T_qreal_T___toList(void *thisObj); +// QList::toVector() const +void *c_QList_T_qreal_T___toVector(void *thisObj); +// QList::value(qsizetype i) const +qreal c_QList_T_qreal_T___value_qsizetype(void *thisObj, qsizetype i); +void c_QList_T_qreal_T___destructor(void *thisObj); +void c_QList_T_qreal_T__Finalizer(void *cppObj); // QList::QList() +void *c_QList_T_int_T___constructor(); +// QList::QList(qsizetype size) +void *c_QList_T_int_T___constructor_qsizetype(qsizetype size); +// QList::append(const QList & l) +void c_QList_T_int_T___append_QList_T(void *thisObj, void *l_); +// QList::at(qsizetype i) const +const int c_QList_T_int_T___at_qsizetype(void *thisObj, qsizetype i); +// QList::back() +int c_QList_T_int_T___back(void *thisObj); +// QList::capacity() const +qsizetype c_QList_T_int_T___capacity(void *thisObj); +// QList::clear() +void c_QList_T_int_T___clear(void *thisObj); +// QList::constFirst() const +const int c_QList_T_int_T___constFirst(void *thisObj); +// QList::constLast() const +const int c_QList_T_int_T___constLast(void *thisObj); +// QList::count() const +qsizetype c_QList_T_int_T___count(void *thisObj); +// QList::detach() +void c_QList_T_int_T___detach(void *thisObj); +// QList::empty() const +bool c_QList_T_int_T___empty(void *thisObj); +// QList::first() +int c_QList_T_int_T___first(void *thisObj); +// QList::first(qsizetype n) const +void *c_QList_T_int_T___first_qsizetype(void *thisObj, qsizetype n); +// QList::front() +int c_QList_T_int_T___front(void *thisObj); +// QList::isDetached() const +bool c_QList_T_int_T___isDetached(void *thisObj); +// QList::isEmpty() const +bool c_QList_T_int_T___isEmpty(void *thisObj); +// QList::isSharedWith(const QList & other) const +bool c_QList_T_int_T___isSharedWith_QList_T(void *thisObj, void *other_); +// QList::last() +int c_QList_T_int_T___last(void *thisObj); +// QList::last(qsizetype n) const +void *c_QList_T_int_T___last_qsizetype(void *thisObj, qsizetype n); +// QList::length() const +qsizetype c_QList_T_int_T___length(void *thisObj); +// QList::mid(qsizetype pos, qsizetype len) const +void *c_QList_T_int_T___mid_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype len); +// QList::move(qsizetype from, qsizetype to) +void c_QList_T_int_T___move_qsizetype_qsizetype(void *thisObj, qsizetype from, qsizetype to); +// QList::pop_back() +void c_QList_T_int_T___pop_back(void *thisObj); +// QList::pop_front() +void c_QList_T_int_T___pop_front(void *thisObj); +// QList::remove(qsizetype i, qsizetype n) +void c_QList_T_int_T___remove_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype n); +// QList::removeAt(qsizetype i) +void c_QList_T_int_T___removeAt_qsizetype(void *thisObj, qsizetype i); +// QList::removeFirst() +void c_QList_T_int_T___removeFirst(void *thisObj); +// QList::removeLast() +void c_QList_T_int_T___removeLast(void *thisObj); +// QList::reserve(qsizetype size) +void c_QList_T_int_T___reserve_qsizetype(void *thisObj, qsizetype size); +// QList::resize(qsizetype size) +void c_QList_T_int_T___resize_qsizetype(void *thisObj, qsizetype size); +// QList::shrink_to_fit() +void c_QList_T_int_T___shrink_to_fit(void *thisObj); +// QList::size() const +qsizetype c_QList_T_int_T___size(void *thisObj); +// QList::sliced(qsizetype pos) const +void *c_QList_T_int_T___sliced_qsizetype(void *thisObj, qsizetype pos); +// QList::sliced(qsizetype pos, qsizetype n) const +void *c_QList_T_int_T___sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype n); +// QList::squeeze() +void c_QList_T_int_T___squeeze(void *thisObj); +// QList::swapItemsAt(qsizetype i, qsizetype j) +void c_QList_T_int_T___swapItemsAt_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype j); +// QList::takeAt(qsizetype i) +int c_QList_T_int_T___takeAt_qsizetype(void *thisObj, qsizetype i); +// QList::toList() const +void *c_QList_T_int_T___toList(void *thisObj); +// QList::toVector() const +void *c_QList_T_int_T___toVector(void *thisObj); +// QList::value(qsizetype i) const +int c_QList_T_int_T___value_qsizetype(void *thisObj, qsizetype i); +void c_QList_T_int_T___destructor(void *thisObj); +void c_QList_T_int_T__Finalizer(void *cppObj); // QList::QList() +void *c_QList_T_QVariant_T___constructor(); +// QList::QList(qsizetype size) +void *c_QList_T_QVariant_T___constructor_qsizetype(qsizetype size); +// QList::append(const QList & l) +void c_QList_T_QVariant_T___append_QList_T(void *thisObj, void *l_); +// QList::at(qsizetype i) const +const void *c_QList_T_QVariant_T___at_qsizetype(void *thisObj, qsizetype i); +// QList::back() +void *c_QList_T_QVariant_T___back(void *thisObj); +// QList::capacity() const +qsizetype c_QList_T_QVariant_T___capacity(void *thisObj); +// QList::clear() +void c_QList_T_QVariant_T___clear(void *thisObj); +// QList::constFirst() const +const void *c_QList_T_QVariant_T___constFirst(void *thisObj); +// QList::constLast() const +const void *c_QList_T_QVariant_T___constLast(void *thisObj); +// QList::count() const +qsizetype c_QList_T_QVariant_T___count(void *thisObj); +// QList::detach() +void c_QList_T_QVariant_T___detach(void *thisObj); +// QList::empty() const +bool c_QList_T_QVariant_T___empty(void *thisObj); +// QList::first() +void *c_QList_T_QVariant_T___first(void *thisObj); +// QList::first(qsizetype n) const +void *c_QList_T_QVariant_T___first_qsizetype(void *thisObj, qsizetype n); +// QList::front() +void *c_QList_T_QVariant_T___front(void *thisObj); +// QList::isDetached() const +bool c_QList_T_QVariant_T___isDetached(void *thisObj); +// QList::isEmpty() const +bool c_QList_T_QVariant_T___isEmpty(void *thisObj); +// QList::isSharedWith(const QList & other) const +bool c_QList_T_QVariant_T___isSharedWith_QList_T(void *thisObj, void *other_); +// QList::last() +void *c_QList_T_QVariant_T___last(void *thisObj); +// QList::last(qsizetype n) const +void *c_QList_T_QVariant_T___last_qsizetype(void *thisObj, qsizetype n); +// QList::length() const +qsizetype c_QList_T_QVariant_T___length(void *thisObj); +// QList::mid(qsizetype pos, qsizetype len) const +void *c_QList_T_QVariant_T___mid_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype len); +// QList::move(qsizetype from, qsizetype to) +void c_QList_T_QVariant_T___move_qsizetype_qsizetype(void *thisObj, qsizetype from, qsizetype to); +// QList::pop_back() +void c_QList_T_QVariant_T___pop_back(void *thisObj); +// QList::pop_front() +void c_QList_T_QVariant_T___pop_front(void *thisObj); +// QList::remove(qsizetype i, qsizetype n) +void c_QList_T_QVariant_T___remove_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype n); +// QList::removeAt(qsizetype i) +void c_QList_T_QVariant_T___removeAt_qsizetype(void *thisObj, qsizetype i); +// QList::removeFirst() +void c_QList_T_QVariant_T___removeFirst(void *thisObj); +// QList::removeLast() +void c_QList_T_QVariant_T___removeLast(void *thisObj); +// QList::reserve(qsizetype size) +void c_QList_T_QVariant_T___reserve_qsizetype(void *thisObj, qsizetype size); +// QList::resize(qsizetype size) +void c_QList_T_QVariant_T___resize_qsizetype(void *thisObj, qsizetype size); +// QList::shrink_to_fit() +void c_QList_T_QVariant_T___shrink_to_fit(void *thisObj); +// QList::size() const +qsizetype c_QList_T_QVariant_T___size(void *thisObj); +// QList::sliced(qsizetype pos) const +void *c_QList_T_QVariant_T___sliced_qsizetype(void *thisObj, qsizetype pos); +// QList::sliced(qsizetype pos, qsizetype n) const +void *c_QList_T_QVariant_T___sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype n); +// QList::squeeze() +void c_QList_T_QVariant_T___squeeze(void *thisObj); +// QList::swapItemsAt(qsizetype i, qsizetype j) +void c_QList_T_QVariant_T___swapItemsAt_qsizetype_qsizetype(void *thisObj, qsizetype i, + qsizetype j); +// QList::takeAt(qsizetype i) +void *c_QList_T_QVariant_T___takeAt_qsizetype(void *thisObj, qsizetype i); +// QList::toList() const +void *c_QList_T_QVariant_T___toList(void *thisObj); +// QList::toVector() const +void *c_QList_T_QVariant_T___toVector(void *thisObj); +// QList::value(qsizetype i) const +void *c_QList_T_QVariant_T___value_qsizetype(void *thisObj, qsizetype i); +void c_QList_T_QVariant_T___destructor(void *thisObj); +void c_QList_T_QVariant_T__Finalizer(void *cppObj); // QList::QList() +void *c_QList_T_QString_T___constructor(); +// QList::QList(qsizetype size) +void *c_QList_T_QString_T___constructor_qsizetype(qsizetype size); +// QList::append(const QList & l) +void c_QList_T_QString_T___append_QList_T(void *thisObj, void *l_); +// QList::at(qsizetype i) const +const void *c_QList_T_QString_T___at_qsizetype(void *thisObj, qsizetype i); +// QList::back() +void *c_QList_T_QString_T___back(void *thisObj); +// QList::capacity() const +qsizetype c_QList_T_QString_T___capacity(void *thisObj); +// QList::clear() +void c_QList_T_QString_T___clear(void *thisObj); +// QList::constFirst() const +const void *c_QList_T_QString_T___constFirst(void *thisObj); +// QList::constLast() const +const void *c_QList_T_QString_T___constLast(void *thisObj); +// QList::count() const +qsizetype c_QList_T_QString_T___count(void *thisObj); +// QList::detach() +void c_QList_T_QString_T___detach(void *thisObj); +// QList::empty() const +bool c_QList_T_QString_T___empty(void *thisObj); +// QList::first() +void *c_QList_T_QString_T___first(void *thisObj); +// QList::first(qsizetype n) const +void *c_QList_T_QString_T___first_qsizetype(void *thisObj, qsizetype n); +// QList::front() +void *c_QList_T_QString_T___front(void *thisObj); +// QList::isDetached() const +bool c_QList_T_QString_T___isDetached(void *thisObj); +// QList::isEmpty() const +bool c_QList_T_QString_T___isEmpty(void *thisObj); +// QList::isSharedWith(const QList & other) const +bool c_QList_T_QString_T___isSharedWith_QList_T(void *thisObj, void *other_); +// QList::last() +void *c_QList_T_QString_T___last(void *thisObj); +// QList::last(qsizetype n) const +void *c_QList_T_QString_T___last_qsizetype(void *thisObj, qsizetype n); +// QList::length() const +qsizetype c_QList_T_QString_T___length(void *thisObj); +// QList::mid(qsizetype pos, qsizetype len) const +void *c_QList_T_QString_T___mid_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype len); +// QList::move(qsizetype from, qsizetype to) +void c_QList_T_QString_T___move_qsizetype_qsizetype(void *thisObj, qsizetype from, qsizetype to); +// QList::pop_back() +void c_QList_T_QString_T___pop_back(void *thisObj); +// QList::pop_front() +void c_QList_T_QString_T___pop_front(void *thisObj); +// QList::remove(qsizetype i, qsizetype n) +void c_QList_T_QString_T___remove_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype n); +// QList::removeAt(qsizetype i) +void c_QList_T_QString_T___removeAt_qsizetype(void *thisObj, qsizetype i); +// QList::removeFirst() +void c_QList_T_QString_T___removeFirst(void *thisObj); +// QList::removeLast() +void c_QList_T_QString_T___removeLast(void *thisObj); +// QList::reserve(qsizetype size) +void c_QList_T_QString_T___reserve_qsizetype(void *thisObj, qsizetype size); +// QList::resize(qsizetype size) +void c_QList_T_QString_T___resize_qsizetype(void *thisObj, qsizetype size); +// QList::shrink_to_fit() +void c_QList_T_QString_T___shrink_to_fit(void *thisObj); +// QList::size() const +qsizetype c_QList_T_QString_T___size(void *thisObj); +// QList::sliced(qsizetype pos) const +void *c_QList_T_QString_T___sliced_qsizetype(void *thisObj, qsizetype pos); +// QList::sliced(qsizetype pos, qsizetype n) const +void *c_QList_T_QString_T___sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype n); +// QList::squeeze() +void c_QList_T_QString_T___squeeze(void *thisObj); +// QList::swapItemsAt(qsizetype i, qsizetype j) +void c_QList_T_QString_T___swapItemsAt_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype j); +// QList::takeAt(qsizetype i) +void *c_QList_T_QString_T___takeAt_qsizetype(void *thisObj, qsizetype i); +// QList::toList() const +void *c_QList_T_QString_T___toList(void *thisObj); +// QList::toVector() const +void *c_QList_T_QString_T___toVector(void *thisObj); +// QList::value(qsizetype i) const +void *c_QList_T_QString_T___value_qsizetype(void *thisObj, qsizetype i); +void c_QList_T_QString_T___destructor(void *thisObj); +void c_QList_T_QString_T__Finalizer(void *cppObj); // QList::QList() +void *c_QList_T_unsigned_int_T___constructor(); +// QList::QList(qsizetype size) +void *c_QList_T_unsigned_int_T___constructor_qsizetype(qsizetype size); +// QList::append(const QList & l) +void c_QList_T_unsigned_int_T___append_QList_T(void *thisObj, void *l_); +// QList::at(qsizetype i) const +const unsigned int c_QList_T_unsigned_int_T___at_qsizetype(void *thisObj, qsizetype i); +// QList::back() +unsigned int c_QList_T_unsigned_int_T___back(void *thisObj); +// QList::capacity() const +qsizetype c_QList_T_unsigned_int_T___capacity(void *thisObj); +// QList::clear() +void c_QList_T_unsigned_int_T___clear(void *thisObj); +// QList::constFirst() const +const unsigned int c_QList_T_unsigned_int_T___constFirst(void *thisObj); +// QList::constLast() const +const unsigned int c_QList_T_unsigned_int_T___constLast(void *thisObj); +// QList::count() const +qsizetype c_QList_T_unsigned_int_T___count(void *thisObj); +// QList::detach() +void c_QList_T_unsigned_int_T___detach(void *thisObj); +// QList::empty() const +bool c_QList_T_unsigned_int_T___empty(void *thisObj); +// QList::first() +unsigned int c_QList_T_unsigned_int_T___first(void *thisObj); +// QList::first(qsizetype n) const +void *c_QList_T_unsigned_int_T___first_qsizetype(void *thisObj, qsizetype n); +// QList::front() +unsigned int c_QList_T_unsigned_int_T___front(void *thisObj); +// QList::isDetached() const +bool c_QList_T_unsigned_int_T___isDetached(void *thisObj); +// QList::isEmpty() const +bool c_QList_T_unsigned_int_T___isEmpty(void *thisObj); +// QList::isSharedWith(const QList & other) const +bool c_QList_T_unsigned_int_T___isSharedWith_QList_T(void *thisObj, void *other_); +// QList::last() +unsigned int c_QList_T_unsigned_int_T___last(void *thisObj); +// QList::last(qsizetype n) const +void *c_QList_T_unsigned_int_T___last_qsizetype(void *thisObj, qsizetype n); +// QList::length() const +qsizetype c_QList_T_unsigned_int_T___length(void *thisObj); +// QList::mid(qsizetype pos, qsizetype len) const +void *c_QList_T_unsigned_int_T___mid_qsizetype_qsizetype(void *thisObj, qsizetype pos, + qsizetype len); +// QList::move(qsizetype from, qsizetype to) +void c_QList_T_unsigned_int_T___move_qsizetype_qsizetype(void *thisObj, qsizetype from, + qsizetype to); +// QList::pop_back() +void c_QList_T_unsigned_int_T___pop_back(void *thisObj); +// QList::pop_front() +void c_QList_T_unsigned_int_T___pop_front(void *thisObj); +// QList::remove(qsizetype i, qsizetype n) +void c_QList_T_unsigned_int_T___remove_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype n); +// QList::removeAt(qsizetype i) +void c_QList_T_unsigned_int_T___removeAt_qsizetype(void *thisObj, qsizetype i); +// QList::removeFirst() +void c_QList_T_unsigned_int_T___removeFirst(void *thisObj); +// QList::removeLast() +void c_QList_T_unsigned_int_T___removeLast(void *thisObj); +// QList::reserve(qsizetype size) +void c_QList_T_unsigned_int_T___reserve_qsizetype(void *thisObj, qsizetype size); +// QList::resize(qsizetype size) +void c_QList_T_unsigned_int_T___resize_qsizetype(void *thisObj, qsizetype size); +// QList::shrink_to_fit() +void c_QList_T_unsigned_int_T___shrink_to_fit(void *thisObj); +// QList::size() const +qsizetype c_QList_T_unsigned_int_T___size(void *thisObj); +// QList::sliced(qsizetype pos) const +void *c_QList_T_unsigned_int_T___sliced_qsizetype(void *thisObj, qsizetype pos); +// QList::sliced(qsizetype pos, qsizetype n) const +void *c_QList_T_unsigned_int_T___sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, + qsizetype n); +// QList::squeeze() +void c_QList_T_unsigned_int_T___squeeze(void *thisObj); +// QList::swapItemsAt(qsizetype i, qsizetype j) +void c_QList_T_unsigned_int_T___swapItemsAt_qsizetype_qsizetype(void *thisObj, qsizetype i, + qsizetype j); +// QList::takeAt(qsizetype i) +unsigned int c_QList_T_unsigned_int_T___takeAt_qsizetype(void *thisObj, qsizetype i); +// QList::toList() const +void *c_QList_T_unsigned_int_T___toList(void *thisObj); +// QList::toVector() const +void *c_QList_T_unsigned_int_T___toVector(void *thisObj); +// QList::value(qsizetype i) const +unsigned int c_QList_T_unsigned_int_T___value_qsizetype(void *thisObj, qsizetype i); +void c_QList_T_unsigned_int_T___destructor(void *thisObj); +void c_QList_T_unsigned_int_T__Finalizer(void *cppObj); // QList::QList() +void *c_QList_T_QObject_T___constructor(); +// QList::QList(qsizetype size) +void *c_QList_T_QObject_T___constructor_qsizetype(qsizetype size); +// QList::append(const QList & l) +void c_QList_T_QObject_T___append_QList_T(void *thisObj, void *l_); +// QList::at(qsizetype i) const +const void *c_QList_T_QObject_T___at_qsizetype(void *thisObj, qsizetype i); +// QList::back() +void *c_QList_T_QObject_T___back(void *thisObj); +// QList::capacity() const +qsizetype c_QList_T_QObject_T___capacity(void *thisObj); +// QList::clear() +void c_QList_T_QObject_T___clear(void *thisObj); +// QList::constFirst() const +const void *c_QList_T_QObject_T___constFirst(void *thisObj); +// QList::constLast() const +const void *c_QList_T_QObject_T___constLast(void *thisObj); +// QList::count() const +qsizetype c_QList_T_QObject_T___count(void *thisObj); +// QList::detach() +void c_QList_T_QObject_T___detach(void *thisObj); +// QList::empty() const +bool c_QList_T_QObject_T___empty(void *thisObj); +// QList::first() +void *c_QList_T_QObject_T___first(void *thisObj); +// QList::first(qsizetype n) const +void *c_QList_T_QObject_T___first_qsizetype(void *thisObj, qsizetype n); +// QList::front() +void *c_QList_T_QObject_T___front(void *thisObj); +// QList::isDetached() const +bool c_QList_T_QObject_T___isDetached(void *thisObj); +// QList::isEmpty() const +bool c_QList_T_QObject_T___isEmpty(void *thisObj); +// QList::isSharedWith(const QList & other) const +bool c_QList_T_QObject_T___isSharedWith_QList_T(void *thisObj, void *other_); +// QList::last() +void *c_QList_T_QObject_T___last(void *thisObj); +// QList::last(qsizetype n) const +void *c_QList_T_QObject_T___last_qsizetype(void *thisObj, qsizetype n); +// QList::length() const +qsizetype c_QList_T_QObject_T___length(void *thisObj); +// QList::mid(qsizetype pos, qsizetype len) const +void *c_QList_T_QObject_T___mid_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype len); +// QList::move(qsizetype from, qsizetype to) +void c_QList_T_QObject_T___move_qsizetype_qsizetype(void *thisObj, qsizetype from, qsizetype to); +// QList::pop_back() +void c_QList_T_QObject_T___pop_back(void *thisObj); +// QList::pop_front() +void c_QList_T_QObject_T___pop_front(void *thisObj); +// QList::remove(qsizetype i, qsizetype n) +void c_QList_T_QObject_T___remove_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype n); +// QList::removeAt(qsizetype i) +void c_QList_T_QObject_T___removeAt_qsizetype(void *thisObj, qsizetype i); +// QList::removeFirst() +void c_QList_T_QObject_T___removeFirst(void *thisObj); +// QList::removeLast() +void c_QList_T_QObject_T___removeLast(void *thisObj); +// QList::reserve(qsizetype size) +void c_QList_T_QObject_T___reserve_qsizetype(void *thisObj, qsizetype size); +// QList::resize(qsizetype size) +void c_QList_T_QObject_T___resize_qsizetype(void *thisObj, qsizetype size); +// QList::shrink_to_fit() +void c_QList_T_QObject_T___shrink_to_fit(void *thisObj); +// QList::size() const +qsizetype c_QList_T_QObject_T___size(void *thisObj); +// QList::sliced(qsizetype pos) const +void *c_QList_T_QObject_T___sliced_qsizetype(void *thisObj, qsizetype pos); +// QList::sliced(qsizetype pos, qsizetype n) const +void *c_QList_T_QObject_T___sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype n); +// QList::squeeze() +void c_QList_T_QObject_T___squeeze(void *thisObj); +// QList::swapItemsAt(qsizetype i, qsizetype j) +void c_QList_T_QObject_T___swapItemsAt_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype j); +// QList::takeAt(qsizetype i) +void *c_QList_T_QObject_T___takeAt_qsizetype(void *thisObj, qsizetype i); +// QList::toList() const +void *c_QList_T_QObject_T___toList(void *thisObj); +// QList::toVector() const +void *c_QList_T_QObject_T___toVector(void *thisObj); +// QList::value(qsizetype i) const +void *c_QList_T_QObject_T___value_qsizetype(void *thisObj, qsizetype i); +void c_QList_T_QObject_T___destructor(void *thisObj); +void c_QList_T_QObject_T__Finalizer(void *cppObj); // QList::QList() +void *c_QList_T_QByteArray_T___constructor(); +// QList::QList(qsizetype size) +void *c_QList_T_QByteArray_T___constructor_qsizetype(qsizetype size); +// QList::append(const QList & l) +void c_QList_T_QByteArray_T___append_QList_T(void *thisObj, void *l_); +// QList::at(qsizetype i) const +const void *c_QList_T_QByteArray_T___at_qsizetype(void *thisObj, qsizetype i); +// QList::back() +void *c_QList_T_QByteArray_T___back(void *thisObj); +// QList::capacity() const +qsizetype c_QList_T_QByteArray_T___capacity(void *thisObj); +// QList::clear() +void c_QList_T_QByteArray_T___clear(void *thisObj); +// QList::constFirst() const +const void *c_QList_T_QByteArray_T___constFirst(void *thisObj); +// QList::constLast() const +const void *c_QList_T_QByteArray_T___constLast(void *thisObj); +// QList::count() const +qsizetype c_QList_T_QByteArray_T___count(void *thisObj); +// QList::detach() +void c_QList_T_QByteArray_T___detach(void *thisObj); +// QList::empty() const +bool c_QList_T_QByteArray_T___empty(void *thisObj); +// QList::first() +void *c_QList_T_QByteArray_T___first(void *thisObj); +// QList::first(qsizetype n) const +void *c_QList_T_QByteArray_T___first_qsizetype(void *thisObj, qsizetype n); +// QList::front() +void *c_QList_T_QByteArray_T___front(void *thisObj); +// QList::isDetached() const +bool c_QList_T_QByteArray_T___isDetached(void *thisObj); +// QList::isEmpty() const +bool c_QList_T_QByteArray_T___isEmpty(void *thisObj); +// QList::isSharedWith(const QList & other) const +bool c_QList_T_QByteArray_T___isSharedWith_QList_T(void *thisObj, void *other_); +// QList::last() +void *c_QList_T_QByteArray_T___last(void *thisObj); +// QList::last(qsizetype n) const +void *c_QList_T_QByteArray_T___last_qsizetype(void *thisObj, qsizetype n); +// QList::length() const +qsizetype c_QList_T_QByteArray_T___length(void *thisObj); +// QList::mid(qsizetype pos, qsizetype len) const +void *c_QList_T_QByteArray_T___mid_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype len); +// QList::move(qsizetype from, qsizetype to) +void c_QList_T_QByteArray_T___move_qsizetype_qsizetype(void *thisObj, qsizetype from, qsizetype to); +// QList::pop_back() +void c_QList_T_QByteArray_T___pop_back(void *thisObj); +// QList::pop_front() +void c_QList_T_QByteArray_T___pop_front(void *thisObj); +// QList::remove(qsizetype i, qsizetype n) +void c_QList_T_QByteArray_T___remove_qsizetype_qsizetype(void *thisObj, qsizetype i, qsizetype n); +// QList::removeAt(qsizetype i) +void c_QList_T_QByteArray_T___removeAt_qsizetype(void *thisObj, qsizetype i); +// QList::removeFirst() +void c_QList_T_QByteArray_T___removeFirst(void *thisObj); +// QList::removeLast() +void c_QList_T_QByteArray_T___removeLast(void *thisObj); +// QList::reserve(qsizetype size) +void c_QList_T_QByteArray_T___reserve_qsizetype(void *thisObj, qsizetype size); +// QList::resize(qsizetype size) +void c_QList_T_QByteArray_T___resize_qsizetype(void *thisObj, qsizetype size); +// QList::shrink_to_fit() +void c_QList_T_QByteArray_T___shrink_to_fit(void *thisObj); +// QList::size() const +qsizetype c_QList_T_QByteArray_T___size(void *thisObj); +// QList::sliced(qsizetype pos) const +void *c_QList_T_QByteArray_T___sliced_qsizetype(void *thisObj, qsizetype pos); +// QList::sliced(qsizetype pos, qsizetype n) const +void *c_QList_T_QByteArray_T___sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, + qsizetype n); +// QList::squeeze() +void c_QList_T_QByteArray_T___squeeze(void *thisObj); +// QList::swapItemsAt(qsizetype i, qsizetype j) +void c_QList_T_QByteArray_T___swapItemsAt_qsizetype_qsizetype(void *thisObj, qsizetype i, + qsizetype j); +// QList::takeAt(qsizetype i) +void *c_QList_T_QByteArray_T___takeAt_qsizetype(void *thisObj, qsizetype i); +// QList::toList() const +void *c_QList_T_QByteArray_T___toList(void *thisObj); +// QList::toVector() const +void *c_QList_T_QByteArray_T___toVector(void *thisObj); +// QList::value(qsizetype i) const +void *c_QList_T_QByteArray_T___value_qsizetype(void *thisObj, qsizetype i); +void c_QList_T_QByteArray_T___destructor(void *thisObj); +void c_QList_T_QByteArray_T__Finalizer(void *cppObj); // QHash::QHash() +void *c_QHash_T_QString_QVariant_T___constructor(); +// QHash::capacity() const +qsizetype c_QHash_T_QString_QVariant_T___capacity(void *thisObj); +// QHash::clear() +void c_QHash_T_QString_QVariant_T___clear(void *thisObj); +// QHash::contains(const Key & key) const +bool c_QHash_T_QString_QVariant_T___contains_QString(void *thisObj, const char *key_); +// QHash::count() const +qsizetype c_QHash_T_QString_QVariant_T___count(void *thisObj); +// QHash::count(const Key & key) const +qsizetype c_QHash_T_QString_QVariant_T___count_QString(void *thisObj, const char *key_); +// QHash::detach() +void c_QHash_T_QString_QVariant_T___detach(void *thisObj); +// QHash::empty() const +bool c_QHash_T_QString_QVariant_T___empty(void *thisObj); +// QHash::insert(const QHash & hash) +void c_QHash_T_QString_QVariant_T___insert_QHash_Key_T(void *thisObj, void *hash_); +// QHash::isDetached() const +bool c_QHash_T_QString_QVariant_T___isDetached(void *thisObj); +// QHash::isEmpty() const +bool c_QHash_T_QString_QVariant_T___isEmpty(void *thisObj); +// QHash::isSharedWith(const QHash & other) const +bool c_QHash_T_QString_QVariant_T___isSharedWith_QHash_Key_T(void *thisObj, void *other_); +// QHash::key(const T & value) const +void *c_QHash_T_QString_QVariant_T___key_QVariant(void *thisObj, void *value_); +// QHash::key(const T & value, const Key & defaultKey) const +void *c_QHash_T_QString_QVariant_T___key_QVariant_QString(void *thisObj, void *value_, + const char *defaultKey_); +// QHash::keys() const +void *c_QHash_T_QString_QVariant_T___keys(void *thisObj); +// QHash::keys(const T & value) const +void *c_QHash_T_QString_QVariant_T___keys_QVariant(void *thisObj, void *value_); +// QHash::load_factor() const +float c_QHash_T_QString_QVariant_T___load_factor(void *thisObj); +// QHash::remove(const Key & key) +bool c_QHash_T_QString_QVariant_T___remove_QString(void *thisObj, const char *key_); +// QHash::reserve(qsizetype size) +void c_QHash_T_QString_QVariant_T___reserve_qsizetype(void *thisObj, qsizetype size); +// QHash::size() const +qsizetype c_QHash_T_QString_QVariant_T___size(void *thisObj); +// QHash::squeeze() +void c_QHash_T_QString_QVariant_T___squeeze(void *thisObj); +// QHash::take(const Key & key) +void *c_QHash_T_QString_QVariant_T___take_QString(void *thisObj, const char *key_); +// QHash::value(const Key & key) const +void *c_QHash_T_QString_QVariant_T___value_QString(void *thisObj, const char *key_); +// QHash::value(const Key & key, const T & defaultValue) const +void *c_QHash_T_QString_QVariant_T___value_QString_QVariant(void *thisObj, const char *key_, + void *defaultValue_); +// QHash::values() const +void *c_QHash_T_QString_QVariant_T___values(void *thisObj); +void c_QHash_T_QString_QVariant_T___destructor(void *thisObj); +void c_QHash_T_QString_QVariant_T__Finalizer(void *cppObj); // QEvent::accept() +void c_QEvent__accept(void *thisObj); +// QEvent::clone() const +void *c_QEvent__clone(void *thisObj); +// QEvent::ignore() +void c_QEvent__ignore(void *thisObj); +// QEvent::isAccepted() const +bool c_QEvent__isAccepted(void *thisObj); +// QEvent::isInputEvent() const +bool c_QEvent__isInputEvent(void *thisObj); +// QEvent::isPointerEvent() const +bool c_QEvent__isPointerEvent(void *thisObj); +// QEvent::isSinglePointEvent() const +bool c_QEvent__isSinglePointEvent(void *thisObj); +// QEvent::registerEventType(int hint) +int c_static_QEvent__registerEventType_int(int hint); +// QEvent::setAccepted(bool accepted) +void c_QEvent__setAccepted_bool(void *thisObj, bool accepted); +// QEvent::spontaneous() const +bool c_QEvent__spontaneous(void *thisObj); +void c_QEvent__destructor(void *thisObj); +void c_QEvent__registerVirtualMethodCallback(void *ptr, void *callback, int methodId); +void c_QEvent_Finalizer(void *cppObj); // QCoreApplication::addLibraryPath(const QString & arg__1) +void c_static_QCoreApplication__addLibraryPath_QString(const char *arg__1_); +// QCoreApplication::applicationDirPath() +void *c_static_QCoreApplication__applicationDirPath(); +// QCoreApplication::applicationFilePath() +void *c_static_QCoreApplication__applicationFilePath(); +// QCoreApplication::applicationName() +void *c_static_QCoreApplication__applicationName(); +// QCoreApplication::applicationNameChanged() +void c_QCoreApplication__applicationNameChanged(void *thisObj); +void c_QCoreApplication__onApplicationNameChanged( + void *thisObj, void *contextQObject, void *callback); // QCoreApplication::applicationPid() +qint64 c_static_QCoreApplication__applicationPid(); +// QCoreApplication::applicationVersion() +void *c_static_QCoreApplication__applicationVersion(); +// QCoreApplication::applicationVersionChanged() +void c_QCoreApplication__applicationVersionChanged(void *thisObj); +void c_QCoreApplication__onApplicationVersionChanged( + void *thisObj, void *contextQObject, void *callback); // QCoreApplication::arguments() +void *c_static_QCoreApplication__arguments(); +// QCoreApplication::closingDown() +bool c_static_QCoreApplication__closingDown(); +// QCoreApplication::customEvent(QEvent * event) +void c_QCoreApplication__customEvent_QEvent(void *thisObj, void *event_); +// QCoreApplication::event(QEvent * arg__1) +bool c_QCoreApplication__event_QEvent(void *thisObj, void *arg__1_); +// QCoreApplication::eventFilter(QObject * watched, QEvent * event) +bool c_QCoreApplication__eventFilter_QObject_QEvent(void *thisObj, void *watched_, void *event_); +// QCoreApplication::exec() +int c_static_QCoreApplication__exec(); +// QCoreApplication::exit(int retcode) +void c_static_QCoreApplication__exit_int(int retcode); +// QCoreApplication::instance() +void *c_static_QCoreApplication__instance(); +// QCoreApplication::isQuitLockEnabled() +bool c_static_QCoreApplication__isQuitLockEnabled(); +// QCoreApplication::isSetuidAllowed() +bool c_static_QCoreApplication__isSetuidAllowed(); +// QCoreApplication::libraryPaths() +void *c_static_QCoreApplication__libraryPaths(); +// QCoreApplication::notify(QObject * arg__1, QEvent * arg__2) +bool c_QCoreApplication__notify_QObject_QEvent(void *thisObj, void *arg__1_, void *arg__2_); +// QCoreApplication::organizationDomain() +void *c_static_QCoreApplication__organizationDomain(); +// QCoreApplication::organizationDomainChanged() +void c_QCoreApplication__organizationDomainChanged(void *thisObj); +void c_QCoreApplication__onOrganizationDomainChanged( + void *thisObj, void *contextQObject, void *callback); // QCoreApplication::organizationName() +void *c_static_QCoreApplication__organizationName(); +// QCoreApplication::organizationNameChanged() +void c_QCoreApplication__organizationNameChanged(void *thisObj); +void c_QCoreApplication__onOrganizationNameChanged(void *thisObj, void *contextQObject, + void *callback); // QCoreApplication::postEvent(QObject + // * receiver, QEvent * event, + // int priority) +void c_static_QCoreApplication__postEvent_QObject_QEvent_int(void *receiver_, void *event_, + int priority); +// QCoreApplication::processEvents() +void c_static_QCoreApplication__processEvents(); +// QCoreApplication::quit() +void c_static_QCoreApplication__quit(); +// QCoreApplication::removeLibraryPath(const QString & arg__1) +void c_static_QCoreApplication__removeLibraryPath_QString(const char *arg__1_); +// QCoreApplication::removePostedEvents(QObject * receiver, int eventType) +void c_static_QCoreApplication__removePostedEvents_QObject_int(void *receiver_, int eventType); +// QCoreApplication::sendEvent(QObject * receiver, QEvent * event) +bool c_static_QCoreApplication__sendEvent_QObject_QEvent(void *receiver_, void *event_); +// QCoreApplication::sendPostedEvents(QObject * receiver, int event_type) +void c_static_QCoreApplication__sendPostedEvents_QObject_int(void *receiver_, int event_type); +// QCoreApplication::setApplicationName(const QString & application) +void c_static_QCoreApplication__setApplicationName_QString(const char *application_); +// QCoreApplication::setApplicationVersion(const QString & version) +void c_static_QCoreApplication__setApplicationVersion_QString(const char *version_); +// QCoreApplication::setLibraryPaths(const QList & arg__1) +void c_static_QCoreApplication__setLibraryPaths_QList_QString(void *arg__1_); +// QCoreApplication::setOrganizationDomain(const QString & orgDomain) +void c_static_QCoreApplication__setOrganizationDomain_QString(const char *orgDomain_); +// QCoreApplication::setOrganizationName(const QString & orgName) +void c_static_QCoreApplication__setOrganizationName_QString(const char *orgName_); +// QCoreApplication::setQuitLockEnabled(bool enabled) +void c_static_QCoreApplication__setQuitLockEnabled_bool(bool enabled); +// QCoreApplication::setSetuidAllowed(bool allow) +void c_static_QCoreApplication__setSetuidAllowed_bool(bool allow); +// QCoreApplication::startingUp() +bool c_static_QCoreApplication__startingUp(); +// QCoreApplication::tr(const char * s, const char * c, int n) +void *c_static_QCoreApplication__tr_char_char_int(const char *s, const char *c, int n); +// QCoreApplication::translate(const char * context, const char * key, const char * disambiguation, +// int n) +void *c_static_QCoreApplication__translate_char_char_char_int(const char *context, const char *key, + const char *disambiguation, int n); +void c_QCoreApplication__destructor(void *thisObj); +void c_QCoreApplication__registerVirtualMethodCallback(void *ptr, void *callback, int methodId); +void c_QCoreApplication_Finalizer(void *cppObj); // QGuiApplication::applicationDisplayName() +void *c_static_QGuiApplication__applicationDisplayName(); +// QGuiApplication::applicationDisplayNameChanged() +void c_QGuiApplication__applicationDisplayNameChanged(void *thisObj); +void c_QGuiApplication__onApplicationDisplayNameChanged(void *thisObj, void *contextQObject, + void *callback); // QGuiApplication::customEvent(QEvent + // * event) +void c_QGuiApplication__customEvent_QEvent(void *thisObj, void *event_); +// QGuiApplication::desktopFileName() +void *c_static_QGuiApplication__desktopFileName(); +// QGuiApplication::desktopSettingsAware() +bool c_static_QGuiApplication__desktopSettingsAware(); +// QGuiApplication::devicePixelRatio() const +qreal c_QGuiApplication__devicePixelRatio(void *thisObj); +// QGuiApplication::event(QEvent * arg__1) +bool c_QGuiApplication__event_QEvent(void *thisObj, void *arg__1_); +// QGuiApplication::eventFilter(QObject * watched, QEvent * event) +bool c_QGuiApplication__eventFilter_QObject_QEvent(void *thisObj, void *watched_, void *event_); +// QGuiApplication::exec() +int c_static_QGuiApplication__exec(); +// QGuiApplication::focusObject() +void *c_static_QGuiApplication__focusObject(); +// QGuiApplication::focusObjectChanged(QObject * focusObject) +void c_QGuiApplication__focusObjectChanged_QObject(void *thisObj, void *focusObject_); +void c_QGuiApplication__onFocusObjectChanged_QObject( + void *thisObj, void *contextQObject, void *callback); // QGuiApplication::fontDatabaseChanged() +void c_QGuiApplication__fontDatabaseChanged(void *thisObj); +void c_QGuiApplication__onFontDatabaseChanged(void *thisObj, void *contextQObject, + void *callback); // QGuiApplication::isLeftToRight() +bool c_static_QGuiApplication__isLeftToRight(); +// QGuiApplication::isRightToLeft() +bool c_static_QGuiApplication__isRightToLeft(); +// QGuiApplication::isSavingSession() const +bool c_QGuiApplication__isSavingSession(void *thisObj); +// QGuiApplication::isSessionRestored() const +bool c_QGuiApplication__isSessionRestored(void *thisObj); +// QGuiApplication::lastWindowClosed() +void c_QGuiApplication__lastWindowClosed(void *thisObj); +void c_QGuiApplication__onLastWindowClosed(void *thisObj, void *contextQObject, + void *callback); // QGuiApplication::notify(QObject * + // arg__1, QEvent * arg__2) +bool c_QGuiApplication__notify_QObject_QEvent(void *thisObj, void *arg__1_, void *arg__2_); +// QGuiApplication::platformName() +void *c_static_QGuiApplication__platformName(); +// QGuiApplication::quitOnLastWindowClosed() +bool c_static_QGuiApplication__quitOnLastWindowClosed(); +// QGuiApplication::restoreOverrideCursor() +void c_static_QGuiApplication__restoreOverrideCursor(); +// QGuiApplication::sessionId() const +void *c_QGuiApplication__sessionId(void *thisObj); +// QGuiApplication::sessionKey() const +void *c_QGuiApplication__sessionKey(void *thisObj); +// QGuiApplication::setApplicationDisplayName(const QString & name) +void c_static_QGuiApplication__setApplicationDisplayName_QString(const char *name_); +// QGuiApplication::setDesktopFileName(const QString & name) +void c_static_QGuiApplication__setDesktopFileName_QString(const char *name_); +// QGuiApplication::setDesktopSettingsAware(bool on) +void c_static_QGuiApplication__setDesktopSettingsAware_bool(bool on); +// QGuiApplication::setQuitOnLastWindowClosed(bool quit) +void c_static_QGuiApplication__setQuitOnLastWindowClosed_bool(bool quit); +// QGuiApplication::sync() +void c_static_QGuiApplication__sync(); +// QGuiApplication::tr(const char * s, const char * c, int n) +void *c_static_QGuiApplication__tr_char_char_int(const char *s, const char *c, int n); +void c_QGuiApplication__destructor(void *thisObj); +void c_QGuiApplication__registerVirtualMethodCallback(void *ptr, void *callback, int methodId); +void c_QGuiApplication_Finalizer(void *cppObj); // QColor::QColor() +void *c_QColor__constructor(); +// QColor::QColor(const QString & name) +void *c_QColor__constructor_QString(const char *name_); +// QColor::QColor(const char * aname) +void *c_QColor__constructor_char(const char *aname); +// QColor::QColor(int r, int g, int b, int a) +void *c_QColor__constructor_int_int_int_int(int r, int g, int b, int a); +// QColor::alpha() const +int c_QColor__alpha(void *thisObj); +// QColor::alphaF() const +float c_QColor__alphaF(void *thisObj); +// QColor::black() const +int c_QColor__black(void *thisObj); +// QColor::blackF() const +float c_QColor__blackF(void *thisObj); +// QColor::blue() const +int c_QColor__blue(void *thisObj); +// QColor::blueF() const +float c_QColor__blueF(void *thisObj); +// QColor::colorNames() +void *c_static_QColor__colorNames(); +// QColor::cyan() const +int c_QColor__cyan(void *thisObj); +// QColor::cyanF() const +float c_QColor__cyanF(void *thisObj); +// QColor::darker(int f) const +void *c_QColor__darker_int(void *thisObj, int f); +// QColor::fromCmyk(int c, int m, int y, int k, int a) +void *c_static_QColor__fromCmyk_int_int_int_int_int(int c, int m, int y, int k, int a); +// QColor::fromCmykF(float c, float m, float y, float k, float a) +void *c_static_QColor__fromCmykF_float_float_float_float_float(float c, float m, float y, float k, + float a); +// QColor::fromHsl(int h, int s, int l, int a) +void *c_static_QColor__fromHsl_int_int_int_int(int h, int s, int l, int a); +// QColor::fromHslF(float h, float s, float l, float a) +void *c_static_QColor__fromHslF_float_float_float_float(float h, float s, float l, float a); +// QColor::fromHsv(int h, int s, int v, int a) +void *c_static_QColor__fromHsv_int_int_int_int(int h, int s, int v, int a); +// QColor::fromHsvF(float h, float s, float v, float a) +void *c_static_QColor__fromHsvF_float_float_float_float(float h, float s, float v, float a); +// QColor::fromRgb(int r, int g, int b, int a) +void *c_static_QColor__fromRgb_int_int_int_int(int r, int g, int b, int a); +// QColor::fromRgbF(float r, float g, float b, float a) +void *c_static_QColor__fromRgbF_float_float_float_float(float r, float g, float b, float a); +// QColor::green() const +int c_QColor__green(void *thisObj); +// QColor::greenF() const +float c_QColor__greenF(void *thisObj); +// QColor::hslHue() const +int c_QColor__hslHue(void *thisObj); +// QColor::hslHueF() const +float c_QColor__hslHueF(void *thisObj); +// QColor::hslSaturation() const +int c_QColor__hslSaturation(void *thisObj); +// QColor::hslSaturationF() const +float c_QColor__hslSaturationF(void *thisObj); +// QColor::hsvHue() const +int c_QColor__hsvHue(void *thisObj); +// QColor::hsvHueF() const +float c_QColor__hsvHueF(void *thisObj); +// QColor::hsvSaturation() const +int c_QColor__hsvSaturation(void *thisObj); +// QColor::hsvSaturationF() const +float c_QColor__hsvSaturationF(void *thisObj); +// QColor::hue() const +int c_QColor__hue(void *thisObj); +// QColor::hueF() const +float c_QColor__hueF(void *thisObj); +// QColor::isValid() const +bool c_QColor__isValid(void *thisObj); +// QColor::isValidColor(const QString & name) +bool c_static_QColor__isValidColor_QString(const char *name_); +// QColor::lighter(int f) const +void *c_QColor__lighter_int(void *thisObj, int f); +// QColor::lightness() const +int c_QColor__lightness(void *thisObj); +// QColor::lightnessF() const +float c_QColor__lightnessF(void *thisObj); +// QColor::magenta() const +int c_QColor__magenta(void *thisObj); +// QColor::magentaF() const +float c_QColor__magentaF(void *thisObj); +// QColor::name() const +void *c_QColor__name(void *thisObj); +// QColor::red() const +int c_QColor__red(void *thisObj); +// QColor::redF() const +float c_QColor__redF(void *thisObj); +// QColor::saturation() const +int c_QColor__saturation(void *thisObj); +// QColor::saturationF() const +float c_QColor__saturationF(void *thisObj); +// QColor::setAlpha(int alpha) +void c_QColor__setAlpha_int(void *thisObj, int alpha); +// QColor::setAlphaF(float alpha) +void c_QColor__setAlphaF_float(void *thisObj, float alpha); +// QColor::setBlue(int blue) +void c_QColor__setBlue_int(void *thisObj, int blue); +// QColor::setBlueF(float blue) +void c_QColor__setBlueF_float(void *thisObj, float blue); +// QColor::setCmyk(int c, int m, int y, int k, int a) +void c_QColor__setCmyk_int_int_int_int_int(void *thisObj, int c, int m, int y, int k, int a); +// QColor::setCmykF(float c, float m, float y, float k, float a) +void c_QColor__setCmykF_float_float_float_float_float(void *thisObj, float c, float m, float y, + float k, float a); +// QColor::setGreen(int green) +void c_QColor__setGreen_int(void *thisObj, int green); +// QColor::setGreenF(float green) +void c_QColor__setGreenF_float(void *thisObj, float green); +// QColor::setHsl(int h, int s, int l, int a) +void c_QColor__setHsl_int_int_int_int(void *thisObj, int h, int s, int l, int a); +// QColor::setHslF(float h, float s, float l, float a) +void c_QColor__setHslF_float_float_float_float(void *thisObj, float h, float s, float l, float a); +// QColor::setHsv(int h, int s, int v, int a) +void c_QColor__setHsv_int_int_int_int(void *thisObj, int h, int s, int v, int a); +// QColor::setHsvF(float h, float s, float v, float a) +void c_QColor__setHsvF_float_float_float_float(void *thisObj, float h, float s, float v, float a); +// QColor::setNamedColor(const QString & name) +void c_QColor__setNamedColor_QString(void *thisObj, const char *name_); +// QColor::setRed(int red) +void c_QColor__setRed_int(void *thisObj, int red); +// QColor::setRedF(float red) +void c_QColor__setRedF_float(void *thisObj, float red); +// QColor::setRgb(int r, int g, int b, int a) +void c_QColor__setRgb_int_int_int_int(void *thisObj, int r, int g, int b, int a); +// QColor::setRgbF(float r, float g, float b, float a) +void c_QColor__setRgbF_float_float_float_float(void *thisObj, float r, float g, float b, float a); +// QColor::toCmyk() const +void *c_QColor__toCmyk(void *thisObj); +// QColor::toExtendedRgb() const +void *c_QColor__toExtendedRgb(void *thisObj); +// QColor::toHsl() const +void *c_QColor__toHsl(void *thisObj); +// QColor::toHsv() const +void *c_QColor__toHsv(void *thisObj); +// QColor::toRgb() const +void *c_QColor__toRgb(void *thisObj); +// QColor::value() const +int c_QColor__value(void *thisObj); +// QColor::valueF() const +float c_QColor__valueF(void *thisObj); +// QColor::yellow() const +int c_QColor__yellow(void *thisObj); +// QColor::yellowF() const +float c_QColor__yellowF(void *thisObj); +void c_QColor__destructor(void *thisObj); +void c_QColor_Finalizer(void *cppObj); // QByteArray::QByteArray() +void *c_QByteArray__constructor(); +// QByteArray::QByteArray(const char * arg__1, qsizetype size) +void *c_QByteArray__constructor_char_qsizetype(const char *arg__1, qsizetype size); +// QByteArray::append(const QByteArray & a) +void *c_QByteArray__append_QByteArray(void *thisObj, void *a_); +// QByteArray::append(const char * s) +void *c_QByteArray__append_char(void *thisObj, const char *s); +// QByteArray::append(const char * s, qsizetype len) +void *c_QByteArray__append_char_qsizetype(void *thisObj, const char *s, qsizetype len); +// QByteArray::at(qsizetype i) const +char c_QByteArray__at_qsizetype(void *thisObj, qsizetype i); +// QByteArray::back() const +char c_QByteArray__back(void *thisObj); +// QByteArray::begin() const +const char *c_QByteArray__begin(void *thisObj); +// QByteArray::capacity() const +qsizetype c_QByteArray__capacity(void *thisObj); +// QByteArray::cbegin() const +const char *c_QByteArray__cbegin(void *thisObj); +// QByteArray::cend() const +const char *c_QByteArray__cend(void *thisObj); +// QByteArray::chop(qsizetype n) +void c_QByteArray__chop_qsizetype(void *thisObj, qsizetype n); +// QByteArray::chopped(qsizetype len) const +void *c_QByteArray__chopped_qsizetype(void *thisObj, qsizetype len); +// QByteArray::clear() +void c_QByteArray__clear(void *thisObj); +// QByteArray::constBegin() const +const char *c_QByteArray__constBegin(void *thisObj); +// QByteArray::constData() const +const char *c_QByteArray__constData(void *thisObj); +// QByteArray::constEnd() const +const char *c_QByteArray__constEnd(void *thisObj); +// QByteArray::count() const +qsizetype c_QByteArray__count(void *thisObj); +// QByteArray::data() const +const char *c_QByteArray__data(void *thisObj); +// QByteArray::detach() +void c_QByteArray__detach(void *thisObj); +// QByteArray::end() const +const char *c_QByteArray__end(void *thisObj); +// QByteArray::first(qsizetype n) const +void *c_QByteArray__first_qsizetype(void *thisObj, qsizetype n); +// QByteArray::fromBase64(const QByteArray & base64) +void *c_static_QByteArray__fromBase64_QByteArray(void *base64_); +// QByteArray::fromHex(const QByteArray & hexEncoded) +void *c_static_QByteArray__fromHex_QByteArray(void *hexEncoded_); +// QByteArray::fromRawData(const char * data, qsizetype size) +void *c_static_QByteArray__fromRawData_char_qsizetype(const char *data, qsizetype size); +// QByteArray::front() const +char c_QByteArray__front(void *thisObj); +// QByteArray::insert(qsizetype i, const QByteArray & data) +void *c_QByteArray__insert_qsizetype_QByteArray(void *thisObj, qsizetype i, void *data_); +// QByteArray::insert(qsizetype i, const char * s) +void *c_QByteArray__insert_qsizetype_char(void *thisObj, qsizetype i, const char *s); +// QByteArray::insert(qsizetype i, const char * s, qsizetype len) +void *c_QByteArray__insert_qsizetype_char_qsizetype(void *thisObj, qsizetype i, const char *s, + qsizetype len); +// QByteArray::isDetached() const +bool c_QByteArray__isDetached(void *thisObj); +// QByteArray::isEmpty() const +bool c_QByteArray__isEmpty(void *thisObj); +// QByteArray::isLower() const +bool c_QByteArray__isLower(void *thisObj); +// QByteArray::isNull() const +bool c_QByteArray__isNull(void *thisObj); +// QByteArray::isSharedWith(const QByteArray & other) const +bool c_QByteArray__isSharedWith_QByteArray(void *thisObj, void *other_); +// QByteArray::isUpper() const +bool c_QByteArray__isUpper(void *thisObj); +// QByteArray::isValidUtf8() const +bool c_QByteArray__isValidUtf8(void *thisObj); +// QByteArray::last(qsizetype n) const +void *c_QByteArray__last_qsizetype(void *thisObj, qsizetype n); +// QByteArray::left(qsizetype len) const +void *c_QByteArray__left_qsizetype(void *thisObj, qsizetype len); +// QByteArray::length() const +qsizetype c_QByteArray__length(void *thisObj); +// QByteArray::mid(qsizetype index, qsizetype len) const +void *c_QByteArray__mid_qsizetype_qsizetype(void *thisObj, qsizetype index, qsizetype len); +// QByteArray::number(int arg__1, int base) +void *c_static_QByteArray__number_int_int(int arg__1, int base); +// QByteArray::number(long arg__1, int base) +void *c_static_QByteArray__number_long_int(long arg__1, int base); +// QByteArray::number(qint64 arg__1, int base) +void *c_static_QByteArray__number_qint64_int(qint64 arg__1, int base); +// QByteArray::prepend(const QByteArray & a) +void *c_QByteArray__prepend_QByteArray(void *thisObj, void *a_); +// QByteArray::prepend(const char * s) +void *c_QByteArray__prepend_char(void *thisObj, const char *s); +// QByteArray::prepend(const char * s, qsizetype len) +void *c_QByteArray__prepend_char_qsizetype(void *thisObj, const char *s, qsizetype len); +// QByteArray::push_back(const QByteArray & a) +void c_QByteArray__push_back_QByteArray(void *thisObj, void *a_); +// QByteArray::push_back(const char * s) +void c_QByteArray__push_back_char(void *thisObj, const char *s); +// QByteArray::push_front(const QByteArray & a) +void c_QByteArray__push_front_QByteArray(void *thisObj, void *a_); +// QByteArray::push_front(const char * c) +void c_QByteArray__push_front_char(void *thisObj, const char *c); +// QByteArray::remove(qsizetype index, qsizetype len) +void *c_QByteArray__remove_qsizetype_qsizetype(void *thisObj, qsizetype index, qsizetype len); +// QByteArray::repeated(qsizetype times) const +void *c_QByteArray__repeated_qsizetype(void *thisObj, qsizetype times); +// QByteArray::replace(const char * before, qsizetype bsize, const char * after, qsizetype asize) +void *c_QByteArray__replace_char_qsizetype_char_qsizetype(void *thisObj, const char *before, + qsizetype bsize, const char *after, + qsizetype asize); +// QByteArray::replace(qsizetype index, qsizetype len, const char * s, qsizetype alen) +void *c_QByteArray__replace_qsizetype_qsizetype_char_qsizetype(void *thisObj, qsizetype index, + qsizetype len, const char *s, + qsizetype alen); +// QByteArray::reserve(qsizetype size) +void c_QByteArray__reserve_qsizetype(void *thisObj, qsizetype size); +// QByteArray::resize(qsizetype size) +void c_QByteArray__resize_qsizetype(void *thisObj, qsizetype size); +// QByteArray::right(qsizetype len) const +void *c_QByteArray__right_qsizetype(void *thisObj, qsizetype len); +// QByteArray::setNum(int arg__1, int base) +void *c_QByteArray__setNum_int_int(void *thisObj, int arg__1, int base); +// QByteArray::setNum(long arg__1, int base) +void *c_QByteArray__setNum_long_int(void *thisObj, long arg__1, int base); +// QByteArray::setNum(qint64 arg__1, int base) +void *c_QByteArray__setNum_qint64_int(void *thisObj, qint64 arg__1, int base); +// QByteArray::setNum(short arg__1, int base) +void *c_QByteArray__setNum_short_int(void *thisObj, short arg__1, int base); +// QByteArray::setRawData(const char * a, qsizetype n) +void *c_QByteArray__setRawData_char_qsizetype(void *thisObj, const char *a, qsizetype n); +// QByteArray::shrink_to_fit() +void c_QByteArray__shrink_to_fit(void *thisObj); +// QByteArray::simplified() +void *c_QByteArray__simplified(void *thisObj); +// QByteArray::size() const +qsizetype c_QByteArray__size(void *thisObj); +// QByteArray::sliced(qsizetype pos) const +void *c_QByteArray__sliced_qsizetype(void *thisObj, qsizetype pos); +// QByteArray::sliced(qsizetype pos, qsizetype n) const +void *c_QByteArray__sliced_qsizetype_qsizetype(void *thisObj, qsizetype pos, qsizetype n); +// QByteArray::squeeze() +void c_QByteArray__squeeze(void *thisObj); +// QByteArray::toBase64() const +void *c_QByteArray__toBase64(void *thisObj); +// QByteArray::toLower() +void *c_QByteArray__toLower(void *thisObj); +// QByteArray::toUpper() +void *c_QByteArray__toUpper(void *thisObj); +// QByteArray::trimmed() +void *c_QByteArray__trimmed(void *thisObj); +// QByteArray::truncate(qsizetype pos) +void c_QByteArray__truncate_qsizetype(void *thisObj, qsizetype pos); +void c_QByteArray__destructor(void *thisObj); +void c_QByteArray_Finalizer(void *cppObj); // QApplication::aboutQt() +void c_static_QApplication__aboutQt(); +// QApplication::autoSipEnabled() const +bool c_QApplication__autoSipEnabled(void *thisObj); +// QApplication::beep() +void c_static_QApplication__beep(); +// QApplication::closeAllWindows() +void c_static_QApplication__closeAllWindows(); +// QApplication::cursorFlashTime() +int c_static_QApplication__cursorFlashTime(); +// QApplication::customEvent(QEvent * event) +void c_QApplication__customEvent_QEvent(void *thisObj, void *event_); +// QApplication::doubleClickInterval() +int c_static_QApplication__doubleClickInterval(); +// QApplication::event(QEvent * arg__1) +bool c_QApplication__event_QEvent(void *thisObj, void *arg__1_); +// QApplication::eventFilter(QObject * watched, QEvent * event) +bool c_QApplication__eventFilter_QObject_QEvent(void *thisObj, void *watched_, void *event_); +// QApplication::exec() +int c_static_QApplication__exec(); +// QApplication::keyboardInputInterval() +int c_static_QApplication__keyboardInputInterval(); +// QApplication::notify(QObject * arg__1, QEvent * arg__2) +bool c_QApplication__notify_QObject_QEvent(void *thisObj, void *arg__1_, void *arg__2_); +// QApplication::setAutoSipEnabled(const bool enabled) +void c_QApplication__setAutoSipEnabled_bool(void *thisObj, bool enabled); +// QApplication::setCursorFlashTime(int arg__1) +void c_static_QApplication__setCursorFlashTime_int(int arg__1); +// QApplication::setDoubleClickInterval(int arg__1) +void c_static_QApplication__setDoubleClickInterval_int(int arg__1); +// QApplication::setKeyboardInputInterval(int arg__1) +void c_static_QApplication__setKeyboardInputInterval_int(int arg__1); +// QApplication::setStartDragDistance(int l) +void c_static_QApplication__setStartDragDistance_int(int l); +// QApplication::setStartDragTime(int ms) +void c_static_QApplication__setStartDragTime_int(int ms); +// QApplication::setStyleSheet(const QString & sheet) +void c_QApplication__setStyleSheet_QString(void *thisObj, const char *sheet_); +// QApplication::setWheelScrollLines(int arg__1) +void c_static_QApplication__setWheelScrollLines_int(int arg__1); +// QApplication::startDragDistance() +int c_static_QApplication__startDragDistance(); +// QApplication::startDragTime() +int c_static_QApplication__startDragTime(); +// QApplication::styleSheet() const +void *c_QApplication__styleSheet(void *thisObj); +// QApplication::tr(const char * s, const char * c, int n) +void *c_static_QApplication__tr_char_char_int(const char *s, const char *c, int n); +// QApplication::wheelScrollLines() +int c_static_QApplication__wheelScrollLines(); +void c_QApplication__destructor(void *thisObj); +void c_QApplication__registerVirtualMethodCallback(void *ptr, void *callback, int methodId); +void c_QApplication_Finalizer(void *cppObj); // PureAbstractWithUnknownType::getValue() const +int c_PureAbstractWithUnknownType__getValue(void *thisObj); +void c_PureAbstractWithUnknownType__destructor(void *thisObj); +void c_PureAbstractWithUnknownType_Finalizer(void *cppObj); // NonCopiable::NonCopiable() +void *c_NonCopiable__constructor(); +// NonCopiable::count() const +int c_NonCopiable__count(void *thisObj); +void c_NonCopiable__destructor(void *thisObj); +void c_NonCopiable_Finalizer(void *cppObj); +void c_NameClashingNS2_Finalizer(void *cppObj); // NameClashingNS2::SimpleClash::SimpleClash(int + // arg__1) +void *c_NameClashingNS2__SimpleClash__constructor_int(int arg__1); +// NameClashingNS2::SimpleClash::getFoo() +int c_NameClashingNS2__SimpleClash__getFoo(void *thisObj); +// NameClashingNS2::SimpleClash::getValueStatic() +int c_static_NameClashingNS2__SimpleClash__getValueStatic(); +// NameClashingNS2::SimpleClash::returnsAndReceivesFromOtherScope(NameClashingNS1::SimpleClash s) +void *c_static_NameClashingNS2__SimpleClash__returnsAndReceivesFromOtherScope_SimpleClash(void *s_); +// NameClashingNS2::SimpleClash::returnsFromOtherScope() +void *c_static_NameClashingNS2__SimpleClash__returnsFromOtherScope(); +void c_NameClashingNS2__SimpleClash__destructor(void *thisObj); +void c_NameClashingNS2__SimpleClash_Finalizer(void *cppObj); +void c_NameClashingNS1_Finalizer(void *cppObj); // NameClashingNS1::SimpleClash::SimpleClash(int + // arg__1) +void *c_NameClashingNS1__SimpleClash__constructor_int(int arg__1); +// NameClashingNS1::SimpleClash::getValue() +int c_NameClashingNS1__SimpleClash__getValue(void *thisObj); +// NameClashingNS1::SimpleClash::getValueStatic() +int c_static_NameClashingNS1__SimpleClash__getValueStatic(); +void c_NameClashingNS1__SimpleClash__destructor(void *thisObj); +void c_NameClashingNS1__SimpleClash_Finalizer(void *cppObj); // MyTemplateWithTwoArgs::MyTemplateWithTwoArgs() +void *c_MyTemplateWithTwoArgs_T_int_double_T___constructor(); +// MyTemplateWithTwoArgs::returnInt() const +int c_MyTemplateWithTwoArgs_T_int_double_T___returnInt(void *thisObj); +void c_MyTemplateWithTwoArgs_T_int_double_T___destructor(void *thisObj); +void c_MyTemplateWithTwoArgs_T_int_double_T__Finalizer(void *cppObj); // MyTemplate2::MyTemplate2() +void *c_MyTemplate2_T_NonCopiable_T___constructor(); +// MyTemplate2::assignsT() +void c_MyTemplate2_T_NonCopiable_T___assignsT(void *thisObj); +// MyTemplate2::count() const +int c_MyTemplate2_T_NonCopiable_T___count(void *thisObj); +// MyTemplate2::receivesT(T arg__1) +void c_MyTemplate2_T_NonCopiable_T___receivesT_NonCopiable(void *thisObj, void *arg__1_); +// MyTemplate2::returnTemplate1() +void *c_MyTemplate2_T_NonCopiable_T___returnTemplate1(void *thisObj); +void c_MyTemplate2_T_NonCopiable_T___destructor(void *thisObj); +void c_MyTemplate2_T_NonCopiable_T__Finalizer(void *cppObj); // MyTemplate::MyTemplate() +void *c_MyTemplate_T_int_T___constructor(); +// MyTemplate::receivesT(T arg__1) +int c_MyTemplate_T_int_T___receivesT_int(void *thisObj, int arg__1); +// MyTemplate::receivesTemplate(MyTemplate arg__1) +int c_MyTemplate_T_int_T___receivesTemplate_MyTemplate_T(void *thisObj, void *arg__1_); +// MyTemplate::returnInt() const +int c_MyTemplate_T_int_T___returnInt(void *thisObj); +// MyTemplate::returnTemplate2() +void *c_MyTemplate_T_int_T___returnTemplate2(void *thisObj); +// MyTemplate::returnTemplate3() +void *c_MyTemplate_T_int_T___returnTemplate3(void *thisObj); +// MyTemplate::returnTemplate4() +void *c_MyTemplate_T_int_T___returnTemplate4(void *thisObj); +// MyTemplate::returnsT() +int c_MyTemplate_T_int_T___returnsT(void *thisObj); +// MyTemplate::returnsTemplate() +void *c_MyTemplate_T_int_T___returnsTemplate(void *thisObj); +void c_MyTemplate_T_int_T___destructor(void *thisObj); +void c_MyTemplate_T_int_T__Finalizer(void *cppObj); // MyTemplate::MyTemplate() +void *c_MyTemplate_T_double_T___constructor(); +// MyTemplate::receivesT(T arg__1) +int c_MyTemplate_T_double_T___receivesT_double(void *thisObj, double arg__1); +// MyTemplate::receivesTemplate(MyTemplate arg__1) +int c_MyTemplate_T_double_T___receivesTemplate_MyTemplate_T(void *thisObj, void *arg__1_); +// MyTemplate::returnInt() const +int c_MyTemplate_T_double_T___returnInt(void *thisObj); +// MyTemplate::returnTemplate2() +void *c_MyTemplate_T_double_T___returnTemplate2(void *thisObj); +// MyTemplate::returnTemplate3() +void *c_MyTemplate_T_double_T___returnTemplate3(void *thisObj); +// MyTemplate::returnTemplate4() +void *c_MyTemplate_T_double_T___returnTemplate4(void *thisObj); +// MyTemplate::returnsT() +double c_MyTemplate_T_double_T___returnsT(void *thisObj); +// MyTemplate::returnsTemplate() +void *c_MyTemplate_T_double_T___returnsTemplate(void *thisObj); +void c_MyTemplate_T_double_T___destructor(void *thisObj); +void c_MyTemplate_T_double_T__Finalizer(void *cppObj); // MyTemplate::MyTemplate() +void *c_MyTemplate_T_EmptyStruct_T___constructor(); +// MyTemplate::receivesT(T arg__1) +int c_MyTemplate_T_EmptyStruct_T___receivesT_EmptyStruct(void *thisObj, void *arg__1_); +// MyTemplate::receivesTemplate(MyTemplate arg__1) +int c_MyTemplate_T_EmptyStruct_T___receivesTemplate_MyTemplate_T(void *thisObj, void *arg__1_); +// MyTemplate::returnInt() const +int c_MyTemplate_T_EmptyStruct_T___returnInt(void *thisObj); +// MyTemplate::returnTemplate2() +void *c_MyTemplate_T_EmptyStruct_T___returnTemplate2(void *thisObj); +// MyTemplate::returnTemplate3() +void *c_MyTemplate_T_EmptyStruct_T___returnTemplate3(void *thisObj); +// MyTemplate::returnTemplate4() +void *c_MyTemplate_T_EmptyStruct_T___returnTemplate4(void *thisObj); +// MyTemplate::returnsT() +void *c_MyTemplate_T_EmptyStruct_T___returnsT(void *thisObj); +// MyTemplate::returnsTemplate() +void *c_MyTemplate_T_EmptyStruct_T___returnsTemplate(void *thisObj); +void c_MyTemplate_T_EmptyStruct_T___destructor(void *thisObj); +void c_MyTemplate_T_EmptyStruct_T__Finalizer(void *cppObj); // MyObject::MyObject(QObject * parent) +void *c_MyObject__constructor_QObject(void *parent_); +// MyObject::customEvent(QEvent * event) +void c_MyObject__customEvent_QEvent(void *thisObj, void *event_); +// MyObject::event(QEvent * event) +bool c_MyObject__event_QEvent(void *thisObj, void *event_); +// MyObject::eventFilter(QObject * watched, QEvent * event) +bool c_MyObject__eventFilter_QObject_QEvent(void *thisObj, void *watched_, void *event_); +// MyObject::pureVirtual() +void c_MyObject__pureVirtual(void *thisObj); +// MyObject::receivesEnumClassWithDefaultArg(AnotherNamespace::MyNamespacedEnumClass foo) +void c_MyObject__receivesEnumClassWithDefaultArg_MyNamespacedEnumClass(void *thisObj, int foo); +// MyObject::receivesEnumClassWithDefaultArg(MyEnumClass foo) +void c_MyObject__receivesEnumClassWithDefaultArg_MyEnumClass(void *thisObj, int foo); +// MyObject::returnsEnumClass() +int c_MyObject__returnsEnumClass(void *thisObj); +// MyObject::tr(const char * s, const char * c, int n) +void *c_static_MyObject__tr_char_char_int(const char *s, const char *c, int n); +// MyObject::valueChanged(int arg__1) +void c_MyObject__valueChanged_int(void *thisObj, int arg__1); +void c_MyObject__onValueChanged_int(void *thisObj, void *contextQObject, + void *callback); // MyObject::virtualFunc() +int c_MyObject__virtualFunc(void *thisObj); +// MyObject::virtualMethodReturningConstChar() const +const char *c_MyObject__virtualMethodReturningConstChar(void *thisObj); +// MyObject::virtualReceivingQString(const QString & str) +void c_MyObject__virtualReceivingQString_QString(void *thisObj, const char *str_); +// MyObject::virtualReturningInt() const +int c_MyObject__virtualReturningInt(void *thisObj); +void c_MyObject__destructor(void *thisObj); +void c_MyObject__registerVirtualMethodCallback(void *ptr, void *callback, int methodId); +void c_MyObject_Finalizer(void *cppObj); // EmptyStruct::EmptyStruct() +void *c_EmptyStruct__constructor(); +void c_EmptyStruct__destructor(void *thisObj); +void c_EmptyStruct_Finalizer(void *cppObj); +void c_EmptyNameSpace_Finalizer( + void *cppObj); // DoubleInheritanceFromVirtuals::DoubleInheritanceFromVirtuals() +void *c_DoubleInheritanceFromVirtuals__constructor(); +// DoubleInheritanceFromVirtuals::virtualMethod1() +void c_DoubleInheritanceFromVirtuals__virtualMethod1(void *thisObj); +// DoubleInheritanceFromVirtuals::virtualMethod2() +void c_DoubleInheritanceFromVirtuals__virtualMethod2(void *thisObj); +void c_DoubleInheritanceFromVirtuals__destructor(void *thisObj); +void c_DoubleInheritanceFromVirtuals__registerVirtualMethodCallback(void *ptr, void *callback, + int methodId); +void c_DoubleInheritanceFromVirtuals_Finalizer( + void *cppObj); // DoubleInheritance::DoubleInheritance() +void *c_DoubleInheritance__constructor(); +// DoubleInheritance::customEvent(QEvent * event) +void c_DoubleInheritance__customEvent_QEvent(void *thisObj, void *event_); +// DoubleInheritance::event(QEvent * event) +bool c_DoubleInheritance__event_QEvent(void *thisObj, void *event_); +// DoubleInheritance::eventFilter(QObject * watched, QEvent * event) +bool c_DoubleInheritance__eventFilter_QObject_QEvent(void *thisObj, void *watched_, void *event_); +// DoubleInheritance::nonVirtualCallsVirtualFrom2ndBase() const +int c_DoubleInheritance__nonVirtualCallsVirtualFrom2ndBase(void *thisObj); +// DoubleInheritance::pureVirtual() +void c_DoubleInheritance__pureVirtual(void *thisObj); +// DoubleInheritance::virtualFunc() +int c_DoubleInheritance__virtualFunc(void *thisObj); +// DoubleInheritance::virtualMethodReturningConstChar() const +const char *c_DoubleInheritance__virtualMethodReturningConstChar(void *thisObj); +// DoubleInheritance::virtualReceivingQString(const QString & str) +void c_DoubleInheritance__virtualReceivingQString_QString(void *thisObj, const char *str_); +// DoubleInheritance::virtualReturningInt() const +int c_DoubleInheritance__virtualReturningInt(void *thisObj); +void c_DoubleInheritance__destructor(void *thisObj); +void c_DoubleInheritance__registerVirtualMethodCallback(void *ptr, void *callback, int methodId); +void c_DoubleInheritance_Finalizer(void *cppObj); // Cyclic1::Cyclic1(Cyclic2 * arg__1) +void *c_Cyclic1__constructor_Cyclic2(void *arg__1_); +// Cyclic1::getCyclic2() const +void *c_Cyclic1__getCyclic2(void *thisObj); +void c_Cyclic1__destructor(void *thisObj); +void c_Cyclic1_Finalizer(void *cppObj); // Cyclic2::getCyclic1() const +void *c_Cyclic2__getCyclic1(void *thisObj); +void c_Cyclic2__destructor(void *thisObj); +void c_Cyclic2_Finalizer(void *cppObj); // BaseClassWithFinalMethod::BaseClassWithFinalMethod() +void *c_BaseClassWithFinalMethod__constructor(); +// BaseClassWithFinalMethod::finalMethod() +void c_BaseClassWithFinalMethod__finalMethod(void *thisObj); +void c_BaseClassWithFinalMethod__destructor(void *thisObj); +void c_BaseClassWithFinalMethod__registerVirtualMethodCallback(void *ptr, void *callback, + int methodId); +void c_BaseClassWithFinalMethod_Finalizer(void *cppObj); // AnotherNamespace::size(QString s) +void *c_static_AnotherNamespace__size_QString(const char *s_); +void c_AnotherNamespace_Finalizer( + void *cppObj); // AnotherNamespace::AnotherNamespaceStruct::AnotherNamespaceStruct() +void *c_AnotherNamespace__AnotherNamespaceStruct__constructor(); +// AnotherNamespace::AnotherNamespaceStruct::receivesEnumerator(AnotherNamespace::NamespaceLevelEnum +// arg__1) +void c_AnotherNamespace__AnotherNamespaceStruct__receivesEnumerator_NamespaceLevelEnum( + void *thisObj, int arg__1); +void c_AnotherNamespace__AnotherNamespaceStruct__destructor(void *thisObj); +void c_AnotherNamespace__AnotherNamespaceStruct_Finalizer(void *cppObj); \ No newline at end of file diff --git a/tests/generated/TestBindings/dart/lib/Bindings.dart b/tests/generated/TestBindings/dart/lib/Bindings.dart new file mode 100644 index 0000000..965f951 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/Bindings.dart @@ -0,0 +1,61 @@ +export 'src/TestBindings.dart' + show + GlobalEnum, + MyEnumClass, + globalFunction, + receivesStructAsOptionalArgument, + receivesStructAsOptionalArgument2, + receivingPureAbstract, + returnsPureAbstract; +export 'src/AnotherNamespaceStruct.dart' show AnotherNamespaceStruct; +export 'src/AnotherNamespace.dart' + show + size, + AnotherNamespace_NamespaceLevelEnum, + AnotherNamespace_MyNamespacedEnumClass; +export 'src/BaseClassWithFinalMethod.dart' show BaseClassWithFinalMethod; +export 'src/Cyclic2.dart' show Cyclic2; +export 'src/Cyclic1.dart' show Cyclic1; +export 'src/DoubleInheritance.dart' show DoubleInheritance; +export 'src/DoubleInheritanceFromVirtuals.dart' + show DoubleInheritanceFromVirtuals; +export 'src/EmptyStruct.dart' show EmptyStruct; +export 'src/MyObject.dart' show MyObject; +export 'src/MyTemplate.dart' show MyTemplate; +export 'src/MyTemplate2.dart' show MyTemplate2; +export 'src/MyTemplateWithTwoArgs.dart' show MyTemplateWithTwoArgs; +export 'src/NonCopiable.dart' show NonCopiable; +export 'src/PureAbstractWithUnknownType.dart' show PureAbstractWithUnknownType; +export 'src/QApplication.dart' show QApplication; +export 'src/QByteArray.dart' show QByteArray; +export 'src/QColor.dart' show QColor; +export 'src/QGuiApplication.dart' show QGuiApplication; +export 'src/QCoreApplication.dart' show QCoreApplication; +export 'src/QEvent.dart' show QEvent; +export 'src/QHash.dart' show QHash; +export 'src/QList.dart' show QList; +export 'src/QMap.dart' show QMap; +export 'src/QObject.dart' show QObject; +export 'src/QSet.dart' show QSet; +export 'src/QString.dart' show QString; +export 'src/QVariant.dart' show QVariant; +export 'src/Qt.dart' show Qt_EventPriority; +export 'src/SimpleObjectStruct.dart' show SimpleObjectStruct; +export 'src/SimpleStruct.dart' show SimpleStruct; +export 'src/Derived2FromPureAbstract.dart' show Derived2FromPureAbstract; +export 'src/DerivedFromPureAbstract.dart' show DerivedFromPureAbstract; +export 'src/DestructorCounter.dart' show DestructorCounter; +export 'src/MyDerivedClass.dart' show MyDerivedClass; +export 'src/MyBaseClass.dart' + show MyBaseClass, MyBaseClass_MyEnum, MyBaseClass_ProtectedEnum; +export 'src/StructWithStructAsMember.dart' show StructWithStructAsMember; +export 'src/POD.dart' show POD; +export 'src/PureAbstract.dart' show PureAbstract; +export 'src/TestTargetNS.dart' + show + namespaceFunctionReturningNamespaceEnum, + namespaceLevelGlobalFunction, + TestTargetNS_NameSpaceLevelEnum; +export 'src/UnusedTemplate.dart' show UnusedTemplate; +export 'src/Virtual1.dart' show Virtual1; +export 'src/Virtual2.dart' show Virtual2; diff --git a/tests/generated/TestBindings/dart/lib/Bindings_ExplicitNamespace1.dart b/tests/generated/TestBindings/dart/lib/Bindings_ExplicitNamespace1.dart new file mode 100644 index 0000000..65fab19 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/Bindings_ExplicitNamespace1.dart @@ -0,0 +1 @@ +export 'src/ExplicitNamespace1/SimpleClash.dart' show SimpleClash; diff --git a/tests/generated/TestBindings/dart/lib/Bindings_ExplicitNamespace2.dart b/tests/generated/TestBindings/dart/lib/Bindings_ExplicitNamespace2.dart new file mode 100644 index 0000000..546ad65 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/Bindings_ExplicitNamespace2.dart @@ -0,0 +1 @@ +export 'src/ExplicitNamespace2/SimpleClash.dart' show SimpleClash; diff --git a/tests/generated/TestBindings/dart/lib/LibraryLoader.dart b/tests/generated/TestBindings/dart/lib/LibraryLoader.dart new file mode 100644 index 0000000..7726287 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/LibraryLoader.dart @@ -0,0 +1,37 @@ +import 'dart:ffi' as ffi; +import 'dart:io' show Platform; + +String bindingsLibraryName(String name) { + if (Platform.isWindows) return "${name}.dll"; + if (Platform.isMacOS) return "lib${name}.dylib"; + return "lib${name}.so"; +} + +class Library { + var _dylib; + + ffi.DynamicLibrary get dylib { + return _dylib; + } + + static var _library = null; + + factory Library.instance() { + // Singleton impl. + if (_library == null) _library = Library._(); + return _library; + } + + Library._() { + // DYLD_LIBRARY_PATH doesn't work by default on newer macOS. Instead + // introduce our own env variable for the same use case + var bindingsPath = Platform.environment["DARTAGNAN_BINDINGSLIB_PATH"] ?? ""; + + var libraryPath = bindingsLibraryName("TestBindings"); + if (!bindingsPath.isEmpty) { + libraryPath = bindingsPath + "/" + libraryPath; + } + + _dylib = ffi.DynamicLibrary.open(libraryPath); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/AnotherNamespace.dart b/tests/generated/TestBindings/dart/lib/src/AnotherNamespace.dart new file mode 100644 index 0000000..166b0a2 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/AnotherNamespace.dart @@ -0,0 +1,27 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; + +class AnotherNamespace_NamespaceLevelEnum { + static const NamespaceLevelEnum_value1 = 1; + static const NamespaceLevelEnum_value2 = 2; +} + +class AnotherNamespace_MyNamespacedEnumClass { + static const ValueFoo1 = 0; +} // size(QString s) + +QString size(String s) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_static_AnotherNamespace__size_QString') + .asFunction(); + ffi.Pointer result = func(s.toNativeUtf8()); + return QString.fromCppPointer(result, true); +} diff --git a/tests/generated/TestBindings/dart/lib/src/AnotherNamespaceStruct.dart b/tests/generated/TestBindings/dart/lib/src/AnotherNamespaceStruct.dart new file mode 100644 index 0000000..5eb65cd --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/AnotherNamespaceStruct.dart @@ -0,0 +1,79 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class AnotherNamespaceStruct implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = true; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory AnotherNamespaceStruct.fromCache(var cppPointer, + [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + AnotherNamespaceStruct.fromCppPointer(cppPointer, needsAutoDelete)) + as AnotherNamespaceStruct; + } + AnotherNamespaceStruct.fromCppPointer(var cppPointer, + [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + AnotherNamespaceStruct.init() {} + String getFinalizerName() { + return "c_AnotherNamespace__AnotherNamespaceStruct_Finalizer"; + } //AnotherNamespaceStruct() + + AnotherNamespaceStruct() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_AnotherNamespace__AnotherNamespaceStruct__constructor') + .asFunction(); + thisCpp = func(); + AnotherNamespaceStruct.s_dartInstanceByCppPtr[thisCpp.address] = this; + } // receivesEnumerator(AnotherNamespace::NamespaceLevelEnum arg__1) + receivesEnumerator( + {int arg__1 = + AnotherNamespace_NamespaceLevelEnum.NamespaceLevelEnum_value2}) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_AnotherNamespace__AnotherNamespaceStruct__receivesEnumerator_NamespaceLevelEnum') + .asFunction(); + func(thisCpp, arg__1); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_AnotherNamespace__AnotherNamespaceStruct__destructor') + .asFunction(); + func(thisCpp); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/BaseClassWithFinalMethod.dart b/tests/generated/TestBindings/dart/lib/src/BaseClassWithFinalMethod.dart new file mode 100644 index 0000000..3505916 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/BaseClassWithFinalMethod.dart @@ -0,0 +1,116 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class BaseClassWithFinalMethod implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = false; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory BaseClassWithFinalMethod.fromCache(var cppPointer, + [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + BaseClassWithFinalMethod.fromCppPointer( + cppPointer, needsAutoDelete)) as BaseClassWithFinalMethod; + } + BaseClassWithFinalMethod.fromCppPointer(var cppPointer, + [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + BaseClassWithFinalMethod.init() {} + String getFinalizerName() { + return "c_BaseClassWithFinalMethod_Finalizer"; + } //BaseClassWithFinalMethod() + + BaseClassWithFinalMethod() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_BaseClassWithFinalMethod__constructor') + .asFunction(); + thisCpp = func(); + BaseClassWithFinalMethod.s_dartInstanceByCppPtr[thisCpp.address] = this; + registerCallbacks(); + } // finalMethod() + finalMethod() { + final void_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(1200)) + .asFunction(); + func(thisCpp); + } + + static void finalMethod_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = + BaseClassWithFinalMethod.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for BaseClassWithFinalMethod::finalMethod()! (${thisCpp.address})"); + throw Error(); + } + dartInstance.finalMethod(); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_BaseClassWithFinalMethod__destructor') + .asFunction(); + func(thisCpp); + } + + String cFunctionSymbolName(int methodId) { + switch (methodId) { + case 1200: + return "c_BaseClassWithFinalMethod__finalMethod"; + } + return ""; + } + + static String methodNameFromId(int methodId) { + switch (methodId) { + case 1200: + return "finalMethod"; + } + throw Error(); + } + + void registerCallbacks() { + assert(thisCpp != null); + final RegisterMethodIsReimplementedCallback registerCallback = _dylib + .lookup>( + 'c_BaseClassWithFinalMethod__registerVirtualMethodCallback') + .asFunction(); + final callback1200 = ffi.Pointer.fromFunction( + BaseClassWithFinalMethod.finalMethod_calledFromC); + registerCallback(thisCpp, callback1200, 1200); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/Cyclic1.dart b/tests/generated/TestBindings/dart/lib/src/Cyclic1.dart new file mode 100644 index 0000000..0a1385f --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/Cyclic1.dart @@ -0,0 +1,75 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class Cyclic1 implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = true; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory Cyclic1.fromCache(var cppPointer, [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + Cyclic1.fromCppPointer(cppPointer, needsAutoDelete)) as Cyclic1; + } + Cyclic1.fromCppPointer(var cppPointer, [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + Cyclic1.init() {} + String getFinalizerName() { + return "c_Cyclic1_Finalizer"; + } //Cyclic1(Cyclic2 * arg__1) + + Cyclic1(Cyclic2? arg__1) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_Cyclic1__constructor_Cyclic2') + .asFunction(); + thisCpp = func(arg__1 == null ? ffi.nullptr : arg__1.thisCpp); + Cyclic1.s_dartInstanceByCppPtr[thisCpp.address] = this; + } // getCyclic2() const + Cyclic2 getCyclic2() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_Cyclic1__getCyclic2') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return Cyclic2.fromCppPointer(result, false); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_Cyclic1__destructor') + .asFunction(); + func(thisCpp); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/Cyclic2.dart b/tests/generated/TestBindings/dart/lib/src/Cyclic2.dart new file mode 100644 index 0000000..7d5b933 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/Cyclic2.dart @@ -0,0 +1,42 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; + +class Cyclic2 extends Cyclic1 { + Cyclic2.fromCppPointer(var cppPointer, [var needsAutoDelete = false]) + : super.fromCppPointer(cppPointer, needsAutoDelete) {} + Cyclic2.init() : super.init() {} + factory Cyclic2.fromCache(var cppPointer, [needsAutoDelete = false]) { + if (Cyclic1.isCached(cppPointer)) { + var instance = Cyclic1.s_dartInstanceByCppPtr[cppPointer.address]; + if (instance != null) return instance as Cyclic2; + } + return Cyclic2.fromCppPointer(cppPointer, needsAutoDelete); + } + String getFinalizerName() { + return "c_Cyclic2_Finalizer"; + } // getCyclic1() const + + Cyclic1 getCyclic1() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_Cyclic2__getCyclic1') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return Cyclic1.fromCppPointer(result, false); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_Cyclic2__destructor') + .asFunction(); + func(thisCpp); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/Derived2FromPureAbstract.dart b/tests/generated/TestBindings/dart/lib/src/Derived2FromPureAbstract.dart new file mode 100644 index 0000000..80157e4 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/Derived2FromPureAbstract.dart @@ -0,0 +1,186 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; + +class Derived2FromPureAbstract extends PureAbstract { + Derived2FromPureAbstract.fromCppPointer(var cppPointer, + [var needsAutoDelete = false]) + : super.fromCppPointer(cppPointer, needsAutoDelete) {} + Derived2FromPureAbstract.init() : super.init() {} + factory Derived2FromPureAbstract.fromCache(var cppPointer, + [needsAutoDelete = false]) { + if (PureAbstract.isCached(cppPointer)) { + var instance = PureAbstract.s_dartInstanceByCppPtr[cppPointer.address]; + if (instance != null) return instance as Derived2FromPureAbstract; + } + return Derived2FromPureAbstract.fromCppPointer(cppPointer, needsAutoDelete); + } + String getFinalizerName() { + return "c_TestTargetNS__Derived2FromPureAbstract_Finalizer"; + } //Derived2FromPureAbstract() + + Derived2FromPureAbstract() : super.init() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_TestTargetNS__Derived2FromPureAbstract__constructor') + .asFunction(); + thisCpp = func(); + PureAbstract.s_dartInstanceByCppPtr[thisCpp.address] = this; + registerCallbacks(); + } // foo() + int foo() { + final int_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(13)) + .asFunction(); + return func(thisCpp); + } + + static int foo_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = PureAbstract.s_dartInstanceByCppPtr[thisCpp.address] + as Derived2FromPureAbstract; + if (dartInstance == null) { + print( + "Dart instance not found for Derived2FromPureAbstract::foo()! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.foo(); + return result; + } // renamedPureVirtual() + + renamedPureVirtual1() { + final void_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(14)) + .asFunction(); + func(thisCpp); + } + + static void renamedPureVirtual1_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = PureAbstract.s_dartInstanceByCppPtr[thisCpp.address] + as Derived2FromPureAbstract; + if (dartInstance == null) { + print( + "Dart instance not found for Derived2FromPureAbstract::renamedPureVirtual()! (${thisCpp.address})"); + throw Error(); + } + dartInstance.renamedPureVirtual1(); + } + + static void unnamedOverriddenDefaultArgCase_calledFromC( + ffi.Pointer thisCpp, int myarg) { + var dartInstance = PureAbstract.s_dartInstanceByCppPtr[thisCpp.address] + as Derived2FromPureAbstract; + if (dartInstance == null) { + print( + "Dart instance not found for Derived2FromPureAbstract::unnamedOverriddenDefaultArgCase(int myarg)! (${thisCpp.address})"); + throw Error(); + } + dartInstance.unnamedOverriddenDefaultArgCase(myarg: myarg); + } + + static int virtualReceivingPointer_calledFromC( + ffi.Pointer thisCpp, ffi.Pointer? s) { + var dartInstance = PureAbstract.s_dartInstanceByCppPtr[thisCpp.address] + as Derived2FromPureAbstract; + if (dartInstance == null) { + print( + "Dart instance not found for Derived2FromPureAbstract::virtualReceivingPointer(SimpleStruct * s)! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.virtualReceivingPointer( + (s == null || s.address == 0) ? null : SimpleStruct.fromCppPointer(s)); + return result; + } // voidPureAbstract() + + voidPureAbstract() { + final void_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(19)) + .asFunction(); + func(thisCpp); + } + + static void voidPureAbstract_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = PureAbstract.s_dartInstanceByCppPtr[thisCpp.address] + as Derived2FromPureAbstract; + if (dartInstance == null) { + print( + "Dart instance not found for Derived2FromPureAbstract::voidPureAbstract()! (${thisCpp.address})"); + throw Error(); + } + dartInstance.voidPureAbstract(); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__Derived2FromPureAbstract__destructor') + .asFunction(); + func(thisCpp); + } + + String cFunctionSymbolName(int methodId) { + switch (methodId) { + case 13: + return "c_TestTargetNS__Derived2FromPureAbstract__foo"; + case 14: + return "c_TestTargetNS__Derived2FromPureAbstract__renamedPureVirtual1"; + case 17: + return "c_TestTargetNS__Derived2FromPureAbstract__unnamedOverriddenDefaultArgCase_int"; + case 18: + return "c_TestTargetNS__Derived2FromPureAbstract__virtualReceivingPointer_SimpleStruct"; + case 19: + return "c_TestTargetNS__Derived2FromPureAbstract__voidPureAbstract"; + } + return super.cFunctionSymbolName(methodId); + } + + static String methodNameFromId(int methodId) { + switch (methodId) { + case 13: + return "foo"; + case 14: + return "renamedPureVirtual1"; + case 17: + return "unnamedOverriddenDefaultArgCase"; + case 18: + return "virtualReceivingPointer"; + case 19: + return "voidPureAbstract"; + } + throw Error(); + } + + void registerCallbacks() { + assert(thisCpp != null); + final RegisterMethodIsReimplementedCallback registerCallback = _dylib + .lookup>( + 'c_TestTargetNS__Derived2FromPureAbstract__registerVirtualMethodCallback') + .asFunction(); + const callbackExcept13 = 0; + final callback13 = ffi.Pointer.fromFunction( + PureAbstract.foo_calledFromC, callbackExcept13); + registerCallback(thisCpp, callback13, 13); + final callback14 = ffi.Pointer.fromFunction( + PureAbstract.renamedPureVirtual1_calledFromC); + registerCallback(thisCpp, callback14, 14); + final callback17 = + ffi.Pointer.fromFunction( + PureAbstract.unnamedOverriddenDefaultArgCase_calledFromC); + registerCallback(thisCpp, callback17, 17); + const callbackExcept18 = 0; + final callback18 = ffi.Pointer.fromFunction( + PureAbstract.virtualReceivingPointer_calledFromC, callbackExcept18); + registerCallback(thisCpp, callback18, 18); + final callback19 = ffi.Pointer.fromFunction( + PureAbstract.voidPureAbstract_calledFromC); + registerCallback(thisCpp, callback19, 19); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/DerivedFromPureAbstract.dart b/tests/generated/TestBindings/dart/lib/src/DerivedFromPureAbstract.dart new file mode 100644 index 0000000..f0d580c --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/DerivedFromPureAbstract.dart @@ -0,0 +1,219 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; + +class DerivedFromPureAbstract extends PureAbstract { + DerivedFromPureAbstract.fromCppPointer(var cppPointer, + [var needsAutoDelete = false]) + : super.fromCppPointer(cppPointer, needsAutoDelete) {} + DerivedFromPureAbstract.init() : super.init() {} + factory DerivedFromPureAbstract.fromCache(var cppPointer, + [needsAutoDelete = false]) { + if (PureAbstract.isCached(cppPointer)) { + var instance = PureAbstract.s_dartInstanceByCppPtr[cppPointer.address]; + if (instance != null) return instance as DerivedFromPureAbstract; + } + return DerivedFromPureAbstract.fromCppPointer(cppPointer, needsAutoDelete); + } + String getFinalizerName() { + return "c_TestTargetNS__DerivedFromPureAbstract_Finalizer"; + } //DerivedFromPureAbstract() + + DerivedFromPureAbstract() : super.init() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_TestTargetNS__DerivedFromPureAbstract__constructor') + .asFunction(); + thisCpp = func(); + PureAbstract.s_dartInstanceByCppPtr[thisCpp.address] = this; + registerCallbacks(); + } //DerivedFromPureAbstract(int arg__1) + DerivedFromPureAbstract.ctor2(int arg__1) : super.init() { + final voidstar_Func_int func = _dylib + .lookup>( + 'c_TestTargetNS__DerivedFromPureAbstract__constructor_int') + .asFunction(); + thisCpp = func(arg__1); + PureAbstract.s_dartInstanceByCppPtr[thisCpp.address] = this; + registerCallbacks(); + } + static int foo_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = PureAbstract.s_dartInstanceByCppPtr[thisCpp.address] + as DerivedFromPureAbstract; + if (dartInstance == null) { + print( + "Dart instance not found for DerivedFromPureAbstract::foo()! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.foo(); + return result; + } // indirectionCallsVirtualReceivingStruct(SimpleStruct s) + + int indirectionCallsVirtualReceivingStruct(SimpleStruct s) { + final int_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__DerivedFromPureAbstract__indirectionCallsVirtualReceivingStruct_SimpleStruct') + .asFunction(); + return func(thisCpp, s == null ? ffi.nullptr : s.thisCpp); + } // nonVirtualCallsVirtual() + + int nonVirtualCallsVirtual() { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__DerivedFromPureAbstract__nonVirtualCallsVirtual') + .asFunction(); + return func(thisCpp); + } // receivesValueStruct(SimpleStruct arg__1) + + int receivesValueStruct(SimpleStruct arg__1) { + final int_Func_voidstar_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(193)) + .asFunction(); + return func(thisCpp, arg__1 == null ? ffi.nullptr : arg__1.thisCpp); + } + + static int receivesValueStruct_calledFromC( + ffi.Pointer thisCpp, ffi.Pointer arg__1) { + var dartInstance = PureAbstract.s_dartInstanceByCppPtr[thisCpp.address] + as DerivedFromPureAbstract; + if (dartInstance == null) { + print( + "Dart instance not found for DerivedFromPureAbstract::receivesValueStruct(SimpleStruct arg__1)! (${thisCpp.address})"); + throw Error(); + } + final result = + dartInstance.receivesValueStruct(SimpleStruct.fromCppPointer(arg__1)); + return result; + } + + static void renamedPureVirtual1_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = PureAbstract.s_dartInstanceByCppPtr[thisCpp.address] + as DerivedFromPureAbstract; + if (dartInstance == null) { + print( + "Dart instance not found for DerivedFromPureAbstract::renamedPureVirtual()! (${thisCpp.address})"); + throw Error(); + } + dartInstance.renamedPureVirtual1(); + } + + static void unnamedOverriddenDefaultArgCase_calledFromC( + ffi.Pointer thisCpp, int arg__1) { + var dartInstance = PureAbstract.s_dartInstanceByCppPtr[thisCpp.address] + as DerivedFromPureAbstract; + if (dartInstance == null) { + print( + "Dart instance not found for DerivedFromPureAbstract::unnamedOverriddenDefaultArgCase(int arg__1)! (${thisCpp.address})"); + throw Error(); + } + dartInstance.unnamedOverriddenDefaultArgCase(myarg: arg__1); + } + + static int virtualReceivingPointer_calledFromC( + ffi.Pointer thisCpp, ffi.Pointer? s) { + var dartInstance = PureAbstract.s_dartInstanceByCppPtr[thisCpp.address] + as DerivedFromPureAbstract; + if (dartInstance == null) { + print( + "Dart instance not found for DerivedFromPureAbstract::virtualReceivingPointer(SimpleStruct * s)! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.virtualReceivingPointer( + (s == null || s.address == 0) ? null : SimpleStruct.fromCppPointer(s)); + return result; + } + + static void voidPureAbstract_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = PureAbstract.s_dartInstanceByCppPtr[thisCpp.address] + as DerivedFromPureAbstract; + if (dartInstance == null) { + print( + "Dart instance not found for DerivedFromPureAbstract::voidPureAbstract()! (${thisCpp.address})"); + throw Error(); + } + dartInstance.voidPureAbstract(); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__DerivedFromPureAbstract__destructor') + .asFunction(); + func(thisCpp); + } + + String cFunctionSymbolName(int methodId) { + switch (methodId) { + case 13: + return "c_TestTargetNS__DerivedFromPureAbstract__foo"; + case 193: + return "c_TestTargetNS__DerivedFromPureAbstract__receivesValueStruct_SimpleStruct"; + case 14: + return "c_TestTargetNS__DerivedFromPureAbstract__renamedPureVirtual1"; + case 17: + return "c_TestTargetNS__DerivedFromPureAbstract__unnamedOverriddenDefaultArgCase_int"; + case 18: + return "c_TestTargetNS__DerivedFromPureAbstract__virtualReceivingPointer_SimpleStruct"; + case 19: + return "c_TestTargetNS__DerivedFromPureAbstract__voidPureAbstract"; + } + return super.cFunctionSymbolName(methodId); + } + + static String methodNameFromId(int methodId) { + switch (methodId) { + case 13: + return "foo"; + case 193: + return "receivesValueStruct"; + case 14: + return "renamedPureVirtual1"; + case 17: + return "unnamedOverriddenDefaultArgCase"; + case 18: + return "virtualReceivingPointer"; + case 19: + return "voidPureAbstract"; + } + throw Error(); + } + + void registerCallbacks() { + assert(thisCpp != null); + final RegisterMethodIsReimplementedCallback registerCallback = _dylib + .lookup>( + 'c_TestTargetNS__DerivedFromPureAbstract__registerVirtualMethodCallback') + .asFunction(); + const callbackExcept13 = 0; + final callback13 = ffi.Pointer.fromFunction( + DerivedFromPureAbstract.foo_calledFromC, callbackExcept13); + registerCallback(thisCpp, callback13, 13); + const callbackExcept193 = 0; + final callback193 = + ffi.Pointer.fromFunction( + DerivedFromPureAbstract.receivesValueStruct_calledFromC, + callbackExcept193); + registerCallback(thisCpp, callback193, 193); + final callback14 = ffi.Pointer.fromFunction( + DerivedFromPureAbstract.renamedPureVirtual1_calledFromC); + registerCallback(thisCpp, callback14, 14); + final callback17 = ffi.Pointer.fromFunction< + void_Func_voidstar_ffi_Int32_FFI>( + DerivedFromPureAbstract.unnamedOverriddenDefaultArgCase_calledFromC); + registerCallback(thisCpp, callback17, 17); + const callbackExcept18 = 0; + final callback18 = ffi.Pointer.fromFunction( + PureAbstract.virtualReceivingPointer_calledFromC, callbackExcept18); + registerCallback(thisCpp, callback18, 18); + final callback19 = ffi.Pointer.fromFunction( + DerivedFromPureAbstract.voidPureAbstract_calledFromC); + registerCallback(thisCpp, callback19, 19); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/DestructorCounter.dart b/tests/generated/TestBindings/dart/lib/src/DestructorCounter.dart new file mode 100644 index 0000000..a93fec6 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/DestructorCounter.dart @@ -0,0 +1,114 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class DestructorCounter implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = true; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory DestructorCounter.fromCache(var cppPointer, + [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + DestructorCounter.fromCppPointer(cppPointer, needsAutoDelete)) + as DestructorCounter; + } + DestructorCounter.fromCppPointer(var cppPointer, + [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + DestructorCounter.init() {} + String getFinalizerName() { + return "c_TestTargetNS__DestructorCounter_Finalizer"; + } + + static int get s_instanceCount { + final int_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__DestructorCounter___get_s_instanceCount') + .asFunction(); + return func(); + } + + static set s_instanceCount(int s_instanceCount_) { + final void_Func_int func = _dylib + .lookup>( + 'c_static_TestTargetNS__DestructorCounter___set_s_instanceCount_int') + .asFunction(); + func(s_instanceCount_); + } //DestructorCounter() + + DestructorCounter() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_TestTargetNS__DestructorCounter__constructor') + .asFunction(); + thisCpp = func(); + DestructorCounter.s_dartInstanceByCppPtr[thisCpp.address] = this; + } + static // instanceCount() + int instanceCount() { + final int_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__DestructorCounter__instanceCount') + .asFunction(); + return func(); + } + + static // newOnTheHeap() + DestructorCounter newOnTheHeap() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__DestructorCounter__newOnTheHeap') + .asFunction(); + ffi.Pointer result = func(); + return DestructorCounter.fromCppPointer(result, false); + } + + static // newOnTheStack() + DestructorCounter newOnTheStack() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__DestructorCounter__newOnTheStack') + .asFunction(); + ffi.Pointer result = func(); + return DestructorCounter.fromCppPointer(result, true); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__DestructorCounter__destructor') + .asFunction(); + func(thisCpp); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/DoubleInheritance.dart b/tests/generated/TestBindings/dart/lib/src/DoubleInheritance.dart new file mode 100644 index 0000000..31bd9cb --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/DoubleInheritance.dart @@ -0,0 +1,280 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; + +class DoubleInheritance extends SimpleStruct { + DoubleInheritance.fromCppPointer(var cppPointer, + [var needsAutoDelete = false]) + : super.fromCppPointer(cppPointer, needsAutoDelete) {} + DoubleInheritance.init() : super.init() {} + factory DoubleInheritance.fromCache(var cppPointer, + [needsAutoDelete = false]) { + if (SimpleStruct.isCached(cppPointer)) { + var instance = SimpleStruct.s_dartInstanceByCppPtr[cppPointer.address]; + if (instance != null) return instance as DoubleInheritance; + } + return DoubleInheritance.fromCppPointer(cppPointer, needsAutoDelete); + } + String getFinalizerName() { + return "c_DoubleInheritance_Finalizer"; + } //DoubleInheritance() + + DoubleInheritance() : super.init() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_DoubleInheritance__constructor') + .asFunction(); + thisCpp = func(); + SimpleStruct.s_dartInstanceByCppPtr[thisCpp.address] = this; + registerCallbacks(); + } // customEvent(QEvent * event) + customEvent(QEvent? event) { + final void_Func_voidstar_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(481)) + .asFunction(); + func(thisCpp, event == null ? ffi.nullptr : event.thisCpp); + } + + static void customEvent_calledFromC( + ffi.Pointer thisCpp, ffi.Pointer? event) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as DoubleInheritance; + if (dartInstance == null) { + print( + "Dart instance not found for DoubleInheritance::customEvent(QEvent * event)! (${thisCpp.address})"); + throw Error(); + } + dartInstance.customEvent((event == null || event.address == 0) + ? null + : QEvent.fromCppPointer(event)); + } // event(QEvent * event) + + bool event(QEvent? event) { + final bool_Func_voidstar_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(490)) + .asFunction(); + return func(thisCpp, event == null ? ffi.nullptr : event.thisCpp) != 0; + } + + static int event_calledFromC( + ffi.Pointer thisCpp, ffi.Pointer? event) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as DoubleInheritance; + if (dartInstance == null) { + print( + "Dart instance not found for DoubleInheritance::event(QEvent * event)! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.event((event == null || event.address == 0) + ? null + : QEvent.fromCppPointer(event)); + return result ? 1 : 0; + } // eventFilter(QObject * watched, QEvent * event) + + bool eventFilter(QObject? watched, QEvent? event) { + final bool_Func_voidstar_voidstar_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(491)) + .asFunction(); + return func(thisCpp, watched == null ? ffi.nullptr : watched.thisCpp, + event == null ? ffi.nullptr : event.thisCpp) != + 0; + } + + static int eventFilter_calledFromC(ffi.Pointer thisCpp, + ffi.Pointer? watched, ffi.Pointer? event) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as DoubleInheritance; + if (dartInstance == null) { + print( + "Dart instance not found for DoubleInheritance::eventFilter(QObject * watched, QEvent * event)! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.eventFilter( + (watched == null || watched.address == 0) + ? null + : QObject.fromCppPointer(watched), + (event == null || event.address == 0) + ? null + : QEvent.fromCppPointer(event)); + return result ? 1 : 0; + } // nonVirtualCallsVirtualFrom2ndBase() const + + int nonVirtualCallsVirtualFrom2ndBase() { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_DoubleInheritance__nonVirtualCallsVirtualFrom2ndBase') + .asFunction(); + return func(thisCpp); + } // pureVirtual() + + pureVirtual() { + final void_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(1166)) + .asFunction(); + func(thisCpp); + } + + static void pureVirtual_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as DoubleInheritance; + if (dartInstance == null) { + print( + "Dart instance not found for DoubleInheritance::pureVirtual()! (${thisCpp.address})"); + throw Error(); + } + dartInstance.pureVirtual(); + } // virtualFunc() + + int virtualFunc() { + final int_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(1181)) + .asFunction(); + return func(thisCpp); + } + + static int virtualFunc_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as DoubleInheritance; + if (dartInstance == null) { + print( + "Dart instance not found for DoubleInheritance::virtualFunc()! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.virtualFunc(); + return result; + } // virtualMethodReturningConstChar() const + + String virtualMethodReturningConstChar() { + final string_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(1182)) + .asFunction(); + ffi.Pointer result = func(thisCpp); + return result.toDartString(); + } + + static ffi.Pointer virtualMethodReturningConstChar_calledFromC( + ffi.Pointer thisCpp) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as DoubleInheritance; + if (dartInstance == null) { + print( + "Dart instance not found for DoubleInheritance::virtualMethodReturningConstChar() const! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.virtualMethodReturningConstChar(); + return result.toNativeUtf8(); + } // virtualReceivingQString(const QString & str) + + virtualReceivingQString(String str) { + final void_Func_voidstar_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(1183)) + .asFunction(); + func(thisCpp, str.toNativeUtf8()); + } + + static void virtualReceivingQString_calledFromC( + ffi.Pointer thisCpp, ffi.Pointer str) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as DoubleInheritance; + if (dartInstance == null) { + print( + "Dart instance not found for DoubleInheritance::virtualReceivingQString(const QString & str)! (${thisCpp.address})"); + throw Error(); + } + dartInstance + .virtualReceivingQString(QString.fromCppPointer(str).toDartString()); + } // virtualReturningInt() const + + int virtualReturningInt() { + final int_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(1184)) + .asFunction(); + return func(thisCpp); + } + + static int virtualReturningInt_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as DoubleInheritance; + if (dartInstance == null) { + print( + "Dart instance not found for DoubleInheritance::virtualReturningInt() const! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.virtualReturningInt(); + return result; + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_DoubleInheritance__destructor') + .asFunction(); + func(thisCpp); + } + + String cFunctionSymbolName(int methodId) { + switch (methodId) { + case 481: + return "c_DoubleInheritance__customEvent_QEvent"; + case 490: + return "c_DoubleInheritance__event_QEvent"; + case 491: + return "c_DoubleInheritance__eventFilter_QObject_QEvent"; + case 1166: + return "c_DoubleInheritance__pureVirtual"; + case 1181: + return "c_DoubleInheritance__virtualFunc"; + case 1182: + return "c_DoubleInheritance__virtualMethodReturningConstChar"; + case 1183: + return "c_DoubleInheritance__virtualReceivingQString_QString"; + case 1184: + return "c_DoubleInheritance__virtualReturningInt"; + } + return ""; + } + + static String methodNameFromId(int methodId) { + switch (methodId) { + case 481: + return "customEvent"; + case 490: + return "event"; + case 491: + return "eventFilter"; + case 1166: + return "pureVirtual"; + case 1181: + return "virtualFunc"; + case 1182: + return "virtualMethodReturningConstChar"; + case 1183: + return "virtualReceivingQString"; + case 1184: + return "virtualReturningInt"; + } + throw Error(); + } + + void registerCallbacks() { + assert(thisCpp != null); + final RegisterMethodIsReimplementedCallback registerCallback = _dylib + .lookup>( + 'c_DoubleInheritance__registerVirtualMethodCallback') + .asFunction(); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/DoubleInheritanceFromVirtuals.dart b/tests/generated/TestBindings/dart/lib/src/DoubleInheritanceFromVirtuals.dart new file mode 100644 index 0000000..b725e32 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/DoubleInheritanceFromVirtuals.dart @@ -0,0 +1,114 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; + +class DoubleInheritanceFromVirtuals extends Virtual1 { + DoubleInheritanceFromVirtuals.fromCppPointer(var cppPointer, + [var needsAutoDelete = false]) + : super.fromCppPointer(cppPointer, needsAutoDelete) {} + DoubleInheritanceFromVirtuals.init() : super.init() {} + factory DoubleInheritanceFromVirtuals.fromCache(var cppPointer, + [needsAutoDelete = false]) { + if (Virtual1.isCached(cppPointer)) { + var instance = Virtual1.s_dartInstanceByCppPtr[cppPointer.address]; + if (instance != null) return instance as DoubleInheritanceFromVirtuals; + } + return DoubleInheritanceFromVirtuals.fromCppPointer( + cppPointer, needsAutoDelete); + } + String getFinalizerName() { + return "c_DoubleInheritanceFromVirtuals_Finalizer"; + } //DoubleInheritanceFromVirtuals() + + DoubleInheritanceFromVirtuals() : super.init() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_DoubleInheritanceFromVirtuals__constructor') + .asFunction(); + thisCpp = func(); + Virtual1.s_dartInstanceByCppPtr[thisCpp.address] = this; + registerCallbacks(); + } // virtualMethod1() + virtualMethod1() { + final void_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(3)) + .asFunction(); + func(thisCpp); + } + + static void virtualMethod1_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = Virtual1.s_dartInstanceByCppPtr[thisCpp.address] + as DoubleInheritanceFromVirtuals; + if (dartInstance == null) { + print( + "Dart instance not found for DoubleInheritanceFromVirtuals::virtualMethod1()! (${thisCpp.address})"); + throw Error(); + } + dartInstance.virtualMethod1(); + } // virtualMethod2() + + virtualMethod2() { + final void_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(1)) + .asFunction(); + func(thisCpp); + } + + static void virtualMethod2_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = Virtual2.s_dartInstanceByCppPtr[thisCpp.address] + as DoubleInheritanceFromVirtuals; + if (dartInstance == null) { + print( + "Dart instance not found for DoubleInheritanceFromVirtuals::virtualMethod2()! (${thisCpp.address})"); + throw Error(); + } + dartInstance.virtualMethod2(); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_DoubleInheritanceFromVirtuals__destructor') + .asFunction(); + func(thisCpp); + } + + String cFunctionSymbolName(int methodId) { + switch (methodId) { + case 3: + return "c_DoubleInheritanceFromVirtuals__virtualMethod1"; + case 1: + return "c_DoubleInheritanceFromVirtuals__virtualMethod2"; + } + return super.cFunctionSymbolName(methodId); + } + + static String methodNameFromId(int methodId) { + switch (methodId) { + case 3: + return "virtualMethod1"; + case 1: + return "virtualMethod2"; + } + throw Error(); + } + + void registerCallbacks() { + assert(thisCpp != null); + final RegisterMethodIsReimplementedCallback registerCallback = _dylib + .lookup>( + 'c_DoubleInheritanceFromVirtuals__registerVirtualMethodCallback') + .asFunction(); + final callback3 = ffi.Pointer.fromFunction( + Virtual1.virtualMethod1_calledFromC); + registerCallback(thisCpp, callback3, 3); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/EmptyNameSpace.dart b/tests/generated/TestBindings/dart/lib/src/EmptyNameSpace.dart new file mode 100644 index 0000000..fb328d3 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/EmptyNameSpace.dart @@ -0,0 +1,9 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; diff --git a/tests/generated/TestBindings/dart/lib/src/EmptyStruct.dart b/tests/generated/TestBindings/dart/lib/src/EmptyStruct.dart new file mode 100644 index 0000000..bde7a12 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/EmptyStruct.dart @@ -0,0 +1,66 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class EmptyStruct implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = true; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory EmptyStruct.fromCache(var cppPointer, [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + EmptyStruct.fromCppPointer(cppPointer, needsAutoDelete)) as EmptyStruct; + } + EmptyStruct.fromCppPointer(var cppPointer, [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + EmptyStruct.init() {} + String getFinalizerName() { + return "c_EmptyStruct_Finalizer"; + } //EmptyStruct() + + EmptyStruct() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_EmptyStruct__constructor') + .asFunction(); + thisCpp = func(); + EmptyStruct.s_dartInstanceByCppPtr[thisCpp.address] = this; + } + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_EmptyStruct__destructor') + .asFunction(); + func(thisCpp); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/ExplicitNamespace1/SimpleClash.dart b/tests/generated/TestBindings/dart/lib/src/ExplicitNamespace1/SimpleClash.dart new file mode 100644 index 0000000..6006022 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/ExplicitNamespace1/SimpleClash.dart @@ -0,0 +1,84 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import '../TypeHelpers.dart'; +import '../../Bindings.dart'; +import '../../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class SimpleClash implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = true; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory SimpleClash.fromCache(var cppPointer, [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + SimpleClash.fromCppPointer(cppPointer, needsAutoDelete)) as SimpleClash; + } + SimpleClash.fromCppPointer(var cppPointer, [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + SimpleClash.init() {} + String getFinalizerName() { + return "c_NameClashingNS1__SimpleClash_Finalizer"; + } //SimpleClash(int arg__1) + + SimpleClash(int arg__1) { + final voidstar_Func_int func = _dylib + .lookup>( + 'c_NameClashingNS1__SimpleClash__constructor_int') + .asFunction(); + thisCpp = func(arg__1); + ExplicitNamespace1.SimpleClash.s_dartInstanceByCppPtr[thisCpp.address] = + this; + } // getValue() + int getValue() { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_NameClashingNS1__SimpleClash__getValue') + .asFunction(); + return func(thisCpp); + } + + static // getValueStatic() + int getValueStatic() { + final int_Func_void func = _dylib + .lookup>( + 'c_static_NameClashingNS1__SimpleClash__getValueStatic') + .asFunction(); + return func(); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_NameClashingNS1__SimpleClash__destructor') + .asFunction(); + func(thisCpp); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/ExplicitNamespace2/SimpleClash.dart b/tests/generated/TestBindings/dart/lib/src/ExplicitNamespace2/SimpleClash.dart new file mode 100644 index 0000000..ab26f0a --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/ExplicitNamespace2/SimpleClash.dart @@ -0,0 +1,105 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import '../TypeHelpers.dart'; +import '../../Bindings.dart'; +import '../../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class SimpleClash implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = true; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory SimpleClash.fromCache(var cppPointer, [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + SimpleClash.fromCppPointer(cppPointer, needsAutoDelete)) as SimpleClash; + } + SimpleClash.fromCppPointer(var cppPointer, [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + SimpleClash.init() {} + String getFinalizerName() { + return "c_NameClashingNS2__SimpleClash_Finalizer"; + } //SimpleClash(int arg__1) + + SimpleClash(int arg__1) { + final voidstar_Func_int func = _dylib + .lookup>( + 'c_NameClashingNS2__SimpleClash__constructor_int') + .asFunction(); + thisCpp = func(arg__1); + ExplicitNamespace2.SimpleClash.s_dartInstanceByCppPtr[thisCpp.address] = + this; + } // getFoo() + int getFoo() { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_NameClashingNS2__SimpleClash__getFoo') + .asFunction(); + return func(thisCpp); + } + + static // getValueStatic() + int getValueStatic() { + final int_Func_void func = _dylib + .lookup>( + 'c_static_NameClashingNS2__SimpleClash__getValueStatic') + .asFunction(); + return func(); + } + + static // returnsAndReceivesFromOtherScope(NameClashingNS1::SimpleClash s) + ExplicitNamespace1.SimpleClash returnsAndReceivesFromOtherScope( + ExplicitNamespace1.SimpleClash s) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_static_NameClashingNS2__SimpleClash__returnsAndReceivesFromOtherScope_SimpleClash') + .asFunction(); + ffi.Pointer result = func(s == null ? ffi.nullptr : s.thisCpp); + return ExplicitNamespace1.SimpleClash.fromCppPointer(result, true); + } + + static // returnsFromOtherScope() + ExplicitNamespace1.SimpleClash returnsFromOtherScope() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_NameClashingNS2__SimpleClash__returnsFromOtherScope') + .asFunction(); + ffi.Pointer result = func(); + return ExplicitNamespace1.SimpleClash.fromCppPointer(result, true); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_NameClashingNS2__SimpleClash__destructor') + .asFunction(); + func(thisCpp); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/MyBaseClass.dart b/tests/generated/TestBindings/dart/lib/src/MyBaseClass.dart new file mode 100644 index 0000000..6d50d98 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/MyBaseClass.dart @@ -0,0 +1,896 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class MyBaseClass_MyEnum { + static const MyEnumerator0 = 0; + static const MyEnumerator1 = 1; + static const MyEnumerator3 = 3; +} + +class MyBaseClass_ProtectedEnum { + static const ProtectedEnum_V1 = 1; +} + +class MyBaseClass implements ffi.Finalizable { + // Anonymous enum + static const AnonymousEnumerator1 = 1; + static const AnonymousEnumerator2 = 2; + static const AnonymousEnumerator3 = 3; + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = false; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory MyBaseClass.fromCache(var cppPointer, [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + MyBaseClass.fromCppPointer(cppPointer, needsAutoDelete)) as MyBaseClass; + } + MyBaseClass.fromCppPointer(var cppPointer, [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + MyBaseClass.init() {} + String getFinalizerName() { + return "c_TestTargetNS__MyBaseClass_Finalizer"; + } + + static int get s_instanceCount { + final int_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__MyBaseClass___get_s_instanceCount') + .asFunction(); + return func(); + } + + static set s_instanceCount(int s_instanceCount_) { + final void_Func_int func = _dylib + .lookup>( + 'c_static_TestTargetNS__MyBaseClass___set_s_instanceCount_int') + .asFunction(); + func(s_instanceCount_); + } + + static int get s_staticMember { + final int_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__MyBaseClass___get_s_staticMember') + .asFunction(); + return func(); + } + + static set s_staticMember(int s_staticMember_) { + final void_Func_int func = _dylib + .lookup>( + 'c_static_TestTargetNS__MyBaseClass___set_s_staticMember_int') + .asFunction(); + func(s_staticMember_); + } + + static int get s_staticConstMember { + final int_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__MyBaseClass___get_s_staticConstMember') + .asFunction(); + return func(); + } //MyBaseClass() + + MyBaseClass() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__constructor') + .asFunction(); + thisCpp = func(); + MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address] = this; + registerCallbacks(); + } //MyBaseClass(TestTargetNS::MyBaseClass * mybaseclassptr) + MyBaseClass.ctor2(MyBaseClass? mybaseclassptr) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__constructor_MyBaseClass') + .asFunction(); + thisCpp = + func(mybaseclassptr == null ? ffi.nullptr : mybaseclassptr.thisCpp); + MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address] = this; + registerCallbacks(); + } // addInts(QList arg__1) + addInts(QList arg__1) { + final void_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__addInts_QList_int') + .asFunction(); + func(thisCpp, arg__1 == null ? ffi.nullptr : arg__1.thisCpp); + } // addQObjects(const QList & arg__1) + + addQObjects(QList arg__1) { + final void_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__addQObjects_QList_QObject') + .asFunction(); + func(thisCpp, arg__1 == null ? ffi.nullptr : arg__1.thisCpp); + } // addReals(QList arg__1) + + addReals(QList arg__1) { + final void_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__addReals_QList_qreal') + .asFunction(); + func(thisCpp, arg__1 == null ? ffi.nullptr : arg__1.thisCpp); + } + + static // anotherOverloadedStatic(int arg__1) + int anotherOverloadedStatic(int arg__1) { + final int_Func_int func = _dylib + .lookup>( + 'c_static_TestTargetNS__MyBaseClass__anotherOverloadedStatic_int') + .asFunction(); + return func(arg__1); + } // bar() const + + int bar() { + final int_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(51)) + .asFunction(); + return func(thisCpp); + } + + static int bar_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for MyBaseClass::bar() const! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.bar(); + return result; + } // bar2() const + + int bar2() { + final int_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(52)) + .asFunction(); + return func(thisCpp); + } + + static int bar2_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for MyBaseClass::bar2() const! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.bar2(); + return result; + } // callsVirtual() const + + int callsVirtual() { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__callsVirtual') + .asFunction(); + return func(thisCpp); + } // foo() const + + int foo() { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__foo') + .asFunction(); + return func(thisCpp); + } // getBool(int arg__1) const + + bool getBool(int arg__1) { + final bool_Func_voidstar_int func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__getBool_int') + .asFunction(); + return func(thisCpp, arg__1) != 0; + } // getBoolFalse() const + + bool getBoolFalse() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__getBoolFalse') + .asFunction(); + return func(thisCpp) != 0; + } // getBoolTrue() const + + bool getBoolTrue() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__getBoolTrue') + .asFunction(); + return func(thisCpp) != 0; + } // hello() + + hello() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__hello') + .asFunction(); + func(thisCpp); + } // methodReturnsIntTemplate() + + MyTemplate methodReturnsIntTemplate() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__methodReturnsIntTemplate') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return MyTemplate.fromCppPointer(result, true); + } // nonVirtualButOverridden() const + + int nonVirtualButOverridden() { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__nonVirtualButOverridden') + .asFunction(); + return func(thisCpp); + } // nonVirtualInBaseButVirtualInDerived(int i) const + + int nonVirtualInBaseButVirtualInDerived(int i) { + final int_Func_voidstar_int func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__nonVirtualInBaseButVirtualInDerived_int') + .asFunction(); + return func(thisCpp, i); + } // nonVirtualInBaseButVirtualInDerived(int i, int j) const + + int nonVirtualInBaseButVirtualInDerived_2(int i, int j) { + final int_Func_voidstar_int_int func = _dylib + .lookup>( + cFunctionSymbolName(63)) + .asFunction(); + return func(thisCpp, i, j); + } + + static int nonVirtualInBaseButVirtualInDerived_2_calledFromC( + ffi.Pointer thisCpp, int i, int j) { + var dartInstance = MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for MyBaseClass::nonVirtualInBaseButVirtualInDerived(int i, int j) const! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.nonVirtualInBaseButVirtualInDerived_2(i, j); + return result; + } // nonVirtualReturningStruct() const + + SimpleStruct nonVirtualReturningStruct() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__nonVirtualReturningStruct') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return SimpleStruct.fromCppPointer(result, true); + } + + static // overloadedStatic() + overloadedStatic() { + final void_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__MyBaseClass__overloadedStatic') + .asFunction(); + func(); + } + + static // overloadedStatic(int arg__1) + overloadedStatic_2(int arg__1) { + final void_Func_int func = _dylib + .lookup>( + 'c_static_TestTargetNS__MyBaseClass__overloadedStatic_int') + .asFunction(); + func(arg__1); + } + + static // overloadedStatic(int arg__1, int arg__2) + overloadedStatic_3(int arg__1, int arg__2) { + final void_Func_int_int func = _dylib + .lookup>( + 'c_static_TestTargetNS__MyBaseClass__overloadedStatic_int_int') + .asFunction(); + func(arg__1, arg__2); + } + + static // print(const char * msg) + print(String? msg) { + final void_Func_string func = _dylib + .lookup>( + 'c_static_TestTargetNS__MyBaseClass__print_char') + .asFunction(); + func(msg?.toNativeUtf8() ?? ffi.nullptr); + } // push(const char * arg__1) + + push(String? arg__1) { + final void_Func_voidstar_string func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__push_char') + .asFunction(); + func(thisCpp, arg__1?.toNativeUtf8() ?? ffi.nullptr); + } // receivesAndReturnsQString(const QString & s) + + QString receivesAndReturnsQString(String s) { + final voidstar_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__receivesAndReturnsQString_QString') + .asFunction(); + ffi.Pointer result = func(thisCpp, s.toNativeUtf8()); + return QString.fromCppPointer(result, true); + } // receivesEnum(TestTargetNS::MyBaseClass::MyEnum e) + + int receivesEnum(int e) { + final int_Func_voidstar_int func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__receivesEnum_MyEnum') + .asFunction(); + return func(thisCpp, e); + } // receivesEnumWithDefaultArg(TestTargetNS::MyBaseClass::MyEnum arg__1) + + receivesEnumWithDefaultArg({int arg__1 = MyBaseClass_MyEnum.MyEnumerator0}) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__receivesEnumWithDefaultArg_MyEnum') + .asFunction(); + func(thisCpp, arg__1); + } // receivesEnumWithDefaultArgNull(TestTargetNS::MyBaseClass::MyEnum arg__1) + + receivesEnumWithDefaultArgNull({int arg__1 = 0}) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__receivesEnumWithDefaultArgNull_MyEnum') + .asFunction(); + func(thisCpp, arg__1); + } // receivesFloat(float arg__1) + + receivesFloat(double arg__1) { + final void_Func_voidstar_double func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__receivesFloat_float') + .asFunction(); + func(thisCpp, arg__1); + } // receivesQFlags(QFlags arg__1) + + receivesQFlags(int arg__1) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__receivesQFlags_NamespaceLevelEnums') + .asFunction(); + func(thisCpp, arg__1); + } // receivesintWithDefaultEnumArg(int arg__1) + + receivesintWithDefaultEnumArg( + {int arg__1 = MyBaseClass_MyEnum.MyEnumerator0}) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__receivesintWithDefaultEnumArg_int') + .asFunction(); + func(thisCpp, arg__1); + } // receivesintWithDefaultEnumArg2(int arg__1) + + receivesintWithDefaultEnumArg2( + {int arg__1 = MyBaseClass.AnonymousEnumerator1}) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__receivesintWithDefaultEnumArg2_int') + .asFunction(); + func(thisCpp, arg__1); + } // receivesintWithDefaultEnumArg3(int arg__1) + + receivesintWithDefaultEnumArg3( + {int arg__1 = MyBaseClass_MyEnum.MyEnumerator0}) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__receivesintWithDefaultEnumArg3_int') + .asFunction(); + func(thisCpp, arg__1); + } // renamedMethod1() + + renamedMethod2() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__renamedMethod2') + .asFunction(); + func(thisCpp); + } // renamedVirtual1() + + renamedVirtual2() { + final void_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(86)) + .asFunction(); + func(thisCpp); + } + + static void renamedVirtual2_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for MyBaseClass::renamedVirtual1()! (${thisCpp.address})"); + throw Error(); + } + dartInstance.renamedVirtual2(); + } + + static // returnsConstChar() + String returnsConstChar() { + final string_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__MyBaseClass__returnsConstChar') + .asFunction(); + ffi.Pointer result = func(); + return result.toDartString(); + } + + static // returnsDoubleTemplate() + MyTemplate returnsDoubleTemplate() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__MyBaseClass__returnsDoubleTemplate') + .asFunction(); + ffi.Pointer result = func(); + return MyTemplate.fromCppPointer(result, true); + } + + static // returnsIntTemplate() + MyTemplate returnsIntTemplate() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__MyBaseClass__returnsIntTemplate') + .asFunction(); + ffi.Pointer result = func(); + return MyTemplate.fromCppPointer(result, true); + } + + static // returnsListOfStructPtr() + QList returnsListOfStructPtr() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__MyBaseClass__returnsListOfStructPtr') + .asFunction(); + ffi.Pointer result = func(); + return QList.fromCppPointer(result, true); + } // returnsQFlags() const + + int returnsQFlags() { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__returnsQFlags') + .asFunction(); + return func(thisCpp); + } + + static // returnsQString() + QString returnsQString() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__MyBaseClass__returnsQString') + .asFunction(); + ffi.Pointer result = func(); + return QString.fromCppPointer(result, true); + } // returnsReals() const + + QList returnsReals() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__returnsReals') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QList.fromCppPointer(result, true); + } + + static // returnsSimpleStruct(int value) + SimpleStruct returnsSimpleStruct(int value) { + final voidstar_Func_int func = _dylib + .lookup>( + 'c_static_TestTargetNS__MyBaseClass__returnsSimpleStruct_int') + .asFunction(); + ffi.Pointer result = func(value); + return SimpleStruct.fromCppPointer(result, true); + } + + static // returnsTemplateWithTwoArgs() + MyTemplateWithTwoArgs returnsTemplateWithTwoArgs() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__MyBaseClass__returnsTemplateWithTwoArgs') + .asFunction(); + ffi.Pointer result = func(); + return MyTemplateWithTwoArgs.fromCppPointer(result, true); + } // returnsVector() + + QList returnsVector() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__returnsVector') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QList.fromCppPointer(result, true); + } // setBool(bool b) + + bool setBool(bool b) { + final bool_Func_voidstar_bool func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__setBool_bool') + .asFunction(); + return func(thisCpp, b ? 1 : 0) != 0; + } // sum(int a, int b) + + int sum(int a, int b) { + final int_Func_voidstar_int_int func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__sum_int_int') + .asFunction(); + return func(thisCpp, a, b); + } // virtualReceivingBool(bool b) + + int virtualReceivingBool(bool b) { + final int_Func_voidstar_bool func = _dylib + .lookup>( + cFunctionSymbolName(103)) + .asFunction(); + return func(thisCpp, b ? 1 : 0); + } + + static int virtualReceivingBool_calledFromC( + ffi.Pointer thisCpp, int b) { + var dartInstance = MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for MyBaseClass::virtualReceivingBool(bool b)! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.virtualReceivingBool(b != 0); + return result; + } // virtualReceivingCharPtr(char * arg__1) + + virtualReceivingCharPtr(String? arg__1) { + final void_Func_voidstar_string func = _dylib + .lookup>( + cFunctionSymbolName(104)) + .asFunction(); + func(thisCpp, arg__1?.toNativeUtf8() ?? ffi.nullptr); + } + + static void virtualReceivingCharPtr_calledFromC( + ffi.Pointer thisCpp, ffi.Pointer? arg__1) { + var dartInstance = MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for MyBaseClass::virtualReceivingCharPtr(char * arg__1)! (${thisCpp.address})"); + throw Error(); + } + dartInstance.virtualReceivingCharPtr(arg__1.toString()); + } // virtualReceivingInt(int arg__1) + + int virtualReceivingInt(int arg__1) { + final int_Func_voidstar_int func = _dylib + .lookup>( + cFunctionSymbolName(105)) + .asFunction(); + return func(thisCpp, arg__1); + } + + static int virtualReceivingInt_calledFromC( + ffi.Pointer thisCpp, int arg__1) { + var dartInstance = MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for MyBaseClass::virtualReceivingInt(int arg__1)! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.virtualReceivingInt(arg__1); + return result; + } // virtualReceivingOptionalArgument(int optional) + + int virtualReceivingOptionalArgument({int optional = 1}) { + final int_Func_voidstar_int func = _dylib + .lookup>( + cFunctionSymbolName(106)) + .asFunction(); + return func(thisCpp, optional); + } + + static int virtualReceivingOptionalArgument_calledFromC( + ffi.Pointer thisCpp, int optional) { + var dartInstance = MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for MyBaseClass::virtualReceivingOptionalArgument(int optional)! (${thisCpp.address})"); + throw Error(); + } + final result = + dartInstance.virtualReceivingOptionalArgument(optional: optional); + return result; + } // virtualReturningBool(bool b) + + bool virtualReturningBool(bool b) { + final bool_Func_voidstar_bool func = _dylib + .lookup>( + cFunctionSymbolName(107)) + .asFunction(); + return func(thisCpp, b ? 1 : 0) != 0; + } + + static int virtualReturningBool_calledFromC( + ffi.Pointer thisCpp, int b) { + var dartInstance = MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for MyBaseClass::virtualReturningBool(bool b)! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.virtualReturningBool(b != 0); + return result ? 1 : 0; + } // virtualReturningStruct() const + + SimpleStruct virtualReturningStruct() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(109)) + .asFunction(); + ffi.Pointer result = func(thisCpp); + return SimpleStruct.fromCppPointer(result, true); + } + + static ffi.Pointer virtualReturningStruct_calledFromC( + ffi.Pointer thisCpp) { + var dartInstance = MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for MyBaseClass::virtualReturningStruct() const! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.virtualReturningStruct(); + return result.thisCpp; + } // virtualReturnsIntTemplate() + + MyTemplate virtualReturnsIntTemplate() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(110)) + .asFunction(); + ffi.Pointer result = func(thisCpp); + return MyTemplate.fromCppPointer(result, true); + } + + static ffi.Pointer virtualReturnsIntTemplate_calledFromC( + ffi.Pointer thisCpp) { + var dartInstance = MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for MyBaseClass::virtualReturnsIntTemplate()! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.virtualReturnsIntTemplate(); + return result.thisCpp; + } // virtualWithNoDefaultArgumentInDerived(int optional) + + virtualWithNoDefaultArgumentInDerived({int optional = 1}) { + final void_Func_voidstar_int func = _dylib + .lookup>( + cFunctionSymbolName(111)) + .asFunction(); + func(thisCpp, optional); + } + + static void virtualWithNoDefaultArgumentInDerived_calledFromC( + ffi.Pointer thisCpp, int optional) { + var dartInstance = MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for MyBaseClass::virtualWithNoDefaultArgumentInDerived(int optional)! (${thisCpp.address})"); + throw Error(); + } + dartInstance.virtualWithNoDefaultArgumentInDerived(optional: optional); + } // virtualWithOverload(int i) const + + virtualWithOverload(int i) { + final void_Func_voidstar_int func = _dylib + .lookup>( + cFunctionSymbolName(112)) + .asFunction(); + func(thisCpp, i); + } + + static void virtualWithOverload_calledFromC( + ffi.Pointer thisCpp, int i) { + var dartInstance = MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for MyBaseClass::virtualWithOverload(int i) const! (${thisCpp.address})"); + throw Error(); + } + dartInstance.virtualWithOverload(i); + } // virtualWithOverload(int i, int j) const + + virtualWithOverload_2(int i, int j) { + final void_Func_voidstar_int_int func = _dylib + .lookup>( + cFunctionSymbolName(113)) + .asFunction(); + func(thisCpp, i, j); + } + + static void virtualWithOverload_2_calledFromC( + ffi.Pointer thisCpp, int i, int j) { + var dartInstance = MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for MyBaseClass::virtualWithOverload(int i, int j) const! (${thisCpp.address})"); + throw Error(); + } + dartInstance.virtualWithOverload_2(i, j); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__destructor') + .asFunction(); + func(thisCpp); + } + + String cFunctionSymbolName(int methodId) { + switch (methodId) { + case 51: + return "c_TestTargetNS__MyBaseClass__bar"; + case 52: + return "c_TestTargetNS__MyBaseClass__bar2"; + case 63: + return "c_TestTargetNS__MyBaseClass__nonVirtualInBaseButVirtualInDerived_int_int"; + case 86: + return "c_TestTargetNS__MyBaseClass__renamedVirtual2"; + case 103: + return "c_TestTargetNS__MyBaseClass__virtualReceivingBool_bool"; + case 104: + return "c_TestTargetNS__MyBaseClass__virtualReceivingCharPtr_char"; + case 105: + return "c_TestTargetNS__MyBaseClass__virtualReceivingInt_int"; + case 106: + return "c_TestTargetNS__MyBaseClass__virtualReceivingOptionalArgument_int"; + case 107: + return "c_TestTargetNS__MyBaseClass__virtualReturningBool_bool"; + case 109: + return "c_TestTargetNS__MyBaseClass__virtualReturningStruct"; + case 110: + return "c_TestTargetNS__MyBaseClass__virtualReturnsIntTemplate"; + case 111: + return "c_TestTargetNS__MyBaseClass__virtualWithNoDefaultArgumentInDerived_int"; + case 112: + return "c_TestTargetNS__MyBaseClass__virtualWithOverload_int"; + case 113: + return "c_TestTargetNS__MyBaseClass__virtualWithOverload_int_int"; + } + return ""; + } + + static String methodNameFromId(int methodId) { + switch (methodId) { + case 51: + return "bar"; + case 52: + return "bar2"; + case 63: + return "nonVirtualInBaseButVirtualInDerived_2"; + case 86: + return "renamedVirtual2"; + case 103: + return "virtualReceivingBool"; + case 104: + return "virtualReceivingCharPtr"; + case 105: + return "virtualReceivingInt"; + case 106: + return "virtualReceivingOptionalArgument"; + case 107: + return "virtualReturningBool"; + case 109: + return "virtualReturningStruct"; + case 110: + return "virtualReturnsIntTemplate"; + case 111: + return "virtualWithNoDefaultArgumentInDerived"; + case 112: + return "virtualWithOverload"; + case 113: + return "virtualWithOverload_2"; + } + throw Error(); + } + + void registerCallbacks() { + assert(thisCpp != null); + final RegisterMethodIsReimplementedCallback registerCallback = _dylib + .lookup>( + 'c_TestTargetNS__MyBaseClass__registerVirtualMethodCallback') + .asFunction(); + const callbackExcept51 = 0; + final callback51 = ffi.Pointer.fromFunction( + MyBaseClass.bar_calledFromC, callbackExcept51); + registerCallback(thisCpp, callback51, 51); + const callbackExcept52 = 0; + final callback52 = ffi.Pointer.fromFunction( + MyBaseClass.bar2_calledFromC, callbackExcept52); + registerCallback(thisCpp, callback52, 52); + const callbackExcept63 = 0; + final callback63 = + ffi.Pointer.fromFunction( + MyBaseClass.nonVirtualInBaseButVirtualInDerived_2_calledFromC, + callbackExcept63); + registerCallback(thisCpp, callback63, 63); + final callback86 = ffi.Pointer.fromFunction( + MyBaseClass.renamedVirtual2_calledFromC); + registerCallback(thisCpp, callback86, 86); + const callbackExcept103 = 0; + final callback103 = + ffi.Pointer.fromFunction( + MyBaseClass.virtualReceivingBool_calledFromC, callbackExcept103); + registerCallback(thisCpp, callback103, 103); + final callback104 = ffi.Pointer.fromFunction( + MyBaseClass.virtualReceivingCharPtr_calledFromC); + registerCallback(thisCpp, callback104, 104); + const callbackExcept105 = 0; + final callback105 = + ffi.Pointer.fromFunction( + MyBaseClass.virtualReceivingInt_calledFromC, callbackExcept105); + registerCallback(thisCpp, callback105, 105); + const callbackExcept106 = 0; + final callback106 = + ffi.Pointer.fromFunction( + MyBaseClass.virtualReceivingOptionalArgument_calledFromC, + callbackExcept106); + registerCallback(thisCpp, callback106, 106); + const callbackExcept107 = 0; + final callback107 = + ffi.Pointer.fromFunction( + MyBaseClass.virtualReturningBool_calledFromC, callbackExcept107); + registerCallback(thisCpp, callback107, 107); + final callback109 = ffi.Pointer.fromFunction( + MyBaseClass.virtualReturningStruct_calledFromC); + registerCallback(thisCpp, callback109, 109); + final callback110 = ffi.Pointer.fromFunction( + MyBaseClass.virtualReturnsIntTemplate_calledFromC); + registerCallback(thisCpp, callback110, 110); + final callback111 = + ffi.Pointer.fromFunction( + MyBaseClass.virtualWithNoDefaultArgumentInDerived_calledFromC); + registerCallback(thisCpp, callback111, 111); + final callback112 = + ffi.Pointer.fromFunction( + MyBaseClass.virtualWithOverload_calledFromC); + registerCallback(thisCpp, callback112, 112); + final callback113 = + ffi.Pointer.fromFunction( + MyBaseClass.virtualWithOverload_2_calledFromC); + registerCallback(thisCpp, callback113, 113); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/MyDerivedClass.dart b/tests/generated/TestBindings/dart/lib/src/MyDerivedClass.dart new file mode 100644 index 0000000..07583f4 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/MyDerivedClass.dart @@ -0,0 +1,570 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; + +class MyDerivedClass extends MyBaseClass { + MyDerivedClass.fromCppPointer(var cppPointer, [var needsAutoDelete = false]) + : super.fromCppPointer(cppPointer, needsAutoDelete) {} + MyDerivedClass.init() : super.init() {} + factory MyDerivedClass.fromCache(var cppPointer, [needsAutoDelete = false]) { + if (MyBaseClass.isCached(cppPointer)) { + var instance = MyBaseClass.s_dartInstanceByCppPtr[cppPointer.address]; + if (instance != null) return instance as MyDerivedClass; + } + return MyDerivedClass.fromCppPointer(cppPointer, needsAutoDelete); + } + String getFinalizerName() { + return "c_TestTargetNS__MyDerivedClass_Finalizer"; + } + + static int get s_instanceCount { + final int_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__MyDerivedClass___get_s_instanceCount') + .asFunction(); + return func(); + } + + static set s_instanceCount(int s_instanceCount_) { + final void_Func_int func = _dylib + .lookup>( + 'c_static_TestTargetNS__MyDerivedClass___set_s_instanceCount_int') + .asFunction(); + func(s_instanceCount_); + } //MyDerivedClass() + + MyDerivedClass() : super.init() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_TestTargetNS__MyDerivedClass__constructor') + .asFunction(); + thisCpp = func(); + MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address] = this; + registerCallbacks(); + } // alsoCallsVirtual() + int alsoCallsVirtual() { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__MyDerivedClass__alsoCallsVirtual') + .asFunction(); + return func(thisCpp); + } + + static // anotherOverloadedStatic(int arg__1) + MyDerivedClass anotherOverloadedStatic(int arg__1) { + final voidstar_Func_int func = _dylib + .lookup>( + 'c_static_TestTargetNS__MyDerivedClass__anotherOverloadedStatic_int') + .asFunction(); + ffi.Pointer result = func(arg__1); + return MyDerivedClass.fromCppPointer(result, false); + } + + static // anotherOverloadedStatic(int arg__1, int arg__2) + MyDerivedClass anotherOverloadedStatic_1(int arg__1, int arg__2) { + final voidstar_Func_int_int func = _dylib + .lookup>( + 'c_static_TestTargetNS__MyDerivedClass__anotherOverloadedStatic_int_int') + .asFunction(); + ffi.Pointer result = func(arg__1, arg__2); + return MyDerivedClass.fromCppPointer(result, false); + } + + static int bar_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = + MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address] as MyDerivedClass; + if (dartInstance == null) { + print( + "Dart instance not found for MyDerivedClass::bar() const! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.bar(); + return result; + } + + static int bar2_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = + MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address] as MyDerivedClass; + if (dartInstance == null) { + print( + "Dart instance not found for MyDerivedClass::bar2() const! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.bar2(); + return result; + } // nonVirtualButOverridden() const + + int nonVirtualButOverridden() { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__MyDerivedClass__nonVirtualButOverridden') + .asFunction(); + return func(thisCpp); + } + + static int nonVirtualInBaseButVirtualInDerived_2_calledFromC( + ffi.Pointer thisCpp, int i, int j) { + var dartInstance = + MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address] as MyDerivedClass; + if (dartInstance == null) { + print( + "Dart instance not found for MyDerivedClass::nonVirtualInBaseButVirtualInDerived(int i, int j) const! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.nonVirtualInBaseButVirtualInDerived_2(i, j); + return result; + } // paintEvent() + + paintEvent() { + final void_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(135)) + .asFunction(); + func(thisCpp); + } + + static void paintEvent_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = + MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address] as MyDerivedClass; + if (dartInstance == null) { + print( + "Dart instance not found for MyDerivedClass::paintEvent()! (${thisCpp.address})"); + throw Error(); + } + dartInstance.paintEvent(); + } // receivesDerivedPolymorphic(TestTargetNS::MyDerivedClass * der) + + int receivesDerivedPolymorphic(MyDerivedClass? der) { + final int_Func_voidstar_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(143)) + .asFunction(); + return func(thisCpp, der == null ? ffi.nullptr : der.thisCpp); + } + + static int receivesDerivedPolymorphic_calledFromC( + ffi.Pointer thisCpp, ffi.Pointer? der) { + var dartInstance = + MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address] as MyDerivedClass; + if (dartInstance == null) { + print( + "Dart instance not found for MyDerivedClass::receivesDerivedPolymorphic(TestTargetNS::MyDerivedClass * der)! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.receivesDerivedPolymorphic( + (der == null || der.address == 0) + ? null + : MyDerivedClass.fromCppPointer(der)); + return result; + } // receivesEnumFromBaseClassWithDefaultValue(int a) + + receivesEnumFromBaseClassWithDefaultValue( + {int a = MyBaseClass_MyEnum.MyEnumerator0}) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_TestTargetNS__MyDerivedClass__receivesEnumFromBaseClassWithDefaultValue_int') + .asFunction(); + func(thisCpp, a); + } // receivesProtectedEnum(TestTargetNS::MyBaseClass::ProtectedEnum p) + + int receivesProtectedEnum(int p) { + final int_Func_voidstar_int func = _dylib + .lookup>( + 'c_TestTargetNS__MyDerivedClass__receivesProtectedEnum_ProtectedEnum') + .asFunction(); + return func(thisCpp, p); + } + + static void renamedVirtual2_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = + MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address] as MyDerivedClass; + if (dartInstance == null) { + print( + "Dart instance not found for MyDerivedClass::renamedVirtual1()! (${thisCpp.address})"); + throw Error(); + } + dartInstance.renamedVirtual2(); + } // returnTemplate1() + + MyTemplate2 returnTemplate1() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__MyDerivedClass__returnTemplate1') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return MyTemplate2.fromCppPointer(result, true); + } // returnTemplate2() + + MyTemplate2 returnTemplate2() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__MyDerivedClass__returnTemplate2') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return MyTemplate2.fromCppPointer(result, false); + } + + static // returnsAnotherNamespaceEnum() + int returnsAnotherNamespaceEnum() { + final int_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__MyDerivedClass__returnsAnotherNamespaceEnum') + .asFunction(); + return func(); + } + + static // returnsAnotherNamespaceStruct() + AnotherNamespaceStruct returnsAnotherNamespaceStruct() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__MyDerivedClass__returnsAnotherNamespaceStruct') + .asFunction(); + ffi.Pointer result = func(); + return AnotherNamespaceStruct.fromCppPointer(result, true); + } // returnsConstPointer() + + MyDerivedClass returnsConstPointer() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__MyDerivedClass__returnsConstPointer') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return MyDerivedClass.fromCppPointer(result, false); + } // setVisible(bool b) + + setVisible(bool b) { + final void_Func_voidstar_bool func = _dylib + .lookup>( + cFunctionSymbolName(176)) + .asFunction(); + func(thisCpp, b ? 1 : 0); + } + + static void setVisible_calledFromC(ffi.Pointer thisCpp, int b) { + var dartInstance = + MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address] as MyDerivedClass; + if (dartInstance == null) { + print( + "Dart instance not found for MyDerivedClass::setVisible(bool b)! (${thisCpp.address})"); + throw Error(); + } + dartInstance.setVisible(b != 0); + } // show() + + show() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__MyDerivedClass__show') + .asFunction(); + func(thisCpp); + } // virtualNotInBase() const + + int virtualNotInBase() { + final int_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(181)) + .asFunction(); + return func(thisCpp); + } + + static int virtualNotInBase_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = + MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address] as MyDerivedClass; + if (dartInstance == null) { + print( + "Dart instance not found for MyDerivedClass::virtualNotInBase() const! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.virtualNotInBase(); + return result; + } + + static int virtualReceivingBool_calledFromC( + ffi.Pointer thisCpp, int b) { + var dartInstance = + MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address] as MyDerivedClass; + if (dartInstance == null) { + print( + "Dart instance not found for MyDerivedClass::virtualReceivingBool(bool b)! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.virtualReceivingBool(b != 0); + return result; + } + + static void virtualReceivingCharPtr_calledFromC( + ffi.Pointer thisCpp, ffi.Pointer? arg__1) { + var dartInstance = + MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address] as MyDerivedClass; + if (dartInstance == null) { + print( + "Dart instance not found for MyDerivedClass::virtualReceivingCharPtr(char * arg__1)! (${thisCpp.address})"); + throw Error(); + } + dartInstance.virtualReceivingCharPtr(arg__1.toString()); + } + + static int virtualReceivingInt_calledFromC( + ffi.Pointer thisCpp, int arg__1) { + var dartInstance = + MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address] as MyDerivedClass; + if (dartInstance == null) { + print( + "Dart instance not found for MyDerivedClass::virtualReceivingInt(int arg__1)! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.virtualReceivingInt(arg__1); + return result; + } + + static int virtualReceivingOptionalArgument_calledFromC( + ffi.Pointer thisCpp, int optional) { + var dartInstance = + MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address] as MyDerivedClass; + if (dartInstance == null) { + print( + "Dart instance not found for MyDerivedClass::virtualReceivingOptionalArgument(int optional)! (${thisCpp.address})"); + throw Error(); + } + final result = + dartInstance.virtualReceivingOptionalArgument(optional: optional); + return result; + } + + static int virtualReturningBool_calledFromC( + ffi.Pointer thisCpp, int b) { + var dartInstance = + MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address] as MyDerivedClass; + if (dartInstance == null) { + print( + "Dart instance not found for MyDerivedClass::virtualReturningBool(bool b)! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.virtualReturningBool(b != 0); + return result ? 1 : 0; + } + + static ffi.Pointer virtualReturningStruct_calledFromC( + ffi.Pointer thisCpp) { + var dartInstance = + MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address] as MyDerivedClass; + if (dartInstance == null) { + print( + "Dart instance not found for MyDerivedClass::virtualReturningStruct() const! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.virtualReturningStruct(); + return result.thisCpp; + } + + static ffi.Pointer virtualReturnsIntTemplate_calledFromC( + ffi.Pointer thisCpp) { + var dartInstance = + MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address] as MyDerivedClass; + if (dartInstance == null) { + print( + "Dart instance not found for MyDerivedClass::virtualReturnsIntTemplate()! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.virtualReturnsIntTemplate(); + return result.thisCpp; + } + + static void virtualWithOverload_calledFromC( + ffi.Pointer thisCpp, int i) { + var dartInstance = + MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address] as MyDerivedClass; + if (dartInstance == null) { + print( + "Dart instance not found for MyDerivedClass::virtualWithOverload(int i) const! (${thisCpp.address})"); + throw Error(); + } + dartInstance.virtualWithOverload(i); + } + + static void virtualWithOverload_2_calledFromC( + ffi.Pointer thisCpp, int i, int j) { + var dartInstance = + MyBaseClass.s_dartInstanceByCppPtr[thisCpp.address] as MyDerivedClass; + if (dartInstance == null) { + print( + "Dart instance not found for MyDerivedClass::virtualWithOverload(int i, int j) const! (${thisCpp.address})"); + throw Error(); + } + dartInstance.virtualWithOverload_2(i, j); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__MyDerivedClass__destructor') + .asFunction(); + func(thisCpp); + } + + String cFunctionSymbolName(int methodId) { + switch (methodId) { + case 51: + return "c_TestTargetNS__MyDerivedClass__bar"; + case 52: + return "c_TestTargetNS__MyDerivedClass__bar2"; + case 63: + return "c_TestTargetNS__MyDerivedClass__nonVirtualInBaseButVirtualInDerived_int_int"; + case 135: + return "c_TestTargetNS__MyDerivedClass__paintEvent"; + case 143: + return "c_TestTargetNS__MyDerivedClass__receivesDerivedPolymorphic_MyDerivedClass"; + case 86: + return "c_TestTargetNS__MyDerivedClass__renamedVirtual2"; + case 176: + return "c_TestTargetNS__MyDerivedClass__setVisible_bool"; + case 181: + return "c_TestTargetNS__MyDerivedClass__virtualNotInBase"; + case 103: + return "c_TestTargetNS__MyDerivedClass__virtualReceivingBool_bool"; + case 104: + return "c_TestTargetNS__MyDerivedClass__virtualReceivingCharPtr_char"; + case 105: + return "c_TestTargetNS__MyDerivedClass__virtualReceivingInt_int"; + case 106: + return "c_TestTargetNS__MyDerivedClass__virtualReceivingOptionalArgument_int"; + case 107: + return "c_TestTargetNS__MyDerivedClass__virtualReturningBool_bool"; + case 109: + return "c_TestTargetNS__MyDerivedClass__virtualReturningStruct"; + case 110: + return "c_TestTargetNS__MyDerivedClass__virtualReturnsIntTemplate"; + case 112: + return "c_TestTargetNS__MyDerivedClass__virtualWithOverload_int"; + case 113: + return "c_TestTargetNS__MyDerivedClass__virtualWithOverload_int_int"; + } + return super.cFunctionSymbolName(methodId); + } + + static String methodNameFromId(int methodId) { + switch (methodId) { + case 51: + return "bar"; + case 52: + return "bar2"; + case 63: + return "nonVirtualInBaseButVirtualInDerived_2"; + case 135: + return "paintEvent"; + case 143: + return "receivesDerivedPolymorphic"; + case 86: + return "renamedVirtual2"; + case 176: + return "setVisible"; + case 181: + return "virtualNotInBase"; + case 103: + return "virtualReceivingBool"; + case 104: + return "virtualReceivingCharPtr"; + case 105: + return "virtualReceivingInt"; + case 106: + return "virtualReceivingOptionalArgument"; + case 107: + return "virtualReturningBool"; + case 109: + return "virtualReturningStruct"; + case 110: + return "virtualReturnsIntTemplate"; + case 112: + return "virtualWithOverload"; + case 113: + return "virtualWithOverload_2"; + } + throw Error(); + } + + void registerCallbacks() { + assert(thisCpp != null); + final RegisterMethodIsReimplementedCallback registerCallback = _dylib + .lookup>( + 'c_TestTargetNS__MyDerivedClass__registerVirtualMethodCallback') + .asFunction(); + const callbackExcept51 = 0; + final callback51 = ffi.Pointer.fromFunction( + MyDerivedClass.bar_calledFromC, callbackExcept51); + registerCallback(thisCpp, callback51, 51); + const callbackExcept52 = 0; + final callback52 = ffi.Pointer.fromFunction( + MyBaseClass.bar2_calledFromC, callbackExcept52); + registerCallback(thisCpp, callback52, 52); + const callbackExcept63 = 0; + final callback63 = + ffi.Pointer.fromFunction( + MyBaseClass.nonVirtualInBaseButVirtualInDerived_2_calledFromC, + callbackExcept63); + registerCallback(thisCpp, callback63, 63); + final callback135 = ffi.Pointer.fromFunction( + MyDerivedClass.paintEvent_calledFromC); + registerCallback(thisCpp, callback135, 135); + const callbackExcept143 = 0; + final callback143 = + ffi.Pointer.fromFunction( + MyDerivedClass.receivesDerivedPolymorphic_calledFromC, + callbackExcept143); + registerCallback(thisCpp, callback143, 143); + final callback86 = ffi.Pointer.fromFunction( + MyBaseClass.renamedVirtual2_calledFromC); + registerCallback(thisCpp, callback86, 86); + final callback176 = + ffi.Pointer.fromFunction( + MyDerivedClass.setVisible_calledFromC); + registerCallback(thisCpp, callback176, 176); + const callbackExcept181 = 0; + final callback181 = ffi.Pointer.fromFunction( + MyDerivedClass.virtualNotInBase_calledFromC, callbackExcept181); + registerCallback(thisCpp, callback181, 181); + const callbackExcept103 = 0; + final callback103 = + ffi.Pointer.fromFunction( + MyBaseClass.virtualReceivingBool_calledFromC, callbackExcept103); + registerCallback(thisCpp, callback103, 103); + final callback104 = ffi.Pointer.fromFunction( + MyBaseClass.virtualReceivingCharPtr_calledFromC); + registerCallback(thisCpp, callback104, 104); + const callbackExcept105 = 0; + final callback105 = + ffi.Pointer.fromFunction( + MyBaseClass.virtualReceivingInt_calledFromC, callbackExcept105); + registerCallback(thisCpp, callback105, 105); + const callbackExcept106 = 0; + final callback106 = + ffi.Pointer.fromFunction( + MyBaseClass.virtualReceivingOptionalArgument_calledFromC, + callbackExcept106); + registerCallback(thisCpp, callback106, 106); + const callbackExcept107 = 0; + final callback107 = + ffi.Pointer.fromFunction( + MyBaseClass.virtualReturningBool_calledFromC, callbackExcept107); + registerCallback(thisCpp, callback107, 107); + final callback109 = ffi.Pointer.fromFunction( + MyBaseClass.virtualReturningStruct_calledFromC); + registerCallback(thisCpp, callback109, 109); + final callback110 = ffi.Pointer.fromFunction( + MyBaseClass.virtualReturnsIntTemplate_calledFromC); + registerCallback(thisCpp, callback110, 110); + final callback112 = + ffi.Pointer.fromFunction( + MyBaseClass.virtualWithOverload_calledFromC); + registerCallback(thisCpp, callback112, 112); + final callback113 = + ffi.Pointer.fromFunction( + MyBaseClass.virtualWithOverload_2_calledFromC); + registerCallback(thisCpp, callback113, 113); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/MyObject.dart b/tests/generated/TestBindings/dart/lib/src/MyObject.dart new file mode 100644 index 0000000..ad9afbc --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/MyObject.dart @@ -0,0 +1,347 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; + +class MyObject extends QObject { + MyObject.fromCppPointer(var cppPointer, [var needsAutoDelete = false]) + : super.fromCppPointer(cppPointer, needsAutoDelete) {} + MyObject.init() : super.init() {} + factory MyObject.fromCache(var cppPointer, [needsAutoDelete = false]) { + if (QObject.isCached(cppPointer)) { + var instance = QObject.s_dartInstanceByCppPtr[cppPointer.address]; + if (instance != null) return instance as MyObject; + } + return MyObject.fromCppPointer(cppPointer, needsAutoDelete); + } + String getFinalizerName() { + return "c_MyObject_Finalizer"; + } //MyObject(QObject * parent) + + MyObject({QObject? parent}) : super.init() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_MyObject__constructor_QObject') + .asFunction(); + thisCpp = func(parent == null ? ffi.nullptr : parent.thisCpp); + QObject.s_dartInstanceByCppPtr[thisCpp.address] = this; + registerCallbacks(); + } + static void customEvent_calledFromC( + ffi.Pointer thisCpp, ffi.Pointer? event) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as MyObject; + if (dartInstance == null) { + print( + "Dart instance not found for MyObject::customEvent(QEvent * event)! (${thisCpp.address})"); + throw Error(); + } + dartInstance.customEvent((event == null || event.address == 0) + ? null + : QEvent.fromCppPointer(event)); + } + + static int event_calledFromC( + ffi.Pointer thisCpp, ffi.Pointer? event) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as MyObject; + if (dartInstance == null) { + print( + "Dart instance not found for MyObject::event(QEvent * event)! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.event((event == null || event.address == 0) + ? null + : QEvent.fromCppPointer(event)); + return result ? 1 : 0; + } + + static int eventFilter_calledFromC(ffi.Pointer thisCpp, + ffi.Pointer? watched, ffi.Pointer? event) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as MyObject; + if (dartInstance == null) { + print( + "Dart instance not found for MyObject::eventFilter(QObject * watched, QEvent * event)! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.eventFilter( + (watched == null || watched.address == 0) + ? null + : QObject.fromCppPointer(watched), + (event == null || event.address == 0) + ? null + : QEvent.fromCppPointer(event)); + return result ? 1 : 0; + } // pureVirtual() + + pureVirtual() { + final void_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(1166)) + .asFunction(); + func(thisCpp); + } + + static void pureVirtual_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as MyObject; + if (dartInstance == null) { + print( + "Dart instance not found for MyObject::pureVirtual()! (${thisCpp.address})"); + throw Error(); + } + dartInstance.pureVirtual(); + } // receivesEnumClassWithDefaultArg(AnotherNamespace::MyNamespacedEnumClass foo) + + receivesEnumClassWithDefaultArg( + {int foo = AnotherNamespace_MyNamespacedEnumClass.ValueFoo1}) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_MyObject__receivesEnumClassWithDefaultArg_MyNamespacedEnumClass') + .asFunction(); + func(thisCpp, foo); + } // receivesEnumClassWithDefaultArg(MyEnumClass foo) + + receivesEnumClassWithDefaultArg_2({int foo = MyEnumClass.ValueFoo}) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_MyObject__receivesEnumClassWithDefaultArg_MyEnumClass') + .asFunction(); + func(thisCpp, foo); + } // returnsEnumClass() + + int returnsEnumClass() { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_MyObject__returnsEnumClass') + .asFunction(); + return func(thisCpp); + } + + static // tr(const char * s, const char * c, int n) + QString tr(String? s, String? c, int n) { + final voidstar_Func_string_string_int func = _dylib + .lookup>( + 'c_static_MyObject__tr_char_char_int') + .asFunction(); + ffi.Pointer result = func( + s?.toNativeUtf8() ?? ffi.nullptr, c?.toNativeUtf8() ?? ffi.nullptr, n); + return QString.fromCppPointer(result, true); + } // valueChanged(int arg__1) + + valueChanged(int arg__1) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_MyObject__valueChanged_int') + .asFunction(); + func(thisCpp, arg__1); + } + + void onValueChanged(Function callback, {QObject? context}) { + final SignalHandler func = _dylib + .lookup>( + 'c_MyObject__onValueChanged_int') + .asFunction(); + final dartCallback = + ffi.Pointer.fromFunction)>( + onValueChanged_callback); + final callbackMethod = onValueChanged_callback; + var handlers = signalHandlerersBySignal[callbackMethod] ?? []; + handlers.add(callback); + signalHandlerersBySignal[callbackMethod] = handlers; + ffi.Pointer contextPtr = + context == null ? ffi.nullptr : context.thisCpp; + func(thisCpp, contextPtr, dartCallback); + } + + static void onValueChanged_callback(ffi.Pointer thisCpp) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as MyObject; + final signalHandlers = + dartInstance.signalHandlerersBySignal[onValueChanged_callback] ?? []; + for (var signalHandler in signalHandlers) { + signalHandler(); + } + } // virtualFunc() + + int virtualFunc() { + final int_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(1181)) + .asFunction(); + return func(thisCpp); + } + + static int virtualFunc_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as MyObject; + if (dartInstance == null) { + print( + "Dart instance not found for MyObject::virtualFunc()! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.virtualFunc(); + return result; + } // virtualMethodReturningConstChar() const + + String virtualMethodReturningConstChar() { + final string_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(1182)) + .asFunction(); + ffi.Pointer result = func(thisCpp); + return result.toDartString(); + } + + static ffi.Pointer virtualMethodReturningConstChar_calledFromC( + ffi.Pointer thisCpp) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as MyObject; + if (dartInstance == null) { + print( + "Dart instance not found for MyObject::virtualMethodReturningConstChar() const! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.virtualMethodReturningConstChar(); + return result.toNativeUtf8(); + } // virtualReceivingQString(const QString & str) + + virtualReceivingQString(String str) { + final void_Func_voidstar_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(1183)) + .asFunction(); + func(thisCpp, str.toNativeUtf8()); + } + + static void virtualReceivingQString_calledFromC( + ffi.Pointer thisCpp, ffi.Pointer str) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as MyObject; + if (dartInstance == null) { + print( + "Dart instance not found for MyObject::virtualReceivingQString(const QString & str)! (${thisCpp.address})"); + throw Error(); + } + dartInstance + .virtualReceivingQString(QString.fromCppPointer(str).toDartString()); + } // virtualReturningInt() const + + int virtualReturningInt() { + final int_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(1184)) + .asFunction(); + return func(thisCpp); + } + + static int virtualReturningInt_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as MyObject; + if (dartInstance == null) { + print( + "Dart instance not found for MyObject::virtualReturningInt() const! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.virtualReturningInt(); + return result; + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_MyObject__destructor') + .asFunction(); + func(thisCpp); + } + + String cFunctionSymbolName(int methodId) { + switch (methodId) { + case 481: + return "c_MyObject__customEvent_QEvent"; + case 490: + return "c_MyObject__event_QEvent"; + case 491: + return "c_MyObject__eventFilter_QObject_QEvent"; + case 1166: + return "c_MyObject__pureVirtual"; + case 1181: + return "c_MyObject__virtualFunc"; + case 1182: + return "c_MyObject__virtualMethodReturningConstChar"; + case 1183: + return "c_MyObject__virtualReceivingQString_QString"; + case 1184: + return "c_MyObject__virtualReturningInt"; + } + return super.cFunctionSymbolName(methodId); + } + + static String methodNameFromId(int methodId) { + switch (methodId) { + case 481: + return "customEvent"; + case 490: + return "event"; + case 491: + return "eventFilter"; + case 1166: + return "pureVirtual"; + case 1181: + return "virtualFunc"; + case 1182: + return "virtualMethodReturningConstChar"; + case 1183: + return "virtualReceivingQString"; + case 1184: + return "virtualReturningInt"; + } + throw Error(); + } + + void registerCallbacks() { + assert(thisCpp != null); + final RegisterMethodIsReimplementedCallback registerCallback = _dylib + .lookup>( + 'c_MyObject__registerVirtualMethodCallback') + .asFunction(); + final callback481 = + ffi.Pointer.fromFunction( + QObject.customEvent_calledFromC); + registerCallback(thisCpp, callback481, 481); + const callbackExcept490 = 0; + final callback490 = + ffi.Pointer.fromFunction( + QObject.event_calledFromC, callbackExcept490); + registerCallback(thisCpp, callback490, 490); + const callbackExcept491 = 0; + final callback491 = + ffi.Pointer.fromFunction( + QObject.eventFilter_calledFromC, callbackExcept491); + registerCallback(thisCpp, callback491, 491); + final callback1166 = ffi.Pointer.fromFunction( + MyObject.pureVirtual_calledFromC); + registerCallback(thisCpp, callback1166, 1166); + const callbackExcept1181 = 0; + final callback1181 = ffi.Pointer.fromFunction( + MyObject.virtualFunc_calledFromC, callbackExcept1181); + registerCallback(thisCpp, callback1181, 1181); + final callback1182 = ffi.Pointer.fromFunction( + MyObject.virtualMethodReturningConstChar_calledFromC); + registerCallback(thisCpp, callback1182, 1182); + final callback1183 = + ffi.Pointer.fromFunction( + MyObject.virtualReceivingQString_calledFromC); + registerCallback(thisCpp, callback1183, 1183); + const callbackExcept1184 = 0; + final callback1184 = ffi.Pointer.fromFunction( + MyObject.virtualReturningInt_calledFromC, callbackExcept1184); + registerCallback(thisCpp, callback1184, 1184); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/MyTemplate.dart b/tests/generated/TestBindings/dart/lib/src/MyTemplate.dart new file mode 100644 index 0000000..5c51031 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/MyTemplate.dart @@ -0,0 +1,277 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class MyTemplate implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = true; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory MyTemplate.fromCache(var cppPointer, [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + MyTemplate.fromCppPointer(cppPointer, needsAutoDelete)) + as MyTemplate; + } + MyTemplate.fromCppPointer(var cppPointer, [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + MyTemplate.init() {} + String getCFunctionName(int id) { + if (this is MyTemplate) { + switch (id) { + case 1136: + return "c_MyTemplate_T_int_T___constructor"; + break; + case 1138: + return "c_MyTemplate_T_int_T___receivesT_int"; + break; + case 1139: + return "c_MyTemplate_T_int_T___receivesTemplate_MyTemplate_T"; + break; + case 1140: + return "c_MyTemplate_T_int_T___returnInt"; + break; + case 1141: + return "c_MyTemplate_T_int_T___returnTemplate2"; + break; + case 1142: + return "c_MyTemplate_T_int_T___returnTemplate3"; + break; + case 1143: + return "c_MyTemplate_T_int_T___returnTemplate4"; + break; + case 1144: + return "c_MyTemplate_T_int_T___returnsT"; + break; + case 1145: + return "c_MyTemplate_T_int_T___returnsTemplate"; + break; + } + } + if (this is MyTemplate) { + switch (id) { + case 1136: + return "c_MyTemplate_T_double_T___constructor"; + break; + case 1138: + return "c_MyTemplate_T_double_T___receivesT_double"; + break; + case 1139: + return "c_MyTemplate_T_double_T___receivesTemplate_MyTemplate_T"; + break; + case 1140: + return "c_MyTemplate_T_double_T___returnInt"; + break; + case 1141: + return "c_MyTemplate_T_double_T___returnTemplate2"; + break; + case 1142: + return "c_MyTemplate_T_double_T___returnTemplate3"; + break; + case 1143: + return "c_MyTemplate_T_double_T___returnTemplate4"; + break; + case 1144: + return "c_MyTemplate_T_double_T___returnsT"; + break; + case 1145: + return "c_MyTemplate_T_double_T___returnsTemplate"; + break; + } + } + if (this is MyTemplate) { + switch (id) { + case 1136: + return "c_MyTemplate_T_EmptyStruct_T___constructor"; + break; + case 1138: + return "c_MyTemplate_T_EmptyStruct_T___receivesT_EmptyStruct"; + break; + case 1139: + return "c_MyTemplate_T_EmptyStruct_T___receivesTemplate_MyTemplate_T"; + break; + case 1140: + return "c_MyTemplate_T_EmptyStruct_T___returnInt"; + break; + case 1141: + return "c_MyTemplate_T_EmptyStruct_T___returnTemplate2"; + break; + case 1142: + return "c_MyTemplate_T_EmptyStruct_T___returnTemplate3"; + break; + case 1143: + return "c_MyTemplate_T_EmptyStruct_T___returnTemplate4"; + break; + case 1144: + return "c_MyTemplate_T_EmptyStruct_T___returnsT"; + break; + case 1145: + return "c_MyTemplate_T_EmptyStruct_T___returnsTemplate"; + break; + } + } + return ""; + } + + String getFinalizerName() { + if (this is MyTemplate) { + return "c_MyTemplate_T_int_T__Finalizer"; + } + if (this is MyTemplate) { + return "c_MyTemplate_T_double_T__Finalizer"; + } + if (this is MyTemplate) { + return "c_MyTemplate_T_EmptyStruct_T__Finalizer"; + } + print( + "ERROR: Couldn't find finalizerName for" + this.runtimeType.toString()); + return ""; + } //MyTemplate() + + MyTemplate() { + final voidstar_Func_void func = _dylib + .lookup>( + '${getCFunctionName(1136)}') + .asFunction(); + thisCpp = func(); + MyTemplate.s_dartInstanceByCppPtr[thisCpp.address] = this; + } // receivesT(T arg__1) + int receivesT(T arg__1) { + if (this is MyTemplate) { + final int_Func_voidstar_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1138)}') + .asFunction(); + return func( + thisCpp, + (arg__1 as EmptyStruct) == null + ? ffi.nullptr + : (arg__1 as EmptyStruct).thisCpp); + } + if (this is MyTemplate) { + final int_Func_voidstar_double func = _dylib + .lookup>( + '${getCFunctionName(1138)}') + .asFunction(); + return func(thisCpp, (arg__1 as double)); + } + if (this is MyTemplate) { + final int_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(1138)}') + .asFunction(); + return func(thisCpp, (arg__1 as int)); + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } // receivesTemplate(MyTemplate arg__1) + + int receivesTemplate(MyTemplate arg__1) { + final int_Func_voidstar_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1139)}') + .asFunction(); + return func(thisCpp, arg__1 == null ? ffi.nullptr : arg__1.thisCpp); + } // returnInt() const + + int returnInt() { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1140)}') + .asFunction(); + return func(thisCpp); + } // returnTemplate2() + + MyTemplate returnTemplate2() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1141)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return MyTemplate.fromCppPointer(result, true); + } // returnTemplate3() + + MyTemplate returnTemplate3() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1142)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return MyTemplate.fromCppPointer(result, true); + } // returnTemplate4() + + MyTemplate returnTemplate4() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1143)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return MyTemplate.fromCppPointer(result, true); + } // returnsT() + + T returnsT() { + if (this is MyTemplate) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1144)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (EmptyStruct.fromCppPointer(result, true) as T); + } + if (this is MyTemplate) { + final double_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1144)}') + .asFunction(); + return (func(thisCpp) as T); + } + if (this is MyTemplate) { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1144)}') + .asFunction(); + return (func(thisCpp) as T); + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(-2)}') + .asFunction(); + func(thisCpp); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/MyTemplate2.dart b/tests/generated/TestBindings/dart/lib/src/MyTemplate2.dart new file mode 100644 index 0000000..4745530 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/MyTemplate2.dart @@ -0,0 +1,134 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class MyTemplate2 implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = true; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory MyTemplate2.fromCache(var cppPointer, [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + MyTemplate2.fromCppPointer(cppPointer, needsAutoDelete)) + as MyTemplate2; + } + MyTemplate2.fromCppPointer(var cppPointer, [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + MyTemplate2.init() {} + String getCFunctionName(int id) { + if (this is MyTemplate2) { + switch (id) { + case 1130: + return "c_MyTemplate2_T_NonCopiable_T___constructor"; + break; + case 1132: + return "c_MyTemplate2_T_NonCopiable_T___assignsT"; + break; + case 1133: + return "c_MyTemplate2_T_NonCopiable_T___count"; + break; + case 1134: + return "c_MyTemplate2_T_NonCopiable_T___receivesT_NonCopiable"; + break; + case 1135: + return "c_MyTemplate2_T_NonCopiable_T___returnTemplate1"; + break; + } + } + return ""; + } + + String getFinalizerName() { + if (this is MyTemplate2) { + return "c_MyTemplate2_T_NonCopiable_T__Finalizer"; + } + print( + "ERROR: Couldn't find finalizerName for" + this.runtimeType.toString()); + return ""; + } //MyTemplate2() + + MyTemplate2() { + final voidstar_Func_void func = _dylib + .lookup>( + '${getCFunctionName(1130)}') + .asFunction(); + thisCpp = func(); + MyTemplate2.s_dartInstanceByCppPtr[thisCpp.address] = this; + } // assignsT() + assignsT() { + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1132)}') + .asFunction(); + func(thisCpp); + } // count() const + + int count() { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1133)}') + .asFunction(); + return func(thisCpp); + } // receivesT(T arg__1) + + receivesT(T arg__1) { + if (this is MyTemplate2) { + final void_Func_voidstar_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1134)}') + .asFunction(); + func( + thisCpp, + (arg__1 as NonCopiable) == null + ? ffi.nullptr + : (arg__1 as NonCopiable).thisCpp); + } + } // returnTemplate1() + + MyTemplate2 returnTemplate1() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1135)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return MyTemplate2.fromCppPointer(result, true); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(-2)}') + .asFunction(); + func(thisCpp); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/MyTemplateWithTwoArgs.dart b/tests/generated/TestBindings/dart/lib/src/MyTemplateWithTwoArgs.dart new file mode 100644 index 0000000..9f25e4c --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/MyTemplateWithTwoArgs.dart @@ -0,0 +1,96 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class MyTemplateWithTwoArgs implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = true; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory MyTemplateWithTwoArgs.fromCache(var cppPointer, + [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + MyTemplateWithTwoArgs.fromCppPointer(cppPointer, needsAutoDelete)) + as MyTemplateWithTwoArgs; + } + MyTemplateWithTwoArgs.fromCppPointer(var cppPointer, + [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + MyTemplateWithTwoArgs.init() {} + String getCFunctionName(int id) { + if (this is MyTemplateWithTwoArgs) { + switch (id) { + case 1128: + return "c_MyTemplateWithTwoArgs_T_int_double_T___constructor"; + break; + case 1129: + return "c_MyTemplateWithTwoArgs_T_int_double_T___returnInt"; + break; + } + } + return ""; + } + + String getFinalizerName() { + if (this is MyTemplateWithTwoArgs) { + return "c_MyTemplateWithTwoArgs_T_int_double_T__Finalizer"; + } + print( + "ERROR: Couldn't find finalizerName for" + this.runtimeType.toString()); + return ""; + } //MyTemplateWithTwoArgs() + + MyTemplateWithTwoArgs() { + final voidstar_Func_void func = _dylib + .lookup>( + '${getCFunctionName(1128)}') + .asFunction(); + thisCpp = func(); + MyTemplateWithTwoArgs.s_dartInstanceByCppPtr[thisCpp.address] = this; + } // returnInt() const + int returnInt() { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1129)}') + .asFunction(); + return func(thisCpp); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(-2)}') + .asFunction(); + func(thisCpp); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/NameClashingNS1.dart b/tests/generated/TestBindings/dart/lib/src/NameClashingNS1.dart new file mode 100644 index 0000000..fb328d3 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/NameClashingNS1.dart @@ -0,0 +1,9 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; diff --git a/tests/generated/TestBindings/dart/lib/src/NameClashingNS2.dart b/tests/generated/TestBindings/dart/lib/src/NameClashingNS2.dart new file mode 100644 index 0000000..fb328d3 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/NameClashingNS2.dart @@ -0,0 +1,9 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; diff --git a/tests/generated/TestBindings/dart/lib/src/NonCopiable.dart b/tests/generated/TestBindings/dart/lib/src/NonCopiable.dart new file mode 100644 index 0000000..01302c5 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/NonCopiable.dart @@ -0,0 +1,74 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class NonCopiable implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = true; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory NonCopiable.fromCache(var cppPointer, [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + NonCopiable.fromCppPointer(cppPointer, needsAutoDelete)) as NonCopiable; + } + NonCopiable.fromCppPointer(var cppPointer, [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + NonCopiable.init() {} + String getFinalizerName() { + return "c_NonCopiable_Finalizer"; + } //NonCopiable() + + NonCopiable() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_NonCopiable__constructor') + .asFunction(); + thisCpp = func(); + NonCopiable.s_dartInstanceByCppPtr[thisCpp.address] = this; + } // count() const + int count() { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_NonCopiable__count') + .asFunction(); + return func(thisCpp); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_NonCopiable__destructor') + .asFunction(); + func(thisCpp); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/POD.dart b/tests/generated/TestBindings/dart/lib/src/POD.dart new file mode 100644 index 0000000..a01808d --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/POD.dart @@ -0,0 +1,320 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class POD implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = true; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory POD.fromCache(var cppPointer, [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + POD.fromCppPointer(cppPointer, needsAutoDelete)) as POD; + } + POD.fromCppPointer(var cppPointer, [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + POD.init() {} + String getFinalizerName() { + return "c_TestTargetNS__POD_Finalizer"; + } + + int get v1 { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__POD___get_v1') + .asFunction(); + return func(thisCpp); + } + + set v1(int v1_) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_TestTargetNS__POD___set_v1_int') + .asFunction(); + func(thisCpp, v1_); + } + + int get v2 { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__POD___get_v2') + .asFunction(); + return func(thisCpp); + } + + set v2(int v2_) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_TestTargetNS__POD___set_v2_int') + .asFunction(); + func(thisCpp, v2_); + } + + int get v3 { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__POD___get_v3') + .asFunction(); + return func(thisCpp); + } + + set v3(int v3_) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_TestTargetNS__POD___set_v3_int') + .asFunction(); + func(thisCpp, v3_); + } + + int get v4_const { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__POD___get_v4_const') + .asFunction(); + return func(thisCpp); + } //POD() + + POD() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_TestTargetNS__POD__constructor') + .asFunction(); + thisCpp = func(); + POD.s_dartInstanceByCppPtr[thisCpp.address] = this; + } //POD(int a, int b, int c, int d) + POD.ctor2(int a, int b, int c, int d) { + final voidstar_Func_int_int_int_int func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_ffi_Int32_ffi_Int32_ffi_Int32_ffi_Int32_FFI>>( + 'c_TestTargetNS__POD__constructor_int_int_int_int') + .asFunction(); + thisCpp = func(a, b, c, d); + POD.s_dartInstanceByCppPtr[thisCpp.address] = this; + } // calculate() const + int calculate() { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__POD__calculate') + .asFunction(); + return func(thisCpp); + } + + static // calculateStatic() + int calculateStatic() { + final int_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__POD__calculateStatic') + .asFunction(); + return func(); + } + + static // doStuffOnMyClass(TestTargetNS::MyBaseClass * myarg) + int doStuffOnMyClass(MyBaseClass? myarg) { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_static_TestTargetNS__POD__doStuffOnMyClass_MyBaseClass') + .asFunction(); + return func(myarg == null ? ffi.nullptr : myarg.thisCpp); + } // intByConstRef() const + + int intByConstRef() { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__POD__intByConstRef') + .asFunction(); + return func(thisCpp); + } + + static // receivesConstPointerToPODs(const TestTargetNS::POD * ptrPod1, const TestTargetNS::POD * ptrPod2) + int receivesConstPointerToPODs(POD? ptrPod1, POD? ptrPod2) { + final int_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_static_TestTargetNS__POD__receivesConstPointerToPODs_POD_POD') + .asFunction(); + return func(ptrPod1 == null ? ffi.nullptr : ptrPod1.thisCpp, + ptrPod2 == null ? ffi.nullptr : ptrPod2.thisCpp); + } + + static // receivesConstRefPODs(const TestTargetNS::POD & pod1, const TestTargetNS::POD & pod2) + int receivesConstRefPODs(POD pod1, POD pod2) { + final int_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_static_TestTargetNS__POD__receivesConstRefPODs_POD_POD') + .asFunction(); + return func(pod1 == null ? ffi.nullptr : pod1.thisCpp, + pod2 == null ? ffi.nullptr : pod2.thisCpp); + } // receivesNamespaceEnum(int v) + + receivesNamespaceEnum( + {int v = + AnotherNamespace_NamespaceLevelEnum.NamespaceLevelEnum_value1 + 1}) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_TestTargetNS__POD__receivesNamespaceEnum_int') + .asFunction(); + func(thisCpp, v); + } // receivesNamespaceEnum1(AnotherNamespace::NamespaceLevelEnum arg__1) + + receivesNamespaceEnum1( + {int arg__1 = + AnotherNamespace_NamespaceLevelEnum.NamespaceLevelEnum_value1}) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_TestTargetNS__POD__receivesNamespaceEnum1_NamespaceLevelEnum') + .asFunction(); + func(thisCpp, arg__1); + } + + static // receivesPODs(TestTargetNS::POD pod1, TestTargetNS::POD pod2) + int receivesPODs(POD pod1, POD pod2) { + final int_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_static_TestTargetNS__POD__receivesPODs_POD_POD') + .asFunction(); + return func(pod1 == null ? ffi.nullptr : pod1.thisCpp, + pod2 == null ? ffi.nullptr : pod2.thisCpp); + } + + static // receivesPointerToPODs(TestTargetNS::POD * ptrPod1, TestTargetNS::POD * ptrPod2) + int receivesPointerToPODs(POD? ptrPod1, POD? ptrPod2) { + final int_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_static_TestTargetNS__POD__receivesPointerToPODs_POD_POD') + .asFunction(); + return func(ptrPod1 == null ? ffi.nullptr : ptrPod1.thisCpp, + ptrPod2 == null ? ffi.nullptr : ptrPod2.thisCpp); + } + + static // receivesRefPODs(TestTargetNS::POD & pod1, TestTargetNS::POD & pod2) + int receivesRefPODs(POD pod1, POD pod2) { + final int_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_static_TestTargetNS__POD__receivesRefPODs_POD_POD') + .asFunction(); + return func(pod1 == null ? ffi.nullptr : pod1.thisCpp, + pod2 == null ? ffi.nullptr : pod2.thisCpp); + } // receivesReservedDartKeyword(int var) + + receivesReservedDartKeyword(int var_dart) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_TestTargetNS__POD__receivesReservedDartKeyword_int') + .asFunction(); + func(thisCpp, var_dart); + } + + static // returnsChar() + String returnsChar() { + final char_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__POD__returnsChar') + .asFunction(); + return String.fromCharCode(func()); + } + + static // returnsConstChar() + String returnsConstChar() { + final char_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__POD__returnsConstChar') + .asFunction(); + return String.fromCharCode(func()); + } + + static // returnsConstReferenceToPOD() + POD returnsConstReferenceToPOD() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__POD__returnsConstReferenceToPOD') + .asFunction(); + ffi.Pointer result = func(); + return POD.fromCppPointer(result, false); + } + + static // returnsPOD() + POD returnsPOD() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__POD__returnsPOD') + .asFunction(); + ffi.Pointer result = func(); + return POD.fromCppPointer(result, true); + } + + static // returnsPointerToPOD() + POD returnsPointerToPOD() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__POD__returnsPointerToPOD') + .asFunction(); + ffi.Pointer result = func(); + return POD.fromCppPointer(result, false); + } + + static // returnsPointerToPolymorphic() + MyBaseClass returnsPointerToPolymorphic() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__POD__returnsPointerToPolymorphic') + .asFunction(); + ffi.Pointer result = func(); + return MyBaseClass.fromCppPointer(result, false); + } + + static // returnsReferenceToPOD() + POD returnsReferenceToPOD() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__POD__returnsReferenceToPOD') + .asFunction(); + ffi.Pointer result = func(); + return POD.fromCppPointer(result, false); + } // withDefaultAarg(int v) + + withDefaultAarg({int v = 2}) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_TestTargetNS__POD__withDefaultAarg_int') + .asFunction(); + func(thisCpp, v); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__POD__destructor') + .asFunction(); + func(thisCpp); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/PureAbstract.dart b/tests/generated/TestBindings/dart/lib/src/PureAbstract.dart new file mode 100644 index 0000000..250a494 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/PureAbstract.dart @@ -0,0 +1,270 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class PureAbstract implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = false; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory PureAbstract.fromCache(var cppPointer, [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + PureAbstract.fromCppPointer(cppPointer, needsAutoDelete)) + as PureAbstract; + } + PureAbstract.fromCppPointer(var cppPointer, [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + PureAbstract.init() {} + String getFinalizerName() { + return "c_TestTargetNS__PureAbstract_Finalizer"; + } + + static int get s_instanceCount { + final int_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__PureAbstract___get_s_instanceCount') + .asFunction(); + return func(); + } + + static set s_instanceCount(int s_instanceCount_) { + final void_Func_int func = _dylib + .lookup>( + 'c_static_TestTargetNS__PureAbstract___set_s_instanceCount_int') + .asFunction(); + func(s_instanceCount_); + } //PureAbstract() + + PureAbstract() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_TestTargetNS__PureAbstract__constructor') + .asFunction(); + thisCpp = func(); + PureAbstract.s_dartInstanceByCppPtr[thisCpp.address] = this; + registerCallbacks(); + } // callVirtualReceivingPointer(SimpleStruct * s) + int callVirtualReceivingPointer(SimpleStruct? s) { + final int_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__PureAbstract__callVirtualReceivingPointer_SimpleStruct') + .asFunction(); + return func(thisCpp, s == null ? ffi.nullptr : s.thisCpp); + } // flagsWithDefaultArgs(QFlags options) + + flagsWithDefaultArgs({int options = 0}) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_TestTargetNS__PureAbstract__flagsWithDefaultArgs_NamespaceLevelEnums') + .asFunction(); + func(thisCpp, options); + } // foo() + + int foo() { + final int_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(13)) + .asFunction(); + return func(thisCpp); + } + + static int foo_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = PureAbstract.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for PureAbstract::foo()! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.foo(); + return result; + } // renamedPureVirtual() + + renamedPureVirtual1() { + final void_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(14)) + .asFunction(); + func(thisCpp); + } + + static void renamedPureVirtual1_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = PureAbstract.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for PureAbstract::renamedPureVirtual()! (${thisCpp.address})"); + throw Error(); + } + dartInstance.renamedPureVirtual1(); + } + + static // renamedStatic() + renamedStatic1() { + final void_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__PureAbstract__renamedStatic1') + .asFunction(); + func(); + } // returnsInt() const + + int returnsInt() { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__PureAbstract__returnsInt') + .asFunction(); + return func(thisCpp); + } // unnamedOverriddenDefaultArgCase(int myarg) + + unnamedOverriddenDefaultArgCase({int myarg = 0}) { + final void_Func_voidstar_int func = _dylib + .lookup>( + cFunctionSymbolName(17)) + .asFunction(); + func(thisCpp, myarg); + } + + static void unnamedOverriddenDefaultArgCase_calledFromC( + ffi.Pointer thisCpp, int myarg) { + var dartInstance = PureAbstract.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for PureAbstract::unnamedOverriddenDefaultArgCase(int myarg)! (${thisCpp.address})"); + throw Error(); + } + dartInstance.unnamedOverriddenDefaultArgCase(myarg: myarg); + } // virtualReceivingPointer(SimpleStruct * s) + + int virtualReceivingPointer(SimpleStruct? s) { + final int_Func_voidstar_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(18)) + .asFunction(); + return func(thisCpp, s == null ? ffi.nullptr : s.thisCpp); + } + + static int virtualReceivingPointer_calledFromC( + ffi.Pointer thisCpp, ffi.Pointer? s) { + var dartInstance = PureAbstract.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for PureAbstract::virtualReceivingPointer(SimpleStruct * s)! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.virtualReceivingPointer( + (s == null || s.address == 0) ? null : SimpleStruct.fromCppPointer(s)); + return result; + } // voidPureAbstract() + + voidPureAbstract() { + final void_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(19)) + .asFunction(); + func(thisCpp); + } + + static void voidPureAbstract_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = PureAbstract.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for PureAbstract::voidPureAbstract()! (${thisCpp.address})"); + throw Error(); + } + dartInstance.voidPureAbstract(); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__PureAbstract__destructor') + .asFunction(); + func(thisCpp); + } + + String cFunctionSymbolName(int methodId) { + switch (methodId) { + case 13: + return "c_TestTargetNS__PureAbstract__foo"; + case 14: + return "c_TestTargetNS__PureAbstract__renamedPureVirtual1"; + case 17: + return "c_TestTargetNS__PureAbstract__unnamedOverriddenDefaultArgCase_int"; + case 18: + return "c_TestTargetNS__PureAbstract__virtualReceivingPointer_SimpleStruct"; + case 19: + return "c_TestTargetNS__PureAbstract__voidPureAbstract"; + } + return ""; + } + + static String methodNameFromId(int methodId) { + switch (methodId) { + case 13: + return "foo"; + case 14: + return "renamedPureVirtual1"; + case 17: + return "unnamedOverriddenDefaultArgCase"; + case 18: + return "virtualReceivingPointer"; + case 19: + return "voidPureAbstract"; + } + throw Error(); + } + + void registerCallbacks() { + assert(thisCpp != null); + final RegisterMethodIsReimplementedCallback registerCallback = _dylib + .lookup>( + 'c_TestTargetNS__PureAbstract__registerVirtualMethodCallback') + .asFunction(); + const callbackExcept13 = 0; + final callback13 = ffi.Pointer.fromFunction( + PureAbstract.foo_calledFromC, callbackExcept13); + registerCallback(thisCpp, callback13, 13); + final callback14 = ffi.Pointer.fromFunction( + PureAbstract.renamedPureVirtual1_calledFromC); + registerCallback(thisCpp, callback14, 14); + final callback17 = + ffi.Pointer.fromFunction( + PureAbstract.unnamedOverriddenDefaultArgCase_calledFromC); + registerCallback(thisCpp, callback17, 17); + const callbackExcept18 = 0; + final callback18 = ffi.Pointer.fromFunction( + PureAbstract.virtualReceivingPointer_calledFromC, callbackExcept18); + registerCallback(thisCpp, callback18, 18); + final callback19 = ffi.Pointer.fromFunction( + PureAbstract.voidPureAbstract_calledFromC); + registerCallback(thisCpp, callback19, 19); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/PureAbstractWithUnknownType.dart b/tests/generated/TestBindings/dart/lib/src/PureAbstractWithUnknownType.dart new file mode 100644 index 0000000..7d72717 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/PureAbstractWithUnknownType.dart @@ -0,0 +1,77 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class PureAbstractWithUnknownType implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = true; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory PureAbstractWithUnknownType.fromCache(var cppPointer, + [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + PureAbstractWithUnknownType.fromCppPointer( + cppPointer, needsAutoDelete)) as PureAbstractWithUnknownType; + } + PureAbstractWithUnknownType.fromCppPointer(var cppPointer, + [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + PureAbstractWithUnknownType.init() {} + String getFinalizerName() { + return "c_PureAbstractWithUnknownType_Finalizer"; + } //PureAbstractWithUnknownType() + + PureAbstractWithUnknownType() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_PureAbstractWithUnknownType__constructor') + .asFunction(); + thisCpp = func(); + PureAbstractWithUnknownType.s_dartInstanceByCppPtr[thisCpp.address] = this; + } // getValue() const + int getValue() { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_PureAbstractWithUnknownType__getValue') + .asFunction(); + return func(thisCpp); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_PureAbstractWithUnknownType__destructor') + .asFunction(); + func(thisCpp); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/QApplication.dart b/tests/generated/TestBindings/dart/lib/src/QApplication.dart new file mode 100644 index 0000000..a64523b --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/QApplication.dart @@ -0,0 +1,343 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; + +class QApplication extends QGuiApplication { + QApplication.fromCppPointer(var cppPointer, [var needsAutoDelete = false]) + : super.fromCppPointer(cppPointer, needsAutoDelete) {} + QApplication.init() : super.init() {} + factory QApplication.fromCache(var cppPointer, [needsAutoDelete = false]) { + if (QObject.isCached(cppPointer)) { + var instance = QObject.s_dartInstanceByCppPtr[cppPointer.address]; + if (instance != null) return instance as QApplication; + } + return QApplication.fromCppPointer(cppPointer, needsAutoDelete); + } + String getFinalizerName() { + return "c_QApplication_Finalizer"; + } + + static // aboutQt() + aboutQt() { + final void_Func_void func = _dylib + .lookup>( + 'c_static_QApplication__aboutQt') + .asFunction(); + func(); + } // autoSipEnabled() const + + bool autoSipEnabled() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QApplication__autoSipEnabled') + .asFunction(); + return func(thisCpp) != 0; + } + + static // beep() + beep() { + final void_Func_void func = _dylib + .lookup>( + 'c_static_QApplication__beep') + .asFunction(); + func(); + } + + static // closeAllWindows() + closeAllWindows() { + final void_Func_void func = _dylib + .lookup>( + 'c_static_QApplication__closeAllWindows') + .asFunction(); + func(); + } + + static // cursorFlashTime() + int cursorFlashTime() { + final int_Func_void func = _dylib + .lookup>( + 'c_static_QApplication__cursorFlashTime') + .asFunction(); + return func(); + } + + static void customEvent_calledFromC( + ffi.Pointer thisCpp, ffi.Pointer? event) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as QApplication; + if (dartInstance == null) { + print( + "Dart instance not found for QApplication::customEvent(QEvent * event)! (${thisCpp.address})"); + throw Error(); + } + dartInstance.customEvent((event == null || event.address == 0) + ? null + : QEvent.fromCppPointer(event)); + } + + static // doubleClickInterval() + int doubleClickInterval() { + final int_Func_void func = _dylib + .lookup>( + 'c_static_QApplication__doubleClickInterval') + .asFunction(); + return func(); + } + + static int event_calledFromC( + ffi.Pointer thisCpp, ffi.Pointer? arg__1) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as QApplication; + if (dartInstance == null) { + print( + "Dart instance not found for QApplication::event(QEvent * arg__1)! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.event((arg__1 == null || arg__1.address == 0) + ? null + : QEvent.fromCppPointer(arg__1)); + return result ? 1 : 0; + } + + static int eventFilter_calledFromC(ffi.Pointer thisCpp, + ffi.Pointer? watched, ffi.Pointer? event) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as QApplication; + if (dartInstance == null) { + print( + "Dart instance not found for QApplication::eventFilter(QObject * watched, QEvent * event)! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.eventFilter( + (watched == null || watched.address == 0) + ? null + : QObject.fromCppPointer(watched), + (event == null || event.address == 0) + ? null + : QEvent.fromCppPointer(event)); + return result ? 1 : 0; + } + + static // exec() + int exec() { + final int_Func_void func = _dylib + .lookup>( + 'c_static_QApplication__exec') + .asFunction(); + return func(); + } + + static // keyboardInputInterval() + int keyboardInputInterval() { + final int_Func_void func = _dylib + .lookup>( + 'c_static_QApplication__keyboardInputInterval') + .asFunction(); + return func(); + } + + static int notify_calledFromC(ffi.Pointer thisCpp, + ffi.Pointer? arg__1, ffi.Pointer? arg__2) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as QApplication; + if (dartInstance == null) { + print( + "Dart instance not found for QApplication::notify(QObject * arg__1, QEvent * arg__2)! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.notify( + (arg__1 == null || arg__1.address == 0) + ? null + : QObject.fromCppPointer(arg__1), + (arg__2 == null || arg__2.address == 0) + ? null + : QEvent.fromCppPointer(arg__2)); + return result ? 1 : 0; + } // setAutoSipEnabled(const bool enabled) + + setAutoSipEnabled(bool enabled) { + final void_Func_voidstar_bool func = _dylib + .lookup>( + 'c_QApplication__setAutoSipEnabled_bool') + .asFunction(); + func(thisCpp, enabled ? 1 : 0); + } + + static // setCursorFlashTime(int arg__1) + setCursorFlashTime(int arg__1) { + final void_Func_int func = _dylib + .lookup>( + 'c_static_QApplication__setCursorFlashTime_int') + .asFunction(); + func(arg__1); + } + + static // setDoubleClickInterval(int arg__1) + setDoubleClickInterval(int arg__1) { + final void_Func_int func = _dylib + .lookup>( + 'c_static_QApplication__setDoubleClickInterval_int') + .asFunction(); + func(arg__1); + } + + static // setKeyboardInputInterval(int arg__1) + setKeyboardInputInterval(int arg__1) { + final void_Func_int func = _dylib + .lookup>( + 'c_static_QApplication__setKeyboardInputInterval_int') + .asFunction(); + func(arg__1); + } + + static // setStartDragDistance(int l) + setStartDragDistance(int l) { + final void_Func_int func = _dylib + .lookup>( + 'c_static_QApplication__setStartDragDistance_int') + .asFunction(); + func(l); + } + + static // setStartDragTime(int ms) + setStartDragTime(int ms) { + final void_Func_int func = _dylib + .lookup>( + 'c_static_QApplication__setStartDragTime_int') + .asFunction(); + func(ms); + } // setStyleSheet(const QString & sheet) + + setStyleSheet(String sheet) { + final void_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QApplication__setStyleSheet_QString') + .asFunction(); + func(thisCpp, sheet.toNativeUtf8()); + } + + static // setWheelScrollLines(int arg__1) + setWheelScrollLines(int arg__1) { + final void_Func_int func = _dylib + .lookup>( + 'c_static_QApplication__setWheelScrollLines_int') + .asFunction(); + func(arg__1); + } + + static // startDragDistance() + int startDragDistance() { + final int_Func_void func = _dylib + .lookup>( + 'c_static_QApplication__startDragDistance') + .asFunction(); + return func(); + } + + static // startDragTime() + int startDragTime() { + final int_Func_void func = _dylib + .lookup>( + 'c_static_QApplication__startDragTime') + .asFunction(); + return func(); + } // styleSheet() const + + QString styleSheet() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QApplication__styleSheet') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QString.fromCppPointer(result, true); + } + + static // tr(const char * s, const char * c, int n) + QString tr(String? s, String? c, int n) { + final voidstar_Func_string_string_int func = _dylib + .lookup>( + 'c_static_QApplication__tr_char_char_int') + .asFunction(); + ffi.Pointer result = func( + s?.toNativeUtf8() ?? ffi.nullptr, c?.toNativeUtf8() ?? ffi.nullptr, n); + return QString.fromCppPointer(result, true); + } + + static // wheelScrollLines() + int wheelScrollLines() { + final int_Func_void func = _dylib + .lookup>( + 'c_static_QApplication__wheelScrollLines') + .asFunction(); + return func(); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QApplication__destructor') + .asFunction(); + func(thisCpp); + } + + String cFunctionSymbolName(int methodId) { + switch (methodId) { + case 481: + return "c_QApplication__customEvent_QEvent"; + case 490: + return "c_QApplication__event_QEvent"; + case 491: + return "c_QApplication__eventFilter_QObject_QEvent"; + case 688: + return "c_QApplication__notify_QObject_QEvent"; + } + return super.cFunctionSymbolName(methodId); + } + + static String methodNameFromId(int methodId) { + switch (methodId) { + case 481: + return "customEvent"; + case 490: + return "event"; + case 491: + return "eventFilter"; + case 688: + return "notify"; + } + throw Error(); + } + + void registerCallbacks() { + assert(thisCpp != null); + final RegisterMethodIsReimplementedCallback registerCallback = _dylib + .lookup>( + 'c_QApplication__registerVirtualMethodCallback') + .asFunction(); + final callback481 = + ffi.Pointer.fromFunction( + QObject.customEvent_calledFromC); + registerCallback(thisCpp, callback481, 481); + const callbackExcept490 = 0; + final callback490 = + ffi.Pointer.fromFunction( + QApplication.event_calledFromC, callbackExcept490); + registerCallback(thisCpp, callback490, 490); + const callbackExcept491 = 0; + final callback491 = + ffi.Pointer.fromFunction( + QObject.eventFilter_calledFromC, callbackExcept491); + registerCallback(thisCpp, callback491, 491); + const callbackExcept688 = 0; + final callback688 = + ffi.Pointer.fromFunction( + QApplication.notify_calledFromC, callbackExcept688); + registerCallback(thisCpp, callback688, 688); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/QByteArray.dart b/tests/generated/TestBindings/dart/lib/src/QByteArray.dart new file mode 100644 index 0000000..cb3d004 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/QByteArray.dart @@ -0,0 +1,747 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class QByteArray implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = true; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory QByteArray.fromCache(var cppPointer, [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + QByteArray.fromCppPointer(cppPointer, needsAutoDelete)) as QByteArray; + } + QByteArray.fromCppPointer(var cppPointer, [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + QByteArray.init() {} + String getFinalizerName() { + return "c_QByteArray_Finalizer"; + } //QByteArray() + + QByteArray() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_QByteArray__constructor') + .asFunction(); + thisCpp = func(); + QByteArray.s_dartInstanceByCppPtr[thisCpp.address] = this; + } //QByteArray(const char * arg__1, qsizetype size) + QByteArray.ctor2(String? arg__1, {int size = -1}) { + final voidstar_Func_string_int func = _dylib + .lookup>( + 'c_QByteArray__constructor_char_qsizetype') + .asFunction(); + thisCpp = func(arg__1?.toNativeUtf8() ?? ffi.nullptr, size); + QByteArray.s_dartInstanceByCppPtr[thisCpp.address] = this; + } // append(const QByteArray & a) + QByteArray append(QByteArray a) { + final voidstar_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QByteArray__append_QByteArray') + .asFunction(); + ffi.Pointer result = + func(thisCpp, a == null ? ffi.nullptr : a.thisCpp); + return QByteArray.fromCppPointer(result, false); + } // append(const char * s) + + QByteArray append_2(String? s) { + final voidstar_Func_voidstar_string func = _dylib + .lookup>( + 'c_QByteArray__append_char') + .asFunction(); + ffi.Pointer result = func(thisCpp, s?.toNativeUtf8() ?? ffi.nullptr); + return QByteArray.fromCppPointer(result, false); + } // append(const char * s, qsizetype len) + + QByteArray append_3(String? s, int len) { + final voidstar_Func_voidstar_string_int func = _dylib + .lookup< + ffi + .NativeFunction>( + 'c_QByteArray__append_char_qsizetype') + .asFunction(); + ffi.Pointer result = + func(thisCpp, s?.toNativeUtf8() ?? ffi.nullptr, len); + return QByteArray.fromCppPointer(result, false); + } // at(qsizetype i) const + + String at(int i) { + final char_Func_voidstar_int func = _dylib + .lookup>( + 'c_QByteArray__at_qsizetype') + .asFunction(); + return String.fromCharCode(func(thisCpp, i)); + } // capacity() const + + int capacity() { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_QByteArray__capacity') + .asFunction(); + return func(thisCpp); + } // cbegin() const + + String cbegin() { + final string_Func_voidstar func = _dylib + .lookup>( + 'c_QByteArray__cbegin') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return result.toDartString(); + } // cend() const + + String cend() { + final string_Func_voidstar func = _dylib + .lookup>( + 'c_QByteArray__cend') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return result.toDartString(); + } // chop(qsizetype n) + + chop(int n) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_QByteArray__chop_qsizetype') + .asFunction(); + func(thisCpp, n); + } // chopped(qsizetype len) const + + QByteArray chopped(int len) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + 'c_QByteArray__chopped_qsizetype') + .asFunction(); + ffi.Pointer result = func(thisCpp, len); + return QByteArray.fromCppPointer(result, true); + } // clear() + + clear() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QByteArray__clear') + .asFunction(); + func(thisCpp); + } // constBegin() const + + String constBegin() { + final string_Func_voidstar func = _dylib + .lookup>( + 'c_QByteArray__constBegin') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return result.toDartString(); + } // constData() const + + String constData() { + final string_Func_voidstar func = _dylib + .lookup>( + 'c_QByteArray__constData') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return result.toDartString(); + } // constEnd() const + + String constEnd() { + final string_Func_voidstar func = _dylib + .lookup>( + 'c_QByteArray__constEnd') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return result.toDartString(); + } // count() const + + int count() { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_QByteArray__count') + .asFunction(); + return func(thisCpp); + } // detach() + + detach() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QByteArray__detach') + .asFunction(); + func(thisCpp); + } // expand(qsizetype i) + + expand(int i) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_QByteArray__expand_qsizetype') + .asFunction(); + func(thisCpp, i); + } // first(qsizetype n) const + + QByteArray first(int n) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + 'c_QByteArray__first_qsizetype') + .asFunction(); + ffi.Pointer result = func(thisCpp, n); + return QByteArray.fromCppPointer(result, true); + } + + static // fromBase64(const QByteArray & base64) + QByteArray fromBase64(QByteArray base64) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_static_QByteArray__fromBase64_QByteArray') + .asFunction(); + ffi.Pointer result = + func(base64 == null ? ffi.nullptr : base64.thisCpp); + return QByteArray.fromCppPointer(result, true); + } + + static // fromHex(const QByteArray & hexEncoded) + QByteArray fromHex(QByteArray hexEncoded) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_static_QByteArray__fromHex_QByteArray') + .asFunction(); + ffi.Pointer result = + func(hexEncoded == null ? ffi.nullptr : hexEncoded.thisCpp); + return QByteArray.fromCppPointer(result, true); + } + + static // fromRawData(const char * data, qsizetype size) + QByteArray fromRawData(String? data, int size) { + final voidstar_Func_string_int func = _dylib + .lookup>( + 'c_static_QByteArray__fromRawData_char_qsizetype') + .asFunction(); + ffi.Pointer result = func(data?.toNativeUtf8() ?? ffi.nullptr, size); + return QByteArray.fromCppPointer(result, true); + } // insert(qsizetype i, const QByteArray & data) + + QByteArray insert(int i, QByteArray data) { + final voidstar_Func_voidstar_int_voidstar func = _dylib + .lookup< + ffi + .NativeFunction>( + 'c_QByteArray__insert_qsizetype_QByteArray') + .asFunction(); + ffi.Pointer result = + func(thisCpp, i, data == null ? ffi.nullptr : data.thisCpp); + return QByteArray.fromCppPointer(result, false); + } // insert(qsizetype i, const char * s) + + QByteArray insert_2(int i, String? s) { + final voidstar_Func_voidstar_int_string func = _dylib + .lookup< + ffi + .NativeFunction>( + 'c_QByteArray__insert_qsizetype_char') + .asFunction(); + ffi.Pointer result = + func(thisCpp, i, s?.toNativeUtf8() ?? ffi.nullptr); + return QByteArray.fromCppPointer(result, false); + } // insert(qsizetype i, const char * s, qsizetype len) + + QByteArray insert_3(int i, String? s, int len) { + final voidstar_Func_voidstar_int_string_int func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_voidstar_ffi_Int32_string_ffi_Int32_FFI>>( + 'c_QByteArray__insert_qsizetype_char_qsizetype') + .asFunction(); + ffi.Pointer result = + func(thisCpp, i, s?.toNativeUtf8() ?? ffi.nullptr, len); + return QByteArray.fromCppPointer(result, false); + } // isDetached() const + + bool isDetached() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QByteArray__isDetached') + .asFunction(); + return func(thisCpp) != 0; + } // isEmpty() const + + bool isEmpty() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QByteArray__isEmpty') + .asFunction(); + return func(thisCpp) != 0; + } // isLower() const + + bool isLower() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QByteArray__isLower') + .asFunction(); + return func(thisCpp) != 0; + } // isNull() const + + bool isNull() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QByteArray__isNull') + .asFunction(); + return func(thisCpp) != 0; + } // isSharedWith(const QByteArray & other) const + + bool isSharedWith(QByteArray other) { + final bool_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QByteArray__isSharedWith_QByteArray') + .asFunction(); + return func(thisCpp, other == null ? ffi.nullptr : other.thisCpp) != 0; + } // isUpper() const + + bool isUpper() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QByteArray__isUpper') + .asFunction(); + return func(thisCpp) != 0; + } // isValidUtf8() const + + bool isValidUtf8() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QByteArray__isValidUtf8') + .asFunction(); + return func(thisCpp) != 0; + } // last(qsizetype n) const + + QByteArray last(int n) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + 'c_QByteArray__last_qsizetype') + .asFunction(); + ffi.Pointer result = func(thisCpp, n); + return QByteArray.fromCppPointer(result, true); + } // left(qsizetype len) const + + QByteArray left(int len) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + 'c_QByteArray__left_qsizetype') + .asFunction(); + ffi.Pointer result = func(thisCpp, len); + return QByteArray.fromCppPointer(result, true); + } // length() const + + int length() { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_QByteArray__length') + .asFunction(); + return func(thisCpp); + } // mid(qsizetype index, qsizetype len) const + + QByteArray mid(int index, {int len = -1}) { + final voidstar_Func_voidstar_int_int func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_voidstar_ffi_Int32_ffi_Int32_FFI>>( + 'c_QByteArray__mid_qsizetype_qsizetype') + .asFunction(); + ffi.Pointer result = func(thisCpp, index, len); + return QByteArray.fromCppPointer(result, true); + } // nulTerminated() const + + QByteArray nulTerminated() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QByteArray__nulTerminated') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QByteArray.fromCppPointer(result, true); + } + + static // number(int arg__1, int base) + QByteArray number(int arg__1, {int base = 10}) { + final voidstar_Func_int_int func = _dylib + .lookup>( + 'c_static_QByteArray__number_int_int') + .asFunction(); + ffi.Pointer result = func(arg__1, base); + return QByteArray.fromCppPointer(result, true); + } // prepend(const QByteArray & a) + + QByteArray prepend(QByteArray a) { + final voidstar_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QByteArray__prepend_QByteArray') + .asFunction(); + ffi.Pointer result = + func(thisCpp, a == null ? ffi.nullptr : a.thisCpp); + return QByteArray.fromCppPointer(result, false); + } // prepend(const char * s) + + QByteArray prepend_2(String? s) { + final voidstar_Func_voidstar_string func = _dylib + .lookup>( + 'c_QByteArray__prepend_char') + .asFunction(); + ffi.Pointer result = func(thisCpp, s?.toNativeUtf8() ?? ffi.nullptr); + return QByteArray.fromCppPointer(result, false); + } // prepend(const char * s, qsizetype len) + + QByteArray prepend_3(String? s, int len) { + final voidstar_Func_voidstar_string_int func = _dylib + .lookup< + ffi + .NativeFunction>( + 'c_QByteArray__prepend_char_qsizetype') + .asFunction(); + ffi.Pointer result = + func(thisCpp, s?.toNativeUtf8() ?? ffi.nullptr, len); + return QByteArray.fromCppPointer(result, false); + } // push_back(const QByteArray & a) + + push_back(QByteArray a) { + final void_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QByteArray__push_back_QByteArray') + .asFunction(); + func(thisCpp, a == null ? ffi.nullptr : a.thisCpp); + } // push_back(const char * s) + + push_back_2(String? s) { + final void_Func_voidstar_string func = _dylib + .lookup>( + 'c_QByteArray__push_back_char') + .asFunction(); + func(thisCpp, s?.toNativeUtf8() ?? ffi.nullptr); + } // push_front(const QByteArray & a) + + push_front(QByteArray a) { + final void_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QByteArray__push_front_QByteArray') + .asFunction(); + func(thisCpp, a == null ? ffi.nullptr : a.thisCpp); + } // push_front(const char * c) + + push_front_2(String? c) { + final void_Func_voidstar_string func = _dylib + .lookup>( + 'c_QByteArray__push_front_char') + .asFunction(); + func(thisCpp, c?.toNativeUtf8() ?? ffi.nullptr); + } // reallocGrowData(qsizetype n) + + reallocGrowData(int n) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_QByteArray__reallocGrowData_qsizetype') + .asFunction(); + func(thisCpp, n); + } // remove(qsizetype index, qsizetype len) + + QByteArray remove(int index, int len) { + final voidstar_Func_voidstar_int_int func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_voidstar_ffi_Int32_ffi_Int32_FFI>>( + 'c_QByteArray__remove_qsizetype_qsizetype') + .asFunction(); + ffi.Pointer result = func(thisCpp, index, len); + return QByteArray.fromCppPointer(result, false); + } // repeated(qsizetype times) const + + QByteArray repeated(int times) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + 'c_QByteArray__repeated_qsizetype') + .asFunction(); + ffi.Pointer result = func(thisCpp, times); + return QByteArray.fromCppPointer(result, true); + } // replace(const char * before, qsizetype bsize, const char * after, qsizetype asize) + + QByteArray replace(String? before, int bsize, String? after, int asize) { + final voidstar_Func_voidstar_string_int_string_int func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_voidstar_string_ffi_Int32_string_ffi_Int32_FFI>>( + 'c_QByteArray__replace_char_qsizetype_char_qsizetype') + .asFunction(); + ffi.Pointer result = func( + thisCpp, + before?.toNativeUtf8() ?? ffi.nullptr, + bsize, + after?.toNativeUtf8() ?? ffi.nullptr, + asize); + return QByteArray.fromCppPointer(result, false); + } // replace(qsizetype index, qsizetype len, const char * s, qsizetype alen) + + QByteArray replace_2(int index, int len, String? s, int alen) { + final voidstar_Func_voidstar_int_int_string_int func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_voidstar_ffi_Int32_ffi_Int32_string_ffi_Int32_FFI>>( + 'c_QByteArray__replace_qsizetype_qsizetype_char_qsizetype') + .asFunction(); + ffi.Pointer result = + func(thisCpp, index, len, s?.toNativeUtf8() ?? ffi.nullptr, alen); + return QByteArray.fromCppPointer(result, false); + } // reserve(qsizetype size) + + reserve(int size) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_QByteArray__reserve_qsizetype') + .asFunction(); + func(thisCpp, size); + } // resize(qsizetype size) + + resize(int size) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_QByteArray__resize_qsizetype') + .asFunction(); + func(thisCpp, size); + } // right(qsizetype len) const + + QByteArray right(int len) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + 'c_QByteArray__right_qsizetype') + .asFunction(); + ffi.Pointer result = func(thisCpp, len); + return QByteArray.fromCppPointer(result, true); + } // setNum(int arg__1, int base) + + QByteArray setNum(int arg__1, {int base = 10}) { + final voidstar_Func_voidstar_int_int func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_voidstar_ffi_Int32_ffi_Int32_FFI>>( + 'c_QByteArray__setNum_int_int') + .asFunction(); + ffi.Pointer result = func(thisCpp, arg__1, base); + return QByteArray.fromCppPointer(result, false); + } // setRawData(const char * a, qsizetype n) + + QByteArray setRawData(String? a, int n) { + final voidstar_Func_voidstar_string_int func = _dylib + .lookup< + ffi + .NativeFunction>( + 'c_QByteArray__setRawData_char_qsizetype') + .asFunction(); + ffi.Pointer result = + func(thisCpp, a?.toNativeUtf8() ?? ffi.nullptr, n); + return QByteArray.fromCppPointer(result, false); + } // shrink_to_fit() + + shrink_to_fit() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QByteArray__shrink_to_fit') + .asFunction(); + func(thisCpp); + } // simplified() + + QByteArray simplified() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QByteArray__simplified') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QByteArray.fromCppPointer(result, true); + } + + static // simplified_helper(QByteArray & a) + QByteArray simplified_helper(QByteArray a) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_static_QByteArray__simplified_helper_QByteArray') + .asFunction(); + ffi.Pointer result = func(a == null ? ffi.nullptr : a.thisCpp); + return QByteArray.fromCppPointer(result, true); + } + + static // simplified_helper(const QByteArray & a) + QByteArray simplified_helper_2(QByteArray a) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_static_QByteArray__simplified_helper_QByteArray') + .asFunction(); + ffi.Pointer result = func(a == null ? ffi.nullptr : a.thisCpp); + return QByteArray.fromCppPointer(result, true); + } // size() const + + int size() { + final int_Func_voidstar func = _dylib + .lookup>('c_QByteArray__size') + .asFunction(); + return func(thisCpp); + } // sliced(qsizetype pos) const + + QByteArray sliced(int pos) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + 'c_QByteArray__sliced_qsizetype') + .asFunction(); + ffi.Pointer result = func(thisCpp, pos); + return QByteArray.fromCppPointer(result, true); + } // sliced(qsizetype pos, qsizetype n) const + + QByteArray sliced_2(int pos, int n) { + final voidstar_Func_voidstar_int_int func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_voidstar_ffi_Int32_ffi_Int32_FFI>>( + 'c_QByteArray__sliced_qsizetype_qsizetype') + .asFunction(); + ffi.Pointer result = func(thisCpp, pos, n); + return QByteArray.fromCppPointer(result, true); + } // squeeze() + + squeeze() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QByteArray__squeeze') + .asFunction(); + func(thisCpp); + } // toBase64() const + + QByteArray toBase64() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QByteArray__toBase64') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QByteArray.fromCppPointer(result, true); + } // toLower() + + QByteArray toLower() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QByteArray__toLower') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QByteArray.fromCppPointer(result, true); + } + + static // toLower_helper(QByteArray & a) + QByteArray toLower_helper(QByteArray a) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_static_QByteArray__toLower_helper_QByteArray') + .asFunction(); + ffi.Pointer result = func(a == null ? ffi.nullptr : a.thisCpp); + return QByteArray.fromCppPointer(result, true); + } + + static // toLower_helper(const QByteArray & a) + QByteArray toLower_helper_2(QByteArray a) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_static_QByteArray__toLower_helper_QByteArray') + .asFunction(); + ffi.Pointer result = func(a == null ? ffi.nullptr : a.thisCpp); + return QByteArray.fromCppPointer(result, true); + } // toUpper() + + QByteArray toUpper() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QByteArray__toUpper') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QByteArray.fromCppPointer(result, true); + } + + static // toUpper_helper(QByteArray & a) + QByteArray toUpper_helper(QByteArray a) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_static_QByteArray__toUpper_helper_QByteArray') + .asFunction(); + ffi.Pointer result = func(a == null ? ffi.nullptr : a.thisCpp); + return QByteArray.fromCppPointer(result, true); + } + + static // toUpper_helper(const QByteArray & a) + QByteArray toUpper_helper_2(QByteArray a) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_static_QByteArray__toUpper_helper_QByteArray') + .asFunction(); + ffi.Pointer result = func(a == null ? ffi.nullptr : a.thisCpp); + return QByteArray.fromCppPointer(result, true); + } // trimmed() + + QByteArray trimmed() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QByteArray__trimmed') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QByteArray.fromCppPointer(result, true); + } + + static // trimmed_helper(QByteArray & a) + QByteArray trimmed_helper(QByteArray a) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_static_QByteArray__trimmed_helper_QByteArray') + .asFunction(); + ffi.Pointer result = func(a == null ? ffi.nullptr : a.thisCpp); + return QByteArray.fromCppPointer(result, true); + } + + static // trimmed_helper(const QByteArray & a) + QByteArray trimmed_helper_2(QByteArray a) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_static_QByteArray__trimmed_helper_QByteArray') + .asFunction(); + ffi.Pointer result = func(a == null ? ffi.nullptr : a.thisCpp); + return QByteArray.fromCppPointer(result, true); + } // truncate(qsizetype pos) + + truncate(int pos) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_QByteArray__truncate_qsizetype') + .asFunction(); + func(thisCpp, pos); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QByteArray__destructor') + .asFunction(); + func(thisCpp); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/QColor.dart b/tests/generated/TestBindings/dart/lib/src/QColor.dart new file mode 100644 index 0000000..d93324d --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/QColor.dart @@ -0,0 +1,698 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class QColor implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = true; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory QColor.fromCache(var cppPointer, [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + QColor.fromCppPointer(cppPointer, needsAutoDelete)) as QColor; + } + QColor.fromCppPointer(var cppPointer, [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + QColor.init() {} + String getFinalizerName() { + return "c_QColor_Finalizer"; + } //QColor() + + QColor() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_QColor__constructor') + .asFunction(); + thisCpp = func(); + QColor.s_dartInstanceByCppPtr[thisCpp.address] = this; + } //QColor(const QString & name) + QColor.ctor2(String name) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QColor__constructor_QString') + .asFunction(); + thisCpp = func(name.toNativeUtf8()); + QColor.s_dartInstanceByCppPtr[thisCpp.address] = this; + } //QColor(const char * aname) + QColor.ctor3(String? aname) { + final voidstar_Func_string func = _dylib + .lookup>( + 'c_QColor__constructor_char') + .asFunction(); + thisCpp = func(aname?.toNativeUtf8() ?? ffi.nullptr); + QColor.s_dartInstanceByCppPtr[thisCpp.address] = this; + } //QColor(int r, int g, int b, int a) + QColor.ctor4(int r, int g, int b, {int a = 255}) { + final voidstar_Func_int_int_int_int func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_ffi_Int32_ffi_Int32_ffi_Int32_ffi_Int32_FFI>>( + 'c_QColor__constructor_int_int_int_int') + .asFunction(); + thisCpp = func(r, g, b, a); + QColor.s_dartInstanceByCppPtr[thisCpp.address] = this; + } // alpha() const + int alpha() { + final int_Func_voidstar func = _dylib + .lookup>('c_QColor__alpha') + .asFunction(); + return func(thisCpp); + } // alphaF() const + + double alphaF() { + final double_Func_voidstar func = _dylib + .lookup>( + 'c_QColor__alphaF') + .asFunction(); + return func(thisCpp); + } // black() const + + int black() { + final int_Func_voidstar func = _dylib + .lookup>('c_QColor__black') + .asFunction(); + return func(thisCpp); + } // blackF() const + + double blackF() { + final double_Func_voidstar func = _dylib + .lookup>( + 'c_QColor__blackF') + .asFunction(); + return func(thisCpp); + } // blue() const + + int blue() { + final int_Func_voidstar func = _dylib + .lookup>('c_QColor__blue') + .asFunction(); + return func(thisCpp); + } // blueF() const + + double blueF() { + final double_Func_voidstar func = _dylib + .lookup>('c_QColor__blueF') + .asFunction(); + return func(thisCpp); + } + + static // colorNames() + QList colorNames() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_QColor__colorNames') + .asFunction(); + ffi.Pointer result = func(); + return QList.fromCppPointer(result, true); + } // cyan() const + + int cyan() { + final int_Func_voidstar func = _dylib + .lookup>('c_QColor__cyan') + .asFunction(); + return func(thisCpp); + } // cyanF() const + + double cyanF() { + final double_Func_voidstar func = _dylib + .lookup>('c_QColor__cyanF') + .asFunction(); + return func(thisCpp); + } // darker(int f) const + + QColor darker({int f = 200}) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + 'c_QColor__darker_int') + .asFunction(); + ffi.Pointer result = func(thisCpp, f); + return QColor.fromCppPointer(result, true); + } + + static // fromCmyk(int c, int m, int y, int k, int a) + QColor fromCmyk(int c, int m, int y, int k, {int a = 255}) { + final voidstar_Func_int_int_int_int_int func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_ffi_Int32_ffi_Int32_ffi_Int32_ffi_Int32_ffi_Int32_FFI>>( + 'c_static_QColor__fromCmyk_int_int_int_int_int') + .asFunction(); + ffi.Pointer result = func(c, m, y, k, a); + return QColor.fromCppPointer(result, true); + } + + static // fromCmykF(float c, float m, float y, float k, float a) + QColor fromCmykF(double c, double m, double y, double k, + {double a = 1.0}) { + final voidstar_Func_double_double_double_double_double func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_ffi_Double_ffi_Double_ffi_Double_ffi_Double_ffi_Double_FFI>>( + 'c_static_QColor__fromCmykF_float_float_float_float_float') + .asFunction(); + ffi.Pointer result = func(c, m, y, k, a); + return QColor.fromCppPointer(result, true); + } + + static // fromHsl(int h, int s, int l, int a) + QColor fromHsl(int h, int s, int l, {int a = 255}) { + final voidstar_Func_int_int_int_int func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_ffi_Int32_ffi_Int32_ffi_Int32_ffi_Int32_FFI>>( + 'c_static_QColor__fromHsl_int_int_int_int') + .asFunction(); + ffi.Pointer result = func(h, s, l, a); + return QColor.fromCppPointer(result, true); + } + + static // fromHslF(float h, float s, float l, float a) + QColor fromHslF(double h, double s, double l, {double a = 1.0}) { + final voidstar_Func_double_double_double_double func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_ffi_Double_ffi_Double_ffi_Double_ffi_Double_FFI>>( + 'c_static_QColor__fromHslF_float_float_float_float') + .asFunction(); + ffi.Pointer result = func(h, s, l, a); + return QColor.fromCppPointer(result, true); + } + + static // fromHsv(int h, int s, int v, int a) + QColor fromHsv(int h, int s, int v, {int a = 255}) { + final voidstar_Func_int_int_int_int func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_ffi_Int32_ffi_Int32_ffi_Int32_ffi_Int32_FFI>>( + 'c_static_QColor__fromHsv_int_int_int_int') + .asFunction(); + ffi.Pointer result = func(h, s, v, a); + return QColor.fromCppPointer(result, true); + } + + static // fromHsvF(float h, float s, float v, float a) + QColor fromHsvF(double h, double s, double v, {double a = 1.0}) { + final voidstar_Func_double_double_double_double func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_ffi_Double_ffi_Double_ffi_Double_ffi_Double_FFI>>( + 'c_static_QColor__fromHsvF_float_float_float_float') + .asFunction(); + ffi.Pointer result = func(h, s, v, a); + return QColor.fromCppPointer(result, true); + } + + static // fromRgb(int r, int g, int b, int a) + QColor fromRgb(int r, int g, int b, {int a = 255}) { + final voidstar_Func_int_int_int_int func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_ffi_Int32_ffi_Int32_ffi_Int32_ffi_Int32_FFI>>( + 'c_static_QColor__fromRgb_int_int_int_int') + .asFunction(); + ffi.Pointer result = func(r, g, b, a); + return QColor.fromCppPointer(result, true); + } + + static // fromRgbF(float r, float g, float b, float a) + QColor fromRgbF(double r, double g, double b, {double a = 1.0}) { + final voidstar_Func_double_double_double_double func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_ffi_Double_ffi_Double_ffi_Double_ffi_Double_FFI>>( + 'c_static_QColor__fromRgbF_float_float_float_float') + .asFunction(); + ffi.Pointer result = func(r, g, b, a); + return QColor.fromCppPointer(result, true); + } // green() const + + int green() { + final int_Func_voidstar func = _dylib + .lookup>('c_QColor__green') + .asFunction(); + return func(thisCpp); + } // greenF() const + + double greenF() { + final double_Func_voidstar func = _dylib + .lookup>( + 'c_QColor__greenF') + .asFunction(); + return func(thisCpp); + } // hslHue() const + + int hslHue() { + final int_Func_voidstar func = _dylib + .lookup>('c_QColor__hslHue') + .asFunction(); + return func(thisCpp); + } // hslHueF() const + + double hslHueF() { + final double_Func_voidstar func = _dylib + .lookup>( + 'c_QColor__hslHueF') + .asFunction(); + return func(thisCpp); + } // hslSaturation() const + + int hslSaturation() { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_QColor__hslSaturation') + .asFunction(); + return func(thisCpp); + } // hslSaturationF() const + + double hslSaturationF() { + final double_Func_voidstar func = _dylib + .lookup>( + 'c_QColor__hslSaturationF') + .asFunction(); + return func(thisCpp); + } // hsvHue() const + + int hsvHue() { + final int_Func_voidstar func = _dylib + .lookup>('c_QColor__hsvHue') + .asFunction(); + return func(thisCpp); + } // hsvHueF() const + + double hsvHueF() { + final double_Func_voidstar func = _dylib + .lookup>( + 'c_QColor__hsvHueF') + .asFunction(); + return func(thisCpp); + } // hsvSaturation() const + + int hsvSaturation() { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_QColor__hsvSaturation') + .asFunction(); + return func(thisCpp); + } // hsvSaturationF() const + + double hsvSaturationF() { + final double_Func_voidstar func = _dylib + .lookup>( + 'c_QColor__hsvSaturationF') + .asFunction(); + return func(thisCpp); + } // hue() const + + int hue() { + final int_Func_voidstar func = _dylib + .lookup>('c_QColor__hue') + .asFunction(); + return func(thisCpp); + } // hueF() const + + double hueF() { + final double_Func_voidstar func = _dylib + .lookup>('c_QColor__hueF') + .asFunction(); + return func(thisCpp); + } // invalidate() + + invalidate() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QColor__invalidate') + .asFunction(); + func(thisCpp); + } + + static // isRgbaValid(int r, int g, int b, int a) + bool isRgbaValid(int r, int g, int b, {int a = 255}) { + final bool_Func_int_int_int_int func = _dylib + .lookup< + ffi.NativeFunction< + bool_Func_ffi_Int32_ffi_Int32_ffi_Int32_ffi_Int32_FFI>>( + 'c_static_QColor__isRgbaValid_int_int_int_int') + .asFunction(); + return func(r, g, b, a) != 0; + } // isValid() const + + bool isValid() { + final bool_Func_voidstar func = _dylib + .lookup>('c_QColor__isValid') + .asFunction(); + return func(thisCpp) != 0; + } + + static // isValidColor(const QString & name) + bool isValidColor(String name) { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_static_QColor__isValidColor_QString') + .asFunction(); + return func(name.toNativeUtf8()) != 0; + } // lighter(int f) const + + QColor lighter({int f = 150}) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + 'c_QColor__lighter_int') + .asFunction(); + ffi.Pointer result = func(thisCpp, f); + return QColor.fromCppPointer(result, true); + } // lightness() const + + int lightness() { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_QColor__lightness') + .asFunction(); + return func(thisCpp); + } // lightnessF() const + + double lightnessF() { + final double_Func_voidstar func = _dylib + .lookup>( + 'c_QColor__lightnessF') + .asFunction(); + return func(thisCpp); + } // magenta() const + + int magenta() { + final int_Func_voidstar func = _dylib + .lookup>('c_QColor__magenta') + .asFunction(); + return func(thisCpp); + } // magentaF() const + + double magentaF() { + final double_Func_voidstar func = _dylib + .lookup>( + 'c_QColor__magentaF') + .asFunction(); + return func(thisCpp); + } // name() const + + QString name() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QColor__name') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QString.fromCppPointer(result, true); + } // red() const + + int red() { + final int_Func_voidstar func = _dylib + .lookup>('c_QColor__red') + .asFunction(); + return func(thisCpp); + } // redF() const + + double redF() { + final double_Func_voidstar func = _dylib + .lookup>('c_QColor__redF') + .asFunction(); + return func(thisCpp); + } // saturation() const + + int saturation() { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_QColor__saturation') + .asFunction(); + return func(thisCpp); + } // saturationF() const + + double saturationF() { + final double_Func_voidstar func = _dylib + .lookup>( + 'c_QColor__saturationF') + .asFunction(); + return func(thisCpp); + } // setAlpha(int alpha) + + setAlpha(int alpha) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_QColor__setAlpha_int') + .asFunction(); + func(thisCpp, alpha); + } // setAlphaF(float alpha) + + setAlphaF(double alpha) { + final void_Func_voidstar_double func = _dylib + .lookup>( + 'c_QColor__setAlphaF_float') + .asFunction(); + func(thisCpp, alpha); + } // setBlue(int blue) + + setBlue(int blue) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_QColor__setBlue_int') + .asFunction(); + func(thisCpp, blue); + } // setBlueF(float blue) + + setBlueF(double blue) { + final void_Func_voidstar_double func = _dylib + .lookup>( + 'c_QColor__setBlueF_float') + .asFunction(); + func(thisCpp, blue); + } // setCmyk(int c, int m, int y, int k, int a) + + setCmyk(int c, int m, int y, int k, {int a = 255}) { + final void_Func_voidstar_int_int_int_int_int func = _dylib + .lookup< + ffi.NativeFunction< + void_Func_voidstar_ffi_Int32_ffi_Int32_ffi_Int32_ffi_Int32_ffi_Int32_FFI>>( + 'c_QColor__setCmyk_int_int_int_int_int') + .asFunction(); + func(thisCpp, c, m, y, k, a); + } // setCmykF(float c, float m, float y, float k, float a) + + setCmykF(double c, double m, double y, double k, {double a = 1.0}) { + final void_Func_voidstar_double_double_double_double_double func = _dylib + .lookup< + ffi.NativeFunction< + void_Func_voidstar_ffi_Double_ffi_Double_ffi_Double_ffi_Double_ffi_Double_FFI>>( + 'c_QColor__setCmykF_float_float_float_float_float') + .asFunction(); + func(thisCpp, c, m, y, k, a); + } // setGreen(int green) + + setGreen(int green) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_QColor__setGreen_int') + .asFunction(); + func(thisCpp, green); + } // setGreenF(float green) + + setGreenF(double green) { + final void_Func_voidstar_double func = _dylib + .lookup>( + 'c_QColor__setGreenF_float') + .asFunction(); + func(thisCpp, green); + } // setHsl(int h, int s, int l, int a) + + setHsl(int h, int s, int l, {int a = 255}) { + final void_Func_voidstar_int_int_int_int func = _dylib + .lookup< + ffi.NativeFunction< + void_Func_voidstar_ffi_Int32_ffi_Int32_ffi_Int32_ffi_Int32_FFI>>( + 'c_QColor__setHsl_int_int_int_int') + .asFunction(); + func(thisCpp, h, s, l, a); + } // setHslF(float h, float s, float l, float a) + + setHslF(double h, double s, double l, {double a = 1.0}) { + final void_Func_voidstar_double_double_double_double func = _dylib + .lookup< + ffi.NativeFunction< + void_Func_voidstar_ffi_Double_ffi_Double_ffi_Double_ffi_Double_FFI>>( + 'c_QColor__setHslF_float_float_float_float') + .asFunction(); + func(thisCpp, h, s, l, a); + } // setHsv(int h, int s, int v, int a) + + setHsv(int h, int s, int v, {int a = 255}) { + final void_Func_voidstar_int_int_int_int func = _dylib + .lookup< + ffi.NativeFunction< + void_Func_voidstar_ffi_Int32_ffi_Int32_ffi_Int32_ffi_Int32_FFI>>( + 'c_QColor__setHsv_int_int_int_int') + .asFunction(); + func(thisCpp, h, s, v, a); + } // setHsvF(float h, float s, float v, float a) + + setHsvF(double h, double s, double v, {double a = 1.0}) { + final void_Func_voidstar_double_double_double_double func = _dylib + .lookup< + ffi.NativeFunction< + void_Func_voidstar_ffi_Double_ffi_Double_ffi_Double_ffi_Double_FFI>>( + 'c_QColor__setHsvF_float_float_float_float') + .asFunction(); + func(thisCpp, h, s, v, a); + } // setNamedColor(const QString & name) + + setNamedColor(String name) { + final void_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QColor__setNamedColor_QString') + .asFunction(); + func(thisCpp, name.toNativeUtf8()); + } // setRed(int red) + + setRed(int red) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_QColor__setRed_int') + .asFunction(); + func(thisCpp, red); + } // setRedF(float red) + + setRedF(double red) { + final void_Func_voidstar_double func = _dylib + .lookup>( + 'c_QColor__setRedF_float') + .asFunction(); + func(thisCpp, red); + } // setRgb(int r, int g, int b, int a) + + setRgb(int r, int g, int b, {int a = 255}) { + final void_Func_voidstar_int_int_int_int func = _dylib + .lookup< + ffi.NativeFunction< + void_Func_voidstar_ffi_Int32_ffi_Int32_ffi_Int32_ffi_Int32_FFI>>( + 'c_QColor__setRgb_int_int_int_int') + .asFunction(); + func(thisCpp, r, g, b, a); + } // setRgbF(float r, float g, float b, float a) + + setRgbF(double r, double g, double b, {double a = 1.0}) { + final void_Func_voidstar_double_double_double_double func = _dylib + .lookup< + ffi.NativeFunction< + void_Func_voidstar_ffi_Double_ffi_Double_ffi_Double_ffi_Double_FFI>>( + 'c_QColor__setRgbF_float_float_float_float') + .asFunction(); + func(thisCpp, r, g, b, a); + } // toCmyk() const + + QColor toCmyk() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QColor__toCmyk') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QColor.fromCppPointer(result, true); + } // toExtendedRgb() const + + QColor toExtendedRgb() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QColor__toExtendedRgb') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QColor.fromCppPointer(result, true); + } // toHsl() const + + QColor toHsl() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QColor__toHsl') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QColor.fromCppPointer(result, true); + } // toHsv() const + + QColor toHsv() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QColor__toHsv') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QColor.fromCppPointer(result, true); + } // toRgb() const + + QColor toRgb() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QColor__toRgb') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QColor.fromCppPointer(result, true); + } // value() const + + int value() { + final int_Func_voidstar func = _dylib + .lookup>('c_QColor__value') + .asFunction(); + return func(thisCpp); + } // valueF() const + + double valueF() { + final double_Func_voidstar func = _dylib + .lookup>( + 'c_QColor__valueF') + .asFunction(); + return func(thisCpp); + } // yellow() const + + int yellow() { + final int_Func_voidstar func = _dylib + .lookup>('c_QColor__yellow') + .asFunction(); + return func(thisCpp); + } // yellowF() const + + double yellowF() { + final double_Func_voidstar func = _dylib + .lookup>( + 'c_QColor__yellowF') + .asFunction(); + return func(thisCpp); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QColor__destructor') + .asFunction(); + func(thisCpp); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/QCoreApplication.dart b/tests/generated/TestBindings/dart/lib/src/QCoreApplication.dart new file mode 100644 index 0000000..a606c9a --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/QCoreApplication.dart @@ -0,0 +1,671 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; + +class QCoreApplication extends QObject { + // Anonymous enum + static const ApplicationFlags = 393985; + QCoreApplication.fromCppPointer(var cppPointer, [var needsAutoDelete = false]) + : super.fromCppPointer(cppPointer, needsAutoDelete) {} + QCoreApplication.init() : super.init() {} + factory QCoreApplication.fromCache(var cppPointer, + [needsAutoDelete = false]) { + if (QObject.isCached(cppPointer)) { + var instance = QObject.s_dartInstanceByCppPtr[cppPointer.address]; + if (instance != null) return instance as QCoreApplication; + } + return QCoreApplication.fromCppPointer(cppPointer, needsAutoDelete); + } + String getFinalizerName() { + return "c_QCoreApplication_Finalizer"; + } + + static // addLibraryPath(const QString & arg__1) + addLibraryPath(String arg__1) { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_static_QCoreApplication__addLibraryPath_QString') + .asFunction(); + func(arg__1.toNativeUtf8()); + } + + static // applicationDirPath() + QString applicationDirPath() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_QCoreApplication__applicationDirPath') + .asFunction(); + ffi.Pointer result = func(); + return QString.fromCppPointer(result, true); + } + + static // applicationFilePath() + QString applicationFilePath() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_QCoreApplication__applicationFilePath') + .asFunction(); + ffi.Pointer result = func(); + return QString.fromCppPointer(result, true); + } + + static // applicationName() + QString applicationName() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_QCoreApplication__applicationName') + .asFunction(); + ffi.Pointer result = func(); + return QString.fromCppPointer(result, true); + } // applicationNameChanged() + + applicationNameChanged() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QCoreApplication__applicationNameChanged') + .asFunction(); + func(thisCpp); + } + + void onApplicationNameChanged(Function callback, {QObject? context}) { + final SignalHandler func = _dylib + .lookup>( + 'c_QCoreApplication__onApplicationNameChanged') + .asFunction(); + final dartCallback = + ffi.Pointer.fromFunction)>( + onApplicationNameChanged_callback); + final callbackMethod = onApplicationNameChanged_callback; + var handlers = signalHandlerersBySignal[callbackMethod] ?? []; + handlers.add(callback); + signalHandlerersBySignal[callbackMethod] = handlers; + ffi.Pointer contextPtr = + context == null ? ffi.nullptr : context.thisCpp; + func(thisCpp, contextPtr, dartCallback); + } + + static void onApplicationNameChanged_callback(ffi.Pointer thisCpp) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as QCoreApplication; + final signalHandlers = dartInstance + .signalHandlerersBySignal[onApplicationNameChanged_callback] ?? + []; + for (var signalHandler in signalHandlers) { + signalHandler(); + } + } + + static // applicationVersion() + QString applicationVersion() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_QCoreApplication__applicationVersion') + .asFunction(); + ffi.Pointer result = func(); + return QString.fromCppPointer(result, true); + } // applicationVersionChanged() + + applicationVersionChanged() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QCoreApplication__applicationVersionChanged') + .asFunction(); + func(thisCpp); + } + + void onApplicationVersionChanged(Function callback, {QObject? context}) { + final SignalHandler func = _dylib + .lookup>( + 'c_QCoreApplication__onApplicationVersionChanged') + .asFunction(); + final dartCallback = + ffi.Pointer.fromFunction)>( + onApplicationVersionChanged_callback); + final callbackMethod = onApplicationVersionChanged_callback; + var handlers = signalHandlerersBySignal[callbackMethod] ?? []; + handlers.add(callback); + signalHandlerersBySignal[callbackMethod] = handlers; + ffi.Pointer contextPtr = + context == null ? ffi.nullptr : context.thisCpp; + func(thisCpp, contextPtr, dartCallback); + } + + static void onApplicationVersionChanged_callback(ffi.Pointer thisCpp) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as QCoreApplication; + final signalHandlers = dartInstance + .signalHandlerersBySignal[onApplicationVersionChanged_callback] ?? + []; + for (var signalHandler in signalHandlers) { + signalHandler(); + } + } + + static // arguments() + QList arguments() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_QCoreApplication__arguments') + .asFunction(); + ffi.Pointer result = func(); + return QList.fromCppPointer(result, true); + } + + static // closingDown() + bool closingDown() { + final bool_Func_void func = _dylib + .lookup>( + 'c_static_QCoreApplication__closingDown') + .asFunction(); + return func() != 0; + } + + static void customEvent_calledFromC( + ffi.Pointer thisCpp, ffi.Pointer? event) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as QCoreApplication; + if (dartInstance == null) { + print( + "Dart instance not found for QCoreApplication::customEvent(QEvent * event)! (${thisCpp.address})"); + throw Error(); + } + dartInstance.customEvent((event == null || event.address == 0) + ? null + : QEvent.fromCppPointer(event)); + } + + static int event_calledFromC( + ffi.Pointer thisCpp, ffi.Pointer? arg__1) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as QCoreApplication; + if (dartInstance == null) { + print( + "Dart instance not found for QCoreApplication::event(QEvent * arg__1)! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.event((arg__1 == null || arg__1.address == 0) + ? null + : QEvent.fromCppPointer(arg__1)); + return result ? 1 : 0; + } + + static int eventFilter_calledFromC(ffi.Pointer thisCpp, + ffi.Pointer? watched, ffi.Pointer? event) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as QCoreApplication; + if (dartInstance == null) { + print( + "Dart instance not found for QCoreApplication::eventFilter(QObject * watched, QEvent * event)! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.eventFilter( + (watched == null || watched.address == 0) + ? null + : QObject.fromCppPointer(watched), + (event == null || event.address == 0) + ? null + : QEvent.fromCppPointer(event)); + return result ? 1 : 0; + } + + static // exec() + int exec() { + final int_Func_void func = _dylib + .lookup>( + 'c_static_QCoreApplication__exec') + .asFunction(); + return func(); + } + + static // exit(int retcode) + exit({int retcode = 0}) { + final void_Func_int func = _dylib + .lookup>( + 'c_static_QCoreApplication__exit_int') + .asFunction(); + func(retcode); + } + + static // forwardEvent(QObject * receiver, QEvent * event, QEvent * originatingEvent) + bool forwardEvent(QObject? receiver, QEvent? event, + {QEvent? originatingEvent}) { + final bool_Func_voidstar_voidstar_voidstar func = _dylib + .lookup>( + 'c_static_QCoreApplication__forwardEvent_QObject_QEvent_QEvent') + .asFunction(); + return func( + receiver == null ? ffi.nullptr : receiver.thisCpp, + event == null ? ffi.nullptr : event.thisCpp, + originatingEvent == null + ? ffi.nullptr + : originatingEvent.thisCpp) != + 0; + } + + static // instance() + QCoreApplication instance() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_QCoreApplication__instance') + .asFunction(); + ffi.Pointer result = func(); + return QCoreApplication.fromCppPointer(result, false); + } + + static // isQuitLockEnabled() + bool isQuitLockEnabled() { + final bool_Func_void func = _dylib + .lookup>( + 'c_static_QCoreApplication__isQuitLockEnabled') + .asFunction(); + return func() != 0; + } + + static // isSetuidAllowed() + bool isSetuidAllowed() { + final bool_Func_void func = _dylib + .lookup>( + 'c_static_QCoreApplication__isSetuidAllowed') + .asFunction(); + return func() != 0; + } + + static // libraryPaths() + QList libraryPaths() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_QCoreApplication__libraryPaths') + .asFunction(); + ffi.Pointer result = func(); + return QList.fromCppPointer(result, true); + } + + static // libraryPathsLocked() + QList libraryPathsLocked() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_QCoreApplication__libraryPathsLocked') + .asFunction(); + ffi.Pointer result = func(); + return QList.fromCppPointer(result, true); + } // notify(QObject * arg__1, QEvent * arg__2) + + bool notify(QObject? arg__1, QEvent? arg__2) { + final bool_Func_voidstar_voidstar_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(688)) + .asFunction(); + return func(thisCpp, arg__1 == null ? ffi.nullptr : arg__1.thisCpp, + arg__2 == null ? ffi.nullptr : arg__2.thisCpp) != + 0; + } + + static int notify_calledFromC(ffi.Pointer thisCpp, + ffi.Pointer? arg__1, ffi.Pointer? arg__2) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as QCoreApplication; + if (dartInstance == null) { + print( + "Dart instance not found for QCoreApplication::notify(QObject * arg__1, QEvent * arg__2)! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.notify( + (arg__1 == null || arg__1.address == 0) + ? null + : QObject.fromCppPointer(arg__1), + (arg__2 == null || arg__2.address == 0) + ? null + : QEvent.fromCppPointer(arg__2)); + return result ? 1 : 0; + } + + static // notifyInternal2(QObject * receiver, QEvent * arg__2) + bool notifyInternal2(QObject? receiver, QEvent? arg__2) { + final bool_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_static_QCoreApplication__notifyInternal2_QObject_QEvent') + .asFunction(); + return func(receiver == null ? ffi.nullptr : receiver.thisCpp, + arg__2 == null ? ffi.nullptr : arg__2.thisCpp) != + 0; + } + + static // organizationDomain() + QString organizationDomain() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_QCoreApplication__organizationDomain') + .asFunction(); + ffi.Pointer result = func(); + return QString.fromCppPointer(result, true); + } // organizationDomainChanged() + + organizationDomainChanged() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QCoreApplication__organizationDomainChanged') + .asFunction(); + func(thisCpp); + } + + void onOrganizationDomainChanged(Function callback, {QObject? context}) { + final SignalHandler func = _dylib + .lookup>( + 'c_QCoreApplication__onOrganizationDomainChanged') + .asFunction(); + final dartCallback = + ffi.Pointer.fromFunction)>( + onOrganizationDomainChanged_callback); + final callbackMethod = onOrganizationDomainChanged_callback; + var handlers = signalHandlerersBySignal[callbackMethod] ?? []; + handlers.add(callback); + signalHandlerersBySignal[callbackMethod] = handlers; + ffi.Pointer contextPtr = + context == null ? ffi.nullptr : context.thisCpp; + func(thisCpp, contextPtr, dartCallback); + } + + static void onOrganizationDomainChanged_callback(ffi.Pointer thisCpp) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as QCoreApplication; + final signalHandlers = dartInstance + .signalHandlerersBySignal[onOrganizationDomainChanged_callback] ?? + []; + for (var signalHandler in signalHandlers) { + signalHandler(); + } + } + + static // organizationName() + QString organizationName() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_QCoreApplication__organizationName') + .asFunction(); + ffi.Pointer result = func(); + return QString.fromCppPointer(result, true); + } // organizationNameChanged() + + organizationNameChanged() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QCoreApplication__organizationNameChanged') + .asFunction(); + func(thisCpp); + } + + void onOrganizationNameChanged(Function callback, {QObject? context}) { + final SignalHandler func = _dylib + .lookup>( + 'c_QCoreApplication__onOrganizationNameChanged') + .asFunction(); + final dartCallback = + ffi.Pointer.fromFunction)>( + onOrganizationNameChanged_callback); + final callbackMethod = onOrganizationNameChanged_callback; + var handlers = signalHandlerersBySignal[callbackMethod] ?? []; + handlers.add(callback); + signalHandlerersBySignal[callbackMethod] = handlers; + ffi.Pointer contextPtr = + context == null ? ffi.nullptr : context.thisCpp; + func(thisCpp, contextPtr, dartCallback); + } + + static void onOrganizationNameChanged_callback(ffi.Pointer thisCpp) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as QCoreApplication; + final signalHandlers = dartInstance + .signalHandlerersBySignal[onOrganizationNameChanged_callback] ?? + []; + for (var signalHandler in signalHandlers) { + signalHandler(); + } + } + + static // postEvent(QObject * receiver, QEvent * event, int priority) + postEvent(QObject? receiver, QEvent? event, + {int priority = Qt_EventPriority.NormalEventPriority}) { + final void_Func_voidstar_voidstar_int func = _dylib + .lookup>( + 'c_static_QCoreApplication__postEvent_QObject_QEvent_int') + .asFunction(); + func(receiver == null ? ffi.nullptr : receiver.thisCpp, + event == null ? ffi.nullptr : event.thisCpp, priority); + } + + static // processEvents() + processEvents() { + final void_Func_void func = _dylib + .lookup>( + 'c_static_QCoreApplication__processEvents') + .asFunction(); + func(); + } + + static // quit() + quit() { + final void_Func_void func = _dylib + .lookup>( + 'c_static_QCoreApplication__quit') + .asFunction(); + func(); + } + + static // removeLibraryPath(const QString & arg__1) + removeLibraryPath(String arg__1) { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_static_QCoreApplication__removeLibraryPath_QString') + .asFunction(); + func(arg__1.toNativeUtf8()); + } + + static // removePostedEvents(QObject * receiver, int eventType) + removePostedEvents(QObject? receiver, {int eventType = 0}) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_static_QCoreApplication__removePostedEvents_QObject_int') + .asFunction(); + func(receiver == null ? ffi.nullptr : receiver.thisCpp, eventType); + } + + static // sendEvent(QObject * receiver, QEvent * event) + bool sendEvent(QObject? receiver, QEvent? event) { + final bool_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_static_QCoreApplication__sendEvent_QObject_QEvent') + .asFunction(); + return func(receiver == null ? ffi.nullptr : receiver.thisCpp, + event == null ? ffi.nullptr : event.thisCpp) != + 0; + } + + static // sendPostedEvents(QObject * receiver, int event_type) + sendPostedEvents({QObject? receiver, int event_type = 0}) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_static_QCoreApplication__sendPostedEvents_QObject_int') + .asFunction(); + func(receiver == null ? ffi.nullptr : receiver.thisCpp, event_type); + } + + static // sendSpontaneousEvent(QObject * receiver, QEvent * event) + bool sendSpontaneousEvent(QObject? receiver, QEvent? event) { + final bool_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_static_QCoreApplication__sendSpontaneousEvent_QObject_QEvent') + .asFunction(); + return func(receiver == null ? ffi.nullptr : receiver.thisCpp, + event == null ? ffi.nullptr : event.thisCpp) != + 0; + } + + static // setApplicationName(const QString & application) + setApplicationName(String application) { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_static_QCoreApplication__setApplicationName_QString') + .asFunction(); + func(application.toNativeUtf8()); + } + + static // setApplicationVersion(const QString & version) + setApplicationVersion(String version) { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_static_QCoreApplication__setApplicationVersion_QString') + .asFunction(); + func(version.toNativeUtf8()); + } + + static // setLibraryPaths(const QList & arg__1) + setLibraryPaths(QList arg__1) { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_static_QCoreApplication__setLibraryPaths_QList_QString') + .asFunction(); + func(arg__1 == null ? ffi.nullptr : arg__1.thisCpp); + } + + static // setOrganizationDomain(const QString & orgDomain) + setOrganizationDomain(String orgDomain) { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_static_QCoreApplication__setOrganizationDomain_QString') + .asFunction(); + func(orgDomain.toNativeUtf8()); + } + + static // setOrganizationName(const QString & orgName) + setOrganizationName(String orgName) { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_static_QCoreApplication__setOrganizationName_QString') + .asFunction(); + func(orgName.toNativeUtf8()); + } + + static // setQuitLockEnabled(bool enabled) + setQuitLockEnabled(bool enabled) { + final void_Func_bool func = _dylib + .lookup>( + 'c_static_QCoreApplication__setQuitLockEnabled_bool') + .asFunction(); + func(enabled ? 1 : 0); + } + + static // setSetuidAllowed(bool allow) + setSetuidAllowed(bool allow) { + final void_Func_bool func = _dylib + .lookup>( + 'c_static_QCoreApplication__setSetuidAllowed_bool') + .asFunction(); + func(allow ? 1 : 0); + } + + static // startingUp() + bool startingUp() { + final bool_Func_void func = _dylib + .lookup>( + 'c_static_QCoreApplication__startingUp') + .asFunction(); + return func() != 0; + } + + static // tr(const char * s, const char * c, int n) + QString tr(String? s, String? c, int n) { + final voidstar_Func_string_string_int func = _dylib + .lookup>( + 'c_static_QCoreApplication__tr_char_char_int') + .asFunction(); + ffi.Pointer result = func( + s?.toNativeUtf8() ?? ffi.nullptr, c?.toNativeUtf8() ?? ffi.nullptr, n); + return QString.fromCppPointer(result, true); + } + + static // translate(const char * context, const char * key, const char * disambiguation, int n) + QString translate(String? context, String? key, + {String? disambiguation, int n = -1}) { + final voidstar_Func_string_string_string_int func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_string_string_string_ffi_Int32_FFI>>( + 'c_static_QCoreApplication__translate_char_char_char_int') + .asFunction(); + ffi.Pointer result = func( + context?.toNativeUtf8() ?? ffi.nullptr, + key?.toNativeUtf8() ?? ffi.nullptr, + disambiguation?.toNativeUtf8() ?? ffi.nullptr, + n); + return QString.fromCppPointer(result, true); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QCoreApplication__destructor') + .asFunction(); + func(thisCpp); + } + + String cFunctionSymbolName(int methodId) { + switch (methodId) { + case 481: + return "c_QCoreApplication__customEvent_QEvent"; + case 490: + return "c_QCoreApplication__event_QEvent"; + case 491: + return "c_QCoreApplication__eventFilter_QObject_QEvent"; + case 688: + return "c_QCoreApplication__notify_QObject_QEvent"; + } + return super.cFunctionSymbolName(methodId); + } + + static String methodNameFromId(int methodId) { + switch (methodId) { + case 481: + return "customEvent"; + case 490: + return "event"; + case 491: + return "eventFilter"; + case 688: + return "notify"; + } + throw Error(); + } + + void registerCallbacks() { + assert(thisCpp != null); + final RegisterMethodIsReimplementedCallback registerCallback = _dylib + .lookup>( + 'c_QCoreApplication__registerVirtualMethodCallback') + .asFunction(); + final callback481 = + ffi.Pointer.fromFunction( + QObject.customEvent_calledFromC); + registerCallback(thisCpp, callback481, 481); + const callbackExcept490 = 0; + final callback490 = + ffi.Pointer.fromFunction( + QCoreApplication.event_calledFromC, callbackExcept490); + registerCallback(thisCpp, callback490, 490); + const callbackExcept491 = 0; + final callback491 = + ffi.Pointer.fromFunction( + QObject.eventFilter_calledFromC, callbackExcept491); + registerCallback(thisCpp, callback491, 491); + const callbackExcept688 = 0; + final callback688 = + ffi.Pointer.fromFunction( + QCoreApplication.notify_calledFromC, callbackExcept688); + registerCallback(thisCpp, callback688, 688); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/QEvent.dart b/tests/generated/TestBindings/dart/lib/src/QEvent.dart new file mode 100644 index 0000000..7f03dbe --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/QEvent.dart @@ -0,0 +1,202 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class QEvent implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = false; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory QEvent.fromCache(var cppPointer, [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + QEvent.fromCppPointer(cppPointer, needsAutoDelete)) as QEvent; + } + QEvent.fromCppPointer(var cppPointer, [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + QEvent.init() {} + String getFinalizerName() { + return "c_QEvent_Finalizer"; + } // accept() + + accept() { + final void_Func_voidstar func = _dylib + .lookup>('c_QEvent__accept') + .asFunction(); + func(thisCpp); + } // clone() const + + QEvent clone() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(643)) + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QEvent.fromCppPointer(result, false); + } + + static ffi.Pointer clone_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = QEvent.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for QEvent::clone() const! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.clone(); + return result.thisCpp; + } // ignore() + + ignore() { + final void_Func_voidstar func = _dylib + .lookup>('c_QEvent__ignore') + .asFunction(); + func(thisCpp); + } // isAccepted() const + + bool isAccepted() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QEvent__isAccepted') + .asFunction(); + return func(thisCpp) != 0; + } // isInputEvent() const + + bool isInputEvent() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QEvent__isInputEvent') + .asFunction(); + return func(thisCpp) != 0; + } // isPointerEvent() const + + bool isPointerEvent() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QEvent__isPointerEvent') + .asFunction(); + return func(thisCpp) != 0; + } // isSinglePointEvent() const + + bool isSinglePointEvent() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QEvent__isSinglePointEvent') + .asFunction(); + return func(thisCpp) != 0; + } + + static // registerEventType(int hint) + int registerEventType({int hint = -1}) { + final int_Func_int func = _dylib + .lookup>( + 'c_static_QEvent__registerEventType_int') + .asFunction(); + return func(hint); + } // setAccepted(bool accepted) + + setAccepted(bool accepted) { + final void_Func_voidstar_bool func = _dylib + .lookup>( + cFunctionSymbolName(651)) + .asFunction(); + func(thisCpp, accepted ? 1 : 0); + } + + static void setAccepted_calledFromC(ffi.Pointer thisCpp, int accepted) { + var dartInstance = QEvent.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for QEvent::setAccepted(bool accepted)! (${thisCpp.address})"); + throw Error(); + } + dartInstance.setAccepted(accepted != 0); + } // setSpontaneous() + + setSpontaneous() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QEvent__setSpontaneous') + .asFunction(); + func(thisCpp); + } // spontaneous() const + + bool spontaneous() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QEvent__spontaneous') + .asFunction(); + return func(thisCpp) != 0; + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QEvent__destructor') + .asFunction(); + func(thisCpp); + } + + String cFunctionSymbolName(int methodId) { + switch (methodId) { + case 643: + return "c_QEvent__clone"; + case 651: + return "c_QEvent__setAccepted_bool"; + } + return ""; + } + + static String methodNameFromId(int methodId) { + switch (methodId) { + case 643: + return "clone"; + case 651: + return "setAccepted"; + } + throw Error(); + } + + void registerCallbacks() { + assert(thisCpp != null); + final RegisterMethodIsReimplementedCallback registerCallback = _dylib + .lookup>( + 'c_QEvent__registerVirtualMethodCallback') + .asFunction(); + final callback643 = ffi.Pointer.fromFunction( + QEvent.clone_calledFromC); + registerCallback(thisCpp, callback643, 643); + final callback651 = + ffi.Pointer.fromFunction( + QEvent.setAccepted_calledFromC); + registerCallback(thisCpp, callback651, 651); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/QGuiApplication.dart b/tests/generated/TestBindings/dart/lib/src/QGuiApplication.dart new file mode 100644 index 0000000..f515265 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/QGuiApplication.dart @@ -0,0 +1,492 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; + +class QGuiApplication extends QCoreApplication { + QGuiApplication.fromCppPointer(var cppPointer, [var needsAutoDelete = false]) + : super.fromCppPointer(cppPointer, needsAutoDelete) {} + QGuiApplication.init() : super.init() {} + factory QGuiApplication.fromCache(var cppPointer, [needsAutoDelete = false]) { + if (QObject.isCached(cppPointer)) { + var instance = QObject.s_dartInstanceByCppPtr[cppPointer.address]; + if (instance != null) return instance as QGuiApplication; + } + return QGuiApplication.fromCppPointer(cppPointer, needsAutoDelete); + } + String getFinalizerName() { + return "c_QGuiApplication_Finalizer"; + } + + static // applicationDisplayName() + QString applicationDisplayName() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_QGuiApplication__applicationDisplayName') + .asFunction(); + ffi.Pointer result = func(); + return QString.fromCppPointer(result, true); + } // applicationDisplayNameChanged() + + applicationDisplayNameChanged() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QGuiApplication__applicationDisplayNameChanged') + .asFunction(); + func(thisCpp); + } + + void onApplicationDisplayNameChanged(Function callback, {QObject? context}) { + final SignalHandler func = _dylib + .lookup>( + 'c_QGuiApplication__onApplicationDisplayNameChanged') + .asFunction(); + final dartCallback = + ffi.Pointer.fromFunction)>( + onApplicationDisplayNameChanged_callback); + final callbackMethod = onApplicationDisplayNameChanged_callback; + var handlers = signalHandlerersBySignal[callbackMethod] ?? []; + handlers.add(callback); + signalHandlerersBySignal[callbackMethod] = handlers; + ffi.Pointer contextPtr = + context == null ? ffi.nullptr : context.thisCpp; + func(thisCpp, contextPtr, dartCallback); + } + + static void onApplicationDisplayNameChanged_callback( + ffi.Pointer thisCpp) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as QGuiApplication; + final signalHandlers = dartInstance.signalHandlerersBySignal[ + onApplicationDisplayNameChanged_callback] ?? + []; + for (var signalHandler in signalHandlers) { + signalHandler(); + } + } + + static void customEvent_calledFromC( + ffi.Pointer thisCpp, ffi.Pointer? event) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as QGuiApplication; + if (dartInstance == null) { + print( + "Dart instance not found for QGuiApplication::customEvent(QEvent * event)! (${thisCpp.address})"); + throw Error(); + } + dartInstance.customEvent((event == null || event.address == 0) + ? null + : QEvent.fromCppPointer(event)); + } + + static // desktopFileName() + QString desktopFileName() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_QGuiApplication__desktopFileName') + .asFunction(); + ffi.Pointer result = func(); + return QString.fromCppPointer(result, true); + } + + static // desktopSettingsAware() + bool desktopSettingsAware() { + final bool_Func_void func = _dylib + .lookup>( + 'c_static_QGuiApplication__desktopSettingsAware') + .asFunction(); + return func() != 0; + } // devicePixelRatio() const + + double devicePixelRatio() { + final double_Func_voidstar func = _dylib + .lookup>( + 'c_QGuiApplication__devicePixelRatio') + .asFunction(); + return func(thisCpp); + } + + static int event_calledFromC( + ffi.Pointer thisCpp, ffi.Pointer? arg__1) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as QGuiApplication; + if (dartInstance == null) { + print( + "Dart instance not found for QGuiApplication::event(QEvent * arg__1)! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.event((arg__1 == null || arg__1.address == 0) + ? null + : QEvent.fromCppPointer(arg__1)); + return result ? 1 : 0; + } + + static int eventFilter_calledFromC(ffi.Pointer thisCpp, + ffi.Pointer? watched, ffi.Pointer? event) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as QGuiApplication; + if (dartInstance == null) { + print( + "Dart instance not found for QGuiApplication::eventFilter(QObject * watched, QEvent * event)! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.eventFilter( + (watched == null || watched.address == 0) + ? null + : QObject.fromCppPointer(watched), + (event == null || event.address == 0) + ? null + : QEvent.fromCppPointer(event)); + return result ? 1 : 0; + } + + static // exec() + int exec() { + final int_Func_void func = _dylib + .lookup>( + 'c_static_QGuiApplication__exec') + .asFunction(); + return func(); + } + + static // focusObject() + QObject focusObject() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_QGuiApplication__focusObject') + .asFunction(); + ffi.Pointer result = func(); + return QObject.fromCppPointer(result, false); + } // focusObjectChanged(QObject * focusObject) + + focusObjectChanged(QObject? focusObject) { + final void_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QGuiApplication__focusObjectChanged_QObject') + .asFunction(); + func(thisCpp, focusObject == null ? ffi.nullptr : focusObject.thisCpp); + } + + void onFocusObjectChanged(Function callback, {QObject? context}) { + final SignalHandler func = _dylib + .lookup>( + 'c_QGuiApplication__onFocusObjectChanged_QObject') + .asFunction(); + final dartCallback = + ffi.Pointer.fromFunction)>( + onFocusObjectChanged_callback); + final callbackMethod = onFocusObjectChanged_callback; + var handlers = signalHandlerersBySignal[callbackMethod] ?? []; + handlers.add(callback); + signalHandlerersBySignal[callbackMethod] = handlers; + ffi.Pointer contextPtr = + context == null ? ffi.nullptr : context.thisCpp; + func(thisCpp, contextPtr, dartCallback); + } + + static void onFocusObjectChanged_callback(ffi.Pointer thisCpp) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as QGuiApplication; + final signalHandlers = + dartInstance.signalHandlerersBySignal[onFocusObjectChanged_callback] ?? + []; + for (var signalHandler in signalHandlers) { + signalHandler(); + } + } // fontDatabaseChanged() + + fontDatabaseChanged() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QGuiApplication__fontDatabaseChanged') + .asFunction(); + func(thisCpp); + } + + void onFontDatabaseChanged(Function callback, {QObject? context}) { + final SignalHandler func = _dylib + .lookup>( + 'c_QGuiApplication__onFontDatabaseChanged') + .asFunction(); + final dartCallback = + ffi.Pointer.fromFunction)>( + onFontDatabaseChanged_callback); + final callbackMethod = onFontDatabaseChanged_callback; + var handlers = signalHandlerersBySignal[callbackMethod] ?? []; + handlers.add(callback); + signalHandlerersBySignal[callbackMethod] = handlers; + ffi.Pointer contextPtr = + context == null ? ffi.nullptr : context.thisCpp; + func(thisCpp, contextPtr, dartCallback); + } + + static void onFontDatabaseChanged_callback(ffi.Pointer thisCpp) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as QGuiApplication; + final signalHandlers = + dartInstance.signalHandlerersBySignal[onFontDatabaseChanged_callback] ?? + []; + for (var signalHandler in signalHandlers) { + signalHandler(); + } + } + + static // isLeftToRight() + bool isLeftToRight() { + final bool_Func_void func = _dylib + .lookup>( + 'c_static_QGuiApplication__isLeftToRight') + .asFunction(); + return func() != 0; + } + + static // isRightToLeft() + bool isRightToLeft() { + final bool_Func_void func = _dylib + .lookup>( + 'c_static_QGuiApplication__isRightToLeft') + .asFunction(); + return func() != 0; + } // isSavingSession() const + + bool isSavingSession() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QGuiApplication__isSavingSession') + .asFunction(); + return func(thisCpp) != 0; + } // isSessionRestored() const + + bool isSessionRestored() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QGuiApplication__isSessionRestored') + .asFunction(); + return func(thisCpp) != 0; + } // lastWindowClosed() + + lastWindowClosed() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QGuiApplication__lastWindowClosed') + .asFunction(); + func(thisCpp); + } + + void onLastWindowClosed(Function callback, {QObject? context}) { + final SignalHandler func = _dylib + .lookup>( + 'c_QGuiApplication__onLastWindowClosed') + .asFunction(); + final dartCallback = + ffi.Pointer.fromFunction)>( + onLastWindowClosed_callback); + final callbackMethod = onLastWindowClosed_callback; + var handlers = signalHandlerersBySignal[callbackMethod] ?? []; + handlers.add(callback); + signalHandlerersBySignal[callbackMethod] = handlers; + ffi.Pointer contextPtr = + context == null ? ffi.nullptr : context.thisCpp; + func(thisCpp, contextPtr, dartCallback); + } + + static void onLastWindowClosed_callback(ffi.Pointer thisCpp) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as QGuiApplication; + final signalHandlers = + dartInstance.signalHandlerersBySignal[onLastWindowClosed_callback] ?? + []; + for (var signalHandler in signalHandlers) { + signalHandler(); + } + } + + static int notify_calledFromC(ffi.Pointer thisCpp, + ffi.Pointer? arg__1, ffi.Pointer? arg__2) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as QGuiApplication; + if (dartInstance == null) { + print( + "Dart instance not found for QGuiApplication::notify(QObject * arg__1, QEvent * arg__2)! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.notify( + (arg__1 == null || arg__1.address == 0) + ? null + : QObject.fromCppPointer(arg__1), + (arg__2 == null || arg__2.address == 0) + ? null + : QEvent.fromCppPointer(arg__2)); + return result ? 1 : 0; + } + + static // platformName() + QString platformName() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static_QGuiApplication__platformName') + .asFunction(); + ffi.Pointer result = func(); + return QString.fromCppPointer(result, true); + } + + static // quitOnLastWindowClosed() + bool quitOnLastWindowClosed() { + final bool_Func_void func = _dylib + .lookup>( + 'c_static_QGuiApplication__quitOnLastWindowClosed') + .asFunction(); + return func() != 0; + } + + static // restoreOverrideCursor() + restoreOverrideCursor() { + final void_Func_void func = _dylib + .lookup>( + 'c_static_QGuiApplication__restoreOverrideCursor') + .asFunction(); + func(); + } // sessionId() const + + QString sessionId() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QGuiApplication__sessionId') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QString.fromCppPointer(result, true); + } // sessionKey() const + + QString sessionKey() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QGuiApplication__sessionKey') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QString.fromCppPointer(result, true); + } + + static // setApplicationDisplayName(const QString & name) + setApplicationDisplayName(String name) { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_static_QGuiApplication__setApplicationDisplayName_QString') + .asFunction(); + func(name.toNativeUtf8()); + } + + static // setDesktopFileName(const QString & name) + setDesktopFileName(String name) { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_static_QGuiApplication__setDesktopFileName_QString') + .asFunction(); + func(name.toNativeUtf8()); + } + + static // setDesktopSettingsAware(bool on) + setDesktopSettingsAware(bool on) { + final void_Func_bool func = _dylib + .lookup>( + 'c_static_QGuiApplication__setDesktopSettingsAware_bool') + .asFunction(); + func(on ? 1 : 0); + } + + static // setQuitOnLastWindowClosed(bool quit) + setQuitOnLastWindowClosed(bool quit) { + final void_Func_bool func = _dylib + .lookup>( + 'c_static_QGuiApplication__setQuitOnLastWindowClosed_bool') + .asFunction(); + func(quit ? 1 : 0); + } + + static // sync() + sync() { + final void_Func_void func = _dylib + .lookup>( + 'c_static_QGuiApplication__sync') + .asFunction(); + func(); + } + + static // tr(const char * s, const char * c, int n) + QString tr(String? s, String? c, int n) { + final voidstar_Func_string_string_int func = _dylib + .lookup>( + 'c_static_QGuiApplication__tr_char_char_int') + .asFunction(); + ffi.Pointer result = func( + s?.toNativeUtf8() ?? ffi.nullptr, c?.toNativeUtf8() ?? ffi.nullptr, n); + return QString.fromCppPointer(result, true); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QGuiApplication__destructor') + .asFunction(); + func(thisCpp); + } + + String cFunctionSymbolName(int methodId) { + switch (methodId) { + case 481: + return "c_QGuiApplication__customEvent_QEvent"; + case 490: + return "c_QGuiApplication__event_QEvent"; + case 491: + return "c_QGuiApplication__eventFilter_QObject_QEvent"; + case 688: + return "c_QGuiApplication__notify_QObject_QEvent"; + } + return super.cFunctionSymbolName(methodId); + } + + static String methodNameFromId(int methodId) { + switch (methodId) { + case 481: + return "customEvent"; + case 490: + return "event"; + case 491: + return "eventFilter"; + case 688: + return "notify"; + } + throw Error(); + } + + void registerCallbacks() { + assert(thisCpp != null); + final RegisterMethodIsReimplementedCallback registerCallback = _dylib + .lookup>( + 'c_QGuiApplication__registerVirtualMethodCallback') + .asFunction(); + final callback481 = + ffi.Pointer.fromFunction( + QObject.customEvent_calledFromC); + registerCallback(thisCpp, callback481, 481); + const callbackExcept490 = 0; + final callback490 = + ffi.Pointer.fromFunction( + QGuiApplication.event_calledFromC, callbackExcept490); + registerCallback(thisCpp, callback490, 490); + const callbackExcept491 = 0; + final callback491 = + ffi.Pointer.fromFunction( + QObject.eventFilter_calledFromC, callbackExcept491); + registerCallback(thisCpp, callback491, 491); + const callbackExcept688 = 0; + final callback688 = + ffi.Pointer.fromFunction( + QGuiApplication.notify_calledFromC, callbackExcept688); + registerCallback(thisCpp, callback688, 688); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/QHash.dart b/tests/generated/TestBindings/dart/lib/src/QHash.dart new file mode 100644 index 0000000..b5e60a5 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/QHash.dart @@ -0,0 +1,417 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class QHash implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = true; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory QHash.fromCache(var cppPointer, [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + QHash.fromCppPointer(cppPointer, needsAutoDelete)) as QHash; + } + QHash.fromCppPointer(var cppPointer, [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + QHash.init() {} + String getCFunctionName(int id) { + if (this is QHash) { + switch (id) { + case 604: + return "c_QHash_T_QString_QVariant_T___constructor"; + break; + case 608: + return "c_QHash_T_QString_QVariant_T___capacity"; + break; + case 609: + return "c_QHash_T_QString_QVariant_T___clear"; + break; + case 610: + return "c_QHash_T_QString_QVariant_T___contains_QString"; + break; + case 611: + return "c_QHash_T_QString_QVariant_T___count"; + break; + case 612: + return "c_QHash_T_QString_QVariant_T___count_QString"; + break; + case 613: + return "c_QHash_T_QString_QVariant_T___detach"; + break; + case 614: + return "c_QHash_T_QString_QVariant_T___empty"; + break; + case 615: + return "c_QHash_T_QString_QVariant_T___insert_QHash_Key_T"; + break; + case 616: + return "c_QHash_T_QString_QVariant_T___isDetached"; + break; + case 617: + return "c_QHash_T_QString_QVariant_T___isEmpty"; + break; + case 618: + return "c_QHash_T_QString_QVariant_T___isSharedWith_QHash_Key_T"; + break; + case 619: + return "c_QHash_T_QString_QVariant_T___key_QVariant"; + break; + case 620: + return "c_QHash_T_QString_QVariant_T___key_QVariant_QString"; + break; + case 622: + return "c_QHash_T_QString_QVariant_T___keys"; + break; + case 623: + return "c_QHash_T_QString_QVariant_T___keys_QVariant"; + break; + case 624: + return "c_QHash_T_QString_QVariant_T___load_factor"; + break; + case 631: + return "c_QHash_T_QString_QVariant_T___remove_QString"; + break; + case 632: + return "c_QHash_T_QString_QVariant_T___reserve_qsizetype"; + break; + case 633: + return "c_QHash_T_QString_QVariant_T___size"; + break; + case 634: + return "c_QHash_T_QString_QVariant_T___squeeze"; + break; + case 636: + return "c_QHash_T_QString_QVariant_T___take_QString"; + break; + case 637: + return "c_QHash_T_QString_QVariant_T___value_QString"; + break; + case 638: + return "c_QHash_T_QString_QVariant_T___value_QString_QVariant"; + break; + case 640: + return "c_QHash_T_QString_QVariant_T___values"; + break; + } + } + return ""; + } + + String getFinalizerName() { + if (this is QHash) { + return "c_QHash_T_QString_QVariant_T__Finalizer"; + } + print( + "ERROR: Couldn't find finalizerName for" + this.runtimeType.toString()); + return ""; + } //QHash() + + QHash() { + final voidstar_Func_void func = _dylib + .lookup>( + '${getCFunctionName(604)}') + .asFunction(); + thisCpp = func(); + QHash.s_dartInstanceByCppPtr[thisCpp.address] = this; + } // capacity() const + int capacity() { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(608)}') + .asFunction(); + return func(thisCpp); + } // clear() + + clear() { + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(609)}') + .asFunction(); + func(thisCpp); + } // contains(const Key & key) const + + bool contains(Key key) { + if (this is QHash) { + final bool_Func_voidstar_voidstar func = _dylib + .lookup>( + '${getCFunctionName(610)}') + .asFunction(); + return func(thisCpp, (key as String).toNativeUtf8()) != 0; + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } // count() const + + int count() { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(611)}') + .asFunction(); + return func(thisCpp); + } // count(const Key & key) const + + int count_2(Key key) { + if (this is QHash) { + final int_Func_voidstar_voidstar func = _dylib + .lookup>( + '${getCFunctionName(612)}') + .asFunction(); + return func(thisCpp, (key as String).toNativeUtf8()); + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } // detach() + + detach() { + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(613)}') + .asFunction(); + func(thisCpp); + } // empty() const + + bool empty() { + final bool_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(614)}') + .asFunction(); + return func(thisCpp) != 0; + } // insert(const QHash & hash) + + insert(QHash hash) { + final void_Func_voidstar_voidstar func = _dylib + .lookup>( + '${getCFunctionName(615)}') + .asFunction(); + func(thisCpp, hash == null ? ffi.nullptr : hash.thisCpp); + } // isDetached() const + + bool isDetached() { + final bool_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(616)}') + .asFunction(); + return func(thisCpp) != 0; + } // isEmpty() const + + bool isEmpty() { + final bool_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(617)}') + .asFunction(); + return func(thisCpp) != 0; + } // isSharedWith(const QHash & other) const + + bool isSharedWith(QHash other) { + final bool_Func_voidstar_voidstar func = _dylib + .lookup>( + '${getCFunctionName(618)}') + .asFunction(); + return func(thisCpp, other == null ? ffi.nullptr : other.thisCpp) != 0; + } // key(const T & value) const + + Key key(T value) { + if (this is QHash) { + final voidstar_Func_voidstar_voidstar func = _dylib + .lookup>( + '${getCFunctionName(619)}') + .asFunction(); + ffi.Pointer result = func( + thisCpp, + (value as QVariant) == null + ? ffi.nullptr + : (value as QVariant).thisCpp); + return (QString.fromCppPointer(result, true) as Key); + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } // key(const T & value, const Key & defaultKey) const + + Key key_2(T value, Key defaultKey) { + if (this is QHash) { + final voidstar_Func_voidstar_voidstar_voidstar func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_voidstar_voidstar_voidstar_FFI>>( + '${getCFunctionName(620)}') + .asFunction(); + ffi.Pointer result = func( + thisCpp, + (value as QVariant) == null + ? ffi.nullptr + : (value as QVariant).thisCpp, + (defaultKey as String).toNativeUtf8()); + return (QString.fromCppPointer(result, true) as Key); + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } // keyImpl(const T & value) const + + Key keyImpl(T value) { + if (this is QHash) { + final voidstar_Func_voidstar_voidstar func = _dylib + .lookup>( + '${getCFunctionName(621)}') + .asFunction(); + ffi.Pointer result = func( + thisCpp, + (value as QVariant) == null + ? ffi.nullptr + : (value as QVariant).thisCpp); + return (QString.fromCppPointer(result, true) as Key); + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } // load_factor() const + + double load_factor() { + final double_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(624)}') + .asFunction(); + return func(thisCpp); + } // remove(const Key & key) + + bool remove(Key key) { + if (this is QHash) { + final bool_Func_voidstar_voidstar func = _dylib + .lookup>( + '${getCFunctionName(631)}') + .asFunction(); + return func(thisCpp, (key as String).toNativeUtf8()) != 0; + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } // reserve(qsizetype size) + + reserve(int size) { + final void_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(632)}') + .asFunction(); + func(thisCpp, size); + } // size() const + + int size() { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(633)}') + .asFunction(); + return func(thisCpp); + } // squeeze() + + squeeze() { + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(634)}') + .asFunction(); + func(thisCpp); + } // take(const Key & key) + + T take(Key key) { + if (this is QHash) { + final voidstar_Func_voidstar_voidstar func = _dylib + .lookup>( + '${getCFunctionName(636)}') + .asFunction(); + ffi.Pointer result = func(thisCpp, (key as String).toNativeUtf8()); + return (QVariant.fromCppPointer(result, true) as T); + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } // value(const Key & key) const + + T value(Key key) { + if (this is QHash) { + final voidstar_Func_voidstar_voidstar func = _dylib + .lookup>( + '${getCFunctionName(637)}') + .asFunction(); + ffi.Pointer result = func(thisCpp, (key as String).toNativeUtf8()); + return (QVariant.fromCppPointer(result, true) as T); + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } // value(const Key & key, const T & defaultValue) const + + T value_2(Key key, T defaultValue) { + if (this is QHash) { + final voidstar_Func_voidstar_voidstar_voidstar func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_voidstar_voidstar_voidstar_FFI>>( + '${getCFunctionName(638)}') + .asFunction(); + ffi.Pointer result = func( + thisCpp, + (key as String).toNativeUtf8(), + (defaultValue as QVariant) == null + ? ffi.nullptr + : (defaultValue as QVariant).thisCpp); + return (QVariant.fromCppPointer(result, true) as T); + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } // valueImpl(const Key & key) const + + T valueImpl(Key key) { + if (this is QHash) { + final voidstar_Func_voidstar_voidstar func = _dylib + .lookup>( + '${getCFunctionName(639)}') + .asFunction(); + ffi.Pointer result = func(thisCpp, (key as String).toNativeUtf8()); + return (QVariant.fromCppPointer(result, true) as T); + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(-2)}') + .asFunction(); + func(thisCpp); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/QList.dart b/tests/generated/TestBindings/dart/lib/src/QList.dart new file mode 100644 index 0000000..0360a62 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/QList.dart @@ -0,0 +1,2011 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class QList implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = true; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory QList.fromCache(var cppPointer, [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + QList.fromCppPointer(cppPointer, needsAutoDelete)) as QList; + } + QList.fromCppPointer(var cppPointer, [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + QList.init() {} + String getCFunctionName(int id) { + if (this is QList) { + switch (id) { + case 543: + return "c_QList_T_SimpleStruct_T___constructor"; + break; + case 544: + return "c_QList_T_SimpleStruct_T___constructor_qsizetype"; + break; + case 546: + return "c_QList_T_SimpleStruct_T___append_QList_T"; + break; + case 547: + return "c_QList_T_SimpleStruct_T___at_qsizetype"; + break; + case 548: + return "c_QList_T_SimpleStruct_T___back"; + break; + case 549: + return "c_QList_T_SimpleStruct_T___back"; + break; + case 550: + return "c_QList_T_SimpleStruct_T___capacity"; + break; + case 551: + return "c_QList_T_SimpleStruct_T___clear"; + break; + case 553: + return "c_QList_T_SimpleStruct_T___constFirst"; + break; + case 554: + return "c_QList_T_SimpleStruct_T___constLast"; + break; + case 555: + return "c_QList_T_SimpleStruct_T___count"; + break; + case 558: + return "c_QList_T_SimpleStruct_T___detach"; + break; + case 559: + return "c_QList_T_SimpleStruct_T___empty"; + break; + case 560: + return "c_QList_T_SimpleStruct_T___first"; + break; + case 561: + return "c_QList_T_SimpleStruct_T___first"; + break; + case 562: + return "c_QList_T_SimpleStruct_T___first_qsizetype"; + break; + case 565: + return "c_QList_T_SimpleStruct_T___front"; + break; + case 566: + return "c_QList_T_SimpleStruct_T___front"; + break; + case 567: + return "c_QList_T_SimpleStruct_T___isDetached"; + break; + case 568: + return "c_QList_T_SimpleStruct_T___isEmpty"; + break; + case 569: + return "c_QList_T_SimpleStruct_T___isSharedWith_QList_T"; + break; + case 570: + return "c_QList_T_SimpleStruct_T___last"; + break; + case 571: + return "c_QList_T_SimpleStruct_T___last"; + break; + case 572: + return "c_QList_T_SimpleStruct_T___last_qsizetype"; + break; + case 573: + return "c_QList_T_SimpleStruct_T___length"; + break; + case 574: + return "c_QList_T_SimpleStruct_T___mid_qsizetype_qsizetype"; + break; + case 575: + return "c_QList_T_SimpleStruct_T___move_qsizetype_qsizetype"; + break; + case 584: + return "c_QList_T_SimpleStruct_T___pop_back"; + break; + case 585: + return "c_QList_T_SimpleStruct_T___pop_front"; + break; + case 586: + return "c_QList_T_SimpleStruct_T___remove_qsizetype_qsizetype"; + break; + case 587: + return "c_QList_T_SimpleStruct_T___removeAt_qsizetype"; + break; + case 588: + return "c_QList_T_SimpleStruct_T___removeFirst"; + break; + case 589: + return "c_QList_T_SimpleStruct_T___removeLast"; + break; + case 590: + return "c_QList_T_SimpleStruct_T___reserve_qsizetype"; + break; + case 591: + return "c_QList_T_SimpleStruct_T___resize_qsizetype"; + break; + case 593: + return "c_QList_T_SimpleStruct_T___shrink_to_fit"; + break; + case 594: + return "c_QList_T_SimpleStruct_T___size"; + break; + case 595: + return "c_QList_T_SimpleStruct_T___sliced_qsizetype"; + break; + case 596: + return "c_QList_T_SimpleStruct_T___sliced_qsizetype_qsizetype"; + break; + case 597: + return "c_QList_T_SimpleStruct_T___squeeze"; + break; + case 599: + return "c_QList_T_SimpleStruct_T___swapItemsAt_qsizetype_qsizetype"; + break; + case 600: + return "c_QList_T_SimpleStruct_T___takeAt_qsizetype"; + break; + case 601: + return "c_QList_T_SimpleStruct_T___toList"; + break; + case 602: + return "c_QList_T_SimpleStruct_T___toVector"; + break; + case 603: + return "c_QList_T_SimpleStruct_T___value_qsizetype"; + break; + } + } + if (this is QList) { + switch (id) { + case 543: + return "c_QList_T_qreal_T___constructor"; + break; + case 544: + return "c_QList_T_qreal_T___constructor_qsizetype"; + break; + case 546: + return "c_QList_T_qreal_T___append_QList_T"; + break; + case 547: + return "c_QList_T_qreal_T___at_qsizetype"; + break; + case 548: + return "c_QList_T_qreal_T___back"; + break; + case 549: + return "c_QList_T_qreal_T___back"; + break; + case 550: + return "c_QList_T_qreal_T___capacity"; + break; + case 551: + return "c_QList_T_qreal_T___clear"; + break; + case 553: + return "c_QList_T_qreal_T___constFirst"; + break; + case 554: + return "c_QList_T_qreal_T___constLast"; + break; + case 555: + return "c_QList_T_qreal_T___count"; + break; + case 558: + return "c_QList_T_qreal_T___detach"; + break; + case 559: + return "c_QList_T_qreal_T___empty"; + break; + case 560: + return "c_QList_T_qreal_T___first"; + break; + case 561: + return "c_QList_T_qreal_T___first"; + break; + case 562: + return "c_QList_T_qreal_T___first_qsizetype"; + break; + case 565: + return "c_QList_T_qreal_T___front"; + break; + case 566: + return "c_QList_T_qreal_T___front"; + break; + case 567: + return "c_QList_T_qreal_T___isDetached"; + break; + case 568: + return "c_QList_T_qreal_T___isEmpty"; + break; + case 569: + return "c_QList_T_qreal_T___isSharedWith_QList_T"; + break; + case 570: + return "c_QList_T_qreal_T___last"; + break; + case 571: + return "c_QList_T_qreal_T___last"; + break; + case 572: + return "c_QList_T_qreal_T___last_qsizetype"; + break; + case 573: + return "c_QList_T_qreal_T___length"; + break; + case 574: + return "c_QList_T_qreal_T___mid_qsizetype_qsizetype"; + break; + case 575: + return "c_QList_T_qreal_T___move_qsizetype_qsizetype"; + break; + case 584: + return "c_QList_T_qreal_T___pop_back"; + break; + case 585: + return "c_QList_T_qreal_T___pop_front"; + break; + case 586: + return "c_QList_T_qreal_T___remove_qsizetype_qsizetype"; + break; + case 587: + return "c_QList_T_qreal_T___removeAt_qsizetype"; + break; + case 588: + return "c_QList_T_qreal_T___removeFirst"; + break; + case 589: + return "c_QList_T_qreal_T___removeLast"; + break; + case 590: + return "c_QList_T_qreal_T___reserve_qsizetype"; + break; + case 591: + return "c_QList_T_qreal_T___resize_qsizetype"; + break; + case 593: + return "c_QList_T_qreal_T___shrink_to_fit"; + break; + case 594: + return "c_QList_T_qreal_T___size"; + break; + case 595: + return "c_QList_T_qreal_T___sliced_qsizetype"; + break; + case 596: + return "c_QList_T_qreal_T___sliced_qsizetype_qsizetype"; + break; + case 597: + return "c_QList_T_qreal_T___squeeze"; + break; + case 599: + return "c_QList_T_qreal_T___swapItemsAt_qsizetype_qsizetype"; + break; + case 600: + return "c_QList_T_qreal_T___takeAt_qsizetype"; + break; + case 601: + return "c_QList_T_qreal_T___toList"; + break; + case 602: + return "c_QList_T_qreal_T___toVector"; + break; + case 603: + return "c_QList_T_qreal_T___value_qsizetype"; + break; + } + } + if (this is QList) { + switch (id) { + case 543: + return "c_QList_T_int_T___constructor"; + break; + case 544: + return "c_QList_T_int_T___constructor_qsizetype"; + break; + case 546: + return "c_QList_T_int_T___append_QList_T"; + break; + case 547: + return "c_QList_T_int_T___at_qsizetype"; + break; + case 548: + return "c_QList_T_int_T___back"; + break; + case 549: + return "c_QList_T_int_T___back"; + break; + case 550: + return "c_QList_T_int_T___capacity"; + break; + case 551: + return "c_QList_T_int_T___clear"; + break; + case 553: + return "c_QList_T_int_T___constFirst"; + break; + case 554: + return "c_QList_T_int_T___constLast"; + break; + case 555: + return "c_QList_T_int_T___count"; + break; + case 558: + return "c_QList_T_int_T___detach"; + break; + case 559: + return "c_QList_T_int_T___empty"; + break; + case 560: + return "c_QList_T_int_T___first"; + break; + case 561: + return "c_QList_T_int_T___first"; + break; + case 562: + return "c_QList_T_int_T___first_qsizetype"; + break; + case 565: + return "c_QList_T_int_T___front"; + break; + case 566: + return "c_QList_T_int_T___front"; + break; + case 567: + return "c_QList_T_int_T___isDetached"; + break; + case 568: + return "c_QList_T_int_T___isEmpty"; + break; + case 569: + return "c_QList_T_int_T___isSharedWith_QList_T"; + break; + case 570: + return "c_QList_T_int_T___last"; + break; + case 571: + return "c_QList_T_int_T___last"; + break; + case 572: + return "c_QList_T_int_T___last_qsizetype"; + break; + case 573: + return "c_QList_T_int_T___length"; + break; + case 574: + return "c_QList_T_int_T___mid_qsizetype_qsizetype"; + break; + case 575: + return "c_QList_T_int_T___move_qsizetype_qsizetype"; + break; + case 584: + return "c_QList_T_int_T___pop_back"; + break; + case 585: + return "c_QList_T_int_T___pop_front"; + break; + case 586: + return "c_QList_T_int_T___remove_qsizetype_qsizetype"; + break; + case 587: + return "c_QList_T_int_T___removeAt_qsizetype"; + break; + case 588: + return "c_QList_T_int_T___removeFirst"; + break; + case 589: + return "c_QList_T_int_T___removeLast"; + break; + case 590: + return "c_QList_T_int_T___reserve_qsizetype"; + break; + case 591: + return "c_QList_T_int_T___resize_qsizetype"; + break; + case 593: + return "c_QList_T_int_T___shrink_to_fit"; + break; + case 594: + return "c_QList_T_int_T___size"; + break; + case 595: + return "c_QList_T_int_T___sliced_qsizetype"; + break; + case 596: + return "c_QList_T_int_T___sliced_qsizetype_qsizetype"; + break; + case 597: + return "c_QList_T_int_T___squeeze"; + break; + case 599: + return "c_QList_T_int_T___swapItemsAt_qsizetype_qsizetype"; + break; + case 600: + return "c_QList_T_int_T___takeAt_qsizetype"; + break; + case 601: + return "c_QList_T_int_T___toList"; + break; + case 602: + return "c_QList_T_int_T___toVector"; + break; + case 603: + return "c_QList_T_int_T___value_qsizetype"; + break; + } + } + if (this is QList) { + switch (id) { + case 543: + return "c_QList_T_QVariant_T___constructor"; + break; + case 544: + return "c_QList_T_QVariant_T___constructor_qsizetype"; + break; + case 546: + return "c_QList_T_QVariant_T___append_QList_T"; + break; + case 547: + return "c_QList_T_QVariant_T___at_qsizetype"; + break; + case 548: + return "c_QList_T_QVariant_T___back"; + break; + case 549: + return "c_QList_T_QVariant_T___back"; + break; + case 550: + return "c_QList_T_QVariant_T___capacity"; + break; + case 551: + return "c_QList_T_QVariant_T___clear"; + break; + case 553: + return "c_QList_T_QVariant_T___constFirst"; + break; + case 554: + return "c_QList_T_QVariant_T___constLast"; + break; + case 555: + return "c_QList_T_QVariant_T___count"; + break; + case 558: + return "c_QList_T_QVariant_T___detach"; + break; + case 559: + return "c_QList_T_QVariant_T___empty"; + break; + case 560: + return "c_QList_T_QVariant_T___first"; + break; + case 561: + return "c_QList_T_QVariant_T___first"; + break; + case 562: + return "c_QList_T_QVariant_T___first_qsizetype"; + break; + case 565: + return "c_QList_T_QVariant_T___front"; + break; + case 566: + return "c_QList_T_QVariant_T___front"; + break; + case 567: + return "c_QList_T_QVariant_T___isDetached"; + break; + case 568: + return "c_QList_T_QVariant_T___isEmpty"; + break; + case 569: + return "c_QList_T_QVariant_T___isSharedWith_QList_T"; + break; + case 570: + return "c_QList_T_QVariant_T___last"; + break; + case 571: + return "c_QList_T_QVariant_T___last"; + break; + case 572: + return "c_QList_T_QVariant_T___last_qsizetype"; + break; + case 573: + return "c_QList_T_QVariant_T___length"; + break; + case 574: + return "c_QList_T_QVariant_T___mid_qsizetype_qsizetype"; + break; + case 575: + return "c_QList_T_QVariant_T___move_qsizetype_qsizetype"; + break; + case 584: + return "c_QList_T_QVariant_T___pop_back"; + break; + case 585: + return "c_QList_T_QVariant_T___pop_front"; + break; + case 586: + return "c_QList_T_QVariant_T___remove_qsizetype_qsizetype"; + break; + case 587: + return "c_QList_T_QVariant_T___removeAt_qsizetype"; + break; + case 588: + return "c_QList_T_QVariant_T___removeFirst"; + break; + case 589: + return "c_QList_T_QVariant_T___removeLast"; + break; + case 590: + return "c_QList_T_QVariant_T___reserve_qsizetype"; + break; + case 591: + return "c_QList_T_QVariant_T___resize_qsizetype"; + break; + case 593: + return "c_QList_T_QVariant_T___shrink_to_fit"; + break; + case 594: + return "c_QList_T_QVariant_T___size"; + break; + case 595: + return "c_QList_T_QVariant_T___sliced_qsizetype"; + break; + case 596: + return "c_QList_T_QVariant_T___sliced_qsizetype_qsizetype"; + break; + case 597: + return "c_QList_T_QVariant_T___squeeze"; + break; + case 599: + return "c_QList_T_QVariant_T___swapItemsAt_qsizetype_qsizetype"; + break; + case 600: + return "c_QList_T_QVariant_T___takeAt_qsizetype"; + break; + case 601: + return "c_QList_T_QVariant_T___toList"; + break; + case 602: + return "c_QList_T_QVariant_T___toVector"; + break; + case 603: + return "c_QList_T_QVariant_T___value_qsizetype"; + break; + } + } + if (this is QList) { + switch (id) { + case 543: + return "c_QList_T_QString_T___constructor"; + break; + case 544: + return "c_QList_T_QString_T___constructor_qsizetype"; + break; + case 546: + return "c_QList_T_QString_T___append_QList_T"; + break; + case 547: + return "c_QList_T_QString_T___at_qsizetype"; + break; + case 548: + return "c_QList_T_QString_T___back"; + break; + case 549: + return "c_QList_T_QString_T___back"; + break; + case 550: + return "c_QList_T_QString_T___capacity"; + break; + case 551: + return "c_QList_T_QString_T___clear"; + break; + case 553: + return "c_QList_T_QString_T___constFirst"; + break; + case 554: + return "c_QList_T_QString_T___constLast"; + break; + case 555: + return "c_QList_T_QString_T___count"; + break; + case 558: + return "c_QList_T_QString_T___detach"; + break; + case 559: + return "c_QList_T_QString_T___empty"; + break; + case 560: + return "c_QList_T_QString_T___first"; + break; + case 561: + return "c_QList_T_QString_T___first"; + break; + case 562: + return "c_QList_T_QString_T___first_qsizetype"; + break; + case 565: + return "c_QList_T_QString_T___front"; + break; + case 566: + return "c_QList_T_QString_T___front"; + break; + case 567: + return "c_QList_T_QString_T___isDetached"; + break; + case 568: + return "c_QList_T_QString_T___isEmpty"; + break; + case 569: + return "c_QList_T_QString_T___isSharedWith_QList_T"; + break; + case 570: + return "c_QList_T_QString_T___last"; + break; + case 571: + return "c_QList_T_QString_T___last"; + break; + case 572: + return "c_QList_T_QString_T___last_qsizetype"; + break; + case 573: + return "c_QList_T_QString_T___length"; + break; + case 574: + return "c_QList_T_QString_T___mid_qsizetype_qsizetype"; + break; + case 575: + return "c_QList_T_QString_T___move_qsizetype_qsizetype"; + break; + case 584: + return "c_QList_T_QString_T___pop_back"; + break; + case 585: + return "c_QList_T_QString_T___pop_front"; + break; + case 586: + return "c_QList_T_QString_T___remove_qsizetype_qsizetype"; + break; + case 587: + return "c_QList_T_QString_T___removeAt_qsizetype"; + break; + case 588: + return "c_QList_T_QString_T___removeFirst"; + break; + case 589: + return "c_QList_T_QString_T___removeLast"; + break; + case 590: + return "c_QList_T_QString_T___reserve_qsizetype"; + break; + case 591: + return "c_QList_T_QString_T___resize_qsizetype"; + break; + case 593: + return "c_QList_T_QString_T___shrink_to_fit"; + break; + case 594: + return "c_QList_T_QString_T___size"; + break; + case 595: + return "c_QList_T_QString_T___sliced_qsizetype"; + break; + case 596: + return "c_QList_T_QString_T___sliced_qsizetype_qsizetype"; + break; + case 597: + return "c_QList_T_QString_T___squeeze"; + break; + case 599: + return "c_QList_T_QString_T___swapItemsAt_qsizetype_qsizetype"; + break; + case 600: + return "c_QList_T_QString_T___takeAt_qsizetype"; + break; + case 601: + return "c_QList_T_QString_T___toList"; + break; + case 602: + return "c_QList_T_QString_T___toVector"; + break; + case 603: + return "c_QList_T_QString_T___value_qsizetype"; + break; + } + } + if (this is QList) { + switch (id) { + case 543: + return "c_QList_T_unsigned_int_T___constructor"; + break; + case 544: + return "c_QList_T_unsigned_int_T___constructor_qsizetype"; + break; + case 546: + return "c_QList_T_unsigned_int_T___append_QList_T"; + break; + case 547: + return "c_QList_T_unsigned_int_T___at_qsizetype"; + break; + case 548: + return "c_QList_T_unsigned_int_T___back"; + break; + case 549: + return "c_QList_T_unsigned_int_T___back"; + break; + case 550: + return "c_QList_T_unsigned_int_T___capacity"; + break; + case 551: + return "c_QList_T_unsigned_int_T___clear"; + break; + case 553: + return "c_QList_T_unsigned_int_T___constFirst"; + break; + case 554: + return "c_QList_T_unsigned_int_T___constLast"; + break; + case 555: + return "c_QList_T_unsigned_int_T___count"; + break; + case 558: + return "c_QList_T_unsigned_int_T___detach"; + break; + case 559: + return "c_QList_T_unsigned_int_T___empty"; + break; + case 560: + return "c_QList_T_unsigned_int_T___first"; + break; + case 561: + return "c_QList_T_unsigned_int_T___first"; + break; + case 562: + return "c_QList_T_unsigned_int_T___first_qsizetype"; + break; + case 565: + return "c_QList_T_unsigned_int_T___front"; + break; + case 566: + return "c_QList_T_unsigned_int_T___front"; + break; + case 567: + return "c_QList_T_unsigned_int_T___isDetached"; + break; + case 568: + return "c_QList_T_unsigned_int_T___isEmpty"; + break; + case 569: + return "c_QList_T_unsigned_int_T___isSharedWith_QList_T"; + break; + case 570: + return "c_QList_T_unsigned_int_T___last"; + break; + case 571: + return "c_QList_T_unsigned_int_T___last"; + break; + case 572: + return "c_QList_T_unsigned_int_T___last_qsizetype"; + break; + case 573: + return "c_QList_T_unsigned_int_T___length"; + break; + case 574: + return "c_QList_T_unsigned_int_T___mid_qsizetype_qsizetype"; + break; + case 575: + return "c_QList_T_unsigned_int_T___move_qsizetype_qsizetype"; + break; + case 584: + return "c_QList_T_unsigned_int_T___pop_back"; + break; + case 585: + return "c_QList_T_unsigned_int_T___pop_front"; + break; + case 586: + return "c_QList_T_unsigned_int_T___remove_qsizetype_qsizetype"; + break; + case 587: + return "c_QList_T_unsigned_int_T___removeAt_qsizetype"; + break; + case 588: + return "c_QList_T_unsigned_int_T___removeFirst"; + break; + case 589: + return "c_QList_T_unsigned_int_T___removeLast"; + break; + case 590: + return "c_QList_T_unsigned_int_T___reserve_qsizetype"; + break; + case 591: + return "c_QList_T_unsigned_int_T___resize_qsizetype"; + break; + case 593: + return "c_QList_T_unsigned_int_T___shrink_to_fit"; + break; + case 594: + return "c_QList_T_unsigned_int_T___size"; + break; + case 595: + return "c_QList_T_unsigned_int_T___sliced_qsizetype"; + break; + case 596: + return "c_QList_T_unsigned_int_T___sliced_qsizetype_qsizetype"; + break; + case 597: + return "c_QList_T_unsigned_int_T___squeeze"; + break; + case 599: + return "c_QList_T_unsigned_int_T___swapItemsAt_qsizetype_qsizetype"; + break; + case 600: + return "c_QList_T_unsigned_int_T___takeAt_qsizetype"; + break; + case 601: + return "c_QList_T_unsigned_int_T___toList"; + break; + case 602: + return "c_QList_T_unsigned_int_T___toVector"; + break; + case 603: + return "c_QList_T_unsigned_int_T___value_qsizetype"; + break; + } + } + if (this is QList) { + switch (id) { + case 543: + return "c_QList_T_QObject_T___constructor"; + break; + case 544: + return "c_QList_T_QObject_T___constructor_qsizetype"; + break; + case 546: + return "c_QList_T_QObject_T___append_QList_T"; + break; + case 547: + return "c_QList_T_QObject_T___at_qsizetype"; + break; + case 548: + return "c_QList_T_QObject_T___back"; + break; + case 549: + return "c_QList_T_QObject_T___back"; + break; + case 550: + return "c_QList_T_QObject_T___capacity"; + break; + case 551: + return "c_QList_T_QObject_T___clear"; + break; + case 553: + return "c_QList_T_QObject_T___constFirst"; + break; + case 554: + return "c_QList_T_QObject_T___constLast"; + break; + case 555: + return "c_QList_T_QObject_T___count"; + break; + case 558: + return "c_QList_T_QObject_T___detach"; + break; + case 559: + return "c_QList_T_QObject_T___empty"; + break; + case 560: + return "c_QList_T_QObject_T___first"; + break; + case 561: + return "c_QList_T_QObject_T___first"; + break; + case 562: + return "c_QList_T_QObject_T___first_qsizetype"; + break; + case 565: + return "c_QList_T_QObject_T___front"; + break; + case 566: + return "c_QList_T_QObject_T___front"; + break; + case 567: + return "c_QList_T_QObject_T___isDetached"; + break; + case 568: + return "c_QList_T_QObject_T___isEmpty"; + break; + case 569: + return "c_QList_T_QObject_T___isSharedWith_QList_T"; + break; + case 570: + return "c_QList_T_QObject_T___last"; + break; + case 571: + return "c_QList_T_QObject_T___last"; + break; + case 572: + return "c_QList_T_QObject_T___last_qsizetype"; + break; + case 573: + return "c_QList_T_QObject_T___length"; + break; + case 574: + return "c_QList_T_QObject_T___mid_qsizetype_qsizetype"; + break; + case 575: + return "c_QList_T_QObject_T___move_qsizetype_qsizetype"; + break; + case 584: + return "c_QList_T_QObject_T___pop_back"; + break; + case 585: + return "c_QList_T_QObject_T___pop_front"; + break; + case 586: + return "c_QList_T_QObject_T___remove_qsizetype_qsizetype"; + break; + case 587: + return "c_QList_T_QObject_T___removeAt_qsizetype"; + break; + case 588: + return "c_QList_T_QObject_T___removeFirst"; + break; + case 589: + return "c_QList_T_QObject_T___removeLast"; + break; + case 590: + return "c_QList_T_QObject_T___reserve_qsizetype"; + break; + case 591: + return "c_QList_T_QObject_T___resize_qsizetype"; + break; + case 593: + return "c_QList_T_QObject_T___shrink_to_fit"; + break; + case 594: + return "c_QList_T_QObject_T___size"; + break; + case 595: + return "c_QList_T_QObject_T___sliced_qsizetype"; + break; + case 596: + return "c_QList_T_QObject_T___sliced_qsizetype_qsizetype"; + break; + case 597: + return "c_QList_T_QObject_T___squeeze"; + break; + case 599: + return "c_QList_T_QObject_T___swapItemsAt_qsizetype_qsizetype"; + break; + case 600: + return "c_QList_T_QObject_T___takeAt_qsizetype"; + break; + case 601: + return "c_QList_T_QObject_T___toList"; + break; + case 602: + return "c_QList_T_QObject_T___toVector"; + break; + case 603: + return "c_QList_T_QObject_T___value_qsizetype"; + break; + } + } + if (this is QList) { + switch (id) { + case 543: + return "c_QList_T_QByteArray_T___constructor"; + break; + case 544: + return "c_QList_T_QByteArray_T___constructor_qsizetype"; + break; + case 546: + return "c_QList_T_QByteArray_T___append_QList_T"; + break; + case 547: + return "c_QList_T_QByteArray_T___at_qsizetype"; + break; + case 548: + return "c_QList_T_QByteArray_T___back"; + break; + case 549: + return "c_QList_T_QByteArray_T___back"; + break; + case 550: + return "c_QList_T_QByteArray_T___capacity"; + break; + case 551: + return "c_QList_T_QByteArray_T___clear"; + break; + case 553: + return "c_QList_T_QByteArray_T___constFirst"; + break; + case 554: + return "c_QList_T_QByteArray_T___constLast"; + break; + case 555: + return "c_QList_T_QByteArray_T___count"; + break; + case 558: + return "c_QList_T_QByteArray_T___detach"; + break; + case 559: + return "c_QList_T_QByteArray_T___empty"; + break; + case 560: + return "c_QList_T_QByteArray_T___first"; + break; + case 561: + return "c_QList_T_QByteArray_T___first"; + break; + case 562: + return "c_QList_T_QByteArray_T___first_qsizetype"; + break; + case 565: + return "c_QList_T_QByteArray_T___front"; + break; + case 566: + return "c_QList_T_QByteArray_T___front"; + break; + case 567: + return "c_QList_T_QByteArray_T___isDetached"; + break; + case 568: + return "c_QList_T_QByteArray_T___isEmpty"; + break; + case 569: + return "c_QList_T_QByteArray_T___isSharedWith_QList_T"; + break; + case 570: + return "c_QList_T_QByteArray_T___last"; + break; + case 571: + return "c_QList_T_QByteArray_T___last"; + break; + case 572: + return "c_QList_T_QByteArray_T___last_qsizetype"; + break; + case 573: + return "c_QList_T_QByteArray_T___length"; + break; + case 574: + return "c_QList_T_QByteArray_T___mid_qsizetype_qsizetype"; + break; + case 575: + return "c_QList_T_QByteArray_T___move_qsizetype_qsizetype"; + break; + case 584: + return "c_QList_T_QByteArray_T___pop_back"; + break; + case 585: + return "c_QList_T_QByteArray_T___pop_front"; + break; + case 586: + return "c_QList_T_QByteArray_T___remove_qsizetype_qsizetype"; + break; + case 587: + return "c_QList_T_QByteArray_T___removeAt_qsizetype"; + break; + case 588: + return "c_QList_T_QByteArray_T___removeFirst"; + break; + case 589: + return "c_QList_T_QByteArray_T___removeLast"; + break; + case 590: + return "c_QList_T_QByteArray_T___reserve_qsizetype"; + break; + case 591: + return "c_QList_T_QByteArray_T___resize_qsizetype"; + break; + case 593: + return "c_QList_T_QByteArray_T___shrink_to_fit"; + break; + case 594: + return "c_QList_T_QByteArray_T___size"; + break; + case 595: + return "c_QList_T_QByteArray_T___sliced_qsizetype"; + break; + case 596: + return "c_QList_T_QByteArray_T___sliced_qsizetype_qsizetype"; + break; + case 597: + return "c_QList_T_QByteArray_T___squeeze"; + break; + case 599: + return "c_QList_T_QByteArray_T___swapItemsAt_qsizetype_qsizetype"; + break; + case 600: + return "c_QList_T_QByteArray_T___takeAt_qsizetype"; + break; + case 601: + return "c_QList_T_QByteArray_T___toList"; + break; + case 602: + return "c_QList_T_QByteArray_T___toVector"; + break; + case 603: + return "c_QList_T_QByteArray_T___value_qsizetype"; + break; + } + } + return ""; + } + + String getFinalizerName() { + if (this is QList) { + return "c_QList_T_SimpleStruct_T__Finalizer"; + } + if (this is QList) { + return "c_QList_T_qreal_T__Finalizer"; + } + if (this is QList) { + return "c_QList_T_int_T__Finalizer"; + } + if (this is QList) { + return "c_QList_T_QVariant_T__Finalizer"; + } + if (this is QList) { + return "c_QList_T_QString_T__Finalizer"; + } + if (this is QList) { + return "c_QList_T_unsigned_int_T__Finalizer"; + } + if (this is QList) { + return "c_QList_T_QObject_T__Finalizer"; + } + if (this is QList) { + return "c_QList_T_QByteArray_T__Finalizer"; + } + print( + "ERROR: Couldn't find finalizerName for" + this.runtimeType.toString()); + return ""; + } //QList() + + QList() { + final voidstar_Func_void func = _dylib + .lookup>( + '${getCFunctionName(543)}') + .asFunction(); + thisCpp = func(); + QList.s_dartInstanceByCppPtr[thisCpp.address] = this; + } //QList(qsizetype size) + QList.ctor2(int size) { + final voidstar_Func_int func = _dylib + .lookup>( + '${getCFunctionName(544)}') + .asFunction(); + thisCpp = func(size); + QList.s_dartInstanceByCppPtr[thisCpp.address] = this; + } // append(const QList & l) + append(QList l) { + final void_Func_voidstar_voidstar func = _dylib + .lookup>( + '${getCFunctionName(546)}') + .asFunction(); + func(thisCpp, l == null ? ffi.nullptr : l.thisCpp); + } // at(qsizetype i) const + + T at(int i) { + if (this is QList) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(547)}') + .asFunction(); + ffi.Pointer result = func(thisCpp, i); + return (QByteArray.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(547)}') + .asFunction(); + ffi.Pointer result = func(thisCpp, i); + return (QString.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(547)}') + .asFunction(); + ffi.Pointer result = func(thisCpp, i); + return (QVariant.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(547)}') + .asFunction(); + ffi.Pointer result = func(thisCpp, i); + return (SimpleStruct.fromCppPointer(result, false) as T); + } + if (this is QList) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(547)}') + .asFunction(); + ffi.Pointer result = func(thisCpp, i); + return (QObject.fromCppPointer(result, false) as T); + } + if (this is QList) { + final int_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(547)}') + .asFunction(); + return (func(thisCpp, i) as T); + } + if (this is QList) { + final double_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(547)}') + .asFunction(); + return (func(thisCpp, i) as T); + } + if (this is QList) { + final int_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(547)}') + .asFunction(); + return (func(thisCpp, i) as T); + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } // back() + + T back() { + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(548)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QByteArray.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(548)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QString.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(548)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QVariant.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(548)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (SimpleStruct.fromCppPointer(result, false) as T); + } + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(548)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QObject.fromCppPointer(result, false) as T); + } + if (this is QList) { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(548)}') + .asFunction(); + return (func(thisCpp) as T); + } + if (this is QList) { + final double_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(548)}') + .asFunction(); + return (func(thisCpp) as T); + } + if (this is QList) { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(548)}') + .asFunction(); + return (func(thisCpp) as T); + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } // capacity() const + + int capacity() { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(550)}') + .asFunction(); + return func(thisCpp); + } // clear() + + clear() { + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(551)}') + .asFunction(); + func(thisCpp); + } // constFirst() const + + T constFirst() { + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(553)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QByteArray.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(553)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QString.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(553)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QVariant.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(553)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (SimpleStruct.fromCppPointer(result, false) as T); + } + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(553)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QObject.fromCppPointer(result, false) as T); + } + if (this is QList) { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(553)}') + .asFunction(); + return (func(thisCpp) as T); + } + if (this is QList) { + final double_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(553)}') + .asFunction(); + return (func(thisCpp) as T); + } + if (this is QList) { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(553)}') + .asFunction(); + return (func(thisCpp) as T); + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } // constLast() const + + T constLast() { + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(554)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QByteArray.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(554)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QString.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(554)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QVariant.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(554)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (SimpleStruct.fromCppPointer(result, false) as T); + } + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(554)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QObject.fromCppPointer(result, false) as T); + } + if (this is QList) { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(554)}') + .asFunction(); + return (func(thisCpp) as T); + } + if (this is QList) { + final double_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(554)}') + .asFunction(); + return (func(thisCpp) as T); + } + if (this is QList) { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(554)}') + .asFunction(); + return (func(thisCpp) as T); + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } // count() const + + int count() { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(555)}') + .asFunction(); + return func(thisCpp); + } // detach() + + detach() { + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(558)}') + .asFunction(); + func(thisCpp); + } // empty() const + + bool empty() { + final bool_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(559)}') + .asFunction(); + return func(thisCpp) != 0; + } // first() + + T first() { + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(560)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QByteArray.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(560)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QString.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(560)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QVariant.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(560)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (SimpleStruct.fromCppPointer(result, false) as T); + } + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(560)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QObject.fromCppPointer(result, false) as T); + } + if (this is QList) { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(560)}') + .asFunction(); + return (func(thisCpp) as T); + } + if (this is QList) { + final double_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(560)}') + .asFunction(); + return (func(thisCpp) as T); + } + if (this is QList) { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(560)}') + .asFunction(); + return (func(thisCpp) as T); + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } // front() + + T front() { + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(565)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QByteArray.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(565)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QString.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(565)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QVariant.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(565)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (SimpleStruct.fromCppPointer(result, false) as T); + } + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(565)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QObject.fromCppPointer(result, false) as T); + } + if (this is QList) { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(565)}') + .asFunction(); + return (func(thisCpp) as T); + } + if (this is QList) { + final double_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(565)}') + .asFunction(); + return (func(thisCpp) as T); + } + if (this is QList) { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(565)}') + .asFunction(); + return (func(thisCpp) as T); + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } // isDetached() const + + bool isDetached() { + final bool_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(567)}') + .asFunction(); + return func(thisCpp) != 0; + } // isEmpty() const + + bool isEmpty() { + final bool_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(568)}') + .asFunction(); + return func(thisCpp) != 0; + } // isSharedWith(const QList & other) const + + bool isSharedWith(QList other) { + final bool_Func_voidstar_voidstar func = _dylib + .lookup>( + '${getCFunctionName(569)}') + .asFunction(); + return func(thisCpp, other == null ? ffi.nullptr : other.thisCpp) != 0; + } // last() + + T last() { + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(570)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QByteArray.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(570)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QString.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(570)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QVariant.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(570)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (SimpleStruct.fromCppPointer(result, false) as T); + } + if (this is QList) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(570)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QObject.fromCppPointer(result, false) as T); + } + if (this is QList) { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(570)}') + .asFunction(); + return (func(thisCpp) as T); + } + if (this is QList) { + final double_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(570)}') + .asFunction(); + return (func(thisCpp) as T); + } + if (this is QList) { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(570)}') + .asFunction(); + return (func(thisCpp) as T); + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } // length() const + + int length() { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(573)}') + .asFunction(); + return func(thisCpp); + } // move(qsizetype from, qsizetype to) + + move(int from, int to) { + final void_Func_voidstar_int_int func = _dylib + .lookup>( + '${getCFunctionName(575)}') + .asFunction(); + func(thisCpp, from, to); + } // pop_back() + + pop_back() { + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(584)}') + .asFunction(); + func(thisCpp); + } // pop_front() + + pop_front() { + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(585)}') + .asFunction(); + func(thisCpp); + } // remove(qsizetype i, qsizetype n) + + remove(int i, {int n = 1}) { + final void_Func_voidstar_int_int func = _dylib + .lookup>( + '${getCFunctionName(586)}') + .asFunction(); + func(thisCpp, i, n); + } // removeAt(qsizetype i) + + removeAt(int i) { + final void_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(587)}') + .asFunction(); + func(thisCpp, i); + } // removeFirst() + + removeFirst() { + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(588)}') + .asFunction(); + func(thisCpp); + } // removeLast() + + removeLast() { + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(589)}') + .asFunction(); + func(thisCpp); + } // reserve(qsizetype size) + + reserve(int size) { + final void_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(590)}') + .asFunction(); + func(thisCpp, size); + } // resize(qsizetype size) + + resize(int size) { + final void_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(591)}') + .asFunction(); + func(thisCpp, size); + } // resize_internal(qsizetype i) + + resize_internal(int i) { + final void_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(592)}') + .asFunction(); + func(thisCpp, i); + } // shrink_to_fit() + + shrink_to_fit() { + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(593)}') + .asFunction(); + func(thisCpp); + } // size() const + + int size() { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(594)}') + .asFunction(); + return func(thisCpp); + } // squeeze() + + squeeze() { + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(597)}') + .asFunction(); + func(thisCpp); + } // swapItemsAt(qsizetype i, qsizetype j) + + swapItemsAt(int i, int j) { + final void_Func_voidstar_int_int func = _dylib + .lookup>( + '${getCFunctionName(599)}') + .asFunction(); + func(thisCpp, i, j); + } // takeAt(qsizetype i) + + T takeAt(int i) { + if (this is QList) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(600)}') + .asFunction(); + ffi.Pointer result = func(thisCpp, i); + return (QByteArray.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(600)}') + .asFunction(); + ffi.Pointer result = func(thisCpp, i); + return (QString.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(600)}') + .asFunction(); + ffi.Pointer result = func(thisCpp, i); + return (QVariant.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(600)}') + .asFunction(); + ffi.Pointer result = func(thisCpp, i); + return (SimpleStruct.fromCppPointer(result, false) as T); + } + if (this is QList) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(600)}') + .asFunction(); + ffi.Pointer result = func(thisCpp, i); + return (QObject.fromCppPointer(result, false) as T); + } + if (this is QList) { + final int_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(600)}') + .asFunction(); + return (func(thisCpp, i) as T); + } + if (this is QList) { + final double_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(600)}') + .asFunction(); + return (func(thisCpp, i) as T); + } + if (this is QList) { + final int_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(600)}') + .asFunction(); + return (func(thisCpp, i) as T); + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } // value(qsizetype i) const + + T value(int i) { + if (this is QList) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(603)}') + .asFunction(); + ffi.Pointer result = func(thisCpp, i); + return (QByteArray.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(603)}') + .asFunction(); + ffi.Pointer result = func(thisCpp, i); + return (QString.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(603)}') + .asFunction(); + ffi.Pointer result = func(thisCpp, i); + return (QVariant.fromCppPointer(result, true) as T); + } + if (this is QList) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(603)}') + .asFunction(); + ffi.Pointer result = func(thisCpp, i); + return (SimpleStruct.fromCppPointer(result, false) as T); + } + if (this is QList) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(603)}') + .asFunction(); + ffi.Pointer result = func(thisCpp, i); + return (QObject.fromCppPointer(result, false) as T); + } + if (this is QList) { + final int_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(603)}') + .asFunction(); + return (func(thisCpp, i) as T); + } + if (this is QList) { + final double_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(603)}') + .asFunction(); + return (func(thisCpp, i) as T); + } + if (this is QList) { + final int_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(603)}') + .asFunction(); + return (func(thisCpp, i) as T); + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(-2)}') + .asFunction(); + func(thisCpp); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/QMap.dart b/tests/generated/TestBindings/dart/lib/src/QMap.dart new file mode 100644 index 0000000..53391dd --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/QMap.dart @@ -0,0 +1,323 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class QMap implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = true; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory QMap.fromCache(var cppPointer, [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + QMap.fromCppPointer(cppPointer, needsAutoDelete)) as QMap; + } + QMap.fromCppPointer(var cppPointer, [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + QMap.init() {} + String getCFunctionName(int id) { + if (this is QMap) { + switch (id) { + case 510: + return "c_QMap_T_QString_QVariant_T___constructor"; + break; + case 513: + return "c_QMap_T_QString_QVariant_T___clear"; + break; + case 514: + return "c_QMap_T_QString_QVariant_T___contains_QString"; + break; + case 517: + return "c_QMap_T_QString_QVariant_T___detach"; + break; + case 518: + return "c_QMap_T_QString_QVariant_T___empty"; + break; + case 519: + return "c_QMap_T_QString_QVariant_T___first"; + break; + case 520: + return "c_QMap_T_QString_QVariant_T___first"; + break; + case 521: + return "c_QMap_T_QString_QVariant_T___firstKey"; + break; + case 523: + return "c_QMap_T_QString_QVariant_T___insert_QMap_Key_T"; + break; + case 524: + return "c_QMap_T_QString_QVariant_T___isDetached"; + break; + case 525: + return "c_QMap_T_QString_QVariant_T___isEmpty"; + break; + case 526: + return "c_QMap_T_QString_QVariant_T___isSharedWith_QMap_Key_T"; + break; + case 527: + return "c_QMap_T_QString_QVariant_T___key_QVariant_QString"; + break; + case 528: + return "c_QMap_T_QString_QVariant_T___keys"; + break; + case 529: + return "c_QMap_T_QString_QVariant_T___keys_QVariant"; + break; + case 530: + return "c_QMap_T_QString_QVariant_T___last"; + break; + case 531: + return "c_QMap_T_QString_QVariant_T___last"; + break; + case 532: + return "c_QMap_T_QString_QVariant_T___lastKey"; + break; + case 538: + return "c_QMap_T_QString_QVariant_T___take_QString"; + break; + case 541: + return "c_QMap_T_QString_QVariant_T___value_QString_QVariant"; + break; + case 542: + return "c_QMap_T_QString_QVariant_T___values"; + break; + } + } + return ""; + } + + String getFinalizerName() { + if (this is QMap) { + return "c_QMap_T_QString_QVariant_T__Finalizer"; + } + print( + "ERROR: Couldn't find finalizerName for" + this.runtimeType.toString()); + return ""; + } //QMap() + + QMap() { + final voidstar_Func_void func = _dylib + .lookup>( + '${getCFunctionName(510)}') + .asFunction(); + thisCpp = func(); + QMap.s_dartInstanceByCppPtr[thisCpp.address] = this; + } // clear() + clear() { + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(513)}') + .asFunction(); + func(thisCpp); + } // contains(const Key & key) const + + bool contains(Key key) { + if (this is QMap) { + final bool_Func_voidstar_voidstar func = _dylib + .lookup>( + '${getCFunctionName(514)}') + .asFunction(); + return func(thisCpp, (key as String).toNativeUtf8()) != 0; + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } // detach() + + detach() { + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(517)}') + .asFunction(); + func(thisCpp); + } // empty() const + + bool empty() { + final bool_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(518)}') + .asFunction(); + return func(thisCpp) != 0; + } // first() + + T first() { + if (this is QMap) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(519)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QVariant.fromCppPointer(result, true) as T); + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } // firstKey() const + + Key firstKey() { + if (this is QMap) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(521)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QString.fromCppPointer(result, true) as Key); + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } // insert(const QMap & map) + + insert(QMap map) { + final void_Func_voidstar_voidstar func = _dylib + .lookup>( + '${getCFunctionName(523)}') + .asFunction(); + func(thisCpp, map == null ? ffi.nullptr : map.thisCpp); + } // isDetached() const + + bool isDetached() { + final bool_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(524)}') + .asFunction(); + return func(thisCpp) != 0; + } // isEmpty() const + + bool isEmpty() { + final bool_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(525)}') + .asFunction(); + return func(thisCpp) != 0; + } // isSharedWith(const QMap & other) const + + bool isSharedWith(QMap other) { + final bool_Func_voidstar_voidstar func = _dylib + .lookup>( + '${getCFunctionName(526)}') + .asFunction(); + return func(thisCpp, other == null ? ffi.nullptr : other.thisCpp) != 0; + } // key(const T & value, const Key & defaultKey) const + + Key key(T value, {required Key defaultKey}) { + if (this is QMap) { + final voidstar_Func_voidstar_voidstar_voidstar func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_voidstar_voidstar_voidstar_FFI>>( + '${getCFunctionName(527)}') + .asFunction(); + ffi.Pointer result = func( + thisCpp, + (value as QVariant) == null + ? ffi.nullptr + : (value as QVariant).thisCpp, + (defaultKey as String).toNativeUtf8()); + return (QString.fromCppPointer(result, true) as Key); + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } // last() + + T last() { + if (this is QMap) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(530)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QVariant.fromCppPointer(result, true) as T); + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } // lastKey() const + + Key lastKey() { + if (this is QMap) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(532)}') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return (QString.fromCppPointer(result, true) as Key); + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } // take(const Key & key) + + T take(Key key) { + if (this is QMap) { + final voidstar_Func_voidstar_voidstar func = _dylib + .lookup>( + '${getCFunctionName(538)}') + .asFunction(); + ffi.Pointer result = func(thisCpp, (key as String).toNativeUtf8()); + return (QVariant.fromCppPointer(result, true) as T); + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } // value(const Key & key, const T & defaultValue) const + + T value(Key key, {required T defaultValue}) { + if (this is QMap) { + final voidstar_Func_voidstar_voidstar_voidstar func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_voidstar_voidstar_voidstar_FFI>>( + '${getCFunctionName(541)}') + .asFunction(); + ffi.Pointer result = func( + thisCpp, + (key as String).toNativeUtf8(), + (defaultValue as QVariant) == null + ? ffi.nullptr + : (defaultValue as QVariant).thisCpp); + return (QVariant.fromCppPointer(result, true) as T); + } + print( + "Unreachable, but required, due to null safety we need to return something"); + throw Error(); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(-2)}') + .asFunction(); + func(thisCpp); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/QObject.dart b/tests/generated/TestBindings/dart/lib/src/QObject.dart new file mode 100644 index 0000000..9a5fce8 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/QObject.dart @@ -0,0 +1,466 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class QObject implements ffi.Finalizable { + Map> signalHandlerersBySignal = {}; + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = false; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory QObject.fromCache(var cppPointer, [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + QObject.fromCppPointer(cppPointer, needsAutoDelete)) as QObject; + } + QObject.fromCppPointer(var cppPointer, [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + QObject.init() {} + String getFinalizerName() { + return "c_QObject_Finalizer"; + } //QObject(QObject * parent) + + QObject({QObject? parent}) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QObject__constructor_QObject') + .asFunction(); + thisCpp = func(parent == null ? ffi.nullptr : parent.thisCpp); + QObject.s_dartInstanceByCppPtr[thisCpp.address] = this; + registerCallbacks(); + } // blockSignals(bool b) + bool blockSignals(bool b) { + final bool_Func_voidstar_bool func = _dylib + .lookup>( + 'c_QObject__blockSignals_bool') + .asFunction(); + return func(thisCpp, b ? 1 : 0) != 0; + } // children() const + + QList children() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QObject__children') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QList.fromCppPointer(result, false); + } // customEvent(QEvent * event) + + customEvent(QEvent? event) { + final void_Func_voidstar_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(481)) + .asFunction(); + func(thisCpp, event == null ? ffi.nullptr : event.thisCpp); + } + + static void customEvent_calledFromC( + ffi.Pointer thisCpp, ffi.Pointer? event) { + var dartInstance = QObject.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for QObject::customEvent(QEvent * event)! (${thisCpp.address})"); + throw Error(); + } + dartInstance.customEvent((event == null || event.address == 0) + ? null + : QEvent.fromCppPointer(event)); + } // deleteLater() + + deleteLater() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QObject__deleteLater') + .asFunction(); + func(thisCpp); + } // destroyed(QObject * arg__1) + + destroyed({QObject? arg__1}) { + final void_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QObject__destroyed_QObject') + .asFunction(); + func(thisCpp, arg__1 == null ? ffi.nullptr : arg__1.thisCpp); + } + + void onDestroyed(Function callback, {QObject? context}) { + final SignalHandler func = _dylib + .lookup>( + 'c_QObject__onDestroyed_QObject') + .asFunction(); + final dartCallback = + ffi.Pointer.fromFunction)>( + onDestroyed_callback); + final callbackMethod = onDestroyed_callback; + var handlers = signalHandlerersBySignal[callbackMethod] ?? []; + handlers.add(callback); + signalHandlerersBySignal[callbackMethod] = handlers; + ffi.Pointer contextPtr = + context == null ? ffi.nullptr : context.thisCpp; + func(thisCpp, contextPtr, dartCallback); + } + + static void onDestroyed_callback(ffi.Pointer thisCpp) { + var dartInstance = + QObject.s_dartInstanceByCppPtr[thisCpp.address] as QObject; + final signalHandlers = + dartInstance.signalHandlerersBySignal[onDestroyed_callback] ?? []; + for (var signalHandler in signalHandlers) { + signalHandler(); + } + } // disconnect(const QObject * receiver, const char * member) const + + bool disconnect(QObject? receiver, {String? member}) { + final bool_Func_voidstar_voidstar_string func = _dylib + .lookup>( + 'c_QObject__disconnect_QObject_char') + .asFunction(); + return func(thisCpp, receiver == null ? ffi.nullptr : receiver.thisCpp, + member?.toNativeUtf8() ?? ffi.nullptr) != + 0; + } + + static // disconnect(const QObject * sender, const char * signal, const QObject * receiver, const char * member) + bool disconnect_2( + QObject? sender, String? signal, QObject? receiver, String? member) { + final bool_Func_voidstar_string_voidstar_string func = _dylib + .lookup< + ffi + .NativeFunction>( + 'c_static_QObject__disconnect_QObject_char_QObject_char') + .asFunction(); + return func( + sender == null ? ffi.nullptr : sender.thisCpp, + signal?.toNativeUtf8() ?? ffi.nullptr, + receiver == null ? ffi.nullptr : receiver.thisCpp, + member?.toNativeUtf8() ?? ffi.nullptr) != + 0; + } // disconnect(const char * signal, const QObject * receiver, const char * member) const + + bool disconnect_3({String? signal, QObject? receiver, String? member}) { + final bool_Func_voidstar_string_voidstar_string func = _dylib + .lookup< + ffi + .NativeFunction>( + 'c_QObject__disconnect_char_QObject_char') + .asFunction(); + return func( + thisCpp, + signal?.toNativeUtf8() ?? ffi.nullptr, + receiver == null ? ffi.nullptr : receiver.thisCpp, + member?.toNativeUtf8() ?? ffi.nullptr) != + 0; + } // dumpObjectInfo() const + + dumpObjectInfo() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QObject__dumpObjectInfo') + .asFunction(); + func(thisCpp); + } // dumpObjectTree() const + + dumpObjectTree() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QObject__dumpObjectTree') + .asFunction(); + func(thisCpp); + } // dynamicPropertyNames() const + + QList dynamicPropertyNames() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QObject__dynamicPropertyNames') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QList.fromCppPointer(result, true); + } // event(QEvent * event) + + bool event(QEvent? event) { + final bool_Func_voidstar_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(490)) + .asFunction(); + return func(thisCpp, event == null ? ffi.nullptr : event.thisCpp) != 0; + } + + static int event_calledFromC( + ffi.Pointer thisCpp, ffi.Pointer? event) { + var dartInstance = QObject.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for QObject::event(QEvent * event)! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.event((event == null || event.address == 0) + ? null + : QEvent.fromCppPointer(event)); + return result ? 1 : 0; + } // eventFilter(QObject * watched, QEvent * event) + + bool eventFilter(QObject? watched, QEvent? event) { + final bool_Func_voidstar_voidstar_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(491)) + .asFunction(); + return func(thisCpp, watched == null ? ffi.nullptr : watched.thisCpp, + event == null ? ffi.nullptr : event.thisCpp) != + 0; + } + + static int eventFilter_calledFromC(ffi.Pointer thisCpp, + ffi.Pointer? watched, ffi.Pointer? event) { + var dartInstance = QObject.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for QObject::eventFilter(QObject * watched, QEvent * event)! (${thisCpp.address})"); + throw Error(); + } + final result = dartInstance.eventFilter( + (watched == null || watched.address == 0) + ? null + : QObject.fromCppPointer(watched), + (event == null || event.address == 0) + ? null + : QEvent.fromCppPointer(event)); + return result ? 1 : 0; + } // inherits(const char * classname) const + + bool inherits(String? classname) { + final bool_Func_voidstar_string func = _dylib + .lookup>( + 'c_QObject__inherits_char') + .asFunction(); + return func(thisCpp, classname?.toNativeUtf8() ?? ffi.nullptr) != 0; + } // installEventFilter(QObject * filterObj) + + installEventFilter(QObject? filterObj) { + final void_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QObject__installEventFilter_QObject') + .asFunction(); + func(thisCpp, filterObj == null ? ffi.nullptr : filterObj.thisCpp); + } // isWidgetType() const + + bool isWidgetType() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QObject__isWidgetType') + .asFunction(); + return func(thisCpp) != 0; + } // isWindowType() const + + bool isWindowType() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QObject__isWindowType') + .asFunction(); + return func(thisCpp) != 0; + } // killTimer(int id) + + killTimer(int id) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_QObject__killTimer_int') + .asFunction(); + func(thisCpp, id); + } // objectName() const + + QString objectName() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QObject__objectName') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QString.fromCppPointer(result, true); + } // parent() const + + QObject parent() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QObject__parent') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QObject.fromCppPointer(result, false); + } // property(const char * name) const + + QVariant property(String? name) { + final voidstar_Func_voidstar_string func = _dylib + .lookup>( + 'c_QObject__property_char') + .asFunction(); + ffi.Pointer result = + func(thisCpp, name?.toNativeUtf8() ?? ffi.nullptr); + return QVariant.fromCppPointer(result, true); + } // receivers(const char * signal) const + + int receivers(String? signal) { + final int_Func_voidstar_string func = _dylib + .lookup>( + 'c_QObject__receivers_char') + .asFunction(); + return func(thisCpp, signal?.toNativeUtf8() ?? ffi.nullptr); + } // removeEventFilter(QObject * obj) + + removeEventFilter(QObject? obj) { + final void_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QObject__removeEventFilter_QObject') + .asFunction(); + func(thisCpp, obj == null ? ffi.nullptr : obj.thisCpp); + } // sender() const + + QObject sender() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QObject__sender') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QObject.fromCppPointer(result, false); + } // senderSignalIndex() const + + int senderSignalIndex() { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_QObject__senderSignalIndex') + .asFunction(); + return func(thisCpp); + } // setObjectName(const QString & name) + + setObjectName(String name) { + final void_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QObject__setObjectName_QString') + .asFunction(); + func(thisCpp, name.toNativeUtf8()); + } // setParent(QObject * parent) + + setParent(QObject? parent) { + final void_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QObject__setParent_QObject') + .asFunction(); + func(thisCpp, parent == null ? ffi.nullptr : parent.thisCpp); + } // setProperty(const char * name, const QVariant & value) + + bool setProperty(String? name, QVariant value) { + final bool_Func_voidstar_string_voidstar func = _dylib + .lookup>( + 'c_QObject__setProperty_char_QVariant') + .asFunction(); + return func(thisCpp, name?.toNativeUtf8() ?? ffi.nullptr, + value == null ? ffi.nullptr : value.thisCpp) != + 0; + } // signalsBlocked() const + + bool signalsBlocked() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QObject__signalsBlocked') + .asFunction(); + return func(thisCpp) != 0; + } // startTimer(int interval) + + int startTimer(int interval) { + final int_Func_voidstar_int func = _dylib + .lookup>( + 'c_QObject__startTimer_int') + .asFunction(); + return func(thisCpp, interval); + } + + static // tr(const char * s, const char * c, int n) + QString tr(String? s, String? c, int n) { + final voidstar_Func_string_string_int func = _dylib + .lookup>( + 'c_static_QObject__tr_char_char_int') + .asFunction(); + ffi.Pointer result = func( + s?.toNativeUtf8() ?? ffi.nullptr, c?.toNativeUtf8() ?? ffi.nullptr, n); + return QString.fromCppPointer(result, true); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QObject__destructor') + .asFunction(); + func(thisCpp); + } + + String cFunctionSymbolName(int methodId) { + switch (methodId) { + case 481: + return "c_QObject__customEvent_QEvent"; + case 490: + return "c_QObject__event_QEvent"; + case 491: + return "c_QObject__eventFilter_QObject_QEvent"; + } + return ""; + } + + static String methodNameFromId(int methodId) { + switch (methodId) { + case 481: + return "customEvent"; + case 490: + return "event"; + case 491: + return "eventFilter"; + } + throw Error(); + } + + void registerCallbacks() { + assert(thisCpp != null); + final RegisterMethodIsReimplementedCallback registerCallback = _dylib + .lookup>( + 'c_QObject__registerVirtualMethodCallback') + .asFunction(); + final callback481 = + ffi.Pointer.fromFunction( + QObject.customEvent_calledFromC); + registerCallback(thisCpp, callback481, 481); + const callbackExcept490 = 0; + final callback490 = + ffi.Pointer.fromFunction( + QObject.event_calledFromC, callbackExcept490); + registerCallback(thisCpp, callback490, 490); + const callbackExcept491 = 0; + final callback491 = + ffi.Pointer.fromFunction( + QObject.eventFilter_calledFromC, callbackExcept491); + registerCallback(thisCpp, callback491, 491); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/QSet.dart b/tests/generated/TestBindings/dart/lib/src/QSet.dart new file mode 100644 index 0000000..97ae01e --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/QSet.dart @@ -0,0 +1,160 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class QSet implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = true; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory QSet.fromCache(var cppPointer, [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + QSet.fromCppPointer(cppPointer, needsAutoDelete)) as QSet; + } + QSet.fromCppPointer(var cppPointer, [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + QSet.init() {} + String getCFunctionName(int id) { + return ""; + } + + String getFinalizerName() { + print( + "ERROR: Couldn't find finalizerName for" + this.runtimeType.toString()); + return ""; + } //QSet() + + QSet() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_QSet__constructor') + .asFunction(); + thisCpp = func(); + QSet.s_dartInstanceByCppPtr[thisCpp.address] = this; + } // capacity() const + int capacity() { + final int_Func_voidstar func = _dylib + .lookup>('c_QSet__capacity') + .asFunction(); + return func(thisCpp); + } // clear() + + clear() { + final void_Func_voidstar func = _dylib + .lookup>('c_QSet__clear') + .asFunction(); + func(thisCpp); + } // contains(const QSet & set) const + + bool contains(QSet set) { + final bool_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QSet__contains_QSet_T') + .asFunction(); + return func(thisCpp, set == null ? ffi.nullptr : set.thisCpp) != 0; + } // count() const + + int count() { + final int_Func_voidstar func = _dylib + .lookup>('c_QSet__count') + .asFunction(); + return func(thisCpp); + } // detach() + + detach() { + final void_Func_voidstar func = _dylib + .lookup>('c_QSet__detach') + .asFunction(); + func(thisCpp); + } // empty() const + + bool empty() { + final bool_Func_voidstar func = _dylib + .lookup>('c_QSet__empty') + .asFunction(); + return func(thisCpp) != 0; + } // intersects(const QSet & other) const + + bool intersects(QSet other) { + final bool_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QSet__intersects_QSet_T') + .asFunction(); + return func(thisCpp, other == null ? ffi.nullptr : other.thisCpp) != 0; + } // isDetached() const + + bool isDetached() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QSet__isDetached') + .asFunction(); + return func(thisCpp) != 0; + } // isEmpty() const + + bool isEmpty() { + final bool_Func_voidstar func = _dylib + .lookup>('c_QSet__isEmpty') + .asFunction(); + return func(thisCpp) != 0; + } // reserve(qsizetype size) + + reserve(int size) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_QSet__reserve_qsizetype') + .asFunction(); + func(thisCpp, size); + } // size() const + + int size() { + final int_Func_voidstar func = _dylib + .lookup>('c_QSet__size') + .asFunction(); + return func(thisCpp); + } // squeeze() + + squeeze() { + final void_Func_voidstar func = _dylib + .lookup>('c_QSet__squeeze') + .asFunction(); + func(thisCpp); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QSet__destructor') + .asFunction(); + func(thisCpp); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/QString.dart b/tests/generated/TestBindings/dart/lib/src/QString.dart new file mode 100644 index 0000000..437d309 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/QString.dart @@ -0,0 +1,922 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class QString implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = true; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory QString.fromCache(var cppPointer, [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + QString.fromCppPointer(cppPointer, needsAutoDelete)) as QString; + } + QString.fromCppPointer(var cppPointer, [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + QString.init() {} + String getFinalizerName() { + return "c_QString_Finalizer"; + } //QString() + + QString() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_QString__constructor') + .asFunction(); + thisCpp = func(); + QString.s_dartInstanceByCppPtr[thisCpp.address] = this; + } //QString(const QByteArray & a) + QString.ctor2(QByteArray a) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QString__constructor_QByteArray') + .asFunction(); + thisCpp = func(a == null ? ffi.nullptr : a.thisCpp); + QString.s_dartInstanceByCppPtr[thisCpp.address] = this; + } //QString(const char * ch) + QString.ctor3(String? ch) { + final voidstar_Func_string func = _dylib + .lookup>( + 'c_QString__constructor_char') + .asFunction(); + thisCpp = func(ch?.toNativeUtf8() ?? ffi.nullptr); + QString.s_dartInstanceByCppPtr[thisCpp.address] = this; + } // append(const QByteArray & s) + QString append(QByteArray s) { + final voidstar_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QString__append_QByteArray') + .asFunction(); + ffi.Pointer result = + func(thisCpp, s == null ? ffi.nullptr : s.thisCpp); + return QString.fromCppPointer(result, false); + } // append(const QString & s) + + QString append_2(String s) { + final voidstar_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QString__append_QString') + .asFunction(); + ffi.Pointer result = func(thisCpp, s.toNativeUtf8()); + return QString.fromCppPointer(result, false); + } // append(const char * s) + + QString append_3(String? s) { + final voidstar_Func_voidstar_string func = _dylib + .lookup>( + 'c_QString__append_char') + .asFunction(); + ffi.Pointer result = func(thisCpp, s?.toNativeUtf8() ?? ffi.nullptr); + return QString.fromCppPointer(result, false); + } // arg(const QString & a, int fieldWidth) const + + QString arg(String a, {int fieldWidth = 0}) { + final voidstar_Func_voidstar_voidstar_int func = _dylib + .lookup< + ffi + .NativeFunction>( + 'c_QString__arg_QString_int') + .asFunction(); + ffi.Pointer result = func(thisCpp, a.toNativeUtf8(), fieldWidth); + return QString.fromCppPointer(result, true); + } // arg(int a, int fieldWidth, int base) const + + QString arg_2(int a, {int fieldWidth = 0, int base = 10}) { + final voidstar_Func_voidstar_int_int_int func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_voidstar_ffi_Int32_ffi_Int32_ffi_Int32_FFI>>( + 'c_QString__arg_int_int_int') + .asFunction(); + ffi.Pointer result = func(thisCpp, a, fieldWidth, base); + return QString.fromCppPointer(result, true); + } + + static // asprintf(const char * format) + QString asprintf(String? format) { + final voidstar_Func_string func = _dylib + .lookup>( + 'c_static_QString__asprintf_char') + .asFunction(); + ffi.Pointer result = func(format?.toNativeUtf8() ?? ffi.nullptr); + return QString.fromCppPointer(result, true); + } // capacity() const + + int capacity() { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_QString__capacity') + .asFunction(); + return func(thisCpp); + } // chop(qsizetype n) + + chop(int n) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_QString__chop_qsizetype') + .asFunction(); + func(thisCpp, n); + } // chopped(qsizetype n) const + + QString chopped(int n) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + 'c_QString__chopped_qsizetype') + .asFunction(); + ffi.Pointer result = func(thisCpp, n); + return QString.fromCppPointer(result, true); + } // clear() + + clear() { + final void_Func_voidstar func = _dylib + .lookup>('c_QString__clear') + .asFunction(); + func(thisCpp); + } // compare(const QString & s) const + + int compare(String s) { + final int_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QString__compare_QString') + .asFunction(); + return func(thisCpp, s.toNativeUtf8()); + } + + static // compare(const QString & s1, const QString & s2) + int compare_2(String s1, String s2) { + final int_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_static_QString__compare_QString_QString') + .asFunction(); + return func(s1.toNativeUtf8(), s2.toNativeUtf8()); + } // contains(const QString & s) const + + bool contains(String s) { + final bool_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QString__contains_QString') + .asFunction(); + return func(thisCpp, s.toNativeUtf8()) != 0; + } // count() const + + int count() { + final int_Func_voidstar func = _dylib + .lookup>('c_QString__count') + .asFunction(); + return func(thisCpp); + } // count(const QString & s) const + + int count_2(String s) { + final int_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QString__count_QString') + .asFunction(); + return func(thisCpp, s.toNativeUtf8()); + } // detach() + + detach() { + final void_Func_voidstar func = _dylib + .lookup>('c_QString__detach') + .asFunction(); + func(thisCpp); + } // endsWith(const QString & s) const + + bool endsWith(String s) { + final bool_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QString__endsWith_QString') + .asFunction(); + return func(thisCpp, s.toNativeUtf8()) != 0; + } // first(qsizetype n) const + + QString first(int n) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + 'c_QString__first_qsizetype') + .asFunction(); + ffi.Pointer result = func(thisCpp, n); + return QString.fromCppPointer(result, true); + } + + static // fromLatin1(const char * str, qsizetype size) + QString fromLatin1(String? str, int size) { + final voidstar_Func_string_int func = _dylib + .lookup>( + 'c_static_QString__fromLatin1_char_qsizetype') + .asFunction(); + ffi.Pointer result = func(str?.toNativeUtf8() ?? ffi.nullptr, size); + return QString.fromCppPointer(result, true); + } + + static // fromLocal8Bit(const char * str, qsizetype size) + QString fromLocal8Bit(String? str, int size) { + final voidstar_Func_string_int func = _dylib + .lookup>( + 'c_static_QString__fromLocal8Bit_char_qsizetype') + .asFunction(); + ffi.Pointer result = func(str?.toNativeUtf8() ?? ffi.nullptr, size); + return QString.fromCppPointer(result, true); + } + + static // fromUtf8(const char * utf8, qsizetype size) + QString fromUtf8(String? utf8, int size) { + final voidstar_Func_string_int func = _dylib + .lookup>( + 'c_static_QString__fromUtf8_char_qsizetype') + .asFunction(); + ffi.Pointer result = func(utf8?.toNativeUtf8() ?? ffi.nullptr, size); + return QString.fromCppPointer(result, true); + } // indexOf(const QString & s, qsizetype from) const + + int indexOf(String s, {int from = 0}) { + final int_Func_voidstar_voidstar_int func = _dylib + .lookup>( + 'c_QString__indexOf_QString_qsizetype') + .asFunction(); + return func(thisCpp, s.toNativeUtf8(), from); + } // insert(qsizetype i, const QByteArray & s) + + QString insert(int i, QByteArray s) { + final voidstar_Func_voidstar_int_voidstar func = _dylib + .lookup< + ffi + .NativeFunction>( + 'c_QString__insert_qsizetype_QByteArray') + .asFunction(); + ffi.Pointer result = + func(thisCpp, i, s == null ? ffi.nullptr : s.thisCpp); + return QString.fromCppPointer(result, false); + } // insert(qsizetype i, const QString & s) + + QString insert_2(int i, String s) { + final voidstar_Func_voidstar_int_voidstar func = _dylib + .lookup< + ffi + .NativeFunction>( + 'c_QString__insert_qsizetype_QString') + .asFunction(); + ffi.Pointer result = func(thisCpp, i, s.toNativeUtf8()); + return QString.fromCppPointer(result, false); + } // insert(qsizetype i, const char * s) + + QString insert_3(int i, String? s) { + final voidstar_Func_voidstar_int_string func = _dylib + .lookup< + ffi + .NativeFunction>( + 'c_QString__insert_qsizetype_char') + .asFunction(); + ffi.Pointer result = + func(thisCpp, i, s?.toNativeUtf8() ?? ffi.nullptr); + return QString.fromCppPointer(result, false); + } // isDetached() const + + bool isDetached() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QString__isDetached') + .asFunction(); + return func(thisCpp) != 0; + } // isEmpty() const + + bool isEmpty() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QString__isEmpty') + .asFunction(); + return func(thisCpp) != 0; + } // isLower() const + + bool isLower() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QString__isLower') + .asFunction(); + return func(thisCpp) != 0; + } // isNull() const + + bool isNull() { + final bool_Func_voidstar func = _dylib + .lookup>('c_QString__isNull') + .asFunction(); + return func(thisCpp) != 0; + } // isRightToLeft() const + + bool isRightToLeft() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QString__isRightToLeft') + .asFunction(); + return func(thisCpp) != 0; + } // isSharedWith(const QString & other) const + + bool isSharedWith(String other) { + final bool_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QString__isSharedWith_QString') + .asFunction(); + return func(thisCpp, other.toNativeUtf8()) != 0; + } // isSimpleText() const + + bool isSimpleText() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QString__isSimpleText') + .asFunction(); + return func(thisCpp) != 0; + } // isUpper() const + + bool isUpper() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QString__isUpper') + .asFunction(); + return func(thisCpp) != 0; + } // isValidUtf16() const + + bool isValidUtf16() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QString__isValidUtf16') + .asFunction(); + return func(thisCpp) != 0; + } // last(qsizetype n) const + + QString last(int n) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + 'c_QString__last_qsizetype') + .asFunction(); + ffi.Pointer result = func(thisCpp, n); + return QString.fromCppPointer(result, true); + } // lastIndexOf(const QString & s) const + + int lastIndexOf(String s) { + final int_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QString__lastIndexOf_QString') + .asFunction(); + return func(thisCpp, s.toNativeUtf8()); + } // lastIndexOf(const QString & s, qsizetype from) const + + int lastIndexOf_2(String s, int from) { + final int_Func_voidstar_voidstar_int func = _dylib + .lookup>( + 'c_QString__lastIndexOf_QString_qsizetype') + .asFunction(); + return func(thisCpp, s.toNativeUtf8(), from); + } // left(qsizetype n) const + + QString left(int n) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + 'c_QString__left_qsizetype') + .asFunction(); + ffi.Pointer result = func(thisCpp, n); + return QString.fromCppPointer(result, true); + } // leftJustified(qsizetype width) const + + QString leftJustified(int width) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + 'c_QString__leftJustified_qsizetype') + .asFunction(); + ffi.Pointer result = func(thisCpp, width); + return QString.fromCppPointer(result, true); + } // length() const + + int length() { + final int_Func_voidstar func = _dylib + .lookup>('c_QString__length') + .asFunction(); + return func(thisCpp); + } // localeAwareCompare(const QString & s) const + + int localeAwareCompare(String s) { + final int_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QString__localeAwareCompare_QString') + .asFunction(); + return func(thisCpp, s.toNativeUtf8()); + } + + static // localeAwareCompare(const QString & s1, const QString & s2) + int localeAwareCompare_2(String s1, String s2) { + final int_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_static_QString__localeAwareCompare_QString_QString') + .asFunction(); + return func(s1.toNativeUtf8(), s2.toNativeUtf8()); + } // mid(qsizetype position, qsizetype n) const + + QString mid(int position, {int n = -1}) { + final voidstar_Func_voidstar_int_int func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_voidstar_ffi_Int32_ffi_Int32_FFI>>( + 'c_QString__mid_qsizetype_qsizetype') + .asFunction(); + ffi.Pointer result = func(thisCpp, position, n); + return QString.fromCppPointer(result, true); + } + + static // number(int arg__1, int base) + QString number(int arg__1, {int base = 10}) { + final voidstar_Func_int_int func = _dylib + .lookup>( + 'c_static_QString__number_int_int') + .asFunction(); + ffi.Pointer result = func(arg__1, base); + return QString.fromCppPointer(result, true); + } // prepend(const QByteArray & s) + + QString prepend(QByteArray s) { + final voidstar_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QString__prepend_QByteArray') + .asFunction(); + ffi.Pointer result = + func(thisCpp, s == null ? ffi.nullptr : s.thisCpp); + return QString.fromCppPointer(result, false); + } // prepend(const QString & s) + + QString prepend_2(String s) { + final voidstar_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QString__prepend_QString') + .asFunction(); + ffi.Pointer result = func(thisCpp, s.toNativeUtf8()); + return QString.fromCppPointer(result, false); + } // prepend(const char * s) + + QString prepend_3(String? s) { + final voidstar_Func_voidstar_string func = _dylib + .lookup>( + 'c_QString__prepend_char') + .asFunction(); + ffi.Pointer result = func(thisCpp, s?.toNativeUtf8() ?? ffi.nullptr); + return QString.fromCppPointer(result, false); + } // push_back(const QString & s) + + push_back(String s) { + final void_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QString__push_back_QString') + .asFunction(); + func(thisCpp, s.toNativeUtf8()); + } // push_front(const QString & s) + + push_front(String s) { + final void_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QString__push_front_QString') + .asFunction(); + func(thisCpp, s.toNativeUtf8()); + } // reallocGrowData(qsizetype n) + + reallocGrowData(int n) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_QString__reallocGrowData_qsizetype') + .asFunction(); + func(thisCpp, n); + } // remove(const QString & s) + + QString remove(String s) { + final voidstar_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QString__remove_QString') + .asFunction(); + ffi.Pointer result = func(thisCpp, s.toNativeUtf8()); + return QString.fromCppPointer(result, false); + } // remove(qsizetype i, qsizetype len) + + QString remove_2(int i, int len) { + final voidstar_Func_voidstar_int_int func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_voidstar_ffi_Int32_ffi_Int32_FFI>>( + 'c_QString__remove_qsizetype_qsizetype') + .asFunction(); + ffi.Pointer result = func(thisCpp, i, len); + return QString.fromCppPointer(result, false); + } // repeated(qsizetype times) const + + QString repeated(int times) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + 'c_QString__repeated_qsizetype') + .asFunction(); + ffi.Pointer result = func(thisCpp, times); + return QString.fromCppPointer(result, true); + } // replace(const QString & before, const QString & after) + + QString replace(String before, String after) { + final voidstar_Func_voidstar_voidstar_voidstar func = _dylib + .lookup< + ffi + .NativeFunction>( + 'c_QString__replace_QString_QString') + .asFunction(); + ffi.Pointer result = + func(thisCpp, before.toNativeUtf8(), after.toNativeUtf8()); + return QString.fromCppPointer(result, false); + } // replace(qsizetype i, qsizetype len, const QString & after) + + QString replace_2(int i, int len, String after) { + final voidstar_Func_voidstar_int_int_voidstar func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_voidstar_ffi_Int32_ffi_Int32_voidstar_FFI>>( + 'c_QString__replace_qsizetype_qsizetype_QString') + .asFunction(); + ffi.Pointer result = func(thisCpp, i, len, after.toNativeUtf8()); + return QString.fromCppPointer(result, false); + } // reserve(qsizetype size) + + reserve(int size) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_QString__reserve_qsizetype') + .asFunction(); + func(thisCpp, size); + } // resize(qsizetype size) + + resize(int size) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_QString__resize_qsizetype') + .asFunction(); + func(thisCpp, size); + } // right(qsizetype n) const + + QString right(int n) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + 'c_QString__right_qsizetype') + .asFunction(); + ffi.Pointer result = func(thisCpp, n); + return QString.fromCppPointer(result, true); + } // rightJustified(qsizetype width) const + + QString rightJustified(int width) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + 'c_QString__rightJustified_qsizetype') + .asFunction(); + ffi.Pointer result = func(thisCpp, width); + return QString.fromCppPointer(result, true); + } // section(const QString & in_sep, qsizetype start, qsizetype end) const + + QString section(String in_sep, int start, {int end = -1}) { + final voidstar_Func_voidstar_voidstar_int_int func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_voidstar_voidstar_ffi_Int32_ffi_Int32_FFI>>( + 'c_QString__section_QString_qsizetype_qsizetype') + .asFunction(); + ffi.Pointer result = func(thisCpp, in_sep.toNativeUtf8(), start, end); + return QString.fromCppPointer(result, true); + } // setNum(int arg__1, int base) + + QString setNum(int arg__1, {int base = 10}) { + final voidstar_Func_voidstar_int_int func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_voidstar_ffi_Int32_ffi_Int32_FFI>>( + 'c_QString__setNum_int_int') + .asFunction(); + ffi.Pointer result = func(thisCpp, arg__1, base); + return QString.fromCppPointer(result, false); + } // shrink_to_fit() + + shrink_to_fit() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QString__shrink_to_fit') + .asFunction(); + func(thisCpp); + } // simplified() + + QString simplified() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QString__simplified') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QString.fromCppPointer(result, true); + } + + static // simplified_helper(QString & str) + QString simplified_helper(String str) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_static_QString__simplified_helper_QString') + .asFunction(); + ffi.Pointer result = func(str.toNativeUtf8()); + return QString.fromCppPointer(result, true); + } + + static // simplified_helper(const QString & str) + QString simplified_helper_2(String str) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_static_QString__simplified_helper_QString') + .asFunction(); + ffi.Pointer result = func(str.toNativeUtf8()); + return QString.fromCppPointer(result, true); + } // size() const + + int size() { + final int_Func_voidstar func = _dylib + .lookup>('c_QString__size') + .asFunction(); + return func(thisCpp); + } // sliced(qsizetype pos) const + + QString sliced(int pos) { + final voidstar_Func_voidstar_int func = _dylib + .lookup>( + 'c_QString__sliced_qsizetype') + .asFunction(); + ffi.Pointer result = func(thisCpp, pos); + return QString.fromCppPointer(result, true); + } // sliced(qsizetype pos, qsizetype n) const + + QString sliced_2(int pos, int n) { + final voidstar_Func_voidstar_int_int func = _dylib + .lookup< + ffi.NativeFunction< + voidstar_Func_voidstar_ffi_Int32_ffi_Int32_FFI>>( + 'c_QString__sliced_qsizetype_qsizetype') + .asFunction(); + ffi.Pointer result = func(thisCpp, pos, n); + return QString.fromCppPointer(result, true); + } // split(const QString & sep) const + + QList split(String sep) { + final voidstar_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QString__split_QString') + .asFunction(); + ffi.Pointer result = func(thisCpp, sep.toNativeUtf8()); + return QList.fromCppPointer(result, true); + } // squeeze() + + squeeze() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QString__squeeze') + .asFunction(); + func(thisCpp); + } // startsWith(const QString & s) const + + bool startsWith(String s) { + final bool_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QString__startsWith_QString') + .asFunction(); + return func(thisCpp, s.toNativeUtf8()) != 0; + } // toCaseFolded() + + QString toCaseFolded() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QString__toCaseFolded') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QString.fromCppPointer(result, true); + } + + static // toCaseFolded_helper(QString & str) + QString toCaseFolded_helper(String str) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_static_QString__toCaseFolded_helper_QString') + .asFunction(); + ffi.Pointer result = func(str.toNativeUtf8()); + return QString.fromCppPointer(result, true); + } + + static // toCaseFolded_helper(const QString & str) + QString toCaseFolded_helper_2(String str) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_static_QString__toCaseFolded_helper_QString') + .asFunction(); + ffi.Pointer result = func(str.toNativeUtf8()); + return QString.fromCppPointer(result, true); + } // toHtmlEscaped() const + + QString toHtmlEscaped() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QString__toHtmlEscaped') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QString.fromCppPointer(result, true); + } // toLatin1() + + QByteArray toLatin1() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QString__toLatin1') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QByteArray.fromCppPointer(result, true); + } + + static // toLatin1_helper(const QString & arg__1) + QByteArray toLatin1_helper(String arg__1) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_static_QString__toLatin1_helper_QString') + .asFunction(); + ffi.Pointer result = func(arg__1.toNativeUtf8()); + return QByteArray.fromCppPointer(result, true); + } + + static // toLatin1_helper_inplace(QString & arg__1) + QByteArray toLatin1_helper_inplace(String arg__1) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_static_QString__toLatin1_helper_inplace_QString') + .asFunction(); + ffi.Pointer result = func(arg__1.toNativeUtf8()); + return QByteArray.fromCppPointer(result, true); + } // toLocal8Bit() + + QByteArray toLocal8Bit() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QString__toLocal8Bit') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QByteArray.fromCppPointer(result, true); + } // toLower() + + QString toLower() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QString__toLower') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QString.fromCppPointer(result, true); + } + + static // toLower_helper(QString & str) + QString toLower_helper(String str) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_static_QString__toLower_helper_QString') + .asFunction(); + ffi.Pointer result = func(str.toNativeUtf8()); + return QString.fromCppPointer(result, true); + } + + static // toLower_helper(const QString & str) + QString toLower_helper_2(String str) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_static_QString__toLower_helper_QString') + .asFunction(); + ffi.Pointer result = func(str.toNativeUtf8()); + return QString.fromCppPointer(result, true); + } // toUcs4() const + + QList toUcs4() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QString__toUcs4') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QList.fromCppPointer(result, true); + } // toUpper() + + QString toUpper() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QString__toUpper') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QString.fromCppPointer(result, true); + } + + static // toUpper_helper(QString & str) + QString toUpper_helper(String str) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_static_QString__toUpper_helper_QString') + .asFunction(); + ffi.Pointer result = func(str.toNativeUtf8()); + return QString.fromCppPointer(result, true); + } + + static // toUpper_helper(const QString & str) + QString toUpper_helper_2(String str) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_static_QString__toUpper_helper_QString') + .asFunction(); + ffi.Pointer result = func(str.toNativeUtf8()); + return QString.fromCppPointer(result, true); + } // toUtf8() + + QByteArray toUtf8() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QString__toUtf8') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QByteArray.fromCppPointer(result, true); + } + + static // toUtf8_helper(const QString & arg__1) + QByteArray toUtf8_helper(String arg__1) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_static_QString__toUtf8_helper_QString') + .asFunction(); + ffi.Pointer result = func(arg__1.toNativeUtf8()); + return QByteArray.fromCppPointer(result, true); + } // trimmed() + + QString trimmed() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QString__trimmed') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QString.fromCppPointer(result, true); + } + + static // trimmed_helper(QString & str) + QString trimmed_helper(String str) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_static_QString__trimmed_helper_QString') + .asFunction(); + ffi.Pointer result = func(str.toNativeUtf8()); + return QString.fromCppPointer(result, true); + } + + static // trimmed_helper(const QString & str) + QString trimmed_helper_2(String str) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_static_QString__trimmed_helper_QString') + .asFunction(); + ffi.Pointer result = func(str.toNativeUtf8()); + return QString.fromCppPointer(result, true); + } // truncate(qsizetype pos) + + truncate(int pos) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_QString__truncate_qsizetype') + .asFunction(); + func(thisCpp, pos); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QString__destructor') + .asFunction(); + func(thisCpp); + } + + String toDartString() { + return toUtf8().constData(); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/QVariant.dart b/tests/generated/TestBindings/dart/lib/src/QVariant.dart new file mode 100644 index 0000000..c9f891d --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/QVariant.dart @@ -0,0 +1,297 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class QVariant implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = true; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory QVariant.fromCache(var cppPointer, [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + QVariant.fromCppPointer(cppPointer, needsAutoDelete)) as QVariant; + } + QVariant.fromCppPointer(var cppPointer, [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + QVariant.init() {} + String getFinalizerName() { + return "c_QVariant_Finalizer"; + } //QVariant() + + QVariant() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_QVariant__constructor') + .asFunction(); + thisCpp = func(); + QVariant.s_dartInstanceByCppPtr[thisCpp.address] = this; + } //QVariant(bool b) + QVariant.ctor2(bool b) { + final voidstar_Func_bool func = _dylib + .lookup>( + 'c_QVariant__constructor_bool') + .asFunction(); + thisCpp = func(b ? 1 : 0); + QVariant.s_dartInstanceByCppPtr[thisCpp.address] = this; + } //QVariant(const QByteArray & bytearray) + QVariant.ctor3(QByteArray bytearray) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QVariant__constructor_QByteArray') + .asFunction(); + thisCpp = func(bytearray == null ? ffi.nullptr : bytearray.thisCpp); + QVariant.s_dartInstanceByCppPtr[thisCpp.address] = this; + } //QVariant(const QHash & hash) + QVariant.ctor4(QHash hash) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QVariant__constructor_QHash_QString_QVariant') + .asFunction(); + thisCpp = func(hash == null ? ffi.nullptr : hash.thisCpp); + QVariant.s_dartInstanceByCppPtr[thisCpp.address] = this; + } //QVariant(const QList & stringlist) + QVariant.ctor5(QList stringlist) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QVariant__constructor_QList_QString') + .asFunction(); + thisCpp = func(stringlist == null ? ffi.nullptr : stringlist.thisCpp); + QVariant.s_dartInstanceByCppPtr[thisCpp.address] = this; + } //QVariant(const QList & list) + QVariant.ctor6(QList list) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QVariant__constructor_QList_QVariant') + .asFunction(); + thisCpp = func(list == null ? ffi.nullptr : list.thisCpp); + QVariant.s_dartInstanceByCppPtr[thisCpp.address] = this; + } //QVariant(const QMap & map) + QVariant.ctor7(QMap map) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QVariant__constructor_QMap_QString_QVariant') + .asFunction(); + thisCpp = func(map == null ? ffi.nullptr : map.thisCpp); + QVariant.s_dartInstanceByCppPtr[thisCpp.address] = this; + } //QVariant(const QString & string) + QVariant.ctor8(String string) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QVariant__constructor_QString') + .asFunction(); + thisCpp = func(string.toNativeUtf8()); + QVariant.s_dartInstanceByCppPtr[thisCpp.address] = this; + } //QVariant(const char * str) + QVariant.ctor9(String? str) { + final voidstar_Func_string func = _dylib + .lookup>( + 'c_QVariant__constructor_char') + .asFunction(); + thisCpp = func(str?.toNativeUtf8() ?? ffi.nullptr); + QVariant.s_dartInstanceByCppPtr[thisCpp.address] = this; + } //QVariant(double d) + QVariant.ctor10(double d) { + final voidstar_Func_double func = _dylib + .lookup>( + 'c_QVariant__constructor_double') + .asFunction(); + thisCpp = func(d); + QVariant.s_dartInstanceByCppPtr[thisCpp.address] = this; + } //QVariant(float f) + QVariant.ctor11(double f) { + final voidstar_Func_double func = _dylib + .lookup>( + 'c_QVariant__constructor_float') + .asFunction(); + thisCpp = func(f); + QVariant.s_dartInstanceByCppPtr[thisCpp.address] = this; + } //QVariant(int i) + QVariant.ctor12(int i) { + final voidstar_Func_int func = _dylib + .lookup>( + 'c_QVariant__constructor_int') + .asFunction(); + thisCpp = func(i); + QVariant.s_dartInstanceByCppPtr[thisCpp.address] = this; + } // clear() + clear() { + final void_Func_voidstar func = _dylib + .lookup>('c_QVariant__clear') + .asFunction(); + func(thisCpp); + } // detach() + + detach() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QVariant__detach') + .asFunction(); + func(thisCpp); + } // equals(const QVariant & other) const + + bool equals(QVariant other) { + final bool_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QVariant__equals_QVariant') + .asFunction(); + return func(thisCpp, other == null ? ffi.nullptr : other.thisCpp) != 0; + } + + static // fromObject(QObject * arg__1) + QVariant fromObject(QObject? arg__1) { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_static_QVariant__fromObject_QObject') + .asFunction(); + ffi.Pointer result = + func(arg__1 == null ? ffi.nullptr : arg__1.thisCpp); + return QVariant.fromCppPointer(result, true); + } // isDetached() const + + bool isDetached() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QVariant__isDetached') + .asFunction(); + return func(thisCpp) != 0; + } // isNull() const + + bool isNull() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QVariant__isNull') + .asFunction(); + return func(thisCpp) != 0; + } // isValid() const + + bool isValid() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QVariant__isValid') + .asFunction(); + return func(thisCpp) != 0; + } // setValue(const QVariant & avalue) + + setValue(QVariant avalue) { + final void_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_QVariant__setValue_QVariant') + .asFunction(); + func(thisCpp, avalue == null ? ffi.nullptr : avalue.thisCpp); + } // toBool() const + + bool toBool() { + final bool_Func_voidstar func = _dylib + .lookup>( + 'c_QVariant__toBool') + .asFunction(); + return func(thisCpp) != 0; + } // toByteArray() const + + QByteArray toByteArray() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QVariant__toByteArray') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QByteArray.fromCppPointer(result, true); + } // toHash() const + + QHash toHash() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QVariant__toHash') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QHash.fromCppPointer(result, true); + } // toList() const + + QList toList() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QVariant__toList') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QList.fromCppPointer(result, true); + } // toMap() const + + QMap toMap() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QVariant__toMap') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QMap.fromCppPointer(result, true); + } // toStringList() const + + QList toStringList() { + final voidstar_Func_voidstar func = _dylib + .lookup>( + 'c_QVariant__toStringList') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return QList.fromCppPointer(result, true); + } // typeId() const + + int typeId() { + final int_Func_voidstar func = _dylib + .lookup>('c_QVariant__typeId') + .asFunction(); + return func(thisCpp); + } // typeName() const + + String typeName() { + final string_Func_voidstar func = _dylib + .lookup>( + 'c_QVariant__typeName') + .asFunction(); + ffi.Pointer result = func(thisCpp); + return result.toDartString(); + } // userType() const + + int userType() { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_QVariant__userType') + .asFunction(); + return func(thisCpp); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_QVariant__destructor') + .asFunction(); + func(thisCpp); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/QVector.dart b/tests/generated/TestBindings/dart/lib/src/QVector.dart new file mode 100644 index 0000000..7e4bb28 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/QVector.dart @@ -0,0 +1,1225 @@ +//tag=1052 +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../FinalizerHelpers.dart'; + +//tag=1051 +var _dylib = Library.instance().dylib; +final _finalizer_T_int_T_ = + _dylib.lookup>( + 'dartffi_QVector_T_int_T__Finalizer'); + +class QVector { +//tag=1060 + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = true; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + s_dartInstanceByCppPtr[ptr.address] = this; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) + newWeakPersistentHandle?.call(this, ptrvoid, 0, getFinalizer()); + } + + static bool isCached(var cppPointer) { +//tag=1024 + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + +//tag=1061 + factory QVector.fromCache(var cppPointer, [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + QVector.fromCppPointer(cppPointer, needsAutoDelete)) as QVector; + } + QVector.fromCppPointer(var cppPointer, [this._needsAutoDelete = false]) { +//tag=1024 + thisCpp = cppPointer; + } +//tag=1025 + QVector.init() {} +//tag=1063 + String getCFunctionName(int id) { + if (this is QVector) { + switch (id) { + case 1060: + return "dartffi_QVector_T_int_T___constructor"; + break; + case 1063: + return "dartffi_QVector_T_int_T___constructor_int"; + break; + case 1064: + return "dartffi_QVector_T_int_T___constructor_int_int"; + break; + case 1066: + return "dartffi_QVector_T_int_T___append_QVector"; + break; + case 1067: + return "dartffi_QVector_T_int_T___append_int"; + break; + case 1068: + return "dartffi_QVector_T_int_T___at_int"; + break; + case 1069: + return "dartffi_QVector_T_int_T___back"; + break; + case 1070: + return "dartffi_QVector_T_int_T___back"; + break; + case 1071: + return "dartffi_QVector_T_int_T___capacity"; + break; + case 1072: + return "dartffi_QVector_T_int_T___clear"; + break; + case 1073: + return "dartffi_QVector_T_int_T___constData"; + break; + case 1074: + return "dartffi_QVector_T_int_T___constFirst"; + break; + case 1075: + return "dartffi_QVector_T_int_T___constLast"; + break; + case 1076: + return "dartffi_QVector_T_int_T___contains_int"; + break; + case 1078: + return "dartffi_QVector_T_int_T___count"; + break; + case 1079: + return "dartffi_QVector_T_int_T___count_int"; + break; + case 1080: + return "dartffi_QVector_T_int_T___data"; + break; + case 1081: + return "dartffi_QVector_T_int_T___data"; + break; + case 1084: + return "dartffi_QVector_T_int_T___detach"; + break; + case 1085: + return "dartffi_QVector_T_int_T___empty"; + break; + case 1086: + return "dartffi_QVector_T_int_T___endsWith_int"; + break; + case 1087: + return "dartffi_QVector_T_int_T___fill_int_int"; + break; + case 1088: + return "dartffi_QVector_T_int_T___first"; + break; + case 1089: + return "dartffi_QVector_T_int_T___first"; + break; + case 1091: + return "dartffi_QVector_T_int_T___front"; + break; + case 1092: + return "dartffi_QVector_T_int_T___front"; + break; + case 1093: + return "dartffi_QVector_T_int_T___indexOf_int_int"; + break; + case 1095: + return "dartffi_QVector_T_int_T___insert_int_int"; + break; + case 1096: + return "dartffi_QVector_T_int_T___insert_int_int_int"; + break; + case 1097: + return "dartffi_QVector_T_int_T___isDetached"; + break; + case 1098: + return "dartffi_QVector_T_int_T___isEmpty"; + break; + case 1099: + return "dartffi_QVector_T_int_T___isSharedWith_QVector"; + break; + case 1100: + return "dartffi_QVector_T_int_T___last"; + break; + case 1101: + return "dartffi_QVector_T_int_T___last"; + break; + case 1102: + return "dartffi_QVector_T_int_T___lastIndexOf_int_int"; + break; + case 1103: + return "dartffi_QVector_T_int_T___length"; + break; + case 1104: + return "dartffi_QVector_T_int_T___mid_int_int"; + break; + case 1105: + return "dartffi_QVector_T_int_T___move_int_int"; + break; + case 1119: + return "dartffi_QVector_T_int_T___pop_back"; + break; + case 1120: + return "dartffi_QVector_T_int_T___pop_front"; + break; + case 1122: + return "dartffi_QVector_T_int_T___prepend_int"; + break; + case 1124: + return "dartffi_QVector_T_int_T___push_back_int"; + break; + case 1126: + return "dartffi_QVector_T_int_T___push_front_int"; + break; + case 1130: + return "dartffi_QVector_T_int_T___remove_int"; + break; + case 1131: + return "dartffi_QVector_T_int_T___remove_int_int"; + break; + case 1132: + return "dartffi_QVector_T_int_T___removeAll_int"; + break; + case 1133: + return "dartffi_QVector_T_int_T___removeAt_int"; + break; + case 1134: + return "dartffi_QVector_T_int_T___removeFirst"; + break; + case 1135: + return "dartffi_QVector_T_int_T___removeLast"; + break; + case 1136: + return "dartffi_QVector_T_int_T___removeOne_int"; + break; + case 1137: + return "dartffi_QVector_T_int_T___replace_int_int"; + break; + case 1138: + return "dartffi_QVector_T_int_T___reserve_int"; + break; + case 1139: + return "dartffi_QVector_T_int_T___resize_int"; + break; + case 1140: + return "dartffi_QVector_T_int_T___setSharable_bool"; + break; + case 1141: + return "dartffi_QVector_T_int_T___shrink_to_fit"; + break; + case 1142: + return "dartffi_QVector_T_int_T___size"; + break; + case 1143: + return "dartffi_QVector_T_int_T___squeeze"; + break; + case 1144: + return "dartffi_QVector_T_int_T___startsWith_int"; + break; + case 1146: + return "dartffi_QVector_T_int_T___swapItemsAt_int_int"; + break; + case 1147: + return "dartffi_QVector_T_int_T___takeAt_int"; + break; + case 1148: + return "dartffi_QVector_T_int_T___takeFirst"; + break; + case 1149: + return "dartffi_QVector_T_int_T___takeLast"; + break; + case 1150: + return "dartffi_QVector_T_int_T___toList"; + break; + case 1151: + return "dartffi_QVector_T_int_T___value_int"; + break; + case 1152: + return "dartffi_QVector_T_int_T___value_int_int"; + break; + } + } + return ""; + } + +//tag=1065 + dynamic getFinalizer() { + if (this is QVector) { + return _finalizer_T_int_T_; + } + print("ERROR: Couldn't find finalizer for" + this.runtimeType.toString()); + } + +//tag=1023 +//QVector() + QVector() { +//tag=1075 + final voidstar_Func_void func = _dylib + .lookup>( + '${getCFunctionName(1060)}') + .asFunction(); + thisCpp = func(); + } +//tag=1023 +//QVector(int size) + QVector.ctor2(int size) { +//tag=1075 + final voidstar_Func_int func = _dylib + .lookup>( + '${getCFunctionName(1063)}') + .asFunction(); + thisCpp = func(size); + } +//tag=1023 +//QVector(int size, const T & t) + QVector.ctor3(int size, T t) { +//tag=1075 + if (this is QVector) { + final voidstar_Func_int_int func = _dylib + .lookup>( + '${getCFunctionName(1064)}') + .asFunction(); + thisCpp = func(size, (t as int)); + } + } +//tag=1024 + +//tag=1027 +// append(const QVector & l) + void append(QVector l) { +//tag=1028 + final void_Func_voidstar_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1066)}') + .asFunction(); +//tag=1030 + func(thisCpp, l == null ? ffi.nullptr : l.thisCpp); + } +//tag=1024 + +//tag=1027 +// append(const T & t) + void append_2(T t) { +//tag=1028 + if (this is QVector) { + final void_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(1067)}') + .asFunction(); +//tag=1030 + func(thisCpp, (t as int)); + } + } +//tag=1024 + +//tag=1027 +// at(int i) const + T at(int i) { +//tag=1028 + if (this is QVector) { + final int_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(1068)}') + .asFunction(); +//tag=1031 + return (func(thisCpp, i) as T); + } else { +// Unreachable, but required, due to null safety we need to return something + throw Error(); + } + } +//tag=1024 + +//tag=1027 +// back() + T back() { +//tag=1028 + if (this is QVector) { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1069)}') + .asFunction(); +//tag=1031 + return (func(thisCpp) as T); + } else { +// Unreachable, but required, due to null safety we need to return something + throw Error(); + } + } +//tag=1024 + +//tag=1027 +// capacity() const + int capacity() { +//tag=1028 + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1071)}') + .asFunction(); +//tag=1031 + return func(thisCpp); + } +//tag=1024 + +//tag=1027 +// clear() + void clear() { +//tag=1028 + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1072)}') + .asFunction(); +//tag=1030 + func(thisCpp); + } +//tag=1024 + +//tag=1027 +// constData() const + T constData() { +//tag=1028 + if (this is QVector) { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1073)}') + .asFunction(); +//tag=1031 + return (func(thisCpp) as T); + } else { +// Unreachable, but required, due to null safety we need to return something + throw Error(); + } + } +//tag=1024 + +//tag=1027 +// constFirst() const + T constFirst() { +//tag=1028 + if (this is QVector) { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1074)}') + .asFunction(); +//tag=1031 + return (func(thisCpp) as T); + } else { +// Unreachable, but required, due to null safety we need to return something + throw Error(); + } + } +//tag=1024 + +//tag=1027 +// constLast() const + T constLast() { +//tag=1028 + if (this is QVector) { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1075)}') + .asFunction(); +//tag=1031 + return (func(thisCpp) as T); + } else { +// Unreachable, but required, due to null safety we need to return something + throw Error(); + } + } +//tag=1024 + +//tag=1027 +// contains(const T & t) const + bool contains(T t) { +//tag=1028 + if (this is QVector) { + final bool_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(1076)}') + .asFunction(); +//tag=1029 + return func(thisCpp, (t as int)) != 0; + } else { +// Unreachable, but required, due to null safety we need to return something + throw Error(); + } + } +//tag=1024 + +//tag=1027 +// copyConstruct(const T * srcFrom, const T * srcTo, T * dstFrom) + void copyConstruct(T srcFrom, T srcTo, T dstFrom) { +//tag=1028 + if (this is QVector) { + final void_Func_voidstar_int_int_int func = _dylib + .lookup< + ffi.NativeFunction< + void_Func_voidstar_ffi_Int32_ffi_Int32_ffi_Int32_FFI>>( + '${getCFunctionName(1077)}') + .asFunction(); +//tag=1030 + func(thisCpp, (srcFrom as int), (srcTo as int), (dstFrom as int)); + } + } +//tag=1024 + +//tag=1027 +// count() const + int count() { +//tag=1028 + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1078)}') + .asFunction(); +//tag=1031 + return func(thisCpp); + } +//tag=1024 + +//tag=1027 +// count(const T & t) const + int count_2(T t) { +//tag=1028 + if (this is QVector) { + final int_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(1079)}') + .asFunction(); +//tag=1031 + return func(thisCpp, (t as int)); + } else { +// Unreachable, but required, due to null safety we need to return something + throw Error(); + } + } +//tag=1024 + +//tag=1027 +// data() + T data() { +//tag=1028 + if (this is QVector) { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1080)}') + .asFunction(); +//tag=1031 + return (func(thisCpp) as T); + } else { +// Unreachable, but required, due to null safety we need to return something + throw Error(); + } + } +//tag=1024 + +//tag=1027 +// defaultConstruct(T * from, T * to) + void defaultConstruct(T from, T to) { +//tag=1028 + if (this is QVector) { + final void_Func_voidstar_int_int func = _dylib + .lookup< + ffi + .NativeFunction>( + '${getCFunctionName(1082)}') + .asFunction(); +//tag=1030 + func(thisCpp, (from as int), (to as int)); + } + } +//tag=1024 + +//tag=1027 +// destruct(T * from, T * to) + void destruct(T from, T to) { +//tag=1028 + if (this is QVector) { + final void_Func_voidstar_int_int func = _dylib + .lookup< + ffi + .NativeFunction>( + '${getCFunctionName(1083)}') + .asFunction(); +//tag=1030 + func(thisCpp, (from as int), (to as int)); + } + } +//tag=1024 + +//tag=1027 +// detach() + void detach() { +//tag=1028 + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1084)}') + .asFunction(); +//tag=1030 + func(thisCpp); + } +//tag=1024 + +//tag=1027 +// empty() const + bool empty() { +//tag=1028 + final bool_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1085)}') + .asFunction(); +//tag=1029 + return func(thisCpp) != 0; + } +//tag=1024 + +//tag=1027 +// endsWith(const T & t) const + bool endsWith(T t) { +//tag=1028 + if (this is QVector) { + final bool_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(1086)}') + .asFunction(); +//tag=1029 + return func(thisCpp, (t as int)) != 0; + } else { +// Unreachable, but required, due to null safety we need to return something + throw Error(); + } + } +//tag=1024 + +//tag=1027 +// first() + T first() { +//tag=1028 + if (this is QVector) { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1088)}') + .asFunction(); +//tag=1031 + return (func(thisCpp) as T); + } else { +// Unreachable, but required, due to null safety we need to return something + throw Error(); + } + } +//tag=1024 + +//tag=1027 +// front() + T front() { +//tag=1028 + if (this is QVector) { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1091)}') + .asFunction(); +//tag=1031 + return (func(thisCpp) as T); + } else { +// Unreachable, but required, due to null safety we need to return something + throw Error(); + } + } +//tag=1024 + +//tag=1027 +// indexOf(const T & t, int from) const + int indexOf(T t, {int from = 0}) { +//tag=1028 + if (this is QVector) { + final int_Func_voidstar_int_int func = _dylib + .lookup< + ffi + .NativeFunction>( + '${getCFunctionName(1093)}') + .asFunction(); +//tag=1031 + return func(thisCpp, (t as int), from); + } else { +// Unreachable, but required, due to null safety we need to return something + throw Error(); + } + } +//tag=1024 + +//tag=1027 +// insert(int i, const T & t) + void insert(int i, T t) { +//tag=1028 + if (this is QVector) { + final void_Func_voidstar_int_int func = _dylib + .lookup< + ffi + .NativeFunction>( + '${getCFunctionName(1095)}') + .asFunction(); +//tag=1030 + func(thisCpp, i, (t as int)); + } + } +//tag=1024 + +//tag=1027 +// insert(int i, int n, const T & t) + void insert_2(int i, int n, T t) { +//tag=1028 + if (this is QVector) { + final void_Func_voidstar_int_int_int func = _dylib + .lookup< + ffi.NativeFunction< + void_Func_voidstar_ffi_Int32_ffi_Int32_ffi_Int32_FFI>>( + '${getCFunctionName(1096)}') + .asFunction(); +//tag=1030 + func(thisCpp, i, n, (t as int)); + } + } +//tag=1024 + +//tag=1027 +// isDetached() const + bool isDetached() { +//tag=1028 + final bool_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1097)}') + .asFunction(); +//tag=1029 + return func(thisCpp) != 0; + } +//tag=1024 + +//tag=1027 +// isEmpty() const + bool isEmpty() { +//tag=1028 + final bool_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1098)}') + .asFunction(); +//tag=1029 + return func(thisCpp) != 0; + } +//tag=1024 + +//tag=1027 +// isSharedWith(const QVector & other) const + bool isSharedWith(QVector other) { +//tag=1028 + final bool_Func_voidstar_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1099)}') + .asFunction(); +//tag=1029 + return func(thisCpp, other == null ? ffi.nullptr : other.thisCpp) != 0; + } +//tag=1024 + +//tag=1027 +// last() + T last() { +//tag=1028 + if (this is QVector) { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1100)}') + .asFunction(); +//tag=1031 + return (func(thisCpp) as T); + } else { +// Unreachable, but required, due to null safety we need to return something + throw Error(); + } + } +//tag=1024 + +//tag=1027 +// lastIndexOf(const T & t, int from) const + int lastIndexOf(T t, {int from = -1}) { +//tag=1028 + if (this is QVector) { + final int_Func_voidstar_int_int func = _dylib + .lookup< + ffi + .NativeFunction>( + '${getCFunctionName(1102)}') + .asFunction(); +//tag=1031 + return func(thisCpp, (t as int), from); + } else { +// Unreachable, but required, due to null safety we need to return something + throw Error(); + } + } +//tag=1024 + +//tag=1027 +// length() const + int length() { +//tag=1028 + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1103)}') + .asFunction(); +//tag=1031 + return func(thisCpp); + } +//tag=1024 + +//tag=1027 +// move(int from, int to) + void move(int from, int to) { +//tag=1028 + final void_Func_voidstar_int_int func = _dylib + .lookup>( + '${getCFunctionName(1105)}') + .asFunction(); +//tag=1030 + func(thisCpp, from, to); + } +//tag=1024 + +//tag=1027 +// pop_back() + void pop_back() { +//tag=1028 + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1119)}') + .asFunction(); +//tag=1030 + func(thisCpp); + } +//tag=1024 + +//tag=1027 +// pop_front() + void pop_front() { +//tag=1028 + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1120)}') + .asFunction(); +//tag=1030 + func(thisCpp); + } +//tag=1024 + +//tag=1027 +// prepend(const T & t) + void prepend(T t) { +//tag=1028 + if (this is QVector) { + final void_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(1122)}') + .asFunction(); +//tag=1030 + func(thisCpp, (t as int)); + } + } +//tag=1024 + +//tag=1027 +// push_back(const T & t) + void push_back(T t) { +//tag=1028 + if (this is QVector) { + final void_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(1124)}') + .asFunction(); +//tag=1030 + func(thisCpp, (t as int)); + } + } +//tag=1024 + +//tag=1027 +// push_front(const T & t) + void push_front(T t) { +//tag=1028 + if (this is QVector) { + final void_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(1126)}') + .asFunction(); +//tag=1030 + func(thisCpp, (t as int)); + } + } +//tag=1024 + +//tag=1027 +// realloc(int alloc) + void realloc(int alloc) { +//tag=1028 + final void_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(1127)}') + .asFunction(); +//tag=1030 + func(thisCpp, alloc); + } +//tag=1024 + +//tag=1027 +// reallocData(const int size, const int alloc) + void reallocData(int size, int alloc) { +//tag=1028 + final void_Func_voidstar_int_int func = _dylib + .lookup>( + '${getCFunctionName(1128)}') + .asFunction(); +//tag=1030 + func(thisCpp, size, alloc); + } +//tag=1024 + +//tag=1027 +// reallocData(const int sz) + void reallocData_2(int sz) { +//tag=1028 + final void_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(1129)}') + .asFunction(); +//tag=1030 + func(thisCpp, sz); + } +//tag=1024 + +//tag=1027 +// remove(int i) + void remove(int i) { +//tag=1028 + final void_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(1130)}') + .asFunction(); +//tag=1030 + func(thisCpp, i); + } +//tag=1024 + +//tag=1027 +// remove(int i, int n) + void remove_2(int i, int n) { +//tag=1028 + final void_Func_voidstar_int_int func = _dylib + .lookup>( + '${getCFunctionName(1131)}') + .asFunction(); +//tag=1030 + func(thisCpp, i, n); + } +//tag=1024 + +//tag=1027 +// removeAll(const T & t) + int removeAll(T t) { +//tag=1028 + if (this is QVector) { + final int_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(1132)}') + .asFunction(); +//tag=1031 + return func(thisCpp, (t as int)); + } else { +// Unreachable, but required, due to null safety we need to return something + throw Error(); + } + } +//tag=1024 + +//tag=1027 +// removeAt(int i) + void removeAt(int i) { +//tag=1028 + final void_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(1133)}') + .asFunction(); +//tag=1030 + func(thisCpp, i); + } +//tag=1024 + +//tag=1027 +// removeFirst() + void removeFirst() { +//tag=1028 + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1134)}') + .asFunction(); +//tag=1030 + func(thisCpp); + } +//tag=1024 + +//tag=1027 +// removeLast() + void removeLast() { +//tag=1028 + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1135)}') + .asFunction(); +//tag=1030 + func(thisCpp); + } +//tag=1024 + +//tag=1027 +// removeOne(const T & t) + bool removeOne(T t) { +//tag=1028 + if (this is QVector) { + final bool_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(1136)}') + .asFunction(); +//tag=1029 + return func(thisCpp, (t as int)) != 0; + } else { +// Unreachable, but required, due to null safety we need to return something + throw Error(); + } + } +//tag=1024 + +//tag=1027 +// replace(int i, const T & t) + void replace(int i, T t) { +//tag=1028 + if (this is QVector) { + final void_Func_voidstar_int_int func = _dylib + .lookup< + ffi + .NativeFunction>( + '${getCFunctionName(1137)}') + .asFunction(); +//tag=1030 + func(thisCpp, i, (t as int)); + } + } +//tag=1024 + +//tag=1027 +// reserve(int size) + void reserve(int size) { +//tag=1028 + final void_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(1138)}') + .asFunction(); +//tag=1030 + func(thisCpp, size); + } +//tag=1024 + +//tag=1027 +// resize(int size) + void resize(int size) { +//tag=1028 + final void_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(1139)}') + .asFunction(); +//tag=1030 + func(thisCpp, size); + } +//tag=1024 + +//tag=1027 +// setSharable(bool sharable) + void setSharable(bool sharable) { +//tag=1028 + final void_Func_voidstar_bool func = _dylib + .lookup>( + '${getCFunctionName(1140)}') + .asFunction(); +//tag=1030 + func(thisCpp, sharable ? 1 : 0); + } +//tag=1024 + +//tag=1027 +// shrink_to_fit() + void shrink_to_fit() { +//tag=1028 + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1141)}') + .asFunction(); +//tag=1030 + func(thisCpp); + } +//tag=1024 + +//tag=1027 +// size() const + int size() { +//tag=1028 + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1142)}') + .asFunction(); +//tag=1031 + return func(thisCpp); + } +//tag=1024 + +//tag=1027 +// squeeze() + void squeeze() { +//tag=1028 + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1143)}') + .asFunction(); +//tag=1030 + func(thisCpp); + } +//tag=1024 + +//tag=1027 +// startsWith(const T & t) const + bool startsWith(T t) { +//tag=1028 + if (this is QVector) { + final bool_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(1144)}') + .asFunction(); +//tag=1029 + return func(thisCpp, (t as int)) != 0; + } else { +// Unreachable, but required, due to null safety we need to return something + throw Error(); + } + } +//tag=1024 + +//tag=1027 +// swapItemsAt(int i, int j) + void swapItemsAt(int i, int j) { +//tag=1028 + final void_Func_voidstar_int_int func = _dylib + .lookup>( + '${getCFunctionName(1146)}') + .asFunction(); +//tag=1030 + func(thisCpp, i, j); + } +//tag=1024 + +//tag=1027 +// takeAt(int i) + T takeAt(int i) { +//tag=1028 + if (this is QVector) { + final int_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(1147)}') + .asFunction(); +//tag=1031 + return (func(thisCpp, i) as T); + } else { +// Unreachable, but required, due to null safety we need to return something + throw Error(); + } + } +//tag=1024 + +//tag=1027 +// takeFirst() + T takeFirst() { +//tag=1028 + if (this is QVector) { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1148)}') + .asFunction(); +//tag=1031 + return (func(thisCpp) as T); + } else { +// Unreachable, but required, due to null safety we need to return something + throw Error(); + } + } +//tag=1024 + +//tag=1027 +// takeLast() + T takeLast() { +//tag=1028 + if (this is QVector) { + final int_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(1149)}') + .asFunction(); +//tag=1031 + return (func(thisCpp) as T); + } else { +// Unreachable, but required, due to null safety we need to return something + throw Error(); + } + } +//tag=1024 + +//tag=1027 +// value(int i) const + T value(int i) { +//tag=1028 + if (this is QVector) { + final int_Func_voidstar_int func = _dylib + .lookup>( + '${getCFunctionName(1151)}') + .asFunction(); +//tag=1031 + return (func(thisCpp, i) as T); + } else { +// Unreachable, but required, due to null safety we need to return something + throw Error(); + } + } +//tag=1024 + +//tag=1027 +// value(int i, const T & defaultValue) const + T value_2(int i, T defaultValue) { +//tag=1028 + if (this is QVector) { + final int_Func_voidstar_int_int func = _dylib + .lookup< + ffi + .NativeFunction>( + '${getCFunctionName(1152)}') + .asFunction(); +//tag=1031 + return (func(thisCpp, i, (defaultValue as int)) as T); + } else { +// Unreachable, but required, due to null safety we need to return something + throw Error(); + } + } + +//tag=1022 + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + '${getCFunctionName(-2)}') + .asFunction(); + func(thisCpp); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/Qt.dart b/tests/generated/TestBindings/dart/lib/src/Qt.dart new file mode 100644 index 0000000..8ca340a --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/Qt.dart @@ -0,0 +1,15 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; + +class Qt_EventPriority { + static const HighEventPriority = 1; + static const NormalEventPriority = 0; + static const LowEventPriority = -1; +} diff --git a/tests/generated/TestBindings/dart/lib/src/SimpleObjectStruct.dart b/tests/generated/TestBindings/dart/lib/src/SimpleObjectStruct.dart new file mode 100644 index 0000000..f669460 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/SimpleObjectStruct.dart @@ -0,0 +1,77 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class SimpleObjectStruct implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = true; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory SimpleObjectStruct.fromCache(var cppPointer, + [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + SimpleObjectStruct.fromCppPointer(cppPointer, needsAutoDelete)) + as SimpleObjectStruct; + } + SimpleObjectStruct.fromCppPointer(var cppPointer, + [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + SimpleObjectStruct.init() {} + String getFinalizerName() { + return "c_SimpleObjectStruct_Finalizer"; + } //SimpleObjectStruct() + + SimpleObjectStruct() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_SimpleObjectStruct__constructor') + .asFunction(); + thisCpp = func(); + SimpleObjectStruct.s_dartInstanceByCppPtr[thisCpp.address] = this; + } // receivesStructWithDefaultArg(SimpleObjectStruct arg__1) + receivesStructWithDefaultArg({required SimpleObjectStruct arg__1}) { + final void_Func_voidstar_voidstar func = _dylib + .lookup>( + 'c_SimpleObjectStruct__receivesStructWithDefaultArg_SimpleObjectStruct') + .asFunction(); + func(thisCpp, arg__1 == null ? ffi.nullptr : arg__1.thisCpp); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_SimpleObjectStruct__destructor') + .asFunction(); + func(thisCpp); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/SimpleStruct.dart b/tests/generated/TestBindings/dart/lib/src/SimpleStruct.dart new file mode 100644 index 0000000..bd99add --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/SimpleStruct.dart @@ -0,0 +1,83 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class SimpleStruct implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = true; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory SimpleStruct.fromCache(var cppPointer, [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + SimpleStruct.fromCppPointer(cppPointer, needsAutoDelete)) + as SimpleStruct; + } + SimpleStruct.fromCppPointer(var cppPointer, [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + SimpleStruct.init() {} + String getFinalizerName() { + return "c_SimpleStruct_Finalizer"; + } + + int get value { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_SimpleStruct___get_value') + .asFunction(); + return func(thisCpp); + } + + set value(int value_) { + final void_Func_voidstar_int func = _dylib + .lookup>( + 'c_SimpleStruct___set_value_int') + .asFunction(); + func(thisCpp, value_); + } //SimpleStruct() + + SimpleStruct() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_SimpleStruct__constructor') + .asFunction(); + thisCpp = func(); + SimpleStruct.s_dartInstanceByCppPtr[thisCpp.address] = this; + } + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_SimpleStruct__destructor') + .asFunction(); + func(thisCpp); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/StructWithStructAsMember.dart b/tests/generated/TestBindings/dart/lib/src/StructWithStructAsMember.dart new file mode 100644 index 0000000..d7b1820 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/StructWithStructAsMember.dart @@ -0,0 +1,69 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class StructWithStructAsMember implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = true; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory StructWithStructAsMember.fromCache(var cppPointer, + [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + StructWithStructAsMember.fromCppPointer( + cppPointer, needsAutoDelete)) as StructWithStructAsMember; + } + StructWithStructAsMember.fromCppPointer(var cppPointer, + [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + StructWithStructAsMember.init() {} + String getFinalizerName() { + return "c_TestTargetNS__StructWithStructAsMember_Finalizer"; + } //StructWithStructAsMember() + + StructWithStructAsMember() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_TestTargetNS__StructWithStructAsMember__constructor') + .asFunction(); + thisCpp = func(); + StructWithStructAsMember.s_dartInstanceByCppPtr[thisCpp.address] = this; + } + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_TestTargetNS__StructWithStructAsMember__destructor') + .asFunction(); + func(thisCpp); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/TestBindings.dart b/tests/generated/TestBindings/dart/lib/src/TestBindings.dart new file mode 100644 index 0000000..436cb4a --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/TestBindings.dart @@ -0,0 +1,58 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; + +class GlobalEnum { + static const GlobalEnum_Value = 30; +} + +class MyEnumClass { + static const Value = 1; + static const ValueFoo = 2; +} // globalFunction() + +int globalFunction() { + final int_Func_void func = _dylib + .lookup>('c___globalFunction') + .asFunction(); + return func(); +} // receivesStructAsOptionalArgument(EmptyStruct arg1) + +int receivesStructAsOptionalArgument({required EmptyStruct arg1}) { + final int_Func_voidstar func = _dylib + .lookup>( + 'c___receivesStructAsOptionalArgument_EmptyStruct') + .asFunction(); + return func(arg1 == null ? ffi.nullptr : arg1.thisCpp); +} // receivesStructAsOptionalArgument2(EmptyStruct arg__1) + +int receivesStructAsOptionalArgument2({required EmptyStruct arg__1}) { + final int_Func_voidstar func = _dylib + .lookup>( + 'c___receivesStructAsOptionalArgument2_EmptyStruct') + .asFunction(); + return func(arg__1 == null ? ffi.nullptr : arg__1.thisCpp); +} // receivingPureAbstract(TestTargetNS::PureAbstract * a) + +int receivingPureAbstract(PureAbstract? a) { + final int_Func_voidstar func = _dylib + .lookup>( + 'c_static___receivingPureAbstract_PureAbstract') + .asFunction(); + return func(a == null ? ffi.nullptr : a.thisCpp); +} // returnsPureAbstract() + +PureAbstract returnsPureAbstract() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_static___returnsPureAbstract') + .asFunction(); + ffi.Pointer result = func(); + return PureAbstract.fromCppPointer(result, false); +} diff --git a/tests/generated/TestBindings/dart/lib/src/TestTargetNS.dart b/tests/generated/TestBindings/dart/lib/src/TestTargetNS.dart new file mode 100644 index 0000000..160effa --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/TestTargetNS.dart @@ -0,0 +1,29 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; + +class TestTargetNS_NameSpaceLevelEnum { + static const NameSpaceLevelEnum_Value = 41; +} // namespaceFunctionReturningNamespaceEnum() + +int namespaceFunctionReturningNamespaceEnum() { + final int_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__namespaceFunctionReturningNamespaceEnum') + .asFunction(); + return func(); +} // namespaceLevelGlobalFunction() + +int namespaceLevelGlobalFunction() { + final int_Func_void func = _dylib + .lookup>( + 'c_static_TestTargetNS__namespaceLevelGlobalFunction') + .asFunction(); + return func(); +} diff --git a/tests/generated/TestBindings/dart/lib/src/TypeHelpers.dart b/tests/generated/TestBindings/dart/lib/src/TypeHelpers.dart new file mode 100644 index 0000000..8833fbc --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/TypeHelpers.dart @@ -0,0 +1,266 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +// tag=1053 + +typedef void_Func_voidstar = void Function(ffi.Pointer); +typedef void_Func_voidstar_FFI = ffi.Void Function(ffi.Pointer); +typedef RegisterMethodIsReimplementedCallback = void Function( + ffi.Pointer, ffi.Pointer, int); +typedef RegisterMethodIsReimplementedCallback_FFI = ffi.Void Function( + ffi.Pointer, ffi.Pointer, ffi.Int32); +typedef SignalHandler = void Function( + ffi.Pointer, ffi.Pointer, ffi.Pointer); +typedef SignalHandler_FFI = ffi.Void Function( + ffi.Pointer, ffi.Pointer, ffi.Pointer); +typedef voidstar_Func_void = ffi.Pointer Function(); +typedef voidstar_Func_void_FFI = ffi.Pointer Function(); +typedef int_Func_void = int Function(); +typedef int_Func_void_FFI = ffi.Int32 Function(); +typedef void_Func_int = void Function(int); +typedef void_Func_ffi_Int32_FFI = ffi.Void Function(ffi.Int32); +typedef int_Func_voidstar_voidstar = int Function( + ffi.Pointer, ffi.Pointer); +typedef int_Func_voidstar_voidstar_FFI = ffi.Int32 Function( + ffi.Pointer, ffi.Pointer); +typedef void_Func_voidstar_int = void Function(ffi.Pointer, int); +typedef void_Func_voidstar_ffi_Int32_FFI = ffi.Void Function( + ffi.Pointer, ffi.Int32); +typedef int_Func_voidstar = int Function(ffi.Pointer); +typedef int_Func_voidstar_FFI = ffi.Int32 Function(ffi.Pointer); +typedef void_Func_void = void Function(); +typedef void_Func_void_FFI = ffi.Void Function(); +typedef voidstar_Func_int_int_int_int = ffi.Pointer Function( + int, int, int, int); +typedef voidstar_Func_ffi_Int32_ffi_Int32_ffi_Int32_ffi_Int32_FFI + = ffi.Pointer Function(ffi.Int32, ffi.Int32, ffi.Int32, ffi.Int32); +typedef char_Func_void = int Function(); +typedef char_Func_void_FFI = ffi.Int8 Function(); +typedef voidstar_Func_voidstar = ffi.Pointer Function(ffi.Pointer); +typedef voidstar_Func_voidstar_FFI = ffi.Pointer Function( + ffi.Pointer); +typedef void_Func_voidstar_voidstar = void Function( + ffi.Pointer, ffi.Pointer); +typedef void_Func_voidstar_voidstar_FFI = ffi.Void Function( + ffi.Pointer, ffi.Pointer); +typedef int_Func_int = int Function(int); +typedef int_Func_ffi_Int32_FFI = ffi.Int32 Function(ffi.Int32); +typedef bool_Func_voidstar_int = int Function(ffi.Pointer, int); +typedef bool_Func_voidstar_ffi_Int32_FFI = ffi.Int8 Function( + ffi.Pointer, ffi.Int32); +typedef bool_Func_voidstar = int Function(ffi.Pointer); +typedef bool_Func_voidstar_FFI = ffi.Int8 Function(ffi.Pointer); +typedef int_Func_voidstar_int = int Function(ffi.Pointer, int); +typedef int_Func_voidstar_ffi_Int32_FFI = ffi.Int32 Function( + ffi.Pointer, ffi.Int32); +typedef int_Func_voidstar_int_int = int Function(ffi.Pointer, int, int); +typedef int_Func_voidstar_ffi_Int32_ffi_Int32_FFI = ffi.Int32 Function( + ffi.Pointer, ffi.Int32, ffi.Int32); +typedef void_Func_int_int = void Function(int, int); +typedef void_Func_ffi_Int32_ffi_Int32_FFI = ffi.Void Function( + ffi.Int32, ffi.Int32); +typedef void_Func_string = void Function(ffi.Pointer); +typedef void_Func_string_FFI = ffi.Void Function(ffi.Pointer); +typedef void_Func_voidstar_string = void Function( + ffi.Pointer, ffi.Pointer); +typedef void_Func_voidstar_string_FFI = ffi.Void Function( + ffi.Pointer, ffi.Pointer); +typedef voidstar_Func_voidstar_voidstar = ffi.Pointer Function( + ffi.Pointer, ffi.Pointer); +typedef voidstar_Func_voidstar_voidstar_FFI = ffi.Pointer Function( + ffi.Pointer, ffi.Pointer); +typedef void_Func_voidstar_double = void Function(ffi.Pointer, double); +typedef void_Func_voidstar_ffi_Double_FFI = ffi.Void Function( + ffi.Pointer, ffi.Double); +typedef string_Func_void = ffi.Pointer Function(); +typedef string_Func_void_FFI = ffi.Pointer Function(); +typedef voidstar_Func_int = ffi.Pointer Function(int); +typedef voidstar_Func_ffi_Int32_FFI = ffi.Pointer Function(ffi.Int32); +typedef bool_Func_voidstar_bool = int Function(ffi.Pointer, int); +typedef bool_Func_voidstar_ffi_Int8_FFI = ffi.Int8 Function( + ffi.Pointer, ffi.Int8); +typedef int_Func_voidstar_bool = int Function(ffi.Pointer, int); +typedef int_Func_voidstar_ffi_Int8_FFI = ffi.Int32 Function( + ffi.Pointer, ffi.Int8); +typedef void_Func_voidstar_int_int = void Function(ffi.Pointer, int, int); +typedef void_Func_voidstar_ffi_Int32_ffi_Int32_FFI = ffi.Void Function( + ffi.Pointer, ffi.Int32, ffi.Int32); +typedef voidstar_Func_int_int = ffi.Pointer Function(int, int); +typedef voidstar_Func_ffi_Int32_ffi_Int32_FFI = ffi.Pointer Function( + ffi.Int32, ffi.Int32); +typedef void_Func_voidstar_bool = void Function(ffi.Pointer, int); +typedef void_Func_voidstar_ffi_Int8_FFI = ffi.Void Function( + ffi.Pointer, ffi.Int8); +typedef voidstar_Func_bool = ffi.Pointer Function(int); +typedef voidstar_Func_ffi_Int8_FFI = ffi.Pointer Function(ffi.Int8); +typedef voidstar_Func_string = ffi.Pointer Function(ffi.Pointer); +typedef voidstar_Func_string_FFI = ffi.Pointer Function( + ffi.Pointer); +typedef voidstar_Func_double = ffi.Pointer Function(double); +typedef voidstar_Func_ffi_Double_FFI = ffi.Pointer Function(ffi.Double); +typedef bool_Func_voidstar_voidstar = int Function( + ffi.Pointer, ffi.Pointer); +typedef bool_Func_voidstar_voidstar_FFI = ffi.Int8 Function( + ffi.Pointer, ffi.Pointer); +typedef string_Func_voidstar = ffi.Pointer Function(ffi.Pointer); +typedef string_Func_voidstar_FFI = ffi.Pointer Function( + ffi.Pointer); +typedef voidstar_Func_voidstar_string = ffi.Pointer Function( + ffi.Pointer, ffi.Pointer); +typedef voidstar_Func_voidstar_string_FFI = ffi.Pointer Function( + ffi.Pointer, ffi.Pointer); +typedef voidstar_Func_voidstar_voidstar_int = ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int); +typedef voidstar_Func_voidstar_voidstar_ffi_Int32_FFI = ffi.Pointer + Function(ffi.Pointer, ffi.Pointer, ffi.Int32); +typedef voidstar_Func_voidstar_int_int_int = ffi.Pointer Function( + ffi.Pointer, int, int, int); +typedef voidstar_Func_voidstar_ffi_Int32_ffi_Int32_ffi_Int32_FFI + = ffi.Pointer Function( + ffi.Pointer, ffi.Int32, ffi.Int32, ffi.Int32); +typedef voidstar_Func_voidstar_int = ffi.Pointer Function( + ffi.Pointer, int); +typedef voidstar_Func_voidstar_ffi_Int32_FFI = ffi.Pointer Function( + ffi.Pointer, ffi.Int32); +typedef voidstar_Func_string_int = ffi.Pointer Function( + ffi.Pointer, int); +typedef voidstar_Func_string_ffi_Int32_FFI = ffi.Pointer Function( + ffi.Pointer, ffi.Int32); +typedef int_Func_voidstar_voidstar_int = int Function( + ffi.Pointer, ffi.Pointer, int); +typedef int_Func_voidstar_voidstar_ffi_Int32_FFI = ffi.Int32 Function( + ffi.Pointer, ffi.Pointer, ffi.Int32); +typedef voidstar_Func_voidstar_int_voidstar = ffi.Pointer Function( + ffi.Pointer, int, ffi.Pointer); +typedef voidstar_Func_voidstar_ffi_Int32_voidstar_FFI = ffi.Pointer + Function(ffi.Pointer, ffi.Int32, ffi.Pointer); +typedef voidstar_Func_voidstar_int_string = ffi.Pointer Function( + ffi.Pointer, int, ffi.Pointer); +typedef voidstar_Func_voidstar_ffi_Int32_string_FFI = ffi.Pointer + Function(ffi.Pointer, ffi.Int32, ffi.Pointer); +typedef voidstar_Func_voidstar_int_int = ffi.Pointer Function( + ffi.Pointer, int, int); +typedef voidstar_Func_voidstar_ffi_Int32_ffi_Int32_FFI = ffi.Pointer + Function(ffi.Pointer, ffi.Int32, ffi.Int32); +typedef voidstar_Func_voidstar_voidstar_voidstar = ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, ffi.Pointer); +typedef voidstar_Func_voidstar_voidstar_voidstar_FFI = ffi.Pointer + Function(ffi.Pointer, ffi.Pointer, ffi.Pointer); +typedef voidstar_Func_voidstar_int_int_voidstar = ffi.Pointer Function( + ffi.Pointer, int, int, ffi.Pointer); +typedef voidstar_Func_voidstar_ffi_Int32_ffi_Int32_voidstar_FFI + = ffi.Pointer Function( + ffi.Pointer, ffi.Int32, ffi.Int32, ffi.Pointer); +typedef voidstar_Func_voidstar_voidstar_int_int = ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int, int); +typedef voidstar_Func_voidstar_voidstar_ffi_Int32_ffi_Int32_FFI + = ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, ffi.Int32, ffi.Int32); +typedef bool_Func_voidstar_voidstar_string = int Function( + ffi.Pointer, ffi.Pointer, ffi.Pointer); +typedef bool_Func_voidstar_voidstar_string_FFI = ffi.Int8 Function( + ffi.Pointer, ffi.Pointer, ffi.Pointer); +typedef bool_Func_voidstar_string_voidstar_string = int Function( + ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer); +typedef bool_Func_voidstar_string_voidstar_string_FFI = ffi.Int8 Function( + ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer); +typedef bool_Func_voidstar_voidstar_voidstar = int Function( + ffi.Pointer, ffi.Pointer, ffi.Pointer); +typedef bool_Func_voidstar_voidstar_voidstar_FFI = ffi.Int8 Function( + ffi.Pointer, ffi.Pointer, ffi.Pointer); +typedef bool_Func_voidstar_string = int Function( + ffi.Pointer, ffi.Pointer); +typedef bool_Func_voidstar_string_FFI = ffi.Int8 Function( + ffi.Pointer, ffi.Pointer); +typedef int_Func_voidstar_string = int Function( + ffi.Pointer, ffi.Pointer); +typedef int_Func_voidstar_string_FFI = ffi.Int32 Function( + ffi.Pointer, ffi.Pointer); +typedef bool_Func_voidstar_string_voidstar = int Function( + ffi.Pointer, ffi.Pointer, ffi.Pointer); +typedef bool_Func_voidstar_string_voidstar_FFI = ffi.Int8 Function( + ffi.Pointer, ffi.Pointer, ffi.Pointer); +typedef voidstar_Func_string_string_int = ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int); +typedef voidstar_Func_string_string_ffi_Int32_FFI = ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, ffi.Int32); +typedef double_Func_voidstar_int = double Function(ffi.Pointer, int); +typedef double_Func_voidstar_ffi_Int32_FFI = ffi.Double Function( + ffi.Pointer, ffi.Int32); +typedef double_Func_voidstar = double Function(ffi.Pointer); +typedef double_Func_voidstar_FFI = ffi.Double Function(ffi.Pointer); +typedef bool_Func_void = int Function(); +typedef bool_Func_void_FFI = ffi.Int8 Function(); +typedef void_Func_voidstar_voidstar_int = void Function( + ffi.Pointer, ffi.Pointer, int); +typedef void_Func_voidstar_voidstar_ffi_Int32_FFI = ffi.Void Function( + ffi.Pointer, ffi.Pointer, ffi.Int32); +typedef void_Func_bool = void Function(int); +typedef void_Func_ffi_Int8_FFI = ffi.Void Function(ffi.Int8); +typedef voidstar_Func_string_string_string_int = ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, ffi.Pointer, int); +typedef voidstar_Func_string_string_string_ffi_Int32_FFI + = ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Int32); +typedef voidstar_Func_int_int_int_int_int = ffi.Pointer Function( + int, int, int, int, int); +typedef voidstar_Func_ffi_Int32_ffi_Int32_ffi_Int32_ffi_Int32_ffi_Int32_FFI + = ffi.Pointer Function( + ffi.Int32, ffi.Int32, ffi.Int32, ffi.Int32, ffi.Int32); +typedef voidstar_Func_double_double_double_double_double = ffi.Pointer + Function(double, double, double, double, double); +typedef voidstar_Func_ffi_Double_ffi_Double_ffi_Double_ffi_Double_ffi_Double_FFI + = ffi.Pointer Function( + ffi.Double, ffi.Double, ffi.Double, ffi.Double, ffi.Double); +typedef voidstar_Func_double_double_double_double = ffi.Pointer Function( + double, double, double, double); +typedef voidstar_Func_ffi_Double_ffi_Double_ffi_Double_ffi_Double_FFI + = ffi.Pointer Function( + ffi.Double, ffi.Double, ffi.Double, ffi.Double); +typedef bool_Func_int_int_int_int = int Function(int, int, int, int); +typedef bool_Func_ffi_Int32_ffi_Int32_ffi_Int32_ffi_Int32_FFI = ffi.Int8 + Function(ffi.Int32, ffi.Int32, ffi.Int32, ffi.Int32); +typedef void_Func_voidstar_int_int_int_int_int = void Function( + ffi.Pointer, int, int, int, int, int); +typedef void_Func_voidstar_ffi_Int32_ffi_Int32_ffi_Int32_ffi_Int32_ffi_Int32_FFI + = ffi.Void Function(ffi.Pointer, ffi.Int32, ffi.Int32, ffi.Int32, + ffi.Int32, ffi.Int32); +typedef void_Func_voidstar_double_double_double_double_double = void Function( + ffi.Pointer, double, double, double, double, double); +typedef void_Func_voidstar_ffi_Double_ffi_Double_ffi_Double_ffi_Double_ffi_Double_FFI + = ffi.Void Function(ffi.Pointer, ffi.Double, ffi.Double, ffi.Double, + ffi.Double, ffi.Double); +typedef void_Func_voidstar_int_int_int_int = void Function( + ffi.Pointer, int, int, int, int); +typedef void_Func_voidstar_ffi_Int32_ffi_Int32_ffi_Int32_ffi_Int32_FFI + = ffi.Void Function( + ffi.Pointer, ffi.Int32, ffi.Int32, ffi.Int32, ffi.Int32); +typedef void_Func_voidstar_double_double_double_double = void Function( + ffi.Pointer, double, double, double, double); +typedef void_Func_voidstar_ffi_Double_ffi_Double_ffi_Double_ffi_Double_FFI + = ffi.Void Function( + ffi.Pointer, ffi.Double, ffi.Double, ffi.Double, ffi.Double); +typedef voidstar_Func_voidstar_string_int = ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, int); +typedef voidstar_Func_voidstar_string_ffi_Int32_FFI = ffi.Pointer + Function(ffi.Pointer, ffi.Pointer, ffi.Int32); +typedef char_Func_voidstar_int = int Function(ffi.Pointer, int); +typedef char_Func_voidstar_ffi_Int32_FFI = ffi.Int8 Function( + ffi.Pointer, ffi.Int32); +typedef voidstar_Func_voidstar_int_string_int = ffi.Pointer Function( + ffi.Pointer, int, ffi.Pointer, int); +typedef voidstar_Func_voidstar_ffi_Int32_string_ffi_Int32_FFI + = ffi.Pointer Function( + ffi.Pointer, ffi.Int32, ffi.Pointer, ffi.Int32); +typedef voidstar_Func_voidstar_string_int_string_int = ffi.Pointer + Function(ffi.Pointer, ffi.Pointer, int, ffi.Pointer, int); +typedef voidstar_Func_voidstar_string_ffi_Int32_string_ffi_Int32_FFI + = ffi.Pointer Function(ffi.Pointer, ffi.Pointer, + ffi.Int32, ffi.Pointer, ffi.Int32); +typedef voidstar_Func_voidstar_int_int_string_int = ffi.Pointer Function( + ffi.Pointer, int, int, ffi.Pointer, int); +typedef voidstar_Func_voidstar_ffi_Int32_ffi_Int32_string_ffi_Int32_FFI + = ffi.Pointer Function( + ffi.Pointer, ffi.Int32, ffi.Int32, ffi.Pointer, ffi.Int32); +typedef int_Func_voidstar_double = int Function(ffi.Pointer, double); +typedef int_Func_voidstar_ffi_Double_FFI = ffi.Int32 Function( + ffi.Pointer, ffi.Double); diff --git a/tests/generated/TestBindings/dart/lib/src/UnusedTemplate.dart b/tests/generated/TestBindings/dart/lib/src/UnusedTemplate.dart new file mode 100644 index 0000000..8a91d92 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/UnusedTemplate.dart @@ -0,0 +1,74 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class UnusedTemplate implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = true; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory UnusedTemplate.fromCache(var cppPointer, [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + UnusedTemplate.fromCppPointer(cppPointer, needsAutoDelete)) + as UnusedTemplate; + } + UnusedTemplate.fromCppPointer(var cppPointer, + [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + UnusedTemplate.init() {} + String getCFunctionName(int id) { + return ""; + } + + String getFinalizerName() { + print( + "ERROR: Couldn't find finalizerName for" + this.runtimeType.toString()); + return ""; + } //UnusedTemplate() + + UnusedTemplate() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_UnusedTemplate__constructor') + .asFunction(); + thisCpp = func(); + UnusedTemplate.s_dartInstanceByCppPtr[thisCpp.address] = this; + } + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_UnusedTemplate__destructor') + .asFunction(); + func(thisCpp); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/Virtual1.dart b/tests/generated/TestBindings/dart/lib/src/Virtual1.dart new file mode 100644 index 0000000..f1b44e7 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/Virtual1.dart @@ -0,0 +1,112 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class Virtual1 implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = false; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory Virtual1.fromCache(var cppPointer, [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + Virtual1.fromCppPointer(cppPointer, needsAutoDelete)) as Virtual1; + } + Virtual1.fromCppPointer(var cppPointer, [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + Virtual1.init() {} + String getFinalizerName() { + return "c_Virtual1_Finalizer"; + } //Virtual1() + + Virtual1() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_Virtual1__constructor') + .asFunction(); + thisCpp = func(); + Virtual1.s_dartInstanceByCppPtr[thisCpp.address] = this; + registerCallbacks(); + } // virtualMethod1() + virtualMethod1() { + final void_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(3)) + .asFunction(); + func(thisCpp); + } + + static void virtualMethod1_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = Virtual1.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for Virtual1::virtualMethod1()! (${thisCpp.address})"); + throw Error(); + } + dartInstance.virtualMethod1(); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_Virtual1__destructor') + .asFunction(); + func(thisCpp); + } + + String cFunctionSymbolName(int methodId) { + switch (methodId) { + case 3: + return "c_Virtual1__virtualMethod1"; + } + return ""; + } + + static String methodNameFromId(int methodId) { + switch (methodId) { + case 3: + return "virtualMethod1"; + } + throw Error(); + } + + void registerCallbacks() { + assert(thisCpp != null); + final RegisterMethodIsReimplementedCallback registerCallback = _dylib + .lookup>( + 'c_Virtual1__registerVirtualMethodCallback') + .asFunction(); + final callback3 = ffi.Pointer.fromFunction( + Virtual1.virtualMethod1_calledFromC); + registerCallback(thisCpp, callback3, 3); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/Virtual2.dart b/tests/generated/TestBindings/dart/lib/src/Virtual2.dart new file mode 100644 index 0000000..aec28fe --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/Virtual2.dart @@ -0,0 +1,112 @@ +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../Bindings_ExplicitNamespace1.dart' as ExplicitNamespace1; +import '../Bindings_ExplicitNamespace2.dart' as ExplicitNamespace2; +import '../LibraryLoader.dart'; + +var _dylib = Library.instance().dylib; +final _finalizerFunc = (String name) { + return _dylib + .lookup>(name); +}; + +Map _finalizers = {}; + +class Virtual2 implements ffi.Finalizable { + static var s_dartInstanceByCppPtr = Map(); + var _thisCpp = null; + bool _needsAutoDelete = false; + get thisCpp => _thisCpp; + set thisCpp(var ptr) { + _thisCpp = ptr; + ffi.Pointer ptrvoid = ptr.cast(); + if (_needsAutoDelete) { + final String finalizerName = getFinalizerName(); + if (!_finalizers.keys.contains(runtimeType)) { + _finalizers[finalizerName] = + ffi.NativeFinalizer(_finalizerFunc(finalizerName).cast()); + } + _finalizers[finalizerName]!.attach(this, ptrvoid); + } + } + + static bool isCached(var cppPointer) { + return s_dartInstanceByCppPtr.containsKey(cppPointer.address); + } + + factory Virtual2.fromCache(var cppPointer, [needsAutoDelete = false]) { + return (s_dartInstanceByCppPtr[cppPointer.address] ?? + Virtual2.fromCppPointer(cppPointer, needsAutoDelete)) as Virtual2; + } + Virtual2.fromCppPointer(var cppPointer, [this._needsAutoDelete = false]) { + thisCpp = cppPointer; + } + Virtual2.init() {} + String getFinalizerName() { + return "c_Virtual2_Finalizer"; + } //Virtual2() + + Virtual2() { + final voidstar_Func_void func = _dylib + .lookup>( + 'c_Virtual2__constructor') + .asFunction(); + thisCpp = func(); + Virtual2.s_dartInstanceByCppPtr[thisCpp.address] = this; + registerCallbacks(); + } // virtualMethod2() + virtualMethod2() { + final void_Func_voidstar func = _dylib + .lookup>( + cFunctionSymbolName(1)) + .asFunction(); + func(thisCpp); + } + + static void virtualMethod2_calledFromC(ffi.Pointer thisCpp) { + var dartInstance = Virtual2.s_dartInstanceByCppPtr[thisCpp.address]; + if (dartInstance == null) { + print( + "Dart instance not found for Virtual2::virtualMethod2()! (${thisCpp.address})"); + throw Error(); + } + dartInstance.virtualMethod2(); + } + + void release() { + final void_Func_voidstar func = _dylib + .lookup>( + 'c_Virtual2__destructor') + .asFunction(); + func(thisCpp); + } + + String cFunctionSymbolName(int methodId) { + switch (methodId) { + case 1: + return "c_Virtual2__virtualMethod2"; + } + return ""; + } + + static String methodNameFromId(int methodId) { + switch (methodId) { + case 1: + return "virtualMethod2"; + } + throw Error(); + } + + void registerCallbacks() { + assert(thisCpp != null); + final RegisterMethodIsReimplementedCallback registerCallback = _dylib + .lookup>( + 'c_Virtual2__registerVirtualMethodCallback') + .asFunction(); + final callback1 = ffi.Pointer.fromFunction( + Virtual2.virtualMethod2_calledFromC); + registerCallback(thisCpp, callback1, 1); + } +} diff --git a/tests/generated/TestBindings/dart/lib/src/std.dart b/tests/generated/TestBindings/dart/lib/src/std.dart new file mode 100644 index 0000000..30e4fd4 --- /dev/null +++ b/tests/generated/TestBindings/dart/lib/src/std.dart @@ -0,0 +1,9 @@ +//tag=1052 +import 'dart:ffi' as ffi; +import 'package:ffi/ffi.dart'; +import 'TypeHelpers.dart'; +import '../Bindings.dart'; +import '../FinalizerHelpers.dart'; + +//tag=1051 +var _dylib = Library.instance().dylib; diff --git a/tests/generated/TestBindings/dart/pubspec.lock b/tests/generated/TestBindings/dart/pubspec.lock new file mode 100644 index 0000000..f666aca --- /dev/null +++ b/tests/generated/TestBindings/dart/pubspec.lock @@ -0,0 +1,53 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + clock: + dependency: transitive + description: + name: clock + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" + source: hosted + version: "1.1.1" + ffi: + dependency: "direct main" + description: + name: ffi + sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + intl: + dependency: "direct main" + description: + name: intl + sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + url: "https://pub.dev" + source: hosted + version: "0.18.1" + meta: + dependency: "direct main" + description: + name: meta + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + url: "https://pub.dev" + source: hosted + version: "1.10.0" + path: + dependency: transitive + description: + name: path + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" + source: hosted + version: "1.8.3" + pedantic: + dependency: "direct dev" + description: + name: pedantic + sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602" + url: "https://pub.dev" + source: hosted + version: "1.11.1" +sdks: + dart: ">=3.0.0 <4.0.0" diff --git a/tests/generated/TestBindings/dart/pubspec.yaml b/tests/generated/TestBindings/dart/pubspec.yaml new file mode 100644 index 0000000..eddf6d5 --- /dev/null +++ b/tests/generated/TestBindings/dart/pubspec.yaml @@ -0,0 +1,13 @@ +name: TestBindings +description: Bindings + +environment: + sdk: '>=2.17.0 <3.0.0' + +dependencies: + ffi: + intl: + meta: + +dev_dependencies: + pedantic: ^1.9.0 diff --git a/tests/glue/qvariant.cpp b/tests/glue/qvariant.cpp new file mode 100644 index 0000000..f8eedee --- /dev/null +++ b/tests/glue/qvariant.cpp @@ -0,0 +1,7 @@ +// @snippet qvariant-fromObject + +/** static*/ +QVariant QVariant_wrapper::fromObject(QObject *obj) +{ + return QVariant::fromValue(obj); +} diff --git a/tests/test.cpp b/tests/test.cpp new file mode 100644 index 0000000..a2146eb --- /dev/null +++ b/tests/test.cpp @@ -0,0 +1,84 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#include "test.h" + +#include + +using namespace TestTargetNS; + +int MyBaseClass::s_staticMember = 1; +const int MyBaseClass::s_staticConstMember = 1; + +int DestructorCounter::s_instanceCount = 0; +int MyBaseClass::s_instanceCount = 0; +int MyDerivedClass::s_instanceCount = 0; +int PureAbstract::s_instanceCount = 0; + +TEST_EXPORT int s_myTemplateInstanceCount = 0; + +int MyBaseClass::foo() const +{ + return 42; +} + +int MyBaseClass::bar() const +{ + return 42; +} + +int MyDerivedClass::bar() const +{ + return 43; +} + +int POD::calculateStatic() +{ + qDebug() << Q_FUNC_INFO; + return 42; +} + +int POD::doStuffOnMyClass(MyBaseClass *) +{ + return 42; +} + +struct MemoryLeakChecker +{ + // Since there's no easy way to force GC in Dart, we run this at static-dtors time + // and make sure that there are 0 DestructorCounter instances + ~MemoryLeakChecker() + { + + if (TestTargetNS::DestructorCounter::s_instanceCount != 0 + || TestTargetNS::MyDerivedClass::s_instanceCount != 0 + || TestTargetNS::MyBaseClass::s_instanceCount != 0 + || TestTargetNS::PureAbstract::s_instanceCount != 0 || s_myTemplateInstanceCount != 0) { + qWarning() << "Memory leaks found." << TestTargetNS::DestructorCounter::s_instanceCount + << TestTargetNS::MyDerivedClass::s_instanceCount + << TestTargetNS::MyBaseClass::s_instanceCount + << TestTargetNS::PureAbstract::s_instanceCount << s_myTemplateInstanceCount; + abort(); + } + } +}; + +MyObject::MyObject(QObject *parent) + : QObject(parent) +{ +} + +MyObject::~MyObject() {}; + +int MyObject::virtualFunc() +{ + return 42; +} + +void MyObject::virtualReceivingQString(const QString &) +{ +} + +static MemoryLeakChecker s_memoryLeakChecker; diff --git a/tests/test.h b/tests/test.h new file mode 100644 index 0000000..d4e3d4a --- /dev/null +++ b/tests/test.h @@ -0,0 +1,1149 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#pragma once + +#include "test_exports.h" + +#include +#include +#include +#include + +#include +#include + +extern TEST_EXPORT int s_myTemplateInstanceCount; + +inline void globalReceivingStringView(std::string_view) +{ +} + +enum class MyEnumClass { + Value = 1, + ValueFoo +}; + +struct EmptyStruct +{ +}; + +struct SimpleStruct +{ + int value = 1; +}; + +struct SimpleObjectStruct +{ + void receivesStructWithDefaultArg(SimpleObjectStruct = {}) + { + } + + void receivesStringView(std::string_view) + { + } + + void receivesString(std::string) + { + } + + std::string returnsString() const + { + return {}; + } +}; + +struct NonCopiable +{ + int count() const + { + return 1000; + } + + NonCopiable() = default; + Q_DISABLE_COPY(NonCopiable) +}; + +namespace AnotherNamespace { +// Tests that the wrapper includes +static QString size(QString s) +{ + return s; +} +enum NamespaceLevelEnum { + NamespaceLevelEnum_value1 = 1, + NamespaceLevelEnum_value2 = 2 +}; +Q_DECLARE_FLAGS(NamespaceLevelEnums, NamespaceLevelEnum) + +struct AnotherNamespaceStruct +{ + void receivesEnumerator(NamespaceLevelEnum = NamespaceLevelEnum_value2) + { + } +}; + +enum class MyNamespacedEnumClass { + ValueFoo1 +}; + + +} + +template +struct MyTemplate +{ + T value; + int returnInt() const + { + return 1; + } + + MyTemplate() + { + s_myTemplateInstanceCount++; + } + + MyTemplate returnsTemplate() + { + return {}; + } + + T returnsT() + { + return {}; + } + + MyTemplate returnTemplate2() + { + return {}; + } + + MyTemplate returnTemplate3() + { + return {}; + } + + MyTemplate returnTemplate4() + { + return {}; + } + + MyTemplate(const MyTemplate &other) + { + s_myTemplateInstanceCount++; + } + + ~MyTemplate() + { + s_myTemplateInstanceCount--; + } + + int receivesTemplate(MyTemplate) + { + return 30; + } + + int receivesT(T) + { + return 31; + } + + static void staticInTemplateClass() + { + } +}; + +template +struct MyTemplateWithTwoArgs +{ + T0 value0; + T1 value1; + + int returnInt() const + { + return 1; + } + + MyTemplateWithTwoArgs() + { + s_myTemplateInstanceCount++; + } + + ~MyTemplateWithTwoArgs() + { + s_myTemplateInstanceCount--; + } +}; + +template +struct MyTemplate2 +{ + MyTemplate2 returnTemplate1() + { + return {}; + } + + int count() const + { + return 1000; + } + + void receivesT(T) + { + } + + void assignsT() + { + T a; + T b; + a = b; + } + + T m_value = {}; +}; + +template +struct UnusedTemplate +{ + // For testing that we don't generate these methods, as we don't have any instantiations + bool receivesT(T) const + { + return false; + } + T returnsT() + { + return {}; + } +}; + +/** + * Contains simple C++ function that we call from Dart, for demo/testing purposes. + * This is built as libTestTarget.so. + * The generated bindings for this class are in libMyBindings.so + **/ +namespace TestTargetNS { + + +class TEST_EXPORT PureAbstract +{ +public: + virtual int foo() = 0; + virtual void voidPureAbstract() = 0; + virtual void renamedPureVirtual() = 0; + static void renamedStatic() + { + } + + static int s_instanceCount; + PureAbstract() + { + s_instanceCount++; + } + + virtual ~PureAbstract() + { + s_instanceCount--; + } + + int callVirtualReceivingPointer(SimpleStruct *s) + { + return virtualReceivingPointer(s); + } + + virtual int virtualReceivingPointer(SimpleStruct *s) + { + return 42; + } + + int returnsInt() const + { + return 5; + } + + void flagsWithDefaultArgs(AnotherNamespace::NamespaceLevelEnums options = {}) + { + } + + /// For testing when the derived class overrides without a name ("int = 0") + virtual void unnamedOverriddenDefaultArgCase(int myarg = 0) + { + } +}; + +class TEST_EXPORT DerivedFromPureAbstract : public PureAbstract +{ +public: + DerivedFromPureAbstract() + { + } + + DerivedFromPureAbstract(int) + { + } + + int foo() override + { + return 42; + } + + int nonVirtualCallsVirtual() + { + return foo(); + } + + void voidPureAbstract() override + { + } + + void renamedPureVirtual() override + { + } + + void unnamedOverriddenDefaultArgCase(int = 0) override + { + } + + int indirectionCallsVirtualReceivingStruct(SimpleStruct s) + { + return receivesValueStruct(s); + } + + virtual int receivesValueStruct(SimpleStruct) + { + qDebug() << Q_FUNC_INFO << "receivesValueStruct() C++"; + return 1; + } +}; + +class TEST_EXPORT Derived2FromPureAbstract : public PureAbstract +{ +public: + // Tests that a pure abstract derived from pure abstract still compiles +}; + +struct TEST_EXPORT DestructorCounter +{ + DestructorCounter() + { + s_instanceCount++; + } + + ~DestructorCounter() + { + s_instanceCount--; + } + + static int instanceCount() + { + return s_instanceCount; + } + + static DestructorCounter *newOnTheHeap() + { + return new DestructorCounter(); + } + + static DestructorCounter newOnTheStack() + { + return DestructorCounter(); + } + + static int s_instanceCount; +}; + +class TEST_EXPORT MyBaseClass +{ +public: + enum MyEnum { + MyEnumerator0, + MyEnumerator1 = 1, + MyEnumerator3 = 3 + }; + + enum { + AnonymousEnumerator1 = 1, + AnonymousEnumerator2 = 2, + AnonymousEnumerator3 + }; + + static int s_instanceCount; + MyBaseClass() + { + s_instanceCount++; + } + + explicit MyBaseClass(MyBaseClass *mybaseclassptr) + { + s_instanceCount++; + } + + virtual ~MyBaseClass() + { + s_instanceCount--; + } + + int foo() const; + virtual int bar() const; + virtual int bar2() const + { + return 1; + } + virtual int virtualReceivingInt(int) + { + return 1; + } + bool getBoolFalse() const + { + return false; + } + bool getBoolTrue() const + { + return true; + } + bool getBool(int) const + { + return false; + } + bool setBool(bool b) + { + return b; + } + void hello() + { + } + int sum(int a, int b) + { + return a + b; + } + + int receivesEnum(MyEnum e) + { + return e * 10; + } + + void receivesEnumWithDefaultArg(MyEnum = MyEnumerator0) + { + } + + void receivesintWithDefaultEnumArg(int = MyEnumerator0) + { + } + + void receivesintWithDefaultEnumArg2(int = AnonymousEnumerator1) + { + } + + void receivesintWithDefaultEnumArg3(int = MyBaseClass::MyEnumerator0) + { + } + + void receivesEnumWithDefaultArgNull(MyEnum = {}) + { + // Tests that {} is converted into 0, not to null in dart. + } + + void receivesCharStarStar(const char **) + { + } + + void receivesCharStarStar2(char **) + { + } + + void receivesIntStarStar(int **) + { + } + + void receivesPtr(void *ptr) + { + Q_UNUSED(ptr); + } + + void receivesCharStarStar2(const char *[]) + { + } + + void addQObjects(const QList &) + { + } + + void addReals(QList) + { + } + void addInts(QList) + { + } + + QList returnsReals() const + { + return {}; + } + + qint64 returnsInt64() const + { + return 1; // TODO test a big number + } + + const char **returnsCharStarStar() + { + return nullptr; + } + + int callsVirtual() const + { + return bar(); + } + + int receivesCallback(int (*callback)(int)) + { + return callback(42); + } + + virtual int virtualReceivingBool(bool b) + { + return b ? 10 : 5; + } + + virtual MyTemplate virtualReturnsIntTemplate() + { + return {}; + } + MyTemplate methodReturnsIntTemplate() + { + return {}; + } + + virtual bool virtualReturningBool(bool b) + { + return b; + } + + SimpleStruct nonVirtualReturningStruct() const + { + return virtualReturningStruct(); + } + + virtual SimpleStruct virtualReturningStruct() const + { + return {}; + } + + static void print(const char *msg) + { + qDebug() << msg; + } + static const char *returnsConstChar() + { + return "Hello"; + } + static QString returnsQString() + { + return QString("hello"); + } + + QString receivesAndReturnsQString(const QString &s) + { + return s; + } + + void receivesFloat(float) + { + } + + static MyTemplate returnsIntTemplate() + { + return {}; + } + static MyTemplate returnsDoubleTemplate() + { + return {}; + } + static MyTemplateWithTwoArgs returnsTemplateWithTwoArgs() + { + return {}; + } + + static QList returnsListOfStructPtr() + { + QList list; + list << new SimpleStruct(); + return list; + } + + QList returnsVector() + { + return { 1, 2, 3 }; + } + + void renamedMethod1() + { + } + + virtual void renamedVirtual1() + { + } + + virtual int virtualReceivingOptionalArgument(int optional = 1) + { + return optional; + } + + virtual void virtualWithNoDefaultArgumentInDerived(int optional = 1) + { + Q_UNUSED(optional); + } + + int nonVirtualButOverridden() const + { + // Tests that shadowing works + return 1; + } + + void receivesQFlags(AnotherNamespace::NamespaceLevelEnums) + { + } + + AnotherNamespace::NamespaceLevelEnums returnsQFlags() const + { + return AnotherNamespace::NamespaceLevelEnum_value1; + } + + virtual int nonVirtualInBaseButVirtualInDerived(int i, int j) const + { + return i * j; + } + + + int nonVirtualInBaseButVirtualInDerived(int i) const + { + return 10 * i; + } + + virtual void virtualWithOverload(int i) const + { + } + virtual void virtualWithOverload(int i, int j) const + { + } + + virtual void virtualReceivingCharPtr(char *) + { + // TODO call this in the test. For now it validates that it builds + } + + static void overloadedStatic() + { + } + static void overloadedStatic(int) + { + } + static void overloadedStatic(int, int) + { + } + + static SimpleStruct returnsSimpleStruct(int value) + { + return { value }; + } + + static int s_staticMember; + static const int s_staticConstMember; + + virtual qint64 virtualReturningQint64() + { + // Tests that the virtual callback in dart compiles + return 0; + } + + static int anotherOverloadedStatic(int) + { + // Tests that overloaded and overriden statics with different + // return type compile in dart + return 0; + } + + static inline QString fromStdString(const std::string &) + { + return {}; + } + + void testUnsignedInt(unsigned int) + { + } + unsigned int testUnsignedIntReturn() + { + return 0; + } + + void push(char) + { + } + void push(const char *) + { + } + +protected: + enum ProtectedEnum { + ProtectedEnum_V1 = 1 + }; + + int m_protectedValue = 1; +}; + +class TEST_EXPORT MyDerivedClass : public MyBaseClass +{ +public: + static int s_instanceCount; + MyDerivedClass() + { + s_instanceCount++; + } + + virtual ~MyDerivedClass() + { + s_instanceCount--; + } + + int bar() const override; + int virtual virtualNotInBase() const + { + return 40; + } + + void show() + { + setVisible(true); + paintEvent(); + } + virtual void setVisible(bool b) + { + } + + virtual int receivesDerivedPolymorphic(MyDerivedClass *der) + { + delete der; + return 10; + } + + int alsoCallsVirtual() + { + // Tests that passing a class created in C++ runs the correct dart fromCache() method. + return receivesDerivedPolymorphic(new MyDerivedClass()); + } + + const MyDerivedClass *returnsConstPointer() + { + return this; + } + + MyTemplate2 returnTemplate1() + { + return {}; + } + + const MyTemplate2 &returnTemplate2() + { + static const MyTemplate2 s_foo; + return s_foo; + } + + void virtualWithNoDefaultArgumentInDerived(int optional) override + { + Q_UNUSED(optional); + } + + int nonVirtualButOverridden() const + { + // Tests that shadowing works + return 2; + } + + int receivesProtectedEnum(ProtectedEnum p) + { + return p; + } + + void receivesEnumFromBaseClassWithDefaultValue(int a = MyEnumerator0) + { + } + + static const MyDerivedClass *anotherOverloadedStatic(int) + { + return nullptr; + } + static const MyDerivedClass *anotherOverloadedStatic(int, int) + { + return nullptr; + } + + static AnotherNamespace::NamespaceLevelEnum returnsAnotherNamespaceEnum() + { + return {}; + } + + static AnotherNamespace::AnotherNamespaceStruct returnsAnotherNamespaceStruct() + { + return {}; + } + + static std::vector returnsStdVector() + { + return {}; + } + +protected: + virtual void paintEvent() + { + // Tests an infinit loop when calling a protected method + } +}; + +struct TEST_EXPORT POD +{ + int v1 = 1; + int v2 = 2; + int v3 = 3; + const int v4_const = 4; + + POD() // TODO remove this ctor + { + } + POD(int a, int b, int c, int d) // TODO remove this ctor + : v1(a) + , v2(b) + , v3(c) + , v4_const(d) + { + } + + int calculate() const + { + return v1 * v2 * v3; + } + + void withDefaultAarg(int v = 2) + { + Q_UNUSED(v); + } + + void receivesReservedDartKeyword(int var) + { + Q_UNUSED(var); + } + + static int calculateStatic(); + static int doStuffOnMyClass(MyBaseClass *myarg); + + static POD returnsPOD() + { + return { 10, 20, 30, 40 }; + } + + static POD &returnsReferenceToPOD() + { + static POD s_pod; + return s_pod; + } + + static const POD &returnsConstReferenceToPOD() + { + static const POD s_pod; + return s_pod; + } + + static POD *returnsPointerToPOD() + { + return new POD(); + } + static MyBaseClass *returnsPointerToPolymorphic() + { + return new MyBaseClass(); + } + + static int receivesPODs(POD pod1, POD pod2) + { + return pod1.v1 + pod2.v2; + } + + static int receivesRefPODs(POD &pod1, POD &pod2) + { + pod1.v1 = 10; + pod2.v2 = 10; + return pod1.v1 + pod2.v2; + } + + static int receivesConstRefPODs(const POD &pod1, const POD &pod2) + { + return pod1.v1 + pod2.v2; + } + + static int receivesPointerToPODs(POD *ptrPod1, POD *ptrPod2) + { + return ptrPod1->v1 + ptrPod2->v2; + } + + static int receivesConstPointerToPODs(const POD *ptrPod1, const POD *ptrPod2) + { + return ptrPod1->v1 + ptrPod2->v2; + } + + static char returnsChar() + { + return 'c'; + } + + static const char returnsConstChar() + { + return 'a'; + } + + const int &intByConstRef() const + { + return v1; + } + + int &intRef() + { + return v1; + } + + void receivesNamespaceEnum(int v = AnotherNamespace::NamespaceLevelEnum_value1 + 1) + { + } + + void receivesNamespaceEnum1( + AnotherNamespace::NamespaceLevelEnum = AnotherNamespace::NamespaceLevelEnum_value1) + { + } +}; + +struct StructWithStructAsMember +{ + POD m_pod; +}; + +inline int namespaceLevelGlobalFunction() +{ + return 41; +} + +enum NameSpaceLevelEnum { + NameSpaceLevelEnum_Value = 41 +}; + +inline NameSpaceLevelEnum namespaceFunctionReturningNamespaceEnum() +{ + return NameSpaceLevelEnum_Value; +} + +} // namespace + +namespace EmptyNameSpace { +} + +enum GlobalEnum { + GlobalEnum_Value = 30 +}; + +inline int globalFunction() +{ + return 42; +} + +static TestTargetNS::PureAbstract *returnsPureAbstract() +{ + return new TestTargetNS::DerivedFromPureAbstract(); +} + +static int receivingPureAbstract(TestTargetNS::PureAbstract *a) +{ + return a->foo(); +} + +inline int receivesStructAsOptionalArgument(EmptyStruct arg1 = EmptyStruct()) +{ + return 10; +} + +inline int receivesStructAsOptionalArgument2(EmptyStruct = {}) +{ + return 11; +} + +class TEST_EXPORT MyObject : public QObject +{ + Q_OBJECT +public: + explicit MyObject(QObject *parent = nullptr); + ~MyObject() override; + + virtual int virtualFunc(); + virtual void virtualReceivingQString(const QString &str); + virtual int virtualReturningInt() const + { + return 42; + } + virtual void pureVirtual() = 0; + + virtual const char *virtualMethodReturningConstChar() const + { + return "dartagnan"; + } + + + MyEnumClass returnsEnumClass() + { + return {}; + } + + void receivesEnumClassWithDefaultArg(MyEnumClass foo = MyEnumClass::ValueFoo) + { + } + + void receivesEnumClassWithDefaultArg(AnotherNamespace::MyNamespacedEnumClass foo = + AnotherNamespace::MyNamespacedEnumClass::ValueFoo1) + { + } + +Q_SIGNALS: + void valueChanged(int); +}; + +class DoubleInheritance : public SimpleStruct, public MyObject +{ +public: + int nonVirtualCallsVirtualFrom2ndBase() const + { + // We don't support virtuals in 2nd base class yet + return virtualReturningInt(); + } +}; + +class Virtual1 +{ +public: + virtual void virtualMethod1() + { + } +}; + +class Virtual2 +{ +public: + virtual void virtualMethod2() + { + } +}; + +class DoubleInheritanceFromVirtuals : public Virtual1, public Virtual2 +{ +public: + // Tests that we can inherit from two virtuals +}; + +struct Cyclic2; +struct Cyclic1 +{ + Cyclic1(Cyclic2 *) + { + } + + Cyclic2 *getCyclic2() const + { + return nullptr; + } +}; + +struct Cyclic2 : Cyclic1 +{ + Cyclic1 *getCyclic1() const + { + return nullptr; + } +}; + + +/// A type that's not in typesystem.xml: +struct UnknownType +{ +}; + +class PureAbstractWithUnknownType +{ +public: + // Method that we won't generate bindings for + virtual UnknownType unknownmethod() = 0; + + int getValue() const + { + return 1; + } +}; + +/// Tests two classes with the same name but on different namespaces +/// Uses dartagnan.json to split them into two scopes +namespace NameClashingNS1 { +struct SimpleClash +{ + SimpleClash(int) + { + } + + static int getValueStatic() + { + return 1; + } + + int getValue() + { + return 1; + } +}; +} + +namespace NameClashingNS2 { +struct SimpleClash +{ + SimpleClash(int) + { + } + + static int getValueStatic() + { + return 2; + } + + int getFoo() + { + return 2; + } + + static NameClashingNS1::SimpleClash returnsFromOtherScope() + { + return NameClashingNS1::SimpleClash(1); + } + + static NameClashingNS1::SimpleClash + returnsAndReceivesFromOtherScope(NameClashingNS1::SimpleClash s) + { + return s; + } +}; + +inline SimpleStruct operator+(SimpleStruct one, SimpleStruct) +{ + return one; +} + +} + +class BaseClassWithFinalMethod +{ +public: + virtual void finalMethod() final + { + } +}; diff --git a/tests/test_exports.h b/tests/test_exports.h new file mode 100644 index 0000000..d5ab536 --- /dev/null +++ b/tests/test_exports.h @@ -0,0 +1,14 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +#pragma once + +#include + +#if defined(BUILDING_TEST_LIBRARY) +# define TEST_EXPORT Q_DECL_EXPORT +#else +# define TEST_EXPORT Q_DECL_IMPORT +#endif diff --git a/tests/typesystem.xml b/tests/typesystem.xml new file mode 100644 index 0000000..f6ade67 --- /dev/null +++ b/tests/typesystem.xml @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/utils.dart b/utils.dart new file mode 100644 index 0000000..fb8a046 --- /dev/null +++ b/utils.dart @@ -0,0 +1,230 @@ +/// This file is part of Dartagnan. +/// +/// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +/// SPDX-License-Identifier: MIT + +import 'dart:io' show Platform; +import 'dart:io'; +import 'dart:convert'; + +/// Path list separator (for PATH env var) +final String s_listSeparator = Platform.isWindows ? ";" : ":"; + +/// The name of the env var for runtime library path +final String s_libraryPathEnvVariable = Platform.isWindows + ? "PATH" + : Platform.isLinux + ? "LD_LIBRARY_PATH" + : Platform.isMacOS + ? "DYLD_LIBRARY_PATH" + : ""; + +final String s_qtIncludePath = qtIncludePath(); +final String s_qtLibraryPath = qtLibPath(); + +/** + * Returns the library filename according to the operating system. + */ +String normalizedLibName(String name) { + if (Platform.isWindows) return "${name}.dll"; + if (Platform.isMacOS) return "lib${name}.dylib"; + + return "lib${name}.so"; +} + +/** + * Runs the specified command. Pipes its output to this script's stdout/err. + */ +Future runCommand(String command, List args, + {String? workingDirectory, + Map? env, + bool printOnly = false, + bool silent = false, + bool useGDB = false, + bool forwardStdOut = true, + bool forwardStdErr = true}) async { + if (workingDirectory != null && !silent) + print("Running: cd ${workingDirectory}"); + + if (useGDB) { + args.insertAll(0, ["-ex=run", "--args", command]); + command = "gdb"; + } + + if (!silent) print("Running: ${command} ${args.join(" ")}"); + if (printOnly) return 0; + + Process process = await Process.start(command, args, + workingDirectory: workingDirectory, environment: env) + .then((process) { + if (forwardStdErr) stderr.addStream(process.stderr); + if (forwardStdOut) stdout.addStream(process.stdout); + if (useGDB) process.stdin.addStream(stdin); + + return process; + }); + + return await process.exitCode; +} + +Future runDartFormat(String folder, {bool printOnly = false}) async { + if (Platform.isWindows) { + return runCommand('cmd', ["/C", 'dart', 'format', '--fix', folder], + printOnly: printOnly); + } else { + return runCommand("dart", ['format', '--fix', folder], + printOnly: printOnly); + } +} + +Future runClangFormat(String folder) async { + final String clangFormat = + Platform.environment['DARTAGNAN_CLANG_FORMAT'] ?? "clang-format"; + + var dir = Directory(folder); + final fileEntries = dir.listSync().where((element) => + element.path.endsWith('.h') || element.path.endsWith('.cpp')); + + final List files = fileEntries.map((e) => e.path.toString()).toList(); + final List arguments = ["-i"] + files; + + print("Running ${clangFormat}..."); + try { + return await runCommand(clangFormat, arguments, silent: true); + } catch (e) { + print( + "Exception while running clang-format $e. Skipping as it's not crucial."); + return 0; + } +} + +/** + * Runs "dart pub get" + */ +Future getPackages( + {required String workingDirectory, bool printOnly = false}) async { + if (File("${workingDirectory}/.packages").existsSync()) { + // No need to get packages + return 0; + } + + return runCommand("dart", ["pub", "get"], + workingDirectory: workingDirectory, printOnly: printOnly); +} + +/** + * Runs qmake -query + */ +String qmakeQuery(String key) { + ProcessResult result = Process.runSync('qmake', ['-query']); + + for (String line in result.stdout.toString().split("\n")) { + if (line.startsWith('${key}:')) { + line = line.replaceAll('${key}:', ''); + line = line.trim(); + return line; + } + } + + return ""; +} + +String qtIncludePath() { + return qmakeQuery('QT_INSTALL_HEADERS'); +} + +String qtLibPath() { + return qmakeQuery('QT_INSTALL_LIBS'); +} + +List includeArguments() { + if (Platform.isMacOS) { + return [ + "-I${s_qtLibraryPath}/QtCore.framework/Headers", + "-I${s_qtLibraryPath}/QtGui.framework/Headers", + "-I${s_qtLibraryPath}/QtWidgets.framework/Headers", + "-F${s_qtLibraryPath}" + ]; + } else { + return [ + "-I${s_qtIncludePath}", + "-I${s_qtIncludePath}/QtCore", + "-I${s_qtIncludePath}/QtGui", + "-I${s_qtIncludePath}/QtWidgets" + ]; + } +} + +class TimeStamp { + final String filename; + final String _originalContents; + final String originalTimeStamp; + + static Future create(String filename) async { + final String timestamp = await getTimeStamp(filename); + return TimeStamp._ctor(filename, timestamp); + } + + TimeStamp._ctor(this.filename, this.originalTimeStamp) + : _originalContents = File(filename).readAsStringSync() {} + + /// @brief Returns whether this file has a different contents now + bool wasModified() { + return File(filename).readAsStringSync() != _originalContents; + } + + static Future getTimeStamp(String filename) async { + Process process = await Process.start("stat", ['-c', '%y', filename]); + + String result = ""; + await for (var line in process.stdout.transform(utf8.decoder)) { + result += line; + } + await process.exitCode; + return result.trim(); + } + + Future restoreTimeStamp() async { + return await runCommand("touch", ['-d', '${originalTimeStamp}', filename], + silent: true) == + 0; + } +} + +class TimeStamps { + final String path; + var _timestamps = []; + + TimeStamps(this.path) {} + + void create() async { + final dir = Directory(path); + + dir.list(recursive: true).forEach((entry) async { + if (entry.path.endsWith('.cpp') || entry.path.endsWith('.h')) { + _timestamps.add(await TimeStamp.create(entry.path)); + } + }); + } + + /// @brief Returns the list of files which have a different contents now + List modifiedFiles() { + return _timestamps.where((t) => t.wasModified()).toList(); + } + + /// @brief Returns the list of files which still have the same contents + List unmodifiedFiles() { + return _timestamps.where((t) => !t.wasModified()).toList(); + } + + /// @brief restores the timestams of all files which weren't modified + Future restoreTimeStamps() async { + for (final file in unmodifiedFiles()) { + if (!await file.restoreTimeStamp()) { + return false; + } + } + + return true; + } +} diff --git a/vscode.code-workspace b/vscode.code-workspace new file mode 100644 index 0000000..18bd51f --- /dev/null +++ b/vscode.code-workspace @@ -0,0 +1,36 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": { + "files.trimTrailingWhitespace": true, + "editor.formatOnSave": true, + "clangd.arguments": [ + "-header-insertion=never" + ], + "cmake.copyCompileCommands": "${workspaceFolder}/compile_commands.json" + }, + "launch": { + "version": "0.2.0", + "configurations": [ + { + "name": "gdb-shiboken6", + "type": "lldb", + "request": "launch", + "program": "${workspaceFolder}/build-dev/3rdparty/shiboken/sources/shiboken6/generator/shiboken6", + "args": [ + "--output-directory=/dartagnan/tests/generated/", + "--generator-set=dart", + "--skip-deprecated", + "-I/usr/include/x86_64-linux-gnu/qt6/", + "-I/usr/include/x86_64-linux-gnu/qt6/QtCore/", + "bindings_global.h", + "typesystem.xml" + ], + "cwd": "${workspaceFolder}/tests" + } + ] + } +} \ No newline at end of file